示例#1
0
 private void frmPhoneConfig_Load(object sender, EventArgs e)
 {
     initDictionary      = ProfileManagementHandler.GetSipProfile(Auth.SecurityToken, Auth.guUserId);// ?? XMLHandler.ReadXML();
     txtuserName.Text    = (string)initDictionary["userName"];
     txtPassword.Text    = (string)initDictionary["password"];
     txtDisolayName.Text = (string)initDictionary["displayName"];
     txtauthName.Text    = (string)initDictionary["authName"];
     txtlocalPort.Text   = initDictionary["localPort"].ToString();
     txtserverPort.Text  = initDictionary["serverPort"].ToString();
     txtHostName.Text    = (string)initDictionary["hostName"];
 }
示例#2
0
 private void frmPhoneConfig_Load(object sender, EventArgs e)
 {
     SipProfile          = ProfileManagementHandler.GetSipProfile(Auth.SecurityToken, Auth.guUserId);//?? AbstractPhoneController.InitDictionary;// ?? XMLHandler.ReadXML();
     txtuserName.Text    = SipProfile.userName;
     txtPassword.Text    = SipProfile.password;
     txtDisolayName.Text = SipProfile.displayName;
     txtauthName.Text    = SipProfile.authName;
     txtlocalPort.Text   = SipProfile.localPort.ToString();
     txtserverPort.Text  = SipProfile.serverPort.ToString();
     txtHostName.Text    = SipProfile.hostName;
 }
示例#3
0
 private void UserLogin(Agent agent)
 {
     try
     { var sip = ProfileManagementHandler.GetSipProfile(agent.Auth.SecurityToken, agent.Auth.guUserId);
       if (sip == null)
       {
           Logger.Instance.LogMessage(Logger.LoggerFiles.DuoDefault, "Fail to Get SIP Profile", Logger.LogLevel.Error);
           MessageBox.Show("Fail to Get SIP Profile", "Duo Dialer", MessageBoxButtons.OK, MessageBoxIcon.Error);
           return;
       }
       agent.ResoursHandler.ResourceRegistration(agent.Auth, agent.IP); }
     catch (Exception exception)
     {
         Logger.Instance.LogMessage(Logger.LoggerFiles.DuoDefault, "Login fail", exception, Logger.LogLevel.Error);
         MessageBox.Show("Login Fail", "Duo Dialer", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#4
0
 private void frmPhoneConfig_Load(object sender, EventArgs e)
 {
     try
     {
         initDictionary      = ProfileManagementHandler.GetSipProfile(Auth.SecurityToken, Auth.guUserId);// ?? XMLHandler.ReadXML();
         txtuserName.Text    = (string)initDictionary["userName"];
         txtPassword.Text    = (string)initDictionary["password"];
         txtDisolayName.Text = (string)initDictionary["displayName"];
         txtauthName.Text    = (string)initDictionary["authName"];
         txtlocalPort.Text   = initDictionary["localPort"].ToString();
         txtserverPort.Text  = initDictionary["serverPort"].ToString();
         txtHostName.Text    = (string)initDictionary["hostName"];
     }
     catch (Exception exception)
     {
         Logger.Instance.LogMessage(Logger.LogAppender.DuoDefault, "frmPhoneConfig_Load", exception, Logger.LogLevel.Error);
     }
 }
示例#5
0
        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);
            }
        }
