public static List <IPowerOfAttorney> GetActivePowerOfAttorneys(Company.IEmployee employee, DateTime?date) { return(PowerOfAttorneys .GetAll(p => Equals(p.IssuedTo, employee) && (p.RegistrationDate == null || p.RegistrationDate <= date) && date <= p.ValidTill && (p.LifeCycleState == LifeCycleState.Draft || p.LifeCycleState == LifeCycleState.Active)) .ToList()); }
public virtual bool CanForwardTo(Company.IEmployee employee) { var assignments = FreeApprovalAssignments.GetAll(a => Equals(a.Task, _obj.Task) && Equals(a.TaskStartId, _obj.TaskStartId) && Equals(a.IterationId, _obj.IterationId)); // Если у сотрудника есть хоть одно задание в работе - считаем, что нет смысла дублировать ему задания. // BUG: если assignments материализовать (завернуть ToList), то в задании можно будет переадресовать самому себе, т.к. в BeforeComplete задание считается уже выполненным. var hasInProcess = assignments.Where(a => Equals(a.Status, Status.InProcess) && Equals(a.Performer, employee)).Any(); if (hasInProcess) { return(false); } var materialized = assignments.ToList(); // Если у сотрудника нет заданий в работе, проверяем, все ли его задания созданы. foreach (var assignment in materialized) { var added = assignment.ForwardedTo.Count(u => Equals(u, employee)); var created = materialized.Count(a => Equals(a.Performer, employee) && Equals(a.ForwardedFrom, assignment)); if (added != created) { return(false); } } return(true); }
public virtual void GenerateDefaultAnswer(Company.IEmployee signatory, bool isAgent) { IPowerOfAttorney signatoryPowerOfAttorney = null; IPowerOfAttorney consigneePowerOfAttorney = null; var signatoryOtherReason = string.Empty; var signaturesSettings = Functions.OfficialDocument.GetSignatureSettings(_obj, signatory); var signaturesSettingWithDuties = signaturesSettings.Where(o => Equals(o.Reason, Docflow.SignatureSetting.Reason.Duties)).FirstOrDefault(); var signaturesSettingWithPowerOfAttorney = signaturesSettings.Where(o => Equals(o.Reason, Docflow.SignatureSetting.Reason.PowerOfAttorney)).FirstOrDefault(); var signaturesSettingWithOtherDocument = signaturesSettings.Where(o => Equals(o.Reason, Docflow.SignatureSetting.Reason.Other)).FirstOrDefault(); if (signaturesSettingWithDuties == null && _obj.FormalizedServiceType != FormalizedServiceType.Waybill) { if (signaturesSettingWithPowerOfAttorney != null) { signatoryPowerOfAttorney = Docflow.PowerOfAttorneys.As(signaturesSettingWithPowerOfAttorney.Document); } else if (signaturesSettingWithOtherDocument != null) { signatoryOtherReason = signaturesSettingWithOtherDocument.DocumentInfo; } } var errorlist = Functions.AccountingDocumentBase.TitleDialogValidationErrors(_obj, signatory, null, signatoryPowerOfAttorney, consigneePowerOfAttorney, signatoryOtherReason, null); var validationText = string.Join(Environment.NewLine, errorlist.Select(l => l.Text)); if (errorlist.Any()) { throw AppliedCodeException.Create(validationText); } // У УКД доступен только вариант "ответственный за оформление". var authority = Docflow.AccountingDocumentBases.Resources.PropertiesFillingDialog_HasAuthority_DealAndRegister; if (_obj.FormalizedServiceType == Docflow.AccountingDocumentBase.FormalizedServiceType.GeneralTransfer && _obj.IsAdjustment == true) { authority = Docflow.AccountingDocumentBases.Resources.PropertiesFillingDialog_HasAuthority_Register; } var basis = SignatureSettings.Info.Properties.Reason.GetLocalizedValue(Docflow.SignatureSetting.Reason.Duties); var buyerTitle = Docflow.Structures.AccountingDocumentBase.BuyerTitle.Create(); buyerTitle.ActOfDisagreement = string.Empty; buyerTitle.Signatory = signatory; buyerTitle.SignatoryPowersBase = basis; buyerTitle.Consignee = null; buyerTitle.ConsigneePowersBase = string.Empty; buyerTitle.SignResult = true; buyerTitle.SignatoryPowers = authority; buyerTitle.AcceptanceDate = Calendar.Now; buyerTitle.SignatoryPowerOfAttorney = signatoryPowerOfAttorney; buyerTitle.SignatoryOtherReason = signatoryOtherReason; buyerTitle.ConsigneePowerOfAttorney = consigneePowerOfAttorney; buyerTitle.ConsigneeOtherReason = null; this.GenerateAnswer(buyerTitle, isAgent); }
public override void SetDocumentSignatory(Company.IEmployee employee) { // Не перебивать подписанта при рассмотрении. US: 78188. if (CallContext.CalledFrom(ApprovalReviewAssignments.Info)) { return; } base.SetDocumentSignatory(employee); }
/// <summary> /// Получить вносящего результат рассмотрения. /// </summary> /// <param name="addressee">Адресат.</param> /// <param name="task">Задача на согласование.</param> /// <returns>Вносящий результат рассмотрения за адресата.</returns> public Company.IEmployee GetAddresseeAssistantForResultSubmission(Company.IEmployee addressee, IApprovalTask task) { if (_obj.IsResultSubmission != true) { return(null); } var stage = Functions.ApprovalTask.GetStages(task).Stages.Where(s => s.Stage.StageType == Docflow.ApprovalStage.StageType.Review).Select(s => s.Stage).FirstOrDefault(); IEmployee performer = null; if (stage != null) { performer = Functions.ApprovalStage.GetStagePerformer(task, stage); } return(Equals(performer, addressee) ? null : performer); }
/// <summary> /// Получить подтверждающего подписание. /// </summary> /// <param name="signatory">Подписывающий.</param> /// <param name="task">Задача на согласование.</param> /// <returns>Подтверждающий подписание.</returns> public Company.IEmployee GetConfirmByForSignatory(Company.IEmployee signatory, IApprovalTask task) { if (_obj.IsConfirmSigning != true) { return(null); } var stage = Functions.ApprovalTask.GetStages(task).Stages.Where(s => s.Stage.StageType == Docflow.ApprovalStage.StageType.Sign).Select(s => s.Stage).FirstOrDefault(); IEmployee performer = null; if (stage != null) { performer = Functions.ApprovalStage.GetStagePerformer(task, stage); } return(Equals(performer, signatory) ? null : performer); }
public static Company.IDepartment GetDepartment(Company.IEmployee employee) { if (employee == null) { return(null); } var department = Company.Departments.Null; var settings = Docflow.PublicFunctions.PersonalSetting.GetPersonalSettings(employee); if (settings != null) { department = settings.Department; } if (department == null) { department = employee.Department; } return(department); }
public virtual List <Company.Structures.ResponsibilitiesReport.ResponsibilitiesReportTableLine> GetResponsibilitiesReportData(Company.IEmployee employee) { var result = new List <Company.Structures.ResponsibilitiesReport.ResponsibilitiesReportTableLine>(); // HACK: Получаем отображаемое имя модуля. // Dmitriev_IA: Данные из модуля ExchangeCode должны попасть в таблицу модуля Компания. var companyModuleMetadata = Sungero.Metadata.Services.MetadataSearcher.FindModuleMetadata(Company.PublicConstants.Module.ModuleGuid); var moduleName = companyModuleMetadata.GetDisplayName(); var modulePriority = Company.PublicConstants.ResponsibilitiesReport.ExchangePriority; // Цифровые сертификаты. if (Certificates.AccessRights.CanRead()) { var certificateResponsibility = Company.Reports.Resources.ResponsibilitiesReport.CertificateResponsibility; var certificates = Certificates.GetAll() .Where(x => Equals(x.Owner, employee)) .Where(d => d.Enabled.HasValue && d.Enabled.Value) .Where(d => !d.NotAfter.HasValue || d.NotAfter.Value > Calendar.Now); result = Company.PublicFunctions.Module.AppendResponsibilitiesReportResult(result, certificates, moduleName, modulePriority, certificateResponsibility, null); } // Ответственный за абонентские ящики наших организаций. if (BoxBases.AccessRights.CanRead()) { var boxResponsibility = Company.Reports.Resources.ResponsibilitiesReport.BoxResponsibility; var boxes = BoxBases.GetAll() .Where(x => Equals(x.Responsible, employee)) .Where(d => d.Status == Sungero.CoreEntities.DatabookEntry.Status.Active); result = Company.PublicFunctions.Module.AppendResponsibilitiesReportResult(result, boxes, moduleName, modulePriority, boxResponsibility, null); } return(result); }
public virtual ICertificate GetUserExchangeCertificate(ExchangeCore.IBoxBase box, Company.IEmployee employee) { return(GetCurrentUserExchangeCertificate(box, employee)); }
/// <summary> /// Получить сертификат сервиса обмена для текущего сотрудника, используя системный диалог выбора сертификата. /// </summary> /// <param name="box">Абонентский ящик.</param> /// <param name="employee">Сотрудник.</param> /// <returns>Сертификат.</returns> public static ICertificate GetCurrentUserExchangeCertificate(ExchangeCore.IBoxBase box, Company.IEmployee employee) { var businessUnitBox = ExchangeCore.PublicFunctions.BoxBase.GetRootBox(box); var certificates = businessUnitBox.HasExchangeServiceCertificates == true ? businessUnitBox.ExchangeServiceCertificates.Where(x => Equals(x.Certificate.Owner, employee) && x.Certificate.Enabled == true).Select(x => x.Certificate) : Certificates.GetAllCached().Where(x => Equals(x.Owner, employee) && x.Enabled == true).AsEnumerable(); certificates = certificates.GroupBy(x => x.Thumbprint).Select(x => x.First()); if (certificates.Count() > 1) { return(certificates.ShowSelectCertificate()); } return(certificates.FirstOrDefault()); }
public virtual List <Structures.AccountingDocumentBase.GenerateTitleError> TitleDialogValidationErrors(Company.IEmployee signatory, Company.IEmployee consignee, IPowerOfAttorney signatoryPowerOfAttorney, IPowerOfAttorney consigneePowerOfAttorney, string signatoryOtherReason, string consigneeOtherReason) { var errorlist = new List <Structures.AccountingDocumentBase.GenerateTitleError>(); var signatoryType = Constants.AccountingDocumentBase.GenerateTitleTypes.Signatory; var consigneeType = Constants.AccountingDocumentBase.GenerateTitleTypes.Consignee; var signatoryPoAType = Constants.AccountingDocumentBase.GenerateTitleTypes.SignatoryPowerOfAttorney; var consigneePoAType = Constants.AccountingDocumentBase.GenerateTitleTypes.ConsigneePowerOfAttorney; if (string.IsNullOrEmpty(_obj.BusinessUnit.TIN)) { errorlist.Add(Structures.AccountingDocumentBase.GenerateTitleError.Create(null, AccountingDocumentBases.Resources.PropertiesFillingDialog_Error_TIN)); } if (signatory != null && signatory.JobTitle == null) { errorlist.Add(Structures.AccountingDocumentBase.GenerateTitleError.Create(signatoryType, AccountingDocumentBases.Resources.PropertiesFillingDialog_Error_SignatoryJobTitle)); } if (signatory != null && string.IsNullOrEmpty(signatory.Person.MiddleName)) { errorlist.Add(Structures.AccountingDocumentBase.GenerateTitleError.Create(signatoryType, Sungero.Docflow.AccountingDocumentBases.Resources.Error_SignatoryMiddleName)); } if (consignee != null && consignee.JobTitle == null) { errorlist.Add(Structures.AccountingDocumentBase.GenerateTitleError.Create(consigneeType, AccountingDocumentBases.Resources.PropertiesFillingDialog_Error_ConsigneeJobTitle)); } if (signatoryPowerOfAttorney != null && (signatoryPowerOfAttorney.RegistrationDate == null || string.IsNullOrWhiteSpace(signatoryPowerOfAttorney.RegistrationNumber))) { errorlist.Add(Structures.AccountingDocumentBase.GenerateTitleError.Create(signatoryPoAType, AccountingDocumentBases.Resources.PropertiesFillingDialog_Error_AttorneyRegistration)); } if (signatoryPowerOfAttorney != null && signatoryPowerOfAttorney.OurSignatory.JobTitle == null) { errorlist.Add(Structures.AccountingDocumentBase.GenerateTitleError.Create(signatoryPoAType, AccountingDocumentBases.Resources.PropertiesFillingDialog_Error_AttorneyJobTitle)); } if (consigneePowerOfAttorney != null && (consigneePowerOfAttorney.RegistrationDate == null || string.IsNullOrWhiteSpace(consigneePowerOfAttorney.RegistrationNumber))) { errorlist.Add(Structures.AccountingDocumentBase.GenerateTitleError.Create(consigneePoAType, AccountingDocumentBases.Resources.PropertiesFillingDialog_Error_AttorneyRegistration)); } if (consigneePowerOfAttorney != null && consigneePowerOfAttorney.OurSignatory.JobTitle == null) { errorlist.Add(Structures.AccountingDocumentBase.GenerateTitleError.Create(consigneePoAType, AccountingDocumentBases.Resources.PropertiesFillingDialog_Error_AttorneyJobTitle)); } if (_obj.FormalizedServiceType == FormalizedServiceType.Waybill && !string.IsNullOrWhiteSpace(consigneeOtherReason)) { errorlist.Add(Structures.AccountingDocumentBase.GenerateTitleError.Create(null, AccountingDocumentBases.Resources.PropertiesFillingDialog_Error_OtherDocument)); } if (_obj.FormalizedServiceType == FormalizedServiceType.Act && !string.IsNullOrWhiteSpace(signatoryOtherReason)) { errorlist.Add(Structures.AccountingDocumentBase.GenerateTitleError.Create(null, AccountingDocumentBases.Resources.PropertiesFillingDialog_Error_OtherDocument)); } return(errorlist); }
public static IQueryable <IOfficialDocument> GetFilteredRegisteredDocuments( string registrationNumber, DateTime?registrationDateFrom, DateTime?registrationDateTo, IDocumentRegister documentRegister, ICaseFile caseFile, Company.IEmployee registeredBy) { var documents = OfficialDocuments.GetAll(); if (registrationNumber != null) { documents = documents.Where(l => l.RegistrationNumber.Contains(registrationNumber)); } if (registrationDateFrom != null) { documents = documents.Where(l => l.RegistrationDate >= registrationDateFrom); } if (registrationDateTo != null) { registrationDateTo = registrationDateTo.Value.Date.EndOfDay(); documents = documents.Where(l => l.RegistrationDate <= registrationDateTo); } if (documentRegister != null) { documents = documents.Where(l => Equals(l.DocumentRegister, documentRegister)); } if (caseFile != null) { documents = documents.Where(l => Equals(l.CaseFile, caseFile)); } if (registeredBy != null) { // TODO Zamerov: ересь с операциями. var regitrationOperation = new Enumeration(Docflow.PublicFunctions.OfficialDocument.GetRegistrationOperation()); documents = documents.WhereDocumentHistory(h => Equals(h.User, registeredBy) && h.Operation == regitrationOperation); } return(documents); }