Skip to content

Commit f134089

Browse files
committed
edit
1 parent 6f536ed commit f134089

17 files changed

+278
-106
lines changed

RapidDoc/Activities/USR_OFM_UIT_OfficeMemo.xaml

Lines changed: 137 additions & 81 deletions
Large diffs are not rendered by default.

RapidDoc/Controllers/DocumentController.cs

Lines changed: 75 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@ public ActionResult ApproveDocumentCZ(Guid processId, int type, Guid fileId, For
365365
DocumentTable documentTable = _DocumentService.Find(documentId);
366366
_DocumentService.UpdateDocument(documentTable, User.Identity.GetUserId());
367367

368+
_HistoryUserService.SaveDomain(new HistoryUserTable { DocumentTableId = documentId, HistoryType = Models.Repository.HistoryType.ApproveDocument }, User.Identity.GetUserId());
369+
368370
foreach (var userid in users)
369371
{
370372
string[] arrayStructrue = userid.Split('|');
@@ -380,12 +382,14 @@ public ActionResult RejectDocumentCZ(Guid processId, int type, Guid fileId, Form
380382
ApplicationUser user = _AccountService.Find(User.Identity.GetUserId());
381383

382384
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"] : "");
384386

385387
var timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(user.TimeZoneId);
386388
DocumentTable documentTable = _DocumentService.Find(documentId);
387389
_DocumentService.UpdateDocument(documentTable, user.Id);
388390

391+
_HistoryUserService.SaveDomain(new HistoryUserTable { DocumentTableId = documentId, HistoryType = Models.Repository.HistoryType.CancelledDocument }, User.Identity.GetUserId());
392+
389393
_EmailService.SendInitiatorRejectEmail(documentId);
390394
return RedirectToAction("Index", "Document");
391395
}
@@ -440,6 +444,10 @@ public ActionResult DelegateDocumentTask(Guid processId, int type, Guid fileId,
440444

441445
DocumentTable documentTable = _DocumentService.Find(documentId);
442446
_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());
443451
}
444452

445453
return RedirectToAction("ShowDocument", new { id = documentId, isAfterView = true });
@@ -467,6 +475,8 @@ public ActionResult ApproveDocumentTask(Guid processId, int type, Guid fileId, F
467475

468476
_DocumentService.UpdateDocument(documentTable, User.Identity.GetUserId());
469477

478+
_HistoryUserService.SaveDomain(new HistoryUserTable { DocumentTableId = documentId, HistoryType = Models.Repository.HistoryType.ApproveDocument }, User.Identity.GetUserId());
479+
470480
_EmailService.SendInitiatorClosedEmail(documentTable.Id);
471481

472482
return RedirectToAction("ShowDocument", new { id = documentId, isAfterView = true });
@@ -486,25 +496,18 @@ public ActionResult RejectDocumentTask(Guid processId, int type, Guid fileId, Fo
486496

487497
DocumentTable documentTable = _DocumentService.Find(documentId);
488498
documentTable.WWFInstanceId = Guid.Empty;
489-
documentTable.DocumentState = DocumentState.Created;
499+
documentTable.DocumentState = DocumentState.Cancelled;
490500
documentTable.ActivityName = String.Empty;
491501

492502
_DocumentService.UpdateDocument(documentTable, User.Identity.GetUserId());
493503

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);
500505

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());
504507

505508
_EmailService.SendInitiatorClosedEmail(documentTable.Id);
506509

507-
return view;
510+
return RedirectToAction("Index", "Document");
508511
}
509512

510513
public ActionResult ProlongDocumentTask(string tableName, Guid documentId)
@@ -527,7 +530,9 @@ public ActionResult ProlongDocumentTask(string tableName, Guid documentId)
527530
return RedirectToAction("PageNotFound", "Error");
528531
}
529532
}
530-
533+
534+
_HistoryUserService.SaveDomain(new HistoryUserTable { DocumentTableId = documentId, HistoryType = Models.Repository.HistoryType.NewDocument }, User.Identity.GetUserId());
535+
531536
var viewModel = new DocumentComposite();
532537
viewModel.ProcessView = process;
533538
viewModel.docData = _DocumentService.RouteCustomModelView(process.TableName);
@@ -561,6 +566,8 @@ public ActionResult CreateTaskFromDocument(Guid documentId)
561566
}
562567
}
563568

569+
_HistoryUserService.SaveDomain(new HistoryUserTable { DocumentTableId = documentId, HistoryType = Models.Repository.HistoryType.NewDocument }, User.Identity.GetUserId());
570+
564571
var viewModel = new DocumentComposite();
565572
viewModel.ProcessView = process;
566573
viewModel.docData = _DocumentService.RouteCustomModelView(process.TableName);
@@ -781,6 +788,26 @@ public ActionResult Create(ProcessView processView, OperationType operationType,
781788
{
782789
if (ModelState.IsValid)
783790
{
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+
}
784811
//Save Document
785812
ApplicationUser user = _AccountService.Find(User.Identity.GetUserId());
786813
var documentId = _DocumentService.SaveDocument(docModel, processView.TableName, GuidNull2Guid(processView.Id), fileId, user);
@@ -1786,5 +1813,40 @@ protected override void Dispose(bool disposing)
17861813
}
17871814
base.Dispose(disposing);
17881815
}
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+
}
17891851
}
17901852
}

