Exemplo n.º 1
0
        public bool Save()
        {
            bool SaveOK = false;

            if (_IsNew)
            {
                IReportPlugin plugin = CreateInstance();
                if (plugin != null)
                {
                    ReportPluginInfo plugininfo = plugin.GetPluginInfo();
                    GUID               = plugininfo.GUID;
                    Description        = plugininfo.Description;
                    ReportName         = plugininfo.ReportName;
                    TopLevelMenuKey    = plugininfo.TopLevelMenuKey;
                    SecondLevelMenuKey = plugininfo.SecondLevelMenuKey;
                    plugin.Dispose();
                }
            }

            if (!Directory.Exists(_Folder))
            {
                Directory.CreateDirectory(_Folder);
            }

            if (GUID.Length > 0)
            {
                Serializer <ReportPluginInfo> .Save(this, _Folder + GUID + ".xml");

                OnChanged(this);
                _IsNew = false;
                SaveOK = true;
            }

            return(SaveOK);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates an instance of the plugin corresponding to the GUID
        /// </summary>
        public IReportPlugin CreateInstance()
        {
            if (!File.Exists(FileName))
            {
                return(null);
            }

            Assembly ass = Assembly.LoadFile(FileName);

            TypeFilter myFilter = new TypeFilter(MyInterfaceFilter);

            foreach (Type type in ass.GetTypes())
            {
                if (type.GetInterfaces().Contains(typeof(IReportPlugin)))
                {
                    IReportPlugin _plugin = Activator.CreateInstance(type) as IReportPlugin;
                    if (_plugin.GetPluginInfo().GUID == GUID)
                    {
                        return(_plugin);
                    }
                    _plugin.Dispose();
                }
            }

            return(null);
        }
Exemplo n.º 3
0
        protected override bool CanAccess(IReportPlugin plugin)
        {
            var webReportPlugin = (IWebReportPlugin)plugin;

            string[] roles = webReportPlugin.Roles();
            if (UserRoles.IsInAnyRoles(roles))
            {
                return(true);
            }
            return(roles.Length == 0);
        }
        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 TreeView1_SelectedNodeChanged(object sender, EventArgs e)
        {
            ImageCheckBox.Checked = false;
            IReportPlugin plugin = webReportManager.HierarchyReports.Controls[TreeView1.SelectedNode].ReportPlugin;

            if (webReportManager.Plugin == plugin)
            {
                return;
            }
            webReportManager.CloseReports();
            swReport.SessionWorker.RemoveObject();
            WebConditionControlsCreated = false;
//            bool isRedirect = sender == this;

            SetCurrentPlugin(plugin, false);
        }
        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();
        }
Exemplo n.º 7
0
 public LogMessageType GetLogCode(IReportPlugin plugin)
 {
     return(_typeReportLists[plugin.GetType()].LogMessageType);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Discover Plugins implemented in an assembly and creates corresponding XML file definitions for faster loading in the future.
        /// </summary>
        public static List <ReportPluginInfo> DiscoverPlugins(string fileName, ILogger logger)
        {
            if (!File.Exists(fileName))
            {
                return(null);
            }

            try
            {
                List <ReportPluginInfo> plugins = new List <ReportPluginInfo>();

                if (!Directory.Exists(_Folder))
                {
                    Directory.CreateDirectory(_Folder);
                }

                Assembly _assembly = Assembly.LoadFile(fileName);
                foreach (Type t in _assembly.GetTypes())
                {
                    if (t.GetInterfaces().Contains(typeof(IReportPlugin)))
                    {
                        IReportPlugin    plugin      = Activator.CreateInstance(t) as IReportPlugin;
                        ReportPluginInfo _plugininfo = plugin.GetPluginInfo();

                        _plugininfo.FileName = fileName;

                        if ((_plugininfo.GUID.Length > 0) && (_plugininfo.ReportName.Length > 0))
                        {
                            plugins.Add(_plugininfo);

                            string XMLFileName = _Folder + _plugininfo.GUID + ".xml";
                            if (File.Exists(XMLFileName))
                            {
                                File.Delete(XMLFileName);
                            }

                            Serializer <ReportPluginInfo> .Save(_plugininfo, XMLFileName);

                            _plugininfo._IsNew = false;
                        }
                    }
                }

                if (plugins.Count > 0)
                {
                    return(plugins);
                }
                else
                {
                    return(null);
                }
            }
            catch (InvalidOperationException)
            {
                return(null);
            }
            catch (Exception ex)
            {
                logger.LogException(ex);
                return(null);
            }
        }