Ejemplo n.º 1
0
        /// <summary>
        /// Установить иконку.
        /// </summary>
        /// <param name="block">Блок, для которого требуется установить иконку.</param>
        /// <param name="assignment">Задание, от которого построен блок.</param>
        private void SetIcon(StateBlock block, IExchangeDocumentProcessingAssignment assignment)
        {
            var iconSize = StateBlockIconSize.Large;

            // Иконка по умолчанию.
            block.AssignIcon(StateBlockIconType.OfEntity, iconSize);

            // Прекращено, остановлено по ошибке.
            if (assignment.Status == Workflow.AssignmentBase.Status.Aborted ||
                assignment.Status == Workflow.AssignmentBase.Status.Suspended ||
                assignment.Result == Exchange.ExchangeDocumentProcessingAssignment.Result.Abort)
            {
                block.AssignIcon(StateBlockIconType.Abort, iconSize);
                return;
            }

            if (assignment.Result == null)
            {
                return;
            }

            if (assignment.Result == Exchange.ExchangeDocumentProcessingAssignment.Result.Complete ||
                assignment.Result == Exchange.ExchangeDocumentProcessingAssignment.Result.ReAddress)
            {
                block.AssignIcon(StateBlockIconType.Completed, iconSize);
                return;
            }
        }
