Beispiel #1
0
        /// <summary>
        /// ショートカットを作成します。
        /// </summary>
        public void CreateShortcut()
        {
            var shortcut        = new StartupShortcut();
            var desktopShortcut = new DesktopShortcut();

            shortcut.Recreate(Settings.General.IsRegisterInStartup);
            desktopShortcut.Recreate(Settings.General.IsCreateShortcutToDesktop);
        }
Beispiel #2
0
        private void RemoveObjects()
        {
            try
            {
                string loggedUser = Session["username"] as string;
#if DEBUG
                if (loggedUser == "DEVELOPER")
                {
                    return;
                }
#endif

                UsuarioLogic usuariologic = new UsuarioLogic();

                List <COCASJOL.DATAACCESS.privilegio> privs = usuariologic.GetPrivilegiosDeUsuario(loggedUser);

                XmlDocument doc = new XmlDocument();
                doc.Load(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings.Get("privilegesXML")));

                XmlNodeList nodes = doc.SelectNodes("privilegios/privilege");

                DesktopShortcuts            listDS = this.MyDesktop.Shortcuts;
                DesktopModulesCollection    listDM = this.MyDesktop.Modules;
                ItemsCollection <Component> listIC = this.MyDesktop.StartMenu.Items;

                if (privs.Count == 0)
                {
                    listDS.Clear();
                    listDM.Clear();
                    listIC.Clear();
                }
                else
                {
                    foreach (XmlNode node in nodes)
                    {
                        XmlNode keyNode      = node.SelectSingleNode("key");
                        XmlNode moduleNode   = node.SelectSingleNode("module");
                        XmlNode shortcutNode = node.SelectSingleNode("shortcut");
                        XmlNode menuitemNode = node.SelectSingleNode("menuitem");

                        string key      = keyNode.InnerText.Replace("\t", "").Replace("\r\n", "").Replace("\n", "").Trim();
                        string module   = moduleNode.InnerText.Replace("\t", "").Replace("\r\n", "").Replace("\n", "").Trim();
                        string shortcut = shortcutNode.InnerText.Replace("\t", "").Replace("\r\n", "").Replace("\n", "").Trim();
                        string menuitem = menuitemNode.InnerText.Replace("\t", "").Replace("\r\n", "").Replace("\n", "").Trim();

                        var query = from p in privs.AsParallel()
                                    where p.PRIV_LLAVE == key
                                    select p;

                        if (query.Count() == 0)
                        {
                            for (int x = 0; x < listDS.Count; x++)
                            {
                                DesktopShortcut ds = listDS.ElementAt(x);

                                if (ds.ShortcutID == shortcut)
                                {
                                    listDS.Remove(ds);
                                }
                            }

                            for (int x = 0; x < listDM.Count; x++)
                            {
                                DesktopModule dm = listDM.ElementAt(x);

                                if (dm.ModuleID == module)
                                {
                                    listDM.Remove(dm);
                                }
                            }

                            for (int x = 0; x < listIC.Count; x++)
                            {
                                Component item = listIC.ElementAt(x);

                                if (item is Ext.Net.MenuItem)
                                {
                                    Ext.Net.MenuItem menuItem = (Ext.Net.MenuItem)item;

                                    if (menuItem.Menu.Count > 0)
                                    {
                                        MenuCollection menu = menuItem.Menu;

                                        for (int y = 0; y < menu.Primary.Items.Count; y++)
                                        {
                                            Component itm = menu.Primary.Items.ElementAt(y);
                                            if (itm.ID == menuitem)
                                            {
                                                menu.Primary.Items.Remove(itm);
                                            }
                                        }
                                    }

                                    if (menuItem.Menu.Primary.Items.Count == 0)
                                    {
                                        listIC.Remove(menuItem);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al remover objetos sin acceso.", ex);
                throw;
            }
        }