private void showCoolMasterNetInfo() { try { isRead = true; Cursor.Current = Cursors.WaitCursor; chbEnable.Checked = ((CoolMasterNet)MyCoolMaster).Enable; txtIP.Text = ((CoolMasterNet)MyCoolMaster).strIP; txtPort.Text = ((CoolMasterNet)MyCoolMaster).Port.ToString(); dgvAC.Rows.Clear(); if (MyCoolMaster.myACSetting != null) { for (int i = 0; i < MyCoolMaster.myACSetting.Count; i++) { ThirdPartAC temp = MyCoolMaster.myACSetting[i]; string strEnable = CsConst.WholeTextsList[1775].sDisplayName; if (temp.Enable == 1) { strEnable = CsConst.mstrINIDefault.IniReadValue("public", "00042", ""); } byte[] arayTmp = new byte[1]; arayTmp[0] = temp.GroupID; string strLine = System.Text.Encoding.Default.GetString(arayTmp); string strIndoor = System.Text.Encoding.Default.GetString(temp.arayACinfo); object[] obj = new object[] { temp.ID.ToString(), strEnable, temp.ACNO.ToString(), strLine, strIndoor }; dgvAC.Rows.Add(obj); } } } catch { } Cursor.Current = Cursors.Default; isRead = false; }
//<summary> //读取数据信息 //</summary> public void ReadDataFrmDBTobuf(int DIndex) { try { #region string strsql = string.Format("select * from dbClassInfomation where DIndex={0} and ClassID={1} order by SenNum", DIndex, 0); OleDbDataReader dr = DataModule.SearchAResultSQLDB(strsql, CsConst.mstrCurPath); myACSetting = new List<ThirdPartAC>(); if (dr != null) { while (dr.Read()) { ThirdPartAC temp = new ThirdPartAC(); string str = dr.GetValue(5).ToString(); temp.ID = Convert.ToByte(str.Split('-')[0].ToString()); temp.Enable = Convert.ToByte(str.Split('-')[1].ToString()); temp.ACNO = Convert.ToByte(str.Split('-')[2].ToString()); temp.CoolMasterAddress = Convert.ToByte(str.Split('-')[3].ToString()); temp.GroupID = Convert.ToByte(str.Split('-')[4].ToString()); temp.arayACinfo = (byte[])dr[6]; temp.Remark = dr.GetValue(4).ToString(); myACSetting.Add(temp); } dr.Close(); } #endregion } catch { } }
public bool DownLoadInfoFrmDevice(string DevNam, int wdDeviceType, int intActivePage, int num1, int num2) { string strMainRemark = DevNam.Split('\\')[1].Trim(); DevNam = DevNam.Split('\\')[0].Trim(); byte bytSubID = byte.Parse(DevNam.Split('-')[0].ToString()); byte bytDevID = byte.Parse(DevNam.Split('-')[1].ToString()); byte[] ArayTmp = null; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x000E, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == false) { return false; } else { byte[] arayRemark = new byte[20]; for (int intI = 0; intI < 20; intI++) { arayRemark[intI] = CsConst.myRevBuf[25 + intI]; } DeviceName = bytSubID.ToString() + "-" + bytDevID.ToString() + "\\" + HDLPF.Byte2String(arayRemark); CsConst.myRevBuf = new byte[1200]; } if (CsConst.isRestore) { num1 = 1; num2 = 64; } if (intActivePage == 0 || intActivePage == 1) { myACSetting = new List<ThirdPartAC>(); for (int i = num1; i <= num2; i++) { ArayTmp = new byte[1]; ArayTmp[0] = Convert.ToByte(i); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x0240, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { ThirdPartAC temp = new ThirdPartAC(); temp.ID = Convert.ToByte(i); temp.ACNO = CsConst.myRevBuf[26]; temp.Enable = CsConst.myRevBuf[27]; temp.CoolMasterAddress = CsConst.myRevBuf[28]; temp.GroupID = CsConst.myRevBuf[29]; temp.arayACinfo = new byte[10]; Array.Copy(CsConst.myRevBuf, 30, temp.arayACinfo, 0, 10); CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(ArayTmp.Length); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x0244, bytSubID, bytDevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(wdDeviceType)) == true) { byte[] arayRemark = new byte[20]; Array.Copy(CsConst.myRevBuf, 26, arayRemark, 0, 20); temp.Remark = HDLPF.Byte2String(arayRemark); CsConst.myRevBuf = new byte[1200]; HDLUDP.TimeBetwnNext(ArayTmp.Length); } else return false; myACSetting.Add(temp); } else return false; if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) CsConst.calculationWorker.ReportProgress(i, null); } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) CsConst.calculationWorker.ReportProgress(100, null); return true; }
private void showCoolMasterInfo() { try { isRead = true; dgvAC.Rows.Clear(); if (MyCoolMaster.myACSetting != null) { for (int i = 0; i < MyCoolMaster.myACSetting.Count; i++) { ThirdPartAC temp = MyCoolMaster.myACSetting[i]; string strEnable = CsConst.WholeTextsList[1775].sDisplayName; if (temp.Enable == 1) { strEnable = CsConst.mstrINIDefault.IniReadValue("public", "00042", ""); } bool[] arayBL1 = new bool[] { false, false, false, false }; bool[] arayBL2 = new bool[] { false, false, false, false }; if (temp.arayACinfo[0] > 0) { for (int j = 0; j < temp.arayACinfo[0]; j++) { if (j < 4) { if (1 <= temp.arayACinfo[1 + j] && temp.arayACinfo[1 + j] <= 4) { arayBL1[temp.arayACinfo[1 + j] - 1] = true; } } } } if (temp.arayACinfo[5] > 0) { for (int j = 0; j < temp.arayACinfo[5]; j++) { if (j < 4) { if (1 <= temp.arayACinfo[6 + j] && temp.arayACinfo[6 + j] <= 4) { arayBL2[temp.arayACinfo[6 + j] - 1] = true; } } } } object[] obj = new object[] { temp.ID.ToString(), temp.ACNO.ToString(), strEnable, temp.Remark, temp.CoolMasterAddress.ToString(), temp.GroupID.ToString(), arayBL1[0], arayBL1[1], arayBL1[2], arayBL1[3], arayBL2[0], arayBL2[1], arayBL2[2], arayBL2[3] }; dgvAC.Rows.Add(obj); } } } catch { } isRead = false; }
//<summary> //保存数据 //</summary> public void SaveDataToDB() { try { #region string strsql = string.Format("delete * from dbClassInfomation where DIndex={0}", DIndex); DataModule.ExecuteSQLDatabase(strsql); if (myACSetting != null) { for (int i = 0; i < myACSetting.Count; i++) { ThirdPartAC temp = myACSetting[i]; string strParam = temp.ID.ToString() + "-" + temp.Enable.ToString() + "-" + temp.ACNO.ToString() + "-" + temp.CoolMasterAddress.ToString() + "-" + temp.GroupID.ToString(); strsql = @"Insert into dbClassInfomation(DIndex,ClassID,ObjectID,SenNum,Remark,strParam1,byteAry1)" + " values(@DIndex,@ClassID,@ObjectID,@SenNum,@Remark,@strParam1,@byteAry1)"; OleDbConnection conn; conn = new OleDbConnection(DataModule.ConString + CsConst.mstrDefaultPath); //OleDbConnection conn = new OleDbConnection(DataModule.ConString + CsConst.mstrCurPath); conn.Open(); OleDbCommand cmd = new OleDbCommand(strsql, conn); ((OleDbParameter)cmd.Parameters.Add("@DIndex", OleDbType.Integer)).Value = DIndex; ((OleDbParameter)cmd.Parameters.Add("@ClassID", OleDbType.Integer)).Value = 0; ((OleDbParameter)cmd.Parameters.Add("@ObjectID", OleDbType.Integer)).Value = 0; ((OleDbParameter)cmd.Parameters.Add("@SenNum", OleDbType.Integer)).Value = i; ((OleDbParameter)cmd.Parameters.Add("@Remark", OleDbType.VarChar)).Value = temp.Remark; ((OleDbParameter)cmd.Parameters.Add("@strParam1", OleDbType.VarChar)).Value = strParam; ((OleDbParameter)cmd.Parameters.Add("@byteAry1", OleDbType.Binary)).Value = temp.arayACinfo; try { cmd.ExecuteNonQuery(); } catch { conn.Close(); } conn.Close(); } } #endregion } catch { } }
public bool DownLoadInfoFrmDeviceNetVersion(string DevNam, int wdDeviceType, int intActivePage, int num1, int num2) { string strMainRemark = DevNam.Split('\\')[1].Trim(); DevNam = DevNam.Split('\\')[0].Trim(); byte bytSubID = byte.Parse(DevNam.Split('-')[0].ToString()); byte bytDevID = byte.Parse(DevNam.Split('-')[1].ToString()); byte[] ArayTmp = null; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x000E, bytSubID, bytDevID, false, true, true, false) == false) { return(false); } else { byte[] arayRemark = new byte[20]; for (int intI = 0; intI < 20; intI++) { arayRemark[intI] = CsConst.myRevBuf[25 + intI]; } DeviceName = bytSubID.ToString() + "-" + bytDevID.ToString() + "\\" + HDLPF.Byte2String(arayRemark); CsConst.myRevBuf = new byte[1200]; } if (CsConst.isRestore) { num1 = 1; num2 = 64; } if (intActivePage == 0 || intActivePage == 1) { ArayTmp = new byte[1]; ArayTmp[0] = 0; if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1388, bytSubID, bytDevID, false, true, true, false) == true) { Enable = (CsConst.myRevBuf[26] == 1); strIP = CsConst.myRevBuf[27].ToString("D3") + "." + CsConst.myRevBuf[28].ToString("D3") + "." + CsConst.myRevBuf[29].ToString("D3") + "." + CsConst.myRevBuf[30].ToString("D3"); Port = CsConst.myRevBuf[31] * 256 + CsConst.myRevBuf[32]; } else { return(false); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(5, null); } myACSetting = new List <ThirdPartAC>(); for (int i = num1; i <= num2; i++) { ArayTmp = new byte[1]; ArayTmp[0] = Convert.ToByte(i); if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1388, bytSubID, bytDevID, false, true, true, false) == true) { ThirdPartAC temp = new ThirdPartAC(); temp.ID = Convert.ToByte(i); temp.Enable = CsConst.myRevBuf[26]; temp.ACNO = CsConst.myRevBuf[27]; temp.GroupID = CsConst.myRevBuf[28]; temp.arayACinfo = new byte[3]; Array.Copy(CsConst.myRevBuf, 29, temp.arayACinfo, 0, 3); myACSetting.Add(temp); } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(5 + i, null); } } } if (CsConst.calculationWorker != null && CsConst.calculationWorker.IsBusy) { CsConst.calculationWorker.ReportProgress(100, null); } return(true); }