@@ -365,6 +365,8 @@ public ActionResult ApproveDocumentCZ(Guid processId, int type, Guid fileId, For
365
365
DocumentTable documentTable = _DocumentService . Find ( documentId ) ;
366
366
_DocumentService . UpdateDocument ( documentTable , User . Identity . GetUserId ( ) ) ;
367
367
368
+ _HistoryUserService . SaveDomain ( new HistoryUserTable { DocumentTableId = documentId , HistoryType = Models . Repository . HistoryType . ApproveDocument } , User . Identity . GetUserId ( ) ) ;
369
+
368
370
foreach ( var userid in users )
369
371
{
370
372
string [ ] arrayStructrue = userid . Split ( '|' ) ;
@@ -380,12 +382,14 @@ public ActionResult RejectDocumentCZ(Guid processId, int type, Guid fileId, Form
380
382
ApplicationUser user = _AccountService . Find ( User . Identity . GetUserId ( ) ) ;
381
383
382
384
var users = _DocumentService . SignDocumentCZ ( documentId , TrackerType . Cancelled ,
383
- ( collection [ "RejectComment" ] != null | collection [ "RejectComment" ] != string . Empty ) ? ( string ) collection [ "RejectComment" ] : "" ) ;
385
+ ( collection [ "RejectComment" ] != null | collection [ "RejectComment" ] != string . Empty ) ? ( string ) collection [ "RejectComment" ] : "" ) ;
384
386
385
387
var timeZoneInfo = TimeZoneInfo . FindSystemTimeZoneById ( user . TimeZoneId ) ;
386
388
DocumentTable documentTable = _DocumentService . Find ( documentId ) ;
387
389
_DocumentService . UpdateDocument ( documentTable , user . Id ) ;
388
390
391
+ _HistoryUserService . SaveDomain ( new HistoryUserTable { DocumentTableId = documentId , HistoryType = Models . Repository . HistoryType . CancelledDocument } , User . Identity . GetUserId ( ) ) ;
392
+
389
393
_EmailService . SendInitiatorRejectEmail ( documentId ) ;
390
394
return RedirectToAction ( "Index" , "Document" ) ;
391
395
}
@@ -440,6 +444,10 @@ public ActionResult DelegateDocumentTask(Guid processId, int type, Guid fileId,
440
444
441
445
DocumentTable documentTable = _DocumentService . Find ( documentId ) ;
442
446
_DocumentService . UpdateDocument ( documentTable , currentUserId ) ;
447
+
448
+ _EmailService . SendNewExecutorEmail ( documentId , users ) ;
449
+
450
+ _HistoryUserService . SaveDomain ( new HistoryUserTable { DocumentTableId = documentId , HistoryType = Models . Repository . HistoryType . DelegateTask } , User . Identity . GetUserId ( ) ) ;
443
451
}
444
452
445
453
return RedirectToAction ( "ShowDocument" , new { id = documentId , isAfterView = true } ) ;
@@ -467,6 +475,8 @@ public ActionResult ApproveDocumentTask(Guid processId, int type, Guid fileId, F
467
475
468
476
_DocumentService . UpdateDocument ( documentTable , User . Identity . GetUserId ( ) ) ;
469
477
478
+ _HistoryUserService . SaveDomain ( new HistoryUserTable { DocumentTableId = documentId , HistoryType = Models . Repository . HistoryType . ApproveDocument } , User . Identity . GetUserId ( ) ) ;
479
+
470
480
_EmailService . SendInitiatorClosedEmail ( documentTable . Id ) ;
471
481
472
482
return RedirectToAction ( "ShowDocument" , new { id = documentId , isAfterView = true } ) ;
@@ -486,25 +496,18 @@ public ActionResult RejectDocumentTask(Guid processId, int type, Guid fileId, Fo
486
496
487
497
DocumentTable documentTable = _DocumentService . Find ( documentId ) ;
488
498
documentTable . WWFInstanceId = Guid . Empty ;
489
- documentTable . DocumentState = DocumentState . Created ;
499
+ documentTable . DocumentState = DocumentState . Cancelled ;
490
500
documentTable . ActivityName = String . Empty ;
491
501
492
502
_DocumentService . UpdateDocument ( documentTable , User . Identity . GetUserId ( ) ) ;
493
503
494
- IEnumerable < WFTrackerTable > wftrackers = _WorkflowTrackerService . GetPartial ( x => x . DocumentTableId == documentId ) . ToList ( ) ;
495
- foreach ( var item in wftrackers )
496
- {
497
- item . Users . Clear ( ) ;
498
- _WorkflowTrackerService . SaveDomain ( item , currentUserId ) ;
499
- }
504
+ _DocumentService . SaveSignData ( _DocumentService . GetCurrentSignStep ( documentId , currentUserId ) . ToList ( ) , TrackerType . Cancelled ) ;
500
505
501
- _WorkflowTrackerService . DeleteAll ( documentId ) ;
502
-
503
- var view = PostDocument ( processId , type , OperationType . SaveDraft , documentId , fileId , collection , actionModelName ) ;
506
+ _HistoryUserService . SaveDomain ( new HistoryUserTable { DocumentTableId = documentId , HistoryType = Models . Repository . HistoryType . CancelledDocument } , User . Identity . GetUserId ( ) ) ;
504
507
505
508
_EmailService . SendInitiatorClosedEmail ( documentTable . Id ) ;
506
509
507
- return view ;
510
+ return RedirectToAction ( "Index" , "Document" ) ;
508
511
}
509
512
510
513
public ActionResult ProlongDocumentTask ( string tableName , Guid documentId )
@@ -527,7 +530,9 @@ public ActionResult ProlongDocumentTask(string tableName, Guid documentId)
527
530
return RedirectToAction ( "PageNotFound" , "Error" ) ;
528
531
}
529
532
}
530
-
533
+
534
+ _HistoryUserService . SaveDomain ( new HistoryUserTable { DocumentTableId = documentId , HistoryType = Models . Repository . HistoryType . NewDocument } , User . Identity . GetUserId ( ) ) ;
535
+
531
536
var viewModel = new DocumentComposite ( ) ;
532
537
viewModel . ProcessView = process ;
533
538
viewModel . docData = _DocumentService . RouteCustomModelView ( process . TableName ) ;
@@ -561,6 +566,8 @@ public ActionResult CreateTaskFromDocument(Guid documentId)
561
566
}
562
567
}
563
568
569
+ _HistoryUserService . SaveDomain ( new HistoryUserTable { DocumentTableId = documentId , HistoryType = Models . Repository . HistoryType . NewDocument } , User . Identity . GetUserId ( ) ) ;
570
+
564
571
var viewModel = new DocumentComposite ( ) ;
565
572
viewModel . ProcessView = process ;
566
573
viewModel . docData = _DocumentService . RouteCustomModelView ( process . TableName ) ;
@@ -781,6 +788,26 @@ public ActionResult Create(ProcessView processView, OperationType operationType,
781
788
{
782
789
if ( ModelState . IsValid )
783
790
{
791
+ if ( processView . DocType == DocumentType . Task && docModel . Separated == true )
792
+ {
793
+ string initailStructure = ( string ) documentData [ "Users" ] ;
794
+ string [ ] arrayTempStructrue = initailStructure . Split ( ',' ) ;
795
+
796
+ Regex isGuid = new Regex ( @"^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$" , RegexOptions . Compiled ) ;
797
+ string [ ] arrayStructure = arrayTempStructrue . Where ( a => isGuid . IsMatch ( a ) == true ) . ToArray ( ) ;
798
+ if ( arrayStructure . Count ( ) > 0 )
799
+ {
800
+ foreach ( var item in arrayStructure )
801
+ {
802
+ string seprateUser = item + "," + arrayTempStructrue [ Array . IndexOf ( arrayTempStructrue , item ) + 1 ] ;
803
+ docModel . Users = seprateUser ;
804
+ documentData [ "Users" ] = seprateUser ;
805
+ this . CreateSeparateTasks ( processView , operationType , docModel , fileId , actionModelName , documentData ) ;
806
+ }
807
+
808
+ return RedirectToAction ( "Index" , "Document" ) ;
809
+ }
810
+ }
784
811
//Save Document
785
812
ApplicationUser user = _AccountService . Find ( User . Identity . GetUserId ( ) ) ;
786
813
var documentId = _DocumentService . SaveDocument ( docModel , processView . TableName , GuidNull2Guid ( processView . Id ) , fileId , user ) ;
@@ -1786,5 +1813,40 @@ protected override void Dispose(bool disposing)
1786
1813
}
1787
1814
base . Dispose ( disposing ) ;
1788
1815
}
1816
+
1817
+ private void CreateSeparateTasks ( ProcessView processView , OperationType operationType , dynamic docModel , Guid fileId , String actionModelName , IDictionary < string , object > documentData )
1818
+ {
1819
+ ApplicationUser user = _AccountService . Find ( User . Identity . GetUserId ( ) ) ;
1820
+ var documentId = _DocumentService . SaveDocument ( docModel , processView . TableName , GuidNull2Guid ( processView . Id ) , fileId , user ) ;
1821
+ DocumentTable documentTable = _DocumentService . Find ( documentId ) ;
1822
+
1823
+ Task . Run ( ( ) =>
1824
+ {
1825
+ IReviewDocLogService _ReviewDocLogServiceTask = DependencyResolver . Current . GetService < IReviewDocLogService > ( ) ;
1826
+ IHistoryUserService _HistoryUserServiceTask = DependencyResolver . Current . GetService < IHistoryUserService > ( ) ;
1827
+ _ReviewDocLogServiceTask . SaveDomain ( new ReviewDocLogTable { DocumentTableId = documentId } , "" , user ) ;
1828
+ _HistoryUserServiceTask . SaveDomain ( new HistoryUserTable { DocumentTableId = documentId , HistoryType = Models . Repository . HistoryType . NewDocument } , user . Id ) ;
1829
+ } ) ;
1830
+
1831
+ _SearchService . SaveSearchData ( documentId , docModel , actionModelName ) ;
1832
+
1833
+ if ( operationType == OperationType . ApproveDocument )
1834
+ {
1835
+ if ( documentTable . ProcessTable != null && ! String . IsNullOrEmpty ( documentTable . ProcessTable . StartReaderRoleId ) )
1836
+ {
1837
+ try
1838
+ {
1839
+ var role = RoleManager . FindById ( documentTable . ProcessTable . StartReaderRoleId ) ;
1840
+ if ( role != null && role . Users != null && role . Users . Count > 0 )
1841
+ {
1842
+ List < string > newReader = _DocumentReaderService . AddReader ( documentTable . Id , role . Users . ToList ( ) ) ;
1843
+ _EmailService . SendReaderEmail ( documentTable . Id , newReader ) ;
1844
+ }
1845
+ }
1846
+ catch { }
1847
+ }
1848
+ _WorkflowService . RunWorkflow ( documentTable , processView . TableName , documentData ) ;
1849
+ }
1850
+ }
1789
1851
}
1790
1852
}
0 commit comments