예제 #1
0
        //删除中继
        public static bool DeletePRI(DB_Talk.Model.m_PRIInterface model)
        {
            //去激活PRI中继
            if (!SetPRITrunkDective(model))
            {
                CommControl.Tools.WriteLog.AppendErrorLog("去激活PRI失败");
                return false;
            }

            //删除信令信道
            DB_Talk.Model.m_PRISigLink PRISigLinkModel = new DB_Talk.Model.m_PRISigLink();
            PRISigLinkModel.PRIID = model.PRIID;
            if (!DeleteAllSigChannel(PRISigLinkModel.PRIID))
            {
                CommControl.Tools.WriteLog.AppendErrorLog("删除信令信道失败");
                return false;
            }


            //删除承载信道
            if (!DeleteT1Channel(model.PRIID))
            {
                CommControl.Tools.WriteLog.AppendErrorLog("删除承载信道失败");
                return false;
            }

            //删除中继
            if (!DeletePriTrunkByID(model))
            {
                CommControl.Tools.WriteLog.AppendErrorLog("删除PRI失败");
                return false;
            }

            //删除路由规则0,PRIID,PRIID
            DB_Talk.Model.m_RouteRule modelRRule = new DB_Talk.Model.m_RouteRule();
            modelRRule.OriRouteID = 0;
            modelRRule.DestRouteID = model.RouteID;
            modelRRule.ID = model.RouteID;
            modelRRule.BoxID = Global.Params.BoxID;
            if (!DeleteRoutingRule(modelRRule))
            {
                CommControl.Tools.WriteLog.AppendErrorLog("删除路由规则失败");
                return false;
            }
           

            //删除路由
            DB_Talk.Model.m_Route mR = new DB_Talk.Model.m_Route();
            mR.ID = model.RouteID;
            mR.vc_Name = "PRI" + model.PRIID.ToString();
            mR.RouteGroupID = model.RouteID;
            mR.i_RouteType = 1; //1: btw(1)双向(默认)
            if (!DeleteRoute(mR))
                return false;

            //删除路由组
            DB_Talk.Model.m_RouteGroup mRg = new DB_Talk.Model.m_RouteGroup();
            mRg.vc_Name = "PRI" + model.PRIID.ToString();
            mRg.ID = model.RouteID;
            if (!DeleteRouteGroup(mRg))
            {
                return false;
            }
          
            //删除呼叫规则

            return true;
        }
예제 #2
0
        //创建中继
        public static bool createPRI(DB_Talk.Model.m_PRIInterface newmodel, List<DB_Talk.Model.m_CalledRule> lstRuleAdd, List<DB_Talk.Model.m_CalledRule> lstRuleDelete)
        {
            //创建路由组
            DB_Talk.Model.m_RouteGroup mRg = new DB_Talk.Model.m_RouteGroup();
            mRg.vc_Name = "PRI" + newmodel.PRIID.ToString();
            int routeGroupID = 0;
            if (!CreateRouteGroup(mRg, out routeGroupID))
            {
                CommControl.Tools.WriteLog.AppendErrorLog("添加PRI路由组失败");
                return false;
            }
            newmodel.RouteID = routeGroupID;
            //创建路由
            DB_Talk.Model.m_Route mR = new DB_Talk.Model.m_Route();
            mR.ID = routeGroupID;
            mR.RouteGroupID = routeGroupID;
            mR.vc_Name = "PRI" + newmodel.PRIID.ToString();
            mR.i_RouteType = MBoxSDK.ConfigSDK.EnumRouteType.btw.GetHashCode();
            if (!CreateRoute(mR))
            {
                CommControl.Tools.WriteLog.AppendErrorLog("添加PRI路由失败");
                return false;
            }

            //创建路由规则0,PRIID,PRIID
            DB_Talk.Model.m_RouteRule modelRRule = new DB_Talk.Model.m_RouteRule();
            modelRRule.OriRouteID = 0;
            modelRRule.DestRouteID = newmodel.RouteID;
            modelRRule.ID = newmodel.RouteID;
            modelRRule.BoxID = Global.Params.BoxID;
            if (!CreateRoutingRule(modelRRule))
            {
                CommControl.Tools.WriteLog.AppendErrorLog("添加路由规则失败");
                return false;
            }
            

            //创建PRI中继
            if (!CreatePriTrunk(newmodel))
            {
                CommControl.Tools.WriteLog.AppendErrorLog("添加PRI失败");
                return false;
            }
            //创建承载新道
            DB_Talk.Model.m_PRIChannel PRIChannelModel = new DB_Talk.Model.m_PRIChannel();
            PRIChannelModel.i_E1Port = newmodel.i_E1Port;
            PRIChannelModel.i_LinkID = newmodel.i_LinkID;
            PRIChannelModel.PRIID = newmodel.PRIID;
            if (!CreateT1Channel(PRIChannelModel))
            {
                CommControl.Tools.WriteLog.AppendErrorLog("添加承载信道失败");
                return false;
            }

            //创建信令新道

            DB_Talk.Model.m_PRISigLink PRISigLinkModel = new DB_Talk.Model.m_PRISigLink();
            PRISigLinkModel.i_E1Port = newmodel.i_E1Port;
            PRISigLinkModel.i_LinkID = newmodel.i_LinkID;
            PRISigLinkModel.PRIID = newmodel.PRIID;
            PRISigLinkModel.i_UNIType = newmodel.i_UNIType;
            if (!CreateSigChannel(PRISigLinkModel))
            {
                CommControl.Tools.WriteLog.AppendErrorLog("添加信令信道失败");
                return false;
            }

            //激活PRI中继
            if (!SetPRITrunkActive(newmodel))
            {
                CommControl.Tools.WriteLog.AppendErrorLog("激活PRI失败");
                return false;
            }

            //添加被叫规则
            foreach (DB_Talk.Model.m_CalledRule d in lstRuleAdd)
            {
                d.DestRouteID = routeGroupID;
                if (!CreateCall_OutRule(d))
                {
                    CommControl.Tools.WriteLog.AppendErrorLog("添加被叫规则失败,被叫号码为:" + d.vc_CalledNumber);
                    DeletePRI(newmodel);
                    return false;
                }
            }
            if (!Delete_Rule(lstRuleAdd, lstRuleDelete))
                return false;


            return true;

        }
