public OutputValues Login(string place, string userName, string workMode, string queue, string agentLoginId, string agentPassword) { logger.Debug("SoftPhone Login:"******"*********************************************"); logger.Debug("Place: " + place + Environment.NewLine + "UserName: "******"WorkMode: " + workMode + Environment.NewLine + "Queue: " + queue + Environment.NewLine + "AgentLoginId: " + agentLoginId); logger.Debug("*********************************************"); var output = new OutputValues(); //Input Validation CheckException.CheckLoginValues(place, userName); //Authenticate User Settings.GetInstance().QueueName = queue; CheckException.CheckDN(Settings.GetInstance().ACDPosition, Settings.GetInstance().ExtensionDN, Settings.GetInstance().PlaceName); EventRegistered evenReg = null; string fullName = ""; if (Settings.GetInstance().ACDPosition == Settings.GetInstance().ExtensionDN) { var message = RegisterDNRequest(Settings.GetInstance().ExtensionDN); if (message != null) { switch (message.Id) { case EventRegistered.MessageId: evenReg = message as EventRegistered; string AID = string.IsNullOrEmpty(evenReg.AgentID) ? "" : evenReg.AgentID; if (CheckPlcaeTaken(AID, out fullName)) { if (Settings.GetInstance().ACDPosition == Settings.GetInstance().ExtensionDN) { Pointel.Softphone.Voice.Core.Request.RequestUnRegisterPlace.UnRegisterDN(Settings.GetInstance().ExtensionDN); } else { Pointel.Softphone.Voice.Core.Request.RequestUnRegisterPlace.UnRegisterDN(Settings.GetInstance().ACDPosition); Pointel.Softphone.Voice.Core.Request.RequestUnRegisterPlace.UnRegisterDN(Settings.GetInstance().ExtensionDN); } output.MessageCode = "2004"; output.Message = "Place is already taken by " + fullName + "."; return(output); } AssignPreAgentStatus(evenReg); AssignPreCallStatus(evenReg); Settings.GetInstance().IsDNRegistered = true; break; case EventError.MessageId: Settings.GetInstance().IsDNRegistered = false; break; } } Register(Settings.GetInstance().ExtensionDN); } else { var message = RegisterDNRequest(Settings.GetInstance().ACDPosition); if (message != null) { switch (message.Id) { case EventRegistered.MessageId: evenReg = message as EventRegistered; string AID = string.IsNullOrEmpty(evenReg.AgentID) ? "" : evenReg.AgentID; if (CheckPlcaeTaken(AID, out fullName)) { if (Settings.GetInstance().ACDPosition == Settings.GetInstance().ExtensionDN) { Pointel.Softphone.Voice.Core.Request.RequestUnRegisterPlace.UnRegisterDN(Settings.GetInstance().ExtensionDN); } else { Pointel.Softphone.Voice.Core.Request.RequestUnRegisterPlace.UnRegisterDN(Settings.GetInstance().ACDPosition); //Pointel.Softphone.Voice.Core.Request.RequestUnRegisterPlace.UnRegisterDN(Settings.GetInstance().ExtensionDN); } output.MessageCode = "2004"; output.Message = "Place is already taken by " + fullName + "."; return(output); } AssignPreAgentStatus(evenReg); Settings.GetInstance().IsDNRegistered = true; break; case EventError.MessageId: Settings.GetInstance().IsDNRegistered = false; break; } } IMessage message1 = RegisterDNRequest(Settings.GetInstance().ExtensionDN); if (message1 != null) { switch (message1.Id) { case EventRegistered.MessageId: evenReg = message as EventRegistered; AssignPreCallStatus(evenReg); Settings.GetInstance().IsDNRegistered = true; break; case EventError.MessageId: Settings.GetInstance().IsDNRegistered = false; break; } } Register(Settings.GetInstance().ACDPosition); Register(Settings.GetInstance().ExtensionDN); } if (!Settings.GetInstance().ISAlreadyLogin&& Settings.GetInstance().IsDNRegistered) { output = RequestLogin.LoginAgent(workMode, queue, agentLoginId, agentPassword); } else if (Settings.GetInstance().ISAlreadyLogin) { output.MessageCode = "201"; output.Message = "Agent Login Success"; } if (output.MessageCode == "200") { output.Message = "Agent Login Success"; } return(output); }
public OutputValues Initialize(string place, string userName, ConfService configObject, string tServerApplicationName, string agentLoginId, string agentPassword, CfgSwitch switchType) { Settings.GetInstance().AgentLoginID = agentLoginId; Settings.GetInstance().Switch = switchType; Settings.GetInstance().SwitchTypeName = switchType.Type == CfgSwitchType.CFGLucentDefinityG3 ? "avaya" : ((switchType.Type == CfgSwitchType.CFGNortelDMS100 || switchType.Type == CfgSwitchType.CFGNortelMeridianCallCenter) ? "nortel" : "avaya"); var output = OutputValues.GetInstance(); var connect = new VoiceConnectionManager(); var read = new ReadConfigObjects(); //Print DLL Info try { Assembly assemblyVersion = Assembly.LoadFrom(Environment.CurrentDirectory + @"\Pointel.Softphone.Voice.dll"); if (assemblyVersion != null) { logger.Debug("*********************************************"); logger.Debug(assemblyVersion.GetName().Name + " : " + assemblyVersion.GetName().Version); logger.Debug("*********************************************"); } } catch (Exception versionException) { logger.Error("Error occurred while getting the version of the SoftPhone library " + versionException.ToString()); } try { //ConnectionSettings.comObject = configObject; //Get Place details Settings.GetInstance().PlaceName = place; Settings.GetInstance().UserName = userName; output = read.ReadPlaceObject(); //Read Person Details //output = read.ReadPersonObject(userName); read.ReadApplicationObject(tServerApplicationName, agentLoginId); } catch (Exception inputException) { logger.Error("Error occurred while login into SoftPhone " + inputException); } //Input Validation CheckException.CheckLoginValues(place, userName); if (output.MessageCode == "200") { //Register with TServer output = connect.ConnectTServer(Settings.GetInstance().PrimaryApplication, Settings.GetInstance().SecondaryApplication); if (output.MessageCode != "200") { logger.Debug("Protocol is not opened, try to connect with server config keys"); if (Settings.GetInstance().VoiceProtocol != null && Settings.GetInstance().VoiceProtocol.State != ChannelState.Opened) { if (!string.IsNullOrEmpty(Settings.GetInstance().PrimaryTServerName)) { logger.Debug("Primary TServer name : " + Settings.GetInstance().PrimaryTServerName); Settings.GetInstance().PrimaryApplication = read.ReadApplicationLevelServerDetails(Settings.GetInstance().PrimaryTServerName); } if (!string.IsNullOrEmpty(Settings.GetInstance().SecondaryTServerName)) { logger.Debug("Secondary TServer name : " + Settings.GetInstance().SecondaryTServerName); Settings.GetInstance().SecondaryApplication = read.ReadApplicationLevelServerDetails(Settings.GetInstance().SecondaryTServerName); if (Settings.GetInstance().PrimaryApplication == null && Settings.GetInstance().SecondaryApplication != null) { logger.Debug("Primary server is not configured, Secondary server is assigned to Primary server"); Settings.GetInstance().PrimaryApplication = Settings.GetInstance().SecondaryApplication; } } else { logger.Debug("secondary application name is not configured"); if (Settings.GetInstance().SecondaryApplication == null) { logger.Debug("Secondary server is not configured, primary server is assigned to secondary server"); Settings.GetInstance().SecondaryApplication = Settings.GetInstance().PrimaryApplication; } } //connect with server names from options tab output = connect.ConnectTServer(Settings.GetInstance().PrimaryApplication, Settings.GetInstance().SecondaryApplication); } else { return(output); } } } return(output); }