Пример #1
0
        //获取SIP中继
        private Dictionary<DB_Talk.Model.m_SIPInterface, DB_Talk.Model.m_SIPInterface> GetLstSIPInterface()
        {
         
            List<DB_Talk.Model.m_SIPInterface> lst = new List<DB_Talk.Model.m_SIPInterface>();

            Dictionary<DB_Talk.Model.m_SIPInterface, DB_Talk.Model.m_SIPInterface> dic = new Dictionary<DB_Talk.Model.m_SIPInterface, DB_Talk.Model.m_SIPInterface>();

            for (int i = 0; i < this.dgvSIP.Rows.Count; i++)
            {
                DB_Talk.Model.m_SIPInterface model = new DB_Talk.Model.m_SIPInterface();
                DB_Talk.Model.m_SIPInterface modelTag = dgvSIP.Rows[i].Tag as DB_Talk.Model.m_SIPInterface;
                if (modelTag != null)
                    model.ID = modelTag.ID;
                //SIP中继索引
                if (dgvSIP.Rows[i].Cells["colSIPID"].Value == null || dgvSIP.Rows[i].Cells["colSIPID"].Value.ToString() == "")
                    throw new Exception("SIP编号不能为空!");
                int num = 0;
                if (dgvSIP.Rows[i].Cells["colSIPID"].Value != null && int.TryParse(dgvSIP.Rows[i].Cells["colSIPID"].Value.ToString(), out num) && num > 0 && num <= 10)
                    model.SIPID = num;
                else
                    throw new Exception("SIP中继编号取值范围为1~10");  //实际是1-32,但是SAP索引是1-10

                List<DB_Talk.Model.m_SIPInterface> lstTemp = new DB_Talk.BLL.m_SIPInterface().GetModelList(
                    string.Format("i_Flag=0 and BoxID={0} and SIPID={1} ", Global.Params.BoxID, model.SIPID));
                if (lstTemp.Count > 0 && model.ID != lstTemp[0].ID)
                    throw new Exception("SIP中继编号【" + model.SIPID + "】已经存在");

                #region 市话长途判断
                bool sh=!(dgvSIP.Rows[i].Cells["colSIPOutSub"].Value == null || dgvSIP.Rows[i].Cells["colSIPOutSub"].Value.ToString() == "");
                bool ct = !(dgvSIP.Rows[i].Cells["colSIPOut"].Value == null || dgvSIP.Rows[i].Cells["colSIPOut"].Value.ToString() == "");

                if (sh == false && ct == false)
                {
                    throw new Exception("市话出局号码前缀和长途出局号码前缀必须要填写一个!");
                }
                if(sh==true )
                {
                    //市话出局引导码
                    //if (sh == false && ct == true)
                    //    throw new Exception("市话出局号码前缀不能为空!");
                    string strOutLocal = dgvSIP.Rows[i].Cells["colSIPOutSub"].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 (dgvSIP.Rows[i].Cells["colSIPOut"].Value == null || dgvSIP.Rows[i].Cells["colSIPOut"].Value.ToString() == "")
                    //    throw new Exception("长途出局号码前缀不能为空!");
                    string strOut = dgvSIP.Rows[i].Cells["colSIPOut"].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 + "】!");
                    }
                }
                model.i_Type = 2;         //接口类型,内部(1),外部(2),默认外部
                //model.RouteID = num;      //1~255
                model.i_Level = 1;        //优先级,主(1),从(2),默认主
                model.SAPID = model.SIPID + 1;    //SAP索引取值范围1-10
                model.i_MaxChannel = 128; //最大通道(1~128)
                
                //本端端口号
                if (dgvSIP.Rows[i].Cells["colSIPPort"].Value == null || dgvSIP.Rows[i].Cells["colSIPPort"].Value.ToString() == "")
                    throw new Exception("本机端口号不能为空!");
                num = 0;
                if (dgvSIP.Rows[i].Cells["colSIPPort"].Value != null && int.TryParse(dgvSIP.Rows[i].Cells["colSIPPort"].Value.ToString(), out num) && num >= 1025 && num <= 9999 && num!=5060)
                    model.i_Port = num;  // 5062;
                else
                    throw new Exception("本端端口号取值范围为1025~9999,并且不能为5060");
               
                //对端IP
                if (dgvSIP.Rows[i].Cells["colSIPIP"].Value == null || dgvSIP.Rows[i].Cells["colSIPIP"].Value.ToString() == "")
                    throw new Exception("对端IP不能为空!");
                model.vc_OppositeIP = dgvSIP.Rows[i].Cells["colSIPIP"].Value.ToString(); // "192.168.1.239";
                if (!Global.Methods.checkIP(model.vc_OppositeIP))
                    throw new Exception("对端IP地址不合法!");

                List<DB_Talk.Model.m_SIPInterface> lstIP = new DB_Talk.BLL.m_SIPInterface().GetModelList(
                  string.Format("i_Flag=0 and BoxID={0} and vc_OppositeIP='{1}' ", Global.Params.BoxID, model.vc_OppositeIP));
                if (lstIP.Count > 0 && model.vc_OppositeIP != lstIP[0].vc_OppositeIP)
                    throw new Exception("对端IP【" + model.vc_OppositeIP + "】已经存在");
                //对端端口号
                if (dgvSIP.Rows[i].Cells["colSIPPort2"].Value == null || dgvSIP.Rows[i].Cells["colSIPPort2"].Value.ToString() == "")
                    throw new Exception("对端端口号不能为空!");
                num = 0;
                if (dgvSIP.Rows[i].Cells["colSIPPort2"].Value != null && int.TryParse(dgvSIP.Rows[i].Cells["colSIPPort2"].Value.ToString(), out num) && num >= 1025 && num <= 9999 )
                    model.i_OppositePort = num;
                else
                    throw new Exception("对端端口号本端端口号取值范围为1025~9999");
                
                //是否放音
                if (dgvSIP.Rows[i].Cells["colSIPIsPlay"].Value.ToString() == "")
                    throw new Exception("未选择是否放音");
                model.i_PlaySound = dgvSIP.Rows[i].Cells["colSIPIsPlay"].Value.ToString() == "是" ? 1 : 2; // 1;  //是否放音,是(1),否(2),默认1
               
                model.i_State = 2;  //激活
                model.i_OperateState = 1; //up(2)运行 down(1)停止

                model.BoxID = Global.Params.BoxID;

                if (modelTag != null &&
                    modelTag.SIPID == model.SIPID &&
                    modelTag.SAPID == model.SAPID &&
                    modelTag.BoxID == model.BoxID &&
                    modelTag.i_Port == model.i_Port &&
                    modelTag.vc_OutNumber == model.vc_OutNumber &&
                    modelTag.vc_OutNumberLocal == model.vc_OutNumberLocal &&
                    //modelTag.RouteID == model.RouteID &&
                    modelTag.vc_OppositeIP == model.vc_OppositeIP &&
                    modelTag.i_PlaySound == model.i_PlaySound &&
                    modelTag.i_OppositePort == model.i_OppositePort)
                {
                    modelTag = null;  //没有变化,则什么都不做
                    continue;
                }
                else
                    model.vc_Memo = "修改";
                lst.Add(model);


                dic.Add(model, modelTag);
            }
            return dic;
        }
