/// <summary> /// Получить последнего утвердившего документ. /// </summary> /// <param name="document">Документ.</param> /// <returns>Подписавший.</returns> public static IEmployee GetDocumentLastApprover(IElectronicDocument document) { return(Employees.As(Signatures.Get(document.LastVersion) .Where(s => s.SignatureType == SignatureType.Approval) .OrderByDescending(s => s.SigningDate) .Select(s => s.Signatory) .FirstOrDefault())); }
public static bool IsDocumentVersionSignatureValid(Docflow.IOfficialDocument document, int version) { var documentVersion = document.Versions.FirstOrDefault(x => x.Number == version); // Проверяем только согласующую и утверждающую подпись. Не согласовано = отсутствие подписи. var signatures = Signatures.Get(documentVersion).Where(x => x.SignatureType != SignatureType.NotEndorsing); var hasAnySignature = signatures.Any(); var hasAnyValidSignature = signatures.Any(x => x.IsValid && !x.ValidationErrors.Any()); return(!hasAnySignature || hasAnyValidSignature); }
public static bool HasUnsignedSellerTitle(Docflow.IAccountingDocumentBase statement) { if (statement.SellerTitleId != null) { var existingSellerTitle = statement.Versions.Where(x => x.Id == statement.SellerTitleId).FirstOrDefault(); if (existingSellerTitle != null && !Signatures.Get(existingSellerTitle).Any()) { return(true); } } return(false); }
public virtual int?GetSenderSignatureId(IOfficialDocument document, Sungero.Content.IElectronicDocumentVersions version) { var info = Exchange.PublicFunctions.ExchangeDocumentInfo.Remote.GetExDocumentInfoFromVersion(document, version.Id); var senderSignature = Signatures.Get(version).Where(x => x.Id == info.SenderSignId).SingleOrDefault(); if (senderSignature != null) { return(senderSignature.Id); } else { return(null); } }
public override void BeforeSigning(Sungero.Domain.BeforeSigningEventArgs e) { base.BeforeSigning(e); // Если подписание выполняется в рамках агента - генерировать заглушку не надо. bool jobRan; if (e.Params.TryGetValue(ExchangeCore.PublicConstants.BoxBase.JobRunned, out jobRan) && jobRan) { return; } if (_obj.BuyerTitleId.HasValue && e.Signature.SignatureType == SignatureType.Approval && !Signatures.Get(_obj.Versions.Single(v => v.Id == _obj.BuyerTitleId.Value)).Any(s => s.SignatureType == SignatureType.Approval)) { Docflow.PublicFunctions.Module.GenerateTempPublicBodyForExchangeDocument(_obj, _obj.BuyerTitleId.Value); Exchange.PublicFunctions.Module.EnqueueXmlToPdfBodyConverter(_obj, _obj.BuyerTitleId.Value, _obj.ExchangeState); } }
internal FileStreamScanner( AMSIClient client , string filePath , int blockSize , bool acceptEncryptedZipEntries ) { this.client = client; this.filePath = filePath; fileInfo = new FileInfo(filePath); this.blockSize = blockSize; this.acceptEncryptedZipEntries = acceptEncryptedZipEntries; buffer = new byte[blockSize]; cancellationTokenSource = new CancellationTokenSource(); using (var signatureReader = new FileSignatureReader(filePath, Signatures.Get())) fileSignature = signatureReader.GetFileSignature(); md5Hash = client.Configuration.SkipContentHashing ? Task.FromResult((string)null) : Task.Run(() => fileInfo.GetFileMD5Hash(), cancellationTokenSource.Token); }
public virtual bool NeedShowSignRecommendation(bool isElectronicAcquaintance, Docflow.IOfficialDocument document) { // Проверка актуальна только для черновиков и электронного ознакомления. var isDraft = _obj.Status.Value == Status.Draft; if (!isDraft || !isElectronicAcquaintance) { return(false); } // Нет тела - проверка не нужна. if (document == null || !document.HasVersions) { return(false); } // Проверить подпись только по белому списку. var inWhiteList = this.IsEditableDocumentFormat(document); var hasApprovalSignatures = Signatures.Get(document.LastVersion).Any(x => x.SignatureType == SignatureType.Approval); return(!hasApprovalSignatures && inWhiteList); }
public ScanResult ScanFile(string filePath) { client.DetermineDetectionEngine(); using (var resultBuilder = new ResultBuilder( new ScanContext(client, null, filePath, ContentType.File, FileType.Unknown, 0, null))) using (var signatureReader = new FileSignatureReader(filePath, Signatures.Get())) if (!signatureReader.FileExists()) { return(resultBuilder.ToResult(DetectionResult.FileNotExists, $"File not found at {filePath}")); } else if (signatureReader.IsFileBlocked()) { return(resultBuilder.ToResultBlocked()); } using (var reader = new FileStreamScannerSession( client , filePath , client.Configuration.FileScannerBlockSize , client.Configuration.FileScannerAcceptZipFileWithEncryptedEntry)) return(reader.Scan()); }
public static StateView CreateApprovalListStateView(IOfficialDocument document) { // Задать текст по умолчанию. var stateView = StateView.Create(); stateView.AddDefaultLabel(OfficialDocuments.Resources.DocumentIsNotSigned); if (document == null) { return(stateView); } // Сформировать список подписей. var filteredSignatures = new List <Structures.ApprovalReviewAssignment.SignaturesInfo>(); var signatures = new List <Structures.ApprovalReviewAssignment.DocumentSignature>(); var signatureList = new List <Domain.Shared.ISignature>(); var externalSignatures = new List <Structures.ApprovalReviewAssignment.DocumentSignature>(); var externalSignatureList = new List <Domain.Shared.ISignature>(); foreach (var version in document.Versions.OrderByDescending(v => v.Created)) { // Получить к версии Согласующие и Утверждающие подписи в порядке подписывания. var versionSignatures = Signatures.Get(version).Where(s => s.SignatureType != SignatureType.NotEndorsing).OrderByDescending(s => s.SigningDate); // Вывести информацию о подписях. foreach (var signature in versionSignatures) { if (signature.IsExternal == true) { externalSignatures.Add(Structures.ApprovalReviewAssignment.DocumentSignature.Create(signature.Id, signature.SigningDate, version.Number)); externalSignatureList.Add(signature); continue; } var signatureTypeString = signature.SignatureType == SignatureType.Approval ? Constants.ApprovalReviewAssignment.ApprovalSignatureType : Constants.ApprovalReviewAssignment.EndorsingSignatureType; if (!filteredSignatures.Where(f => Equals(f.Signatory, signature.Signatory) && Equals(f.SubstitutedUser, signature.SubstitutedUser) && Equals(f.SignatoryType, signatureTypeString)).Any()) { filteredSignatures.Add(Structures.ApprovalReviewAssignment.SignaturesInfo.Create(signature.Signatory, signature.SubstitutedUser, signatureTypeString)); signatures.Add(Structures.ApprovalReviewAssignment.DocumentSignature.Create(signature.Id, signature.SigningDate, version.Number)); signatureList.Add(signature); } } } // Проверить, что подписи есть. if (!signatures.Any()) { return(stateView); } // Добавить подписи: по убыванию даты подписи, без учета версии. foreach (var signatureInfo in signatures.OrderBy(s => s.SigningDate)) { var signingBlock = stateView.AddBlock(); if (externalSignatures.Any() && signatureInfo.Equals(signatures.OrderBy(s => s.SigningDate).Last())) { signingBlock.DockType = DockType.None; } else { signingBlock.DockType = DockType.Bottom; } var signature = signatureList.Single(s => s.Id == signatureInfo.SignatureId); var versionNumber = signatureInfo.VersionNumber; AddSignatureInfoToBlock(signingBlock, signature, versionNumber); } if (externalSignatures.Any()) { // Добавить информацию о внешних подписях. foreach (var signatureInfo in externalSignatures.OrderBy(s => s.SigningDate)) { var signingBlock = stateView.AddBlock(); var signature = externalSignatureList.Single(s => s.Id == signatureInfo.SignatureId); var versionNumber = signatureInfo.VersionNumber; AddExternalSignatureInfoToBlock(signingBlock, signature, versionNumber, document); signingBlock.DockType = DockType.Bottom; } } return(stateView); }