RapidDoc/Models/DomainModels/CustomDomainModelTemplate.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ public abstract class BasicDailyTasksTable : BasicDocumentTable
7979
public Guid? RefDocumentId { get; set; }
8080

8181
public string RefDocNum { get; set; }
82+
83+
public bool Separated { get; set; }
8284

8385
}
8486
}

RapidDoc/Models/Repository/Enums.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public enum HistoryType : byte
7171
RemoveReader = 5,
7272
DeletedFile = 6,
7373
Withdraw = 7,
74-
CopyDocumment = 8
74+
CopyDocumment = 8,
75+
DelegateTask = 9
7576
}
7677

7778
public enum FilterType : byte

RapidDoc/Models/Services/DocumentService.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public interface IDocumentService
6363
void Delete(Guid Id);
6464
List<string> SignDocumentCZ(Guid documentId, TrackerType trackerType, string comment = "");
6565
void SignTaskDocument(Guid documentId, TrackerType trackerType);
66-
List<USR_TAS_DailyTasks_Table> GetDocumentRefTask(Guid documentId);
66+
List<TaskDelegationView> GetDocumentRefTask(Guid documentId);
6767
}
6868

6969
public class DocumentService : IDocumentService
@@ -1056,9 +1056,18 @@ public void SignTaskDocument(Guid documentId, TrackerType trackerType)
10561056
SaveSignData(trackerTables, TrackerType.NonActive);
10571057
}
10581058

1059-
public List<USR_TAS_DailyTasks_Table> GetDocumentRefTask(Guid documentId)
1059+
public List<TaskDelegationView> GetDocumentRefTask(Guid documentId)
10601060
{
1061-
return _uow.GetDbContext<ApplicationDbContext>().USR_TAS_DailyTasks_Table.Where(x => x.RefDocumentId == documentId).ToList();
1061+
List<TaskDelegationView> taskDelegationList = new List<TaskDelegationView>();
1062+
1063+
var taskList= _uow.GetDbContext<ApplicationDbContext>().USR_TAS_DailyTasks_Table.Where(x => x.RefDocumentId == documentId).ToList();
1064+
1065+
taskList.ForEach(y => taskDelegationList.Add(new TaskDelegationView{ DocumentNum = y.DocumentTable.DocumentNum, DocumentId = y.DocumentTable.Id}));
1066+
1067+
var prolongationsList= _uow.GetDbContext<ApplicationDbContext>().USR_TAS_DailyTasksProlongation_Table.Where(x => x.RefDocumentId == documentId).ToList();
1068+
prolongationsList.ForEach(y => taskDelegationList.Add(new TaskDelegationView { DocumentNum = y.DocumentTable.DocumentNum, DocumentId = y.DocumentTable.Id }));
1069+
1070+
return taskDelegationList;
10621071
}
10631072
}
10641073
}

RapidDoc/Models/Services/EmailService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public void SendInitiatorEmail(Guid documentId)
216216
public void SendExecutorEmail(Guid documentId, string additionalTextCZ = "")
217217
{
218218
var documentTable = _DocumentService.Find(documentId);
219-
if (documentTable == null || (documentTable.DocumentState != DocumentState.Agreement && documentTable.DocumentState != DocumentState.Execution))
219+
if (documentTable == null || (documentTable.DocumentState != DocumentState.Agreement && documentTable.DocumentState != DocumentState.Execution && documentTable.DocumentState != DocumentState.OnSign))
220220
return;
221221

222222
dynamic ViewBag = new DynamicViewBag();

RapidDoc/Models/Services/WorkflowService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public WFUserFunctionResult WFUsersDocument(Guid documentId, string currentUserI
238238
Guid emplId = Guid.Parse(item);
239239
EmplTable empl = _EmplService.FindIntercompany(emplId);
240240

241-
if (empl != null && empl.Enable == true && empl.ApplicationUserId != null && empl.ApplicationUserId != documentTable.ApplicationUserCreatedId)
241+
if (empl != null && empl.Enable == true && empl.ApplicationUserId != null && (empl.ApplicationUserId != documentTable.ApplicationUserCreatedId || documentTable.DocType == DocumentType.Task))
242242
{
243243
userList.Add(new WFTrackerUsersTable { UserId = empl.ApplicationUserId });
244244
}

RapidDoc/Models/ViewModels/CustomDirectoryViewModels.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,10 @@ public class ItemCauseView: BasicCompanyNullView
6868
[Display(Name = "Включено")]
6969
public bool Enable { get; set; }
7070
}
71+
72+
public class TaskDelegationView
73+
{
74+
public string DocumentNum { get; set; }
75+
public Guid DocumentId { get; set; }
76+
}
7177
}

RapidDoc/Models/ViewModels/CustomViewModelTemplate.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,8 @@ public abstract class BasicDailyTasksView : BasicDocumentView
9393
public string RefDocNum { get; set; }
9494

9595
public Guid? RefDocumentId { get; set; }
96+
97+
[Display(Name = "Каждому исполнителю отдельную карточку")]
98+
public bool Separated { get; set; }
9699
}
97100
}

RapidDoc/Resources/UIElement/UIElement.Designer.cs

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)