프로젝트

일반

사용자정보

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

hytos / ID2.Manager / ID2.Manager.Controller / Controllers / DocumentController.cs @ 3295dabe

이력 | 보기 | 이력해설 | 다운로드 (11.1 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 b2ff5ff4 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 isID2Work, string id2Status, string avevaStatus, 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 b2ff5ff4 yoush97
                    return rep.GetDocuments(projectGroupID, dateTypes, frDate, toDate, projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, avevaStatus, prodIsResult, clientIsResult, isGateWay, isRegSystem);
41 82705273 yoush97
                }
42
            }
43
            catch (Exception ex)
44
            {
45
                throw ex;
46 5898479a yoush97
            }
47
        }
48 709c1971 yoush97
49 b2ff5ff4 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 isID2Work, string id2Status, string avevaStatus, string prodIsResult, string clientIsResult, string isGateWay, string isRegSystem)
50 fe57f64a yoush97
        {
51 82705273 yoush97
            try
52 fe57f64a yoush97
            {
53 b2ff5ff4 yoush97
                var (dwgs, totalCnt) = this.GetDocuments(projectGroupID, dateTypes, frDate, toDate, projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, avevaStatus, 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
                                     DocFilePath = doc.DocFilePath,
85
                                     DocFileName = doc.DocFileName,
86
                                     JobLevel = doc.JobLevel,
87
                                     IsTypical = doc.IsTypical,
88
                                     PersonInCharge = doc.PersonInCharge,
89
                                     IsDeleted = doc.IsDeleted,
90
                                     RegisteredDate = doc.RegisteredDate,
91
                                     ModifiedDate = doc.ModifiedDate,
92
                                     DeletedDate = doc.DeletedDate,
93
                                     ToIsDiscussion = doc.ToIsDiscussion,
94
                                     ToRemarks = doc.ToRemarks,
95
                                     ToCreator = doc.ToCreator,
96
                                     ToCapture = doc.ToCapture,
97
                                     ToIsMarkup = doc.ToIsMarkup,
98
                                     FrReviewStatus = doc.FrReviewStatus,
99
                                     FrRemarks = doc.FrRemarks,
100
                                     FrCreator = doc.FrCreator,
101
                                     FrCapture = doc.FrCapture,
102
                                     FrIsMarkup = doc.FrIsMarkup,
103
                                     IsID2Work = doc.IsID2Work,
104
                                     ID2Connection = doc.ID2Connection,
105
                                     ID2StartDate = doc.ID2StartDate,
106
                                     ID2EndDate = dw?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(dw?.DATETIME),
107
                                     ID2JobTime = doc.ID2JobTime,
108
                                     ID2Status = doc.ID2Status,
109
                                     ID2Issues = doc.ID2Issues,
110
                                     AVEVAConnection = doc.AVEVAConnection,
111
                                     AVEVAConvertDate = doc.AVEVAConvertDate,
112
                                     AVEVAReviewDate = doc.AVEVAReviewDate,
113
                                     AVEVAStatus = doc.AVEVAStatus,
114
                                     AVEVAIssues = doc.AVEVAIssues,
115
                                     ReviewFilePath = doc.ReviewFilePath,
116
                                     ReviewFileName = doc.ReviewFileName,
117
                                     ProdReviewer = doc.ProdReviewer,
118
                                     ProdIsResult = doc.ProdIsResult,
119
                                     ProdRemarks = doc.ProdRemarks,
120
                                     ClientReviewer = doc.ClientReviewer,
121
                                     ClientIsResult = doc.ClientIsResult,
122
                                     ClientRemarks = doc.ClientRemarks,
123
                                     DTIsGateWay = doc.DTIsGateWay,
124
                                     DTIsImport = doc.DTIsImport,
125
                                     DTIsRegSystem = doc.DTIsRegSystem,
126
                                     DTRemarks = doc.DTRemarks,
127 e458a996 taeseongkim
                                     Markups = doc.Markups
128 82705273 yoush97
                                 };
129
130 904fbe46 yoush97
                    return (result, totalCnt);
131 fe57f64a yoush97
132 82705273 yoush97
                }
133 904fbe46 yoush97
                return (dwgs, totalCnt);
134 82705273 yoush97
            }
