Пример #1
0
        public static IReportPlugin GetPlugin(string reportPluginName)
        {
            var section = ReportInitializerSection.GetReportInitializerSection();
            var errors  = new StringBuilder();
            var tPlugin = typeof(IWebReportPlugin);
            IWebReportPlugin reportPlugin = null;

            try
            {
                var types = section.ReprotPlugins.GetReportPlugins();
                foreach (var type in types.Where(tPlugin.IsAssignableFrom))
                {
                    try
                    {
                        if (type.FullName.Equals(reportPluginName))
                        {
                            reportPlugin = (IWebReportPlugin)Activator.CreateInstance(type);
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        errors.AppendLine("Can't create '" + type.FullName + "':");
                        errors.AppendLine(e.ToString());
                        errors.AppendLine();
                        errors.AppendLine();
                    }
                }
            }
            catch (Exception e)
            {
                errors.AppendLine(e.ToString());
                errors.AppendLine();
                errors.AppendLine();
            }

            if (errors.Length > 0)
            {
                var errorsStr  = errors.ToString();
                var sid        = HttpContext.Current.User == null ? "Nat.Initializer" : User.GetSID();
                var logMonitor = InitializerSection.GetSection().LogMonitor;
                logMonitor.Init();
                logMonitor.Log(
                    LogConstants.SystemErrorInApp,
                    () => new LogMessageEntry(sid, LogMessageType.SystemErrorInApp, errorsStr));
                TraceContextExt.WarnExt(HttpContext.Current.Trace, errorsStr);
            }

            return(reportPlugin);
        }
        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();
        }
 public ReportConditionControls(IWebReportPlugin plugin)
 {
     _plugin = plugin;
 }