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; }
private static void AddSignatureInfoToBlock(StateBlock signingBlock, Sungero.Domain.Shared.ISignature signature, int?versionNumber) { // Добавить подписавшего. var signatory = Sungero.Company.Employees.As(signature.Signatory); if (signatory != null) { signingBlock.AddLabel(string.Format("{0} {1}", signatory.JobTitle, Company.PublicFunctions.Employee.GetShortName(signatory, false)), Functions.Module.CreateHeaderStyle()); } else { signingBlock.AddLabel(signature.Signatory.Name, Functions.Module.CreateHeaderStyle()); } // Добавить дату подписания. var signDate = signature.SigningDate.FromUtcTime().ToUserTime(); signingBlock.AddLabel(string.Format("{0}: {1}", OfficialDocuments.Resources.StateViewDate.ToString(), Functions.Module.ToShortDateShortTime(signDate)), Functions.Module.CreatePerformerDeadlineStyle()); // Добавить замещаемого. var substitutedUser = GetSubstitutedEmployee(signature); if (!string.IsNullOrEmpty(substitutedUser)) { signingBlock.AddLineBreak(); signingBlock.AddLabel(substitutedUser); } // Добавить комментарий пользователя. var comment = GetSignatureComment(signature); if (!string.IsNullOrEmpty(comment)) { signingBlock.AddLineBreak(); signingBlock.AddLabel(Constants.Module.SeparatorText, Docflow.PublicFunctions.Module.CreateSeparatorStyle()); signingBlock.AddLineBreak(); var commentStyle = Functions.Module.CreateNoteStyle(); signingBlock.AddLabel(comment, commentStyle); } // Добавить номер версии документа. 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); // Установить иконку. SetIconToBlock(signingBlock, signature); }
private static void AddValidationInfoToBlock(StateBlock block, Sungero.Domain.Shared.ISignature signature) { var redTextStyle = Functions.Module.CreateStyle(Sungero.Core.Colors.Common.Red); var greenTextStyle = Functions.Module.CreateStyle(Sungero.Core.Colors.Common.Green); var separator = ". "; var errorValidationText = string.Empty; var validationInfo = GetValidationInfo(signature); if (validationInfo.IsInvalidCertificate) { errorValidationText += ApprovalReviewAssignments.Resources.StateViewCertificateIsNotValid + separator; } if (validationInfo.IsInvalidData) { errorValidationText += ApprovalReviewAssignments.Resources.StateViewDocumentIsChanged + separator; } if (validationInfo.IsInvalidAttributes) { errorValidationText += ApprovalReviewAssignments.Resources.StateViewSignatureAttributesNotValid + separator; } // Если нет ошибок - выйти. if (string.IsNullOrWhiteSpace(errorValidationText)) { return; } block.AddLineBreak(); block.AddLabel(errorValidationText, redTextStyle); // Для подписи с невалидными атрибутами добавить информацию, что тело небыло изменено. if (validationInfo.IsInvalidAttributes && !validationInfo.IsInvalidData) { var trueValidationText = ApprovalReviewAssignments.Resources.StateViewDocumentIsValid + separator; block.AddLabel(trueValidationText, greenTextStyle); } }