public void Get_emtpy_rows() { var report = new BaseOrdersReport(); report.GroupHeaders.Add(new ColumnGroupHeader("test", "test1", "test2")); report.Header.Add("Тестовый отчет"); report.Header.Add("Тестовый отчет"); Assert.That(report.EmptyRowCount, Is.EqualTo(3)); }
public FilterField FindFilterField() { var report = new BaseOrdersReport(); return(FilterField.Sufixes.Select( s => report.RegistredField .FirstOrDefault(f => f.reportPropertyPreffix == PropertyName.Replace(s, ""))) .FirstOrDefault(f => f != null)); }
public void Ignore_mnn_without_product() { var report = new BaseOrdersReport(); var mnn = report.RegistredField.First(r => r.reportPropertyPreffix == "Mnn"); report.selectedField.Add(mnn); var producer = report.RegistredField.First(r => r.reportPropertyPreffix == "FirmCr"); report.selectedField.Add(producer); report.CheckAfterLoadFields(); report.SortFields(); Assert.That(report.selectedField.Implode(f => f.reportPropertyPreffix), Is.EqualTo("FirmCr")); }
private static string MakeColumns(string decl) { var report = new BaseOrdersReport(); var columns = decl.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < columns.Length; i++) { var product = report.RegistredField.First(r => r.reportPropertyPreffix == columns[i].Trim()); product.position = i; report.selectedField.Add(product); } report.CheckAfterLoadFields(); report.SortFields(); return(report.selectedField.Implode(f => f.reportPropertyPreffix)); }
public void Execute() { var rootType = typeof(BaseReport); //некоторые отчеты унаследованы от базового но на самом деле они не умеют использовать общие настройки var configurableReports = new[] { typeof(RatingReport), typeof(MixedReport), typeof(PharmacyMixedReport), typeof(OrdersStatistics), typeof(WaybillsStatReport), typeof(OffersExport), typeof(OrderDetails), typeof(SpecReport), typeof(SpecShortReport), }; var types = rootType.Assembly.GetTypes() .Where(t => t != rootType && !t.IsAbstract && rootType.IsAssignableFrom(t) && configurableReports.Contains(t)); foreach (var type in types) { var reportType = session.Query <ReportType>().FirstOrDefault(r => r.ReportClassName == type.FullName) ?? new ReportType(type); if (typeof(BaseOrdersReport).IsAssignableFrom(type)) { var reportInstance = new BaseOrdersReport(); if (type.GetConstructor(new Type[0]) != null) { reportInstance = (BaseOrdersReport)Activator.CreateInstance(type); } var notExists = reportInstance.RegistredField.SelectMany(f => new[] { f.reportPropertyPreffix + FilterField.PositionSuffix, f.reportPropertyPreffix + FilterField.NonEqualSuffix, f.reportPropertyPreffix + FilterField.EqualSuffix, }).Except(reportType.Properties.Select(p => p.PropertyName)); if (reportType.RestrictedFields.Any()) { notExists = notExists.Intersect(reportType.RestrictedFields); } notExists = notExists.Except(reportType.BlockedFields); foreach (var notExist in notExists) { if (notExist.EndsWith(FilterField.PositionSuffix)) { var field = reportInstance.RegistredField .First(f => f.reportPropertyPreffix == notExist.Replace(FilterField.PositionSuffix, "")); var property = new ReportTypeProperty(notExist, "INT", $"Позиция \"{field.outputCaption}\" в отчете") { Optional = true, DefaultValue = "0", }; log.WarnFormat("Добавил опциональный параметр '{0}' для отчета '{1}'", property.DisplayName, reportType.ReportTypeName); reportType.AddProperty(property); } else if (notExist.EndsWith(FilterField.NonEqualSuffix)) { var property = AddListProperty(procedureMap, reportInstance.RegistredField, reportType, notExist, FilterField.NonEqualSuffix, "Список исключений \"{0}\""); log.WarnFormat("Добавил опциональный параметр '{0}' для отчета '{1}'", property.DisplayName, reportType.ReportTypeName); } else { var property = AddListProperty(procedureMap, reportInstance.RegistredField, reportType, notExist, FilterField.EqualSuffix, "Список значений \"{0}\""); log.WarnFormat("Добавил опциональный параметр '{0}' для отчета {1}", property.DisplayName, reportType.ReportTypeName); } } } CheckProperties(type, reportType); session.Save(reportType); } CheckProperties(typeof(SupplierMarketShareByUser)); CheckProperties(typeof(OffersReport)); CheckProperties(typeof(OffersReportAsc)); }