public void ResourceUnregistration() { try { ardsHandler.ResourceUnregistration(Auth); var authClient = new refUserAuth.IauthClient(); authClient.LogOut(Auth.SecurityToken); } catch (Exception exception) { Logger.Instance.LogMessage(Logger.LogAppender.DuoLogger2, "SendStatusChangeRequestBreak", exception, Logger.LogLevel.Error); } }
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 ResourceHandler(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(); txtPassword.Text = string.Empty; switch (r.Command) { case WorkflowResultCode.ACDS101: //- Agent sucessfully registered (ACDS101) Hide(); new FormDialPad(auth, id, sip, ip).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 }; callBack.ResourceRegistration(auth, ip); } catch (Exception exception) { this.Invoke(new MethodInvoker(delegate { button_login.Enabled = true; //ProgressBar.Stop(); //ProgressBar.Hide(); txtPassword.Text = string.Empty; })); Logger.Instance.LogMessage(Logger.LogAppender.DuoDefault, "Login fail", exception, Logger.LogLevel.Error); MessageBox.Show("Login Fail", "Duo Dialer", MessageBoxButtons.OK, MessageBoxIcon.Error); } }