Ejemplo n.º 2
0
 private static void SetIconToBlock(StateBlock signingBlock, Sungero.Domain.Shared.ISignature signature)
 {
     if (signature.IsValid)
     {
         if (signature.SignatureType == Core.SignatureType.Approval)
         {
             signingBlock.AssignIcon(ApprovalTasks.Resources.Sign, StateBlockIconSize.Small);
         }
         else
         {
             signingBlock.AssignIcon(ApprovalTasks.Resources.Approve, StateBlockIconSize.Small);
         }
     }
     else
     {
         if (signature.ValidationErrors.Any(e => e.ErrorType == Sungero.Domain.Shared.SignatureValidationErrorType.Signature))
         {
             signingBlock.AssignIcon(ApprovalReviewAssignments.Resources.SignatureAttributeChanged, StateBlockIconSize.Small);
         }
         else
         {
             signingBlock.AssignIcon(ApprovalReviewAssignments.Resources.SignedDataChanged, StateBlockIconSize.Small);
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Установить иконку.
        /// </summary>
        /// <param name="block">Блок, для которого требуется установить иконку.</param>
        /// <param name="assignment">Задание, от которого построен блок.</param>
        private void SetIcon(StateBlock block, IVerificationAssignment assignment)
        {
            var iconSize = StateBlockIconSize.Large;

            // Иконка по умолчанию.
            block.AssignIcon(StateBlockIconType.OfEntity, iconSize);

            // Прекращено, остановлено по ошибке.
            if (assignment.Status == Workflow.AssignmentBase.Status.Aborted ||
                assignment.Status == Workflow.AssignmentBase.Status.Suspended)
            {
                block.AssignIcon(StateBlockIconType.Abort, iconSize);
                return;
            }

            if (assignment.Result == null)
            {
                return;
            }

            // Проверено.
            if (assignment.Result == SmartProcessing.VerificationAssignment.Result.Complete)
            {
                block.AssignIcon(StateBlockIconType.Completed, iconSize);
                return;
            }

            // Переадресовано.
            if (assignment.Result == SmartProcessing.VerificationAssignment.Result.Forward)
            {
                block.AssignIcon(Sungero.Docflow.FreeApprovalTasks.Resources.Forward, iconSize);
            }
        }
Ejemplo n.º 4
0
        private static void AddExternalSignatureInfoToBlock(StateBlock signingBlock, Sungero.Domain.Shared.ISignature signature, int?versionNumber, IOfficialDocument document)
        {
            var subject       = Docflow.PublicFunctions.Module.GetSignatureCertificate(signature.GetDataSignature()).SubjectName.Format(true);
            var parsedSubject = ParseSignatureSubject(subject);

            signingBlock.AddLabel(ApprovalReviewAssignments.Resources.SignatureBlockFormat(parsedSubject.JobTitle,
                                                                                           Docflow.Server.ModuleFunctions.GetCertificateOwnerShortName(parsedSubject),
                                                                                           parsedSubject.OrganizationName,
                                                                                           parsedSubject.TIN),
                                  Functions.Module.CreateHeaderStyle());
            signingBlock.AddLineBreak();
            signingBlock.AddLabel(Constants.Module.SeparatorText, Docflow.PublicFunctions.Module.CreateSeparatorStyle());
            signingBlock.AddLineBreak();

            var exchangeServiceName = GetOriginalExchangeServiceNameByDocument(document);

            signingBlock.AddLabel(ApprovalReviewAssignments.Resources.DocumentSignedByCounterpartyIsExchangeServiceNoteFormat(exchangeServiceName),
                                  Docflow.PublicFunctions.Module.CreateNoteStyle());

            var number      = versionNumber.HasValue ? versionNumber.Value.ToString() : string.Empty;
            var numberLabel = string.Format("{0} {1}", ApprovalReviewAssignments.Resources.StateViewVersion, number);

            Functions.Module.AddInfoToRightContent(signingBlock, numberLabel, Docflow.PublicFunctions.Module.CreateNoteStyle());

            // Добавить информацию о валидности подписи.
            AddValidationInfoToBlock(signingBlock, signature);

            // Установить иконку.
            signingBlock.AssignIcon(Docflow.ApprovalReviewAssignments.Resources.ExternalSignatureIcon, StateBlockIconSize.Small);

            signingBlock.DockType = DockType.Bottom;
        }
Ejemplo n.º 5
0
        public Sungero.Core.StateView GetStateView()
        {
            // Добавить заголовок.
            var stateView = StateView.Create();

            var taskBeginText = _obj.Texts.OrderBy(t => t.Created).FirstOrDefault();
            var comment       = taskBeginText != null ? taskBeginText.Body : string.Empty;

            comment = comment != FreeApprovalTasks.Resources.ApprovalText ? comment : string.Empty;
            if (_obj.Started.HasValue)
            {
                Docflow.PublicFunctions.OfficialDocument
                .AddUserActionBlock(stateView, _obj.Author, ApprovalTasks.Resources.StateViewDocumentSentForApproval, _obj.Started.Value, _obj, comment, _obj.StartedBy);
            }
            else
            {
                Docflow.PublicFunctions.OfficialDocument
                .AddUserActionBlock(stateView, _obj.Author, ApprovalTasks.Resources.StateViewTaskDrawCreated, _obj.Created.Value, _obj, comment, _obj.Author);
            }

            // Добавить основной блок для задачи.
            var taskBlock = this.AddTaskBlock(stateView);

            // Получить все задания по задаче.
            var taskAssignments = Assignments.GetAll().Where(a => Equals(a.Task, _obj)).ToList();

            // Определить итерации.
            var iterations = Functions.Module.GetIterationDates(_obj);

            // Обработать каждую итерацию.
            foreach (var iteration in iterations)
            {
                var date             = iteration.Date;
                var hasReworkBefore  = iteration.IsRework;
                var hasRestartBefore = iteration.IsRestart;

                var nextIteration = iterations.Where(d => d.Date > date).FirstOrDefault();
                var nextDate      = Calendar.Now;

                if (nextIteration != null)
                {
                    nextDate = nextIteration.Date;
                }

                // Получить задания в рамках круга согласования.
                var assignments = taskAssignments
                                  .Where(a => a.Created >= date && a.Created < nextDate)
                                  .OrderBy(a => a.Created)
                                  .ToList();

                // Если нет заданий, то перейти к следующей итерации.
                if (!assignments.Any())
                {
                    continue;
                }

                // Добавить блок отправки.
                this.AddSendForApprovalBlock(taskBlock, assignments.First(), hasReworkBefore, hasRestartBefore);

                StateBlock parentBlock = null;

                // Выделить этап согласования.
                var approvalAssignments = assignments.Where(a => FreeApprovalAssignments.Is(a));
                if (approvalAssignments.Any())
                {
                    // Вставить блок для группировки этапа согласования.
                    var iterationBlock = taskBlock.AddChildBlock();
                    iterationBlock.NeedGroupChildren = true;
                    iterationBlock.IsExpanded        = approvalAssignments.Any(a => a.Status == Workflow.AssignmentBase.Status.InProcess);

                    // Заголовок блока итерации.
                    iterationBlock.AddLabel(ApprovalTasks.Resources.StateViewApprovalStage, Docflow.PublicFunctions.Module.CreateHeaderStyle());
                    iterationBlock.AddLineBreak();

                    // Добавить информацию по исполнителям группы согласования.
                    var performersLabel = string.Join(", ", approvalAssignments
                                                      .Select(a => a.Performer)
                                                      .Distinct()
                                                      .Select(a => (Sungero.Company.Employees.Is(a) ?
                                                                    Company.PublicFunctions.Employee.GetShortName(Sungero.Company.Employees.As(a), false) :
                                                                    a.Name)));
                    iterationBlock.AddLabel(performersLabel, Docflow.PublicFunctions.Module.CreatePerformerDeadlineStyle());

                    parentBlock = iterationBlock;
                }

                // Добавить задания.
                assignments = assignments.OrderByDescending(a => a.Result.HasValue).ThenBy(a => a.Completed).ToList();
                this.AddAssignmentsBlocks(parentBlock, taskBlock, assignments);

                // Установить иконку и статус для группировки этапа согласования.
                var endStatus = string.Empty;
                if (parentBlock != null)
                {
                    // Иконка по умолчанию.
                    parentBlock.AssignIcon(FreeApprovalTasks.Resources.FreeApproveStage, StateBlockIconSize.Large);

                    if (approvalAssignments.Any(a => a.Result == Docflow.FreeApprovalAssignment.Result.ForRework))
                    {
                        parentBlock.AssignIcon(ApprovalTasks.Resources.Notapprove, StateBlockIconSize.Large);
                        endStatus = ApprovalTasks.Resources.StateViewNotApproved;
                    }
                    else if (!approvalAssignments.Any(a => a.Result != Docflow.FreeApprovalAssignment.Result.Approved))
                    {
                        parentBlock.AssignIcon(ApprovalTasks.Resources.Approve, StateBlockIconSize.Large);
                        endStatus = ApprovalTasks.Resources.StateViewEndorsed;
                    }

                    if (assignments.Any(a => a.Status == Workflow.AssignmentBase.Status.Aborted))
                    {
                        parentBlock.AssignIcon(StateBlockIconType.Abort, StateBlockIconSize.Large);
                        endStatus = ApprovalTasks.Resources.StateViewAborted;
                    }

                    Functions.Module.AddInfoToRightContent(parentBlock, parentBlock.IsExpanded ? ApprovalTasks.Resources.StateViewInProcess : endStatus);
                }
            }

            return(stateView);
        }