135
            catch (Exception ex)
136
            {
137
                throw ex;
138 fe57f64a yoush97
            }
139
        }
140
141 ff990784 yoush97
        public int ExistsDocument(string projectGroupID, List<string> newDwgNos)
142
        {
143
            try
144
            {
145
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
146
                {
147
                    return rep.ExistsDocument(projectGroupID, newDwgNos);
148
                }
149
            }
150
            catch (Exception ex)
151
            {
152
                throw ex;
153
            }
154
        }
155
156 54977253 yoush97
        public bool SetDocumentData(List<Documents> docList, List<Documents> delDocList, string userId)
157 709c1971 yoush97
        {
158 82705273 yoush97
            try
159
            {
160
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
161
                {
162
                    return rep.SetDocumentData(docList, delDocList, userId);
163
                }
164
            }
165
            catch (Exception ex)
166 709c1971 yoush97
            {
167 82705273 yoush97
                throw ex;
168 709c1971 yoush97
            }
169
        }
170 978488b0 yoush97
171 4b8d9ad9 yoush97
        public Documents SetID2Worker(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 4b8d9ad9 yoush97
            {
182 82705273 yoush97
                throw ex;
183 4b8d9ad9 yoush97
            }
184
        }
185
186 978488b0 yoush97
        public Documents SetDocumentDataField(Documents doc, string userId)
187
        {
188 82705273 yoush97
            try
189
            {
190
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
191
                {
192
                    return rep.SetDocumentDataField(doc, userId);
193
                }
194
            }
195
            catch (Exception ex)
196 978488b0 yoush97
            {
197 82705273 yoush97
                throw ex;
198 978488b0 yoush97
            }
199
        }
200 fe57f64a yoush97
201
202
        //ID2
203
        public IEnumerable<ID2Drawings> GetID2DrawingsByProject(ID2ProjectInfo id2Info)
204
        {
205 82705273 yoush97
            try
206
            {
207
                using (DocumentRepository rep = new DocumentRepository(this._ID2CONNSTR))
208
                {
209
                    return rep.GetID2DrawingsByProject(id2Info);
210
                }
211
            }
212
            catch (Exception ex)
213 fe57f64a yoush97
            {
214 82705273 yoush97
                throw ex;
215 fe57f64a yoush97
            }
216
        }
217 54977253 yoush97
218 a4a166e2 yoush97
        public bool SetID2Sync(string projectGroupID, List<ID2ProjectInfo> id2Infos, string userId)
219 54977253 yoush97
        {
220
            bool isSuccess = false;
221
222
            try
223
            {
224 a4a166e2 yoush97
                IEnumerable<Documents> docs = this.GetAllDocuments(projectGroupID);
225 54977253 yoush97
                List<ID2Drawings> id2docs = null;
226
227
                if (id2Infos.Any())
228
                {
229
                    id2docs = new List<ID2Drawings>();
230
                    id2Infos.ForEach(x =>
231
                    {
232
                        id2docs.AddRange(new DocumentController(x).GetID2DrawingsByProject(x));
233
                    });
234
                }
235
236
                if (docs != null && id2docs != null && docs.Any() && id2docs.Any())
237
                {
238
                    var result = from doc in docs
239
                                 join id2 in id2docs on new { projCd = doc.RefProjectCode, DocNo = doc.DocumentNo } equals new { projCd = id2.PROJECTNAME, DocNo = id2.DOCNAME }
240
                                 select new Documents()
241
                                 {
242
                                     DocID = doc.DocID,
243
                                     ID2EndDate = id2?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(id2?.DATETIME)
244
                                 };
245
246
                    if (result.Any())
247
                    {
248
                        using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
249
                        {
250
                            isSuccess = rep.SetDocumentDatasField(result.ToList(), userId);
251
                        }
252
                    }
253
                }
254
            }
255
            catch (Exception ex)
256
            {
257
                throw ex;
258
            }
259
260
            return isSuccess;
261
        }
262 5898479a yoush97
    }
263
}
클립보드 이미지 추가 (최대 크기: 500 MB)