public static IQueryable <IDocumentGroupBase> GetAvailableDocumentGroup(IDocumentKind documentKind)
 {
     return(DocumentGroupBases.GetAllCached()
            .Where(d => d.Status == CoreEntities.DatabookEntry.Status.Active)
            .Where(d => !d.DocumentKinds.Any() || d.DocumentKinds.Any(k => Equals(k.DocumentKind, documentKind)))
            .AsQueryable());
 }
 public static DateTime?GetConsiderationDate(IDocumentKind documentKind, IUser user)
 {
     if (documentKind == null || (!documentKind.DeadlineInDays.HasValue && !documentKind.DeadlineInHours.HasValue))
     {
         return(null);
     }
     return(Calendar.Now.AddWorkingDays(user, documentKind.DeadlineInDays ?? 0).AddWorkingHours(user, documentKind.DeadlineInHours ?? 0));
 }
Ejemplo n.º 3
0
        public virtual bool CheckConditionAbility(IDocumentKind documentKind, System.Collections.Generic.Dictionary <string, List <Enumeration?> > supportedConditions)
        {
            if (supportedConditions.ContainsKey(documentKind.DocumentType.DocumentTypeGuid))
            {
                return(supportedConditions[documentKind.DocumentType.DocumentTypeGuid].Contains(_obj.ConditionType));
            }

            return(false);
        }
