Beispiel #1
0
 private void tabControl2_SelectedIndexChanged(object sender, EventArgs e)
 {
     tabControl2.TabPages[1].Hide();
     if (tabControl2.SelectedIndex == 1)
     {
         uiWndAdmin adm = new uiWndAdmin();
         adm.StartPosition = FormStartPosition.CenterParent;
         if (DialogResult.OK != adm.ShowDialog())
             tabControl2.SelectTab(0);
         else
         {
             maskedTextBox1.Text = AppConfig.APP_Admin;
             tabControl2.SelectTab(1);
             tabControl2.TabPages[1].Show();
             listBox1.Select();
             listBox1.SelectedIndex = 0;
             listBox1.Invalidate(true);
             //NodePerformClick(treeView1.Nodes[0]);
         }
         adm.Dispose();
     }
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            Application.SetCompatibleTextRenderingDefault(false);
            Application.EnableVisualStyles();

            // get arguments
            Hashtable hargs = new Hashtable();
            components.Components.ArgumentParser.Com_ArgumentParser.TransformArguments(hargs, args);

            // load xml settings
            ApplicationConfiguration.CustomConfigurationMethod = CustomConfigurationSettingsContext;
            ApplicationConfiguration.Instance.LoadConfigurationData();

            // load bin settings
            driver.Config.ConfigManager.getInstance();
            if (!driver.Config.ConfigManager.LoadConfiguration())
                return;

            // mode only
            try
            {
                CoreLib.WriteLog(new Exception("Starting service mode for " + hargs["mode"]), "AppStartup (Main)");

                if (hargs.ContainsKey("mode"))
                {
                    // admin verification

                    DialogResult rez = DialogResult.None;
                    PayDesk.Components.UI.uiWndAdmin admin = new uiWndAdmin(FormStartPosition.CenterScreen);
                    rez = admin.ShowDialog();

                    // mode selector with admin
                    if (rez == DialogResult.OK)
                        switch (hargs["mode"].ToString())
                        {
                            case "settings":
                                {
                                    PayDesk.Components.UI.uiWndSettings wnd = new PayDesk.Components.UI.uiWndSettings();
                                    wnd.ShowDialog();
                                    break;
                                }
                            case "printer":
                                {
                                    PayDesk.Components.UI.uiWndPrinting wnd = new PayDesk.Components.UI.uiWndPrinting();
                                    wnd.ShowDialog();
                                    break;
                                }
                            case "billmanager":
                                {
                                    PayDesk.Components.UI.wndBills.uiWndBillManagercs wnd = new PayDesk.Components.UI.wndBills.uiWndBillManagercs();
                                    wnd.ShowDialog();
                                    break;
                                }
                        }

                    admin.Dispose();

                    return;
                }

            }
            catch { }

            ApplicationName = string.Empty;
            //if (args.Length != 0 && args[0] != null && args[0] != string.Empty)
            try
            {
                if (hargs.ContainsKey("app") && hargs["app"].ToString().Length != 0)
                    ApplicationName = args[0];
            }
            catch { }

            //axCfg = ApplicationConfiguration. ("display", @"default/config", (ApplicationName == "" ? "" : ApplicationName + @"/config"), (Program.ApplicationName != string.Empty));

            //MessageBox.Show("wait");

            //appApi = new ApiManager(args);
            /*
            if (!SecureLib.SetGetState(string.Empty))
            {
                Registration reg = new Registration();
                reg.ShowDialog();
                reg.Dispose();
                Environment.Exit(Environment.ExitCode);
            }
            */
            // in futrue move this to mdcore lib
            /* test
            if (MainArgs.ContainsKey("-c") && MainArgs["-c"] != null)
                AppConfig.LoadData(MainArgs["-c"].ToString());
            else
                AppConfig.LoadData();
            test */
            // [a] // AppConfig.LoadData();

            FileMgrLib.VerifyAllFolders();
            CoreLib.WriteLog(new Exception("It is not an error. This message used for tracking of app's startup only."), "AppStartup (Main)");

            // [a] // plugs = new PluginModule.Plugins(AppConfig.Path_Plugins);
            plugs = new Com_PluginManager(driver.Config.ConfigManager.Instance.CommonConfiguration.Path_Plugins);

            //one copy
            System.Threading.Mutex myMutex = null;
            try
            {
                myMutex = System.Threading.Mutex.OpenExisting("PayDeskMutex");
            }
            catch { }
            if (myMutex != null && driver.Config.ConfigManager.Instance.CommonConfiguration.APP_AllowOneCopy)
            {
                MMessageBox.Show("Вже запущена одна копія програми", Application.ProductName);
                Environment.Exit(0);
            }
            else
                myMutex = new System.Threading.Mutex(true, "PayDeskMutex");

            bool active = true;
            do
            {
                active = true;

                uiWndStartupDialog entry = new uiWndStartupDialog();
                active = entry.ShowDialog() == DialogResult.OK;
                entry.Dispose();

                if (!active)
                    break;

                switch (SecureLib.Authorize(entry.Password, entry.Login))
                {
                    case "service":
                        {
                            uiWndService serv = new uiWndService();
                            serv.ShowDialog();
                            serv.Dispose();
                            break;
                        }
                    case "main":
                        {
                            uiWndMain main = new uiWndMain();
                            if (main.ShowDialog() != DialogResult.Retry)
                                active = false;
                            main.Dispose();/*
                            if (Program.MainArgs.ContainsKey("-c") && Program.MainArgs["-c"] != null)
                                AppConfig.SaveData(Program.MainArgs["-c"].ToString());
                            else*/
                            driver.Config.ConfigManager.SaveConfiguration();
                            break;
                        }
                    default: { break; }
                }

            } while (active);

            CoreLib.WriteLog(new Exception("It is not an error. This message used for tracking of app's exit only."), "AppStartup (Main)");

            System.Diagnostics.Process[] prc = System.Diagnostics.Process.GetProcessesByName("vk");
            foreach (System.Diagnostics.Process p in prc)
                p.Kill();
        }