예제 #3
0
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<DB_Talk.Model.m_PRISigLink> DataTableToList(DataSet ds)
		{
			List<DB_Talk.Model.m_PRISigLink> modelList = new List<DB_Talk.Model.m_PRISigLink>();
			if (ds == null) return modelList;
            DataTable dt = ds.Tables[0];
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				DB_Talk.Model.m_PRISigLink model;
				for (int n = 0; n < rowsCount; n++)
				{
				  model = new DB_Talk.Model.m_PRISigLink();	
                  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]["i_MachineID"]!=null && dt.Rows[n]["i_MachineID"].ToString()!="")
				  {
				      model.i_MachineID=int.Parse(dt.Rows[n]["i_MachineID"].ToString());
				  }
				  if(dt.Rows[n]["i_SlotID"]!=null && dt.Rows[n]["i_SlotID"].ToString()!="")
				  {
				      model.i_SlotID=int.Parse(dt.Rows[n]["i_SlotID"].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_ChannelNumber"]!=null && dt.Rows[n]["i_ChannelNumber"].ToString()!="")
				  {
				      model.i_ChannelNumber=int.Parse(dt.Rows[n]["i_ChannelNumber"].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_LinkID"]!=null && dt.Rows[n]["i_LinkID"].ToString()!="")
				  {
				      model.i_LinkID=int.Parse(dt.Rows[n]["i_LinkID"].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_OppositeVoicePrompt"]!=null && dt.Rows[n]["i_OppositeVoicePrompt"].ToString()!="")
				  {
				      model.i_OppositeVoicePrompt=int.Parse(dt.Rows[n]["i_OppositeVoicePrompt"].ToString());
				  }
				  if(dt.Rows[n]["i_SendVoicePrompt"]!=null && dt.Rows[n]["i_SendVoicePrompt"].ToString()!="")
				  {
				      model.i_SendVoicePrompt=int.Parse(dt.Rows[n]["i_SendVoicePrompt"].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;
		}
예제 #4
0
        //获取PRI信令信道
        private static bool GetSigChannel(out List<DB_Talk.Model.m_PRISigLink> lst)
        {
            byte[] byteArray = new byte[ArraySizeBig];
            int len = 0;
            bool b = MBoxSDK.ConfigSDK.MBOX_GetSigChannel(Global.Params.BoxHandle, byteArray, (uint)byteArray.Length, ref len);
            lst = new List<DB_Talk.Model.m_PRISigLink>();
            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_PRISigLink m = new DB_Talk.Model.m_PRISigLink();
                    string[] strArray2 = strArray[i].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    //"Sig信道描述文本,端口类型,网络侧(用户侧),对端提供语音提示,发送语音提示,LINKID;"
                    string[] strArray3 = strArray2[0].Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
                    m.i_MachineID = int.Parse(strArray3[0]);
                    m.i_SlotID = int.Parse(strArray3[1]);
                    m.i_E1Port = int.Parse(strArray3[2]);
                    m.i_ChannelNumber = int.Parse(strArray3[3]);


                    m.PRIID = int.Parse(strArray2[1]);
                    m.i_UNIType = int.Parse(strArray2[2]);
                    m.i_OppositeVoicePrompt = int.Parse(strArray2[3]);
                    m.i_SendVoicePrompt = int.Parse(strArray2[4]);
                    m.i_LinkID = int.Parse(strArray2[5]);
                    m.BoxID = Global.Params.BoxID;
                    lst.Add(m);

                }
            }
            return b;
        }
예제 #5
0
		/// <summary>
		/// 根据条件得到一个对象实体
		/// </summary>
		public DB_Talk.Model.m_PRISigLink GetModel(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("  select top 1 ");
			strSql.Append("  ID, BoxID, PRIID, i_MachineID, i_SlotID, i_E1Port, i_ChannelNumber, i_Type, i_LinkID, i_UNIType, i_OppositeVoicePrompt, i_SendVoicePrompt, vc_Memo, i_Flag  ");			
			strSql.Append("  from m_PRISigLink ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			DB_Talk.Model.m_PRISigLink model=new DB_Talk.Model.m_PRISigLink();
			DataSet ds=GetDataSet(strSql.ToString());
			if(ds!=null && ds.Tables[0].Rows.Count>0)
			{
                model=DataTableToList(ds)[0];						
				return model;
			}
			else
			{
				return null;
			}
		}