Exemplo n.º 1
0
        public bool AgentLogOff(ReconCOM rc, string userName)
        {
            Loger.Log4Net.Info("[CarolHelper]AgentLogOff...begin....");
            bool flag = false;

            try
            {
                //int iRet = rc.T_AgentLogOff(userName, userName);
                //add by lihf 2014-2-18
                int iRet = rc.T_AgentLogOff(userName, LoginUser.AgentNum);
                if (iRet == (int)enErrorCode.E_SUCCESS)
                {
                    flag = true;

                    //退出后,删除状态临时表记录
                    SqlTool tool = new SqlTool();
                    if (!tool.DeleteAgentState2DB())
                    {
                        Loger.Log4Net.Info("[CarolHelper]AgentLogOff...坐席退出时删除状态临时表记录失败....");
                    }
                    else
                    {
                        //Loger.Log4Net.Info("[CarolHelper]AgentLogOff...坐席退出时删除状态临时表记录成功....");
                        //记录坐席退出状态时间
                        DateTime tdate = tool.GetCurrentTime();//DateTime.Now;
                        //测试发现退出状态,在西门子事件里,会处理。所以注释掉
                        //int ival = tool.InsertAgentStateDetail2DB(1, 0, -2, tdate, tdate);
                        //Loger.Log4Net.Info("[CarolHelper]AgentLogOff...坐席退出时ival....IS:" + ival);
                        Loger.Log4Net.Info("[CarolHelper]AgentLogOff...坐席退出时LoginOnOid....IS:" + LoginUser.LoginOnOid);
                        Loger.Log4Net.Info("[CarolHelper]AgentLogOff...坐席退出时tool.GetCurrentTime()....IS:" + tdate.ToString("yyyy-MM-dd HH:mm:ss"));
                        if (LoginUser.LoginOnOid != null)
                        {
                            tool.UpdateStateDetail2DB(Convert.ToInt32(LoginUser.LoginOnOid), tdate);
                        }
                    }
                    Loger.Log4Net.Info("[CarolHelper]AgentLogOff...退出成功....");
                }
                else
                {
                    Loger.Log4Net.Info("[CarolHelper]AgentLogOff...退出失败....iRet=" + iRet);
                }
            }
            catch (Exception ex)
            {
                flag = false;
                Loger.Log4Net.Info("[CarolHelper]AgentLogOff...errorMessage is:" + ex.Message);
                Loger.Log4Net.Info("[CarolHelper]AgentLogOff...errorSource is:" + ex.Source);
                Loger.Log4Net.Info("[CarolHelper]AgentLogOff...errorStackTrace is:" + ex.StackTrace);
            }
            return(flag);
        }
Exemplo n.º 2
0
        public int AgentLogOn(ReconCOM rc, string userName, string userID)
        {
            Loger.Log4Net.Info("[CarolHelper]AgentLogOn...begin....");
            int iRet = 0;

            try
            {
                //iRet = rc.T_AgentLogOn(userName, userName, userName, 0);
                //add by lihf 2014-2-18
                iRet = rc.T_AgentLogOn(userName, LoginUser.AgentNum, LoginUser.AgentNum, 0);
                if (iRet == (int)enErrorCode.E_SUCCESS)
                {
                    Loger.Log4Net.Info("[CarolHelper]AgentLogOn...登录成功....");

                    //登录成功后,插入状态到临时表
                    SqlTool  tool  = new SqlTool();
                    DateTime tdate = DateTime.Now;
                    //登录后,首先进入置忙
                    if (tool.InsertAgentState2DB(4, 0, -2, 0, tdate))
                    {
                        //tool.InsertAgentStateDetail2DB(2, 0, -2, tdate, tdate);
                        string msg = "";
                        msg = tool.UpdateLoginOffTime(LoginUser.UserID.ToString(), tdate);
                        Loger.Log4Net.Info("[CarolHelper]AgentLogOn...更新退出时间...." + msg);
                        LoginUser.LoginOnOid = tool.InsertAgentStateDetail2DB(2, 0, -2, tdate, tdate);
                        Loger.Log4Net.Info("[CarolHelper]AgentLogOn...登录状态LoginOnOid....is:" + LoginUser.LoginOnOid);
                    }
                    else
                    {
                        Loger.Log4Net.Info("[CarolHelper]AgentLogOn...登录成功后,插入状态到临时表失败.....");
                    }
                }
                else
                {
                    Loger.Log4Net.Info("[CarolHelper]AgentLogOn...notE_SUCCESS,iRet is:" + iRet);
                }
            }
            catch (Exception ex)
            {
                Loger.Log4Net.Info("[CarolHelper]AgentLogOn...登录失败....");
                Loger.Log4Net.Info("[CarolHelper]AgentLogOn...errorMessage...is:" + ex.Message);
                Loger.Log4Net.Info("[CarolHelper]AgentLogOn...errorSource...is:" + ex.Source);
                Loger.Log4Net.Info("[CarolHelper]AgentLogOn...errorStackTrace...is:" + ex.StackTrace);
            }
            return(iRet);;
        }
