private void btnSave_Click(object sender, System.EventArgs e) { string text = this.txtpath.Text; if (text == "") { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbpath.Text })); return; } for (int i = 0; i < text.Length; i++) { char c = text.Substring(i, 1).ToCharArray()[0]; if (c > '~') { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.RptMng_pathErr1, new string[0])); return; } } int num = Sys_Para.UpdateDefinePath(this.txtpath.Text.Replace("'", "''")); if (num > 0) { EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); } }
private void butSave_Click(object sender, System.EventArgs e) { bool flag = false; Ecovalidate.checkTextIsNull(this.tbIdleTimeOut, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbidletimeout.Text })); return; } if (!Ecovalidate.Rangeint(this.tbIdleTimeOut, 0, 30)) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Range, new string[] { this.lbidletimeout.Text, "0", "30" })); return; } int num = System.Convert.ToInt32(this.tbIdleTimeOut.Text); ValuePairs.setIdleTimeout(num, true); Program.m_IdleTimeSet = num * Program.m_IdleTimeFact; EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); base.DialogResult = DialogResult.OK; base.Close(); }
private void btnSave_Click(object sender, System.EventArgs e) { string text = Sys_Para.GetBillPath(); if (text.Length == 0) { text = System.IO.Directory.GetCurrentDirectory() + "\\BillReportFile\\"; } System.DateTime now = System.DateTime.Now; int num = this.SaveToFile(text + now.ToString("yyyy-MM-dd HH-mm-ss"), this.m_pParaClass.Txttitle); if (num == -1) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Rpt_saveErr1, new string[0])); return; } if (num == -2) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.OPfail, new string[0])); return; } string str = text + now.ToString("yyyy-MM-dd HH-mm-ss") + "\\" + this.m_pParaClass.Txttitle.Replace("'", "''"); if (ReportInfo.InsertBillReport(this.m_pParaClass.Txttitle, this.m_pParaClass.Txtwriter, now, str + ".html") == 0) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.OPfail, new string[0])); return; } this.m_isRPTSaved = true; EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); }
private void butSysparaSave_Click(object sender, System.EventArgs e) { if (!this.paraCheck()) { return; } if (this.rbBilling1rate.Checked) { float bill_1rate = System.Convert.ToSingle(this.tb1rate.Text); if (Sys_Para.SetBill_ratetype(0) < 0 || Sys_Para.SetBill_1rate(bill_1rate) < 0) { EcoMessageBox.ShowError(this, EcoLanguage.getMsg(LangRes.OPfail, new string[0])); return; } } else { float bill_2rate = System.Convert.ToSingle(this.tb2Rate1.Text); float bill_2rate2 = System.Convert.ToSingle(this.tb2Rate2.Text); string bill_2from = this.dtPicker2from1.Text + ":00:00"; int bill_2duration = System.Convert.ToInt32(this.tbduration.Text); if (Sys_Para.SetBill_ratetype(1) < 0 || Sys_Para.SetBill_2from1(bill_2from) < 0 || Sys_Para.SetBill_2duration1(bill_2duration) < 0 || Sys_Para.SetBill_2rate1(bill_2rate) < 0 || Sys_Para.SetBill_2rate2(bill_2rate2) < 0) { EcoMessageBox.ShowError(this, EcoLanguage.getMsg(LangRes.OPfail, new string[0])); return; } } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); }
private void btCfgBackup_Click(object sender, System.EventArgs e) { if (!DBMaintain.ConvertOldDataFinish) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.DB_inSplitMySQLTable, new string[0])); return; } bool flag = false; Ecovalidate.checkTextIsNull(this.tbBackupPath, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbBackupPath.Text })); return; } Program.IdleTimer_Pause(1); progressPopup progressPopup = new progressPopup("Information", 1, EcoLanguage.getMsg(LangRes.PopProgressMsg_saving, new string[0]), null, new progressPopup.ProcessInThread(this.backupcfgPro), this.tbBackupPath.Text, 0); progressPopup.ShowDialog(); object return_V = progressPopup.Return_V; Program.IdleTimer_Run(1); int?num = return_V as int?; if (!num.HasValue || num < 0) { EcoMessageBox.ShowError(this, EcoLanguage.getMsg(LangRes.OPfail, new string[0])); return; } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); }
public void pageInit_1(EnegAnalysis parent) { this.m_parent = parent; this.pbLoading.Visible = false; this.btndel.Enabled = true; this.btnAdd.Enabled = true; this.dtptime.Value = System.DateTime.Now; this.m_dtbeginlast = this.dtptime.Value; this.cboperiod.SelectedIndex = 0; this.m_oldcboperiodindex = this.cboperiod.SelectedIndex; float cO2KG = Sys_Para.GetCO2KG(); if (cO2KG < 0f) { this.txtco2_elec.Text = ""; } else { this.txtco2_elec.Text = cO2KG.ToString("F2"); } float eLECTRICITYCOST = Sys_Para.GetELECTRICITYCOST(); if (eLECTRICITYCOST < 0f) { this.txtprice_elec.Text = ""; } else { this.txtprice_elec.Text = eLECTRICITYCOST.ToString("F2"); } float cO2COST = Sys_Para.GetCO2COST(); if (eLECTRICITYCOST < 0f) { this.txtprice_co2.Text = ""; } else { this.txtprice_co2.Text = cO2COST.ToString("F2"); } this.label39.Text = EcoGlobalVar.CurCurrency + this.m_ElecUnit; this.label2.Text = EcoGlobalVar.CurCurrency + this.m_CO2Unit; this.FillgroupList(); if (!DBTools.DatabaseIsReady()) { EcoMessageBox.ShowInfo(this, EcoLanguage.getMsg(LangRes.DB_waitready, new string[0])); this.btnGen.Enabled = false; return; } this.btnGen.Enabled = true; }
private void btnsave_Click(object sender, System.EventArgs e) { DataTable dataTable = new DataTable(); DataColumn dataColumn = new DataColumn(); dataColumn.DataType = System.Type.GetType("System.String"); dataColumn.ColumnName = "eventid"; dataTable.Columns.Add(dataColumn); dataColumn = new DataColumn(); dataColumn.DataType = System.Type.GetType("System.Int32"); dataColumn.ColumnName = "logflag"; dataTable.Columns.Add(dataColumn); dataColumn = new DataColumn(); dataColumn.DataType = System.Type.GetType("System.Int32"); dataColumn.ColumnName = "mailflag"; dataTable.Columns.Add(dataColumn); foreach (DataGridViewRow dataGridViewRow in (System.Collections.IEnumerable) this.dataGridViewEvent.Rows) { DataRow dataRow = dataTable.NewRow(); dataRow["eventid"] = dataGridViewRow.Cells[6].Value.ToString(); DataGridViewCheckBoxCell dataGridViewCheckBoxCell = (DataGridViewCheckBoxCell)dataGridViewRow.Cells[1]; if ((bool)dataGridViewCheckBoxCell.Value) { dataRow["logflag"] = 1; } else { dataRow["logflag"] = 0; } dataGridViewCheckBoxCell = (DataGridViewCheckBoxCell)dataGridViewRow.Cells[2]; if ((bool)dataGridViewCheckBoxCell.Value) { dataRow["mailflag"] = 1; } else { dataRow["mailflag"] = 0; } dataTable.Rows.Add(dataRow); } bool flag = LogSetting.SetEventInfo(dataTable); if (flag) { ClientAPI.RemoteCall(101, 1, "1", 10000); EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); } }
private void btCfgRestore_Click(object sender, System.EventArgs e) { if (!DBMaintain.ConvertOldDataFinish) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.DB_inSplitMySQLTable, new string[0])); return; } bool flag = false; Ecovalidate.checkTextIsNull(this.tbRestoreFile, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbRestoreFile.Text })); return; } if (!System.IO.File.Exists(this.tbRestoreFile.Text)) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.File_unexist, new string[0])); this.tbRestoreFile.Focus(); return; } DialogResult dialogResult = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.DB_ConfigRestoreCrm, new string[0]), MessageBoxButtons.OKCancel); if (dialogResult == DialogResult.Cancel) { return; } Program.IdleTimer_Pause(1); progressPopup progressPopup = new progressPopup("Information", 1, EcoLanguage.getMsg(LangRes.PopProgressMsg_Restorecfg, new string[0]), null, new progressPopup.ProcessInThread(this.RestorecfgPro), this.tbRestoreFile.Text, 0); progressPopup.ShowDialog(); object return_V = progressPopup.Return_V; Program.IdleTimer_Run(1); int?num = return_V as int?; if (!num.HasValue || num < 0) { EcoMessageBox.ShowError(this, EcoLanguage.getMsg(LangRes.quitEcoFailed, new string[0])); Program.ExitApp(); return; } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.quitEcoSucc, new string[0])); Program.ExitApp(); }
private void btnDbExport_Click(object sender, System.EventArgs e) { if (!DBMaintain.ConvertOldDataFinish) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.DB_inSplitMySQLTable, new string[0])); return; } if (DBUrl.DB_CURRENT_TYPE.ToUpper().Equals("MYSQL") && !DBMaintain.IsLocalIP(DBUrl.CURRENT_HOST_PATH)) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.DBExportFail1, new string[0])); return; } bool flag = false; Ecovalidate.checkTextIsNull(this.tbExportPath, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbExportPath.Text })); return; } if (!DBTools.CheckFreeSpaceSize4ExportDB(this.tbExportPath.Text)) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.DBExportFail2, new string[0])); return; } Program.IdleTimer_Pause(1); progressPopup progressPopup = new progressPopup("Information", 1, EcoLanguage.getMsg(LangRes.PopProgressMsg_ExportDB, new string[0]), null, new progressPopup.ProcessInThread(this.dbExportPro), null, 0); progressPopup.ShowDialog(); object return_V = progressPopup.Return_V; Program.IdleTimer_Run(1); int?num = return_V as int?; if (!num.HasValue || num < 0) { EcoMessageBox.ShowError(this, EcoLanguage.getMsg(LangRes.quitEcoFailed, new string[0])); Program.ExitApp(); return; } EcoMessageBox.ShowInfo(this, EcoLanguage.getMsg(LangRes.quitEcoSucc, new string[0])); Program.ExitApp(); }
public int modifyZone(long zoneID, string zoneNm, Color color) { ZoneInfo zoneByID = ZoneInfo.getZoneByID(zoneID); zoneByID.ZoneName = zoneNm; zoneByID.ZoneColor = color.ToArgb().ToString(); int result = zoneByID.UpdateZone(); switch (result) { case -2: case -1: EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.OPfail, new string[0])); break; case 1: { string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0430022", new string[] { zoneNm, valuePair }); } else { LogAPI.writeEventLog("0430022", new string[] { zoneNm }); } EcoGlobalVar.setDashBoardFlg(256uL, "", 0); EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); this.treeMenuInit(); this.treeMenuSelect(zoneNm); this.butAdd.Enabled = false; EcoGlobalVar.gl_DevManPage.FlushFlg_ZoneBoard = 1; break; } } return(result); }
private void btnsaveopt_Click(object sender, System.EventArgs e) { if (!this.paraoptCheck()) { return; } if (this.cbkeepdata.Checked) { Sys_Para.SetDBOpt_keepMMflag(1); int dBOpt_keepMM = System.Convert.ToInt32(this.tbkeepmonths.Text); Sys_Para.SetDBOpt_keepMM(dBOpt_keepMM); } else { Sys_Para.SetDBOpt_keepMMflag(0); } if (this.cbdelOlddata.Visible) { if (this.cbdelOlddata.Checked) { Sys_Para.SetDBOpt_deloldflag(1); } else { Sys_Para.SetDBOpt_deloldflag(0); } } string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0130020", new string[] { valuePair }); } else { LogAPI.writeEventLog("0130020", new string[0]); } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); }
private void btndel_Click(object sender, System.EventArgs e) { if (this.dgvwReport.SelectedRows.Count > 0) { if (EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.RptMng_delCrm, new string[0]), MessageBoxButtons.OKCancel).Equals(DialogResult.OK)) { string text = this.dgvwReport.SelectedRows[0].Cells["ReportPath"].Value.ToString(); string path = text.Substring(0, text.LastIndexOf('\\')); if (System.IO.Directory.Exists(path)) { try { System.IO.Directory.Delete(path, true); } catch { System.Console.WriteLine("Delete report fail,it is being used by another process"); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.OPfail, new string[0])); return; } } string sql = "delete from reportinfo where id=" + this.dgvwReport.SelectedRows[0].Cells[1].Value; int num = DBTools.executeSql(sql); if (num > 0) { EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); } if (this.ShowAll) { this.DataBind(""); return; } this.DataBind(this.cboby.SelectedIndex.ToString()); return; } } else { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Comm_selectneed, new string[0])); } }
private void btnendsession_Click(object sender, System.EventArgs e) { if (this.dgvSessions.Rows.Count == 0) { return; } string text = ""; for (int i = 0; i < this.dgvSessions.Rows.Count; i++) { DataGridViewRow dataGridViewRow = this.dgvSessions.Rows[i]; if (System.Convert.ToBoolean(dataGridViewRow.Cells[1].Value)) { string str = System.Convert.ToString(dataGridViewRow.Cells[5].Value); text = text + str + ","; } } ClientAPI.RemoteCall(103, 1, text, 10000); EcoMessageBox.ShowInfo(this, EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); this.pageInit(); }
public void pageInit(Billing parent) { this.m_parent = parent; this.pbLoading.Visible = false; this.btndel.Enabled = true; this.btnAdd.Enabled = true; this.dtptime.Value = System.DateTime.Now; System.DateTime value = this.dtpbegin.Value; int month = value.Month; System.DateTime value2 = new System.DateTime(value.Year, month, 1, value.Hour, value.Minute, value.Second, value.Millisecond); this.dtpbegin.Value = value2; this.cbRptType.SelectedIndex = 0; this.FillgroupList(); if (!DBTools.DatabaseIsReady()) { EcoMessageBox.ShowInfo(this, EcoLanguage.getMsg(LangRes.DB_waitready, new string[0])); this.btnGen.Enabled = false; return; } this.btnGen.Enabled = true; }
private void btnExport_Click(object sender, System.EventArgs e) { System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(this.SaveFile)); thread.SetApartmentState(System.Threading.ApartmentState.STA); if (thread.ThreadState != System.Threading.ThreadState.Running) { thread.Start(); thread.Join(); } if (this.SaveSuccess == 1) { EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); } else { if (this.SaveSuccess == 2) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.OPfail, new string[0])); } } this.SaveSuccess = 0; }
private void btnSave_Click(object sender, System.EventArgs e) { bool flag = false; Ecovalidate.checkTextIsNull(this.tbname, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbname.Text })); this.tbname.Focus(); return; } string text = this.tbname.Text; if (!GroupInfo.CheckGroupName(this.m_groupID, text)) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Group_nmdup, new string[] { text })); this.tbname.Focus(); return; } System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); System.Collections.Generic.List <long> list = new System.Collections.Generic.List <long>(); string text2; foreach (DataRow dataRow in this.member_tb.Rows) { text2 = (string)dataRow[0]; stringBuilder.Append(text2 + ","); list.Add((long)System.Convert.ToInt32(text2)); } text2 = stringBuilder.ToString(); if (text2.Length == 0) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Comm_selectneed, new string[0])); return; } if (this.m_groupID >= 0L) { GroupInfo groupByID = GroupInfo.GetGroupByID(this.m_groupID); groupByID.GroupName = text; groupByID.Members = text2; switch (groupByID.Update()) { case -2: case -1: EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.OPfail, new string[0])); return; case 0: break; case 1: LogAPI.writeEventLog("0430032", new string[] { groupByID.GroupName, groupByID.GroupType, EcoGlobalVar.gl_LoginUser.UserName }); EcoGlobalVar.setDashBoardFlg(520uL, "", 64); EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); base.DialogResult = DialogResult.OK; base.Close(); return; default: return; } } else { int num = GroupInfo.CreateNewGroup(text, this.m_groupType, "", list); if (num == -2) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Group_nmdup, new string[] { text })); return; } if (num < 0) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.OPfail, new string[0])); return; } LogAPI.writeEventLog("0430030", new string[] { text, this.m_groupType, EcoGlobalVar.gl_LoginUser.UserName }); EcoGlobalVar.setDashBoardFlg(512uL, "", 64); EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); base.DialogResult = DialogResult.OK; base.Close(); } }
public int addZone(string zoneNm, Color color) { string text = ""; int num = System.Math.Min(this.zonedef_startR, this.zonedef_endR); int num2 = System.Math.Max(this.zonedef_startR, this.zonedef_endR); int num3 = System.Math.Min(this.zonedef_startC, this.zonedef_endC); int num4 = System.Math.Max(this.zonedef_startC, this.zonedef_endC); for (int i = num; i <= num2; i++) { for (int j = num3; j <= num4; j++) { DataGridViewSpanCell dataGridViewSpanCell = (DataGridViewSpanCell)this.dgvSetDevice.Rows[i].Cells[j]; if (dataGridViewSpanCell.GetRowSpan() != 0 || dataGridViewSpanCell.GetColumnSpan() != 0) { string str = dataGridViewSpanCell.Tag.ToString(); text = text + str + ","; } } } text = commUtil.uniqueIDs(text); if (text.Length > 0) { text = text.Substring(0, text.Length - 1); } this.zonedef_cancel(); int result = ZoneInfo.CreateZoneInfo(zoneNm, text, num, num3, num2, num4, color.ToArgb().ToString()); switch (result) { case -2: case -1: EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.OPfail, new string[0])); break; case 1: { string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0430020", new string[] { zoneNm, valuePair }); } else { LogAPI.writeEventLog("0430020", new string[] { zoneNm }); } EcoGlobalVar.setDashBoardFlg(256uL, "", 0); EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); this.treeMenuInit(); this.treeMenuSelect(zoneNm); this.butAdd.Enabled = false; EcoGlobalVar.gl_DevManPage.FlushFlg_ZoneBoard = 1; break; } } return(result); }
private void butSysparaSave_Click(object sender, System.EventArgs e) { int bPFlag = Sys_Para.GetBPFlag(); int num = 0; int bPPort = Sys_Para.GetBPPort(); int num2 = bPPort; string bPSecurity = Sys_Para.GetBPSecurity(); string text = Sys_Para.GetBPSecurity(); bool flag = false; if (this.cbEnableBP.Checked) { num = 1; Ecovalidate.checkTextIsNull(this.tbBPlistenport, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbBPlistenPort.Text })); return; } if (!Ecovalidate.Rangeint(this.tbBPlistenport, 1, 65535)) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Range, new string[] { this.lbBPlistenPort.Text, "1", "65535" })); return; } num2 = System.Convert.ToInt32(this.tbBPlistenport.Text); if (bPPort != num2) { bool flag2 = NetworkShareAccesser.TcpPortInUse(num2); if (flag2) { this.tbBPlistenport.Focus(); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Portconflict, new string[] { this.tbBPlistenport.Text })); return; } } Ecovalidate.checkTextIsNull(this.tbBPsecuritystr, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbBPsecuritystr.Text })); return; } text = this.tbBPsecuritystr.Text; } if (bPFlag != num || bPPort != num2 || !bPSecurity.Equals(text)) { Sys_Para.SetBPFlag(num); Sys_Para.SetBPPort(num2); Sys_Para.SetBPSecurity(text); InSnergyService.RestartBillingProtocol(num == 1, num2, text); } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); }
private void butBankAssign_Click(object sender, System.EventArgs e) { bool flag = false; DBConn dBConn = null; string text = this.labDevModel.Tag.ToString(); try { int num = System.Convert.ToInt32(text); DeviceInfo deviceByID = DeviceOperation.getDeviceByID(num); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion); if (this.bankCheck(deviceModelConfig)) { DialogResult dialogResult = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.Dev_ApplyBank, new string[0]), MessageBoxButtons.OKCancel); if (dialogResult != DialogResult.Cancel) { string text2 = this.tbBankNm.Text; string text3 = this.labBankNo.Text; int num2 = System.Convert.ToInt32(text3); BankInfo bankInfo = new BankInfo(num, num2); DevSnmpConfig sNMPpara = commUtil.getSNMPpara(deviceByID); BankThreshold bankThreshold = new BankThreshold(1); if (this.gbThreshold.Visible) { bankInfo.Min_current = ThresholdUtil.UI2DB(this.tbOMinCurrent, bankInfo.Min_current, 0); bankInfo.Max_current = ThresholdUtil.UI2DB(this.tbOMaxCurrent, bankInfo.Max_current, 0); bankInfo.Min_voltage = ThresholdUtil.UI2DB(this.tbOMinVoltage, bankInfo.Min_voltage, 0); bankInfo.Max_voltage = ThresholdUtil.UI2DB(this.tbOMaxVoltage, bankInfo.Max_voltage, 0); bankInfo.Min_power = ThresholdUtil.UI2DB(this.tbOMinPower, bankInfo.Min_power, 0); bankInfo.Max_power = ThresholdUtil.UI2DB(this.tbOMaxPower, bankInfo.Max_power, 0); bankInfo.Min_power_diss = ThresholdUtil.UI2DB(this.tbOMinPowerDiss, bankInfo.Min_power_diss, 0); bankInfo.Max_power_diss = ThresholdUtil.UI2DB(this.tbOMaxPowerDiss, bankInfo.Max_power_diss, 0); int thflg = devcfgUtil.ThresholdFlg(deviceModelConfig, "bank"); bankThreshold.MinCurrentMt = bankInfo.Min_current; bankThreshold.MaxCurrentMT = bankInfo.Max_current; bankThreshold.MinVoltageMT = bankInfo.Min_voltage; bankThreshold.MaxVoltageMT = bankInfo.Max_voltage; bankThreshold.MinPowerMT = bankInfo.Min_power; bankThreshold.MaxPowerMT = bankInfo.Max_power; bankThreshold.MaxPowerDissMT = bankInfo.Max_power_diss; ThresholdUtil.UI2Dev(thflg, bankThreshold); } DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara); string myMac = deviceByID.Mac; System.Collections.Generic.List <BankInfo> bankInfo2 = deviceByID.GetBankInfo(); dBConn = DBConnPool.getConnection(); foreach (BankInfo current in bankInfo2) { BankThreshold bankThreshold2 = new BankThreshold(System.Convert.ToInt32(current.PortLists)); if (num2 == System.Convert.ToInt32(current.PortLists)) { current.BankName = text2; } bankThreshold2.BankName = current.BankName; if (this.gbThreshold.Visible) { bankThreshold2.MaxCurrentMT = bankThreshold.MaxCurrentMT; bankThreshold2.MinCurrentMt = bankThreshold.MinCurrentMt; bankThreshold2.MaxPowerMT = bankThreshold.MaxPowerMT; bankThreshold2.MinPowerMT = bankThreshold.MinPowerMT; bankThreshold2.MaxVoltageMT = bankThreshold.MaxVoltageMT; bankThreshold2.MinVoltageMT = bankThreshold.MinVoltageMT; bankThreshold2.MaxPowerDissMT = bankThreshold.MaxPowerDissMT; } bool flag2 = true; if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold) { flag2 = devAccessAPI.SetBankThreshold(bankThreshold2, myMac); } if (!flag2) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); return; } if (this.gbThreshold.Visible) { current.CopyThreshold(bankInfo); } current.UpdateBankThreshold(dBConn); flag = true; myMac = ""; } if (dBConn != null) { dBConn.close(); } string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0630011", new string[] { deviceByID.ModelNm, deviceByID.DeviceIP, deviceByID.DeviceName, valuePair }); } else { LogAPI.writeEventLog("0630011", new string[] { deviceByID.ModelNm, deviceByID.DeviceIP, deviceByID.DeviceName }); } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0])); } } } catch (System.Exception ex) { System.Console.WriteLine("butBankAssign_Click Exception" + ex.Message); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } finally { if (dBConn != null) { dBConn.close(); } DeviceOperation.RefreshDBCache(false); if (flag) { EcoGlobalVar.setDashBoardFlg(128uL, "#UPDATE#D" + text + ":B*;", 2); } } }
private void btnsave_Click(object sender, System.EventArgs e) { if (this.rbbyperiod.Checked) { if (this.i_days < 7) { this.i_days = 7; } else { if (this.i_days > 366) { this.i_days = 366; } } this.txtperiod.Text = this.i_days.ToString(); this.myLogSetting.Days = this.i_days; this.myLogSetting.Maintenance = 0; } else { if (this.i_records < 100) { this.i_records = 100; } else { if (this.i_records > 99999) { this.i_records = 99999; } } this.txtrecords.Text = this.i_records.ToString(); this.myLogSetting.RecordNum = this.i_records; this.myLogSetting.Maintenance = 1; } if (this.i_pagesize < 10) { this.i_pagesize = 10; } else { if (this.i_pagesize > 100) { this.i_pagesize = 100; } } this.txtpagesize.Text = this.i_pagesize.ToString(); this.myLogSetting.PageSize = this.i_pagesize; if (this.myLogSetting.update() > 0) { string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0130030", new string[] { valuePair }); } else { LogAPI.writeEventLog("0130030", new string[0]); } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); return; } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPfail, new string[0])); }
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])); }
private void btnDbImport_Click(object sender, System.EventArgs e) { bool flag = false; Ecovalidate.checkTextIsNull(this.tbImportFile, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbImportFile.Text })); return; } if (!System.IO.File.Exists(this.tbImportFile.Text)) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.File_unexist, new string[0])); this.tbImportFile.Focus(); return; } DBTools.ProgramBar_Percent = 1; Program.IdleTimer_Pause(1); progressPopup progressPopup = new progressPopup("Information", 2, EcoLanguage.getMsg(LangRes.PopProgressMsg_Checkfile, new string[0]), null, new progressPopup.ProcessInThread(this.dbCheckImportFile), this.tbImportFile.Text, new progressPopup.ProgramBarThread(this.dbCheckImportFileBar), 0); progressPopup.ShowDialog(); object return_V = progressPopup.Return_V; Program.IdleTimer_Run(1); string text = return_V as string; if (text == null || text.Length == 0) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.File_illegal, new string[0])); this.tbImportFile.Focus(); return; } if (text.StartsWith("DISKSIZELOW")) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.DBImportFail2, new string[0])); this.tbImportFile.Focus(); return; } if (text.StartsWith("UNZIP_ERROR")) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.DBunziperror, new string[0])); return; } if (text.StartsWith("DBVERSION_ERROR")) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.DBImportLowVerError, new string[0])); return; } string text2 = "MYSQLVERSIONERROR;"; if (text.StartsWith(text2)) { string text3 = text.Substring(text2.Length); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.needHighVerMySQL, new string[] { text3 })); return; } if (text.StartsWith("MYSQL_CONNECT_ERROR")) { mysqlsetting mysqlsetting = new mysqlsetting(text); DialogResult dialogResult = mysqlsetting.ShowDialog(); if (dialogResult != DialogResult.OK) { return; } string text4 = DBUtil.CheckMySQLVersion("127.0.0.1", mysqlsetting.DBPort, mysqlsetting.DBusrnm, mysqlsetting.DBPsw, mysqlsetting.mySQLVer); if (text4.Length > 0) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.needHighVerMySQL, new string[] { text4 })); return; } string[] array = text.Split(new string[] { "," }, System.StringSplitOptions.RemoveEmptyEntries); string text5 = array[5]; text = string.Concat(new object[] { "127.0.0.1,", mysqlsetting.DBPort, ",", mysqlsetting.DBusrnm, ",", mysqlsetting.DBPsw, ",", text5, ",RESET" }); } DialogResult dialogResult2 = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.DB_ChangeCrm, new string[0]), MessageBoxButtons.OKCancel); if (dialogResult2 == DialogResult.Cancel) { try { string aimPath = System.AppDomain.CurrentDomain.BaseDirectory + "tmpdbexchangefolder"; DBTools.DeleteDir(aimPath); } catch { } return; } Program.IdleTimer_Pause(1); DBTools.ProgramBar_Percent = 1; progressPopup = new progressPopup("Information", 2, EcoLanguage.getMsg(LangRes.PopProgressMsg_ImportDB, new string[0]), null, new progressPopup.ProcessInThread(this.dbImportPro), text, new progressPopup.ProgramBarThread(this.dbImportProBar), 0); progressPopup.ShowDialog(); return_V = progressPopup.Return_V; Program.IdleTimer_Run(1); int?num = return_V as int?; if (!num.HasValue || num < 0) { EcoMessageBox.ShowError(this, EcoLanguage.getMsg(LangRes.quitEcoFailed, new string[0])); Program.ExitApp(); return; } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.quitEcoSucc, new string[0])); Program.ExitApp(); }
private void btnSave_Click(object sender, System.EventArgs e) { string str_type = "zone"; switch (this.cboType.SelectedIndex) { case 0: str_type = "zone"; break; case 1: str_type = "rack"; break; case 2: str_type = "dev"; break; case 3: str_type = "outlet"; break; } bool flag = false; Ecovalidate.checkTextIsNull(this.tbname, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbname.Text })); this.tbname.Focus(); return; } string text = this.tbname.Text; System.Collections.Generic.List <long> list = new System.Collections.Generic.List <long>(); for (int i = 0; i < this.dgvGpmember.Rows.Count; i++) { if (this.dgvGpmember.Rows[i].Selected) { string value = this.dgvGpmember.Rows[i].Cells[0].Value.ToString(); list.Add((long)System.Convert.ToInt32(value)); } } if (list.Count == 0) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Comm_selectneed, new string[0])); this.dgvGpmember.Focus(); return; } int num = GroupInfo.CreateNewGroup(text, str_type, "", list); if (num == -2) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Group_nmdup, new string[] { text })); return; } if (num < 0) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.OPfail, new string[0])); return; } EcoGlobalVar.setDashBoardFlg(512uL, "", 64); EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); base.Close(); }
private void butSave_Click(object sender, System.EventArgs e) { try { if (this.devConfigCheck()) { string text = this.labDevModel.Text; string value = this.labDevModel.Tag.ToString(); int l_id = System.Convert.ToInt32(value); DeviceInfo deviceByID = DeviceOperation.getDeviceByID(l_id); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(text, deviceByID.FWVersion); if (this.gbPop2.Visible) { if (this.pop2_cbOutlet.Visible) { deviceByID.OutletPOPMode = (this.pop2_cbOutlet.Checked ? 2 : 1); } if (this.pop2_cbBankLIFO.Visible) { deviceByID.BankPOPLIFOMode = (this.pop2_cbBankLIFO.Checked ? 2 : 1); } deviceByID.BankPOPPriorityMode = (this.pop2_cbBankPriority.Checked ? 2 : 1); } if (this.gbPOPBankPriority.Visible) { string text2 = ""; int num; int num2; if (deviceModelConfig.bankNum == 0) { num = 1; num2 = deviceModelConfig.portNum; } else { num = deviceModelConfig.bankOutlets[0].fromPort; num2 = deviceModelConfig.bankOutlets[0].toPort; } for (int i = 0; i < this.dgvBank1_PList.Rows.Count; i++) { DataGridViewComboBoxCell dataGridViewComboBoxCell = (DataGridViewComboBoxCell)this.dgvBank1_PList.Rows[i].Cells[1]; string text3 = dataGridViewComboBoxCell.Value.ToString(); if (text3.Equals("N/A")) { text2 += "0,"; } else { text3 = text3.Substring("Outlet ".Length); text2 = text2 + ((int)System.Convert.ToInt16(text3)).ToString() + ","; } } for (int j = 0; j < num2 - num + 1 - this.dgvBank1_PList.Rows.Count; j++) { text2 += "0,"; } text2 = text2.Substring(0, text2.Length - 1); if (this.dgvBank2_PList.Visible) { num = deviceModelConfig.bankOutlets[1].fromPort; num2 = deviceModelConfig.bankOutlets[1].toPort; text2 += "#"; for (int k = 0; k < this.dgvBank2_PList.Rows.Count; k++) { DataGridViewComboBoxCell dataGridViewComboBoxCell = (DataGridViewComboBoxCell)this.dgvBank2_PList.Rows[k].Cells[1]; string text3 = dataGridViewComboBoxCell.Value.ToString(); if (text3.Equals("N/A")) { text2 += "0,"; } else { text3 = text3.Substring("Outlet ".Length); text2 = text2 + ((int)System.Convert.ToInt16(text3)).ToString() + ","; } } for (int l = 0; l < num2 - num + 1 - this.dgvBank1_PList.Rows.Count; l++) { text2 += "0,"; } text2 = text2.Substring(0, text2.Length - 1); } deviceByID.Bank_Priority = text2; } if (this.gbPop.Visible) { if (!this.cbPopEnable.Checked) { deviceByID.POPEnableMode = 1; } else { deviceByID.POPEnableMode = 2; if (this.rbPopMaxBankC.Checked) { deviceByID.POPThreshold = -0.1f; } else { deviceByID.POPThreshold = System.Convert.ToSingle(this.tbPopThreshold.Text); } } } string mac = deviceByID.Mac; DevSnmpConfig sNMPpara = commUtil.getSNMPpara(deviceByID); DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara); DevicePOPSettings devicePOPSettings = new DevicePOPSettings(); devicePOPSettings.PopEnableMode = deviceByID.POPEnableMode; devicePOPSettings.PopThreshold = deviceByID.POPThreshold; devicePOPSettings.PopModeOutlet = deviceByID.OutletPOPMode; devicePOPSettings.PopModeLIFO = deviceByID.BankPOPLIFOMode; devicePOPSettings.PopModePriority = deviceByID.BankPOPPriorityMode; devicePOPSettings.PopPriorityList = deviceByID.Bank_Priority; if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold && !devAccessAPI.SetDevicePOPSettings(devicePOPSettings, mac)) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } else { deviceByID.Update(); string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0630005", new string[] { deviceByID.DeviceName, deviceByID.Mac, deviceByID.DeviceIP, valuePair }); } else { LogAPI.writeEventLog("0630005", new string[] { deviceByID.DeviceName, deviceByID.Mac, deviceByID.DeviceIP }); } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0])); } } } catch (System.Exception ex) { System.Console.WriteLine("PropDev Exception" + ex.Message); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } }
private void butBankSave_Click(object sender, System.EventArgs e) { try { string value = this.labDevModel.Tag.ToString(); int num = System.Convert.ToInt32(value); DeviceInfo deviceByID = DeviceOperation.getDeviceByID(num); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion); if (this.bankCheck(deviceModelConfig)) { string text = this.tbBankNm.Text; string text2 = this.labBankNo.Text; int num2 = System.Convert.ToInt32(text2); BankInfo bankInfo = new BankInfo(num, num2); DevSnmpConfig sNMPpara = commUtil.getSNMPpara(deviceByID); BankThreshold bankThreshold = new BankThreshold(num2); bankThreshold.BankName = text; if (this.gbThreshold.Visible) { bankInfo.Min_current = ThresholdUtil.UI2DB(this.tbOMinCurrent, bankInfo.Min_current, 0); bankInfo.Max_current = ThresholdUtil.UI2DB(this.tbOMaxCurrent, bankInfo.Max_current, 0); bankInfo.Min_voltage = ThresholdUtil.UI2DB(this.tbOMinVoltage, bankInfo.Min_voltage, 0); bankInfo.Max_voltage = ThresholdUtil.UI2DB(this.tbOMaxVoltage, bankInfo.Max_voltage, 0); bankInfo.Min_power = ThresholdUtil.UI2DB(this.tbOMinPower, bankInfo.Min_power, 0); bankInfo.Max_power = ThresholdUtil.UI2DB(this.tbOMaxPower, bankInfo.Max_power, 0); bankInfo.Min_power_diss = ThresholdUtil.UI2DB(this.tbOMinPowerDiss, bankInfo.Min_power_diss, 0); bankInfo.Max_power_diss = ThresholdUtil.UI2DB(this.tbOMaxPowerDiss, bankInfo.Max_power_diss, 0); int thflg = devcfgUtil.ThresholdFlg(deviceModelConfig, "bank"); bankThreshold.MinCurrentMt = bankInfo.Min_current; bankThreshold.MaxCurrentMT = bankInfo.Max_current; bankThreshold.MinVoltageMT = bankInfo.Min_voltage; bankThreshold.MaxVoltageMT = bankInfo.Max_voltage; bankThreshold.MinPowerMT = bankInfo.Min_power; bankThreshold.MaxPowerMT = bankInfo.Max_power; bankThreshold.MaxPowerDissMT = bankInfo.Max_power_diss; ThresholdUtil.UI2Dev(thflg, bankThreshold); } bool flag = true; if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold) { DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara); flag = devAccessAPI.SetBankThreshold(bankThreshold, deviceByID.Mac); } if (flag) { if (bankInfo != null) { bankInfo.BankName = text; bankInfo.Update(); EcoGlobalVar.setDashBoardFlg(128uL, string.Concat(new object[] { "#UPDATE#D", bankInfo.DeviceID, ":B", bankInfo.ID, ";" }), 2); string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0630010", new string[] { bankInfo.BankName, bankInfo.PortLists, deviceByID.DeviceIP, deviceByID.DeviceName, valuePair }); } else { LogAPI.writeEventLog("0630010", new string[] { bankInfo.BankName, bankInfo.PortLists, deviceByID.DeviceIP, deviceByID.DeviceName }); } } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0])); } else { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } } } catch (System.Exception ex) { System.Console.WriteLine("PropBank Exception" + ex.Message); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } }
private void btnsave_Click(object sender, System.EventArgs e) { int status = 0; string eVENT = ""; int authenticationFlag = 0; string text = this.txtto.Text.Replace("'", "''"); if (this.cboevent.SelectedIndex == 0) { eVENT = "All"; } else { if (this.cboevent.SelectedIndex == 1) { eVENT = "Event"; } else { if (this.cboevent.SelectedIndex == 2) { eVENT = "Severity"; } } } bool flag = false; if (this.chkenablesmtp.Checked) { status = 1; Ecovalidate.checkTextIsNull(this.txtserver, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbserver.Text })); return; } Ecovalidate.checkTextIsNull(this.txtport, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbport.Text })); return; } if (!Ecovalidate.Rangeint(this.txtport, 1, 65535)) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Range, new string[] { this.lbport.Text, "1", "65535" })); return; } Ecovalidate.checkTextIsNull(this.txtfrom, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbfrom.Text })); return; } Ecovalidate.checkTextIsNull(this.txtto, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbto.Text })); return; } if (!Ecovalidate.validEmail(this.txtfrom.Text)) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.validEmail, new string[0])); this.txtfrom.Focus(); return; } if (text.Length < 5) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.validEmail, new string[0])); this.txtto.Focus(); return; } while (text.Substring(text.Length - 2) == "\r\n") { text = text.Substring(0, text.Length - 2); } string[] array = text.Split(new string[] { "\r\n", ";", ",", " " }, System.StringSplitOptions.RemoveEmptyEntries); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text2 = array2[i]; if (text2 != "" && !Ecovalidate.validEmail(text2)) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.validEmail, new string[0])); this.txtto.Focus(); return; } } } if (this.chkauth.Checked) { authenticationFlag = 1; Ecovalidate.checkTextIsNull(this.txtaccount, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbaccount.Text })); return; } Ecovalidate.checkTextIsNull(this.txtpwd, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbpwd.Text })); return; } } this.m_pSMTPpara.Status = status; this.m_pSMTPpara.ServerIP = this.txtserver.Text; this.m_pSMTPpara.Port = System.Convert.ToInt32(this.txtport.Text); this.m_pSMTPpara.Sender = this.txtfrom.Text; this.m_pSMTPpara.Receiver = this.txtto.Text; this.m_pSMTPpara.EVENT = eVENT; this.m_pSMTPpara.AuthenticationFlag = authenticationFlag; this.m_pSMTPpara.AccountName = this.txtaccount.Text; this.m_pSMTPpara.AccountPwd = this.txtpwd.Text; int num = this.m_pSMTPpara.UpdateSetting(); if (num < 0) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.OPfail, new string[0])); return; } string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0130021", new string[] { valuePair }); } else { LogAPI.writeEventLog("0130021", new string[0]); } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); }
private void startDBchange() { try { System.Threading.Thread.Sleep(500); EcoGlobalVar.ECOAppRunStatus = 2; Program.StopService(EcoGlobalVar.gl_ServiceName, 30000); System.Threading.Thread.Sleep(500); if (DBUrl.DB_CURRENT_TYPE.ToUpper().Equals("MYSQL") && this.m_usemysql) { this.m_retv = DBUrl.updatesetting(this.m_port, this.m_usrnm, this.m_psw); } else { this.m_retv = this.updatesetting(this.m_usemysql, this.m_dbIP, this.m_port, this.m_usrnm, this.m_psw); } string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0130020", new string[] { valuePair }); } else { LogAPI.writeEventLog("0130020", new string[0]); } InterProcessShared <System.Collections.Generic.Dictionary <string, string> > .setInterProcessKeyValue("ServiceStDBMaintain", "DBMaintainFinish"); if (!this.b_cancel) { Program.StartService(null); } ControlAccess.ConfigControl config = delegate(Control control, object param) { if (!this.b_cancel) { if (this.m_retv != DebugCenter.ST_Success) { EcoMessageBox.ShowError(this, EcoLanguage.getMsg(LangRes.OPfail, new string[0])); } else { EcoMessageBox.ShowInfo(this, EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); } this.m_normalclose = 2; } base.Close(); }; ControlAccess controlAccess = new ControlAccess(this, config); controlAccess.Access(this, null); } catch (System.Exception) { if (this.m_normalclose == 1) { ControlAccess.ConfigControl config2 = delegate(Control control, object param) { EcoMessageBox.ShowError(this, EcoLanguage.getMsg(LangRes.OPfail, new string[0])); this.m_normalclose = 2; base.Close(); }; ControlAccess controlAccess2 = new ControlAccess(this, config2); controlAccess2.Access(this, null); } } }
private void butSave_Click(object sender, System.EventArgs e) { try { if (this.devConfigCheck()) { string text = this.labDevModel.Text; string value = this.labDevModel.Tag.ToString(); int l_id = System.Convert.ToInt32(value); DeviceInfo deviceByID = DeviceOperation.getDeviceByID(l_id); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(text, deviceByID.FWVersion); if (this.tbRefVoltage.Visible) { deviceByID.ReferenceVoltage = System.Convert.ToSingle(this.tbRefVoltage.Text); } deviceByID.Min_current = ThresholdUtil.UI2DB(this.tbMinCurrent, deviceByID.Min_current, 0); deviceByID.Max_current = ThresholdUtil.UI2DB(this.tbMaxCurrent, deviceByID.Max_current, 0); deviceByID.Min_voltage = ThresholdUtil.UI2DB(this.tbMinVoltage, deviceByID.Min_voltage, 0); deviceByID.Max_voltage = ThresholdUtil.UI2DB(this.tbMaxVoltage, deviceByID.Max_voltage, 0); deviceByID.Min_power = ThresholdUtil.UI2DB(this.tbMinPower, deviceByID.Min_power, 0); if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU && deviceByID.Min_power != -300f) { deviceByID.Min_power *= 1000f; } deviceByID.Max_power = ThresholdUtil.UI2DB(this.tbMaxPower, deviceByID.Max_power, 0); if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU && deviceByID.Max_power != -300f) { deviceByID.Max_power *= 1000f; } deviceByID.Min_power_diss = ThresholdUtil.UI2DB(this.tbMinPowerDiss, deviceByID.Min_power_diss, 0); deviceByID.Max_power_diss = ThresholdUtil.UI2DB(this.tbMaxPowerDiss, deviceByID.Max_power_diss, 0); if (deviceModelConfig.doorReading == 2) { deviceByID.DoorSensor = 0; if (this.rbPhoto_1.Checked) { deviceByID.DoorSensor = 1; } else { if (this.rbInductive_2.Checked) { deviceByID.DoorSensor = 2; } else { if (this.rbReed_3.Checked) { deviceByID.DoorSensor = 3; } } } } string mac = deviceByID.Mac; DevSnmpConfig sNMPpara = commUtil.getSNMPpara(deviceByID); DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara); DeviceThreshold deviceThreshold = new DeviceThreshold(); int thflg = devcfgUtil.ThresholdFlg(deviceModelConfig, "dev"); deviceThreshold.MinCurrentMT = deviceByID.Min_current; deviceThreshold.MaxCurrentMT = deviceByID.Max_current; deviceThreshold.MinVoltageMT = deviceByID.Min_voltage; deviceThreshold.MaxVoltageMT = deviceByID.Max_voltage; deviceThreshold.MinPowerMT = deviceByID.Min_power; deviceThreshold.MaxPowerMT = deviceByID.Max_power; deviceThreshold.MaxPowerDissMT = deviceByID.Max_power_diss; ThresholdUtil.UI2Dev(thflg, deviceThreshold); deviceThreshold.DevReferenceVoltage = deviceByID.ReferenceVoltage; deviceThreshold.PopEnableMode = -500; deviceThreshold.PopThreshold = -500f; deviceThreshold.PopModeOutlet = -500; deviceThreshold.PopModeLIFO = -500; deviceThreshold.PopModePriority = -500; deviceThreshold.DoorSensorType = deviceByID.DoorSensor; if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold && !devAccessAPI.SetDeviceThreshold(deviceThreshold, mac)) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } else { deviceByID.Update(); string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0630000", new string[] { deviceByID.DeviceName, deviceByID.Mac, deviceByID.DeviceIP, valuePair }); } else { LogAPI.writeEventLog("0630000", new string[] { deviceByID.DeviceName, deviceByID.Mac, deviceByID.DeviceIP }); } EcoGlobalVar.setDashBoardFlg(128uL, "#UPDATE#D" + deviceByID.DeviceID + ":;", 2); EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0])); } } } catch (System.Exception ex) { System.Console.WriteLine("PropDev Exception" + ex.Message); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } }
private void butSysparaSave_Click(object sender, System.EventArgs e) { if (!this.sysparaCheck()) { return; } int selectedIndex = this.cbReadDelay.SelectedIndex; int serviceDelay = 60; if (selectedIndex == 0) { serviceDelay = 30; } else { if (selectedIndex == 1) { serviceDelay = 60; } else { if (selectedIndex == 2) { serviceDelay = 180; } else { if (selectedIndex == 3) { serviceDelay = 300; } else { if (selectedIndex == 4) { serviceDelay = 600; } else { if (selectedIndex == 5) { serviceDelay = 900; } } } } } } float cO2KG = -5f; float cO2KG2 = Sys_Para.GetCO2KG(); int temperatureUnit = Sys_Para.GetTemperatureUnit(); string currency = Sys_Para.GetCurrency(); int rackFullNameflag = Sys_Para.GetRackFullNameflag(); bool enablePowerControlFlag = Sys_Para.GetEnablePowerControlFlag(); if (this.txtco2_elec.Text.Length > 0) { cO2KG = System.Convert.ToSingle(this.txtco2_elec.Text); } float eLECTRICITYCOST = -5f; if (this.txtprice_elec.Text.Length > 0) { eLECTRICITYCOST = System.Convert.ToSingle(this.txtprice_elec.Text); } float cO2COST = -5f; if (this.txtprice_co2.Text.Length > 0) { cO2COST = System.Convert.ToSingle(this.txtprice_co2.Text); } if (Sys_Para.SetServiceDelay(serviceDelay) < 0 || Sys_Para.SetCO2KG(cO2KG) < 0 || Sys_Para.SetELECTRICITYCOST(eLECTRICITYCOST) < 0 || Sys_Para.SetCO2COST(cO2COST) < 0) { EcoMessageBox.ShowError(this, EcoLanguage.getMsg(LangRes.OPfail, new string[0])); EcoGlobalVar.co2kg = Sys_Para.GetCO2KG(); return; } bool flag = false; ulong num = 0uL; int num2 = 0; EcoGlobalVar.co2kg = Sys_Para.GetCO2KG(); if (cO2KG2 != EcoGlobalVar.co2kg) { flag = true; } if (this.rbEC1.Checked) { int energyType = 0; float energyValue = System.Convert.ToSingle(this.tbECVoltage.Text); if (Sys_Para.SetEnergyType(energyType) < 0 || Sys_Para.SetEnergyValue(energyValue) < 0) { EcoMessageBox.ShowError(this, EcoLanguage.getMsg(LangRes.OPfail, new string[0])); return; } } else { if (this.rbEC2.Checked) { int energyType = 1; int referenceDevice = System.Convert.ToInt32(this.lbECDevNm.Tag.ToString()); if (Sys_Para.SetEnergyType(energyType) < 0 || Sys_Para.SetReferenceDevice(referenceDevice) < 0) { EcoMessageBox.ShowError(this, EcoLanguage.getMsg(LangRes.OPfail, new string[0])); return; } } else { if (this.rbEC3.Checked) { int energyType = 2; if (Sys_Para.SetEnergyType(energyType) < 0) { EcoMessageBox.ShowError(this, EcoLanguage.getMsg(LangRes.OPfail, new string[0])); return; } } } } if (this.TempUnitC.Checked) { EcoGlobalVar.TempUnit = 0; } else { EcoGlobalVar.TempUnit = 1; } Sys_Para.SetTemperatureUnit(EcoGlobalVar.TempUnit); if (temperatureUnit != EcoGlobalVar.TempUnit) { flag = true; } EcoGlobalVar.CurCurrency = this.cbCurrency.SelectedItem.ToString(); Sys_Para.SetCurrency(EcoGlobalVar.CurCurrency); if (!currency.Equals(EcoGlobalVar.CurCurrency)) { flag = true; } int selectedIndex2 = this.cbDClayout.SelectedIndex; if (selectedIndex2 != EcoGlobalVar.DCLayoutType) { Sys_Para.SetResolution(selectedIndex2); EcoGlobalVar.DCLayoutType = selectedIndex2; num |= 4uL; num2 |= 1; } if (this.cbERackFNm.Checked) { Sys_Para.SetRackFullNameflag(1); if (rackFullNameflag != 1) { flag = true; } } else { Sys_Para.SetRackFullNameflag(0); if (rackFullNameflag != 0) { flag = true; } } Sys_Para.SetEnablePowerControlFlag(this.cbERPower.Checked); if (enablePowerControlFlag != this.cbERPower.Checked) { flag = true; } if (flag) { num |= 32uL; num2 |= 32; } EcoGlobalVar.setDashBoardFlg(num, "", num2); string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0130023", new string[] { valuePair }); } else { LogAPI.writeEventLog("0130023", new string[0]); } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); }
private void butAssign_Click(object sender, System.EventArgs e) { try { if (this.devConfigCheck()) { DialogResult dialogResult = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.Dev_ApplyAll, new string[0]), MessageBoxButtons.OKCancel); if (dialogResult != DialogResult.Cancel) { string text = this.labDevModel.Text; string value = this.labDevModel.Tag.ToString(); int l_id = System.Convert.ToInt32(value); DeviceInfo deviceByID = DeviceOperation.getDeviceByID(l_id); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(text, deviceByID.FWVersion); System.Collections.Generic.List <DeviceInfo> allDeviceByModel = DeviceOperation.GetAllDeviceByModel(text); string fWVersion = deviceByID.FWVersion; System.Collections.Generic.List <DeviceInfo> list = new System.Collections.Generic.List <DeviceInfo>(); foreach (DeviceInfo current in allDeviceByModel) { if (current.DeviceID != deviceByID.DeviceID) { if (!DevAccessCfg.GetInstance().isAutodectDev(current.ModelNm, current.FWVersion)) { list.Add(current); } else { if (current.FWVersion.Equals(fWVersion)) { list.Add(current); } } } } if (this.tbRefVoltage.Visible) { deviceByID.ReferenceVoltage = System.Convert.ToSingle(this.tbRefVoltage.Text); } deviceByID.Min_current = ThresholdUtil.UI2DB(this.tbMinCurrent, deviceByID.Min_current, 0); deviceByID.Max_current = ThresholdUtil.UI2DB(this.tbMaxCurrent, deviceByID.Max_current, 0); deviceByID.Min_voltage = ThresholdUtil.UI2DB(this.tbMinVoltage, deviceByID.Min_voltage, 0); deviceByID.Max_voltage = ThresholdUtil.UI2DB(this.tbMaxVoltage, deviceByID.Max_voltage, 0); deviceByID.Min_power = ThresholdUtil.UI2DB(this.tbMinPower, deviceByID.Min_power, 0); if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU && deviceByID.Min_power != -300f) { deviceByID.Min_power *= 1000f; } deviceByID.Max_power = ThresholdUtil.UI2DB(this.tbMaxPower, deviceByID.Max_power, 0); if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU && deviceByID.Max_power != -300f) { deviceByID.Max_power *= 1000f; } deviceByID.Min_power_diss = ThresholdUtil.UI2DB(this.tbMinPowerDiss, deviceByID.Min_power_diss, 0); deviceByID.Max_power_diss = ThresholdUtil.UI2DB(this.tbMaxPowerDiss, deviceByID.Max_power_diss, 0); if (deviceModelConfig.doorReading == 2) { deviceByID.DoorSensor = 0; if (this.rbPhoto_1.Checked) { deviceByID.DoorSensor = 1; } else { if (this.rbInductive_2.Checked) { deviceByID.DoorSensor = 2; } else { if (this.rbReed_3.Checked) { deviceByID.DoorSensor = 3; } } } } DeviceInfo item = new DeviceInfo(-1, "", "", "", "", "", "", "", 0, 0, "", 161, 1, "", deviceByID.Max_voltage, deviceByID.Min_voltage, deviceByID.Max_power_diss, deviceByID.Min_power_diss, deviceByID.Max_power, deviceByID.Min_power, deviceByID.Max_current, deviceByID.Min_current, -1L, "", -500, -500f, deviceByID.DoorSensor, 0f, -500, -500, -500, "", -500f); int thflg = devcfgUtil.ThresholdFlg(deviceModelConfig, "dev"); DeviceThreshold deviceThreshold = new DeviceThreshold(); deviceThreshold.MinCurrentMT = deviceByID.Min_current; deviceThreshold.MaxCurrentMT = deviceByID.Max_current; deviceThreshold.MinVoltageMT = deviceByID.Min_voltage; deviceThreshold.MaxVoltageMT = deviceByID.Max_voltage; deviceThreshold.MinPowerMT = deviceByID.Min_power; deviceThreshold.MaxPowerMT = deviceByID.Max_power; deviceThreshold.MaxPowerDissMT = deviceByID.Max_power_diss; ThresholdUtil.UI2Dev(thflg, deviceThreshold); deviceThreshold.PopEnableMode = -500; deviceThreshold.PopThreshold = -500f; deviceThreshold.PopModeOutlet = -500; deviceThreshold.PopModeLIFO = -500; deviceThreshold.PopModePriority = -500; deviceThreshold.DoorSensorType = -500; System.Collections.Generic.List <DevSnmpConfig> list2 = new System.Collections.Generic.List <DevSnmpConfig>(); foreach (DeviceInfo current2 in list) { if (ClientAPI.IsDeviceOnline(current2.DeviceID)) { DevSnmpConfig sNMPpara = commUtil.getSNMPpara(current2); list2.Add(sNMPpara); } } bool flag = false; string text2 = ""; if (list.Count > 0) { System.Collections.Generic.List <object> list3 = new System.Collections.Generic.List <object>(); list3.Add(deviceThreshold); list3.Add(item); list3.Add(list2); list3.Add(list); Program.IdleTimer_Pause(1); System.Collections.Generic.List <object> list4; if (list2.Count > 50) { progressPopup progressPopup = new progressPopup("Information", 1, EcoLanguage.getMsg(LangRes.PopProgressMsg_setDevThreshold, new string[0]), null, new progressPopup.ProcessInThread(this.SetDeviceThresholdProc), list3, 0); progressPopup.ShowDialog(); list4 = (progressPopup.Return_V as System.Collections.Generic.List <object>); } else { list4 = (this.SetDeviceThresholdProc(list3) as System.Collections.Generic.List <object>); } flag = (bool)list4[0]; text2 = (string)list4[1]; } if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold) { DevSnmpConfig sNMPpara2 = commUtil.getSNMPpara(deviceByID); DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara2); deviceThreshold.DevReferenceVoltage = deviceByID.ReferenceVoltage; deviceThreshold.DoorSensorType = deviceByID.DoorSensor; if (devAccessAPI.SetDeviceThreshold(deviceThreshold, deviceByID.Mac)) { flag = true; } else { text2 = "HAVE EXCEPTION!"; } } Program.IdleTimer_Run(1); if (flag) { EcoGlobalVar.setDashBoardFlg(2uL, "", 2); string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0630001", new string[] { text, valuePair }); } else { LogAPI.writeEventLog("0630001", new string[] { text }); } } if (text2.Length > 0) { if (text2.Equals("HAVE EXCEPTION!")) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } else { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail_1, new string[] { text2 })); } } else { EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0])); } } } } catch (System.Exception ex) { System.Console.WriteLine("Devive Porperties -- butAssign_Click Error:" + ex.Message); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } }