프로젝트

일반

사용자정보

개정판 b1591ae6

IDb1591ae676d4d0abf270e7c23dd0bedfb69fd2cb
상위 295ce375
하위 367fc955

유성호이(가) 일년 이상 전에 추가함

issue #0000
저장수정 - 되는지 모름

Change-Id: I6b5f4412c72dcf593eee783e400c6b25372b94d1

차이점 보기:

ID2.Manager/ID2.Manager.Dapper/Repository/DocumentRepository.cs
255 255
                        {
256 256
                            doc.RegisteredUser = userId;
257 257
                            query = $@"
258
declare @tbdoc table(docid varchar(36))
258 259
insert into dbo.Documents
259 260
(
260 261
     DocID
......
302 303
    ,DTIsRegSystem
303 304
    ,DTRemarks
304 305
)
306
output inserted.DocID into @tbdoc
305 307
values 
306 308
(
307 309
     lower(newid())
......
348 350
    ,@DTIsImport
349 351
    ,@DTIsRegSystem
350 352
    ,@DTRemarks
351
);";
353
)
354

  
355
if @@rowcount > 0
356
begin
357
    select docid from @tbdoc
358
end
359
else
360
begin
361
    select ''
362
end;";
352 363
                        }
353 364
                        else
354 365
                        {
......
398 409
      ,DTIsImport=@DTIsImport
399 410
      ,DTIsRegSystem=@DTIsRegSystem
400 411
      ,DTRemarks=@DTRemarks
401
where  DocID=@DocID;";
412
where  DocID=@DocID
413

  
414
if @@rowcount > 0
415
begin
416
    select @DocID
417
end
418
else
419
begin
420
    select ''
421
end;";
422
                        }
423
                        string refID = base.QueryFirstOrDefault<string>(query, doc, transaction);
424

  
425
                        if (doc.AttFiles != null && doc.AttFiles.Count > 0)
426
                        {
427
                            string attDelIDList = string.Join("','", doc.AttFiles.Where(x => !string.IsNullOrEmpty(x.FileID)).Select(x => x.FileID).ToList());
428

  
429
                            if (!string.IsNullOrEmpty(refID) && attDelIDList.Length > 0)
430
                            {
431
                                query = $@"
432
delete from dbo.AttachFIles
433
where  RefID=@RefID and FileID in ('{attDelIDList}');";
434
                                base.Execute(query, new { RefID = refID }, transaction);
435
                            }
436

  
437
                            foreach (AttFileInfo attFile in doc.AttFiles)
438
                            {
439
                                attFile.RefID = refID;
440
                                attFile.Creator = userId;
441

  
442
                                query = $@"
443
insert into dbo.AttachFIles (FileID,RefID,Category,FileType,FileName,FilePath,FileExtension,FileData,Creator)
444
values
445
(
446
    lower(newid())
447
   ,@RefID
448
   ,@Category
449
   ,@FileType
450
   ,@FileName
451
   ,@FilePath
452
   ,@FileExtension
453
   ,@FileData
454
   ,@Creator
455
)";
456

  
457
                                base.Execute(query, attFile, transaction);
458
                            }
402 459
                        }
403
                        base.Execute(query, doc, transaction);
404 460
                    }
405 461

  
406 462
                    transaction.Commit();
ID2.Manager/ID2.Manager.Data/Models/Documents.cs
188 188

  
189 189
        public bool Equals(Documents other)
190 190
        {
191
            bool isAttfilesEqual = false;
192

  
193
            if (this != null && other == null)
194
                return false;
195

  
196
            if (this.AttFiles == null && other.AttFiles == null)
197
            {
198
                isAttfilesEqual = true;
199
            }
200
            else if (this.AttFiles != null && other.AttFiles != null)
201
            {
202
                isAttfilesEqual = this.AttFiles.SequenceEqual(other.AttFiles);
203
            }
204

  
191 205
            bool result = other != null && this.DocumentNo == other.DocumentNo && this.RevisonNo == other.RevisonNo && this.RefProjectCode == other.RefProjectCode && this.IsLatest == other.IsLatest
192 206
                && this.AutoCADFilie == other.AutoCADFilie && this.PDFFile == other.PDFFile && this.MarkupLink == other.MarkupLink && this.AVEVALink == other.AVEVALink
193 207
                && this.DocFilePath == other.DocFilePath && this.DocFileName == other.DocFileName && this.JobLevel == other.JobLevel && this.IsTypical == other.IsTypical
......
201 215
                && this.ProdReviewer == other.ProdReviewer && this.ProdIsResult == other.ProdIsResult && this.ProdRemarks == other.ProdRemarks && this.ClientReviewer == other.ClientReviewer
202 216
                && this.ClientIsResult == other.ClientIsResult && this.ClientRemarks == other.ClientRemarks && this.DTIsGateWay == other.DTIsGateWay && this.DTIsImport == other.DTIsImport
203 217
                && this.DTIsRegSystem == other.DTIsRegSystem && this.DTRemarks == other.DTRemarks
204
                && this.AttFiles != null && other.AttFiles != null && this.AttFiles.SequenceEqual(other.AttFiles);
218
                && isAttfilesEqual;
205 219

  
206 220
            if (result == false)
207 221
            {
......
225 239
                + this.AVEVAStatus.GetNullableHash() + this.AVEVAIssues.GetNullableHash() + this.ReviewFilePath.GetNullableHash() + this.ReviewFileName.GetNullableHash()
226 240
                + this.ProdReviewer.GetNullableHash() + this.ProdIsResult.GetNullableHash() + this.ProdRemarks.GetNullableHash() + this.ClientReviewer.GetNullableHash()
227 241
                + this.ClientIsResult.GetNullableHash() + this.ClientRemarks.GetNullableHash() + this.DTIsGateWay.GetNullableHash() + this.DTIsImport.GetNullableHash()
228
                + this.DTIsRegSystem.GetNullableHash() + this.DTRemarks.GetNullableHash()
229
                + this.AttFiles.GetNullableHash();
242
                + this.DTIsRegSystem.GetNullableHash() + this.DTRemarks.GetNullableHash();
230 243
        }
231 244

  
232 245
        public class DocumentsKeyComparer : IEqualityComparer<Documents>
ID2.Manager/ID2.Manager/Classes/DocumentsWorker.cs
88 88
        }
