public virtual void StartBlock7(Sungero.Docflow.Server.FreeApprovalNotificationArguments e) { // Синхронизировать группу приложений документа. var document = _obj.ForApprovalGroup.ElectronicDocuments.FirstOrDefault(); Functions.Module.SynchronizeAddendaAndAttachmentsGroup(_obj.AddendaGroup, document); if (OfficialDocuments.Is(document)) { Functions.OfficialDocument.AddRelatedDocumentsToAttachmentGroup(OfficialDocuments.As(document), _obj.OtherGroup); } e.Block.Subject = Functions.Module.TrimSpecialSymbols(FreeApprovalTasks.Resources.NewApprovalLapSubject, _obj.ForApprovalGroup.ElectronicDocuments.First().Name); var approvalReworkAssignments = FreeApprovalReworkAssignments.GetAll(asg => asg.Task.Equals(_obj) && asg.TaskStartId == _obj.StartId); if (approvalReworkAssignments.Any()) { var lastApprovalReworkAssignments = approvalReworkAssignments.OrderByDescending(asg => asg.Created).First(); foreach (var recipient in lastApprovalReworkAssignments.Approvers.Where(apr => apr.Action == Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Action.SendNotice)) { e.Block.Performers.Add(recipient.Approver); } } }
public virtual void DocumentForReviewGroupAdded(Sungero.Workflow.Interfaces.AttachmentAddedEventArgs e) { var document = OfficialDocuments.As(e.Attachment); // Задать тему. using (TenantInfo.Culture.SwitchTo()) _obj.Subject = Docflow.PublicFunctions.Module.TrimSpecialSymbols(DocumentReviewTasks.Resources.Consideration, document.Name); // Задать адресата. if (IncomingDocumentBases.Is(document)) { _obj.Addressee = IncomingDocumentBases.As(document).Addressee; } if (Memos.Is(document)) { _obj.Addressee = Memos.As(document).Addressee; } // Задать срок рассмотрения. var addressee = _obj.Addressee ?? Users.Current; _obj.Deadline = Docflow.PublicFunctions.DocumentKind.GetConsiderationDate(document.DocumentKind, addressee) ?? Calendar.Now.AddWorkingDays(addressee, Functions.Module.Remote.GetDocumentReviewDefaultDays()); if (!_obj.State.IsCopied) { Docflow.PublicFunctions.Module.SynchronizeAddendaAndAttachmentsGroup(_obj.AddendaGroup, _obj.DocumentForReviewGroup.OfficialDocuments.FirstOrDefault()); } Docflow.PublicFunctions.OfficialDocument.DocumentAttachedInMainGroup(document, _obj); // Добавить вложения. Docflow.PublicFunctions.OfficialDocument.AddRelatedDocumentsToAttachmentGroup(document, _obj.OtherGroup); }
public virtual void SendForApproval(Sungero.Domain.Client.ExecuteActionArgs e) { // Проверить заполненность обязательных полей во всех документах комплекта. var attachments = _obj.AllAttachments.Select(a => Content.ElectronicDocuments.As(a)).Distinct().ToList(); if (attachments.Cast <Docflow.IOfficialDocument>().Any(x => Sungero.Docflow.PublicFunctions.OfficialDocument.HasEmptyRequiredProperties(x))) { e.AddError(VerificationAssignments.Resources.InvalidDocumentWhenSendInWork, _obj.Info.Actions.ShowInvalidDocuments); return; } // Определить главный документ. var suitableDocuments = Docflow.PublicFunctions.OfficialDocument.GetSuitableDocuments(attachments, Docflow.OfficialDocuments.Info.Actions.SendForApproval); var probablyMainDocument = Content.ElectronicDocuments.As(Functions.Module.GetLeadingDocument(suitableDocuments.Cast <IOfficialDocument>().ToList())); var mainDocument = Docflow.PublicFunctions.OfficialDocument.ChooseMainDocument(suitableDocuments, new List <Content.IElectronicDocument> { probablyMainDocument }); if (mainDocument == null) { return; } var mainOfficialDocument = OfficialDocuments.As(mainDocument); // Если по главному документу ранее были запущены задачи, то вывести соответствующий диалог. if (!Docflow.PublicFunctions.OfficialDocument.NeedCreateApprovalTask(mainOfficialDocument)) { return; } var approvalTask = Docflow.PublicFunctions.Module.Remote.CreateApprovalTask(mainOfficialDocument); // Проверить наличие регламента. if (approvalTask.ApprovalRule != null) { // Добавить вложения. foreach (var attachment in attachments.Where(att => !Equals(att, mainDocument))) { if (!Docflow.PublicFunctions.OfficialDocument.NeedToAttachDocument(attachment, mainOfficialDocument)) { continue; } else { approvalTask.OtherGroup.All.Add(attachment); } } approvalTask.Show(); } else { // Если по документу нет регламента, вывести сообщение. Dialogs.ShowMessage(Docflow.OfficialDocuments.Resources.NoApprovalRuleWarning, MessageType.Warning); return; } }
/// <summary> /// Синхронизировать группу приложений документа. /// </summary> public virtual void SynchronizeAddendaAndAttachmentsGroup() { var document = _obj.ForApprovalGroup.ElectronicDocuments.FirstOrDefault(); Functions.Module.SynchronizeAddendaAndAttachmentsGroup(_obj.AddendaGroup, document); if (OfficialDocuments.Is(document)) { Functions.OfficialDocument.AddRelatedDocumentsToAttachmentGroup(OfficialDocuments.As(document), _obj.OtherGroup); } }
/// <summary> /// Получить документ игнорируя права доступа. /// </summary> /// <param name="documentId">ИД документа.</param> /// <returns>Документ.</returns> public static IOfficialDocument GetOfficialDocumentIgnoreAccessRights(int documentId) { // HACK Котегов: использование внутренней сессии для обхода прав доступа. Logger.DebugFormat("GetOfficialDocumentIgnoreAccessRights: documentId {0}", documentId); using (var session = new Sungero.Domain.Session()) { var innerSession = (Sungero.Domain.ISession)session.GetType() .GetField("InnerSession", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(session); return(OfficialDocuments.As((Sungero.Domain.Shared.IEntity)innerSession.Get(typeof(IOfficialDocument), documentId))); } }
public virtual void ForApprovalGroupDeleted(Sungero.Workflow.Interfaces.AttachmentDeletedEventArgs e) { Functions.Module.SynchronizeAddendaAndAttachmentsGroup(_obj.AddendaGroup, null); // Очистить группу "Дополнительно". var document = OfficialDocuments.As(e.Attachment); if (OfficialDocuments.Is(document)) { Functions.OfficialDocument.RemoveRelatedDocumentsFromAttachmentGroup(OfficialDocuments.As(document), _obj.OtherGroup); } _obj.Subject = Docflow.Resources.AutoformatTaskSubject; }
public virtual void StartBlock6(Sungero.Docflow.Server.FreeApprovalNotificationArguments e) { // Синхронизировать группу приложений документа. var document = _obj.ForApprovalGroup.ElectronicDocuments.FirstOrDefault(); Functions.Module.SynchronizeAddendaAndAttachmentsGroup(_obj.AddendaGroup, document); if (OfficialDocuments.Is(document)) { Functions.OfficialDocument.AddRelatedDocumentsToAttachmentGroup(OfficialDocuments.As(document), _obj.OtherGroup); } e.Block.Performers.Add(_obj.Author); e.Block.Subject = Functions.Module.TrimSpecialSymbols(FreeApprovalTasks.Resources.ApprovalCompletedSubject, _obj.ForApprovalGroup.ElectronicDocuments.First().Name); }
public virtual void StartBlock11(Sungero.Docflow.Server.FreeApprovalNotificationArguments e) { // Синхронизировать группу приложений документа. var document = _obj.ForApprovalGroup.ElectronicDocuments.FirstOrDefault(); Functions.Module.SynchronizeAddendaAndAttachmentsGroup(_obj.AddendaGroup, document); if (OfficialDocuments.Is(document)) { Functions.OfficialDocument.AddRelatedDocumentsToAttachmentGroup(OfficialDocuments.As(document), _obj.OtherGroup); } e.Block.Performers.Add(_obj.Author); var lastIterationId = Functions.FreeApprovalTask.GetApprovalAssignmentLastIterationId(_obj); var firstApprovalAssignment = Functions.FreeApprovalTask.GetLastAssignmentWithoutNotice(_obj, lastIterationId).First(); e.Block.LinkedFreeApprovalAssignment = firstApprovalAssignment; e.Block.Subject = Functions.Module.TrimSpecialSymbols(FreeApprovalTasks.Resources.ReworkNoticeSubject, _obj.ForApprovalGroup.ElectronicDocuments.First().Name); }
public override void SendByMail(Sungero.Domain.Client.ExecuteActionArgs e) { if (this.Entities.Count() != 1) { base.SendByMail(e); return; } var document = OfficialDocuments.As(_objs.FirstOrDefault()); var relations = Functions.OfficialDocument.GetRelatedDocumentsWithVersions(document); if (relations.Count > 0) { Functions.OfficialDocument.SelectRelatedDocumentsAndCreateEmail(document, relations); } else { base.SendByMail(e); } }
public virtual void ForApprovalGroupAdded(Sungero.Workflow.Interfaces.AttachmentAddedEventArgs e) { var document = _obj.ForApprovalGroup.ElectronicDocuments.First(); // Получить ресурсы в культуре тенанта. using (TenantInfo.Culture.SwitchTo()) _obj.Subject = Functions.Module.TrimSpecialSymbols(FreeApprovalTasks.Resources.TaskSubject, document.Name); if (!_obj.State.IsCopied) { Functions.Module.SynchronizeAddendaAndAttachmentsGroup(_obj.AddendaGroup, document); if (OfficialDocuments.Is(document)) { Functions.OfficialDocument.AddRelatedDocumentsToAttachmentGroup(OfficialDocuments.As(document), _obj.OtherGroup); } } if (OfficialDocuments.Is(document)) { Functions.OfficialDocument.DocumentAttachedInMainGroup(OfficialDocuments.As(document), _obj); } }
public virtual void StartBlock3(Sungero.Docflow.Server.FreeApprovalReworkAssignmentArguments e) { // Синхронизировать группу приложений документа. var document = _obj.ForApprovalGroup.ElectronicDocuments.FirstOrDefault(); Functions.Module.SynchronizeAddendaAndAttachmentsGroup(_obj.AddendaGroup, document); if (OfficialDocuments.Is(document)) { Functions.OfficialDocument.AddRelatedDocumentsToAttachmentGroup(OfficialDocuments.As(document), _obj.OtherGroup); } e.Block.Performers.Add(_obj.Author); e.Block.RelativeDeadlineDays = 3; e.Block.Subject = Functions.Module.TrimSpecialSymbols(FreeApprovalTasks.Resources.RevisionAsgSubject, _obj.ForApprovalGroup.ElectronicDocuments.First().Name); if (_obj.MaxDeadline.HasValue) { e.Block.NewDeadline = _obj.MaxDeadline; } var approvalAssignments = FreeApprovalAssignments.GetAll(asg => asg.Task.Equals(_obj) && asg.TaskStartId == _obj.StartId); var reworkAssignments = FreeApprovalReworkAssignments.GetAll(asg => asg.Task.Equals(_obj) && asg.TaskStartId == _obj.StartId); var lastIterationId = Functions.FreeApprovalTask.GetApprovalAssignmentLastIterationId(_obj); // Если заданий на доработку не было, то заполняем всю таблицу из заданий по задаче, // если были - то исполнителей берем из последнего задания на доработку, а результат и действие заполняем по последним заданиям на согласование. if (!reworkAssignments.Any()) { foreach (var aprAssignment in approvalAssignments.Where(asg => asg.IterationId == lastIterationId).OrderBy(i => i.Created)) { Functions.FreeApprovalTask.AddToReworkAssigneeNewApprover(e, aprAssignment); } } else { var approvalReworkAssignmentFromLastIteration = reworkAssignments.OrderByDescending(asg => asg.Created).First(); foreach (var asgApprover in approvalReworkAssignmentFromLastIteration.Approvers.OrderBy(asg => asg.Id)) { // Копируем все значения. var newApprover = e.Block.Approvers.FirstOrDefault(a => Equals(a.Approver, asgApprover.Approver)) ?? e.Block.Approvers.AddNew(); newApprover.Approver = asgApprover.Approver; newApprover.Approved = asgApprover.Approved; newApprover.Action = asgApprover.Action; // Если результат согласования изменился \ согласование не было выполнено - перебиваем данные. var lastApprovalAsg = approvalAssignments.Where(asg => asg.Performer.Equals(asgApprover.Approver)).OrderByDescending(asg => asg.IterationId).ThenByDescending(asg => asg.Modified).FirstOrDefault(); if (lastApprovalAsg != null) { if (lastApprovalAsg.Result == Sungero.Docflow.FreeApprovalAssignment.Result.Approved) { newApprover.Approved = Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Approved.IsApproved; newApprover.Action = newApprover.Action == Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Action.SendForApproval ? Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Action.SendNotice : Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Action.DoNotSend; } else if (lastApprovalAsg.Result == Sungero.Docflow.FreeApprovalAssignment.Result.Forward) { newApprover.Approved = Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Approved.NotApproved; newApprover.Action = Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Action.DoNotSend; } else { newApprover.Approved = Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Approved.NotApproved; newApprover.Action = Sungero.Docflow.FreeApprovalReworkAssignmentApprovers.Action.SendForApproval; } } } foreach (var newApproval in approvalAssignments.Where(a => a.IterationId == lastIterationId).OrderBy(i => i.Created)) { Functions.FreeApprovalTask.AddToReworkAssigneeNewApprover(e, newApproval); } } }