hytos / ID2.Manager / ID2.Manager.Controller / Controllers / ProjectController.cs @ dfb9a03c
이력 | 보기 | 이력해설 | 다운로드 (4.24 KB)
1 | cab8a4a1 | yoush97 | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Threading.Tasks; |
||
6 | |||
7 | using ID2.Manager.Data.Models; |
||
8 | using ID2.Manager.Dapper.Repository; |
||
9 | |||
10 | namespace ID2.Manager.Controller.Controllers |
||
11 | { |
||
12 | public class ProjectController : BaseController |
||
13 | { |
||
14 | 3af65061 | yoush97 | public ProjectController() : base() { } |
15 | |||
16 | public ProjectController(ID2ProjectInfo id2Info) : base(id2Info) { } |
||
17 | |||
18 | 87bcedb4 | yoush97 | public IEnumerable<ProjectInfo> GetAllProjectList() |
19 | { |
||
20 | 82705273 | yoush97 | try |
21 | 87bcedb4 | yoush97 | { |
22 | 82705273 | yoush97 | using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR)) |
23 | { |
||
24 | var id2Project = new ID2Controller().GetID2ProjectList(); |
||
25 | var allProject = rep.GetAllProjectList(); |
||
26 | 87bcedb4 | yoush97 | |
27 | 9f0257a6 | yoush97 | foreach (var id2Prj in id2Project) |
28 | { |
||
29 | string ID2Port = string.Empty; |
||
30 | try |
||
31 | { |
||
32 | ID2Port = new ProjectController(id2Prj).GetID2PortByProject(); |
||
33 | } |
||
34 | catch { } |
||
35 | if (!int.TryParse(ID2Port, out int id2Port)) |
||
36 | id2Port = 2549; |
||
37 | id2Prj.Port = id2Port; |
||
38 | } |
||
39 | |||
40 | 82705273 | yoush97 | return from mg in allProject |
41 | join id2 in id2Project on mg.Code equals id2.Name into gj |
||
42 | from prjs in gj.DefaultIfEmpty() |
||
43 | select new ProjectInfo() |
||
44 | { |
||
45 | ProjectID = mg.ProjectID, |
||
46 | Code = mg.Code, |
||
47 | Name = mg.Name, |
||
48 | Description = mg.Description, |
||
49 | ID2Path = prjs?.Path ?? null, |
||
50 | GroupID = mg.GroupID, |
||
51 | GroupName = mg.GroupName, |
||
52 | a8981c30 | yoush97 | Team = mg.Team, |
53 | 9f0257a6 | yoush97 | Port = prjs?.Port, |
54 | 82705273 | yoush97 | Level = mg.Level, |
55 | ID2Info = prjs ?? new ID2ProjectInfo(), |
||
56 | }; |
||
57 | } |
||
58 | } |
||
59 | catch (Exception ex) |
||
60 | { |
||
61 | throw ex; |
||
62 | cab8a4a1 | yoush97 | } |
63 | } |
||
64 | |||
65 | public ProjectInfo GetProjectInfo(string ProjectID) |
||
66 | { |
||
67 | 82705273 | yoush97 | try |
68 | cab8a4a1 | yoush97 | { |
69 | 82705273 | yoush97 | using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR)) |
70 | { |
||
71 | var id2Project = new ID2Controller().GetID2ProjectList(); |
||
72 | var project = rep.GetProjectInfo(ProjectID); |
||
73 | 1abdd7c3 | yoush97 | |
74 | 82705273 | yoush97 | var id2 = id2Project.Where(x => x.Name.Equals(project.Code)).FirstOrDefault(); |
75 | project.ID2Path = id2?.Path ?? null; |
||
76 | project.ID2Info = id2 ?? new ID2ProjectInfo(); |
||
77 | 1abdd7c3 | yoush97 | |
78 | 82705273 | yoush97 | return rep.GetProjectInfo(ProjectID); |
79 | } |
||
80 | } |
||
81 | catch (Exception ex) |
||
82 | { |
||
83 | throw ex; |
||
84 | cab8a4a1 | yoush97 | } |
85 | } |
||
86 | a23d0a0c | yoush97 | |
87 | public bool SetProjectData(ProjectInfo projectInfo, List<ID2ProjectInfo> id2ProjectList) |
||
88 | { |
||
89 | 82705273 | yoush97 | try |
90 | a23d0a0c | yoush97 | { |
91 | 82705273 | yoush97 | using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR)) |
92 | { |
||
93 | return rep.SetProjectData(projectInfo, id2ProjectList); |
||
94 | } |
||
95 | } |
||
96 | catch (Exception ex) |
||
97 | { |
||
98 | throw ex; |
||
99 | a23d0a0c | yoush97 | } |
100 | } |
||
101 | |||
102 | public bool SetProjectGroupData(ProjectInfo projectInfo) |
||
103 | { |
||
104 | 82705273 | yoush97 | try |
105 | { |
||
106 | using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR)) |
||
107 | { |
||
108 | return rep.SetProjectGroupData(projectInfo); |
||
109 | } |
||
110 | } |
||
111 | catch (Exception ex) |
||
112 | a23d0a0c | yoush97 | { |
113 | 82705273 | yoush97 | throw ex; |
114 | a23d0a0c | yoush97 | } |
115 | } |
||
116 | 3af65061 | yoush97 | |
117 | //ID2 |
||
118 | public string GetID2PortByProject() |
||
119 | { |
||
120 | try |
||
121 | { |
||
122 | using (ProjectRepository rep = new ProjectRepository(this._ID2CONNSTR)) |
||
123 | { |
||
124 | return rep.GetID2PortByProject(); |
||
125 | } |
||
126 | } |
||
127 | catch (Exception ex) |
||
128 | { |
||
129 | throw ex; |
||
130 | } |
||
131 | } |
||
132 | cab8a4a1 | yoush97 | } |
133 | } |