프로젝트

일반

사용자정보

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

hytos / ID2.Manager / ID2.Manager.Controller / Controllers / DocumentController.cs @ 5b086e44

이력 | 보기 | 이력해설 | 다운로드 (8.95 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()
20
        {
21
            using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
22
            {
23
                return rep.GetAllDocuments();
24
            }
25
        }
26

    
27
        public (IEnumerable<Documents> dwgs, int totalCnt) GetDocuments(string projectCode, string personIncharge, string jobLevel, string documentNo, string isToIsDiscussion, string isFrReviewStatus, string isID2Work, string id2Status, string avevaStatus, string prodIsResult, string clientIsResult)
28
        {
29
            using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
30
            {
31
                return rep.GetDocuments(projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, avevaStatus, prodIsResult, clientIsResult);
32
            }
33
        }
34

    
35
        public (IEnumerable<Documents> dwgs, int totalCnt) GetDocuments(List<ID2ProjectInfo> id2Infos, string projectCode, string personIncharge, string jobLevel, string documentNo, string isToIsDiscussion, string isFrReviewStatus, string isID2Work, string id2Status, string avevaStatus, string prodIsResult, string clientIsResult)
36
        {
37
            IEnumerable<Documents> docs = this.GetDocuments(projectCode, personIncharge, jobLevel, documentNo, isToIsDiscussion, isFrReviewStatus, isID2Work, id2Status, avevaStatus, prodIsResult, clientIsResult).dwgs;
38
            List<ID2Drawings> id2docs = null;
39

    
40
            if (id2Infos.Any())
41
            {
42
                id2docs = new List<ID2Drawings>();
43
                id2Infos.ForEach(x =>
44
                {
45
                    id2docs.AddRange(new DocumentController(x).GetID2DrawingsByProject(x));
46
                });
47
            }
48

    
49
            if (docs != null && id2docs != null && docs.Any() && id2docs.Any())
50
            {
51
                var result = from doc in docs
52
                             join id2 in id2docs on new { projCd = doc.RefProjectCode, DocNo = doc.DocumentNo } equals new { projCd = id2.PROJECTNAME, DocNo = id2.DOCNAME } into gj
53
                             from dw in gj.DefaultIfEmpty()
54
                             select new Documents()
55
                             {
56
                                 Seq = doc.Seq,
57
                                 DocID = doc.DocID,
58
                                 DocumentNo = doc.DocumentNo,
59
                                 RevisonNo = doc.RevisonNo,
60
                                 RefProjectCode = doc.RefProjectCode,
61
                                 IsLatest = doc.IsLatest,
62
                                 AutoCADFilie = doc.AutoCADFilie,
63
                                 PDFFile = doc.PDFFile,
64
                                 MarkupLink = doc.MarkupLink,
65
                                 AVEVALink = doc.AVEVALink,
66
                                 DocFilePath = doc.DocFilePath,
67
                                 DocFileName = doc.DocFileName,
68
                                 JobLevel = doc.JobLevel,
69
                                 IsTypical = doc.IsTypical,
70
                                 PersonInCharge = doc.PersonInCharge,
71
                                 IsDeleted = doc.IsDeleted,
72
                                 RegisteredDate = doc.RegisteredDate,
73
                                 ModifiedDate = doc.ModifiedDate,
74
                                 DeletedDate = doc.DeletedDate,
75
                                 ToIsDiscussion = doc.ToIsDiscussion,
76
                                 ToRemarks = doc.ToRemarks,
77
                                 ToCreator = doc.ToCreator,
78
                                 ToCapture = doc.ToCapture,
79
                                 ToIsMarkup = doc.ToIsMarkup,
80
                                 FrReviewStatus = doc.FrReviewStatus,
81
                                 FrRemarks = doc.FrRemarks,
82
                                 FrCreator = doc.FrCreator,
83
                                 FrCapture = doc.FrCapture,
84
                                 FrIsMarkup = doc.FrIsMarkup,
85
                                 IsID2Work = doc.IsID2Work,
86
                                 ID2Connection = doc.ID2Connection,
87
                                 ID2StartDate = doc.ID2StartDate,
88
                                 ID2EndDate = dw?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(dw?.DATETIME),
89
                                 ID2JobTime = doc.ID2JobTime,
90
                                 ID2Status = doc.ID2Status,
91
                                 ID2Issues = doc.ID2Issues,
92
                                 AVEVAConnection = doc.AVEVAConnection,
93
                                 AVEVAConvertDate = doc.AVEVAConvertDate,
94
                                 AVEVAReviewDate = doc.AVEVAReviewDate,
95
                                 AVEVAStatus = doc.AVEVAStatus,
96
                                 AVEVAIssues = doc.AVEVAIssues,
97
                                 ReviewFilePath = doc.ReviewFilePath,
98
                                 ReviewFileName = doc.ReviewFileName,
99
                                 ProdReviewer = doc.ProdReviewer,
100
                                 ProdIsResult = doc.ProdIsResult,
101
                                 ProdRemarks = doc.ProdRemarks,
102
                                 ClientReviewer = doc.ClientReviewer,
103
                                 ClientIsResult = doc.ClientIsResult,
104
                                 ClientRemarks = doc.ClientRemarks,
105
                                 DTIsGateWay = doc.DTIsGateWay,
106
                                 DTIsImport = doc.DTIsImport,
107
                                 DTIsRegSystem = doc.DTIsRegSystem,
108
                                 DTRemarks = doc.DTRemarks,
109
                                 MarkupText = doc.MarkupText
110
                             };
111

    
112
                return (result, 0);
113

    
114
            }
115
            return (docs, 0);
116
        }
117

    
118
        public bool SetDocumentData(List<Documents> docList, List<Documents> delDocList, string userId)
119
        {
120
            using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
121
            {
122
                return rep.SetDocumentData(docList, delDocList, userId);
123
            }
124
        }
125

    
126
        public Documents SetID2Worker(Documents doc, string userId)
127
        {
128
            using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
129
            {
130
                return rep.SetDocumentDataField(doc, userId);
131
            }
132
        }
133

    
134
        public Documents SetDocumentDataField(Documents doc, string userId)
135
        {
136
            using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
137
            {
138
                return rep.SetDocumentDataField(doc, userId);
139
            }
140
        }
141

    
142

    
143
        //ID2
144
        public IEnumerable<ID2Drawings> GetID2DrawingsByProject(ID2ProjectInfo id2Info)
145
        {
146
            using (DocumentRepository rep = new DocumentRepository(this._ID2CONNSTR))
147
            {
148
                return rep.GetID2DrawingsByProject(id2Info);
149
            }
150
        }
151

    
152
        public bool SetID2Sync(List<ID2ProjectInfo> id2Infos, string userId)
153
        {
154
            bool isSuccess = false;
155

    
156
            try
157
            {
158
                IEnumerable<Documents> docs = this.GetAllDocuments();
159
                List<ID2Drawings> id2docs = null;
160

    
161
                if (id2Infos.Any())
162
                {
163
                    id2docs = new List<ID2Drawings>();
164
                    id2Infos.ForEach(x =>
165
                    {
166
                        id2docs.AddRange(new DocumentController(x).GetID2DrawingsByProject(x));
167
                    });
168
                }
169

    
170
                if (docs != null && id2docs != null && docs.Any() && id2docs.Any())
171
                {
172
                    var result = from doc in docs
173
                                 join id2 in id2docs on new { projCd = doc.RefProjectCode, DocNo = doc.DocumentNo } equals new { projCd = id2.PROJECTNAME, DocNo = id2.DOCNAME }
174
                                 select new Documents()
175
                                 {
176
                                     DocID = doc.DocID,
177
                                     ID2EndDate = id2?.DATETIME == null ? (DateTime?)null : Convert.ToDateTime(id2?.DATETIME)
178
                                 };
179

    
180
                    if (result.Any())
181
                    {
182
                        using (DocumentRepository rep = new DocumentRepository(this._MSSQLCONNSTR))
183
                        {
184
                            isSuccess = rep.SetDocumentDatasField(result.ToList(), userId);
185
                        }
186
                    }
187
                }
188
            }
189
            catch (Exception ex)
190
            {
191
                throw ex;
192
            }
193

    
194
            return isSuccess;
195
        }
196
    }
197
}
클립보드 이미지 추가 (최대 크기: 500 MB)