Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            System.Security.Principal.WindowsPrincipal windowsPrincipal = new System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent());
            if (!windowsPrincipal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator))
            {
                TopMostMessageBox.Show(EcoLanguage.getMsg(LangRes.NeedPrivilege, new string[0]), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                System.Environment.Exit(0);
                return;
            }
            EcoGlobalVar.nullcontextMenuStrip = new ContextMenuStrip();
            EcoGlobalVar.ECOAppRunMode        = 1;
            AppInterProcess.OpenInterProcessShared();
            int processID = AppInterProcess.getProcessID(Program.program_uid, Program.program_serverid, EcoGlobalVar.ECOAppRunMode);

            if (processID != 0)
            {
                AppInterProcess.CloseShared();
                string processOwner  = Program.GetProcessOwner(processID);
                string processOwner2 = Program.GetProcessOwner(Process.GetCurrentProcess().Id);
                if (processOwner.Equals(processOwner2))
                {
                    Program.setTopMost(processID);
                }
                else
                {
                    TopMostMessageBox.Show(EcoLanguage.getMsg(LangRes.APPRunbyuser, new string[]
                    {
                        processOwner
                    }), "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                System.Environment.Exit(0);
                return;
            }
            AppInterProcess.setMyProcessID(Program.program_uid, Program.program_serverid, EcoGlobalVar.ECOAppRunMode);
            Program.setTopMost(Process.GetCurrentProcess().Id);
            int mySQLUseMajorVersionOnly = DevAccessCfg.GetInstance().getMySQLUseMajorVersionOnly();

            DBMaintain.SetMySQLVersionRole(mySQLUseMajorVersionOnly);
            while (Program.LocalConsole_cfg() == -2)
            {
            }
            DBUrl.RUNMODE = 1;
            ClientAPI.SetBroadcastCallback(new  CommonAPI.CommonAPI.DelegateOnBroadcast(EcoGlobalVar.receiveDashBoardFlgProc));
            ClientAPI.SetClosedCallback(new CommonAPI.CommonAPI.DelegateOnClosed(EcoGlobalVar.ServerClosedProc));
            Login.Login login = new Login.Login();

            login.Icon = null;
            login.ShowDialog();
            if (login.UserName == null)
            {
                Program.ExitApp();
                return;
            }
            EcoGlobalVar.gl_StartProcessfThread(true);
            Application.CurrentCulture = System.Globalization.CultureInfo.CurrentUICulture;
            if (EcoGlobalVar.ECOAppRunMode == 1)
            {
                DBCacheStatus.DBSyncEventInit(false);
                DBCacheEventProcess.StartRefreshThread(false);
                DBCache.DBCacheInit(false);
            }
            if (ClientAPI.WaitDatasetReady(40000u) < 0)
            {
                TopMostMessageBox.Show(EcoLanguage.getMsg(LangRes.DB_waitready, new string[0]), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                Program.ExitApp();
                return;
            }
            EcoGlobalVar.DCLayoutType       = ClientAPI.getRackLayout();
            EcoGlobalVar.gl_maxZoneNum      = CultureTransfer.ToInt32(ClientAPI.getKeyValue("MaxZoneNum"));
            EcoGlobalVar.gl_maxRackNum      = CultureTransfer.ToInt32(ClientAPI.getKeyValue("MaxRackNum"));
            EcoGlobalVar.gl_maxDevNum       = CultureTransfer.ToInt32(ClientAPI.getKeyValue("MaxDevNum"));
            EcoGlobalVar.gl_supportISG      = (CultureTransfer.ToInt32(ClientAPI.getKeyValue("SupportISG")) > 0);
            EcoGlobalVar.gl_supportBP       = (CultureTransfer.ToInt32(ClientAPI.getKeyValue("SupportBP")) > 0);
            EcoGlobalVar.TempUnit           = CultureTransfer.ToInt32(ClientAPI.getKeyValue("TempUnit"));
            EcoGlobalVar.CurCurrency        = ClientAPI.getKeyValue("CurCurrency");
            EcoGlobalVar.co2kg              = CultureTransfer.ToSingle(ClientAPI.getKeyValue("co2kg"));
            EcoGlobalVar.flgEnablePower     = AppData.getDB_flgEnablePower();
            EcoGlobalVar.RackFullNameFlag   = CultureTransfer.ToInt32(ClientAPI.getKeyValue("RackFullNameFlag"));
            EcoGlobalVar.gl_PeakPowerMethod = DevAccessCfg.GetInstance().getPowerPeakMethod();
            string valuePair  = ValuePairs.getValuePair("UserID");
            long   l_id       = System.Convert.ToInt64(valuePair);
            string valuePair2 = ValuePairs.getValuePair("UserName");

            valuePair = ValuePairs.getValuePair("UserType");
            int i_type = System.Convert.ToInt32(valuePair);

            valuePair = ValuePairs.getValuePair("UserRight");
            int    i_right    = System.Convert.ToInt32(valuePair);
            string valuePair3 = ValuePairs.getValuePair("UserPortNM");
            string valuePair4 = ValuePairs.getValuePair("UserDevice");
            string valuePair5 = ValuePairs.getValuePair("UserGroup");

            valuePair = ValuePairs.getValuePair("UserStatus");
            ValuePairs.getValuePair("trial");
            ValuePairs.getValuePair("remaining_days");
            int      i_status = System.Convert.ToInt32(valuePair);
            UserInfo userInfo = new UserInfo(l_id, valuePair2, "", i_status, i_type, i_right, valuePair3, valuePair4, valuePair5);

            EcoGlobalVar.gl_LoginUser            = userInfo;
            EcoGlobalVar.gl_LoginUserUACDev2Port = (System.Collections.Generic.Dictionary <long, System.Collections.Generic.List <long> >)ClientAPI.RemoteCall(8, 1, "", 10000);
            if (EcoGlobalVar.gl_LoginUserUACDev2Port == null)
            {
                TopMostMessageBox.Show(EcoLanguage.getMsg(LangRes.DB_waitready, new string[0]), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                Program.ExitApp();
                return;
            }
            string para = "0230000\n" + userInfo.UserName;

            ClientAPI.RemoteCall(100, 1, para, 10000);
            MainForm.MainForm mainForm = new MainForm.MainForm(userInfo);
            EcoGlobalVar.gl_mainForm = mainForm;
            if (!EcoGlobalVar.gl_supportISG)
            {
                EcoGlobalVar.gl_monitorCtrl.FreshFlg_ISGPower   = 0;
                EcoGlobalVar.gl_DashBoardCtrl.FreshFlg_ISGPower = 0;
            }
            EcoGlobalVar.gl_StopProcessfThread();
            Program.IdleTimer_init();
            Application.ApplicationExit += new System.EventHandler(Program.Application_ApplicationExit);
            System.AppDomain.CurrentDomain.ProcessExit += new System.EventHandler(Program.CurrentDomain_ProcessExit);
            Application.Run(mainForm);
        }
Ejemplo n.º 2
0
 private void butTest_Click(object sender, System.EventArgs e)
 {
     MainForm.MainForm mainForm = new MainForm.MainForm();
     mainForm.Show();
 }