Пример #2
0
        private void Loaddata(int dgvNum) //0全部加载,1只刷新SIP,2只刷新PRI
        {
            if (dgvNum == 0 || dgvNum == 1)  
            {
                List<DB_Talk.Model.m_SIPInterface> lstSip = new List<DB_Talk.Model.m_SIPInterface>();
                string strWhere = string.Format("i_Flag=0 and BoxID='{0}' order by SIPID", Global.Params.BoxID);
                lstSip = new DB_Talk.BLL.m_SIPInterface().GetModelList(strWhere);
                dgvSIP.Rows.Clear();
                Global.Params.frmMain.getStateSipPri.lstPreSip = lstSip;
                //获取sip状态
                //GetSipState(ref lstSip);
                for (int i = 0; i < lstSip.Count; i++)
                {
                    dgvSIP.Rows[dgvSIP.Rows.Add(lstSip[i].ID,
                                     lstSip[i].SIPID,
                                     lstSip[i].vc_OutNumberLocal,
                                     lstSip[i].vc_OutNumber,
                                     lstSip[i].i_Port,
                                     lstSip[i].vc_OppositeIP,
                                     lstSip[i].i_OppositePort,
                                     lstSip[i].i_PlaySound == 1 ? "是" : "否",  // //是否放音,是(1),否(2),默认1
                                     lstSip[i].i_State == 2 ? "激活" : "未激活",        //unconfigured(0) 2: deactive(1) 3: active(2) 4: deactivePending(3)
                                     lstSip[i].i_OperateState == 2 ? "运行" : "停止"  //up(2) down(1)
                                    )].Tag = lstSip[i];
                    dgvSIP.Rows[i].ReadOnly = true;

                }
                dgvSIP.ClearSelection();

            }
            if (dgvNum == 0 || dgvNum == 2)
            {
                List<DB_Talk.Model.m_PRIInterface> lstPri = new List<DB_Talk.Model.m_PRIInterface>();
                string strWherePri = string.Format("i_Flag=0 and BoxID='{0}' order by PRIID", Global.Params.BoxID);
                lstPri = new DB_Talk.BLL.m_PRIInterface().GetModelList(strWherePri);
                dgvPRI.Rows.Clear();
                Global.Params.frmMain.getStateSipPri.lstPrePri = lstPri;
                //获取pri状态
                //GetPriState(ref lstPri);
                for (int i = 0; i < lstPri.Count; i++)
                {

                    dgvPRI.Rows[dgvPRI.Rows.Add(lstPri[i].ID,
                                     lstPri[i].PRIID,
                                     lstPri[i].vc_OutNumberLocal,
                                     lstPri[i].vc_OutNumber,
                                     lstPri[i].i_E1Port,
                                     lstPri[i].i_LinkID,
                                     lstPri[i].i_SwitchType == 9 ? "Hitotek" : "其他",    //交换机类型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)
                                     lstPri[i].i_UNIType == 1 ? "用户侧" : "网络侧",  // 信令信道UNI类型 //用户侧:1,网络侧:2,默认1
                                     lstPri[i].i_State == 2 ? "激活" : "未激活",        //unconfigured(0) 2: deactive(1) 3: active(2) 4: deactivePending(3)
                                     lstPri[i].i_Operate == 2 ? "运行" : "停止"    //up(2)运行 down(1)停止
                                    )].Tag = lstPri[i];
                   
                    dgvPRI.Rows[i].ReadOnly = true;
                }
                dgvPRI.ClearSelection();
            }
        }
