Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        public int UpdateLineThreshold(DBConn conn)
        {
            if (this.id < 1)
            {
                return(-1);
            }
            if (this.device_id < 1)
            {
                return(-1);
            }
            DbCommand dbCommand = null;

            try
            {
                if (conn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(conn.con);
                    dbCommand.Connection  = conn.con;
                    dbCommand.CommandType = CommandType.Text;
                    string text = "update line_info set ";
                    text = text + "max_voltage=" + CultureTransfer.ToString(this.max_voltage);
                    text = text + ",min_voltage=" + CultureTransfer.ToString(this.min_voltage);
                    text = text + ",max_power=" + CultureTransfer.ToString(this.max_power);
                    text = text + ",min_power=" + CultureTransfer.ToString(this.min_power);
                    text = text + ",max_current=" + CultureTransfer.ToString(this.max_current);
                    text = text + ",min_current=" + CultureTransfer.ToString(this.min_current);
                    text = text + "  where id= " + this.id;
                    dbCommand.CommandText = text;
                    int result = dbCommand.ExecuteNonQuery();
                    dbCommand.Parameters.Clear();
                    dbCommand.Dispose();
                    return(result);
                }
            }
            catch (Exception ex)
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
            }
            return(-1);
        }
Ejemplo n.º 3
0
        public int UpdatePortThreshold(DBConn conn)
        {
            if (this.id < 1)
            {
                return(-1);
            }
            if (this.device_id < 1)
            {
                return(-1);
            }
            DbCommand dbCommand = new OleDbCommand();

            try
            {
                if (conn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(conn.con);
                    dbCommand.CommandType = CommandType.Text;
                    string text = "update port_info set port_nm=?,port_confirmation=?,port_ondelay_time=?,port_offdelay_time=?,max_voltage=?,min_voltage=?,max_power_diss=?,min_power_diss=?,max_power=?,min_power=?,max_current=?,min_current=?,shutdown_method=?,mac=? where id=" + this.id;
                    text = "update port_info set ";
                    text = text + "port_nm='" + this.port_nm + "'";
                    text = text + ",port_confirmation=" + CultureTransfer.ToString(this.port_confirmation);
                    text = text + ",port_ondelay_time=" + CultureTransfer.ToString(this.port_ondelay_time);
                    text = text + ",port_offdelay_time=" + CultureTransfer.ToString(this.port_offdelay_time);
                    text = text + ",max_voltage=" + CultureTransfer.ToString(this.max_voltage);
                    text = text + ",min_voltage=" + CultureTransfer.ToString(this.min_voltage);
                    text = text + ",max_power_diss=" + CultureTransfer.ToString(this.max_power_diss);
                    text = text + ",min_power_diss=" + CultureTransfer.ToString(this.min_power_diss);
                    text = text + ",max_power=" + CultureTransfer.ToString(this.max_power);
                    text = text + ",min_power=" + CultureTransfer.ToString(this.min_power);
                    text = text + ",max_current=" + CultureTransfer.ToString(this.max_current);
                    text = text + ",min_current=" + CultureTransfer.ToString(this.min_current);
                    text = text + ",shutdown_method=" + CultureTransfer.ToString(this.shutdown_method);
                    text = text + ",mac='" + this.port_mac + "'";
                    text = text + "  where id= " + this.id;
                    dbCommand.CommandText = text;
                    int result = dbCommand.ExecuteNonQuery();
                    dbCommand.Parameters.Clear();
                    dbCommand.Dispose();
                    return(result);
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
            }
            return(-1);
        }
Ejemplo n.º 4
0
 public static double ampMax(DevModelConfig devcfg, string sType)
 {
     System.Collections.Generic.List <stru_CommRange> ampcapicity = devcfg.ampcapicity;
     foreach (stru_CommRange current in ampcapicity)
     {
         if (string.Compare(current.type, sType, true) == 0)
         {
             return(CultureTransfer.ToDouble(devcfgUtil.Rang_max(current.range)));
         }
     }
     return(0.0);
 }
Ejemplo n.º 5
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);
 }
Ejemplo n.º 6
0
 public static double ampMax(DevModelConfig devcfg, string sType, int selNo)
 {
     System.Collections.Generic.List <stru_CommRange> ampcapicity = devcfg.ampcapicity;
     foreach (stru_CommRange current in ampcapicity)
     {
         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.ToDouble(devcfgUtil.Rang_max(current.range)));
             }
         }
     }
     return(0.0);
 }
Ejemplo n.º 7
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)))));
        }
Ejemplo n.º 8
0
        public static double getPUE(int index)
        {
            double result = 0.0;

            switch (index)
            {
            case 0:
                result = CultureTransfer.ToDouble(ClientAPI.getPueValue("CurrentIT"));
                break;

            case 1:
                result = CultureTransfer.ToDouble(ClientAPI.getPueValue("CurrentTotal"));
                break;

            case 2:
                result = CultureTransfer.ToDouble(ClientAPI.getPueValue("HourIT"));
                break;

            case 3:
                result = CultureTransfer.ToDouble(ClientAPI.getPueValue("HourTotal"));
                break;

            case 4:
                result = CultureTransfer.ToDouble(ClientAPI.getPueValue("DayIT"));
                break;

            case 5:
                result = CultureTransfer.ToDouble(ClientAPI.getPueValue("DayTotal"));
                break;

            case 6:
                result = CultureTransfer.ToDouble(ClientAPI.getPueValue("WeekIT"));
                break;

            case 7:
                result = CultureTransfer.ToDouble(ClientAPI.getPueValue("WeekTotal"));
                break;
            }
            return(result);
        }
