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 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 <IDocumentGroupBase> GetDocumentGroups() { return(DocumentGroupBases.GetAll().Where(d => d.Status == Status.Active).OrderBy(d => d.Name)); }
/// <summary> /// Получить список групп документов, доступных для выбора в правиле. /// </summary> /// <returns>Список групп документов.</returns> public virtual List <IDocumentGroupBase> GetAvailableDocumentGroups() { return(DocumentGroupBases.GetAllCached().ToList()); }
public override void BeforeExecute(Sungero.Reporting.Server.BeforeExecuteEventArgs e) { #region Параметры var reportSessionId = System.Guid.NewGuid().ToString(); ApprovalRulesConsolidatedReport.ReportSessionId = reportSessionId; var includeSubsidiary = ApprovalRulesConsolidatedReport.IncludeSubsidiary == true; var filterDepartment = ApprovalRulesConsolidatedReport.Department; var filterBusinessUnit = ApprovalRulesConsolidatedReport.BusinessUnit; var filterDepartmentsForBusinessUnits = ApprovalRulesConsolidatedReport.FilterDepartmentsForBusinessUnits == true; var filterDocumentFlow = ApprovalRulesConsolidatedReport.DocumentFlow; var filterDocumentKind = ApprovalRulesConsolidatedReport.DocumentKind; var filterCategory = ApprovalRulesConsolidatedReport.Category; #endregion #region Подготовка начальных данных var localizedValueCash = new Dictionary <Sungero.Core.Enumeration, string>(); localizedValueCash[ApprovalRuleBase.Status.Active] = ApprovalRuleBases.Info.Properties.Status.GetLocalizedValue(ApprovalRuleBase.Status.Active); localizedValueCash[ApprovalRuleBase.Status.Draft] = ApprovalRuleBases.Info.Properties.Status.GetLocalizedValue(ApprovalRuleBase.Status.Draft); var documentFlows = new List <Enumeration>() { ApprovalRuleBase.DocumentFlow.Incoming, ApprovalRuleBase.DocumentFlow.Outgoing, ApprovalRuleBase.DocumentFlow.Inner, ApprovalRuleBase.DocumentFlow.Contracts }; foreach (var flow in documentFlows) { localizedValueCash[flow] = ApprovalRuleBases.Info.Properties.DocumentFlow.GetLocalizedValue(flow); } var tableData = new List <Structures.ApprovalRulesConsolidatedReport.TableLine>(); // Сформировать список активных видов документов, которые можно утверждать. // Чтобы не было перезапросов к СП, весь список хранить в памяти. var approvalAction = Functions.Module.GetSendAction(OfficialDocuments.Info.Actions.SendForApproval); var rules = ApprovalRuleBases.GetAll().Where(r => r.Status == ApprovalRuleBase.Status.Active || r.Status == ApprovalRuleBase.Status.Draft).ToList(); #endregion #region Фильтрация // НОР. List <Company.IBusinessUnit> businessUnits; if (filterBusinessUnit != null) { businessUnits = new List <Company.IBusinessUnit>() { filterBusinessUnit }; if (includeSubsidiary) { businessUnits = this.GetSubBusinessUnits(businessUnits, Company.BusinessUnits.GetAll().Where(u => u.Status == Status.Active).ToList()); } } else { businessUnits = Company.BusinessUnits.GetAll().Where(u => u.Status == Status.Active).ToList(); // Для подразделений без НОР. if (filterDepartmentsForBusinessUnits) { businessUnits.Add(null); } } // Подразделения. List <Company.IDepartment> departments; if (filterDepartment != null) { departments = new List <Company.IDepartment>() { filterDepartment }; if (includeSubsidiary) { departments = this.GetSubDepartments(departments, Company.Departments.GetAll().Where(u => u.Status == Status.Active).ToList()); } } else { departments = Company.Departments.GetAll().Where(u => u.Status == Status.Active).ToList(); } // Виды документов. List <IDocumentKind> documentKinds; if (filterDocumentKind != null) { documentKinds = new List <IDocumentKind>() { filterDocumentKind }; } else { documentKinds = DocumentKinds.GetAll() .Where(k => k.Status == DocumentKind.Status.Active && k.AvailableActions.Any(a => a.Action == approvalAction)) .ToList(); } // Категории договоров. List <IDocumentGroupBase> categories; if (filterCategory != null) { categories = new List <IDocumentGroupBase>() { filterCategory }; } else { categories = DocumentGroupBases.GetAll().Where(d => d.Status == Status.Active).OrderBy(d => d.Name).ToList(); } // Документопоток. if (!string.IsNullOrEmpty(filterDocumentFlow)) { documentFlows = documentFlows.Where(x => localizedValueCash[x] == filterDocumentFlow).ToList(); } #endregion var tableLines = new List <Structures.ApprovalRulesConsolidatedReport.TableLine>(); foreach (var unit in businessUnits) { var subDepartments = departments.Where(d => (!filterDepartmentsForBusinessUnits && unit != null) || Equals(d.BusinessUnit, unit)).OrderBy(d => d.Name).ToList(); if (!subDepartments.Any() && unit != null && filterDepartment == null) { subDepartments.Add(null); } foreach (var department in subDepartments) { foreach (var flow in documentFlows) { foreach (var kind in documentKinds.Where(k => Equals(k.DocumentFlow, flow))) { var subRules = rules .Where(r => r.DocumentFlow == flow && (!r.DocumentKinds.Any() || r.DocumentKinds.Any(k => Equals(k.DocumentKind, kind))) && (!r.BusinessUnits.Any() || r.BusinessUnits.Any(u => Equals(u.BusinessUnit, unit))) && (!r.Departments.Any() || r.Departments.Any(d => Equals(d.Department, department)))); var documentParentType = this.GetDocumentBaseTypeDisplayName(kind); // Отдельно обрабатываем виды документов, для которых настроены категории. var documentKindCategories = categories.Where(c => c.DocumentKinds.Any(d => Equals(d.DocumentKind, kind))); if (documentKindCategories.Any()) { foreach (var category in documentKindCategories) { var categorySubRules = subRules.Where(sr => !sr.DocumentGroups.Any() || sr.DocumentGroups.Any(c => Equals(c.DocumentGroup, category))); tableLines = this.CreateTableDataLines(categorySubRules, reportSessionId, unit, department, category, flow, kind.Name, documentParentType, localizedValueCash); tableData.AddRange(tableLines); } continue; } // Если выбрана фильтрация по категории, то в отчет попадают только записи с заполненной категорией. if (filterCategory == null) { // Если не найдено правила для доп. соглашений, тогда указываем, что используется правило договора. var isSupAgreement = kind.DocumentType.DocumentTypeGuid == "265f2c57-6a8a-4a15-833b-ca00e8047fa5"; if (isSupAgreement) { tableLines = this.CreateTableDataLines(subRules, reportSessionId, unit, department, null, flow, kind.Name, documentParentType, localizedValueCash); foreach (var tableLine in tableLines) { if (string.IsNullOrEmpty(tableLine.ApprovalRule)) { tableLine.ApprovalRule = Reports.Resources.ApprovalRulesConsolidatedReport.ContractualDocumentRule; } } tableData.AddRange(tableLines); continue; } tableLines = this.CreateTableDataLines(subRules, reportSessionId, unit, department, null, flow, kind.Name, documentParentType, localizedValueCash); tableData.AddRange(tableLines); } } } } } Functions.Module.WriteStructuresToTable(Constants.ApprovalRulesConsolidatedReport.SourceTableName, tableData); }
public IQueryable <IDocumentGroupBase> GetPossibleCashedCategories() { return(this.FilterCategories(DocumentGroupBases.GetAllCached() .Where(c => c.Status == CoreEntities.DatabookEntry.Status.Active))); }