328 |
328 |
return existCount;
|
329 |
329 |
}
|
330 |
330 |
|
331 |
|
public bool SetDocumentData(List<Documents> docList, List<Documents> delDocList, string userId)
|
|
331 |
public bool SetDocumentData(string projectGroupID, List<Documents> docList, List<Documents> delDocList, string userId)
|
332 |
332 |
{
|
333 |
333 |
bool isSuccess = false;
|
334 |
334 |
|
335 |
335 |
try
|
336 |
336 |
{
|
|
337 |
|
|
338 |
#region merge 주석처리
|
|
339 |
/*
|
|
340 |
{
|
|
341 |
docList.ForEach(x =>
|
|
342 |
{
|
|
343 |
x.RegisteredUser = userId;
|
|
344 |
x.ModifiedUser = userId;
|
|
345 |
});
|
|
346 |
string query = $@"
|
|
347 |
merge into dbo.Documents as tg
|
|
348 |
using
|
|
349 |
(
|
|
350 |
values
|
|
351 |
(
|
|
352 |
@DocumentNo
|
|
353 |
,@RevisonNo
|
|
354 |
,@System
|
|
355 |
,@SubSystemCode
|
|
356 |
,@RefProjectCode
|
|
357 |
,@JobLevel
|
|
358 |
,@PersonInCharge
|
|
359 |
,@RegisteredUser
|
|
360 |
,@ModifiedUser
|
|
361 |
,@ToIsDiscussion
|
|
362 |
,@ToRemarks
|
|
363 |
,@ToCreator
|
|
364 |
,@FrReviewStatus
|
|
365 |
,@FrRemarks
|
|
366 |
,@FrCreator
|
|
367 |
,@ID2StartDate
|
|
368 |
,@ID2EndDate
|
|
369 |
,@ID2Status
|
|
370 |
,@ID2Issues
|
|
371 |
,@ReplyModifications
|
|
372 |
,@ReplyRequester
|
|
373 |
,@IsConvert
|
|
374 |
,@AVEVAPersonInCharge
|
|
375 |
,@AVEVAWorker
|
|
376 |
,@AVEVAConvertDate
|
|
377 |
,@AVEVAReviewDate
|
|
378 |
,@AVEVAWorkDate
|
|
379 |
,@AVEVAStatus
|
|
380 |
,@AVEVAIssues
|
|
381 |
,@ProdReviewer
|
|
382 |
,@ProdIsResult
|
|
383 |
,@ProdRemarks
|
|
384 |
,@ClientReviewer
|
|
385 |
,@ClientIsResult
|
|
386 |
,@ClientRemarks
|
|
387 |
,@DTIsGateWay
|
|
388 |
,@DTIsImport
|
|
389 |
,@DTIsRegSystem
|
|
390 |
,@DTRemarks
|
|
391 |
)
|
|
392 |
) as sc
|
|
393 |
(
|
|
394 |
DocumentNo
|
|
395 |
,RevisonNo
|
|
396 |
,[System]
|
|
397 |
,SubSystemCode
|
|
398 |
,RefProjectCode
|
|
399 |
,JobLevel
|
|
400 |
,PersonInCharge
|
|
401 |
,RegisteredUser
|
|
402 |
,ModifiedUser
|
|
403 |
,ToIsDiscussion
|
|
404 |
,ToRemarks
|
|
405 |
,ToCreator
|
|
406 |
,FrReviewStatus
|
|
407 |
,FrRemarks
|
|
408 |
,FrCreator
|
|
409 |
,ID2StartDate
|
|
410 |
,ID2EndDate
|
|
411 |
,ID2Status
|
|
412 |
,ID2Issues
|
|
413 |
,ReplyModifications
|
|
414 |
,ReplyRequester
|
|
415 |
,IsConvert
|
|
416 |
,AVEVAPersonInCharge
|
|
417 |
,AVEVAWorker
|
|
418 |
,AVEVAConvertDate
|
|
419 |
,AVEVAReviewDate
|
|
420 |
,AVEVAWorkDate
|
|
421 |
,AVEVAStatus
|
|
422 |
,AVEVAIssues
|
|
423 |
,ProdReviewer
|
|
424 |
,ProdIsResult
|
|
425 |
,ProdRemarks
|
|
426 |
,ClientReviewer
|
|
427 |
,ClientIsResult
|
|
428 |
,ClientRemarks
|
|
429 |
,DTIsGateWay
|
|
430 |
,DTIsImport
|
|
431 |
,DTIsRegSystem
|
|
432 |
,DTRemarks
|
|
433 |
)
|
|
434 |
ON sc.DocumentNo=tg.DocumentNo
|
|
435 |
when matched and tg.IsDeleted=0 then
|
|
436 |
|
|
437 |
update
|
|
438 |
set tg.DocumentNo=sc.DocumentNo
|
|
439 |
,tg.RevisonNo=sc.RevisonNo
|
|
440 |
,tg.[System]=sc.[System]
|
|
441 |
,tg.SubSystemCode=sc.SubSystemCode
|
|
442 |
,tg.RefProjectCode=sc.RefProjectCode
|
|
443 |
,tg.JobLevel=sc.JobLevel
|
|
444 |
,tg.PersonInCharge=sc.PersonInCharge
|
|
445 |
,tg.ModifiedDate=getdate()
|
|
446 |
,tg.ModifiedUser=sc.ModifiedUser
|
|
447 |
,tg.ToIsDiscussion=sc.ToIsDiscussion
|
|
448 |
,tg.ToRemarks=sc.ToRemarks
|
|
449 |
,tg.ToCreator=sc.ToCreator
|
|
450 |
,tg.FrReviewStatus=sc.FrReviewStatus
|
|
451 |
,tg.FrRemarks=sc.FrRemarks
|
|
452 |
,tg.FrCreator=sc.FrCreator
|
|
453 |
,tg.ID2StartDate=sc.ID2StartDate
|
|
454 |
,tg.ID2EndDate=sc.ID2EndDate
|
|
455 |
,tg.ID2Status=sc.ID2Status
|
|
456 |
,tg.ID2Issues=sc.ID2Issues
|
|
457 |
,tg.ReplyModifications=sc.ReplyModifications
|
|
458 |
,tg.ReplyRequester=sc.ReplyRequester
|
|
459 |
,tg.IsConvert=sc.IsConvert
|
|
460 |
,tg.AVEVAPersonInCharge=sc.AVEVAPersonInCharge
|
|
461 |
,tg.AVEVAWorker=sc.AVEVAWorker
|
|
462 |
,tg.AVEVAConvertDate=sc.AVEVAConvertDate
|
|
463 |
,tg.AVEVAReviewDate=sc.AVEVAReviewDate
|
|
464 |
,tg.AVEVAWorkDate=sc.AVEVAWorkDate
|
|
465 |
,tg.AVEVAStatus=sc.AVEVAStatus
|
|
466 |
,tg.AVEVAIssues=sc.AVEVAIssues
|
|
467 |
,tg.ProdReviewer=sc.ProdReviewer
|
|
468 |
,tg.ProdIsResult=sc.ProdIsResult
|
|
469 |
,tg.ProdRemarks=sc.ProdRemarks
|
|
470 |
,tg.ClientReviewer=sc.ClientReviewer
|
|
471 |
,tg.ClientIsResult=sc.ClientIsResult
|
|
472 |
,tg.ClientRemarks=sc.ClientRemarks
|
|
473 |
,tg.DTIsGateWay=sc.DTIsGateWay
|
|
474 |
,tg.DTIsImport=sc.DTIsImport
|
|
475 |
,tg.DTIsRegSystem=sc.DTIsRegSystem
|
|
476 |
,tg.DTRemarks=sc.DTRemarks
|
|
477 |
when not matched then
|
|
478 |
|
|
479 |
|
|
480 |
insert
|
|
481 |
(
|
|
482 |
DocID
|
|
483 |
,DocumentNo
|
|
484 |
,RevisonNo
|
|
485 |
,[System]
|
|
486 |
,SubSystemCode
|
|
487 |
,RefProjectCode
|
|
488 |
,JobLevel
|
|
489 |
,PersonInCharge
|
|
490 |
,RegisteredDate
|
|
491 |
,RegisteredUser
|
|
492 |
,ToIsDiscussion
|
|
493 |
,ToRemarks
|
|
494 |
,ToCreator
|
|
495 |
,FrReviewStatus
|
|
496 |
,FrRemarks
|
|
497 |
,FrCreator
|
|
498 |
,ID2StartDate
|
|
499 |
,ID2EndDate
|
|
500 |
,ID2Status
|
|
501 |
,ID2Issues
|
|
502 |
,ReplyModifications
|
|
503 |
,ReplyRequester
|
|
504 |
,IsConvert
|
|
505 |
,AVEVAPersonInCharge
|
|
506 |
,AVEVAWorker
|
|
507 |
,AVEVAConvertDate
|
|
508 |
,AVEVAReviewDate
|
|
509 |
,AVEVAWorkDate
|
|
510 |
,AVEVAStatus
|
|
511 |
,AVEVAIssues
|
|
512 |
,ProdReviewer
|
|
513 |
,ProdIsResult
|
|
514 |
,ProdRemarks
|
|
515 |
,ClientReviewer
|
|
516 |
,ClientIsResult
|
|
517 |
,ClientRemarks
|
|
518 |
,DTIsGateWay
|
|
519 |
,DTIsImport
|
|
520 |
,DTIsRegSystem
|
|
521 |
,DTRemarks
|
|
522 |
)
|
|
523 |
values
|
|
524 |
(
|
|
525 |
lower(newid())
|
|
526 |
,sc.DocumentNo
|
|
527 |
,case when isnull(sc.RevisonNo,'')='' then '0' else sc.RevisonNo end
|
|
528 |
,sc.System
|
|
529 |
,sc.SubSystemCode
|
|
530 |
,sc.RefProjectCode
|
|
531 |
,sc.JobLevel
|
|
532 |
,sc.PersonInCharge
|
|
533 |
,getdate()
|
|
534 |
,sc.RegisteredUser
|
|
535 |
,sc.ToIsDiscussion
|
|
536 |
,sc.ToRemarks
|
|
537 |
,sc.ToCreator
|
|
538 |
,sc.FrReviewStatus
|
|
539 |
,sc.FrRemarks
|
|
540 |
,sc.FrCreator
|
|
541 |
,sc.ID2StartDate
|
|
542 |
,sc.ID2EndDate
|
|
543 |
,sc.ID2Status
|
|
544 |
,sc.ID2Issues
|
|
545 |
,sc.ReplyModifications
|
|
546 |
,sc.ReplyRequester
|
|
547 |
,sc.IsConvert
|
|
548 |
,sc.AVEVAPersonInCharge
|
|
549 |
,sc.AVEVAWorker
|
|
550 |
,sc.AVEVAConvertDate
|
|
551 |
,sc.AVEVAReviewDate
|
|
552 |
,sc.AVEVAWorkDate
|
|
553 |
,sc.AVEVAStatus
|
|
554 |
,sc.AVEVAIssues
|
|
555 |
,sc.ProdReviewer
|
|
556 |
,sc.ProdIsResult
|
|
557 |
,sc.ProdRemarks
|
|
558 |
,sc.ClientReviewer
|
|
559 |
,sc.ClientIsResult
|
|
560 |
,sc.ClientRemarks
|
|
561 |
,sc.DTIsGateWay
|
|
562 |
,sc.DTIsImport
|
|
563 |
,sc.DTIsRegSystem
|
|
564 |
,sc.DTRemarks
|
|
565 |
)
|
|
566 |
output $action;";
|
|
567 |
//base.Query QueryFirstOrDefault<string>(query, docList, transaction);
|
|
568 |
//var test = base.Query<string>(query, docList);
|
|
569 |
var test = base.QueryFirstOrDefault<string>(query, docList);
|
|
570 |
}
|
|
571 |
*/
|
|
572 |
#endregion
|
|
573 |
|
337 |
574 |
using (var transaction = base.BeginTransaction())
|
338 |
575 |
{
|
339 |
576 |
string query = string.Empty;
|
340 |
577 |
|
341 |
578 |
if (delDocList.Count > 0)
|
342 |
579 |
{
|
343 |
|
string docIDList = string.Join("','", delDocList.Where(x => !string.IsNullOrEmpty(x.DocID)).Select(x => x.DocID).ToList());
|
|
580 |
int paramMaxCount = 2000;
|
|
581 |
int execCount = (delDocList.Count / paramMaxCount) + 1;
|
344 |
582 |
|
345 |
|
if (docIDList.Length > 0)
|
|
583 |
for (int i = 0; i < execCount; i++)
|
346 |
584 |
{
|
|
585 |
var dynamicParameters = new DynamicParameters();
|
|
586 |
StringBuilder sbWhere = new StringBuilder();
|
|
587 |
var parameters = new Dictionary<string, object>();
|
|
588 |
|
|
589 |
parameters.Add("DeletedUser", userId);
|
|
590 |
|
|
591 |
var limitDwgNos = delDocList.Skip(paramMaxCount * i).Take(paramMaxCount).Select(x => x.DocID).ToList();
|
|
592 |
sbWhere.Append($@" DocID in @limitDwgNos ");
|
|
593 |
parameters.Add("limitDwgNos", limitDwgNos);
|
|
594 |
|
347 |
595 |
query = $@"
|
348 |
596 |
update dbo.Documents
|
349 |
597 |
set IsDeleted=1
|
350 |
|
,DeletedDate=getdate(),
|
|
598 |
,DeletedDate=getdate()
|
351 |
599 |
,DeletedUser=@DeletedUser
|
352 |
|
where DocID in ('{docIDList}');";
|
353 |
|
base.Execute(query, new { DeletedUser = userId }, transaction);
|
|
600 |
where {sbWhere}";
|
|
601 |
if (parameters.Count > 0)
|
|
602 |
{
|
|
603 |
dynamicParameters.AddDynamicParams(parameters);
|
|
604 |
}
|
|
605 |
|
|
606 |
base.Execute(query, dynamicParameters, transaction);
|
354 |
607 |
}
|
355 |
608 |
}
|
356 |
609 |
|
... | ... | |
359 |
612 |
if (string.IsNullOrEmpty(doc.DocID))
|
360 |
613 |
{
|
361 |
614 |
doc.RegisteredUser = userId;
|
|
615 |
doc.ModifiedUser = userId;
|
|
616 |
|
|
617 |
query = $@"
|
|
618 |
if exists(select * from dbo.Documents where RefProjectCode=@RefProjectCode and DocumentNo=@DocumentNo)
|
|
619 |
begin
|
|
620 |
--update
|
|
621 |
update dbo.Documents
|
|
622 |
set RevisonNo=case when isnull(@RevisonNo,'')='' then '0' else @RevisonNo end
|
|
623 |
,System=@System
|
|
624 |
,SubSystemCode=@SubSystemCode
|
|
625 |
,JobLevel=@JobLevel
|
|
626 |
,PersonInCharge=@PersonInCharge
|
|
627 |
,ModifiedDate=getdate()
|
|
628 |
,ModifiedUser=@ModifiedUser
|
|
629 |
,ToIsDiscussion=@ToIsDiscussion
|
|
630 |
,ToRemarks=@ToRemarks
|
|
631 |
,ToCreator=@ToCreator
|
|
632 |
,FrReviewStatus=@FrReviewStatus
|
|
633 |
,FrRemarks=@FrRemarks
|
|
634 |
,FrCreator=@FrCreator
|
|
635 |
,ID2StartDate=@ID2StartDate
|
|
636 |
,ID2EndDate=@ID2EndDate
|
|
637 |
,ID2Status=@ID2Status
|
|
638 |
,ID2Issues=@ID2Issues
|
|
639 |
,ReplyModifications=@ReplyModifications
|
|
640 |
,ReplyRequester=@ReplyRequester
|
|
641 |
,IsConvert=@IsConvert
|
|
642 |
,AVEVAPersonInCharge=@AVEVAPersonInCharge
|
|
643 |
,AVEVAWorker=@AVEVAWorker
|
|
644 |
,AVEVAConvertDate=@AVEVAConvertDate
|
|
645 |
,AVEVAReviewDate=@AVEVAReviewDate
|
|
646 |
,AVEVAWorkDate=@AVEVAWorkDate
|
|
647 |
,AVEVAStatus=@AVEVAStatus
|
|
648 |
,AVEVAIssues=@AVEVAIssues
|
|
649 |
,ProdReviewer=@ProdReviewer
|
|
650 |
,ProdIsResult=@ProdIsResult
|
|
651 |
,ProdRemarks=@ProdRemarks
|
|
652 |
,ClientReviewer=@ClientReviewer
|
|
653 |
,ClientIsResult=@ClientIsResult
|
|
654 |
,ClientRemarks=@ClientRemarks
|
|
655 |
,DTIsGateWay=@DTIsGateWay
|
|
656 |
,DTIsImport=@DTIsImport
|
|
657 |
,DTIsRegSystem=@DTIsRegSystem
|
|
658 |
,DTRemarks=@DTRemarks
|
|
659 |
where RefProjectCode=@RefProjectCode and DocumentNo=@DocumentNo
|
|
660 |
|
|
661 |
if @@rowcount > 0
|
|
662 |
begin
|
|
663 |
select ''
|
|
664 |
end
|
|
665 |
else
|
|
666 |
begin
|
|
667 |
select ''
|
|
668 |
end
|
|
669 |
end
|
|
670 |
else
|
|
671 |
begin
|
|
672 |
--insert
|
|
673 |
declare @tbdoc table(docid varchar(36))
|
|
674 |
insert into dbo.Documents
|
|
675 |
(
|
|
676 |
DocID
|
|
677 |
,DocumentNo
|
|
678 |
,RevisonNo
|
|
679 |
,System
|
|
680 |
,SubSystemCode
|
|
681 |
,RefProjectCode
|
|
682 |
,JobLevel
|
|
683 |
,PersonInCharge
|
|
684 |
,RegisteredDate
|
|
685 |
,RegisteredUser
|
|
686 |
,ToIsDiscussion
|
|
687 |
,ToRemarks
|
|
688 |
,ToCreator
|
|
689 |
,FrReviewStatus
|
|
690 |
,FrRemarks
|
|
691 |
,FrCreator
|
|
692 |
,ID2StartDate
|
|
693 |
,ID2EndDate
|
|
694 |
,ID2Status
|
|
695 |
,ID2Issues
|
|
696 |
,ReplyModifications
|
|
697 |
,ReplyRequester
|
|
698 |
,IsConvert
|
|
699 |
,AVEVAPersonInCharge
|
|
700 |
,AVEVAWorker
|
|
701 |
,AVEVAConvertDate
|
|
702 |
,AVEVAReviewDate
|
|
703 |
,AVEVAWorkDate
|
|
704 |
,AVEVAStatus
|
|
705 |
,AVEVAIssues
|
|
706 |
,ProdReviewer
|
|
707 |
,ProdIsResult
|
|
708 |
,ProdRemarks
|
|
709 |
,ClientReviewer
|
|
710 |
,ClientIsResult
|
|
711 |
,ClientRemarks
|
|
712 |
,DTIsGateWay
|
|
713 |
,DTIsImport
|
|
714 |
,DTIsRegSystem
|
|
715 |
,DTRemarks
|
|
716 |
)
|
|
717 |
output inserted.DocID into @tbdoc
|
|
718 |
values
|
|
719 |
(
|
|
720 |
lower(newid())
|
|
721 |
,@DocumentNo
|
|
722 |
,case when isnull(@RevisonNo,'')='' then '0' else @RevisonNo end
|
|
723 |
,@System
|
|
724 |
,@SubSystemCode
|
|
725 |
,@RefProjectCode
|
|
726 |
,@JobLevel
|
|
727 |
,@PersonInCharge
|
|
728 |
,getdate()
|
|
729 |
,@RegisteredUser
|
|
730 |
,@ToIsDiscussion
|
|
731 |
,@ToRemarks
|
|
732 |
,@ToCreator
|
|
733 |
,@FrReviewStatus
|
|
734 |
,@FrRemarks
|
|
735 |
,@FrCreator
|
|
736 |
,@ID2StartDate
|
|
737 |
,@ID2EndDate
|
|
738 |
,@ID2Status
|
|
739 |
,@ID2Issues
|
|
740 |
,@ReplyModifications
|
|
741 |
,@ReplyRequester
|
|
742 |
,@IsConvert
|
|
743 |
,@AVEVAPersonInCharge
|
|
744 |
,@AVEVAWorker
|
|
745 |
,@AVEVAConvertDate
|
|
746 |
,@AVEVAReviewDate
|
|
747 |
,@AVEVAWorkDate
|
|
748 |
,@AVEVAStatus
|
|
749 |
,@AVEVAIssues
|
|
750 |
,@ProdReviewer
|
|
751 |
,@ProdIsResult
|
|
752 |
,@ProdRemarks
|
|
753 |
,@ClientReviewer
|
|
754 |
,@ClientIsResult
|
|
755 |
,@ClientRemarks
|
|
756 |
,@DTIsGateWay
|
|
757 |
,@DTIsImport
|
|
758 |
,@DTIsRegSystem
|
|
759 |
,@DTRemarks
|
|
760 |
)
|
|
761 |
|
|
762 |
if @@rowcount > 0
|
|
763 |
begin
|
|
764 |
select docid from @tbdoc
|
|
765 |
end
|
|
766 |
else
|
|
767 |
begin
|
|
768 |
select ''
|
|
769 |
end
|
|
770 |
end";
|
|
771 |
#region 기존 입력 쿼리 주석
|
|
772 |
/*
|
362 |
773 |
query = $@"
|
363 |
774 |
declare @tbdoc table(docid varchar(36))
|
364 |
775 |
insert into dbo.Documents
|
... | ... | |
457 |
868 |
begin
|
458 |
869 |
select ''
|
459 |
870 |
end;";
|
|
871 |
*/
|
|
872 |
#endregion
|
460 |
873 |
}
|
461 |
874 |
else
|
462 |
875 |
{
|
... | ... | |
464 |
877 |
query = $@"
|
465 |
878 |
update dbo.Documents
|
466 |
879 |
set DocumentNo=@DocumentNo
|
467 |
|
,RevisonNo=@RevisonNo
|
|
880 |
,RevisonNo=case when isnull(@RevisonNo,'')='' then '0' else @RevisonNo end
|
468 |
881 |
,System=@System
|
469 |
882 |
,SubSystemCode=@SubSystemCode
|
470 |
883 |
,RefProjectCode=@RefProjectCode
|