Пример #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);
        }
Пример #2
0
        private static int LocalConsole_cfg()
        {
            DebugCenter instance       = DebugCenter.GetInstance();
            int         lastStatusCode = instance.getLastStatusCode();

            if (lastStatusCode == DebugCenter.ST_Unknown)
            {
                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.srvFailUnknown, new string[]
                {
                    lastStatusCode.ToString("X4")
                }));
                Program.ExitApp();
                return(-1);
            }
            if (lastStatusCode == DebugCenter.ST_DiskFull)
            {
                if (EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.srvFailDiskFull, new string[0]), MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    Program.ExitApp();
                    return(-1);
                }
                progressPopup progressPopup = new progressPopup("Service Checker", 1, EcoLanguage.getMsg(LangRes.PopProgressMsg_startsrv, new string[0]), Resources.login_background, new progressPopup.ProcessInThread(Program.StartService), null, 0);
                progressPopup.StartPosition = FormStartPosition.CenterScreen;
                progressPopup.ShowDialog();
                object return_V = progressPopup.Return_V;
                int?   num      = return_V as int?;
                if (num == -1 || num == -2)
                {
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.srvFail, new string[0]));
                    Program.ExitApp();
                    return(-1);
                }
                return(-2);
            }
            else
            {
                if ((lastStatusCode & DebugCenter.ST_fatalMask) == 0)
                {
                    ServiceController serviceController = new ServiceController(EcoGlobalVar.gl_ServiceName);
                    if (serviceController.Status.Equals(ServiceControllerStatus.Stopped))
                    {
                        progressPopup progressPopup2 = new progressPopup("Service Checker", 1, EcoLanguage.getMsg(LangRes.PopProgressMsg_startsrv, new string[0]), Resources.login_background, new progressPopup.ProcessInThread(Program.StartService), null, 0);
                        progressPopup2.StartPosition = FormStartPosition.CenterScreen;
                        progressPopup2.ShowDialog();
                        object return_V2 = progressPopup2.Return_V;
                        int?   num2      = return_V2 as int?;
                        if (num2 == -1 || num2 == -2)
                        {
                            EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.srvFail, new string[0]));
                            Program.ExitApp();
                            return(-1);
                        }
                        return(-2);
                    }
                    else
                    {
                        if (!Program.isService_initfinish())
                        {
                            int num3 = Program.waitService_initfinish();
                            if (num3 == -2)
                            {
                                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.srvFail, new string[0]));
                                Program.ExitApp();
                                return(-1);
                            }
                            return(-2);
                        }
                        else
                        {
                            if (lastStatusCode == DebugCenter.ST_Success)
                            {
                                return(0);
                            }
                            DBUrl.RUNMODE = 1;
                            DBCacheStatus.DBSyncEventInit(false);
                            DBCacheEventProcess.StartRefreshThread(false);
                            DBCache.DBCacheInit(false);
                            if ((lastStatusCode & DebugCenter.ST_MYSQLCONNECT_LOST) != 0)
                            {
                                string text = "Lost DB connection. Please check your MySQL database service.";
                                EcoMessageBox.ShowWarning(text, MessageBoxButtons.OK);
                            }
                            if (lastStatusCode == DebugCenter.ST_MYSQLCONNECT_LOST)
                            {
                                return(0);
                            }
                            registrySettings registrySettings = new registrySettings(lastStatusCode);
                            registrySettings.ShowDialog();
                            return(0);
                        }
                    }
                }
                else
                {
                    if (lastStatusCode == DebugCenter.ST_DbUpgrade || lastStatusCode == DebugCenter.ST_SysdbNotExist || lastStatusCode == DebugCenter.ST_LogdbNotExist || lastStatusCode == DebugCenter.ST_DatadbNotExist || lastStatusCode == DebugCenter.ST_SysdbNotMatch || lastStatusCode == DebugCenter.ST_ImportDatabase_ERROR)
                    {
                        restoredb    restoredb    = new restoredb(1);
                        DialogResult dialogResult = restoredb.ShowDialog();
                        if (dialogResult != DialogResult.OK)
                        {
                            commUtil.ShowInfo_DEBUG("restoredbdlg.ShowDialog() result is not DialogResult.OK!!!!!");
                        }
                    }
                    else
                    {
                        DBUrl.RUNMODE = 1;
                        registrySettings registrySettings = new registrySettings(lastStatusCode);
                        DialogResult     dialogResult2    = registrySettings.ShowDialog();
                        if (dialogResult2 != DialogResult.OK)
                        {
                            Program.ExitApp();
                            return(-1);
                        }
                    }
                    progressPopup progressPopup3 = new progressPopup("Service Checker", 1, EcoLanguage.getMsg(LangRes.PopProgressMsg_startsrv, new string[0]), Resources.login_background, new progressPopup.ProcessInThread(Program.StartService), null, 0);
                    progressPopup3.StartPosition = FormStartPosition.CenterScreen;
                    progressPopup3.ShowDialog();
                    object return_V3 = progressPopup3.Return_V;
                    int?   num4      = return_V3 as int?;
                    if (num4 == -1 || num4 == -2)
                    {
                        EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.srvFail, new string[0]));
                        Program.ExitApp();
                        return(-1);
                    }
                    return(-2);
                }
            }
        }