hytos / ID2.Manager / ID2.Manager.Controller / Controllers / ProjectController.cs @ 3af65061
이력 | 보기 | 이력해설 | 다운로드 (3.73 KB)
1 |
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 |
public ProjectController() : base() { } |
15 |
|
16 |
public ProjectController(ID2ProjectInfo id2Info) : base(id2Info) { } |
17 |
|
18 |
public IEnumerable<ProjectInfo> GetAllProjectList() |
19 |
{ |
20 |
try |
21 |
{ |
22 |
using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR)) |
23 |
{ |
24 |
var id2Project = new ID2Controller().GetID2ProjectList(); |
25 |
var allProject = rep.GetAllProjectList(); |
26 |
|
27 |
return from mg in allProject |
28 |
join id2 in id2Project on mg.Code equals id2.Name into gj |
29 |
from prjs in gj.DefaultIfEmpty() |
30 |
select new ProjectInfo() |
31 |
{ |
32 |
ProjectID = mg.ProjectID, |
33 |
Code = mg.Code, |
34 |
Name = mg.Name, |
35 |
Description = mg.Description, |
36 |
ID2Path = prjs?.Path ?? null, |
37 |
GroupID = mg.GroupID, |
38 |
GroupName = mg.GroupName, |
39 |
Team = mg.Team, |
40 |
Port = mg.Port, |
41 |
Level = mg.Level, |
42 |
ID2Info = prjs ?? new ID2ProjectInfo(), |
43 |
}; |
44 |
} |
45 |
} |
46 |
catch (Exception ex) |
47 |
{ |
48 |
throw ex; |
49 |
} |
50 |
} |
51 |
|
52 |
public ProjectInfo GetProjectInfo(string ProjectID) |
53 |
{ |
54 |
try |
55 |
{ |
56 |
using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR)) |
57 |
{ |
58 |
var id2Project = new ID2Controller().GetID2ProjectList(); |
59 |
var project = rep.GetProjectInfo(ProjectID); |
60 |
|
61 |
var id2 = id2Project.Where(x => x.Name.Equals(project.Code)).FirstOrDefault(); |
62 |
project.ID2Path = id2?.Path ?? null; |
63 |
project.ID2Info = id2 ?? new ID2ProjectInfo(); |
64 |
|
65 |
return rep.GetProjectInfo(ProjectID); |
66 |
} |
67 |
} |
68 |
catch (Exception ex) |
69 |
{ |
70 |
throw ex; |
71 |
} |
72 |
} |
73 |
|
74 |
public bool SetProjectData(ProjectInfo projectInfo, List<ID2ProjectInfo> id2ProjectList) |
75 |
{ |
76 |
try |
77 |
{ |
78 |
using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR)) |
79 |
{ |
80 |
return rep.SetProjectData(projectInfo, id2ProjectList); |
81 |
} |
82 |
} |
83 |
catch (Exception ex) |
84 |
{ |
85 |
throw ex; |
86 |
} |
87 |
} |
88 |
|
89 |
public bool SetProjectGroupData(ProjectInfo projectInfo) |
90 |
{ |
91 |
try |
92 |
{ |
93 |
using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR)) |
94 |
{ |
95 |
return rep.SetProjectGroupData(projectInfo); |
96 |
} |
97 |
} |
98 |
catch (Exception ex) |
99 |
{ |
100 |
throw ex; |
101 |
} |
102 |
} |
103 |
|
104 |
//ID2 |
105 |
public string GetID2PortByProject() |
106 |
{ |
107 |
try |
108 |
{ |
109 |
using (ProjectRepository rep = new ProjectRepository(this._ID2CONNSTR)) |
110 |
{ |
111 |
return rep.GetID2PortByProject(); |
112 |
} |
113 |
} |
114 |
catch (Exception ex) |
115 |
{ |
116 |
throw ex; |
117 |
} |
118 |
} |
119 |
} |
120 |
} |