89 89
        protected override void DoWork(BackgroundWorker worker, DoWorkEventArgs e)
90 90
        {
91
            /*
92
            //수정리스트
93
            var sets = this.DocList.Where(x => !this.OrgList.Any(y => y.Equals(x))).ToList();
94
            var setorgs = this.OrgList.Intersect(sets, new DocumentsKeyComparer()).ToList();
95
            var newsets = sets.Except(this.OrgList, new DocumentsKeyComparer()).ToList();
96
            foreach (var newset in newsets)
97
            {
98
                newset.DocID = null;
99
            }
100
            if (sets != null && sets.Count > 0)
101
            {
102
                this.SetList.AddRange(sets);
103
            }
104
            //newsets.Select(x => { x.DocID = null; return x; });
105
            //sets.Except(this.OrgList, new DocumentsKeyComparer()).Select(x => { x.DocID = null; return x; })
106
            //this.OrgList.Except(this.DocList, new DocumentsKeyComparer())
107

  
108
            foreach (var set in sets)
109
            {
110
                List<AttFileInfo> setAtts = set.AttFiles ?? new List<AttFileInfo>();
111
                List<AttFileInfo> orgAtts = new List<AttFileInfo>();
112
                List<AttFileInfo> finalAtts = new List<AttFileInfo>();
113

  
114
                var org = setorgs.Where(x => x.DocID == (set.DocID ?? string.Empty)).FirstOrDefault();
115
                if (org != null)
116
                {
117
                    if (org.AttFiles != null)
118
                    {
119
                        orgAtts = org.AttFiles;
120
                    }
121
                }
122

  
123
                finalAtts.AddRange(orgAtts.Where(x => !setAtts.Any(y => y.FileID.Equals(x.FileID))));
124
                finalAtts.AddRange(setAtts.Where(x => !orgAtts.Any(y => y.FileID.Equals(x.FileID))).Select(x => { x.FileID = null; return x; }));
125

  
126
                if (finalAtts.Count > 0)
127
                {
128
                    set.AttFiles = finalAtts;
129
                }
130

  
131
                this.SetList.Add(set);
132
            }
133

  
134

  
135
            //this.DocList.Where(x => !this.OrgList.Any(y => y.Equals(x)))
136
            //            .ToList().ForEach(x => this.SetList.Add(x));
137

  
138
            //this.SetList.Intersect(this.OrgList, new DocumentsKeyComparer());
139

  
140
            //this.SetList.Select(x =>
141
            //{
142
            //    x.inter (this.OrgList, new DocumentsAttFileComparer())
143
            //    return x;
144
            //});
145
            //var test = this.OrgList.Except(this.DocList, new DocumentsAttFileComparer());
146
            */
147

  
91 148
            //수정리스트
92 149
            this.DocList.Where(x => !this.OrgList.Any(y => y.Equals(x)))
93 150
                        .ToList().ForEach(x => this.SetList.Add(x));
151
            foreach (var set in this.SetList)
152
            {
153
                List<AttFileInfo> setAtts = set.AttFiles ?? new List<AttFileInfo>();
154
                List<AttFileInfo> orgAtts = new List<AttFileInfo>();
155
                List<AttFileInfo> finalAtts = new List<AttFileInfo>();
156

  
157
                var org = this.OrgList.Where(x => x.DocID == (set.DocID ?? string.Empty)).FirstOrDefault();
158
                if (org != null)
159
                {
160
                    if (org.AttFiles != null)
161
                    {
162
                        orgAtts = org.AttFiles;
163
                    }
164
                }
165

  
166
                finalAtts.AddRange(orgAtts.Where(x => !setAtts.Any(y => y.FileID.Equals(x.FileID))));
167
                finalAtts.AddRange(setAtts.Where(x => !orgAtts.Any(y => y.FileID.Equals(x.FileID))).Select(x => { x.FileID = null; return x; }));
168

  
169
                if (finalAtts.Count > 0)
170
                {
171
                    set.AttFiles = finalAtts;
172
                }
173
            }
174

  
94 175
            //삭제리스트
95 176
            this.DelList.AddRange(this.OrgList.Except(this.DocList, new DocumentsKeyComparer()));
96 177

  

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)