Пример #3
0
        //同步数据库数据 PRI SIP中继
        public static void UpdateDBSIPPRI()
        {
            try
            {
                //CommControl.Tools.WriteLog.AppendLog("同步SipPri ,boxID:" + Global.Params.BoxID.ToString());
                //同步路由组信息
                List<DB_Talk.Model.m_RouteGroup> lstRGroup = new List<DB_Talk.Model.m_RouteGroup>();
                QueryRouteGroup(out lstRGroup);
                new DB_Talk.BLL.m_RouteGroup().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));
                foreach (DB_Talk.Model.m_RouteGroup m in lstRGroup)
                {
                    new DB_Talk.BLL.m_RouteGroup().Add(m);
                }
                //同步路由
                List<DB_Talk.Model.m_Route> lstRoute = new List<DB_Talk.Model.m_Route>();
                QueryRoute(out lstRoute);
                new DB_Talk.BLL.m_Route().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));
                foreach (DB_Talk.Model.m_Route m in lstRoute)
                {
                    new DB_Talk.BLL.m_Route().Add(m);
                }

                //同步SAP接入点
                List<DB_Talk.Model.m_SAPPoint> lstSAPPoint = new List<DB_Talk.Model.m_SAPPoint>();
                GetSipSap(out lstSAPPoint);
                new DB_Talk.BLL.m_SAPPoint().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));
                foreach (DB_Talk.Model.m_SAPPoint m in lstSAPPoint)
                {
                    new DB_Talk.BLL.m_SAPPoint().Add(m);
                }

                //同步被叫规则
                UpdateDB_CallRule();

                //同步SIP中继
                List<DB_Talk.Model.m_SIPInterface> lstSIPInterface = new List<DB_Talk.Model.m_SIPInterface>();
                GetSipTrunk(out lstSIPInterface);
                if (lstSIPInterface.Count == 0)
                    new DB_Talk.BLL.m_SIPInterface().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));


                foreach (DB_Talk.Model.m_SIPInterface m in lstSIPInterface)
                {
                    //m.vc_OutNumber = getCalledNumbers(MBoxSDK.ConfigSDK.CALLED_RULE_TYPE.出局, " and i_SIPID='" + m.SIPID + "'");
                    DB_Talk.Model.m_SIPInterface sip = new DB_Talk.BLL.m_SIPInterface().GetModel(
                                  string.Format("i_Flag=0 and BoxID={0} and SIPID='{1}'", Global.Params.BoxID, m.SIPID));
                    if (sip != null)
                    {
                        m.vc_OutNumber = sip.vc_OutNumber;
                        m.vc_OutNumberLocal = sip.vc_OutNumberLocal;
                        m.i_Port = sip.i_Port;
                      //  m.i_OperateState = sip.i_OperateState;
                     //   m.i_State = sip.i_State;

                        new DB_Talk.BLL.m_SIPInterface().Delete(string.Format("i_Flag=0 and BoxID={0} and SIPID='{1}'", Global.Params.BoxID, m.SIPID));
                        new DB_Talk.BLL.m_SIPInterface().Add(m);
                    }
                    else
                        DeleteSIP(m);
                }
                /*
                //同步承载信道
                List<DB_Talk.Model.m_PRIChannel> lstPRIChannel = new List<DB_Talk.Model.m_PRIChannel>();
                GetT1Channels(out lstPRIChannel);
                new DB_Talk.BLL.m_SAPPoint().Delete("");
                foreach (DB_Talk.Model.m_PRIChannel m in lstPRIChannel)
                {
                    new DB_Talk.BLL.m_PRIChannel().Add(m);
                }

                //同步信令信道
                List<DB_Talk.Model.m_PRISigLink> lstPRISigLink = new List<DB_Talk.Model.m_PRISigLink>();
                GetSigChannel(out lstPRISigLink);
                new DB_Talk.BLL.m_PRISigLink().Delete("");
                foreach (DB_Talk.Model.m_PRISigLink m in lstPRISigLink)
                {
                    new DB_Talk.BLL.m_PRISigLink().Add(m);
                }
                */
                //同步PRI中继
                List<DB_Talk.Model.m_PRIInterface> lstPRIInterface = new List<DB_Talk.Model.m_PRIInterface>();
                GetPriTrunk(out lstPRIInterface);
                if (lstPRIInterface.Count == 0)
                    new DB_Talk.BLL.m_PRIInterface().Delete(string.Format(" BoxID='{0}'", Global.Params.BoxID));
                foreach (DB_Talk.Model.m_PRIInterface m in lstPRIInterface)
                {
                    //m.vc_OutNumber = getCalledNumbers(MBoxSDK.ConfigSDK.CALLED_RULE_TYPE.出局, " and i_SIPID='" + m.SIPID + "'");
                    DB_Talk.Model.m_PRIInterface pri = new DB_Talk.BLL.m_PRIInterface().GetModel(
                                  string.Format("i_Flag=0 and BoxID={0} and PRIID='{1}'", Global.Params.BoxID, m.PRIID));
                    if (pri != null)
                    {
                        m.vc_OutNumber = pri.vc_OutNumber;
                        m.vc_OutNumberLocal = pri.vc_OutNumberLocal;
                        m.i_E1Port = pri.i_E1Port;
                        m.i_LinkID = pri.i_LinkID;
                        m.i_UNIType = pri.i_UNIType;
                      //  m.i_Operate = pri.i_Operate;
                      //  m.i_State = pri.i_State;
                        new DB_Talk.BLL.m_PRIInterface().Delete(string.Format("i_Flag=0 and BoxID={0} and PRIID='{1}'", Global.Params.BoxID, m.PRIID));
                        new DB_Talk.BLL.m_PRIInterface().Add(m);
                    }
                    else
                        DeletePRI(m);
                }

            }
            catch (Exception ex)
            {
                CommControl.Tools.WriteLog.AppendErrorLog(ex);
            }
            

        }
        private void btnDel_Click(object sender, EventArgs e)
        {
            if (dgvList.CurrentRow != null)
            {
                bool delete = false;
                Bestway.Windows.Forms.ProgressBarDialog procDlg = new Bestway.Windows.Forms.ProgressBarDialog();
                try
                {
                    DB_Talk.Model.m_CalledRule model = dgvList.CurrentRow.Tag as DB_Talk.Model.m_CalledRule;
                    if (model != null)
                    {
                        CheckDeleteCondition(model);
                        List<DB_Talk.Model.m_Member> lstMember=new DB_Talk.BLL.m_Member().GetModelList(
                           string.Format(" i_Flag=0 and i_Number like '{0}%' and BoxID='{1}' ", model.vc_CalledNumber, Global.Params.BoxID));
                          // string.Format(" i_Flag=0 and i_Number like '{0}%' and BoxID='{1}' and i_IsDispatch!=1", model.vc_CalledNumber, Global.Params.BoxID));

                        if (lstMember.Count > 0)
                        {
                            CommControl.MessageBoxEx.MessageBoxEx.Show("用户号码中引用了此呼叫规则,不允许删除,要想删除,请先删除用户号码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }

                        procDlg.Show(Bestway.Windows.Forms.EnumDisplayType.LoadData, "      正在删除被叫规则【" + model.vc_CalledNumber + "】,请稍等...");
                        List<DB_Talk.Model.m_CalledRule> lstAdd = new List<DB_Talk.Model.m_CalledRule>();
                        List<DB_Talk.Model.m_CalledRule> lstDelete = new List<DB_Talk.Model.m_CalledRule>();
                        lstDelete.Add(model);
                        DB_Talk.Model.m_SIPInterface modelSip = null;
                        DB_Talk.Model.m_PRIInterface modelPri = null;

                        if (model.i_SIPID > 0)
                            modelSip = new DB_Talk.BLL.m_SIPInterface().GetModel(
                                 string.Format(" i_Flag=0 and SIPID='{0}' and BoxID='{1}'", model.i_SIPID, Global.Params.BoxID));
                        if (modelSip != null)
                        {
                            List<DB_Talk.Model.m_CalledRule> lstm = new DB_Talk.BLL.m_CalledRule().GetModelList(
                               string.Format(" i_Flag=0 and i_SIPID='{0}' and BoxID='{1}' and ID!='{2}'",
                               model.i_SIPID, Global.Params.BoxID, model.ID));
                            if (lstm.Count > 0)  //只删除呼叫规则(还存在引用此中继的呼叫规则)
                            {
                                if (Tools.MBoxOperate.Delete_Rule(lstAdd, lstDelete))
                                {
                                    delete = true;
                                    if (model.i_CalledSubType == MBoxSDK.ConfigSDK.CALLED_SUB_RULE_TYPE.市话.GetHashCode())
                                    {
                                        modelSip.vc_OutNumberLocal = modelSip.vc_OutNumberLocal.Replace(model.vc_CalledNumber, "").Replace(",,",",").Trim(','); ;
                                    }
                                    else if (model.i_CalledSubType == MBoxSDK.ConfigSDK.CALLED_SUB_RULE_TYPE.长途.GetHashCode())
                                    {
                                        modelSip.vc_OutNumber = modelSip.vc_OutNumber.Replace(model.vc_CalledNumber, "").Replace(",,", ",").Trim(','); ;
                                    }
                                     new DB_Talk.BLL.m_SIPInterface().Update(modelSip);
                                }
                            }
                            else  //连中继一起删除
                            {
                                if (Tools.MBoxOperate.DeleteSIP(modelSip, lstAdd, lstDelete) && new DB_Talk.BLL.m_SIPInterface().Delete(modelSip.ID))
                                {
                                    delete = true;
                                }
                            }
                        }

                        if (model.i_PRIID > 0)
                            modelPri = new DB_Talk.BLL.m_PRIInterface().GetModel(
                                 string.Format(" i_Flag=0 and PRIID='{0}' and BoxID='{1}'", model.i_PRIID, Global.Params.BoxID));

                        if (modelPri != null)
                        {
                            List<DB_Talk.Model.m_CalledRule> lstm = new DB_Talk.BLL.m_CalledRule().GetModelList(
                                string.Format(" i_Flag=0 and i_PRIID='{0}' and BoxID='{1}' and ID!='{2}'",
                                model.i_PRIID, Global.Params.BoxID, model.ID));
                            if (lstm.Count > 0 && Tools.MBoxOperate.Delete_Rule(lstAdd, lstDelete))  //只删除呼叫规则
                            {
                                if (model.i_CalledSubType == MBoxSDK.ConfigSDK.CALLED_SUB_RULE_TYPE.市话.GetHashCode())
                                {
                                    //modelPri.vc_OutNumberLocal = modelPri.vc_OutNumberLocal.Replace(model.vc_CalledNumber, "").Replace(",,", ",").Trim(',');
                                    modelPri.vc_OutNumberLocal = ReplaceString(modelPri.vc_OutNumberLocal, model.vc_CalledNumber);
                                }
                                else if (model.i_CalledSubType == MBoxSDK.ConfigSDK.CALLED_SUB_RULE_TYPE.长途.GetHashCode())
                                {
                                   // modelPri.vc_OutNumber = modelPri.vc_OutNumber.Replace(model.vc_CalledNumber, "").Replace(",,", ",").Trim(',');
                                    modelPri.vc_OutNumber = ReplaceString(modelPri.vc_OutNumber, model.vc_CalledNumber);
                                }
                                 new DB_Talk.BLL.m_PRIInterface().Update(modelPri);
                                delete = true;
                            }
                            else  //连中继一起删除
                            {
                                if (Tools.MBoxOperate.DeletePRI(modelPri, lstAdd, lstDelete) && new DB_Talk.BLL.m_PRIInterface().Delete(modelPri.ID))
                                {
                                    delete = true;
                                }
                            }
                        }

                        if (modelSip == null && modelPri == null)  //删除的入局规则
                        {

                            if (Tools.MBoxOperate.Delete_Rule(lstAdd, lstDelete))
                            {
                                DB_Talk.Model.m_Box BoxModel = new DB_Talk.BLL.m_Box().GetModel(Global.Params.BoxID);
                                if (BoxModel != null && BoxModel.vc_NumberHead!=null)  
                                {

                                    BoxModel.vc_NumberHead = BoxModel.vc_NumberHead.Replace(lstDelete[0].vc_CalledNumber, "").Replace(",,", ",").Trim(',');
                                    
                                    new DB_Talk.BLL.m_Box().Update(BoxModel);
                                }
                                delete = true;
                            }
                        }
                    }
                    else  //还未添加 直接删除
                        delete = true;


                    if (delete)
                    {
                        MBoxSDK.ConfigSDK.MBOX_SaveHaveDoneCfg(Global.Params.BoxHandle);
                        procDlg.Hide();
                        Loaddata();
                        //dgvList.Rows.Remove(dgvList.CurrentRow);
                        CommControl.MessageBoxEx.MessageBoxEx.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    }
                    else
                    {
                        procDlg.Hide();
                        CommControl.MessageBoxEx.MessageBoxEx.Show("删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    }
                }
                catch (Exception ex)
                {
                    procDlg.Hide();
                    CommControl.MessageBoxEx.MessageBoxEx.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    //CommControl.Tools.WriteLog.AppendErrorLog(ex);
                }
                finally
                {
                    procDlg.Dispose();
                }
            }
            else
            {
                CommControl.MessageBoxEx.MessageBoxEx.Show("请选择要删除的呼叫规则!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
        }
Пример #5
0
        private void Add()
        {
            if (_BLL.GetModelList(string.Format(" i_flag=0 and  vc_CalledNumber='{0}'", _mModel.vc_CalledNumber)).Count > 0)
            {
                CommControl.MessageBoxEx.MessageBoxEx.Show(string.Format("被叫号码【{0}】已存在!", _mModel.vc_CalledNumber), "添加失败", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                txtNumber.Focus();
                throw new Exception("");
            }

            if (Tools.MBoxOperate.CreateCalledRule(_mModel) && _BLL.Add(_mModel) == 1)
            {
                if (_mModel.i_CalledType == MBoxSDK.ConfigSDK.CALLED_RULE_TYPE.入局.GetHashCode())
                {
                    DB_Talk.Model.m_Box modelBox = new DB_Talk.BLL.m_Box().GetModel(
                               string.Format(" i_Flag=0 and ID='{0}'", Global.Params.BoxID));

                    modelBox.vc_NumberHead = modelBox.vc_NumberHead + "," + _mModel.vc_CalledNumber;
                    modelBox.vc_NumberHead = modelBox.vc_NumberHead.Replace(",,", ",").Trim(',');
                    new DB_Talk.BLL.m_Box().Update(modelBox);
                }
                 
                if (_mModel.i_SIPID > 0)
                {
                    DB_Talk.Model.m_SIPInterface modelSip = new DB_Talk.BLL.m_SIPInterface().GetModel(
                             string.Format(" i_Flag=0 and SIPID='{0}' and BoxID='{1}'", _mModel.i_SIPID, Global.Params.BoxID));
                 
                    if(_mModel.i_CalledSubType==MBoxSDK.ConfigSDK.CALLED_SUB_RULE_TYPE.市话.GetHashCode())
                    {
                        modelSip.vc_OutNumberLocal = modelSip.vc_OutNumberLocal + "," + _mModel.vc_CalledNumber;
                        modelSip.vc_OutNumberLocal = modelSip.vc_OutNumberLocal.Replace(",,", ",").Trim(','); 
                    }
                    else if (_mModel.i_CalledSubType == MBoxSDK.ConfigSDK.CALLED_SUB_RULE_TYPE.长途.GetHashCode())
                    {
                        modelSip.vc_OutNumber = modelSip.vc_OutNumber + "," + _mModel.vc_CalledNumber;
                        modelSip.vc_OutNumber = modelSip.vc_OutNumber.Replace(",,", ",").Trim(','); 
                    }
                        
                   
                    new DB_Talk.BLL.m_SIPInterface().Update(modelSip);
                }
                if (_mModel.i_PRIID > 0)
                {
                    DB_Talk.Model.m_PRIInterface modelPri = new DB_Talk.BLL.m_PRIInterface().GetModel(
                                string.Format(" i_Flag=0 and PRIID='{0}' and BoxID='{1}'", _mModel.i_PRIID, Global.Params.BoxID));

                    if (_mModel.i_CalledSubType == MBoxSDK.ConfigSDK.CALLED_SUB_RULE_TYPE.市话.GetHashCode())
                    {
                        modelPri.vc_OutNumberLocal = modelPri.vc_OutNumberLocal + "," + _mModel.vc_CalledNumber;
                        modelPri.vc_OutNumberLocal = modelPri.vc_OutNumberLocal.Replace(",,", ",").Trim(','); 
                    }
                    else if (_mModel.i_CalledSubType == MBoxSDK.ConfigSDK.CALLED_SUB_RULE_TYPE.长途.GetHashCode())
                    {
                        modelPri.vc_OutNumber = modelPri.vc_OutNumber + "," + _mModel.vc_CalledNumber;
                        modelPri.vc_OutNumber = modelPri.vc_OutNumber.Replace(",,", ",").Trim(','); 
                    }
                   
                    new DB_Talk.BLL.m_PRIInterface().Update(modelPri);
                }
                CommControl.MessageBoxEx.MessageBoxEx.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                CommControl.MessageBoxEx.MessageBoxEx.Show("添加失败", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            
        }