Ejemplo n.º 1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            foreach (ToolStripItem item in toolStripClient.Items)
            {
                toolStripTexts.Add(item.Text);
            }
            Stream inStream = null;
            if(ClientSetting.IsClient())
            {

                // load menu
                inStream = this.GetType().Assembly.GetManifestResourceStream("AppFrameClient.ClientMenuPermissions.xml");
            }
            else
            {
                if(ClientSetting.IsServer())
                {
                    inStream = this.GetType().Assembly.GetManifestResourceStream("AppFrameClient.ServerMenuPermissions.xml");
                }
                else
                {
                    if(ClientSetting.IsSubStock())
                    {
                        inStream = this.GetType().Assembly.GetManifestResourceStream("AppFrameClient.SubStockMenuPermissions.xml");
                    }
                    else
                    {
                        inStream = this.GetType().Assembly.GetManifestResourceStream("AppFrameClient.NAMenuPermissions.xml");
                    }

                }
            }

            // load menu permission
            MenuItemPermission menuItemPermission = new MenuItemPermission(MenuItemPermission.INVISIBLE);
            menuItemPermission.loadRoles(inStream);
            ClientInfo clientInfo = ClientInfo.getInstance();
            clientInfo.MenuPermissions = menuItemPermission;

            // register main form
            GlobalCache.Instance().MainForm = this;

            // check menu permission
            MenuUtility.setPermission(clientInfo.LoggedUser, ref this.mnuMenu, menuItemPermission);
            //CheckClientServer();
            toolStripClient.Focus();
            Stream toolStripInStream = null;
            if(ClientSetting.IsClient())
            {
                toolStripClient.Visible = true;
                // load and set permissions
                toolStripInStream = this.GetType().Assembly.GetManifestResourceStream("AppFrameClient.ClientToolStripPermissions.xml");
                // run service in client
                consumer = new ServerServiceConsumer();
            }
            else if (ClientSetting.IsSubStock())
            {
                subStockConsumer= new SubStockConsumer();
                    // load toolstrip
                    toolStripClient.Visible = true;
                    // load and set permissions
                    toolStripInStream = this.GetType().Assembly.GetManifestResourceStream("AppFrameClient.SubStockToolStripPermissions.xml");

            }
            else if(ClientSetting.IsServer())
            {
                // load toolstrip
                toolStripClient.Visible = true;
                // load and set permissions
                toolStripInStream = this.GetType().Assembly.GetManifestResourceStream("AppFrameClient.ServerToolStripPermissions.xml");
                ServiceStatus.Text = "...";
            }
            else
            {
                toolStripClient.Visible = false;
            }
            if(toolStripInStream != null)
            {
                ToolStripItemPermission toolStripItemPermission = new ToolStripItemPermission(ToolStripItemPermission.INVISIBLE);
                toolStripItemPermission.loadRoles(toolStripInStream);
                GlobalCache.Instance().ClientToolStripPermission = toolStripItemPermission;
                MenuUtility.setPermission(this, clientInfo, ref this.toolStripClient, toolStripItemPermission);
            }

            if(toolStripClient.Visible == true)
            {
                RenderFunctionKeysTextToToolStrip();

            }
        }
Ejemplo n.º 2
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if(consumer != null)
     {
         consumer.Stop();
         consumer = null;
     }
     if(subStockConsumer !=null)
     {
         subStockConsumer.Stop();
         subStockConsumer = null;
     }
 }