PageRenderTime 371ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/IssueTracker/IssueTracker.Service/IssueTrackerService.cs

#
C# | 520 lines | 356 code | 161 blank | 3 comment | 2 complexity | 8589d2288c86b2f0e60ca7c553cf6d56 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.ServiceModel;
  6. using IssueTracker.Business.BO;
  7. using IssueTracker.Business.Entity;
  8. namespace IssueTracker.Service
  9. {
  10. [ServiceBehavior(UseSynchronizationContext = false,
  11. ConcurrencyMode = ConcurrencyMode.Multiple,
  12. InstanceContextMode = InstanceContextMode.PerCall)]
  13. public class IssueTrackerService: IIssueTrackerService
  14. {
  15. #region ProjectBO
  16. public Project CreateProject(Project project)
  17. {
  18. ProjectBO bo = new ProjectBO();
  19. return bo.AddNew(project);
  20. }
  21. public Project UpdateProject(Project project)
  22. {
  23. ProjectBO bo = new ProjectBO();
  24. return bo.UpdateProject(project);
  25. }
  26. public void DeleteProject(Project project)
  27. {
  28. ProjectBO bo = new ProjectBO();
  29. bo.DeleteProject(project);
  30. }
  31. public IEnumerable<Project> ListProjects()
  32. {
  33. ProjectBO bo = new ProjectBO();
  34. return bo.ListProjects();
  35. }
  36. public Project GetProject(int id)
  37. {
  38. ProjectBO bo = new ProjectBO();
  39. return bo.GetProject(id);
  40. }
  41. #endregion
  42. #region ProjectMemberBO
  43. public ProjectMember CreateProjectMember(ProjectMember entity)
  44. {
  45. ProjectMemberBO bo = new ProjectMemberBO();
  46. return bo.AddNew(entity);
  47. }
  48. public ProjectMember UpdateProjectMember(ProjectMember entity)
  49. {
  50. ProjectMemberBO bo = new ProjectMemberBO();
  51. return bo.UpdateProjectMember(entity);
  52. }
  53. public void DeleteProjectMember(ProjectMember entity)
  54. {
  55. ProjectMemberBO bo = new ProjectMemberBO();
  56. bo.DeleteProjectMember(entity);
  57. }
  58. public IEnumerable<ProjectMember> ListProjectMembers()
  59. {
  60. ProjectMemberBO bo = new ProjectMemberBO();
  61. return bo.ListProjectMembers();
  62. }
  63. public ProjectMember GetProjectMember(int id)
  64. {
  65. ProjectMemberBO bo = new ProjectMemberBO();
  66. return bo.GetProjectMember(id);
  67. }
  68. #endregion
  69. #region ProjectCustomTypeBO Implementation
  70. public ProjectCustomType CreateProjectCustomType(ProjectCustomType entity)
  71. {
  72. ProjectCustomTypeBO bo = new ProjectCustomTypeBO();
  73. return bo.AddNew(entity);
  74. }
  75. public ProjectCustomType UpdateProjectCustomType(ProjectCustomType entity)
  76. {
  77. ProjectCustomTypeBO bo = new ProjectCustomTypeBO();
  78. return bo.UpdateProjectCustomType(entity);
  79. }
  80. public void DeleteProjectCustomType(ProjectCustomType entity)
  81. {
  82. ProjectCustomTypeBO bo = new ProjectCustomTypeBO();
  83. bo.DeleteProjectCustomType(entity);
  84. }
  85. public IEnumerable<ProjectCustomType> ListProjectCustomTypes()
  86. {
  87. ProjectCustomTypeBO bo = new ProjectCustomTypeBO();
  88. return bo.ListProjectCustomTypes();
  89. }
  90. public ProjectCustomType GetProjectCustomType(int id)
  91. {
  92. ProjectCustomTypeBO bo = new ProjectCustomTypeBO();
  93. return bo.GetProjectCustomType(id);
  94. }
  95. #endregion
  96. #region ProjectCustomTypeColumnBO Implementation
  97. public ProjectCustomTypeColumn CreateProjectCustomTypeColumn(ProjectCustomTypeColumn entity)
  98. {
  99. ProjectCustomTypeColumnBO bo = new ProjectCustomTypeColumnBO();
  100. return bo.AddNew(entity);
  101. }
  102. public ProjectCustomTypeColumn UpdateProjectCustomTypeColumn(ProjectCustomTypeColumn entity)
  103. {
  104. ProjectCustomTypeColumnBO bo = new ProjectCustomTypeColumnBO();
  105. return bo.UpdateProjectCustomTypeColumn(entity);
  106. }
  107. public void DeleteProjectCustomTypeColumn(ProjectCustomTypeColumn entity)
  108. {
  109. ProjectCustomTypeColumnBO bo = new ProjectCustomTypeColumnBO();
  110. bo.DeleteProjectCustomTypeColumn(entity);
  111. }
  112. public IEnumerable<ProjectCustomTypeColumn> ListProjectCustomTypeColumns()
  113. {
  114. ProjectCustomTypeColumnBO bo = new ProjectCustomTypeColumnBO();
  115. return bo.ListProjectCustomTypeColumns();
  116. }
  117. public ProjectCustomTypeColumn GetProjectCustomTypeColumn(int id)
  118. {
  119. ProjectCustomTypeColumnBO bo = new ProjectCustomTypeColumnBO();
  120. return bo.GetProjectCustomTypeColumn(id);
  121. }
  122. #endregion
  123. #region IssueBO Implementation
  124. public Issue CreateIssue(Issue entity)
  125. {
  126. IssueBO bo = new IssueBO();
  127. return bo.AddNew(entity);
  128. }
  129. public Issue UpdateIssue(Issue entity)
  130. {
  131. IssueBO bo = new IssueBO();
  132. return bo.UpdateIssue(entity);
  133. }
  134. public Issue UpdateWorkflowStatus(string issueId, string action)
  135. {
  136. IssueBO bo = new IssueBO();
  137. Issue returnIssue = bo.GetIssue(new Guid(issueId));
  138. switch (action)
  139. {
  140. case "ValidateIssue":
  141. returnIssue.CurrentStateName = "Pending Solution";
  142. break;
  143. case "RejectIssue":
  144. returnIssue.CurrentStateName = "Issue Closed";
  145. break;
  146. case "SolutionCompleted":
  147. returnIssue.CurrentStateName = "Pending Testing";
  148. break;
  149. case "SolutionAccepted":
  150. returnIssue.CurrentStateName = "Issue Closed";
  151. break;
  152. case "SolutionRejected":
  153. returnIssue.CurrentStateName = "Pending Solution";
  154. break;
  155. }
  156. return bo.UpdateIssue(returnIssue);
  157. }
  158. public void DeleteIssue(Issue entity)
  159. {
  160. IssueBO bo = new IssueBO();
  161. bo.DeleteIssue(entity);
  162. }
  163. public IEnumerable<Issue> ListIssues()
  164. {
  165. IssueBO bo = new IssueBO();
  166. return bo.ListIssues();
  167. }
  168. public IEnumerable<Issue> SearchIssues(Issue issue)
  169. {
  170. IssueBO bo = new IssueBO();
  171. return bo.SearchIssues(issue);
  172. }
  173. public Issue GetIssue(System.Guid id)
  174. {
  175. IssueBO bo = new IssueBO();
  176. return bo.GetIssue(id);
  177. }
  178. public Issue GetIssueByWorkflowInstanceid(System.Guid workflowInstanceId)
  179. {
  180. IssueBO bo = new IssueBO();
  181. return bo.ListIssueByWorfklowInstanceId(workflowInstanceId);
  182. }
  183. public IEnumerable<Issue> TaskList(string userName, string stateName)
  184. {
  185. IssueBO bo = new IssueBO();
  186. return bo.TaskList(userName, stateName);
  187. }
  188. #endregion
  189. #region IssueTaskBO Implementation
  190. public IssueTask CreateIssueTask(IssueTask entity)
  191. {
  192. IssueTaskBO bo = new IssueTaskBO();
  193. return bo.AddNew(entity);
  194. }
  195. public IssueTask UpdateIssueTask(IssueTask entity)
  196. {
  197. IssueTaskBO bo = new IssueTaskBO();
  198. return bo.UpdateIssueTask(entity);
  199. }
  200. public void DeleteIssueTask(IssueTask entity)
  201. {
  202. IssueTaskBO bo = new IssueTaskBO();
  203. bo.DeleteIssueTask(entity);
  204. }
  205. public IEnumerable<IssueTask> ListIssueTasks()
  206. {
  207. IssueTaskBO bo = new IssueTaskBO();
  208. return bo.ListIssueTasks();
  209. }
  210. public IssueTask GetIssueTask(System.Guid id)
  211. {
  212. IssueTaskBO bo = new IssueTaskBO();
  213. return bo.GetIssueTask(id);
  214. }
  215. #endregion
  216. #region IssueAttachmentBO Implementation
  217. public IssueAttachment CreateIssueAttachment(IssueAttachment entity)
  218. {
  219. IssueAttachmentBO bo = new IssueAttachmentBO();
  220. return bo.AddNew(entity);
  221. }
  222. public IssueAttachment UpdateIssueAttachment(IssueAttachment entity)
  223. {
  224. IssueAttachmentBO bo = new IssueAttachmentBO();
  225. return bo.UpdateIssueAttachment(entity);
  226. }
  227. public void DeleteIssueAttachment(IssueAttachment entity)
  228. {
  229. IssueAttachmentBO bo = new IssueAttachmentBO();
  230. bo.DeleteIssueAttachment(entity);
  231. }
  232. public IEnumerable<IssueAttachment> ListIssueAttachments()
  233. {
  234. IssueAttachmentBO bo = new IssueAttachmentBO();
  235. return bo.ListIssueAttachments();
  236. }
  237. public IssueAttachment GetIssueAttachment(System.Guid id)
  238. {
  239. IssueAttachmentBO bo = new IssueAttachmentBO();
  240. return bo.GetIssueAttachment(id);
  241. }
  242. #endregion
  243. #region IssueCustomTypeValueBO Implementation
  244. public IssueCustomTypeValue CreateIssueCustomTypeValue(IssueCustomTypeValue entity)
  245. {
  246. IssueCustomTypeValueBO bo = new IssueCustomTypeValueBO();
  247. return bo.AddNew(entity);
  248. }
  249. public IssueCustomTypeValue UpdateIssueCustomTypeValue(IssueCustomTypeValue entity)
  250. {
  251. IssueCustomTypeValueBO bo = new IssueCustomTypeValueBO();
  252. return bo.UpdateIssueCustomTypeValue(entity);
  253. }
  254. public void DeleteIssueCustomTypeValue(IssueCustomTypeValue entity)
  255. {
  256. IssueCustomTypeValueBO bo = new IssueCustomTypeValueBO();
  257. bo.DeleteIssueCustomTypeValue(entity);
  258. }
  259. public IEnumerable<IssueCustomTypeValue> ListIssueCustomTypeValues()
  260. {
  261. IssueCustomTypeValueBO bo = new IssueCustomTypeValueBO();
  262. return bo.ListIssueCustomTypeValues();
  263. }
  264. public IssueCustomTypeValue GetIssueCustomTypeValue(System.Guid id)
  265. {
  266. IssueCustomTypeValueBO bo = new IssueCustomTypeValueBO();
  267. return bo.GetIssueCustomTypeValue(id);
  268. }
  269. #endregion
  270. #region IssueWfHistoryBO Implementation
  271. public IssueWfHistory CreateIssueWfHistory(IssueWfHistory entity)
  272. {
  273. IssueWfHistoryBO bo = new IssueWfHistoryBO();
  274. return bo.AddNew(entity);
  275. }
  276. public IssueWfHistory UpdateIssueWfHistory(IssueWfHistory entity)
  277. {
  278. IssueWfHistoryBO bo = new IssueWfHistoryBO();
  279. return bo.UpdateIssueWfHistory(entity);
  280. }
  281. public void DeleteIssueWfHistory(IssueWfHistory entity)
  282. {
  283. IssueWfHistoryBO bo = new IssueWfHistoryBO();
  284. bo.DeleteIssueWfHistory(entity);
  285. }
  286. public IEnumerable<IssueWfHistory> ListIssueWfHistories()
  287. {
  288. IssueWfHistoryBO bo = new IssueWfHistoryBO();
  289. return bo.ListIssueWfHistorys();
  290. }
  291. public IssueWfHistory GetIssueWfHistory(System.Guid id)
  292. {
  293. IssueWfHistoryBO bo = new IssueWfHistoryBO();
  294. return bo.GetIssueWfHistory(id);
  295. }
  296. #endregion
  297. #region IIssueTrackerService Members
  298. public IEnumerable<ProjectCustomType> ListProjectCustomTypesByRef(int reference)
  299. {
  300. ProjectCustomTypeBO bo = new ProjectCustomTypeBO();
  301. return bo.ListProjectCustomTypesByRef(reference);
  302. }
  303. public IEnumerable<ProjectCustomTypeColumn> ListProjectCustomTypeColumnsByRef(int reference)
  304. {
  305. ProjectCustomTypeColumnBO bo = new ProjectCustomTypeColumnBO();
  306. return bo.ListProjectCustomTypeColumnsByRef(reference);
  307. }
  308. public IEnumerable<ProjectMember> ListProjectMembersByRef(int reference)
  309. {
  310. ProjectMemberBO bo = new ProjectMemberBO();
  311. return bo.ListProjectMembersByRef(reference);
  312. }
  313. public IEnumerable<IssueAttachment> ListIssueAttachmentsByRef(Guid reference)
  314. {
  315. IssueAttachmentBO bo = new IssueAttachmentBO();
  316. return bo.ListIssueAttachementsByRef(reference);
  317. }
  318. public IEnumerable<IssueCustomTypeValue> ListIssueCustomTypeValuesByRef(Guid reference)
  319. {
  320. IssueCustomTypeValueBO bo = new IssueCustomTypeValueBO();
  321. return bo.ListIssueCustomTypeValuesByRef(reference);
  322. }
  323. public IEnumerable<IssueTask> ListIssueTasksByRef(Guid reference)
  324. {
  325. IssueTaskBO bo = new IssueTaskBO();
  326. return bo.ListIssueTasksByRef(reference);
  327. }
  328. public IEnumerable<IssueWfHistory> ListIssueWfHistoriesByRef(Guid reference)
  329. {
  330. IssueWfHistoryBO bo = new IssueWfHistoryBO();
  331. return bo.ListIssueWfHistoriesByRef(reference);
  332. }
  333. #endregion
  334. #region "helper methods"
  335. public IDictionary<string, string> GetEventList(string currentStateName)
  336. {
  337. //TODO: Haven't figure out to do it dynamically, hard code first
  338. //http://dotnetperls.com/Content/Dictionary-Keys.aspx for how to use IDictionary object
  339. //It is a value pair of Action Name and the Workflow Activity to trigger
  340. IDictionary<string, string> returnEventList = new Dictionary<string, string>();
  341. switch (currentStateName)
  342. {
  343. case "Pending Approval":
  344. returnEventList.Add("Approval", "IssueApproved");
  345. returnEventList.Add("Reject", "IssueRejected");
  346. break;
  347. case "Pending Solution":
  348. returnEventList.Add("Complete", "SolutionCompleted");
  349. break;
  350. case "Pending Testing":
  351. returnEventList.Add("Accept", "SolutionAccepted");
  352. returnEventList.Add("Reject", "SolutionRejected");
  353. break;
  354. }
  355. return returnEventList;
  356. }
  357. #endregion
  358. }
  359. }