//获取PRI中继 private Dictionary<DB_Talk.Model.m_PRIInterface, DB_Talk.Model.m_PRIInterface> GetLstPRIInterface() { Dictionary<DB_Talk.Model.m_PRIInterface, DB_Talk.Model.m_PRIInterface> dic = new Dictionary<DB_Talk.Model.m_PRIInterface, DB_Talk.Model.m_PRIInterface>(); List<DB_Talk.Model.m_PRIInterface> lst = new List<DB_Talk.Model.m_PRIInterface>(); for (int i = 0; i < this.dgvPRI.Rows.Count; i++) { DB_Talk.Model.m_PRIInterface model = new DB_Talk.Model.m_PRIInterface(); DB_Talk.Model.m_PRIInterface modelTag = dgvPRI.Rows[i].Tag as DB_Talk.Model.m_PRIInterface; if (modelTag != null) model.ID = modelTag.ID; //PRI索引 if (dgvPRI.Rows[i].Cells["colPRIID"].Value == null || dgvPRI.Rows[i].Cells["colPRIID"].Value.ToString() == "") throw new Exception("PRI编号不能为空!"); int num = 0; if (dgvPRI.Rows[i].Cells["colPRIID"].Value != null && int.TryParse(dgvPRI.Rows[i].Cells["colPRIID"].Value.ToString(), out num) && num > 0 && num <= 32) model.PRIID = num; else throw new Exception("PRI中继编号取值范围为1~32"); //实际是1-32 List<DB_Talk.Model.m_PRIInterface> lstTemp = new DB_Talk.BLL.m_PRIInterface().GetModelList( string.Format("i_Flag=0 and BoxID={0} and PRIID={1} ", Global.Params.BoxID, model.PRIID)); if (lstTemp.Count > 0 && model.ID != lstTemp[0].ID) throw new Exception("PRI中继编号【" + model.PRIID + "】已经存在"); #region 市话长途判断 bool sh = !(dgvPRI.Rows[i].Cells["colPriOutSub"].Value == null || dgvPRI.Rows[i].Cells["colPriOutSub"].Value.ToString() == ""); bool ct = !(dgvPRI.Rows[i].Cells["colPriOut"].Value == null || dgvPRI.Rows[i].Cells["colPriOut"].Value.ToString() == ""); if (sh == false && ct == false) { throw new Exception("市话出局号码前缀和长途出局号码前缀必须要填写一个!"); } if (sh == true) { ////市话出局引导码 //if (dgvPRI.Rows[i].Cells["colPriOutSub"].Value == null || dgvPRI.Rows[i].Cells["colPriOutSub"].Value.ToString() == "") // throw new Exception("市话出局号码前缀不能为空!"); string strOutLocal = dgvPRI.Rows[i].Cells["colPriOutSub"].Value.ToString(); string[] strArrayLocal = strOutLocal.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string str in strArrayLocal) { num = 0; if (!int.TryParse(str, out num)) throw new Exception("市话出局号码前缀格式错误!必须是以英文逗号隔开的数字!"); } model.vc_OutNumberLocal = strOutLocal; } if ( ct == true) { ////长途出局引导码 //if (dgvPRI.Rows[i].Cells["colPriOut"].Value == null || dgvPRI.Rows[i].Cells["colPriOut"].Value.ToString() == "") // throw new Exception("长途出局号码前缀不能为空!"); string strOut = dgvPRI.Rows[i].Cells["colPriOut"].Value.ToString(); string[] strArray = strOut.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string str in strArray) { num = 0; if (!int.TryParse(str, out num)) throw new Exception("长途出局号码前缀格式错误!必须是以英文逗号隔开的数字!"); } model.vc_OutNumber = strOut; } #endregion string mes = ""; if (model.vc_OutNumberLocal != null && model.vc_OutNumber != null) { if (Global.Methods.checkNumOutIsSame(model.vc_OutNumberLocal, model.vc_OutNumber, out mes)) { throw new Exception("市话与长途出局号码前缀有重复号码【" + mes + "】!"); } } //E1端口号 if (dgvPRI.Rows[i].Cells["colE1Number"].Value == null || dgvPRI.Rows[i].Cells["colE1Number"].Value.ToString() == "") throw new Exception("E1端口号不能为空!"); num = 0; if (dgvPRI.Rows[i].Cells["colE1Number"].Value != null && int.TryParse(dgvPRI.Rows[i].Cells["colE1Number"].Value.ToString(), out num) && num >= 1 && num <= E1Max) model.i_E1Port = num; else throw new Exception("E1端口号取值范围为1~" + E1Max); List<DB_Talk.Model.m_PRIInterface> lstTempE1 = new DB_Talk.BLL.m_PRIInterface().GetModelList( string.Format("i_Flag=0 and BoxID={0} and i_E1Port={1} ", Global.Params.BoxID, model.i_E1Port)); if (lstTempE1.Count > 0 && model.ID != lstTempE1[0].ID) throw new Exception("E1端口号【" + model.i_E1Port + "】已经存在"); //LinkID if (dgvPRI.Rows[i].Cells["colPriLinkID"].Value == null || dgvPRI.Rows[i].Cells["colPriLinkID"].Value.ToString() == "") throw new Exception("LinkID不能为空!"); num = 0; if (dgvPRI.Rows[i].Cells["colPriLinkID"].Value != null && int.TryParse(dgvPRI.Rows[i].Cells["colPriLinkID"].Value.ToString(), out num) && num >= 1 && num <= 16) model.i_LinkID = num; else throw new Exception("LinkID取值范围为1~16"); //交换机类型1: unknown(1) 2: avaya(2)3: nortel(3)4: alcatel(4) 5: siemens(5) 6: oulian(6)7: shenou(7) 8: utstarcom(8) 9: microxel(9) if (dgvPRI.Rows[i].Cells["colSwitchType"].Value.ToString() == "") throw new Exception("交换机类型不能为空"); model.i_SwitchType = dgvPRI.Rows[i].Cells["colSwitchType"].Value.ToString() == "Hitotek" ? 9 : 1; //用户侧:1,网络侧:2,默认1 if (dgvPRI.Rows[i].Cells["colUNIType"].Value.ToString() == "") throw new Exception("信令信道UNI类型不能为空"); model.i_UNIType = dgvPRI.Rows[i].Cells["colUNIType"].Value.ToString() == "用户侧" ? 1 : 2; model.i_Type = 2; //接口类型,内部(1),外部(2),默认外部 model.i_Level = 1; //优先级,主(1),从(2),默认主 model.i_LinkType = 1; //链路类型 E1(1),T1(2) model.i_State = 2; //激活 model.i_Operate = 1; //up(2)运行 down(1)停止 model.BoxID = Global.Params.BoxID; if (modelTag != null && modelTag.PRIID == model.PRIID && modelTag.vc_OutNumber == model.vc_OutNumber && modelTag.BoxID == model.BoxID && modelTag.i_E1Port == model.i_E1Port && modelTag.i_LinkID == model.i_LinkID && modelTag.i_SwitchType == model.i_SwitchType && modelTag.i_UNIType == model.i_UNIType) { modelTag = null; //没有变化,则什么都不做 continue; } lst.Add(model); dic.Add(model, modelTag); } return dic; }
/// <summary> /// 获得数据列表 /// </summary> public List<DB_Talk.Model.m_PRIInterface> DataTableToList(DataSet ds) { List<DB_Talk.Model.m_PRIInterface> modelList = new List<DB_Talk.Model.m_PRIInterface>(); if (ds == null) return modelList; DataTable dt = ds.Tables[0]; int rowsCount = dt.Rows.Count; if (rowsCount > 0) { DB_Talk.Model.m_PRIInterface model; for (int n = 0; n < rowsCount; n++) { model = new DB_Talk.Model.m_PRIInterface(); if(dt.Rows[n]["ID"]!=null && dt.Rows[n]["ID"].ToString()!="") { model.ID=int.Parse(dt.Rows[n]["ID"].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]["PRIID"]!=null && dt.Rows[n]["PRIID"].ToString()!="") { model.PRIID=int.Parse(dt.Rows[n]["PRIID"].ToString()); } if(dt.Rows[n]["vc_OutNumber"]!=null && dt.Rows[n]["vc_OutNumber"].ToString()!="") { model.vc_OutNumber= dt.Rows[n]["vc_OutNumber"].ToString(); } if(dt.Rows[n]["vc_OutNumberLocal"]!=null && dt.Rows[n]["vc_OutNumberLocal"].ToString()!="") { model.vc_OutNumberLocal= dt.Rows[n]["vc_OutNumberLocal"].ToString(); } if(dt.Rows[n]["vc_Code"]!=null && dt.Rows[n]["vc_Code"].ToString()!="") { model.vc_Code= dt.Rows[n]["vc_Code"].ToString(); } if(dt.Rows[n]["vc_Name"]!=null && dt.Rows[n]["vc_Name"].ToString()!="") { model.vc_Name= dt.Rows[n]["vc_Name"].ToString(); } if(dt.Rows[n]["RouteID"]!=null && dt.Rows[n]["RouteID"].ToString()!="") { model.RouteID=int.Parse(dt.Rows[n]["RouteID"].ToString()); } if(dt.Rows[n]["i_Type"]!=null && dt.Rows[n]["i_Type"].ToString()!="") { model.i_Type=int.Parse(dt.Rows[n]["i_Type"].ToString()); } if(dt.Rows[n]["i_Level"]!=null && dt.Rows[n]["i_Level"].ToString()!="") { model.i_Level=int.Parse(dt.Rows[n]["i_Level"].ToString()); } if(dt.Rows[n]["i_State"]!=null && dt.Rows[n]["i_State"].ToString()!="") { model.i_State=int.Parse(dt.Rows[n]["i_State"].ToString()); } if(dt.Rows[n]["i_Operate"]!=null && dt.Rows[n]["i_Operate"].ToString()!="") { model.i_Operate=int.Parse(dt.Rows[n]["i_Operate"].ToString()); } if(dt.Rows[n]["i_LinkID"]!=null && dt.Rows[n]["i_LinkID"].ToString()!="") { model.i_LinkID=int.Parse(dt.Rows[n]["i_LinkID"].ToString()); } if(dt.Rows[n]["i_LinkCount"]!=null && dt.Rows[n]["i_LinkCount"].ToString()!="") { model.i_LinkCount=int.Parse(dt.Rows[n]["i_LinkCount"].ToString()); } if(dt.Rows[n]["i_LinkType"]!=null && dt.Rows[n]["i_LinkType"].ToString()!="") { model.i_LinkType=int.Parse(dt.Rows[n]["i_LinkType"].ToString()); } if(dt.Rows[n]["i_SwitchType"]!=null && dt.Rows[n]["i_SwitchType"].ToString()!="") { model.i_SwitchType=int.Parse(dt.Rows[n]["i_SwitchType"].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_E1Port"]!=null && dt.Rows[n]["i_E1Port"].ToString()!="") { model.i_E1Port=int.Parse(dt.Rows[n]["i_E1Port"].ToString()); } if(dt.Rows[n]["i_UNIType"]!=null && dt.Rows[n]["i_UNIType"].ToString()!="") { model.i_UNIType=int.Parse(dt.Rows[n]["i_UNIType"].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; }
//获取PRI中继接口 public static bool GetPriTrunk(out List<DB_Talk.Model.m_PRIInterface> lst) { byte[] byteArray = new byte[ArraySizeBig]; int len = 0; bool b = MBoxSDK.ConfigSDK.MBOX_GetPriTrunk(Global.Params.BoxHandle, byteArray, (uint)byteArray.Length, ref len); lst = new List<DB_Talk.Model.m_PRIInterface>(); 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++) { DB_Talk.Model.m_PRIInterface m = new DB_Talk.Model.m_PRIInterface(); string[] strArray2 = strArray[i].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); m.PRIID = int.Parse(strArray2[0]); m.RouteID = int.Parse(strArray2[1]); m.i_Type = int.Parse(strArray2[2]); m.i_Level = int.Parse(strArray2[3]); m.i_LinkType = int.Parse(strArray2[4]); //链路类型 E1(1),T1(2) m.i_SwitchType = int.Parse(strArray2[5]); m.i_State = int.Parse(strArray2[6]); m.i_Operate = int.Parse(strArray2[7]); m.i_LinkCount = int.Parse(strArray2[8]); m.BoxID = Global.Params.BoxID; lst.Add(m); } } return b; }
/// <summary> /// 根据条件得到一个对象实体 /// </summary> public DB_Talk.Model.m_PRIInterface GetModel(string strWhere) { StringBuilder strSql=new StringBuilder(); strSql.Append(" select top 1 "); strSql.Append(" ID, BoxID, PRIID, vc_OutNumber, vc_OutNumberLocal, vc_Code, vc_Name, RouteID, i_Type, i_Level, i_State, i_Operate, i_LinkID, i_LinkCount, i_LinkType, i_SwitchType, vc_Memo, i_E1Port, i_UNIType, i_Flag "); strSql.Append(" from m_PRIInterface "); if(strWhere.Trim()!="") { strSql.Append(" where "+strWhere); } DB_Talk.Model.m_PRIInterface model=new DB_Talk.Model.m_PRIInterface(); DataSet ds=GetDataSet(strSql.ToString()); if(ds!=null && ds.Tables[0].Rows.Count>0) { model=DataTableToList(ds)[0]; return model; } else { return null; } }