프로젝트

일반

사용자정보

통계
| 개정판:

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

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