/// <summary> /// 加载Box列表 /// </summary> public bool LoadBoxList() { if (Pub._configModel.BoxIP == "") { // DataSet dsBox = new DB_Talk.BLL.m_Box().GetListEx("id in (" + Pub.manageModel.vc_BoxID + ")"); DataSet dsBox = new DB_Talk.BLL.m_Box().GetListEx("i_flag=0"); int[] hideTypeCol = { 1 }; if (dsBox != null && dsBox.Tables[0].Rows.Count > 0) { _boxBox.Bind(this.cboSensorType.txtValue, dsBox.Tables[0], 2, hideTypeCol); this.cboSensorType.OnDropDown += new EventHandler(cboSensorType_OnDropDown); _boxBox.OnTextChangedEx += new Bestway.Windows.Controls.InputPromptDialog.TextChangedEx(_sensorTypeBox_OnTextChangedEx); return true; } else { return false; } } else { List<DB_Talk.Model.m_Box> lstBox = new DB_Talk.BLL.m_Box().GetModelList("i_Flag=0 and vc_IP='" + Pub._configModel.BoxIP + "'"); if (lstBox != null && lstBox.Count > 0) { Pub.manageModel.BoxID = lstBox[0].ID; return false ; } else { //MessageBoxEx.Show("输入的设备IP不正确(" + Pub._configModel.BoxIP + ")", "提示"); //this.Close(); Pub._configModel.BoxIP = ""; return LoadBoxList(); } } }
public int LoadData() { dgvList.Rows.Clear(); List<DB_Talk.Model.m_Box> lst = new List<DB_Talk.Model.m_Box>(); lst = new DB_Talk.BLL.m_Box().GetModelList("i_Flag=0"); int i = 0; foreach (DB_Talk.Model.m_Box item in lst) { i++; dgvList.Rows[dgvList.Rows.Add(item.ID, item.vc_Name, item.vc_IP, item.vc_Mask, item.vc_NetIP, item.vc_DispatchIP1, item.vc_DispatchIP2, item.vc_RecordServerIP, item.vc_TimerServerIP, item.vc_Memo, item.vc_SN )].Tag = item; } tslState.Text = " 共" + dgvList.Rows.Count.ToString() + "个" + Global.Params.BOXNAME; loadReport(); //Global.Params.LstBox = new DB_Talk.BLL.m_Box().GetModelList("i_Flag=0"); /* for (int j = 0; j < Global.Params.LstBox.Count; j++) { Global.Params.LstBox[j].i_Flag = 0; } */ return lst.Count; }
private void btnAddRight_Click(object sender, EventArgs e) { if (dgvLeft.Rows.Count == 0) { CommControl.MessageBoxEx.MessageBoxEx.Show("请先添加组!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (_selectLeftListIndex < 0) { CommControl.MessageBoxEx.MessageBoxEx.Show("请先选择组!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } int GroupID = int.Parse(dgvLeft.Rows[_selectLeftListIndex].Cells["colID"].Value.ToString()); string GroupName = dgvLeft.Rows[_selectLeftListIndex].Cells["colName"].Value.ToString(); if (GroupType == CommControl.PublicEnums.EnumGroupType.Meeting) { DB_Talk.Model.m_Box model= new DB_Talk.BLL.m_Box().GetModel("i_Flag=0 and ID='" + Global.Params.BoxID + "'"); if (model.i_MaxMeetingMember != null && model.i_MaxMeetingMember>0) Global.Params.MaxGroupMemberCount = (int)model.i_MaxMeetingMember; if (dgvRight.Rows.Count >= Global.Params.MaxGroupMemberCount) { CommControl.MessageBoxEx.MessageBoxEx.Show("该组人员已经到达最大限制【" + Global.Params.MaxGroupMemberCount + "】个,不能再添加!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } } //frm.groupID = int.Parse(GroupID); UI.frmGroupMember frm = new frmGroupMember(GroupID, GroupName, sbMemberID, dgvRight.Rows.Count, GroupType); if (frm.RecordCount > 0) { frm.ShowDialog(); if (frm.DialogResult == DialogResult.OK) LoadDataRight(); } else if(frm.RecordCount ==0) { string mes=""; if (dgvRight.Rows.Count > 0) mes = "所有人员已经加入组!"; else mes = "该"+Global.Params.BOXNAME+"下无用户!"; CommControl.MessageBoxEx.MessageBoxEx.Show(mes, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
private void btnOk_Click(object sender, EventArgs e) { if (_erroLoingCount <= 0) { this.Close(); return; } List<DB_Talk.Model.m_Manager> lst=new List<DB_Talk.Model.m_Manager>(); try { lst = new DB_Talk.BLL.m_Manager().GetModelList(string.Format("vc_UserName='******' and i_Flag=0 and vc_Password='******'", txtUser.Text, txtPass.Text)); } catch (Exception) { this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); return; } if (lst.Count > 0) { Pub.manageModel = lst[0]; if (_type== EnumLoginType.Out && Pub.manageModel.BoxID==null) { this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); return; } if (Pub.manageModel.i_Dispatch.Value!=1) { MessageBoxEx.Show("当前用户没有调度权限,请联系管理员!", "提示"); return; } //选择Box; FormSelectBox fs = new FormSelectBox(); if (fs.LoadBoxList() == true) { fs.ShowDialog(); } if (Pub.manageModel.BoxID == null ) { MessageBoxEx.Show("请到网管程序修改相应权限!", "提示"); return; } DB_Talk.Model.m_Box boxModel = new DB_Talk.BLL.m_Box().GetModel(Pub.manageModel.BoxID.Value); if (boxModel == null) { MessageBoxEx.Show("请到网管程序增加MBox设备!", "提示"); return; } #region 添加调度号码,取调度的前两个 /// List<DB_Talk.Model.m_Member> lstMember = new List<DB_Talk.Model.m_Member>(); lstMember = new DB_Talk.BLL.m_Member().GetModelList(string.Format("boxID={0} and i_isdispatch=1 and i_Flag=0", Pub.manageModel.BoxID)); if (lstMember.Count >= 2) { Pub.manageModel.LeftDispatchNumber = lstMember[0].i_Number; Pub.manageModel.LeftDispatchName = lstMember[0].vc_Name; Pub.manageModel.RightDispatchNumber = lstMember[1].i_Number; Pub.manageModel.RightDispatchName= lstMember[1].vc_Name; } else { MessageBoxEx.Show("请到网管程序添加调度号码!", "提示"); return; } #endregion this.DialogResult = System.Windows.Forms.DialogResult.OK; Pub._configModel.LastUser = txtUser.Text; Config.WriteModel(Pub._configModel); switch (_type) { case EnumLoginType.Login: CommControl.SystemLogBLL.WriteLog( Pub.manageModel.ID, Pub.manageModel.BoxID.Value, SystemLogBLL.EnumLogAction.SystemOperate, "登录", "登录成功", ""); break; case EnumLoginType.Out: CommControl.SystemLogBLL.WriteLog( Pub.manageModel.ID, Pub.manageModel.BoxID.Value, SystemLogBLL.EnumLogAction.SystemOperate, "退出", "退出成功", ""); break; case EnumLoginType.Lock: break; default: break; } } else { switch (_type) { case EnumLoginType.Login: MessageBoxEx.Show("登录失败", "登录"); break; case EnumLoginType.Out: MessageBoxEx.Show("退出失败", "退出"); break; case EnumLoginType.Lock: MessageBoxEx.Show("解锁失败", "解锁"); break; default: break; } _erroLoingCount--; } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Application.Run(new Form1()); // Application.Run(new TalkLog()); try { //new FormCallKeyborad(null).ShowDialog(); // new Form1().ShowDialog(); //单例模式 bool bCreatedNew; System.Threading.Mutex mutex = new System.Threading.Mutex(false, Application.ProductName, out bCreatedNew); if (!bCreatedNew) { CommControl.MessageBoxEx.MessageBoxEx.Show("程序已打开!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //捕获程序级错误 Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionEventHandler); Bestway.Windows.Forms.ProgressBarDialog procDlg = new Bestway.Windows.Forms.ProgressBarDialog(new FormWelcome()); Form tempForm = new Form(); tempForm.FormBorderStyle = FormBorderStyle.None; tempForm.Size = new System.Drawing.Size(1, 1); tempForm.Show(); tempForm.Hide(); //bool b = DB_Talk.DB.OpenDataBase("172.21.2.78\\hc", "MBoxOss", "Tester1", "User@1234", new ExecuteErrorEventHandler(OleDbHelper_ExecuteError)); Pub._configModel = Config.GetModel(); if (Pub._configModel.LocalIP == "127.0.0.1") { IPHostEntry hostName = Dns.GetHostByName(Dns.GetHostName()); if (hostName.AddressList.Length > 0) { Pub._configModel.LocalIP = hostName.AddressList[0].ToString(); Config.WriteModel(Pub._configModel); } } // bool b = DB_Talk.DB.OpenDataBase(Pub._configModel.DBServer, Pub._configModel.DBName, Pub._configModel.DBUserName, Pub._configModel.DBPassword, new ExecuteErrorEventHandler(OleDbHelper_ExecuteError)); procDlg.Show(Bestway.Windows.Forms.EnumDisplayType.LoadData, " 正在连接数据库,请稍等..."); if (OpenDataBase() == false) { procDlg.Hide(); DialogResult dr = new DialogResult(); dr = (new frmDatabaseConfig()).ShowDialog(); if (dr == DialogResult.Cancel) { procDlg.Dispose(); return; } } procDlg.Hide(); if (Pub._configModel.IsAutoLogin) { List<DB_Talk.Model.m_Manager> lst = new List<DB_Talk.Model.m_Manager>(); lst = new DB_Talk.BLL.m_Manager().GetModelList(string.Format("vc_UserName='******' and i_Flag=0 ", "admin")); Pub._configModel.LastUser = "******"; if (lst != null && lst.Count > 0) { Pub.manageModel = lst[0]; if (Pub.manageModel.i_Dispatch.Value != 1) { MessageBoxEx.Show("当前用户没有调度权限,请联系管理员!", "提示"); return; } Config.WriteModel(Pub._configModel); //选择Box; FormSelectBox fs = new FormSelectBox(); if (fs.LoadBoxList() == true) { fs.ShowDialog(); } if (Pub.manageModel.BoxID == null) { MessageBoxEx.Show("请先到网管程序配置语音调度交换机", "提示"); return; } DB_Talk.Model.m_Box boxModel = new DB_Talk.BLL.m_Box().GetModel(Pub.manageModel.BoxID.Value); if (boxModel == null) { MessageBoxEx.Show("请到网管程序增加MBox设备!", "提示"); return; } ///添加调度号码,取调度的前两个 List<DB_Talk.Model.m_Member> lstM = new List<DB_Talk.Model.m_Member>(); lstM = new DB_Talk.BLL.m_Member().GetModelList(string.Format("boxID={0} and i_isdispatch=1 and i_Flag=0", Pub.manageModel.BoxID)); if (lstM.Count >= 2) { Pub.manageModel.LeftDispatchNumber = lstM[0].i_Number; Pub.manageModel.LeftDispatchName = lstM[0].vc_Name; Pub.manageModel.RightDispatchNumber = lstM[1].i_Number; Pub.manageModel.RightDispatchName = lstM[1].vc_Name; } else { MessageBoxEx.Show("请到网管程序添加调度号码!", "提示"); return; } lstM = new DB_Talk.BLL.m_Member().GetModelList(string.Format("boxID={0} and i_isdispatch=2 and i_Flag=0", Pub.manageModel.BoxID)); if (lstM != null && lstM.Count > 0) { Pub.VideoNumber = lstM[0].i_Number.Value.ToString(); Pub.VideoPassword = lstM[0].i_NuPassword.ToString(); } else { if (Pub._configModel.IsVideoCall) { MessageBoxEx.Show("请到网管程序添加视频调度号码!", "提示"); return; } } if (Pub._configModel.IsVideoCall) { if (Pub._configModel.VideoSize<=0 || Pub._configModel.VideoSize>=10) { MessageBoxEx.Show("请设置合适的视频大小!", "提示"); return; } } if (boxModel.i_MaxMeetingMember != null) { Pub._maxMeetingMemberCount = boxModel.i_MaxMeetingMember.Value; } CommControl.SystemLogBLL.WriteLog( Pub.manageModel.ID, Pub.manageModel.BoxID.Value, SystemLogBLL.EnumLogAction.SystemOperate, "登录", "登录成功", ""); } else { MessageBoxEx.Show("请先到网管程序进行配置!", "提示"); return; } } else { FormLogin frmLogin = new FormLogin(FormLogin.EnumLoginType.Login); if (frmLogin.ShowDialog() == DialogResult.Cancel) { procDlg.Dispose(); return; } } Pub.CanDestroyControl = false; //frmLogin.Dispose(); List<DB_Talk.Model.m_Member> lstMember = new DB_Talk.BLL.m_Member().GetModelList(string.Format("i_Flag=0 and BoxID={0} order by id", Pub.manageModel.BoxID.Value)); if (lstMember.Count == 0) { CommControl.MessageBoxEx.MessageBoxEx.Show("请先到网管软件增加用户", "提示"); return; } FormMain frmMain = new FormMain(); //Form1 frmMain = new Form1(); //frmMain.Width = 1; //frmMain.Height = 1; procDlg.Show(Bestway.Windows.Forms.EnumDisplayType.LoadData, " 正在初始化程序,请稍等..."); frmMain.WindowState = FormWindowState.Normal; frmMain.Show();//为了让加载主窗体滚动条显示出来 frmMain.Visible = false; Pub._pageControl = Pub._meetingManage.GetToSelectPageControl(); if (Pub._pageControl == null) { procDlg.Hide(); MessageBoxEx.Show("请先到网管程序增加电话号码!", "提示"); return; } frmMain.ShowLoadOk(); frmMain.Visible = true; int tt = 10000;//当所有用户的信息都上报之后LstMember.cout会等于0,如果意外情况下Box内部没有上报数据库中的号码的话,这里执行10000次自动跳过 while (FormMain._lstMember.Count>0 && tt>=0) { tt--; System.Threading.Thread.Sleep(1); Application.DoEvents(); } frmMain.SetDispatchAndLoadState(); frmMain.WindowState = System.Windows.Forms.FormWindowState.Maximized; procDlg.Hide(); procDlg.Dispose(); Pub._memberManage.ClickTab(); frmMain.imgBtnMeeting_Click(null, null); Pub._meetingManage.ClickTab(); frmMain.imgBtnDispatch_Click(null, null); frmMain.SetSortButton(); Pub.CanDestroyControl = true; frmMain.SetDefaultMemberGroupIndex(); frmMain.SetMenuSelect(); //new Form1().ShowDialog(); Application.Run(frmMain); } catch (Exception ex) { CommControl.Tools.WriteLog.AppendLog("Main:" + ex.Message + ex.StackTrace); //MessageBoxEx.Show(ex.Message, "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { Environment.Exit(0); } }
//站点基本设置 public static bool SetBaseBox() { //因为恢复出厂设置之后dsp地址会恢复默认值,所以此处要检查下 DB_Talk.Model.m_Box modelbox = new DB_Talk.BLL.m_Box().GetModel(Global.Params.BoxID); if (modelbox != null && !string.IsNullOrEmpty(modelbox.vc_DspIP) && GetDspAddress() != modelbox.vc_DspIP) { MBoxSDK.ConfigSDK.MBOX_SetDspAddress(Global.Params.BoxHandle, modelbox.vc_DspIP); } //因为恢复出厂设置之后调度IP地址会清空,所以此处要重新设置下 List<string> lstIP=new List<string>(); GetDispatcherAddress(out lstIP); if (modelbox != null && !string.IsNullOrEmpty(modelbox.vc_DispatchIP1) ) //&& !lstIP.Contains(modelbox.vc_DispatchIP1)) { lstIP[0]=modelbox.vc_DispatchIP1; } if (modelbox != null && !string.IsNullOrEmpty(modelbox.vc_DispatchIP2) ) //&& !lstIP.Contains(modelbox.vc_DispatchIP2)) { lstIP[1]=modelbox.vc_DispatchIP2; } SetDispatcherAddress(lstIP); //设置CDR服务器 int open = 1, openReal = 2; //1打开,2关闭 if (!MBoxSDK.ConfigSDK.MBOX_SetCdrTrigger(Global.Params.BoxHandle, open, openReal)) return false; //SIP管理设置 if (!SetSipRegisterCycleAndHeartBeatInterval()) return false; //SAP接入点设置 DB_Talk.Model.m_SAPPoint model = new DB_Talk.Model.m_SAPPoint(); model.BoxID = Global.Params.BoxID; model.SAPID = 1; model.i_Port = 5060; model.i_Type = 1; if(!CreateSipSap(model)) { return false; } //设置默认的呼叫源、路由规则、呼叫源规则 if (!Tools.MBoxOperate.CreateCalinglSourceRule()) { return false; } return true; }
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; } }
private bool IsSetBoxNumLenAndHead() { DB_Talk.Model.m_Box model = new DB_Talk.BLL.m_Box().GetModel(Global.Params.BoxID); Global.Params.strNumHead = model.vc_NumberHead; Global.Params.NumberLen = model.i_NumberLen == null ? 0 : model.i_NumberLen.Value; if (model != null && !string.IsNullOrEmpty(model.vc_NumberHead) && (model.i_NumberLen > 0)) { return true; } else return false; }
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); } }
private void GetModel() { _mModel.BoxID = Global.Params.BoxID; _mModel.vc_Name = txtName.Text.Trim(); if (txtName.Enabled==true && _mModel.vc_Name == "") { txtName.Focus(); throw new Exception("用户名称不可以为空"); } if (_mModel.vc_Name.IndexOf("'") >= 0) { txtName.Focus(); throw new Exception("名称中不可以有特殊字符"); } /* if (_mModel.DepartmentID == null) { throw new Exception("请选择部门"); } */ if (txtTel.Text.Trim() == "" || int.Parse(txtTel.Text.Trim()) == 0 ) { txtTel.Focus(); throw new Exception("电话号码不可以为空或零"); } string str = txtTel.Text.Trim().Substring(0,1); if (txtTel.Text.Trim().Length != Global.Params.NumberLen || CheckNumberRule(txtTel.Text.Trim(), Global.Params.strNumHead)==false) { txtTel.Focus(); string mes = Global.Params.strNumHead.Replace(",", "或"); throw new Exception("用户号码长度必须是【" + Global.Params.NumberLen + "】位,且以数字【" + mes + "】开头"); } DB_Talk.Model.m_Box modelBox = new DB_Talk.BLL.m_Box().GetModel(Global.Params.BoxID); if (modelBox != null) { if (modelBox.i_DispatchNumber == int.Parse(txtTel.Text.Trim())) { throw new Exception("用户号码不能和调度号码(" + modelBox.i_DispatchNumber + ")相同!"); } if (modelBox.i_EmergencyNumber == int.Parse(txtTel.Text.Trim())) { throw new Exception("用户号码不能和紧急号码(" + modelBox.i_EmergencyNumber+ ")相同!"); } } //if (txtTel.Text.Replace(" ", "").Length != Global.Params.NumberLen) //{ // txtTel.Focus(); // throw new Exception("电话号码必须是: "+Global.Params.NumberLen+" 位"); //} _mModel.i_Number = int.Parse(txtTel.Text.Replace(" ", "").Trim()); if (cmbNoType.SelectedValue.ToString() != CommControl.PublicEnums.EnumTelType.G3G手机.GetHashCode().ToString()) { if (_mModel.i_NuPasswordType == null) throw new Exception("请选择密码模式"); if (_mModel.i_NuPasswordType == PublicEnums.EnumTelPasswordType.增加.GetHashCode()) { _mModel.i_NuPassword = (UInt64)_mModel.i_Number; } else { if (txtPassword.Text.Trim() == "") { txtPassword.Focus(); throw new Exception("当密码模式为固定时,用户密码不能为空"); } _mModel.i_NuPassword = UInt64.Parse(txtPassword.Text.Trim()); //UInt64 pasw = 0; //if (UInt64.TryParse(txtPassword.Text.Trim(), out pasw) && pasw > 100 && pasw<=999999999999) // //pasw.ToString().Length >= 3 && pasw.ToString().Length <= 12) // _mModel.i_NuPassword = pasw; //else // throw new Exception("用户密码必须是100~999999999999位之间的数字"); // //throw new Exception("用户密码长度必须在3~12位之间,且大于零"); } } else { _mModel.i_NuPasswordType=0; _mModel.i_NuPassword = 0; } if (_mModel.NumberTypeID == null) { throw new Exception("请选择号码类别"); } _mModel.vc_MAC = txtMAC.Text.Trim(); //if (_mModel.vc_MAC == "") //{ // txtMAC.Focus(); // throw new Exception("MAC不可以为空"); //} if (_mModel.vc_MAC.IndexOf("'") >= 0) { txtName.Focus(); throw new Exception("MAC中不可以有特殊字符"); } if (txtTelEnd.Text.Trim() != "") { string strEnd = txtTelEnd.Text.Trim().Substring(0, 1); if (txtTelEnd.Text.Trim().Length != Global.Params.NumberLen || Global.Params.strNumHead.IndexOf(str) < 0) { txtTelEnd.Focus(); string mes = Global.Params.strNumHead.Replace(",", "或"); throw new Exception("用户号码长度必须是【" + Global.Params.NumberLen + "】位,且以数字【" + mes + "】开头"); } addCount =Int64.Parse(txtTelEnd.Text.Trim()) -_mModel.i_Number.Value; if (addCount < 0) { txtTelEnd.Focus(); throw new Exception("终止号码不可以小于起始号码"); } else { DB_Talk.BLL.m_Member _BLL = new DB_Talk.BLL.m_Member(); List<DB_Talk.Model.m_Member> listCount = new List<DB_Talk.Model.m_Member>(); listCount = _BLL.GetModelList(string.Format(" i_flag=0 and BoxID='{0}'", Global.Params.BoxID)); if (listCount != null && (addCount > Global.Params.MaxBoxMemberCount - listCount.Count)) { throw new Exception(string.Format("终止号码过大,最多还能添加【{0}】个号码!", Global.Params.MaxBoxMemberCount-listCount.Count)); } } } if (txtIP1.Enabled) { if (txtIP1.Text=="" || txtIP2.Text=="") { throw new Exception("起始或者终止IP地址不能为空!"); } bool b = IsSameLanNet(IPAddress.Parse(txtIP1.Text.Trim()), IPAddress.Parse(txtIP2.Text.Trim())); if (!b) { throw new Exception("起始IP与终止IP不在一个网段"); } string[] IP1 = txtIP1.Text.Trim().Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries); string[] IP2 = txtIP2.Text.Trim().Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries); int addCountIP = int.Parse(IP2[3]) - int.Parse(IP1[3]); if (addCountIP < 0) { txtIP2.Focus(); throw new Exception("终止IP不可以小于起始IP"); } if (addCount==0 && addCountIP>0) { throw new Exception("起始IP与终止IP不同时,终止号码不能为空!\n\n且增加号码个数与IP个数必须相同"); } else if (addCount!=addCountIP) { throw new Exception("增加的号码个数与IP个数不一致"); } _mModel.vc_IP = txtIP1.Text.Trim(); } if (_mModel.i_TellType == CommControl.PublicEnums.EnumTelType.G3G手机.GetHashCode() && txtUmtsImsi.Text.Trim()=="") { throw new Exception("3G号码标示码不能为空"); } _mModel.vc_UmtsImsi = txtUmtsImsi.Text.Trim(); _mModel.vc_Memo = txtMemo.Text.Trim(); if (_mModel.vc_Memo.IndexOf("'") >= 0) { txtMemo.Focus(); throw new Exception("备注中不可以有特殊字符"); } if (groupBoxG.Visible == true) { if (chkUnCForward.Checked && txtUnCForward.Text == "") { txtUnCForward.Focus(); throw new Exception("请设置无条件呼叫前转号码"); } else if (txtUnCForward.Text != "") { if (txtUnCForward.Text.Trim() == txtTel.Text.Trim()) { txtUnCForward.Focus(); throw new Exception("无条件呼叫前转号码不能与自身号码相同"); } _mModel.i_UnCForwardNu = int.Parse(txtUnCForward.Text); } else { _mModel.i_UnCForwardNu = 0; } if (chkNoAnswerForward.Checked && txtNoAnswerForward.Text == "") { txtNoAnswerForward.Focus(); throw new Exception("请设置无应答呼叫前转号码"); } else if (txtNoAnswerForward.Text != "") { if (txtNoAnswerForward.Text.Trim() == txtTel.Text.Trim()) { txtNoAnswerForward.Focus(); throw new Exception("无应答呼叫前转号码不能与自身号码相同"); } _mModel.i_NoAnswerForward = int.Parse(txtNoAnswerForward.Text); } else { _mModel.i_NoAnswerForward = 0; } if (chkBusyForward.Checked && txtBusyForward.Text == "") { txtBusyForward.Focus(); throw new Exception("请设置遇忙前转号码"); } else if (txtBusyForward.Text != "") { if (txtBusyForward.Text.Trim() == txtTel.Text.Trim()) { txtBusyForward.Focus(); throw new Exception("遇忙转接号码不能与自身号码相同"); } _mModel.i_BusyForward = int.Parse(txtBusyForward.Text); } else { _mModel.i_BusyForward = 0; } if (chkPowerOffForward.Checked && txtPowerOffForward.Text == "") { txtPowerOffForward.Focus(); throw new Exception("请设置关机前转号码"); } else if (txtPowerOffForward.Text != "") { if (txtPowerOffForward.Text.Trim() == txtTel.Text.Trim()) { txtPowerOffForward.Focus(); throw new Exception("关机前转号码不能与自身号码相同"); } _mModel.i_PowerOffForward = int.Parse(txtPowerOffForward.Text); } else { _mModel.i_PowerOffForward = 0; } if (chkDirectNum.Checked && txtDirectNum.Text == "") { txtDirectNum.Focus(); throw new Exception("请设置直通号码"); } else if (txtDirectNum.Text != "") { if (txtDirectNum.Text.Trim() == txtTel.Text.Trim()) { txtDirectNum.Focus(); throw new Exception("直播号码不能与自身号码相同"); } _mModel.i_DirectNum = int.Parse(txtDirectNum.Text); } else { _mModel.i_DirectNum = 0; } if (chkAssociateNum1.Checked && txtAssociateNum1.Text == "") { txtAssociateNum1.Focus(); throw new Exception("请设置关联号码1"); } else if (txtAssociateNum1.Text != "") { if ( _mModel.i_AssociateNum1 != int.Parse(txtAssociateNum1.Text)) { _mModel.i_AssociateNum1 = int.Parse(txtAssociateNum1.Text); CheckAssociateNum(_mModel.i_AssociateNum1.ToString()); } } else { _mModel.i_AssociateNum1 = 0; } if (chkAssociateNum2.Checked && txtAssociateNum2.Text == "") { txtAssociateNum2.Focus(); throw new Exception("请设置关联号码2"); } else if (txtAssociateNum2.Text != "") { _mModel.i_AssociateNum2 = int.Parse(txtAssociateNum2.Text); CheckAssociateNum(_mModel.i_AssociateNum2.ToString()); } else { _mModel.i_AssociateNum2 = 0; } if (txtAssociateNum1.Text.Trim() != "" && txtAssociateNum2.Text.Trim() != "" && txtAssociateNum1.Text.Trim() == txtAssociateNum2.Text.Trim()) { txtAssociateNum2.Focus(); throw new Exception("两个关联号码不能相同"); } } }
void Form1_Load(object sender, EventArgs e) { this.Width = 1; this.Height = 1; this.DoubleBuffered = true; this.Invalidate(); CommControl.Resolution.ChangeRes(); Pub._memberManage = new MemberManage(this); Pub._meetingManage = new MeetingManage(this, Pub._talkControl); Pub._memberManage.Init(); Pub._memberManage.LoadFap(); Pub._meetingManage.Init(); LoadAllUser(); if (superTabControlMeeting.Tabs.Count > 0) { _currentSelectedMeetingModel = (MeetingGroupModel)superTabControlMeeting.Tabs[0].Tag; superTabControlMeeting.SelectedTab = (SuperTabItem)superTabControlMeeting.Tabs[0]; } Pub._talkControl.OnMemberStateChanged += new TalkControl.MemberStateChanaged(_talkControl_OnMemberStateChanged); Pub._talkControl.OnWaitingQueensChanged += new TalkControl.WaitingQueensChaanged(_talkControl_OnWaitingQueensChanged); Pub._talkControl.OnDispatchStateChanged += new TalkControl.DispatchStateChanaged(_talkControl_OnDispatchStateChanged); Pub._talkControl.OnLemcQueensChanged += new TalkControl.LemcQueensChaanged(_talkControl_OnLemcQueensChanged); Pub._talkControl.OnHotStandbyChanged += new TalkControl.HotStandbyChaanged(_talkControl_OnHotStandbyChanged); // dgvWait.CellClick += new DataGridViewCellEventHandler(dgvWait_CellClick); waitControl1.OnSelect += new DispatchPlatform.Control.WaitControl.SelectWaitDelgate(waitControl1_OnSelect); _boxModel = new DB_Talk.BLL.m_Box().GetModel(Pub.manageModel.BoxID.Value); stiAllMember.Click += new EventHandler(MemberTabItem_Click); lblTitle.Text = Pub._configModel.Title; this.Text = Pub._configModel.Title; DB_Talk.Model.m_Box box = new DB_Talk.BLL.m_Box().GetModel(Pub.manageModel.BoxID.Value); if (box != null) { Pub.BoxName = box.vc_Name; } imgBtnDispatch.Checked = true; superTabControlMain.SelectedTab = superTabItemDispatch; superTabItemDispatch.Tag = CommControl.PublicEnums.EnumGroupType.Normal; superTabItemMeeting.Tag = CommControl.PublicEnums.EnumGroupType.Meeting; Pub._meetingManage.SetControlIsCanSelect(false); // lblUserName.Text = Pub.manageModel.vc_UserName; timer1.Enabled = true; timer1.Interval = Pub._configModel.CheckBoxOnLineInterval * 1000; // this.WindowState = FormWindowState.Maximized; Pub.SetAutoRun(Pub._configModel.IsAutoStartBySystem); Pub.CanDeleteMemberState = true; Pub.CanSort = true; _memberGroupIndex = 0; }
public int LoadData() { dgvList.Rows.Clear(); List<DB_Talk.Model.v_Manager> lst = new List<DB_Talk.Model.v_Manager>(); lst = new DB_Talk.BLL.v_Manager().GetModelList("i_Flag=0 "); int i = 0; foreach (DB_Talk.Model.v_Manager item in lst) { StringBuilder sbOperates = new StringBuilder(); StringBuilder sbBoxNames = new StringBuilder(); if(item.i_Net==1) sbOperates.Append(",网络管理" ); if(item.i_Operate==1) sbOperates.Append(",操作管理" ); if(item.i_Dispatch==1) sbOperates.Append(",调度操作" ); if (sbOperates.Length > 0) sbOperates.Remove(0, 1); if (item.vc_BoxID != null && item.vc_BoxID != "") { List<DB_Talk.Model.m_Box> lstbox = new DB_Talk.BLL.m_Box().GetModelList(" i_Flag=0 and ID in(" + item.vc_BoxID + ") "); foreach (DB_Talk.Model.m_Box box in lstbox) { sbBoxNames.Append("," + box.vc_Name); } } if (sbBoxNames.Length > 0) sbBoxNames.Remove(0, 1); i++; string state = item.i_Flag == 0 ? "使用" : "未使用"; dgvList.Rows[dgvList.Rows.Add(i, item.vc_UserName, state, item.vc_Memo, item.ID, sbOperates.ToString(), sbBoxNames.ToString() )].Tag = item; } dgvList.ClearSelection(); enableRight(false); kryptonHeaderGroup1.ValuesSecondary.Heading = " 共" + dgvList.Rows.Count.ToString() + "个用户"; chkNet.Checked = false; chkOperate.Checked =false; chkDispatch.Checked = false; i = 1; loadReport(); return lst.Count; }