Ejemplo n.º 9
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))));
        }
Ejemplo n.º 10
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)));
        }
Ejemplo n.º 11
0
        public System.Collections.Generic.List <string> SetSensorThreshold(SensorThreshold SSThreshold)
        {
            System.Collections.Generic.List <string> list             = new System.Collections.Generic.List <string>();
            SystemThreadPool <SnmpConfiger, string>  systemThreadPool = new SystemLargeThreadPool <SnmpConfiger, string>(this.snmpConfigs);

            return(systemThreadPool.GetResults(delegate(System.Collections.ICollection col, object obj)
            {
                SnmpConfiger snmpConfiger = (SnmpConfiger)obj;
                SnmpExecutor snmpExecutor = new DefaultSnmpExecutor(snmpConfiger);
                string arg = CultureTransfer.ToString(snmpConfiger.DeviceID);
                bool flag = false;
                try
                {
                    flag = snmpExecutor.SetSensorThreshold(SSThreshold);
                }
                catch (System.Exception)
                {
                }
                lock (col)
                {
                    ((System.Collections.Generic.List <string>)col).Add(arg + ":" + flag);
                }
            }));
        }
Ejemplo n.º 12
0
        public static bool getDB_flgEnablePower()
        {
            string keyValue = ClientAPI.getKeyValue("ENABLE_POWER_OP");

            return(string.IsNullOrEmpty(keyValue) || CultureTransfer.ToInt32(keyValue) > 0);
        }
Ejemplo n.º 13
0
 public static int getDB_flgAtenPDU()
 {
     return(CultureTransfer.ToInt32(ClientAPI.getKeyValue("ATEN_PDU")));
 }
Ejemplo n.º 14
0
 public static int getDB_FlgISG()
 {
     return(CultureTransfer.ToInt32(ClientAPI.getKeyValue("PUE_ISG")));
 }
Ejemplo n.º 15
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;
                }
            }
        }
Ejemplo n.º 16
0
        private object SetDeviceThresholdProc(object param)
        {
            DBConn dBConn = null;
            bool   flag   = false;
            string text   = "";

            try
            {
                System.Collections.Generic.List <object> list = (System.Collections.Generic.List <object>)param;
                DeviceThreshold deviceThreshold = (DeviceThreshold)list[0];
                DeviceInfo      tmp_di          = (DeviceInfo)list[1];
                System.Collections.Generic.List <DevSnmpConfig> configs = (System.Collections.Generic.List <DevSnmpConfig>)list[2];
                System.Collections.Generic.List <DeviceInfo>    list2   = (System.Collections.Generic.List <DeviceInfo>)list[3];
                DeviceInfo     deviceInfo        = list2[0];
                DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceInfo.ModelNm, deviceInfo.FWVersion);
                System.Collections.Generic.Dictionary <string, bool> dictionary = null;
                if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold)
                {
                    AppDevAccess appDevAccess = new AppDevAccess();
                    dictionary = appDevAccess.SetDeviceThresholds(configs, deviceThreshold);
                }
                dBConn = DBConnPool.getConnection();
                foreach (DeviceInfo current in list2)
                {
                    string key = CultureTransfer.ToString(current.DeviceID);
                    bool   flag2;
                    if (dictionary == null)
                    {
                        flag2 = true;
                    }
                    else
                    {
                        if (!dictionary.ContainsKey(key))
                        {
                            continue;
                        }
                        flag2 = dictionary[key];
                    }
                    if (flag2)
                    {
                        current.CopyThreshold(tmp_di);
                        current.UpdateDeviceThreshold(dBConn);
                        flag = true;
                    }
                    else
                    {
                        text = text + current.DeviceIP + ",";
                    }
                }
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine("Devive Porperties -- butAssign_Click Error:" + ex.Message);
                text = "HAVE EXCEPTION!";
            }
            if (dBConn != null)
            {
                dBConn.close();
            }
            DeviceOperation.RefreshDBCache(false);
            return(new System.Collections.Generic.List <object>
            {
                flag,
                text
            });
        }
Ejemplo n.º 17
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.º 18
0
        public static float fMaxPress(DevModelConfig devcfg)
        {
            DevCommonThreshold commonThresholds = devcfg.devThresholds.commonThresholds;

            return(CultureTransfer.ToSingle(devcfgUtil.Rang_max(commonThresholds.pressure)));
        }
Ejemplo n.º 19
0
        public static float fMinTemperature(DevModelConfig devcfg)
        {
            DevCommonThreshold commonThresholds = devcfg.devThresholds.commonThresholds;

            return(CultureTransfer.ToSingle(devcfgUtil.Rang_min(commonThresholds.temperature)));
        }
