프로젝트

일반

사용자정보

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

hytos / ID2.Manager / ID2.Manager.Controller / Controllers / DocumentController.cs @ 3fbf99d3

이력 | 보기 | 이력해설 | 다운로드 (11.9 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
                                     JobLevel = doc.JobLevel,
80
                                     PersonInCharge = doc.PersonInCharge,
81
                                     ToIsDiscussion = doc.ToIsDiscussion,
82
                                     ToRemarks = doc.ToRemarks,
83
                                     ToCreator = doc.ToCreator,
84
                                     FrReviewStatus = doc.FrReviewStatus,
85
                                     FrRemarks = doc.FrRemarks,
86
                                     FrCreator = doc.FrCreator,
87
                                     ID2StartDate = doc.ID2StartDate,
88
                                     ID2EndDate = dw?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(dw?.DATETIME),
89
                                     ID2Status = doc.ID2Status,
90
                                     ID2Issues = doc.ID2Issues,
91 cb2e1138 yoush97
                                     ReplyModifications = doc.ReplyModifications,
92
                                     ReplyRequester = doc.ReplyRequester,
93
                                     IsConvert = doc.IsConvert,
94
                                     AVEVAPersonInCharge = doc.AVEVAPersonInCharge,
95
                                     AVEVAWorker = doc.AVEVAWorker,
96 82705273 yoush97
                                     AVEVAConvertDate = doc.AVEVAConvertDate,
97
                                     AVEVAReviewDate = doc.AVEVAReviewDate,
98 ab3c1c74 yoush97
                                     AVEVAWorkDate = doc.AVEVAWorkDate,
99 82705273 yoush97
                                     AVEVAStatus = doc.AVEVAStatus,
100
                                     AVEVAIssues = doc.AVEVAIssues,
101
                                     ProdReviewer = doc.ProdReviewer,
102
                                     ProdIsResult = doc.ProdIsResult,
103
                                     ProdRemarks = doc.ProdRemarks,
104
                                     ClientReviewer = doc.ClientReviewer,
105
                                     ClientIsResult = doc.ClientIsResult,
106
                                     ClientRemarks = doc.ClientRemarks,
107
                                     DTIsGateWay = doc.DTIsGateWay,
108
                                     DTIsImport = doc.DTIsImport,
109
                                     DTIsRegSystem = doc.DTIsRegSystem,
110
                                     DTRemarks = doc.DTRemarks,
111 e458a996 taeseongkim
                                     Markups = doc.Markups
112 82705273 yoush97
                                 };
113
114 904fbe46 yoush97
                    return (result, totalCnt);
115 fe57f64a yoush97
116 82705273 yoush97
                }
117 904fbe46 yoush97
                return (dwgs, totalCnt);
118 82705273 yoush97
            }
119
            catch (Exception ex)
120
            {
121
                throw ex;
122 fe57f64a yoush97
            }
123
        }
124
125 ff990784 yoush97
        public int ExistsDocument(string projectGroupID, List<string> newDwgNos)
126
        {
127
            try
128
            {
129
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
130
                {
131
                    return rep.ExistsDocument(projectGroupID, newDwgNos);
132
                }
133
            }
134
            catch (Exception ex)
135
            {
136
                throw ex;
137
            }
138
        }
139
140 f074a104 yoush97
        public bool SetDocumentData(string projectGroupID, List<Documents> docList, List<string> delDocList, string userId)
141 709c1971 yoush97
        {
142 82705273 yoush97
            try
143
            {
144
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
145
                {
146 993feace yoush97
                    return rep.SetDocumentData(projectGroupID, docList, delDocList, userId);
147 82705273 yoush97
                }
148
            }
149
            catch (Exception ex)
150 709c1971 yoush97
            {
151 82705273 yoush97
                throw ex;
152 709c1971 yoush97
            }
153
        }
154 978488b0 yoush97
155 4b8d9ad9 yoush97
        public Documents SetID2Worker(Documents doc, string userId)
156
        {
157 82705273 yoush97
            try
158
            {
159
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
160
                {
161
                    return rep.SetDocumentDataField(doc, userId);
162
                }
163
            }
164
            catch (Exception ex)
165 4b8d9ad9 yoush97
            {
166 82705273 yoush97
                throw ex;
167 4b8d9ad9 yoush97
            }
168
        }
