Пример #1
0
 private void btnDel_Click(object sender, EventArgs e)
 {
     if (dgvList.SelectedRows.Count > 0)
     {
         DB_Talk.Model.m_Box typeModel = (DB_Talk.Model.m_Box)dgvList.CurrentRow.Tag;
         if (typeModel != null)
         {
             if (CommControl.MessageBoxEx.MessageBoxEx.Show("确认要删除 【" + typeModel.vc_Name + "】 吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
             {
                 bool isExit_manager = new DB_Talk.BLL.m_Manager().Exists("BoxId='" + typeModel.ID + "'");
                 bool isExit_member = new DB_Talk.BLL.m_Member().Exists("BoxId='" + typeModel.ID + "'");
                 List<DB_Talk.Model.m_Group> lst = new DB_Talk.BLL.m_Group().GetModelList("i_Flag=0 and BoxId='" + typeModel.ID + "'");
                 bool isExit_group = false;
               
                 foreach (DB_Talk.Model.m_Group m in lst)
                 {
                     if (m.vc_Name != Global.Params.gruopNormalName)
                     {
                         isExit_group = true;
                         break;
                     }
                 }
                 bool isExit_CalledRule = new DB_Talk.BLL.m_CalledRule().Exists("BoxId='" + typeModel.ID + "' and i_Flag=0 and vc_CalledNumber!='*000'");
                 //bool isExit_group = new DB_Talk.BLL.m_Group().Exists("BoxId='" + typeModel.ID + "'");
                 if (isExit_manager || isExit_member || isExit_group || isExit_CalledRule)
                 //if (isExit_member)
                 {
                     CommControl.MessageBoxEx.MessageBoxEx.Show(Global.Params.BOXNAME + "已经被引用,不可以删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                     return;
                 }
                 if (new DB_Talk.BLL.m_Box().DeleteEx(typeModel.ID))
                 {
                     new DB_Talk.BLL.m_Group().Delete("i_Flag=0 and BoxId='" + typeModel.ID + "'");
                     CommControl.MessageBoxEx.MessageBoxEx.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                     CommControl.SystemLogBLL.WriteLog(Global.Params.UserID, typeModel.ID, CommControl.SystemLogBLL.EnumLogAction.Delete, "删除", "删除了站点:" + typeModel.vc_Name, "");
                     //.BLL.m_SystemLog.WriteLog(Global.Params.UserID, DB_FileManage.Model.m_SystemLog.EnumLogAction.Delete, "删除文件等级", "删除文件等级:" + typeModel.vc_Name);
                     LoadData();
                     Global.Params.LstBox.Remove(typeModel);
                     dr = DialogResult.OK;
                 }
                 else
                 {
                     CommControl.MessageBoxEx.MessageBoxEx.Show("删除失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
     }
     else
     {
         CommControl.MessageBoxEx.MessageBoxEx.Show("请选择要删除的" +Global.Params.BOXNAME, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
     }
 }
Пример #2
0
        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);
            }
        }
Пример #3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtUserName.Text.Trim() == "")
            {
                this.SendToBack();
                CommControl.MessageBoxEx.MessageBoxEx.Show("用户名不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtUserName.Focus();
                return;
            }
            DB_Talk.BLL.m_Manager userBll = new DB_Talk.BLL.m_Manager();
            if (userBll.GetModelList("i_Flag=0 and vc_UserName='******'").Count==0 && txtPassword.Text.Trim().ToUpper() == "ADMIN" && txtUserName.Text.Trim().ToUpper() == "ADMIN")
            {
                DB_Talk.Model.m_Manager model = new DB_Talk.Model.m_Manager();
                model.vc_UserName = "******";
                model.vc_Password = "******";
                model.i_Net = 1;
                model.i_Dispatch = 1;
                model.i_Operate = 1;
                userBll.Add(model);
                Global.Params.UserID = -1;
                Global.Params.UserName = "******";
                Global.Params.Password = "******";
                SaveLoginUser(txtUserName.Text.Trim());
                m_IsOK = true;
                this.Hide();
                return;
            }
            else
            {
                //验证次数
                m_ValidateCount++;
                //DB_Talk.BLL.m_Manager userBll = new DB_Talk.BLL.m_Manager();
                List<DB_Talk.Model.m_Manager> userList = userBll.GetModelList(" i_flag = 0 and vc_UserName='******'", "''") + "'");
                if (userList != null && userList.Count > 0)
                {
                    Global.Params.UserID = userList[0].ID;
                    Global.Params.UserName = userList[0].vc_UserName;
                   
                    string password = userList[0].vc_Password;
                    if (password == null) password = "";
                    if (password == txtPassword.Text.Trim())
                    {
                        if (Convert.ToBoolean(userList[0].i_Net) == true)
                        {
                            Global.Params.Password = password;
                            SaveLoginUser(txtUserName.Text.Trim());
                            //系统用户控制可以登录的box
                            //string strW = "";
                            //if (userList[0].vc_BoxID != null && userList[0].vc_BoxID != "")
                            //    strW = " i_Flag=0 and ID in(" + userList[0].vc_BoxID + ")";
                            
                            //添加到系统里面的box就可以登录
                            string strW = " i_Flag=0 ";
                            if (strW == "")
                                Global.Params.LstBox = new List<DB_Talk.Model.m_Box>(); //为空时 全部不选
                            else
                                Global.Params.LstBox = new DB_Talk.BLL.m_Box().GetModelList(strW);
                            m_IsOK = true;
                            this.Hide();
                            return;
                        }
                        else
                        {
                            this.SendToBack();
                            CommControl.MessageBoxEx.MessageBoxEx.Show("用户无网络管理权限!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        this.SendToBack();
                        CommControl.MessageBoxEx.MessageBoxEx.Show("密码错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    this.SendToBack();
                    CommControl.MessageBoxEx.MessageBoxEx.Show("用户名不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

                }
            }
               
            
           
            if (m_ValidateCount >= 3)
            {
                m_IsOK = false;
                this.Hide();
                return;
            }
            return;
        }
Пример #4
0
        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--;
            }
        }
Пример #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (dgvList.SelectedRows.Count > 0)
            {
                DB_Talk.Model.v_Manager vModel = (DB_Talk.Model.v_Manager)dgvList.CurrentRow.Tag;
                DB_Talk.Model.m_Manager mModel =new DB_Talk.BLL.m_Manager().GetModel(vModel.ID);

                if (vModel != null)
                {
                    try
                    {
                        //checkCondition();
                    }
                    catch (Exception ex)
                    {
                        CommControl.MessageBoxEx.MessageBoxEx.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    DB_Talk.Model.m_Manager m = GetModel(mModel);
                    if (new DB_Talk.BLL.m_Manager().Update(m))
                    {

                        if (Global.Params.UserName == m.vc_UserName && m.vc_BoxID != vModel.vc_BoxID)
                        {
                            /*
                            List<DB_Talk.Model.m_Box> lst = new List<DB_Talk.Model.m_Box>();
                            //string strW = "i_Flag=-1";  //不选择box时,获取0个box
                            if (mModel.vc_BoxID != null && mModel.vc_BoxID != "")
                            {
                                lst = new DB_Talk.BLL.m_Box().GetModelList(" i_Flag=0 and ID in(" + mModel.vc_BoxID + ")");
                            }
                            foreach(DB_Talk.Model.m_Box box in Global.Params.LstBox)
                            {
                                 foreach(DB_Talk.Model.m_Box boxNew in lst)
                                 {
                                     if (box.ID == boxNew.ID)
                                     {
                                         boxNew.i_Flag = box.i_Flag;
                                     }
                                }
                            }
                            Global.Params.LstBox = lst;
                            IsUpdateBox = true;
                            */
                        }
                        CommControl.MessageBoxEx.MessageBoxEx.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        //.BLL.m_SystemLog.WriteLog(Global.Params.UserID, DB_FileManage.Model.m_SystemLog.EnumLogAction.Delete, "删除文件等级", "删除文件等级:" + typeModel.vc_Name);
                        LoadData();
                    }
                    else
                    {
                        CommControl.MessageBoxEx.MessageBoxEx.Show("保存失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                }
            }
            else
            {
                CommControl.MessageBoxEx.MessageBoxEx.Show("请选择要保存的登录用户", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }