public StorageValues GetValues() { if (Plugin == null) { throw new Exception("Свойство Plugin не может быть равен null"); } var storageValues = new StorageValues(new Hashtable(), new List <Hashtable>()); foreach (var filter in Plugin.Conditions) { var storage = filter.ColumnFilter.GetStorage(); var text = filter.Visible ? filter.ColumnFilter.GetTexts() : null; storageValues.AddStorage(storage, text); } if (Plugin.CircleFillConditions != null) { for (int i = 0; i < Plugin.CircleFillConditions.Count; i++) { foreach (var filter in Plugin.CircleFillConditions[i]) { var storage = filter.ColumnFilter.GetStorage(); var text = filter.Visible ? filter.ColumnFilter.GetTexts() : null; storageValues.AddListStorage(storage, i, text); } } } return(storageValues); }
public void SetFiltersToStorageValues(StorageValues storageValues) { var filterValues = GetFilterValues(); foreach (var item in storageValues.GetStorageNames()) { if (!filterValues.ContainsKey(item)) { continue; } if (filterValues[item].Count == 0) { storageValues.SetStorageValues(item, ColumnFilterType.None, new object[2]); } else { var filterItem = filterValues[item][0]; storageValues.SetStorageValues(item, filterItem.ColumnFilterType.Value, filterItem.Value1, filterItem.Value2); } } for (int i = 0; i < storageValues.CountListValues; i++) { foreach (var item in storageValues.GetCircleStorageNames(i)) { if (!filterValues.ContainsKey(item) || filterValues[item].Count <= i) { continue; } var filterItem = filterValues[item][i]; storageValues.SetCircleStorageValues(item, i, filterItem.Value1, filterItem.Value2); } } }
public void InitValues(StorageValues storageValues, bool initInvisible) { if (Plugin == null) { throw new Exception("Свойство Plugin не может быть равен null"); } foreach (var filter in Plugin.Conditions) { if (!filter.Visible && !initInvisible) { continue; } var storage = filter.ColumnFilter.GetStorage(); storageValues.SetStorage(storage); filter.ColumnFilter.SetStorage(storage); } Plugin.SetCountCircleFillConditions(storageValues.CountListValues, true); for (int i = 0; i < storageValues.CountListValues; i++) { foreach (var filter in Plugin.CircleFillConditions[i]) { if (!filter.Visible && !initInvisible) { continue; } var storage = filter.ColumnFilter.GetStorage(); storageValues.SetListStorage(storage, i); filter.ColumnFilter.SetStorage(storage); } } }
private static void ReadStorageValues(RVS_Property row, RvsSavedProperties properties) { if (row.StorageValues != null && row.StorageValues.Length > 0) { properties.StorageValues = StorageValues.Deserialize(row.StorageValues.ToArray()); } }
public void OpenReport(WebReportManager webReportManager, StorageValues storageValues, string format, string culture, string backPath, string textOfBackPath, string command) { var guid = ReportManagerControl.SetSession(storageValues, webReportManager); HttpContext.Current.Response.Redirect( string.Format( "{7}?reportName={0}&rs:command={4}&rs:format={5}&values={1}&text={2}&culture={6}&backPath={3}", GetType().FullName, guid, textOfBackPath, backPath, command, format, culture, this.RedirectUrl)); }
public virtual void SetFiltersByStorageValues(StorageValues storageValues, MainPageUrlBuilder urlBuilder) { var filterValues = GetFilterValues(); foreach (var item in storageValues.GetStorageNames()) { var columnFilterType = storageValues.GetStorageFilterType(item); if (columnFilterType == null || columnFilterType == ColumnFilterType.None) { continue; } var values = storageValues.GetStorageValues(item); if (!filterValues.ContainsKey(item)) { filterValues[item] = new List <FilterItem>(); } else { filterValues[item].Clear(); } if (columnFilterType == ColumnFilterType.In || columnFilterType == ColumnFilterType.OutOf) { filterValues[item].AddRange(values.Select(r => new FilterItem(item, columnFilterType, new[] { r }))); } else { var filterItem = new FilterItem(item, columnFilterType, values); filterValues[item].Add(filterItem); } } for (int i = 0; i < storageValues.CountListValues; i++) { foreach (var item in storageValues.GetCircleStorageNames(i)) { var columnFilterType = storageValues.GetCircleStorageFilterType(item, i); if (columnFilterType == null || columnFilterType == ColumnFilterType.None) { continue; } var values = storageValues.GetCircleStorageValues(item, i); var filterItem = new FilterItem(item, columnFilterType, values); if (!filterValues.ContainsKey(item)) { filterValues[item] = new List <FilterItem>(); } else if (i == 0) { filterValues[item].Clear(); } filterValues[item].Add(filterItem); } } urlBuilder.SetFilter(TableName, filterValues); }
public SettingsController(IHostingEnvironment hostingEnvironment, IOptions <StorageValues> storageValues) { _hostingEnvironment = hostingEnvironment; _storageSettings = storageValues.Value; _blobStorageService = new BlobStorageService(_storageSettings.StorageAccountCs, _storageSettings.ContainerName); _tableStorageService = new TableStorageService(_storageSettings.StorageAccountCs, _storageSettings.TableName); }
internal static string SetSession(StorageValues values, WebReportManager webReportManager) { var guid = Guid.NewGuid().ToString(); HttpContext.Current.Session[guid] = values; HttpContext.Current.Session["logmsg" + guid] = webReportManager.GetLogInformation().Replace("\r\n", "<br/>"); HttpContext.Current.Session["logcode" + guid] = webReportManager.GetLogCode(webReportManager.Plugin); HttpContext.Current.Session["constants" + guid] = ((IWebReportPlugin)webReportManager.Plugin).Constants; return(guid); }
private static StorageValues GetSettings() { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile("appsettings.prod.json", optional: true); var configuration = builder.Build(); var settings = new StorageValues(); configuration.GetSection("Storage").Bind(settings); return(settings); }
public static void UpdateReportSubscriptionParams( DBDataContext db, long refReportSubscriptions, Page page, PlaceHolder ph, StorageValues values, string reportName) { var rowParams = db.ReportSubscriptions_Params.Where(q => q.refReportSubscriptions == refReportSubscriptions); db.ReportSubscriptions_Params.DeleteAllOnSubmit(rowParams); db.SubmitChanges(); var type = BuildManager.GetType(reportName, false, true); var isCultureRu = LocalizationHelper.IsCultureRU; LocalizationHelper.SetCulture("ru-ru"); var pluginRu = (IReportPlugin)Activator.CreateInstance(type); var conditionsRu = pluginRu.Conditions; pluginRu.SetCountCircleFillConditions(values.CountListValues, true); LocalizationHelper.SetCulture("kk-kz"); var pluginKz = (IReportPlugin)Activator.CreateInstance(type); var conditionsKz = pluginKz.Conditions; pluginKz.SetCountCircleFillConditions(values.CountListValues, true); // Create Conditions CreateReportSubscriptionParams(db, refReportSubscriptions, conditionsRu, conditionsKz, ph, values, null); // Create CircleConditions if (pluginRu.CircleFillConditions != null) { int i = -1; foreach (var circleConditionsRu in pluginRu.CircleFillConditions) { i++; var circleConditionsKz = pluginKz.CircleFillConditions; CreateReportSubscriptionParams(db, refReportSubscriptions, circleConditionsRu, circleConditionsKz[i], ph, values, i); } } // Save db.SubmitChanges(); LocalizationHelper.SetCulture(isCultureRu ? "ru-ru" : "kk-kz"); }
private void SaveFiltersState() { StorageValues storageValues = new StorageValues(); bool storageValuesNotSet = true; foreach (ColumnFilterStorage storage in ColumnFilterStorages) { storageValues.AddStorage(storage); if (storage.FilterType != ColumnFilterType.None) { storageValuesNotSet = false; } } if (storageValuesNotSet) { storageValues = null; } var sid = GetSidBytes(); StorageValues.SetStorageValues(string.Format("{0}_{1}", Page.AppRelativeVirtualPath, ClientID), sid, storageValues); }
public static void CreateReportSubscriptionParams( DBDataContext db, long refReportSubscriptions, List <BaseReportCondition> conditionsRu, List <BaseReportCondition> conditionsKz, PlaceHolder ph, StorageValues values, int?index) { var i = -1; foreach (var conditionRu in conditionsRu) { i++; if (!conditionRu.Visible) { continue; } var conditionKz = conditionsKz[i]; ph.Controls.Add((Control)conditionRu.ColumnFilter); var storageRu = conditionRu.ColumnFilter.GetStorage(); if (index == null) { values.SetStorage(storageRu); } else { values.SetListStorage(storageRu, index.Value); } conditionRu.ColumnFilter.SetStorage(storageRu); ph.Controls.Add((Control)conditionKz.ColumnFilter); var storageKz = conditionKz.ColumnFilter.GetStorage(); if (index == null) { values.SetStorage(storageKz); } else { values.SetListStorage(storageKz, index.Value); } conditionKz.ColumnFilter.SetStorage(storageKz); string[] textValues = conditionsKz[i].ColumnFilter.GetTexts(); var paramTextValuesKz = string.Empty; if (textValues != null) { paramTextValuesKz = string.Join(", ", textValues); } var paramCaptionKz = storageKz.Caption; var paramTextValuesRu = string.Empty; textValues = conditionRu.ColumnFilter.GetTexts(); if (textValues != null) { paramTextValuesRu = string.Join(", ", textValues); } var paramCaptionRu = storageRu.Caption; var record = new ReportSubscriptions_Param { refReportSubscriptions = refReportSubscriptions, ParamName = storageRu.Name, ParamCaptionKz = paramCaptionKz, ParamCaptionRu = paramCaptionRu, ParamTextValuesKz = paramTextValuesKz, ParamTextValuesRu = paramTextValuesRu, DynamicAttributeIndex = index, ParamDataType = storageRu.DataType.Name, ParamFilterType = storageRu.FilterType.ToString() }; db.ReportSubscriptions_Params.InsertOnSubmit(record); ph.Controls.Remove((Control)conditionRu.ColumnFilter); ph.Controls.Remove((Control)conditionKz.ColumnFilter); } }
protected override void OnAwake() { storageValues = GetComponentInParent <HeirarchyNode>().GetComponentInChildren <StorageValues>(); }
public static Stream GetReport(bool useReturnStream, string pluginName, string guid, StorageValues storageValues, string culture, Page page, string format, string command, LogMonitor logMonitor, bool expToWord, Dictionary <string, object> constants, StiWebViewer report, out string fileNameExtention, bool RoleCheck) { var originalUICulture = Thread.CurrentThread.CurrentUICulture; var originalCulture = Thread.CurrentThread.CurrentCulture; try { if (string.IsNullOrEmpty(culture)) { culture = "ru-ru"; } Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = new CultureInfo(culture == "ru" ? "ru-ru" : (culture == "kz" ? "kk-kz" : culture)); fileNameExtention = ""; WebInitializer.Initialize(); var webReportManager = new WebReportManager(new TreeView()); if (string.IsNullOrEmpty(pluginName)) { return(null); } webReportManager.RoleCheck = RoleCheck; webReportManager.Plugin = webReportManager.GetPlugins()[pluginName]; if (webReportManager.Plugin != null) { webReportManager.Plugin.InitializeReportCulture(culture); var values = storageValues; var webReportPlugin = (IWebReportPlugin)webReportManager.Plugin; var stiPlugin = (IStimulsoftReportPlugin)webReportPlugin; webReportPlugin.Page = page; webReportManager.CreateView(); if (!string.IsNullOrEmpty(webReportManager.Plugin.CultureParameter)) { values.SetStorageValues( webReportManager.Plugin.CultureParameter, webReportManager.Plugin.InitializedKzCulture); } webReportManager.InitValues(values, webReportPlugin.InitSavedValuesInvisibleConditions); webReportPlugin.Constants = constants; if (!string.IsNullOrEmpty(webReportManager.Plugin.CultureParameter) && stiPlugin.Report.Dictionary.Variables.Contains(webReportManager.Plugin.CultureParameter)) { if (webReportManager.Plugin.SupportRuKz) { stiPlugin.Report[webReportManager.Plugin.CultureParameter] = webReportManager.Plugin.InitializedKzCulture; } else { stiPlugin.Report[webReportManager.Plugin.CultureParameter] = webReportManager.Plugin.InitializedCulture; } } try { webReportManager.ShowReport(); } catch (ConstraintException e) { var allErrors = webReportManager.Plugin.Table.DataSet?.GetAllErrors(); if (!string.IsNullOrEmpty(allErrors)) { throw new Exception(allErrors, e); } var errors = webReportManager.Plugin.Table.GetErrors(); if (errors.Length > 0) { throw new Exception(errors.Select(r => r.RowError).Aggregate((v1, v2) => v1 + "; " + v2), e); } throw; } var section = ReportInitializerSection.GetReportInitializerSection(); if (section != null && !string.IsNullOrEmpty(section.PropSaveDataFile)) { if (webReportManager.Plugin.Table.DataSet != null) { webReportManager.Plugin.Table.DataSet.WriteXml(section.PropSaveDataFile); } else { webReportManager.Plugin.Table.WriteXml(section.PropSaveDataFile); } } if (HttpContext.Current != null && HttpContext.Current.Request.QueryString["GetDataSet"] == "on" && UserRoles.IsInRole(UserRoles.ADMIN)) { using (var stream = new MemoryStream()) { if (webReportManager.Plugin.Table.DataSet != null) { webReportManager.Plugin.Table.DataSet.WriteXml(stream); } else { webReportManager.Plugin.Table.WriteXml(stream); } stream.Position = 0; PageHelper.DownloadFile(stream, "data.xml", HttpContext.Current.Response); } } var autoExport = webReportPlugin as IReportAutoExport; DBDataContext.AddViewReports( Tools.Security.User.GetSID(), HttpContext.Current?.User.Identity.Name ?? "anonymous", HttpContext.Current?.User.Identity.Name ?? "anonymous", ReportInitializerSection.GetReportInitializerSection().ReportPageViewer + "?ClassName=" + pluginName, HttpContext.Current?.Request.Url.GetLeftPart(UriPartial.Authority) ?? "https://maxat", Environment.MachineName, useReturnStream || autoExport != null || expToWord || stiPlugin.AutoExportTo != null, webReportManager.Plugin.GetType()); Log(logMonitor, guid, webReportManager); if (useReturnStream) { StiExportFormat stiExportFormat; try { stiExportFormat = (StiExportFormat)Enum.Parse(typeof(StiExportFormat), format); } catch (Exception) { var stiCustomExportType = (CustomExportType)Enum.Parse(typeof(CustomExportType), format); return(ExportWithoutShow( webReportManager.Report, stiCustomExportType, true, out fileNameExtention)); } fileNameExtention = WebReportManager.GetFileExtension(stiExportFormat); return(ExportWithoutShow(webReportManager.Report, stiExportFormat, true)); } //webReportManager.Report.EndRender += (sender, args) => LogMessages(webReportManager.Report, logMonitor); if (autoExport != null) { autoExport.Export(); } if (!expToWord && stiPlugin.AutoExportTo == null) { report.Report = webReportManager.Report; page.Cache.Insert(report.Report.ReportName, report.Report, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 10, 0), CacheItemPriority.NotRemovable, null); report.ResetCurrentPage(); } else if (webReportPlugin.CustomExportType != CustomExportType.None) { return(ExportWithoutShow( webReportManager.Report, webReportPlugin.CustomExportType, false, out fileNameExtention)); } else if (stiPlugin.AutoExportTo != null) { return(ExportWithoutShow(webReportManager.Report, stiPlugin.AutoExportTo.Value, false)); } else { return(ExportWithoutShow(webReportManager.Report, StiExportFormat.Word2007, false)); } } } finally { Thread.CurrentThread.CurrentUICulture = originalUICulture; Thread.CurrentThread.CurrentCulture = originalCulture; } return(null); }
public Stream GetExcelByTypeName(string journalType, string format, long idProperties, StorageValues storageValues, string culture, ILogMonitor logMonitor, bool checkPermit, out string fileNameExtention) { var rvsProp = RvsSavedProperties.LoadFrom(idProperties, logMonitor); rvsProp.Format = format; rvsProp.Culture = culture; rvsProp.StorageValues = storageValues; journalType = journalType ?? rvsProp.JournalTypeName; var type = Type(journalType); return(GetExcelByType(type, rvsProp, logMonitor, checkPermit, out fileNameExtention)); }
private void SetCurrentPlugin(IReportPlugin plugin, bool isRedirect) { webReportManager.Plugin = plugin; plugin.InitializeReportCulture(plugin.SupportCulture[0]); IWebReportPlugin webPlugin = plugin as IWebReportPlugin; if (webPlugin != null) { webPlugin.Page = Page; } swReport.RefreshSessionWorker(); if (webReportManager.Plugin != null) { CurrentPlugin = webReportManager.Plugin.GetType().FullName; if (isRedirect) { ((IWebReportPlugin)webReportManager.Plugin).DefaultValue = Request.QueryString["idrec"]; } webReportManager.Plugin.OnReportOpening(); } else { CurrentPlugin = ""; } webReportManager.SessionWorker = swReport.SessionWorker; if (!isRedirect) { StorageValues values = null; IWebReportPlugin webReportPlugin = (IWebReportPlugin)webReportManager.Plugin; if (webReportPlugin != null && webReportPlugin.AllowSaveValuesConditions) { byte[] sid = new byte[] { }; switch (this.Context.User.Identity.AuthenticationType) { case "Windows": var windowsIdentity = (WindowsIdentity)this.Context.User.Identity; sid = new byte[windowsIdentity.User.BinaryLength]; windowsIdentity.User.GetBinaryForm(sid, 0); break; case "Forms": // note: Получение сида при идентификации по формам. sid = Encoding.Default.GetBytes(User.GetSID()); break; } if (sid != null && sid.Length > 0) { values = StorageValues.GetStorageValues(webReportManager.Plugin.GetType().FullName, sid); } if (values != null && values.CountListValues > 0) { _countModelFillConditions = values.CountListValues; } } if (values != null) { webReportManager.InitValues(values, webReportPlugin.InitSavedValuesInvisibleConditions); } } else if (IsSubscription) { IWebReportPlugin webReportPlugin = (IWebReportPlugin)webReportManager.Plugin; if (webReportPlugin != null) { tdTreeView.Visible = false; TreeView1.Visible = false; btnCreateReportKz.Visible = false; btnCreateReportRu.Visible = false; ImageCheckBox.Visible = false; btnSubscriptionsSaveParams.Visible = true; StorageValues values = null; values = (StorageValues)Session[Request.QueryString["idStorageValues"]]; if (values != null && values.CountListValues > 0) { _countModelFillConditions = values.CountListValues; } if (values != null) { webReportManager.InitValues(values, webReportPlugin.InitSavedValuesInvisibleConditions); } } } EnsureWebConditionControls(); }
protected internal abstract void InitFilterControl(StorageValues storageValues);
protected void CreateReport(string culture, bool isSubscriptions) { if (webReportManager.Plugin == null) { return; } errorDisplay.Text = ""; ValidateReportEventArgs args = new ValidateReportEventArgs(); if (!webReportManager.Validate(args)) { errorDisplay.ShowError(webReportManager.ErrorText); WriteErrors(errorDisplay, args); return; } //webReportManager.ShowReport(); //StiWebViewer1.Report = webReportManager.Report; //StiWebViewer1.ResetCurrentPage(); if (webReportManager.Plugin != null) { StorageValues values = webReportManager.GetValues(); var sid = new byte[] { }; switch (this.Context.User.Identity.AuthenticationType) { case "Windows": var windowsIdentity = (WindowsIdentity)this.Context.User.Identity; sid = new byte[windowsIdentity.User.BinaryLength]; windowsIdentity.User.GetBinaryForm(sid, 0); break; case "Forms": // note: Получение сида при идентификации по формам. sid = Encoding.Default.GetBytes(User.GetSID()); break; } if (((IWebReportPlugin)webReportManager.Plugin).AllowSaveValuesConditions) { StorageValues.SetStorageValues(webReportManager.Plugin.GetType().FullName, sid, values); } if (!isSubscriptions) { var redirectReportPlugin = webReportManager.Plugin as IRedirectReportPlugin; var backPath = Request.QueryString["backPath"]; var backText = Request.QueryString["text"]; if (string.IsNullOrEmpty(backPath) && webReportManager.Plugin.Visible) { backPath = WebReportManager.GetReportUrl( string.Empty, webReportManager.Plugin.GetType().FullName, string.Empty, string.Empty, false) + "&open=false&setDefaultParams=true"; } if (string.IsNullOrEmpty(backText)) { backText = Resources.SBack; } if (webReportManager.Plugin.Visible) { RememberReports( WebReportManager.GetReportUrl( string.Empty, webReportManager.Plugin.GetType().FullName, string.Empty, string.Empty, false) + "&open=false&setDefaultParams=true", webReportManager.Plugin); } if (redirectReportPlugin != null) { if (redirectReportPlugin.LogViewReport) { Tools.Security.DBDataContext.AddViewReports( Tools.Security.User.GetSID(), HttpContext.Current.User.Identity.Name, HttpContext.Current.User.Identity.Name, ReportInitializerSection.GetReportInitializerSection().ReportPageViewer + "?ClassName=" + redirectReportPlugin.GetType().FullName, HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority), Environment.MachineName, false, redirectReportPlugin.GetType()); } redirectReportPlugin.OpenReport( webReportManager, values, Request.QueryString["rs:format"], culture, HttpUtility.UrlEncode(backPath), backText, Request.QueryString["rs:command"]); } else { var guid = SetSession(values, webReportManager); Response.Redirect( string.Format( "{6}?reportName={0}&expword={4}&values={1}&text={2}&culture={5}&backPath={3}", webReportManager.Plugin.GetType().FullName, guid, backText, HttpUtility.UrlEncode(backPath), Request.QueryString["expword"], culture, ReportInitializerSection.GetReportInitializerSection().ReportingStiReportResultPage)); } // ScriptManager.RegisterStartupScript(btnCreateReport, // GetType(), // "open new window", // string.Format("window.open('ReportResultPage.aspx?reportName={0}&refPerson={1}', '');", // webReportManager.Plugin.GetType().FullName, // refPerson, // Guid.NewGuid().ToString().Replace("-", "")), // true); } else { var guid = SetSession(values, webReportManager); var url = new MainPageUrlBuilder { UserControl = "ReportSubscriptionsEdit", IsDataControl = true, IsNew = true }; url.CustomQueryParameters.Add("guid", guid); /*Определение типа отчета*/ var isSqlReportingServices = Convert.ToByte(webReportManager.Plugin is ISqlReportingServicesPlugin); url.CustomQueryParameters.Add("isSqlReportingServices", isSqlReportingServices.ToString()); url.CustomQueryParameters.Add("reportName", webReportManager.Plugin.GetType().FullName); url.CustomQueryParameters.Add("qscommand", Request.QueryString["rs:command"]); url.CustomQueryParameters.Add("culture", culture); /*Определениe формата выгрузки отчета в зависимости от типа отчета*/ string format = ""; if (isSqlReportingServices == 0) { var webReportPlugin = (IWebReportPlugin)webReportManager.Plugin; var stiPlugin = (IStimulsoftReportPlugin)webReportPlugin; var expToWord = !string.IsNullOrEmpty(Request.QueryString["expword"]); if (!expToWord && stiPlugin.AutoExportTo == null) { format = Request.QueryString["expword"]; } else if (stiPlugin.AutoExportTo != null) { format = stiPlugin.AutoExportTo.Value.ToString(); } } else { format = Request.QueryString["rs:format"]; } /**/ url.CustomQueryParameters.Add("format", format); Page.Response.Redirect(url.CreateUrl(false, true)); } } }
private void LoadFiltersState() { var sid = GetSidBytes(); // Loading user dependend filters state settings // In case there is no user setting apply default settings StorageValues storageValues = StorageValues.GetStorageValues(string.Format("{0}_{1}", Page.AppRelativeVirtualPath, ClientID), sid); if (storageValues != null) { foreach (ColumnFilterStorage storage in ColumnFilterStorages) { storageValues.SetStorage(storage); } } else { WebInitializer.Initialize(); foreach (ColumnFilterStorage storage in ColumnFilterStorages) { ColumnFilterType columnFilterType = (ColumnFilterType)(DataSetResourceManager.GetColumnExtProperty( dataTable.Columns[storage.Name], ColumnExtProperties.FILTER_DEFAULT_CONDITION) ?? ColumnFilterType.None); if (columnFilterType != ColumnFilterType.None) { if (!dataTable.Columns.Contains(storage.Name)) { continue; } object[] values = new object[2]; values[0] = DataSetResourceManager.GetColumnExtProperty(dataTable.Columns[storage.Name], ColumnExtProperties.FILTER_DEFAULT_VALUE_1) ?? null; values[1] = DataSetResourceManager.GetColumnExtProperty(dataTable.Columns[storage.Name], ColumnExtProperties.FILTER_DEFAULT_VALUE_2) ?? null; string codeField = (String)DataSetResourceManager.GetColumnExtProperty(dataTable.Columns[storage.Name], ColumnExtProperties.FILTER_DEFAULT_VALUE_CODE_FIELD); if (storage.IsRefBound && !string.IsNullOrEmpty(codeField)) { for (int i = 0; i < values.Length; i++) { if (values[i] != null) { DataTable table = (DataTable)storage.RefDataSource; QueryConditionList queryConditionList = new QueryConditionList(); QueryCondition queryCondition = new QueryCondition(codeField, ColumnFilterType.Equal, values[i], null); queryConditionList.Add(queryCondition); Type tableAdapterType = TableAdapterTools.GetTableAdapterType(table.GetType()); QueryGenerator queryGenerator; if (table.Columns.IndexOf("dateEnd") != -1 && table.Columns.IndexOf("dateStart") != -1) { Component adapter = HistoricalData.GetTableAdapterToHistoricalData("dateEnd", "dateStart", DateTime.Now, tableAdapterType, 0); queryGenerator = new QueryGenerator(adapter); } else { queryGenerator = new QueryGenerator(table); } queryGenerator.TopCount = 1; queryGenerator.Fill(table, queryConditionList); if (table.Rows.Count != 0) { values[i] = table.Rows[0][storage.ValueColumn]; } } } } storage.FilterType = columnFilterType; try { for (int i = 0; i != 2; i++) { if (values[i] != null) { storage.SetValue(i, Convert.ChangeType(values[i], storage.DataType)); } } } catch (InvalidCastException) { } } } } }
public static Stream GetReport(bool useReturnStream, string pluginName, string guid, StorageValues storageValues, string culture, Page page, string format, string command, LogMonitor logMonitor, ServerReport report, out string fileNameExtention, bool RoleCheck) { fileNameExtention = ""; WebInitializer.Initialize(); report = ReportViewerInitializer(report); var webReportManager = new WebReportManager(new TreeView()); if (string.IsNullOrEmpty(pluginName)) { return(null); } webReportManager.RoleCheck = RoleCheck; webReportManager.Plugin = webReportManager.GetPlugins()[pluginName]; webReportManager.Plugin.InitializeReportCulture(culture); var webReportPlugin = (IWebReportPlugin)webReportManager.Plugin; webReportPlugin.Page = page; webReportManager.CreateView(); webReportManager.InitValues(storageValues, true); var list = new List <ReportParameter>(); foreach (var reportCondition in webReportManager.Plugin.Conditions) { var conditions = reportCondition.GetQueryConditions().ToList(); if (conditions.Count == 0) { list.Add(new ReportParameter(reportCondition.ColumnFilter.GetStorage().Name, (string)null, false)); } else { foreach (var condition in conditions) { if (condition.Parameters.Length == 0) { throw new Exception("Условие без значения не поддерживаются при формировании отчета"); } var values = condition.GetParamValues().Select(r => r.ToString()).ToArray(); list.Add(new ReportParameter(condition.ColumnName, values, false)); } } } if (!string.IsNullOrEmpty(webReportManager.Plugin.CultureParameter)) { if (webReportManager.Plugin.SupportRuKz) { list.Add(new ReportParameter(webReportManager.Plugin.CultureParameter, webReportManager.Plugin.InitializedKzCulture.ToString(), false)); } else { list.Add(new ReportParameter(webReportManager.Plugin.CultureParameter, webReportManager.Plugin.InitializedCulture, false)); } } //+= потому что инициализируется папка в которой лежат отчеты report.ReportPath += ((ISqlReportingServicesPlugin)webReportManager.Plugin).ReportUrl; report.SetParameters(list); Log(logMonitor, guid, webReportManager); var export = !string.IsNullOrEmpty(format) && "render".Equals(command, StringComparison.OrdinalIgnoreCase); DBDataContext.AddViewReports( Tools.Security.User.GetSID(), HttpContext.Current?.User.Identity.Name ?? "anonymous", HttpContext.Current?.User.Identity.Name ?? "anonymous", ReportInitializerSection.GetReportInitializerSection().ReportPageViewer + "?ClassName=" + webReportManager.Plugin.GetType().FullName, HttpContext.Current?.Request.Url.GetLeftPart(UriPartial.Authority) ?? "https://maxat", Environment.MachineName, export, webReportManager.Plugin.GetType()); if (export) { string mimeType; if (useReturnStream) { return(report.Render(format, "", null, out mimeType, out fileNameExtention)); } PageHelper.DownloadFile( report.Render(format, "", null, out mimeType, out fileNameExtention), webReportManager.Plugin.Description + "." + fileNameExtention, HttpContext.Current.Response); } return(null); }