Example #1
0
 public static float fmaxCurrent(DevModelConfig devcfg, string sType, int selNo = 0)
 {
     System.Collections.Generic.List <stru_CommRange> currentThresholds = devcfg.devThresholds.currentThresholds;
     foreach (stru_CommRange current in currentThresholds)
     {
         if (string.Compare(current.type, sType, true) == 0)
         {
             int num  = CultureTransfer.ToInt32(devcfgUtil.Rang_min(current.id));
             int num2 = CultureTransfer.ToInt32(devcfgUtil.Rang_max(current.id));
             if (num <= selNo && selNo <= num2)
             {
                 return(CultureTransfer.ToSingle(devcfgUtil.Rang_max(current.range)));
             }
         }
     }
     return(-300f);
 }
Example #2
0
        public static bool getDB_flgEnablePower()
        {
            string keyValue = ClientAPI.getKeyValue("ENABLE_POWER_OP");

            return(string.IsNullOrEmpty(keyValue) || CultureTransfer.ToInt32(keyValue) > 0);
        }
Example #3
0
 public static int getDB_flgAtenPDU()
 {
     return(CultureTransfer.ToInt32(ClientAPI.getKeyValue("ATEN_PDU")));
 }
Example #4
0
 public static int getDB_FlgISG()
 {
     return(CultureTransfer.ToInt32(ClientAPI.getKeyValue("PUE_ISG")));
 }