Ejemplo n.º 20
0
        public int Update(DBConn conn)
        {
            string text = this.insert_time.ToString("yyyyMMdd");

            try
            {
                long num = Convert.ToInt64(this.power_consumption * 10000.0);
                if (DBUrl.SERVERMODE)
                {
                    string item = string.Concat(new object[]
                    {
                        "update port_data_daily",
                        text,
                        " set power_consumption = power_consumption + ",
                        CultureTransfer.ToString((float)num),
                        " where port_id = ",
                        this.port_id,
                        " and insert_time = #",
                        this.insert_time.ToString("yyyy-MM-dd"),
                        "#"
                    });
                    string item2 = string.Concat(new object[]
                    {
                        "update port_data_hourly",
                        text,
                        " set power_consumption = power_consumption + ",
                        CultureTransfer.ToString((float)num),
                        " where port_id = ",
                        this.port_id,
                        " and insert_time = #",
                        new DateTime(this.insert_time.Year, this.insert_time.Month, this.insert_time.Day, DateTime.Now.Hour, 30, 0).ToString("yyyy-MM-dd HH:mm:ss"),
                        "#"
                    });
                    WorkQueue <string> .getInstance_pd().WorkSequential = true;

                    WorkQueue <string> .getInstance_pd().EnqueueItem(item);

                    WorkQueue <string> .getInstance_pd().EnqueueItem(item2);
                }
                else
                {
                    if (DBUrl.DB_CURRENT_TYPE.Equals("MYSQL"))
                    {
                        string item3 = string.Concat(new object[]
                        {
                            "update port_data_daily",
                            text,
                            " set power_consumption = power_consumption + ",
                            CultureTransfer.ToString((float)num),
                            " where port_id = ",
                            this.port_id,
                            " and insert_time = #",
                            this.insert_time.ToString("yyyy-MM-dd"),
                            "#"
                        });
                        string item4 = string.Concat(new object[]
                        {
                            "update port_data_hourly",
                            text,
                            " set power_consumption = power_consumption + ",
                            CultureTransfer.ToString((float)num),
                            " where port_id = ",
                            this.port_id,
                            " and insert_time = #",
                            new DateTime(this.insert_time.Year, this.insert_time.Month, this.insert_time.Day, DateTime.Now.Hour, 30, 0).ToString("yyyy-MM-dd HH:mm:ss"),
                            "#"
                        });
                        WorkQueue <string> .getInstance_pd().WorkSequential = true;

                        WorkQueue <string> .getInstance_pd().EnqueueItem(item3);

                        WorkQueue <string> .getInstance_pd().EnqueueItem(item4);
                    }
                    else
                    {
                        List <string> list = new List <string>();
                        list.Add(string.Concat(this.port_id));
                        list.Add(this.insert_time.ToString("yyyy-MM-dd HH:mm:ss"));
                        list.Add("port_data_daily");
                        list.Add(CultureTransfer.ToString((float)num));
                        MinuteDataProcess.GetInstance().PutItem(list);
                        List <string> list2 = new List <string>();
                        list2.Add(string.Concat(this.port_id));
                        list2.Add(this.insert_time.ToString("yyyy-MM-dd HH:mm:ss"));
                        list2.Add("port_data_hourly");
                        list2.Add(CultureTransfer.ToString((float)num));
                        MinuteDataProcess.GetInstance().PutItem(list2);
                    }
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
            }
            return(0);
        }
Ejemplo n.º 21
0
        public int UpdateSensorThreshold(DBConn conn)
        {
            if (this.id < 1)
            {
                return(-1);
            }
            if (this.device_id < 1)
            {
                return(-1);
            }
            DbCommand dbCommand = new OleDbCommand();

            try
            {
                if (conn.con != null)
                {
                    dbCommand             = DBConn.GetCommandObject(conn.con);
                    dbCommand.CommandType = CommandType.Text;
                    string text = "update device_sensor_info set max_humidity=?,min_humidity=?,max_temperature=?,min_temperature=?,max_press=?,min_press=?  where id=" + this.id;
                    text = "update device_sensor_info set ";
                    text = text + "max_humidity=" + CultureTransfer.ToString(this.max_humidity);
                    text = text + ",min_humidity=" + CultureTransfer.ToString(this.min_humidity);
                    text = text + ",max_temperature=" + CultureTransfer.ToString(this.max_temperature);
                    text = text + ",min_temperature=" + CultureTransfer.ToString(this.min_temperature);
                    text = text + ",max_press=" + CultureTransfer.ToString(this.max_press);
                    text = text + ",min_press=" + CultureTransfer.ToString(this.min_press);
                    text = text + "  where id= " + this.id;
                    dbCommand.CommandText = text;
                    int result = dbCommand.ExecuteNonQuery();
                    dbCommand.Parameters.Clear();
                    try
                    {
                        dbCommand.Dispose();
                    }
                    catch
                    {
                    }
                    return(result);
                }
            }
            catch (Exception ex)
            {
                DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace);
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
            }
            finally
            {
                try
                {
                    dbCommand.Dispose();
                }
                catch
                {
                }
            }
            return(-1);
        }