Exemplo n.º 3
0
        public bool AgentLogOn(ReconCOM rc, string userName)
        {
            Loger.Log4Net.Info("[CarolHelper]AgentLogOn...begin222....");
            bool flag = false;

            try
            {
                //int iRet = rc.T_AgentLogOn(userName, userName, userName, 0);
                //add by lihf 2014-2-18
                int iRet = rc.T_AgentLogOn(userName, LoginUser.AgentNum, LoginUser.AgentNum, 0);
                if (iRet == (int)enErrorCode.E_SUCCESS)
                {
                    Loger.Log4Net.Info("[CarolHelper]AgentLogOn...登录成功....");
                    flag = true;

                    //登录成功后,插入状态到临时表
                    SqlTool  tool  = new SqlTool();
                    DateTime tdate = DateTime.Now;
                    //登录后,首先进入置忙
                    if (tool.InsertAgentState2DB(4, 0, -2, 0, tdate))
                    {
                        Loger.Log4Net.Info("[CarolHelper]AgentLogOn...置忙状态插入成功....");
                        string msg = "";
                        msg = tool.UpdateLoginOffTime(LoginUser.UserID.ToString(), tdate);
                        Loger.Log4Net.Info("[CarolHelper]AgentLogOn...更新退出时间...." + msg);
                        LoginUser.LoginOnOid = tool.InsertAgentStateDetail2DB(2, 0, -2, tdate, tdate);
                        Loger.Log4Net.Info("[CarolHelper]AgentLogOn...登录状态LoginOnOid....is:" + LoginUser.LoginOnOid);
                    }
                    else
                    {
                        Loger.Log4Net.Info("[CarolHelper]AgentLogOn...登录成功后,插入状态到临时表失败.....");
                    }
                }
                else
                {
                    Loger.Log4Net.Info("[CarolHelper]AgentLogOn...notE_SUCCESS,iRet is:" + iRet);
                }
            }
            catch (Exception)
            {
                flag = false;
            }
            return(flag);
        }
