/// <summary> /// /// </summary> /// <param name="auth"></param> /// <param name="sipSetting"></param> /// <param name="ip"></param> /// <param name="sessionId"></param> /// <param name="uiState"></param> public Agent(UserAuth auth, Dictionary <string, object> sipSetting, string ip, string sessionId, IUiState uiState) { try { Auth = auth; SipSetting = sipSetting; IP = ip; AgentLogOnSessionId = sessionId; UiState = uiState; AgentCurrentState = new AgentInitiate(); ardsHandler = new SoftPhoneResourceHandler(auth.SecurityToken, auth.TenantID, auth.CompanyID); InitializeArdsEvent(); CallHandler = new CallHandler(auth.SecurityToken, auth.TenantID, auth.CompanyID); LastActivity = DateTime.Now; } catch (Exception exception) { Logger.Instance.LogMessage(Logger.LogAppender.DuoLogger2, "Agent", exception, Logger.LogLevel.Error); throw; } }
private void UserLogin() { try { button_login.Enabled = false; //ProgressBar.Start(); //ProgressBar.Show(); var settingObject = System.Configuration.ConfigurationSettings.AppSettings; var company = settingObject["Company"]; var auth = new RefUserAuth.IauthClient().login(txtUserName.Text.Trim(), txtPassword.Text.Trim(), int.Parse(company), "DuoSoftPhone"); var sip = ProfileManagementHandler.GetSipProfile(auth.SecurityToken, auth.guUserId); if (sip == null) { button_login.Enabled = true; //ProgressBar.Stop(); //ProgressBar.Hide(); txtPassword.Text = string.Empty; Logger.Instance.LogMessage(Logger.LogAppender.DuoDefault, "Fail to Get SIP Profile", Logger.LogLevel.Error); MessageBox.Show("Fail to Get SIP Profile", "Duo Dialer", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var id = Guid.NewGuid().ToString(); var callBack = new SoftPhoneResourceHandler(auth.SecurityToken, auth.TenantID, auth.CompanyID); var ip = GetLocalIpAddress(); callBack.OnResourceRegistrationCompleted += (r) => { #region Resource Registration this.Invoke(new MethodInvoker(delegate { button_login.Enabled = true; //ProgressBar.Stop(); //ProgressBar.Hide(); var passWord = txtPassword.Text; txtPassword.Text = string.Empty; switch (r.Command) { case WorkflowResultCode.ACDS101: //- Agent sucessfully registered (ACDS101) Hide(); new FormDialPad(auth, id, sip, ip, passWord).ShowDialog(this); this.Close(); Environment.Exit(0); break; case WorkflowResultCode.ACDE101: //- Agent already registered with different IP (ACDE101) Logger.Instance.LogMessage(Logger.LogAppender.DuoDefault, "Agent already registered with different IP-ARDS Code : ACDE101", Logger.LogLevel.Info); MessageBox.Show("Agent already registered with different IP", "Duo Dialer", MessageBoxButtons.OK, MessageBoxIcon.Error); break; default: Logger.Instance.LogMessage(Logger.LogAppender.DuoDefault, "Login Fail-- ARDS not allow to Login. ARDS Code : " + r.Command, Logger.LogLevel.Info); MessageBox.Show("Login Fail", "Duo Dialer", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } })); #endregion Resource Registration }; callBack.ResourceRegistration(auth, ip); } catch (Exception exception) { this.Invoke(new MethodInvoker(delegate { button_login.Enabled = true; //ProgressBar.Stop(); //ProgressBar.Hide(); txtPassword.Text = string.Empty; })); var id = SessionHandler.UniqueId(txtUserName.Text); Logger.Instance.LogMessage(Logger.LogAppender.DuoDefault, String.Format("Login fail. {0}", id), exception, Logger.LogLevel.Error); MessageBox.Show(@"Login Fail", @"Duo Dialer", MessageBoxButtons.OK, MessageBoxIcon.Error); } }