프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

hytos / ID2.Manager / ID2.Manager.Controller / Controllers / DocumentController.cs @ ab3c1c74

이력 | 보기 | 이력해설 | 다운로드 (10.8 KB)

1 5898479a yoush97
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
7 fe57f64a yoush97
using ID2.Manager.Dapper;
8 5898479a yoush97
using ID2.Manager.Data.Models;
9
using ID2.Manager.Dapper.Repository;
10
11
namespace ID2.Manager.Controller.Controllers
12
{
13
    public class DocumentController : BaseController
14
    {
15 91e72bfe yoush97
        public DocumentController() : base() { }
16 fe57f64a yoush97
17
        public DocumentController(ID2ProjectInfo id2Info) : base(id2Info) { }
18
19 a4a166e2 yoush97
        public IEnumerable<Documents> GetAllDocuments(string projectGroupID)
20 54977253 yoush97
        {
21 82705273 yoush97
            try
22 54977253 yoush97
            {
23 82705273 yoush97
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
24
                {
25 a4a166e2 yoush97
                    return rep.GetAllDocuments(projectGroupID);
26 82705273 yoush97
                }
27
            }
28
            catch (Exception ex)
29
            {
30
                throw ex;
31 54977253 yoush97
            }
32
        }
33
34 2aa2a446 yoush97
        public (IEnumerable<Documents> dwgs, int totalCnt) GetDocuments(string projectGroupID, List<string> dateTypes, DateTime? frDate, DateTime? toDate, string projectCode, string personIncharge, string jobLevel, string documentNo, string isToIsDiscussion, string isFrReviewStatus, string id2Status, string id2Issues, string avevaStatus, string avevaIssues, string prodIsResult, string clientIsResult, string isGateWay, string isRegSystem)
35 5898479a yoush97
        {
36 82705273 yoush97
            try
37 5898479a yoush97
            {
38 82705273 yoush97
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
39
                {
40 2aa2a446 yoush97
                    return rep.GetDocuments(projectGroupID, dateTypes, frDate, toDate, projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, id2Status, id2Issues, avevaStatus, avevaIssues, prodIsResult, clientIsResult, isGateWay, isRegSystem);
41 82705273 yoush97
                }
42
            }
43
            catch (Exception ex)
44
            {
45
                throw ex;
46 5898479a yoush97
            }
47
        }
48 709c1971 yoush97
49 2aa2a446 yoush97
        public (IEnumerable<Documents> dwgs, int totalCnt) GetDocuments(List<ID2ProjectInfo> id2Infos, string projectGroupID, List<string> dateTypes, DateTime? frDate, DateTime? toDate, string projectCode, string personIncharge, string jobLevel, string documentNo, string isToIsDiscussion, string isFrReviewStatus, string id2Issues, string id2Status, string avevaStatus, string avevaIssues, string prodIsResult, string clientIsResult, string isGateWay, string isRegSystem)
50 fe57f64a yoush97
        {
51 82705273 yoush97
            try
52 fe57f64a yoush97
            {
53 2aa2a446 yoush97
                var (dwgs, totalCnt) = this.GetDocuments(projectGroupID, dateTypes, frDate, toDate, projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, id2Status, id2Issues, avevaStatus, avevaIssues, prodIsResult, clientIsResult, isGateWay, isRegSystem);
54 904fbe46 yoush97
55
                IEnumerable<Documents> docs = dwgs;
56 82705273 yoush97
                List<ID2Drawings> id2docs = null;
57
58
                if (id2Infos.Any())
59 fe57f64a yoush97
                {
60 82705273 yoush97
                    id2docs = new List<ID2Drawings>();
61
                    id2Infos.ForEach(x =>
62
                    {
63
                        id2docs.AddRange(new DocumentController(x).GetID2DrawingsByProject(x));
64
                    });
65
                }
66 fe57f64a yoush97
67 82705273 yoush97
                if (docs != null && id2docs != null && docs.Any() && id2docs.Any())
68
                {
69
                    var result = from doc in docs
70
                                 join id2 in id2docs on new { projCd = doc.RefProjectCode, DocNo = doc.DocumentNo } equals new { projCd = id2.PROJECTNAME, DocNo = id2.DOCNAME } into gj
71
                                 from dw in gj.DefaultIfEmpty()
72
                                 select new Documents()
73
                                 {
74
                                     Seq = doc.Seq,
75
                                     DocID = doc.DocID,
76
                                     DocumentNo = doc.DocumentNo,
77
                                     RevisonNo = doc.RevisonNo,
78
                                     RefProjectCode = doc.RefProjectCode,
79
                                     IsLatest = doc.IsLatest,
80
                                     AutoCADFilie = doc.AutoCADFilie,
81
                                     PDFFile = doc.PDFFile,
82
                                     MarkupLink = doc.MarkupLink,
83
                                     AVEVALink = doc.AVEVALink,
84
                                     JobLevel = doc.JobLevel,
85
                                     PersonInCharge = doc.PersonInCharge,
86
                                     IsDeleted = doc.IsDeleted,
87
                                     RegisteredDate = doc.RegisteredDate,
88
                                     ModifiedDate = doc.ModifiedDate,
89
                                     DeletedDate = doc.DeletedDate,
90
                                     ToIsDiscussion = doc.ToIsDiscussion,
91
                                     ToRemarks = doc.ToRemarks,
92
                                     ToCreator = doc.ToCreator,
93
                                     FrReviewStatus = doc.FrReviewStatus,
94
                                     FrRemarks = doc.FrRemarks,
95
                                     FrCreator = doc.FrCreator,
96
                                     ID2StartDate = doc.ID2StartDate,
97
                                     ID2EndDate = dw?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(dw?.DATETIME),
98
                                     ID2Status = doc.ID2Status,
99
                                     ID2Issues = doc.ID2Issues,
100 cb2e1138 yoush97
                                     ReplyModifications = doc.ReplyModifications,
101
                                     ReplyRequester = doc.ReplyRequester,
102
                                     IsConvert = doc.IsConvert,
103
                                     AVEVAPersonInCharge = doc.AVEVAPersonInCharge,
104
                                     AVEVAWorker = doc.AVEVAWorker,
105 82705273 yoush97
                                     AVEVAConvertDate = doc.AVEVAConvertDate,
106
                                     AVEVAReviewDate = doc.AVEVAReviewDate,
107 ab3c1c74 yoush97
                                     AVEVAWorkDate = doc.AVEVAWorkDate,
108 82705273 yoush97
                                     AVEVAStatus = doc.AVEVAStatus,
109
                                     AVEVAIssues = doc.AVEVAIssues,
110
                                     ProdReviewer = doc.ProdReviewer,
111
                                     ProdIsResult = doc.ProdIsResult,
112
                                     ProdRemarks = doc.ProdRemarks,
113
                                     ClientReviewer = doc.ClientReviewer,
114
                                     ClientIsResult = doc.ClientIsResult,
115
                                     ClientRemarks = doc.ClientRemarks,
116
                                     DTIsGateWay = doc.DTIsGateWay,
117
                                     DTIsImport = doc.DTIsImport,
118
                                     DTIsRegSystem = doc.DTIsRegSystem,
119
                                     DTRemarks = doc.DTRemarks,
120 e458a996 taeseongkim
                                     Markups = doc.Markups
121 82705273 yoush97
                                 };
122
123 904fbe46 yoush97
                    return (result, totalCnt);
124 fe57f64a yoush97
125 82705273 yoush97
                }
126 904fbe46 yoush97
                return (dwgs, totalCnt);
127 82705273 yoush97
            }
128
            catch (Exception ex)
129
            {
130
                throw ex;
131 fe57f64a yoush97
            }
132
        }
133
134 ff990784 yoush97
        public int ExistsDocument(string projectGroupID, List<string> newDwgNos)
135
        {
136
            try
137
            {
138
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
139
                {
140
                    return rep.ExistsDocument(projectGroupID, newDwgNos);
141
                }
142
            }
143
            catch (Exception ex)
144
            {
145
                throw ex;
146
            }
147
        }
148
149 54977253 yoush97
        public bool SetDocumentData(List<Documents> docList, List<Documents> delDocList, string userId)
150 709c1971 yoush97
        {
151 82705273 yoush97
            try
152
            {
153
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
154
                {
155
                    return rep.SetDocumentData(docList, delDocList, userId);
156
                }
157
            }
158
            catch (Exception ex)
159 709c1971 yoush97
            {
160 82705273 yoush97
                throw ex;
161 709c1971 yoush97
            }
162
        }
163 978488b0 yoush97
164 4b8d9ad9 yoush97
        public Documents SetID2Worker(Documents doc, string userId)
165
        {
166 82705273 yoush97
            try
167
            {
168
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
169
                {
170
                    return rep.SetDocumentDataField(doc, userId);
171
                }
172
            }
173
            catch (Exception ex)
174 4b8d9ad9 yoush97
            {
175 82705273 yoush97
                throw ex;
176 4b8d9ad9 yoush97
            }
177
        }
178
179 978488b0 yoush97
        public Documents SetDocumentDataField(Documents doc, string userId)
180
        {
181 82705273 yoush97
            try
182
            {
183
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
184
                {
185
                    return rep.SetDocumentDataField(doc, userId);
186
                }
187
            }
188
            catch (Exception ex)
189 978488b0 yoush97
            {
190 82705273 yoush97
                throw ex;
191 978488b0 yoush97
            }
192
        }
193 fe57f64a yoush97
194
195
        //ID2
196
        public IEnumerable<ID2Drawings> GetID2DrawingsByProject(ID2ProjectInfo id2Info)
197
        {
198 82705273 yoush97
            try
199
            {
200
                using (DocumentRepository rep = new DocumentRepository(this._ID2CONNSTR))
201
                {
202
                    return rep.GetID2DrawingsByProject(id2Info);
203
                }
204
            }
205
            catch (Exception ex)
206 fe57f64a yoush97
            {
207 82705273 yoush97
                throw ex;
208 fe57f64a yoush97
            }
209
        }
210 54977253 yoush97
211 a4a166e2 yoush97
        public bool SetID2Sync(string projectGroupID, List<ID2ProjectInfo> id2Infos, string userId)
212 54977253 yoush97
        {
213
            bool isSuccess = false;
214
215
            try
216
            {
217 a4a166e2 yoush97
                IEnumerable<Documents> docs = this.GetAllDocuments(projectGroupID);
218 54977253 yoush97
                List<ID2Drawings> id2docs = null;
219
220
                if (id2Infos.Any())
221
                {
222
                    id2docs = new List<ID2Drawings>();
223
                    id2Infos.ForEach(x =>
224
                    {
225
                        id2docs.AddRange(new DocumentController(x).GetID2DrawingsByProject(x));
226
                    });
227
                }
228
229
                if (docs != null && id2docs != null && docs.Any() && id2docs.Any())
230
                {
231
                    var result = from doc in docs
232
                                 join id2 in id2docs on new { projCd = doc.RefProjectCode, DocNo = doc.DocumentNo } equals new { projCd = id2.PROJECTNAME, DocNo = id2.DOCNAME }
233
                                 select new Documents()
234
                                 {
235
                                     DocID = doc.DocID,
236
                                     ID2EndDate = id2?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(id2?.DATETIME)
237
                                 };
238
239
                    if (result.Any())
240
                    {
241
                        using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
242
                        {
243
                            isSuccess = rep.SetDocumentDatasField(result.ToList(), userId);
244
                        }
245
                    }
246
                }
247
            }
248
            catch (Exception ex)
249
            {
250
                throw ex;
251
            }
252
253
            return isSuccess;
254
        }
255 5898479a yoush97
    }
256
}
클립보드 이미지 추가 (최대 크기: 500 MB)