Exemplo n.º 4
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            Loger.Log4Net.Info("[Login]btnLogin_Click begin...");
            try
            {
                string organizationService   = ConfigurationManager.AppSettings["OrganizationService"];
                IOrganizationService service = (IOrganizationService)Activator.GetObject(typeof(IOrganizationService),
                                                                                         organizationService);
                string userName      = txtUserName.Text.Trim();
                string domainAccount = txtDomainAccount.Text.Trim();
                string password      = txtPwd.Text.Trim();
                Loger.Log4Net.Info("[Login]btnLogin_Click service.Login(domainAccount, password) begin...");
                LoginResult loginResult = service.Login(domainAccount, password);
                if (loginResult == LoginResult.Success)
                {
                    LoginUser.DomainAccount = domainAccount;
                    LoginUser.Password      = password;
                    Employee eModel = service.GetEmployeeByDomainAccount(domainAccount);

                    if (eModel != null)
                    {
                        SqlTool tool = new SqlTool();
                        //LoginUser.AgentID = BitAuto.YanFa.SysRightManager.Common.UserInfo.Instance.GetUserIDByNameDomainAccount("lihefeng");
                        LoginUser.UserID       = tool.GetUserIDByNameDomainAccount(domainAccount);
                        LoginUser.EmployeeID   = eModel.EmployeeID;
                        LoginUser.Department   = eModel.Department;
                        LoginUser.TrueName     = eModel.CnName;
                        LoginUser.ExtensionNum = userName;
                        //LoginUser.GroupName = tool.GetUserGroupNamesStr(Convert.ToInt32(LoginUser.AgentID));

                        string str = tool.GetBGNameAndOutNum(Convert.ToInt32(LoginUser.UserID));
                        if (!string.IsNullOrEmpty(str))
                        {
                            string[] strArray = str.Split(',');

                            LoginUser.BGID      = strArray[0];
                            LoginUser.GroupName = strArray[1];
                            LoginUser.OutNum    = strArray[2];
                            if (string.IsNullOrEmpty(strArray[3]))
                            {
                                MessageBox.Show("坐席工号未设置,请联系管理员!");
                                Loger.Log4Net.Info("[Login]坐席登录 坐席工号未设置 AgentID is:" + LoginUser.UserID + "!");
                                return;
                            }
                            else
                            {
                                LoginUser.AgentNum = strArray[3];
                            }
                        }
                        else
                        {
                            Loger.Log4Net.Info("[Login]btnLogin_Click...AgentID is:" + LoginUser.UserID + ",所属业务组为空!");
                        }
                        Loger.Log4Net.Info("[Login]坐席登录...AgentID is:" + LoginUser.UserID + ",AgentNum is:" + LoginUser.AgentNum + ",GroupName is:" + LoginUser.GroupName);
                    }
                    //DomainAccount = domainAccount;
                    //Password = password;
                }
                else
                {
                    MessageBox.Show("密码错误,请联系管理域帐号的网管!");
                    return;
                }
                if (string.IsNullOrEmpty(userName))
                {
                    MessageBox.Show("请输入坐席分机号码!");
                }
                else
                {
                    Loger.Log4Net.Info("[Login]btnLogin_Click CarolHelper.Instance.Login begin...");
                    int r = CarolHelper.Instance.Login(Program.rc, userName, true);
                    if (r == (int)enErrorCode.E_SUCCESS)
                    {
                        SaveLoginInfoToLocalXML(userName, domainAccount);
                        //LoginUser.ExtensionNum = userName;
                        Loger.Log4Net.Info("[Login]btnLogin_Click LoginUser.ExtensionNum is:" + LoginUser.ExtensionNum + ",LoginUser.UserID is:" + LoginUser.EmployeeID);
                        this.Hide();
                        Main main = new Main();
                        main.Show();
                    }
                    else if (r == (int)enErrorCode.E_TSV_REJECT)
                    {
                        Loger.Log4Net.Info("[Login]btnLogin_Click CarolHelper.Instance.Login is enErrorCode.E_TSV_REJECT...");
                        if (IsForceLogin)
                        {
                            Loger.Log4Net.Info("[Login]btnLogin_Click CarolHelper.Instance.Login 坐席分机强制登录开始...");
                            CarolHelper.Instance.Clear(Program.rc, userName);
                            r = CarolHelper.Instance.Login(Program.rc, userName, true);
                            if (r == (int)enErrorCode.E_SUCCESS)
                            {
                                Loger.Log4Net.Info("[Login]btnLogin_Click CarolHelper.Instance.Login 坐席分机登录成功...");
                                SaveLoginInfoToLocalXML(userName, domainAccount);
                                LoginUser.ExtensionNum = userName;
                                this.Hide();
                                Main main = new Main();
                                main.Show();
                            }
                            else
                            {
                                Loger.Log4Net.Info("[Login]btnLogin_Click CarolHelper.Instance.Login 坐席分机强制登录失败..." + r);
                            }
                        }
                        else
                        {
                            Loger.Log4Net.Info("[Login]btnLogin_Click CarolHelper.Instance.Login 坐席分机已登录,不能重复登录...");
                            MessageBox.Show("坐席分机已登录,不能重复登录");
                        }
                    }
                    //else if (r == (int)enErrorCode.E_TSV_REJECT)
                    //{
                    //    //MessageBox.Show("坐席分机已登录,不能重复登录");
                    //    CarolHelper.Instance.Clear(Program.rc, userName);
                    //    r = CarolHelper.Instance.Login(Program.rc, userName, true);
                    //    if (r == (int)enErrorCode.E_SUCCESS)
                    //    {
                    //        SaveLoginUserNameToLocalXML(userName);
                    //        UserName = userName;
                    //        this.Hide();
                    //        Main main = new Main();
                    //        main.Show();
                    //    }
                    //}
                    else if (r == -1)
                    {
                        MessageBox.Show("宇高录音登录失败");
                        //CarolHelper.Instance.Clear(Program.rc, userName);
                    }
                }

                this.txtUserName.Focus();
            }
            catch (Exception ex)
            {
                Loger.Log4Net.Info("[Login]btnLogin_Click errorMessage is:" + ex.Message);
                Loger.Log4Net.Info("[Login]btnLogin_Click errorSource is:" + ex.Source);
                Loger.Log4Net.Info("[Login]btnLogin_Click errorStackTrace is:" + ex.StackTrace);
            }
        }