/// <summary> /// This reads XML from a string and returns a new instance with that information. /// </summary> /// <param name="xml">The xml string containing the customer.</param> /// <returns>An instance of a account class</returns> public static object ReadCustomer(string xml) { StringReader reader = null; try { CustomerProviderCustomerRecord local = new CustomerProviderCustomerRecord(); XmlSerializer serializer = new XmlSerializer(local.GetType()); reader = new StringReader(xml); local = serializer.Deserialize(reader) as CustomerProviderCustomerRecord; reader.Close(); return(local); } catch // ( Exception exp ) // when needed for debugging { if (reader != null) { reader.Close(); } return(null); } }
/// <summary> /// This is the general method to handle the message and send along as appopriate /// </summary> /// <param name="channel">The serialized channel information object.</param> /// <returns>A message the service wishes to return</returns> public string SendMessage(string channel) { ChannelInformation channelInformation = null; try { ChannelInformation ci = (ChannelInformation)GeneralFunctions.Deserialize <ChannelInformation>(channel); if (ci == null) { Logging.Error("MailChannel", "ChannelInformation is null"); } // Call out to get data CustomerClient customer = new CustomerClient(); CustomerProviderCustomerRecord custrec = customer.GetCustomerByID(ci.CustomerID); customer.Close(); ci.City = custrec.City; // = "Redmond"; ci.Country = custrec.Country; // = "USA"; ci.CustomerID = custrec.CustomerID; // = "1"; ci.FirstName = custrec.FirstName; // = "Maeve"; ci.LastName = custrec.LastName; // = "Elizabeth"; ci.PhoneHome = custrec.PhoneHome; // = "4252210456"; ci.PhoneMobile = custrec.PhoneMobile; // = "4252210456"; ci.PhoneWork = custrec.PhoneWork; // = "4252210456"; ci.State = custrec.State; // = "WA"; ci.Street = custrec.Street; // = "Rainy Street"; ci.ZipCode = custrec.ZipCode; // = "98008"; AgentClientData agent = RetrieveAgentClient(ci.Agent); Uri toUri = new Uri(String.Format("http://{0}:{1}/", agent.IPAddress.Trim(), agent.Port.Trim())); EndpointAddress address = new EndpointAddress(toUri.ToString()); string retValue = string.Empty; MultichannelSubsystemClient mcssclient = new MultichannelSubsystemClient(); try { mcssclient.Endpoint.Address = address; mcssclient.ClientCredentials.Windows.ClientCredential = AgentCredentialUtilities.GetCurrentCredential(); retValue = mcssclient.Call(GeneralFunctions.Serialize <ChannelInformation>(ci)); } catch (Exception ex) { Console.Write(ex.Message); } } catch (Exception ex) { Logging.Error(this.ToString(), ex.Message); return(ex.Message); } return(GeneralFunctions.Serialize(channelInformation)); } // SendMessage
public AgentDesktopSession(string name, int callID, CustomerProviderCustomerRecord customer, Guid sessionID) : base(name, callID, sessionID) { this.customer = customer; }
/// <summary> /// Restores the state of a session from the passed XML. /// </summary> /// <param name="sessionInfoXml"></param> /// <returns>true if this is an active session, false if not</returns> public override bool Restore(string sessionInfoXml) { XmlDocument doc = new XmlDocument(); XmlNode node; bool active = false; // Right now we only permit a single transfer record doc.LoadXml(sessionInfoXml); // Get the name and presence state of the saved session node = doc.SelectSingleNode("Session"); XmlAttribute attr = node.Attributes["name"]; if (attr != null) { this.Name = attr.Value; } attr = node.Attributes["presence"]; if (attr != null) { this.PresenceState = Convert.ToInt32(attr.Value); } // Return true if this was an active session attr = node.Attributes["active"]; if (attr != null) { active = Convert.ToBoolean(attr.Value); } CustomerProviderCustomerRecord c = null; node = doc.SelectSingleNode("descendant::Customer"); if (node != null && (this.customer == null || this.customer.CustomerID == String.Empty)) { c = ReadCustomer(node.InnerXml) as CustomerProviderCustomerRecord; if (c != null && c.CustomerID != String.Empty) { customer = c; } } // Get workflow information, if any node = doc.SelectSingleNode("descendant::WorkflowData"); if (node != null) { //Workflow = node.InnerXml.Trim(); // Workflow Driven Implementation: // Add the <restoredWorkflow/> tag to the workflow data so that // Workflow control recognise this pending workflow as restored one. XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(node.InnerXml.Trim()); XmlElement restoredWrkflNode = xdoc.CreateElement("restoredWorkflow"); xdoc.DocumentElement.AppendChild(restoredWrkflNode); Workflow = xdoc.OuterXml; } // Get the saved application state and pass it to the current apps XmlNodeList nodeList = doc.SelectNodes("descendant::Application"); if (nodeList != null) { foreach (XmlNode appNode in nodeList) { XmlNode stateNode = appNode.SelectSingleNode("State"); if (stateNode != null) { XmlAttribute id = appNode.Attributes["id"]; IHostedApplication app = GetApplication(Convert.ToInt32(id.Value)); if (app != null) { app.SetStateData(stateNode.InnerXml); } } } } // Get the context information, if any // This context wraps the Ccf Conext, hence the "Context" // tag name and not "CcfContext" node = doc.SelectSingleNode("descendant::Context"); if (node != null) { Context context = new Context(); context.SetContext(node.InnerXml.Trim()); this.AppHost.SetContext(context); } //added to ensure that when actions are executed //after the correct context is set. if (customer.CustomerID != String.Empty) { this.AppHost.ExecuteApplicationState(); } // Select the app the transferring agent was looking at node = doc.SelectSingleNode("descendant::CurrentApplication"); if (node != null) { int appID = Convert.ToInt32(node.InnerText); this.FocusedApplication = GetApplication(appID); } //AUDIT TRAIL if (null == customer) { LogData.CustomerID = String.Empty; } else { LogData.CustomerID = customer.CustomerID; } if (this.FocusedApplication != null) { LogData.ApplicationID = this.FocusedApplication.ApplicationID; } //AUDIT TRAIL END return(active); }