private bool Set3GBox() { #region 3G相关 Tools.MBoxOperate.SetSecureGatewayAddress(txtSecureIP.Text.Trim()); Tools.MBoxOperate.SetDNSServer(txtDNS1.Text.Trim(), txtDNS2.Text.Trim()); #region PDS操作 List<DB_Talk.Model.m_PDS> lstPDS = new List<DB_Talk.Model.m_PDS>(); Tools.MBoxOperate.GetPDS(out lstPDS); foreach (DB_Talk.Model.m_PDS item in lstPDS)//先清空所有 { Tools.MBoxOperate.SetPDSDctive(item); Tools.MBoxOperate.DeletePDS(item); } DB_Talk.Model.m_PDS pds = new DB_Talk.Model.m_PDS(); pds.PdsID = 1; pds. vc_IP = txtPdsIP.Text.Trim(); bool b = Tools.MBoxOperate.CreatePDS(pds); Tools.MBoxOperate.SetPDSActive(pds); #endregion #endregion return true; }
/// <summary> /// 获得数据列表 /// </summary> public List<DB_Talk.Model.m_PDS> DataTableToList(DataSet ds) { List<DB_Talk.Model.m_PDS> modelList = new List<DB_Talk.Model.m_PDS>(); if (ds == null) return modelList; DataTable dt = ds.Tables[0]; int rowsCount = dt.Rows.Count; if (rowsCount > 0) { DB_Talk.Model.m_PDS model; for (int n = 0; n < rowsCount; n++) { model = new DB_Talk.Model.m_PDS(); if(dt.Rows[n]["ID"]!=null && dt.Rows[n]["ID"].ToString()!="") { model.ID=int.Parse(dt.Rows[n]["ID"].ToString()); } if(dt.Rows[n]["PdsID"]!=null && dt.Rows[n]["PdsID"].ToString()!="") { model.PdsID=int.Parse(dt.Rows[n]["PdsID"].ToString()); } if(dt.Rows[n]["BoxID"]!=null && dt.Rows[n]["BoxID"].ToString()!="") { model.BoxID=int.Parse(dt.Rows[n]["BoxID"].ToString()); } if(dt.Rows[n]["vc_IP"]!=null && dt.Rows[n]["vc_IP"].ToString()!="") { model.vc_IP= dt.Rows[n]["vc_IP"].ToString(); } if(dt.Rows[n]["i_ConfState"]!=null && dt.Rows[n]["i_ConfState"].ToString()!="") { model.i_ConfState=int.Parse(dt.Rows[n]["i_ConfState"].ToString()); } if(dt.Rows[n]["i_OperateState"]!=null && dt.Rows[n]["i_OperateState"].ToString()!="") { model.i_OperateState=int.Parse(dt.Rows[n]["i_OperateState"].ToString()); } if(dt.Rows[n]["i_IdleGtpChannelCount"]!=null && dt.Rows[n]["i_IdleGtpChannelCount"].ToString()!="") { model.i_IdleGtpChannelCount=int.Parse(dt.Rows[n]["i_IdleGtpChannelCount"].ToString()); } if(dt.Rows[n]["i_BusyGtpChannelCount"]!=null && dt.Rows[n]["i_BusyGtpChannelCount"].ToString()!="") { model.i_BusyGtpChannelCount=int.Parse(dt.Rows[n]["i_BusyGtpChannelCount"].ToString()); } if(dt.Rows[n]["i_IdleVideoChannelCount"]!=null && dt.Rows[n]["i_IdleVideoChannelCount"].ToString()!="") { model.i_IdleVideoChannelCount=int.Parse(dt.Rows[n]["i_IdleVideoChannelCount"].ToString()); } if(dt.Rows[n]["i_BusyVideoChannelCount"]!=null && dt.Rows[n]["i_BusyVideoChannelCount"].ToString()!="") { model.i_BusyVideoChannelCount=int.Parse(dt.Rows[n]["i_BusyVideoChannelCount"].ToString()); } if(dt.Rows[n]["vc_Memo"]!=null && dt.Rows[n]["vc_Memo"].ToString()!="") { model.vc_Memo= dt.Rows[n]["vc_Memo"].ToString(); } if(dt.Rows[n]["i_Flag"]!=null && dt.Rows[n]["i_Flag"].ToString()!="") { model.i_Flag=int.Parse(dt.Rows[n]["i_Flag"].ToString()); } modelList.Add(model); } } return modelList; }
//查询PDS public static bool GetPDS(out List<DB_Talk.Model.m_PDS> lstModel) { byte[] byteArray = new byte[ArraySizeBig]; int count = 0; bool b = MBoxSDK.ConfigSDK.MBOX_3G_GetPDS(Global.Params.BoxHandle, byteArray, (UInt32)byteArray.Length, ref count); lstModel = new List<DB_Talk.Model.m_PDS>(); if (b) { string str = System.Text.Encoding.Default.GetString(byteArray); str = str.Replace("\0", ""); string[] strArray = str.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < strArray.Length; i++) { string[] strArray2 = strArray[i].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); DB_Talk.Model.m_PDS m = new DB_Talk.Model.m_PDS(); m.PdsID = int.Parse(strArray2[0]); m.i_ConfState = int.Parse(strArray2[1]); m.vc_IP = strArray2[3]; m.i_OperateState = int.Parse(strArray2[2]); m.i_IdleGtpChannelCount = int.Parse(strArray2[4]); m.i_BusyGtpChannelCount = int.Parse(strArray2[5]); m.i_IdleVideoChannelCount = int.Parse(strArray2[6]); m.i_BusyVideoChannelCount = int.Parse(strArray2[7]); m.BoxID = Global.Params.BoxID; lstModel.Add(m); } } return b; }
/// <summary> /// 根据条件得到一个对象实体 /// </summary> public DB_Talk.Model.m_PDS GetModel(string strWhere) { StringBuilder strSql=new StringBuilder(); strSql.Append(" select top 1 "); strSql.Append(" ID, PdsID, BoxID, vc_IP, i_ConfState, i_OperateState, i_IdleGtpChannelCount, i_BusyGtpChannelCount, i_IdleVideoChannelCount, i_BusyVideoChannelCount, vc_Memo, i_Flag "); strSql.Append(" from m_PDS "); if(strWhere.Trim()!="") { strSql.Append(" where "+strWhere); } DB_Talk.Model.m_PDS model=new DB_Talk.Model.m_PDS(); DataSet ds=GetDataSet(strSql.ToString()); if(ds!=null && ds.Tables[0].Rows.Count>0) { model=DataTableToList(ds)[0]; return model; } else { return null; } }