Ejemplo n.º 1
0
        public void reloadModule(string FileName)
        {
            Assembly ModuleAssembly = Assembly.LoadFrom(FileName);
            int      j = 0;

            foreach (Type ModuleType in ModuleAssembly.GetTypes())
            {
                if (ModuleType.IsPublic)
                {
                    if (!ModuleType.IsAbstract)
                    {
                        Type typeInterface = ModuleType.GetInterface("RhoInterface.RhoModule", true);
                        if (typeInterface != null)
                        {
                            Types.AvailableModule newModule = new Types.AvailableModule();
                            newModule.AssemblyPath  = FileName;
                            newModule.Instance      = (RhoModule)Activator.CreateInstance(ModuleAssembly.GetType(ModuleType.ToString()));
                            newModule.Instance.Host = this;
                            newModule.Instance.Initialize();
                            newModule.Instance.user_id      = Global.usr_id;
                            newModule.Instance.role_set_id  = Global.role_set_id;
                            newModule.Instance.org_id       = Global.org_id;
                            newModule.Instance.login_number = Global.login_number;
                            newModule.Instance.loadMyRolesNMsgtyps();

                            this.colAvailableModules.Add(newModule);
                            j        += 1;
                            newModule = null;
                        }
                        typeInterface = null;
                    }
                }
            }
            ModuleAssembly = null;
        }
Ejemplo n.º 2
0
        //public void CreateModulePrvldgs()
        //{
        //  foreach (Types.AvailableModule ModuleOn in colAvailableModules)
        //  {
        //    if (ModuleOn.Instance != null)
        //    {
        //      ModuleOn.Instance.loadMyRolesNMsgtyps();
        //    }
        //  }
        //}

        //private void AddAllModules(string FileName)
        //{
        //  Assembly ModuleAssembly = Assembly.LoadFrom(FileName);
        //  int j = 0;
        //  foreach (Type ModuleType in ModuleAssembly.GetTypes())
        //  {
        //    if (ModuleType.IsPublic)
        //    {
        //      if (!ModuleType.IsAbstract)
        //      {
        //        Type typeInterface = ModuleType.GetInterface("RhoInterface.RhoModule", true);
        //        if (typeInterface != null)
        //        {
        //          Types.AvailableModule newModule = new Types.AvailableModule();
        //          newModule.AssemblyPath = FileName;
        //          newModule.Instance = (RhoModule)Activator.CreateInstance(ModuleAssembly.GetType(ModuleType.ToString()));
        //          newModule.Instance.Initialize();
        //          newModule.Instance.Host = this;
        //          newModule.Instance.user_id = Global.usr_id;
        //          newModule.Instance.role_set_id = Global.role_set_id;
        //          newModule.Instance.org_id = Global.org_id;
        //          newModule.Instance.login_number = Global.login_number;
        //          newModule.Instance.loadMyRolesNMsgtyps();

        //          //string vwPrivName = newModule.Instance.vwPrmssnName;
        //          //string appName = newModule.Instance.name;

        //          this.colAvailableModules.Add(newModule);

        //          newModule = null;
        //        }
        //        typeInterface = null;
        //      }
        //    }
        //  }
        //  ModuleAssembly = null;
        //}

        public void AddModule(string FileName)
        {
            Assembly ModuleAssembly = Assembly.LoadFrom(FileName);
            int      j = 0;

            foreach (Type ModuleType in ModuleAssembly.GetTypes())
            {
                if (ModuleType.IsPublic)
                {
                    if (!ModuleType.IsAbstract)
                    {
                        Type typeInterface = ModuleType.GetInterface("RhoInterface.RhoModule", true);
                        if (typeInterface != null)
                        {
                            Types.AvailableModule newModule = new Types.AvailableModule();
                            newModule.AssemblyPath = FileName;
                            newModule.Instance     = (RhoModule)Activator.CreateInstance(ModuleAssembly.GetType(ModuleType.ToString()));
                            newModule.Instance.Initialize();
                            newModule.Instance.Host         = this;
                            newModule.Instance.user_id      = Global.usr_id;
                            newModule.Instance.role_set_id  = Global.role_set_id;
                            newModule.Instance.org_id       = Global.org_id;
                            newModule.Instance.login_number = Global.login_number;
                            newModule.Instance.loadMyRolesNMsgtyps();

                            string vwPrivName = newModule.Instance.vwPrmssnName;
                            string appName    = newModule.Instance.name;

                            this.colAvailableModules.Add(newModule);
                            j += 1;
                            System.Windows.Forms.ToolStripMenuItem item1 = new ToolStripMenuItem();
                            item1.Name   = "mnuItem" + j;
                            item1.Text   = newModule.Instance.name;
                            item1.Image  = System.Drawing.Image.FromHbitmap(newModule.Instance.mainInterface.Icon.ToBitmap().GetHbitmap());
                            item1.Click += new System.EventHandler(Global.myNwMainFrm.loadClickedModule);
                            item1.Tag    = newModule.Instance.whereToPut.ToString() + "|" + newModule.Instance.vwPrmssnName;
                            if (newModule.Instance.whereToPut == 1)
                            {
                                Global.myNwMainFrm.customModulesToolStripMenuItem.DropDownItems.Add(item1);
                            }
                            else if (newModule.Instance.whereToPut == 2)
                            {
                                Global.myNwMainFrm.customModulesToolStripMenuItem.DropDownItems.Add(item1);
                            }
                            else
                            {
                                Global.myNwMainFrm.customModulesToolStripMenuItem.DropDownItems.Add(item1);
                            }
                            bool shdEnbl = false;
                            Global.myNwMainFrm.cmnCdMn.ModuleName = appName;
                            for (int i = 0; i < Global.role_set_id.Length; i++)
                            {
                                if (Global.myNwMainFrm.cmnCdMn.doesRoleHvThisPrvldg(Global.role_set_id[i],
                                                                                    Global.myNwMainFrm.cmnCdMn.getPrvldgID(vwPrivName)) == true)
                                {
                                    shdEnbl = true;
                                }
                            }
                            Global.myNwMainFrm.cmnCdMn.ModuleName = null;
                            if (shdEnbl == true)
                            {
                                item1.Enabled = true;
                                item1.Visible = true;
                            }
                            else
                            {
                                item1.Enabled = false;
                                item1.Visible = false;
                            }
                            newModule = null;
                        }
                        typeInterface = null;
                    }
                }
            }
            ModuleAssembly = null;
        }