private object delGateWayPro(object param) { System.Collections.ArrayList arrayList = param as System.Collections.ArrayList; for (int i = 0; i < arrayList.Count; i++) { string text = (string)arrayList[i]; InSnergyGateway gateWaybyGID = InSnergyGateway.GetGateWaybyGID(text); int num = InSnergyGateway.DeleteGateway(text); if (num < 0) { return(num); } string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0432011", new string[] { gateWaybyGID.GatewayName, valuePair }); } else { LogAPI.writeEventLog("0432011", new string[] { gateWaybyGID.GatewayName }); } InSnergyService.Unmanage(text); } return(1); }
public void pageInit(OtherDevices pParent, string gatewayID, string devName) { this.m_pParent = pParent; this.m_gatewayID = gatewayID; InSnergyGateway gateWaybyGID = InSnergyGateway.GetGateWaybyGID(gatewayID); if (gateWaybyGID == null) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.DevInfo_nofind, new string[] { devName })); return; } this.tbDevName.Text = gateWaybyGID.GatewayName; this.labDevIp.Text = InSnergyService.getGatewayIP(gateWaybyGID.GatewayID); this.labDevType.Text = gateWaybyGID.GatewayType; this.dgvBranchPanels.Rows.Clear(); int num = 1; foreach (Branch current in gateWaybyGID.BranchList) { string[] values = new string[] { num.ToString(), current.BranchName, current.Location, current.SubMeterList.Count.ToString(), current.GatewayID, current.BranchID }; this.dgvBranchPanels.Rows.Add(values); num++; } }
private void butSaveISGDev_Click(object sender, System.EventArgs e) { try { if (this.devConfigCheck()) { string text = this.tbDevName.Text.Trim(); if (InSnergyGateway.ModifyName(this.m_gatewayID, text) >= 0) { string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0432012", new string[] { text, valuePair }); } else { LogAPI.writeEventLog("0432012", new string[] { text }); } this.changeTreeSelect(this.m_gatewayID); } } } catch (System.Exception) { } }
public void QueueWork(object sender, WorkQueue <Dictionary <string, Dictionary <string, Dictionary <string, string> > > > .EnqueueEventArgs e) { if (this.con == null || this.con.State != ConnectionState.Open) { if (this.con != null) { try { this.con.Close(); } catch (Exception) { } } try { if (DBUrl.SERVERMODE) { this.con = this.getConnection(); } else { string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DBUrl.DEFAULT_HOST_PATH + ";Jet OLEDB:Database Password="******"DBERROR~~~~~~~~~~~DBERROR : " + ex.Message + "\n" + ex.StackTrace); } } try { Dictionary <string, Dictionary <string, Dictionary <string, string> > > item = e.Item; foreach (KeyValuePair <string, Dictionary <string, Dictionary <string, string> > > current in item) { string key = current.Key; Dictionary <string, Dictionary <string, string> > value = current.Value; InSnergyGateway.RefreshGateWay(key, value, this.con); if (GateWayRefreshQueue.CBWork != null) { GateWayRefreshQueue.CBWork(key); } } } catch (Exception ex2) { DebugCenter.GetInstance().appendToFile("DBERROR~~~~~~~~~~~DBERROR : " + ex2.Message + "\n" + ex2.StackTrace); } }
private void DevtreeInit() { InSnergyService.UpdateLocalTree(); this.tvDevOther.Nodes.Clear(); TreeNode treeNode = new TreeNode(); treeNode.Text = EcoLanguage.getMsg(LangRes.OtherDevRoot, new string[0]); treeNode.Name = "DevRoot"; treeNode.Tag = "DevRoot"; treeNode.ImageIndex = 0; treeNode.SelectedImageIndex = 0; this.tvDevOther.Nodes.Add(treeNode); System.Collections.Generic.List <InSnergyGateway> allGateWay = InSnergyGateway.GetAllGateWay(); foreach (InSnergyGateway current in allGateWay) { string gatewayName = current.GatewayName; TreeNode treeNode2 = new TreeNode(); treeNode2.Text = gatewayName; treeNode2.Name = current.GatewayID; treeNode2.Tag = "GateWay"; if (InSnergyService.IsGatewayOnline(current.GatewayID)) { treeNode2.ImageIndex = 3; treeNode2.SelectedImageIndex = 3; } else { treeNode2.ImageIndex = 2; treeNode2.SelectedImageIndex = 2; } treeNode.Nodes.Add(treeNode2); foreach (Branch current2 in current.BranchList) { TreeNode treeNode3 = new TreeNode(); treeNode3.Text = current2.BranchName; treeNode3.Name = current2.GatewayID + ":" + current2.BranchID; treeNode3.Tag = "BrPanel"; if (InSnergyService.IsBranchOnline(current2.GatewayID, current2.BranchID)) { treeNode3.ImageIndex = 5; treeNode3.SelectedImageIndex = 5; } else { treeNode3.ImageIndex = 4; treeNode3.SelectedImageIndex = 4; } treeNode2.Nodes.Add(treeNode3); } } }
private void otherDevSave(System.Collections.Generic.List <System.Collections.Hashtable> list) { foreach (System.Collections.Hashtable current in list) { string str_ip = (string)current["ip"]; string text = (string)current["devNm"]; string str_type = (string)current["type"]; string text2 = (string)current["devID"]; int i_usage = 0; System.Collections.Generic.List <Branch> list2 = new System.Collections.Generic.List <Branch>(); System.Collections.Generic.List <string> branchList = InSnergyService.GetBranchList(text2); foreach (string current2 in branchList) { System.Collections.Generic.List <SubMeter> list3 = new System.Collections.Generic.List <SubMeter>(); Branch item = new Branch(text2, current2, "", "", list3); list2.Add(item); System.Collections.Generic.List <string> meterList = InSnergyService.GetMeterList(text2, current2); foreach (string current3 in meterList) { SubMeter item2 = new SubMeter(text2, current2, current3, "", 0f, i_usage); list3.Add(item2); } } InSnergyGateway inSnergyGateway = new InSnergyGateway(text2, text, str_type, str_ip, list2); if (inSnergyGateway.Insert() > 0) { string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0432010", new string[] { text, valuePair }); } else { LogAPI.writeEventLog("0432010", new string[] { text }); } InSnergyService.Manage(text2); } } }
private bool devConfigCheck() { string text = this.tbDevName.Text.Trim(); this.tbDevName.Text = text; bool flag = false; Ecovalidate.checkTextIsNull(this.tbDevName, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbName.Text })); this.tbDevName.BackColor = Color.Red; return(false); } InSnergyGateway gateWaybyGID = InSnergyGateway.GetGateWaybyGID(this.m_gatewayID); if (text.Equals(gateWaybyGID.GatewayName)) { this.tbDevName.BackColor = Color.White; return(true); } if (!InSnergyGateway.CheckGatewayName(text)) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_nmdup, new string[] { this.tbDevName.Text })); this.tbDevName.Focus(); this.tbDevName.BackColor = Color.Red; return(false); } this.tbDevName.BackColor = Color.White; return(true); }
public static void LoadPUEData(ref double[] ret_v, ref int[] DB_Flg, ref string[] strTimePrompt) { try { int iSGFlag = Sys_Para.GetISGFlag(); int iTPowerFlag = Sys_Para.GetITPowerFlag(); DB_Flg[0] = iSGFlag; DB_Flg[1] = iTPowerFlag; if (iSGFlag != 0) { DateTime now = DateTime.Now; double num = 0.0; double num2 = 0.0; List <InSnergyGateway> allGateWay = InSnergyGateway.GetAllGateWay(); foreach (InSnergyGateway current in allGateWay) { if (InSnergyService.IsGatewayOnlineEx(current.GatewayID)) { foreach (Branch current2 in current.BranchList) { if (InSnergyService.IsBranchOnlineEx(current2.GatewayID, current2.BranchID)) { Dictionary <string, IMeter> branchEx = InSnergyService.GetBranchEx(current.GatewayID, current2.BranchID); foreach (SubMeter current3 in current2.SubMeterList) { if (branchEx.ContainsKey(current3.SubmeterID) && current3.ElectricityUsage != 0) { IMeter meter = branchEx[current3.SubmeterID]; switch (current3.ElectricityUsage) { case 1: if (meter.listParam.ContainsKey(5)) { double dvalue = meter.listParam[5].dvalue; num += dvalue; } break; case 2: if (meter.listParam.ContainsKey(5)) { double dvalue = meter.listParam[5].dvalue; num2 += dvalue; } break; } } } } } } } double num3; if (iTPowerFlag == 1) { num3 = num; } else { num3 = num; } double num4 = num3 + num2; ret_v[0] = num3; ret_v[1] = num4; strTimePrompt[0] = ""; strTimePrompt[1] = ""; if (InSnergyGateway.Need_Calculate_PUE) { DebugCenter.GetInstance().appendToFile("^^^ Begin to update PUE data "); DateTime now2 = DateTime.Now; num = InSnergyGateway.GetPUE(0); num2 = InSnergyGateway.GetPUE(1); num3 = num; if (iTPowerFlag == 1) { double dataCenterPDSum = DBTools.GetDataCenterPDSum(0); num3 = dataCenterPDSum + num; } num4 = num3 + num2; ret_v[2] = num3; ret_v[3] = num4; strTimePrompt[2] = now.ToString("yyyy/MM/dd HH", DateTimeFormatInfo.InvariantInfo); strTimePrompt[3] = now.ToString("yyyy/MM/dd HH", DateTimeFormatInfo.InvariantInfo); InSnergyGateway.Last_IT_HOUR = num3; InSnergyGateway.Last_TT_HOUR = num4; num = InSnergyGateway.GetPUE(2); num2 = InSnergyGateway.GetPUE(3); num3 = num; if (iTPowerFlag == 1) { double dataCenterPDSum = DBTools.GetDataCenterPDSum(1); num3 = dataCenterPDSum + num; } num4 = num3 + num2; ret_v[4] = num3; ret_v[5] = num4; strTimePrompt[4] = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo); strTimePrompt[5] = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo); InSnergyGateway.Last_IT_DAY = num3; InSnergyGateway.Last_TT_DAY = num4; num = InSnergyGateway.GetPUE(4); num2 = InSnergyGateway.GetPUE(5); num3 = num; if (iTPowerFlag == 1) { double dataCenterPDSum = DBTools.GetDataCenterPDSum(2); num3 = dataCenterPDSum + num; } num4 = num3 + num2; ret_v[6] = num3; ret_v[7] = num4; DateTime dateTime = now.AddDays((double)(1 - Convert.ToInt32(now.DayOfWeek.ToString("d")))); if (now.DayOfWeek == DayOfWeek.Sunday) { dateTime = dateTime.AddDays(-7.0); } DateTime dateTime2 = dateTime.AddDays(6.0); strTimePrompt[6] = dateTime.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo) + " -- " + dateTime2.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo); strTimePrompt[7] = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo); InSnergyGateway.Last_IT_WEEK = num3; InSnergyGateway.Last_TT_WEEK = num4; InSnergyGateway.Need_Calculate_PUE = false; DebugCenter.GetInstance().appendToFile("^^^^ Finish to update PUE data " + (DateTime.Now - now2).TotalSeconds + " sec"); } else { ret_v[2] = InSnergyGateway.Last_IT_HOUR; ret_v[3] = InSnergyGateway.Last_TT_HOUR; ret_v[4] = InSnergyGateway.Last_IT_DAY; ret_v[5] = InSnergyGateway.Last_TT_DAY; ret_v[6] = InSnergyGateway.Last_IT_WEEK; ret_v[7] = InSnergyGateway.Last_TT_WEEK; strTimePrompt[2] = now.ToString("yyyy/MM/dd HH", DateTimeFormatInfo.InvariantInfo); strTimePrompt[4] = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo); DateTime dateTime3 = now.AddDays((double)(1 - Convert.ToInt32(now.DayOfWeek.ToString("d")))); if (now.DayOfWeek == DayOfWeek.Sunday) { dateTime3 = dateTime3.AddDays(-7.0); } DateTime dateTime4 = dateTime3.AddDays(6.0); strTimePrompt[6] = dateTime3.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo) + " -- " + dateTime4.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo); strTimePrompt[3] = now.ToString("yyyy/MM/dd HH", DateTimeFormatInfo.InvariantInfo); strTimePrompt[5] = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo); strTimePrompt[7] = now.ToString("yyyy/MM/dd", DateTimeFormatInfo.InvariantInfo); } } } catch (Exception ex) { string str = CommonAPI.ReportException(0, ex, true, " "); Common.WriteLine("LoadPUEData: " + ex.Message + "\r\n" + str, new string[0]); } }
private bool pduNmCheckAtDb(string devname) { return(InSnergyGateway.CheckGatewayName(devname)); }
public void pageInit(OtherDevices pParent, string gatewayID, string BranchID) { this.m_pParent = pParent; InSnergyGateway gateWaybyBID = InSnergyGateway.GetGateWaybyBID(BranchID); if (gateWaybyBID == null) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.DevInfo_nofind, new string[] { gatewayID })); return; } this.m_gatewayID = gatewayID; this.m_branchID = BranchID; this.labDevName.Text = gateWaybyBID.GatewayName; this.labDevIp.Text = InSnergyService.getGatewayIP(gateWaybyBID.GatewayID); this.labDevType.Text = gateWaybyBID.GatewayType; Branch branch = gateWaybyBID.BranchList[0]; if (branch == null) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.DevInfo_nofind, new string[] { BranchID })); return; } this.tbBranchNm.Text = branch.BranchName; this.tbBranchLoct.Text = branch.Location; this.dgvtbISG_SubMElecUsage.Items.Clear(); this.dgvtbISG_SubMElecUsage.Items.Add("IT Power"); this.dgvtbISG_SubMElecUsage.Items.Add("Non IT Power"); this.dgvtbISG_SubMElecUsage.Items.Add("Undefined"); this.dgvSubMeters.Rows.Clear(); string text = ""; int num = 1; System.Collections.Generic.Dictionary <string, IMeter> branch2 = InSnergyService.GetBranch(this.m_gatewayID, this.m_branchID); foreach (SubMeter current in branch.SubMeterList) { switch (current.ElectricityUsage) { case 0: text = "Undefined"; break; case 1: text = "IT Power"; break; case 2: text = "Non IT Power"; break; } string submeterID = current.SubmeterID; string text2 = ""; string text3 = ""; string text4 = ""; string text5 = ""; string text6 = ""; string text7 = ""; if (branch2.ContainsKey(submeterID)) { IMeter meter = branch2[submeterID]; if (meter.listParam.ContainsKey(2)) { double dvalue = meter.listParam[2].dvalue; text2 = dvalue.ToString("F2"); } if (meter.listParam.ContainsKey(1)) { double dvalue = meter.listParam[1].dvalue; text3 = dvalue.ToString("F2"); } if (meter.listParam.ContainsKey(3)) { double dvalue = meter.listParam[3].dvalue; text4 = dvalue.ToString("F1"); } if (meter.listParam.ContainsKey(5)) { double dvalue = meter.listParam[5].dvalue; text5 = dvalue.ToString("F2"); } if (meter.listParam.ContainsKey(8)) { double dvalue = meter.listParam[8].dvalue; text6 = dvalue.ToString("F3"); } if (meter.listParam.ContainsKey(4)) { double dvalue = meter.listParam[4].dvalue; text7 = dvalue.ToString("F2"); } } string[] values = new string[] { num.ToString(), text2, text3, text4, text5, text6, text7, current.Capacity.ToString("F2"), text, current.GatewayID, current.BranchID, current.SubmeterID }; this.dgvSubMeters.Rows.Add(values); num++; } }
private void butSaveISGDev_Click(object sender, System.EventArgs e) { bool flag = true; for (int i = 0; i < this.dgvSubMeters.Rows.Count; i++) { DataGridViewRow dataGridViewRow = this.dgvSubMeters.Rows[i]; DataGridViewCellStyle dataGridViewCellStyle = new DataGridViewCellStyle(); try { string value = dataGridViewRow.Cells[7].Value.ToString(); System.Convert.ToSingle(value); dataGridViewCellStyle.BackColor = Color.WhiteSmoke; dataGridViewRow.Cells[7].Style = dataGridViewCellStyle; } catch (System.Exception) { dataGridViewCellStyle.BackColor = Color.Red; dataGridViewRow.Cells[7].Style = dataGridViewCellStyle; this.dgvSubMeters.CurrentCell = dataGridViewRow.Cells[7]; this.dgvSubMeters.BeginEdit(true); flag = false; } } if (!flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Comm_invalidNumber, new string[0])); return; } InSnergyGateway gateWaybyBID = InSnergyGateway.GetGateWaybyBID(this.m_branchID); Branch branch = gateWaybyBID.BranchList[0]; string branchName = branch.BranchName; branch.BranchName = this.tbBranchNm.Text; branch.Location = this.tbBranchLoct.Text; for (int j = 0; j < this.dgvSubMeters.Rows.Count; j++) { DataGridViewRow dataGridViewRow = this.dgvSubMeters.Rows[j]; string value = dataGridViewRow.Cells[7].Value.ToString(); string text = dataGridViewRow.Cells[8].Value.ToString(); string value2 = dataGridViewRow.Cells[11].Value.ToString(); for (int k = 0; k < branch.SubMeterCount; k++) { SubMeter subMeter = branch.SubMeterList[k]; if (subMeter.SubmeterID.Equals(value2)) { subMeter.Capacity = System.Convert.ToSingle(value); int electricityUsage; if (text.Equals("IT Power")) { electricityUsage = 1; } else { if (text.Equals("Non IT Power")) { electricityUsage = 2; } else { electricityUsage = 0; } } subMeter.ElectricityUsage = electricityUsage; } } } int num = branch.Save(); if (num < 0) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); return; } string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0432013", new string[] { branch.BranchName, gateWaybyBID.GatewayName, valuePair }); } else { LogAPI.writeEventLog("0432013", new string[] { branch.BranchName, gateWaybyBID.GatewayName }); } if (!branchName.Equals(branch.BranchName)) { this.changeTreeSelect(this.m_gatewayID + ":" + this.m_branchID); } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0])); }
public void pageInit(OtherDevices pParent, TreeNode rootNode) { this.m_pParent = pParent; if (Sys_Para.GetISGFlag() == 0) { this.cbEnableISGateway.Checked = false; this.tbISGServicePort.Enabled = false; this.cbAtenPDU.Enabled = false; } else { this.cbEnableISGateway.Checked = true; this.tbISGServicePort.Enabled = true; this.cbAtenPDU.Enabled = true; } this.tbISGServicePort.Text = System.Convert.ToString(Sys_Para.GetISGPort()); if (Sys_Para.GetITPowerFlag() == 0) { this.cbAtenPDU.Checked = false; } else { this.cbAtenPDU.Checked = true; } this.dgvAllOtherDevices.Rows.Clear(); System.Collections.Generic.List <InSnergyGateway> allGateWay = InSnergyGateway.GetAllGateWay(); foreach (TreeNode treeNode in rootNode.Nodes) { string text = treeNode.Text; string name = treeNode.Name; bool flag = false; InSnergyGateway inSnergyGateway = null; for (int i = 0; i < allGateWay.Count; i++) { inSnergyGateway = allGateWay[i]; if (inSnergyGateway.GatewayID == name) { flag = true; break; } } if (flag) { string gatewayIP = InSnergyService.getGatewayIP(inSnergyGateway.GatewayID); string msg = EcoLanguage.getMsg(LangRes.ISGST_offline, new string[0]); if (InSnergyService.IsGatewayOnline(name)) { msg = EcoLanguage.getMsg(LangRes.ISGST_online, new string[0]); } string[] values = new string[] { text, inSnergyGateway.GatewayType, gatewayIP, msg, inSnergyGateway.GatewayID }; this.dgvAllOtherDevices.Rows.Add(values); } } if (this.dgvAllOtherDevices.Rows.Count == 0) { this.butOthDevicesDel.Enabled = false; this.butOthDeviceSetup.Enabled = false; return; } this.butOthDevicesDel.Enabled = true; this.butOthDeviceSetup.Enabled = true; }