示例#6
0
        private void UserLogin()
        {
            try
            {
                var settingObject = System.Configuration.ConfigurationSettings.AppSettings;
                var company       = settingObject["Company"];
                var auth          = DuoAuth.DuoAuthorizationService.Login(txtUserName.Text.Trim(), txtPassword.Text.Trim(),
                                                                          int.Parse(company), "DuoSoftPhone");

                if (auth == null)
                {
                    throw new Exception("Fail to Login to Auth.");
                }

                var result = ArdsHandler.ResourceRegistration(auth, GetLocalIPAddress());

                if (result.Command == WorkflowResultCode.ACDS101)
                {
                    result = ArdsHandler.SendStatusChangeRequestIdel(auth, result.SessionID);
                    if (result.Command == WorkflowResultCode.ACDS403 || result.Command == WorkflowResultCode.ACDS405)
                    {
                        result = ArdsHandler.SendModeChangeRequestInbound(auth);
                        if (result.Command == WorkflowResultCode.ACDS601 || result.Command == WorkflowResultCode.ACDS501)
                        {
                            var sip = ProfileManagementHandler.GetSipProfile(auth.SecurityToken, auth.guUserId);
                            if (string.IsNullOrEmpty(sip.userName))
                            {
                                Logger.Instance.LogMessage(Logger.LoggerFiles.DuoDefault, "Fail to get SIP Profile info", Logger.LogLevel.Error);
                                throw new Exception("Fail to get SIP Profile info.");
                            }

                            // set agent status
                            _agent = new Agent
                            {
                                AgentCurrentState = new AgentInitiate(),
                                AgentCurrentMode  = AgentMode.Inbound,
                                SipProfile        = sip,
                                AgentSessionId    = SessionId.UniqueId(txtUserName.Text.Trim()),
                                UserAuth          = auth,
                            };
                            var frm = new FormDialPad(auth, _agent.AgentSessionId, sip, _agent);
                            _agent.AgentCurrentState.OnLogOn(ref _agent, string.Empty);
                            Hide();
                            frm.ShowDialog(this);
                            this.Close();
                            Environment.Exit(0);
                            return;
                        }
                        else
                        {
                            Logger.Instance.LogMessage(Logger.LoggerFiles.DuoDefault, "Fail to set Agent Mode",
                                                       Logger.LogLevel.Error);
                            MessageBox.Show("Fail to set Agent Mode", "Duo Dialer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        Logger.Instance.LogMessage(Logger.LoggerFiles.DuoDefault, "Fail to set Agent Status",
                                                   Logger.LogLevel.Error);
                        MessageBox.Show("Fail to set Agent Status", "Duo Dialer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    Logger.Instance.LogMessage(Logger.LoggerFiles.DuoDefault, "Fail to ResourceRegistration",
                                               Logger.LogLevel.Error);
                    MessageBox.Show("Resource Registration Fail", "Duo Dialer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                ArdsHandler.ResourceUnregistration(auth);
            }
            catch (Exception exception)
            {
                Logger.Instance.LogMessage(Logger.LoggerFiles.DuoDefault, "Login fail", exception, Logger.LogLevel.Error);
                MessageBox.Show("Login Fail", "Duo Dialer", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            txtPassword.Text = string.Empty;
        }
示例#7
0
        public void SetAuth(UserAuth auth)
        {
            try
            {
                Auth = auth;

                ResoursHandler = new ResourceHandler(Auth.SecurityToken, Auth.TenantID, Auth.CompanyID);

                SipSetting = ProfileManagementHandler.GetSipProfile(auth.SecurityToken, auth.guUserId);
                if (SipSetting == null)
                {
                    Logger.Instance.LogMessage(Logger.LoggerFiles.DuoDefault, "Fail to Get SIP Profile", Logger.LogLevel.Error);
                    MessageBox.Show("Fail to Get SIP Profile", "Duo Dialer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                ResoursHandler.OnResourceRegistrationCompleted += (r) =>
                {
                    try
                    {
                        switch (r.Command)
                        {
                        case WorkflowResultCode.ACDS101:     //- Agent sucessfully registered (ACDS101)
                            ResoursHandler.SendModeChangeRequestInbound(Auth);
                            break;

                        case WorkflowResultCode.ACDE101:     //- Agent already registered with different IP (ACDE101)
                            Logger.Instance.LogMessage(Logger.LoggerFiles.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.LoggerFiles.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;
                        }
                    }
                    catch (Exception exception)
                    {
                        Logger.Instance.LogMessage(Logger.LoggerFiles.DuoDefault, "OnResourceRegistrationCompleted", exception, Logger.LogLevel.Error);
                    }
                };

                ResoursHandler.OnSendModeChangeRequestInboundCompleted += (s) =>
                {
                    try
                    {
                        CallHandler = new CallHandler(auth.SecurityToken, auth.TenantID, auth.CompanyID);
                        UiState.InInitiateMsgState(CallHandler.AutoAnswerByDefault(), (CallHandler.AutoAnswerByDefault() && CallHandler.AutoAnswerCanAgentEnable()), auth.UserName);
                    }
                    catch (Exception exception)
                    {
                        Logger.Instance.LogMessage(Logger.LoggerFiles.DuoDefault, "OnSendModeChangeRequestInboundCompleted", exception, Logger.LogLevel.Error);
                    }
                };

                ResoursHandler.OnStatusUpdatedMessage += (s) =>
                {
                    try
                    {
                        Logger.Instance.LogMessage(Logger.LoggerFiles.DuoDefault, string.Format("OnStatusUpdatedMessage : {0}", s), Logger.LogLevel.Info);
                        //if (!string.IsNullOrEmpty(s.ExtraData))
                        //    mynotifyicon.ShowBalloonTip(5, "Duo Soft Phone", s.ExtraData, ToolTipIcon.Info);
                    }
                    catch (Exception exception)
                    {
                        Logger.Instance.LogMessage(Logger.LoggerFiles.DuoDefault, "OnStatusUpdatedMessage", exception, Logger.LogLevel.Error);
                    }
                };

                ResoursHandler.OnSendStatusChangeRequestIdelCompleted += (s) =>
                {
                    try
                    {
                        Logger.Instance.LogMessage(Logger.LoggerFiles.DuoDefault, string.Format("OnSendStatusChangeRequestIdelCompleted : {0}", s), Logger.LogLevel.Info);
                    }
                    catch (Exception exception)
                    {
                        Logger.Instance.LogMessage(Logger.LoggerFiles.DuoDefault, "OnSendStatusChangeRequestIdelCompleted", exception, Logger.LogLevel.Error);
                    }
                };
            }
            catch (Exception exception)
            {
                Logger.Instance.LogMessage(Logger.LoggerFiles.DuoDefault, "SetAuth", exception, Logger.LogLevel.Error);
            }
        }