169
170 978488b0 yoush97
        public Documents SetDocumentDataField(Documents doc, string userId)
171
        {
172 82705273 yoush97
            try
173
            {
174
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
175
                {
176
                    return rep.SetDocumentDataField(doc, userId);
177
                }
178
            }
179
            catch (Exception ex)
180 978488b0 yoush97
            {
181 82705273 yoush97
                throw ex;
182 978488b0 yoush97
            }
183
        }
184 fe57f64a yoush97
185
186
        //ID2
187
        public IEnumerable<ID2Drawings> GetID2DrawingsByProject(ID2ProjectInfo id2Info)
188
        {
189 82705273 yoush97
            try
190
            {
191
                using (DocumentRepository rep = new DocumentRepository(this._ID2CONNSTR))
192
                {
193
                    return rep.GetID2DrawingsByProject(id2Info);
194
                }
195
            }
196
            catch (Exception ex)
197 fe57f64a yoush97
            {
198 82705273 yoush97
                throw ex;
199 fe57f64a yoush97
            }
200
        }
201 54977253 yoush97
202 a4a166e2 yoush97
        public bool SetID2Sync(string projectGroupID, List<ID2ProjectInfo> id2Infos, string userId)
203 54977253 yoush97
        {
204
            bool isSuccess = false;
205
206
            try
207
            {
208 a4a166e2 yoush97
                IEnumerable<Documents> docs = this.GetAllDocuments(projectGroupID);
209 54977253 yoush97
                List<ID2Drawings> id2docs = null;
210
211
                if (id2Infos.Any())
212
                {
213
                    id2docs = new List<ID2Drawings>();
214
                    id2Infos.ForEach(x =>
215
                    {
216
                        id2docs.AddRange(new DocumentController(x).GetID2DrawingsByProject(x));
217
                    });
218
                }
219
220
                if (docs != null && id2docs != null && docs.Any() && id2docs.Any())
221
                {
222
                    var result = from doc in docs
223
                                 join id2 in id2docs on new { projCd = doc.RefProjectCode, DocNo = doc.DocumentNo } equals new { projCd = id2.PROJECTNAME, DocNo = id2.DOCNAME }
224
                                 select new Documents()
225
                                 {
226
                                     DocID = doc.DocID,
227
                                     ID2EndDate = id2?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(id2?.DATETIME)
228
                                 };
229
230
                    if (result.Any())
231
                    {
232
                        using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
233
                        {
234
                            isSuccess = rep.SetDocumentDatasField(result.ToList(), userId);
235
                        }
236
                    }
237
                }
238
            }
239
            catch (Exception ex)
240
            {
241
                throw ex;
242
            }
243
244
            return isSuccess;
245
        }
246 39938acd yoush97
247
        //Transactions
248
        public int GetTranKey(string userId, string projectID)
249
        {
250
            try
251
            {
252
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
253
                {
254
                    return rep.GetTranKey(userId, projectID);
255
                }
256
            }
257
            catch (Exception ex)
258
            {
259
                throw ex;
260
            }
261
        }
262
263
        public bool SetTran(int seq, bool isMgt, bool isStart, int itemCount, int markusItemCount)
264
        {
265
            try
266
            {
267
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
268
                {
269
                    return rep.SetTran(seq, isMgt, isStart, itemCount, markusItemCount);
270
                }
271
            }
272
            catch (Exception ex)
273
            {
274
                throw ex;
275
            }
276
        }
277
278
        public string GetTranData(int seq)
279
        {
280
            try
281
            {
282
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
283
                {
284
                    return rep.GetTranData(seq);
285
                }
286
            }
287
            catch (Exception ex)
288
            {
289
                throw ex;
290
            }
291
        }
292
293
        public IEnumerable<Documents> GetTrDocuments(int seq)
294
        {
295
            try
296
            {
297
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
298
                {
299
                    return rep.GetTrDocuments(seq);
300
                }
301
            }
302
            catch (Exception ex)
303
            {
304
                throw ex;
305
            }
306
        }
307 5898479a yoush97
    }
308
}
클립보드 이미지 추가 (최대 크기: 500 MB)