프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager.Controller / Controllers / ProjectController.cs @ d8bd4799

이력 | 보기 | 이력해설 | 다운로드 (3.23 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 87bcedb4 yoush97
        public IEnumerable<ProjectInfo> GetAllProjectList()
15
        {
16 82705273 yoush97
            try
17 87bcedb4 yoush97
            {
18 82705273 yoush97
                using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR))
19
                {
20
                    var id2Project = new ID2Controller().GetID2ProjectList();
21
                    var allProject = rep.GetAllProjectList();
22 87bcedb4 yoush97
23 82705273 yoush97
                    return from mg in allProject
24
                           join id2 in id2Project on mg.Code equals id2.Name into gj
25
                           from prjs in gj.DefaultIfEmpty()
26
                           select new ProjectInfo()
27
                           {
28
                               ProjectID = mg.ProjectID,
29
                               Code = mg.Code,
30
                               Name = mg.Name,
31
                               Description = mg.Description,
32
                               ID2Path = prjs?.Path ?? null,
33
                               GroupID = mg.GroupID,
34
                               GroupName = mg.GroupName,
35 a8981c30 yoush97
                               Team = mg.Team,
36 2cd9327e yoush97
                               Port = mg.Port,
37 82705273 yoush97
                               Level = mg.Level,
38
                               ID2Info = prjs ?? new ID2ProjectInfo(),
39
                           };
40
                }
41
            }
42
            catch (Exception ex)
43
            {
44
                throw ex;
45 cab8a4a1 yoush97
            }
46
        }
47
48
        public ProjectInfo GetProjectInfo(string ProjectID)
49
        {
50 82705273 yoush97
            try
51 cab8a4a1 yoush97
            {
52 82705273 yoush97
                using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR))
53
                {
54
                    var id2Project = new ID2Controller().GetID2ProjectList();
55
                    var project = rep.GetProjectInfo(ProjectID);
56 1abdd7c3 yoush97
57 82705273 yoush97
                    var id2 = id2Project.Where(x => x.Name.Equals(project.Code)).FirstOrDefault();
58
                    project.ID2Path = id2?.Path ?? null;
59
                    project.ID2Info = id2 ?? new ID2ProjectInfo();
60 1abdd7c3 yoush97
61 82705273 yoush97
                    return rep.GetProjectInfo(ProjectID);
62
                }
63
            }
64
            catch (Exception ex)
65
            {
66
                throw ex;
67 cab8a4a1 yoush97
            }
68
        }
69 a23d0a0c yoush97
70
        public bool SetProjectData(ProjectInfo projectInfo, List<ID2ProjectInfo> id2ProjectList)
71
        {
72 82705273 yoush97
            try
73 a23d0a0c yoush97
            {
74 82705273 yoush97
                using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR))
75
                {
76
                    return rep.SetProjectData(projectInfo, id2ProjectList);
77
                }
78
            }
79
            catch (Exception ex)
80
            {
81
                throw ex;
82 a23d0a0c yoush97
            }
83
        }
84
85
        public bool SetProjectGroupData(ProjectInfo projectInfo)
86
        {
87 82705273 yoush97
            try
88
            {
89
                using (ProjectRepository rep = new ProjectRepository(this._MSSQLCONNSTR))
90
                {
91
                    return rep.SetProjectGroupData(projectInfo);
92
                }
93
            }
94
            catch (Exception ex)
95 a23d0a0c yoush97
            {
96 82705273 yoush97
                throw ex;
97 a23d0a0c yoush97
            }
98
        }
99 cab8a4a1 yoush97
    }
100
}
클립보드 이미지 추가 (최대 크기: 500 MB)