Example #5
0
        public static void receiveDashBoardFlgProc(int infoType, object info, object carried)
        {
            string text = (string)carried;
            int    num  = 0;

            try
            {
                if ((infoType & 8) != 0 && EcoGlobalVar.gl_LoginUser != null && (EcoGlobalVar.gl_LoginUser.UserType == 1 || EcoGlobalVar.gl_LoginUser.UserType == 2))
                {
                    if (EcoGlobalVar.gl_LoginUser.UserType == 1)
                    {
                        EcoGlobalVar.gl_LoginUserUACDev2Port = (System.Collections.Generic.Dictionary <long, System.Collections.Generic.List <long> >)ClientAPI.RemoteCall(8, 1, "", 10000);
                        EcoGlobalVar.gl_LoginUser.UserDevice = ValuePairs.getValuePair("UserDevice");
                        EcoGlobalVar.gl_LoginUser.UserGroup  = ValuePairs.getValuePair("UserGroup");
                    }
                    if (EcoGlobalVar.gl_EnegManPage != null)
                    {
                        if (EcoGlobalVar.gl_LoginUser.UserType != 0 && (EcoGlobalVar.gl_LoginUser.UserDevice == null || EcoGlobalVar.gl_LoginUser.UserDevice.Length == 0))
                        {
                            EcoGlobalVar.gl_EnegManPage.showPowerControlButton(false);
                        }
                        else
                        {
                            EcoGlobalVar.gl_EnegManPage.showPowerControlButton(true);
                        }
                        if (EcoGlobalVar.gl_LoginUser.UserType != 0 && (EcoGlobalVar.gl_LoginUser.UserGroup == null || EcoGlobalVar.gl_LoginUser.UserGroup.Length == 0))
                        {
                            EcoGlobalVar.gl_EnegManPage.showGpControlButton(false);
                        }
                        else
                        {
                            EcoGlobalVar.gl_EnegManPage.showGpControlButton(true);
                        }
                    }
                    if (EcoGlobalVar.gl_DashBoardUserCtrl != null)
                    {
                        EcoGlobalVar.gl_DashBoardUserCtrl.FreshFlg_DashBoard = 1;
                        EcoGlobalVar.gl_DashBoardUserCtrl.resetTimer();
                    }
                    if (EcoGlobalVar.gl_DataGpOPAll != null && EcoGlobalVar.gl_DataGpOPAll.GroupTreeOpFlg != 64)
                    {
                        EcoGlobalVar.gl_DataGpOPAll.GroupTreeOpFlg = 64;
                    }
                }
                if ((infoType & 8192) != 0)
                {
                    try
                    {
                        string text2 = (string)info;
                        string text3 = (string)carried;
                        if (text2.Equals("RestartListener", System.StringComparison.InvariantCultureIgnoreCase))
                        {
                            string[] array = text3.Split(new char[]
                            {
                                ','
                            });
                            if (array.Length >= 2)
                            {
                                array[0].Trim();
                                array[1].Trim();
                                ClientAPI.StopBroadcastChannel();
                                EcoGlobalVar.stopalltimer(true);
                                if (!EcoGlobalVar.isinExit)
                                {
                                    EcoGlobalVar.isinExit = true;
                                    ControlAccess.ConfigControl config = delegate(Control control, object obj)
                                    {
                                        TopMostMessageBox.Show(EcoLanguage.getMsginThread("ThreadPopMsgneedRelogin", new string[0]), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                                    };
                                    ControlAccess controlAccess = new ControlAccess(EcoGlobalVar.gl_mainForm, config);
                                    controlAccess.Access(EcoGlobalVar.gl_mainForm, null);
                                    Program.ExitApp();
                                }
                            }
                        }
                    }
                    catch (System.Exception)
                    {
                    }
                }
                if (text.Length != 0)
                {
                    num = System.Convert.ToInt32(text);
                }
            }
            catch (System.Exception)
            {
            }
            if ((infoType & 4) != 0)
            {
                EcoGlobalVar.DCLayoutType = ClientAPI.getRackLayout();
            }
            if ((num & 32) != 0 || (infoType & 32) != 0)
            {
                System.Collections.Generic.Dictionary <string, string> sysValuePairs = ClientAPI.getSysValuePairs();
                if (sysValuePairs.ContainsKey("TempUnit"))
                {
                    EcoGlobalVar.TempUnit = CultureTransfer.ToInt32(sysValuePairs["TempUnit"]);
                }
                if (sysValuePairs.ContainsKey("CurCurrency"))
                {
                    EcoGlobalVar.CurCurrency = sysValuePairs["CurCurrency"];
                }
                if (sysValuePairs.ContainsKey("co2kg"))
                {
                    EcoGlobalVar.co2kg = CultureTransfer.ToSingle(sysValuePairs["co2kg"]);
                }
                if (sysValuePairs.ContainsKey("ENABLE_POWER_OP"))
                {
                    EcoGlobalVar.flgEnablePower = AppData.getDB_flgEnablePower();
                }
                if (sysValuePairs.ContainsKey("RackFullNameFlag"))
                {
                    EcoGlobalVar.RackFullNameFlag = CultureTransfer.ToInt32(sysValuePairs["RackFullNameFlag"]);
                }
                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);
            }
            if ((num & 64) != 0 && EcoGlobalVar.gl_LoginUser != null && EcoGlobalVar.gl_LoginUser.UserType != 1 && EcoGlobalVar.gl_DataGpOPAll != null && EcoGlobalVar.gl_DataGpOPAll.GroupTreeOpFlg != 64)
            {
                EcoGlobalVar.gl_DataGpOPAll.GroupTreeOpFlg = 64;
            }
            if ((num & 128) != 0 && EcoGlobalVar.ECOAppRunMode == 2)
            {
                ClientAPI.StopBroadcastChannel();
                EcoGlobalVar.stopalltimer(true);
                if (!EcoGlobalVar.isinExit)
                {
                    EcoGlobalVar.isinExit = true;
                    ControlAccess.ConfigControl config2 = delegate(Control control, object obj)
                    {
                        TopMostMessageBox.Show(EcoLanguage.getMsginThread("ThreadPopMsgneedRelogin", new string[0]), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    };
                    ControlAccess controlAccess2 = new ControlAccess(EcoGlobalVar.gl_mainForm, config2);
                    controlAccess2.Access(EcoGlobalVar.gl_mainForm, null);
                    Program.ExitApp();
                }
            }
            if ((num & 1) != 0)
            {
                if (EcoGlobalVar.gl_DashBoardCtrl != null)
                {
                    EcoGlobalVar.gl_DashBoardCtrl.FreshFlg_DashBoard = 1;
                    EcoGlobalVar.gl_DashBoardCtrl.resetTimer();
                }
                if (EcoGlobalVar.gl_DashBoardUserCtrl != null)
                {
                    EcoGlobalVar.gl_DashBoardUserCtrl.FreshFlg_DashBoard = 1;
                    EcoGlobalVar.gl_DashBoardUserCtrl.resetTimer();
                }
                if (EcoGlobalVar.gl_monitorCtrl != null)
                {
                    EcoGlobalVar.gl_monitorCtrl.FreshFlg_DashBoard = 1;
                    EcoGlobalVar.gl_monitorCtrl.resetTimer();
                }
            }
            if ((num & 2) != 0 || (infoType & 2) != 0)
            {
                if (EcoGlobalVar.gl_DashBoardCtrl != null && EcoGlobalVar.gl_DashBoardCtrl.FreshFlg_DashBoard != 1)
                {
                    EcoGlobalVar.gl_DashBoardCtrl.FreshFlg_DashBoard = 2;
                }
                if (EcoGlobalVar.gl_DashBoardUserCtrl != null && EcoGlobalVar.gl_DashBoardUserCtrl.FreshFlg_DashBoard != 1)
                {
                    EcoGlobalVar.gl_DashBoardUserCtrl.FreshFlg_DashBoard = 2;
                }
                if (EcoGlobalVar.gl_monitorCtrl != null && EcoGlobalVar.gl_monitorCtrl.FreshFlg_DashBoard != 1)
                {
                    EcoGlobalVar.gl_monitorCtrl.FreshFlg_DashBoard = 2;
                }
            }
        }
Example #6
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);
        }