Beispiel #1
0
        private void ContextOnPostAcquireRequestState(object sender, EventArgs eventArgs)
        {
            var context = (HttpApplication)sender;

            if (string.IsNullOrEmpty(context.Request.QueryString[ControlIDField]) ||
                string.IsNullOrEmpty(context.Request.QueryString[OpTypeField]) ||
                !OpTypeExport.Equals(context.Request.QueryString[OpTypeField], StringComparison.OrdinalIgnoreCase) ||
                !context.Request.Path.Equals("/Reserved.ReportViewerWebControl.axd", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            var controlID = context.Request.QueryString[ControlIDField];
            var dic       = (Dictionary <string, Type>)context.Session[SessionList];

            if (dic == null || !dic.ContainsKey(controlID))
            {
                return;
            }

            var plugin = dic[controlID];

            DBDataContext.AddViewReports(
                User.GetSID(),
                HttpContext.Current.User.Identity.Name,
                HttpContext.Current.User.Identity.Name,
                ReportInitializerSection.GetReportInitializerSection().ReportPageViewer + "?ClassName=" + plugin.FullName,
                HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority),
                Environment.MachineName,
                true,
                plugin);
        }
        public static string GetReportUrl(Type pluginType, string idrec, string backText, string backUrl, bool export, bool isKz)
        {
            if (export)
            {
                return(string.Format(@"{0}?expword=1&idrec={1}&ClassName={2}&text={3}&culture={5}&backPath={4}",
                                     ReportInitializerSection.GetReportInitializerSection().ReportPageViewer,
                                     idrec, pluginType.FullName, backText, backUrl, isKz ? "kz" : "ru"));
            }

            return(string.Format(@"{0}?idrec={1}&ClassName={2}&text={3}&culture={5}&backPath={4}",
                                 ReportInitializerSection.GetReportInitializerSection().ReportPageViewer,
                                 idrec, pluginType.FullName, backText, backUrl, isKz ? "kz" : "ru"));
        }
        private void RememberReports(string path, IReportPlugin plugin)
        {
            var typeStr = ReportInitializerSection.GetReportInitializerSection().RememberLastReportType;

            if (string.IsNullOrEmpty(typeStr))
            {
                return;
            }

            var type = BuildManager.GetType(typeStr, true, true);
            var obj  = (IRememberReports)Activator.CreateInstance(type);

            obj.CreateReport(path, plugin);
        }
        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));
                }
            }
        }
Beispiel #5
0
 public static string GetReportUrl(Type type, string idrec, string exportFormat, bool isKz)
 {
     return(string.Format(@"{0}?idrec={1}&ClassName={2}&culture={4}&rs:format={3}&rs:command=Render",
                          ReportInitializerSection.GetReportInitializerSection().ReportPageViewer,
                          idrec, type.FullName, exportFormat, isKz ? "kz" : "ru"));
 }