프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager.Controller / Controllers / DocumentController.cs @ 2aa2a446

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

1
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.Dapper;
8
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
        public DocumentController() : base() { }
16

    
17
        public DocumentController(ID2ProjectInfo id2Info) : base(id2Info) { }
18

    
19
        public IEnumerable<Documents> GetAllDocuments(string projectGroupID)
20
        {
21
            try
22
            {
23
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
24
                {
25
                    return rep.GetAllDocuments(projectGroupID);
26
                }
27
            }
28
            catch (Exception ex)
29
            {
30
                throw ex;
31
            }
32
        }
33

    
34
        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
        {
36
            try
37
            {
38
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
39
                {
40
                    return rep.GetDocuments(projectGroupID, dateTypes, frDate, toDate, projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, id2Status, id2Issues, avevaStatus, avevaIssues, prodIsResult, clientIsResult, isGateWay, isRegSystem);
41
                }
42
            }
43
            catch (Exception ex)
44
            {
45
                throw ex;
46
            }
47
        }
48

    
49
        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
        {
51
            try
52
            {
53
                var (dwgs, totalCnt) = this.GetDocuments(projectGroupID, dateTypes, frDate, toDate, projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, id2Status, id2Issues, avevaStatus, avevaIssues, prodIsResult, clientIsResult, isGateWay, isRegSystem);
54

    
55
                IEnumerable<Documents> docs = dwgs;
56
                List<ID2Drawings> id2docs = null;
57

    
58
                if (id2Infos.Any())
59
                {
60
                    id2docs = new List<ID2Drawings>();
61
                    id2Infos.ForEach(x =>
62
                    {
63
                        id2docs.AddRange(new DocumentController(x).GetID2DrawingsByProject(x));
64
                    });
65
                }
66

    
67
                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
                                     IsTypical = doc.IsTypical,
86
                                     PersonInCharge = doc.PersonInCharge,
87
                                     IsDeleted = doc.IsDeleted,
88
                                     RegisteredDate = doc.RegisteredDate,
89
                                     ModifiedDate = doc.ModifiedDate,
90
                                     DeletedDate = doc.DeletedDate,
91
                                     ToIsDiscussion = doc.ToIsDiscussion,
92
                                     ToRemarks = doc.ToRemarks,
93
                                     ToCreator = doc.ToCreator,
94
                                     FrReviewStatus = doc.FrReviewStatus,
95
                                     FrRemarks = doc.FrRemarks,
96
                                     FrCreator = doc.FrCreator,
97
                                     ID2Connection = doc.ID2Connection,
98
                                     ID2StartDate = doc.ID2StartDate,
99
                                     ID2EndDate = dw?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(dw?.DATETIME),
100
                                     ID2Status = doc.ID2Status,
101
                                     ID2Issues = doc.ID2Issues,
102
                                     AVEVAConnection = doc.AVEVAConnection,
103
                                     AVEVAConvertDate = doc.AVEVAConvertDate,
104
                                     AVEVAReviewDate = doc.AVEVAReviewDate,
105
                                     AVEVAStatus = doc.AVEVAStatus,
106
                                     AVEVAIssues = doc.AVEVAIssues,
107
                                     ReviewFilePath = doc.ReviewFilePath,
108
                                     ReviewFileName = doc.ReviewFileName,
109
                                     ProdReviewer = doc.ProdReviewer,
110
                                     ProdIsResult = doc.ProdIsResult,
111
                                     ProdRemarks = doc.ProdRemarks,
112
                                     ClientReviewer = doc.ClientReviewer,
113
                                     ClientIsResult = doc.ClientIsResult,
114
                                     ClientRemarks = doc.ClientRemarks,
115
                                     DTIsGateWay = doc.DTIsGateWay,
116
                                     DTIsImport = doc.DTIsImport,
117
                                     DTIsRegSystem = doc.DTIsRegSystem,
118
                                     DTRemarks = doc.DTRemarks,
119
                                     Markups = doc.Markups
120
                                 };
121

    
122
                    return (result, totalCnt);
123

    
124
                }
125
                return (dwgs, totalCnt);
126
            }
127
            catch (Exception ex)
128
            {
129
                throw ex;
130
            }
131
        }
132

    
133
        public int ExistsDocument(string projectGroupID, List<string> newDwgNos)
134
        {
135
            try
136
            {
137
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
138
                {
139
                    return rep.ExistsDocument(projectGroupID, newDwgNos);
140
                }
141
            }
142
            catch (Exception ex)
143
            {
144
                throw ex;
145
            }
146
        }
147

    
148
        public bool SetDocumentData(List<Documents> docList, List<Documents> delDocList, string userId)
149
        {
150
            try
151
            {
152
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
153
                {
154
                    return rep.SetDocumentData(docList, delDocList, userId);
155
                }
156
            }
157
            catch (Exception ex)
158
            {
159
                throw ex;
160
            }
161
        }
162

    
163
        public Documents SetID2Worker(Documents doc, string userId)
164
        {
165
            try
166
            {
167
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
168
                {
169
                    return rep.SetDocumentDataField(doc, userId);
170
                }
171
            }
172
            catch (Exception ex)
173
            {
174
                throw ex;
175
            }
176
        }
177

    
178
        public Documents SetDocumentDataField(Documents doc, string userId)
179
        {
180
            try
181
            {
182
                using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
183
                {
184
                    return rep.SetDocumentDataField(doc, userId);
185
                }
186
            }
187
            catch (Exception ex)
188
            {
189
                throw ex;
190
            }
191
        }
192

    
193

    
194
        //ID2
195
        public IEnumerable<ID2Drawings> GetID2DrawingsByProject(ID2ProjectInfo id2Info)
196
        {
197
            try
198
            {
199
                using (DocumentRepository rep = new DocumentRepository(this._ID2CONNSTR))
200
                {
201
                    return rep.GetID2DrawingsByProject(id2Info);
202
                }
203
            }
204
            catch (Exception ex)
205
            {
206
                throw ex;
207
            }
208
        }
209

    
210
        public bool SetID2Sync(string projectGroupID, List<ID2ProjectInfo> id2Infos, string userId)
211
        {
212
            bool isSuccess = false;
213

    
214
            try
215
            {
216
                IEnumerable<Documents> docs = this.GetAllDocuments(projectGroupID);
217
                List<ID2Drawings> id2docs = null;
218

    
219
                if (id2Infos.Any())
220
                {
221
                    id2docs = new List<ID2Drawings>();
222
                    id2Infos.ForEach(x =>
223
                    {
224
                        id2docs.AddRange(new DocumentController(x).GetID2DrawingsByProject(x));
225
                    });
226
                }
227

    
228
                if (docs != null && id2docs != null && docs.Any() && id2docs.Any())
229
                {
230
                    var result = from doc in docs
231
                                 join id2 in id2docs on new { projCd = doc.RefProjectCode, DocNo = doc.DocumentNo } equals new { projCd = id2.PROJECTNAME, DocNo = id2.DOCNAME }
232
                                 select new Documents()
233
                                 {
234
                                     DocID = doc.DocID,
235
                                     ID2EndDate = id2?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(id2?.DATETIME)
236
                                 };
237

    
238
                    if (result.Any())
239
                    {
240
                        using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
241
                        {
242
                            isSuccess = rep.SetDocumentDatasField(result.ToList(), userId);
243
                        }
244
                    }
245
                }
246
            }
247
            catch (Exception ex)
248
            {
249
                throw ex;
250
            }
251

    
252
            return isSuccess;
253
        }
254
    }
255
}
클립보드 이미지 추가 (최대 크기: 500 MB)