프로젝트

일반

사용자정보

통계
| 개정판:

hytos / ID2.Manager / ID2.Manager.Controller / Controllers / DocumentController.cs @ 42d4c228

이력 | 보기 | 이력해설 | 다운로드 (11 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 isID2Work, 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, isID2Work, 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 isID2Work, 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, isID2Work, 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
                                     ToIsMarkup = doc.ToIsMarkup,
95
                                     FrReviewStatus = doc.FrReviewStatus,
96
                                     FrRemarks = doc.FrRemarks,
97
                                     FrCreator = doc.FrCreator,
98
                                     FrIsMarkup = doc.FrIsMarkup,
99
                                     IsID2Work = doc.IsID2Work,
100
                                     ID2Connection = doc.ID2Connection,
101
                                     ID2StartDate = doc.ID2StartDate,
102
                                     ID2EndDate = dw?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(dw?.DATETIME),
103
                                     ID2JobTime = doc.ID2JobTime,
104
                                     ID2Status = doc.ID2Status,
105
                                     ID2Issues = doc.ID2Issues,
106
                                     AVEVAConnection = doc.AVEVAConnection,
107
                                     AVEVAConvertDate = doc.AVEVAConvertDate,
108
                                     AVEVAReviewDate = doc.AVEVAReviewDate,
109
                                     AVEVAStatus = doc.AVEVAStatus,
110
                                     AVEVAIssues = doc.AVEVAIssues,
111
                                     ReviewFilePath = doc.ReviewFilePath,
112
                                     ReviewFileName = doc.ReviewFileName,
113
                                     ProdReviewer = doc.ProdReviewer,
114
                                     ProdIsResult = doc.ProdIsResult,
115
                                     ProdRemarks = doc.ProdRemarks,
116
                                     ClientReviewer = doc.ClientReviewer,
117
                                     ClientIsResult = doc.ClientIsResult,
118
                                     ClientRemarks = doc.ClientRemarks,
119
                                     DTIsGateWay = doc.DTIsGateWay,
120
                                     DTIsImport = doc.DTIsImport,
121
                                     DTIsRegSystem = doc.DTIsRegSystem,
122
                                     DTRemarks = doc.DTRemarks,
123
                                     Markups = doc.Markups
124
                                 };
125

    
126
                    return (result, totalCnt);
127

    
128
                }
129
                return (dwgs, totalCnt);
130
            }
131
            catch (Exception ex)
132
            {
133
                throw ex;
134
            }
135
        }
136

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

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

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

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

    
197

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

    
214
        public bool SetID2Sync(string projectGroupID, List<ID2ProjectInfo> id2Infos, string userId)
215
        {
216
            bool isSuccess = false;
217

    
218
            try
219
            {
220
                IEnumerable<Documents> docs = this.GetAllDocuments(projectGroupID);
221
                List<ID2Drawings> id2docs = null;
222

    
223
                if (id2Infos.Any())
224
                {
225
                    id2docs = new List<ID2Drawings>();
226
                    id2Infos.ForEach(x =>
227
                    {
228
                        id2docs.AddRange(new DocumentController(x).GetID2DrawingsByProject(x));
229
                    });
230
                }
231

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

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

    
256
            return isSuccess;
257
        }
258
    }
259
}
클립보드 이미지 추가 (최대 크기: 500 MB)