Ejemplo n.º 4
0
        public static IRegistrationSetting GetSettingByParams(Enumeration?settingType,
                                                              IBusinessUnit businessUnit,
                                                              IDocumentKind documentKind,
                                                              IDepartment department)
        {
            var settings = GetAvailableSettingsByParams(settingType, businessUnit, documentKind, department);

            return(settings.OrderByDescending(r => r.Priority).FirstOrDefault());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Отфильтровать шаблоны по критериям.
        /// </summary>
        /// <param name="documentTemplates">Коллекция шаблонов.</param>
        /// <param name="document">Документ, который создается из шаблона.</param>
        /// <param name="documentKind">Вид документа.</param>
        /// <param name="businessUnit">Наша организация.</param>
        /// <param name="department">Подразделение.</param>
        /// <param name="isCalledFromDocument">True - вызывается из документа, false - вызывается из списка.</param>
        /// <returns>Коллекция отфильтрованных шаблонов.</returns>
        public static IQueryable <T> FilterTemplatesByCriteria(IQueryable <T> documentTemplates,
                                                               IOfficialDocument document,
                                                               IDocumentKind documentKind,
                                                               Company.IBusinessUnit businessUnit,
                                                               Company.IDepartment department,
                                                               bool isCalledFromDocument)
        {
            // Вид документа.
            var allDocumentTypeGuid = Guid.Parse(Docflow.PublicConstants.DocumentTemplate.AllDocumentTypeGuid);

            if (documentKind != null)
            {
                var typeGuid = Guid.Parse(documentKind.DocumentType.DocumentTypeGuid);
                documentTemplates = documentTemplates.Where(d => !d.DocumentKinds.Any() &&
                                                            (d.DocumentType == allDocumentTypeGuid ||
                                                             d.DocumentType == typeGuid) ||
                                                            d.DocumentKinds.Any(k => Equals(k.DocumentKind, documentKind)));
            }
            else if (isCalledFromDocument)
            {
                var typeGuid       = document.TypeDiscriminator;
                var availableKinds = PublicFunctions.DocumentKind.GetAvailableDocumentKinds(document);
                documentTemplates = documentTemplates.Where(d => !d.DocumentKinds.Any() &&
                                                            (d.DocumentType == allDocumentTypeGuid ||
                                                             d.DocumentType == typeGuid) ||
                                                            availableKinds.Any(x => string.Equals(x.DocumentType.DocumentTypeGuid,
                                                                                                  typeGuid.ToString(),
                                                                                                  StringComparison.InvariantCultureIgnoreCase)));
            }

            // НОР.
            if (businessUnit != null)
            {
                documentTemplates = documentTemplates.Where(d => !d.BusinessUnits.Any() || d.BusinessUnits.Any(t => Equals(t.BusinessUnit, businessUnit)));
            }
            else if (isCalledFromDocument)
            {
                documentTemplates = documentTemplates.Where(d => !d.BusinessUnits.Any());
            }

            // Подразделение.
            if (department != null)
            {
                documentTemplates = documentTemplates.Where(d => !d.Departments.Any() || d.Departments.Any(t => Equals(t.Department, department)));
            }
            else if (isCalledFromDocument)
            {
                documentTemplates = documentTemplates.Where(d => !d.Departments.Any());
            }

            return(documentTemplates);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Получить отображаемое имя базового типа сущности по виду документа.
        /// </summary>
        /// <param name="documentKind">Вид документа.</param>
        /// <returns>Отображаемое имя.</returns>
        /// <remarks>В качестве базового типа берется тип, который является прямым наследником от официального документа.</remarks>
        public string GetDocumentBaseTypeDisplayName(IDocumentKind documentKind)
        {
            var documentTypeGuid = Guid.Parse(documentKind.DocumentType.DocumentTypeGuid);
            var documentType     = Sungero.Domain.Shared.TypeExtension.GetTypeByGuid(documentTypeGuid);
            var documentMetadata = Sungero.Domain.Shared.TypeExtension.GetEntityMetadata(documentType);

            while (documentMetadata.BaseEntityMetadata.NameGuid != Docflow.Server.OfficialDocument.ClassTypeGuid)
            {
                documentMetadata = documentMetadata.BaseEntityMetadata;
            }

            return(documentMetadata.GetDisplayName());
        }
        private IDocumentGroupBase[] GetFilteredCategories(IDocumentKind documentKind, Enumeration?documentFlow)
        {
            var categories = Docflow.PublicFunctions.DocumentGroupBase.Remote.GetDocumentGroups();

            if (documentFlow != null)
            {
                categories = categories.Where(c => c.DocumentKinds.All(k => k.DocumentKind.DocumentFlow == documentFlow));
            }

            if (documentKind != null)
            {
                categories = categories.Where(c => c.DocumentKinds.Any(k => Equals(k.DocumentKind, documentKind)) || !c.DocumentKinds.Any());
            }

            return(categories.ToArray());
        }
Ejemplo n.º 8
0
        public static List <IDocumentRegister> GetDocumentRegistersByParams(IDocumentKind kind, IBusinessUnit unit, IDepartment department,
                                                                            Enumeration?settingType, bool forCurrentUser)
        {
            // Результат сразу замыкается в ToList, так как иначе не транслируется в SQL, если вызывать на сервере.
            // Все журналы, указанные в настройках регистрации.
            var documentRegistersWithRegistrationSettings = RegistrationSettings
                                                            .GetAllCached(s => s.Status == CoreEntities.DatabookEntry.Status.Active &&
                                                                          s.SettingType == Docflow.RegistrationSetting.SettingType.Registration)
                                                            .Select(s => s.DocumentRegister)
                                                            .ToList();

            // Все журналы, кроме указанных в настройках регистрации.
            var documentRegistersWithoutRegistrationSettings = DocumentRegisters.GetAll()
                                                               .Where(l => !documentRegistersWithRegistrationSettings.Contains(l));

            // Журналы, подходящие по непротиворечивым настройкам.
            var documentRegistersBySettings = Functions.RegistrationSetting
                                              .GetAvailableSettingsByParams(settingType, unit, kind, department)
                                              .Select(s => s.DocumentRegister)
                                              .ToList();

            // Журналы настроек регистрации, подходящих для текущего документа.
            var documentRegistersByRegistrationSettings = Functions.RegistrationSetting
                                                          .GetAvailableSettingsByParams(Docflow.RegistrationSetting.SettingType.Registration, unit, kind, department)
                                                          .Select(s => s.DocumentRegister)
                                                          .ToList();

            // Получить все журналы по настройкам.
            documentRegistersByRegistrationSettings.AddRange(documentRegistersBySettings);

            // Фильтруем журналы по документопотоку. Только журналы регистрации.
            var result = Functions.DocumentRegister.GetFilteredDocumentRegisters(kind.DocumentFlow.Value, true, forCurrentUser)
                         .Where(a => documentRegistersByRegistrationSettings.Contains(a) || documentRegistersWithoutRegistrationSettings.Contains(a)).ToList();

            // Для резервирования добавить настройки резервирования в обход проверки доступности журнала группе регистрации.
            // Делопроизводитель должен иметь возможность резервировать номер в документе, который не сможет зарегистрировать.
            if (settingType == Docflow.RegistrationSetting.SettingType.Reservation)
            {
                result.AddRange(documentRegistersBySettings);
            }

            return(result.Distinct().ToList());
        }
Ejemplo n.º 9
0
        private static string GetSettingType(IDocumentKind kind, IRegistrationSetting setting)
        {
            if (kind.AutoNumbering == true)
            {
                return(Reports.Resources.RegistrationSettingReport.AutoNumeration);
            }

            if (setting != null)
            {
                return(RegistrationSettings.Info.Properties.SettingType.GetLocalizedValue(setting.SettingType));
            }

            if (kind.NumberingType == DocumentKind.NumberingType.Registrable)
            {
                return(RegistrationSettings.Info.Properties.SettingType.GetLocalizedValue(SettingType.Registration));
            }

            if (kind.NumberingType == DocumentKind.NumberingType.Numerable)
            {
                return(RegistrationSettings.Info.Properties.SettingType.GetLocalizedValue(SettingType.Numeration));
            }

            return(string.Empty);
        }
Ejemplo n.º 10
0
        public static IQueryable <IRegistrationSetting> GetAvailableSettingsByParams(Enumeration?settingType,
                                                                                     IBusinessUnit businessUnit,
                                                                                     IDocumentKind documentKind,
                                                                                     IDepartment department)
        {
            var activeStatus = CoreEntities.DatabookEntry.Status.Active;
            var settings     = RegistrationSettings.GetAllCached(r => r.Status == activeStatus &&
                                                                 r.SettingType == settingType &&
                                                                 r.DocumentRegister.Status == activeStatus);

            settings = businessUnit != null?
                       settings.Where(r => r.BusinessUnits.Any(o => o.BusinessUnit.Equals(businessUnit)) || !r.BusinessUnits.Any()) :
                           settings.Where(r => !r.BusinessUnits.Any());

            settings = documentKind != null?
                       settings.Where(r => r.DocumentKinds.Any(o => o.DocumentKind.Equals(documentKind)) || !r.DocumentKinds.Any()) :
                           settings.Where(r => !r.DocumentKinds.Any());

            settings = department != null?
                       settings.Where(r => r.Departments.Any(o => o.Department.Equals(department)) || !r.Departments.Any()) :
                           settings.Where(r => !r.Departments.Any());

            return(settings);
        }
Ejemplo n.º 11
0
 public static IQueryable <IRegistrationSetting> GetRegistrationSettingsByDocumentKind(IDocumentKind documentKind)
 {
     return(RegistrationSettings.GetAll(s => s.Status == Docflow.RegistrationSetting.Status.Active)
            .Where(s => s.DocumentKinds.Any(k => k.DocumentKind.Id == documentKind.Id)));
 }
 public static IQueryable <IDocumentGroupBase> GetDocumentGroupsByDocumentKind(IDocumentKind documentKind)
 {
     return(DocumentGroupBases.GetAll()
            .Where(d => d.Status == Docflow.DocumentGroupBase.Status.Active)
            .Where(d => d.DocumentKinds.Any(k => Equals(k.DocumentKind, documentKind))));
 }
        public static IQueryable <IAccessRightsRule> GetAccessRightsRulesByDocumentKind(IDocumentKind documentKind)
        {
            var rules = AccessRightsRules.GetAll();

            return(AccessRightsRules.GetAll(r => r.Status == Docflow.AccessRightsRule.Status.Active)
                   .Where(r => r.DocumentKinds.Any(k => k.DocumentKind.Id == documentKind.Id)));
        }
Ejemplo n.º 14
0
 public static IRegistrationSetting GetSettingForKind(IOfficialDocument document,
                                                      Enumeration?settingType,
                                                      IDocumentKind documentKind)
 {
     return(GetSettingByParams(settingType, document.BusinessUnit, documentKind, document.Department));
 }
 public static IQueryable <ISignatureSetting> GetSignatureSettingsByDocumentKind(IDocumentKind documentKind)
 {
     return(SignatureSettings.GetAll(s => s.Status == Docflow.SignatureSetting.Status.Active)
            .Where(s => s.DocumentKinds.Any(k => k.DocumentKind.Id == documentKind.Id)));
 }
Ejemplo n.º 16
0
 public override IQueryable <ISignatureSetting> GetSignatureSetting(IBusinessUnit businessUnit, IDocumentKind kind,
                                                                    double?minAmount, List <Company.IDepartment> departments)
 {
     return(this.GetSignatureSettingWithoutDocumentFlowFilter(businessUnit, kind, minAmount, departments)
            .Where(s => s.DocumentFlow == Docflow.SignatureSetting.DocumentFlow.Contracts || s.DocumentFlow == Docflow.SignatureSetting.DocumentFlow.All));
 }