Example #1
0
        public static string RangeCurrent(DevModelConfig devcfg, string sType, int selNo = 0, string fmt = "F1")
        {
            System.Collections.Generic.List <stru_CommRange> currentThresholds = devcfg.devThresholds.currentThresholds;
            string format = string.Concat(new string[]
            {
                "({0:",
                fmt,
                "}~{1:",
                fmt,
                "})"
            });

            if (currentThresholds != null)
            {
                foreach (stru_CommRange current in currentThresholds)
                {
                    if (string.Compare(current.type, sType, true) == 0)
                    {
                        int num  = System.Convert.ToInt32(devcfgUtil.Rang_min(current.id));
                        int num2 = System.Convert.ToInt32(devcfgUtil.Rang_max(current.id));
                        if (num <= selNo && selNo <= num2)
                        {
                            return(string.Format(format, CultureTransfer.ToSingle(devcfgUtil.Rang_min(current.range)), CultureTransfer.ToSingle(devcfgUtil.Rang_max(current.range))));
                        }
                    }
                }
            }
            return(string.Format(format, 0.0, 20.0));
        }
Example #2
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 #3
0
        public static string RangeTemp(DevModelConfig devcfg, string sType, int selNo = 0, string fmt = "F1")
        {
            System.Collections.Generic.List <stru_CommRange> tempThresholds = devcfg.devThresholds.tempThresholds;
            string format = string.Concat(new string[]
            {
                "({0:",
                fmt,
                "}~{1:",
                fmt,
                "})"
            });

            if (tempThresholds != null)
            {
                foreach (stru_CommRange current in tempThresholds)
                {
                    if (string.Compare(current.type, sType, true) == 0)
                    {
                        int num  = System.Convert.ToInt32(devcfgUtil.Rang_min(current.id));
                        int num2 = System.Convert.ToInt32(devcfgUtil.Rang_max(current.id));
                        if (num <= selNo && selNo <= num2)
                        {
                            string result;
                            if (EcoGlobalVar.TempUnit == 0)
                            {
                                result = string.Format(format, CultureTransfer.ToSingle(devcfgUtil.Rang_min(current.range)), CultureTransfer.ToSingle(devcfgUtil.Rang_max(current.range)));
                                return(result);
                            }
                            result = string.Format(format, RackStatusAll.CtoFdegrees((double)CultureTransfer.ToSingle(devcfgUtil.Rang_min(current.range))), RackStatusAll.CtoFdegrees((double)CultureTransfer.ToSingle(devcfgUtil.Rang_max(current.range))));
                            return(result);
                        }
                    }
                }
            }
            string temperature = devcfg.devThresholds.commonThresholds.temperature;

            if (EcoGlobalVar.TempUnit == 0)
            {
                return(string.Format(format, CultureTransfer.ToSingle(devcfgUtil.Rang_min(temperature)), CultureTransfer.ToSingle(devcfgUtil.Rang_max(temperature))));
            }
            return(string.Format(format, RackStatusAll.CtoFdegrees((double)CultureTransfer.ToSingle(devcfgUtil.Rang_min(temperature))), RackStatusAll.CtoFdegrees((double)CultureTransfer.ToSingle(devcfgUtil.Rang_max(temperature)))));
        }
Example #4
0
        public static float fMaxPowerD(DevModelConfig devcfg, string sType, int selNo = 0)
        {
            System.Collections.Generic.List <stru_CommRange> powerDissThresholds = devcfg.devThresholds.powerDissThresholds;
            if (powerDissThresholds != null)
            {
                foreach (stru_CommRange current in powerDissThresholds)
                {
                    if (string.Compare(current.type, sType, true) == 0)
                    {
                        int num  = System.Convert.ToInt32(devcfgUtil.Rang_min(current.id));
                        int num2 = System.Convert.ToInt32(devcfgUtil.Rang_max(current.id));
                        if (num <= selNo && selNo <= num2)
                        {
                            return(CultureTransfer.ToSingle(devcfgUtil.Rang_max(current.range)));
                        }
                    }
                }
            }
            DevCommonThreshold commonThresholds = devcfg.devThresholds.commonThresholds;

            return(CultureTransfer.ToSingle(devcfgUtil.Rang_max(commonThresholds.powerDissipation)));
        }
Example #5
0
        public static string RangePress(DevModelConfig devcfg, string sType, int selNo = 0)
        {
            System.Collections.Generic.List <stru_CommRange> pressThresholds = devcfg.devThresholds.PressThresholds;
            if (pressThresholds != null)
            {
                foreach (stru_CommRange current in pressThresholds)
                {
                    if (string.Compare(current.type, sType, true) == 0)
                    {
                        int num  = System.Convert.ToInt32(devcfgUtil.Rang_min(current.id));
                        int num2 = System.Convert.ToInt32(devcfgUtil.Rang_max(current.id));
                        if (num <= selNo && selNo <= num2)
                        {
                            return(string.Format("({0:F1}~{1:F1})", CultureTransfer.ToSingle(devcfgUtil.Rang_min(current.range)), CultureTransfer.ToSingle(devcfgUtil.Rang_max(current.range))));
                        }
                    }
                }
            }
            string pressure = devcfg.devThresholds.commonThresholds.pressure;

            return(string.Format("({0:F1}~{1:F1})", CultureTransfer.ToSingle(devcfgUtil.Rang_min(pressure)), CultureTransfer.ToSingle(devcfgUtil.Rang_max(pressure))));
        }
Example #6
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 #7
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);
        }
Example #8
0
        public static float fMaxPress(DevModelConfig devcfg)
        {
            DevCommonThreshold commonThresholds = devcfg.devThresholds.commonThresholds;

            return(CultureTransfer.ToSingle(devcfgUtil.Rang_max(commonThresholds.pressure)));
        }
Example #9
0
        public static float fMinTemperature(DevModelConfig devcfg)
        {
            DevCommonThreshold commonThresholds = devcfg.devThresholds.commonThresholds;

            return(CultureTransfer.ToSingle(devcfgUtil.Rang_min(commonThresholds.temperature)));
        }