public string GetResponseFieldContents(AgentProperties agentProperties, ContactProperties contactProperties, ContactInteractionProperties interactionProperties, string renderText) { string renderedText = string.Empty; OutputValues output = OutputValues.GetInstance(); output = RequestGetFieldCodes.GetRenderFieldCodes(agentProperties, contactProperties, interactionProperties, renderText); if (output.IContactMessage != null) { if (output.IContactMessage.Name == EventRenderFieldCodes.MessageName) { renderedText = ((EventRenderFieldCodes)output.IContactMessage).Text; } else if (output.IContactMessage.Name == EventError.MessageName) { renderedText = ((EventError)output.IContactMessage).ErrorDescription; } } return(renderedText); }
public static OutputValues GetRenderFieldCodes(AgentProperties agentProperties, ContactProperties contactProperties, ContactInteractionProperties interactionProperties, string renderText) { Pointel.Logger.Core.ILog logger = Pointel.Logger.Core.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "AID"); logger.Debug("RequestGetFieldCodes class GetRenderFieldCodes() : Entry"); OutputValues output = OutputValues.GetInstance(); try { RequestRenderFieldCodes renderFieldCodes = RequestRenderFieldCodes.Create(); if (interactionProperties != null) { renderFieldCodes.Interaction = interactionProperties; logger.Info("Interaction Id : " + interactionProperties.Id); logger.Info("From Address : " + interactionProperties.FromAddress); logger.Info("To Address : " + interactionProperties.ToAddress); logger.Info("Subject : " + interactionProperties.Subject); } else { logger.Warn("Interaction properties is null"); } if (agentProperties != null) { renderFieldCodes.Agent = agentProperties; logger.Info("Agent First Name : " + agentProperties.FirstName); logger.Info("Agent Last Name : " + agentProperties.LastName); logger.Info("Agent Full Name : " + agentProperties.FullName); } logger.Warn("Agent properties is null"); if (contactProperties != null) { renderFieldCodes.Contact = contactProperties; logger.Info("Contact Id : " + contactProperties.Id); logger.Info("Contact Title : " + contactProperties.Title); logger.Info("Contact First Name : " + contactProperties.FirstName); logger.Info("Contact Last Name : " + contactProperties.LastName); logger.Info("Contact Full Name : " + contactProperties.FullName); logger.Info("Contact Primary Phone Number : " + contactProperties.PrimaryPhoneNumber); logger.Info("Contact Primary Email Address : " + contactProperties.PrimaryEmailAddress); } logger.Warn("Contact properties is null."); if (!string.IsNullOrEmpty(renderText)) { renderFieldCodes.Text = renderText; logger.Info("Rendering Text : " + renderText); } logger.Warn("Rendering text is null or empty."); if (Settings.UCSProtocol != null && Settings.UCSProtocol.State == ChannelState.Opened) { IMessage response = Settings.UCSProtocol.Request(renderFieldCodes); if (response != null) { output.MessageCode = "200"; output.Message = "Rendering text Successful"; output.IContactMessage = response; } else { output.MessageCode = "2001"; output.Message = "Rendering text UnSuccessful"; output.IContactMessage = null; } } else { output.IContactMessage = null; output.MessageCode = "2001"; output.Message = "Universal Contact Server protocol is Null or Closed"; logger.Warn("GetRenderFieldCodes() : Universal Contact Server protocol is Null or channel is closed"); } } catch (Exception ex) { logger.Error("Error while getting data from standard response filed codes : " + (ex.InnerException == null ? ex.Message : ex.InnerException.ToString())); } logger.Debug("RequestGetFieldCodes class GetRenderFieldCodes() : Exit"); return(output); }
/// <summary> /// Gets the result of a ContactType on a set of PhysicalAttributes. /// </summary> /// <param name="attackerPhysAttributes">The attacker's set of PhysicalAttributes.</param> /// <param name="contactType">The ContactType performed.</param> /// <param name="contactProperty">The ContactProperty of the contact.</param> /// <param name="victimPaybacks">The victim's set of Paybacks to test against.</param> /// <param name="attackerContactExceptions">The attacker's contact exceptions; the set PhysicalAttributes to ignore.</param> /// <returns>A ContactResultInfo of the interaction.</returns> public static ContactResultInfo GetContactResult(IList <PhysicalAttributes> attackerPhysAttributes, ContactTypes contactType, ContactProperties contactProperty, IList <PaybackHolder> victimPaybacks, params PhysicalAttributes[] attackerContactExceptions) { //Return the default value if (victimPaybacks == null || victimPaybacks.Count == 0) { return(ContactResultInfo.Default); } /*0. Initialize a list of Paybacks, called PaybackList * 1. Go through all of the Victim's Paybacks * 2. Check if the Payback's PaybackContacts contains the ContactType of the attack * 3a. If so, check if the Attacker has any ContactExceptions for the Payback's PhysAttribute * 4a. If so, ignore it and continue * 4b. If not, check if the Payback covers any of the attack's ContactProperties * 5a. If so, check if the Attacker has the same PhysAttribute as the Payback's * 6a. If so, examine the SamePhysAttrResult and go to 7a * 6b. If not, examine the PaybackContactResult and go to 7a * 7a. If the ContactResult is a Failure, return that Payback value * 7b. If the ContactResult is a Success, ignore it and continue * 7c. If the ContactResult is a PartialSuccess, add it to PaybackList and continue * 4c. If not, ignore it and continue * 3b. If not, continue */ //The Paybacks that will be combined List <PaybackHolder> combinedPaybacks = new List <PaybackHolder>(); //Look through the Paybacks for (int i = 0; i < victimPaybacks.Count; i++) { PaybackHolder payback = victimPaybacks[i]; //Check if the Payback covers this ContactType if (payback.PaybackContacts != null && payback.PaybackContacts.Contains(contactType) == true) { //If there are contact exceptions for this PhysicalAttribute, ignore this Payback if (attackerContactExceptions.Contains(payback.PhysAttribute) == true) { continue; } //Check if the Payback covers the ContactProperty if (payback.ContactProperties != null && payback.ContactProperties.Contains(contactProperty) == false) { continue; } ContactResult contactResult = payback.PaybackContactResult; //Check if the Attacker has the PhysicalAttribute the Payback is associated with, and adjust the ContactResult if so if (attackerPhysAttributes.Contains(payback.PhysAttribute) == true) { contactResult = payback.SamePhysAttrResult; } //If a Failure, use this Payback if (contactResult == ContactResult.Failure) { return(new ContactResultInfo(payback, contactResult)); } //If a PartialSuccess, add it to the list else if (contactResult == ContactResult.PartialSuccess) { combinedPaybacks.Add(payback); } } } //Combine all the Paybacks in the list PaybackHolder finalPayback = PaybackHolder.CombinePaybacks(combinedPaybacks); return(new ContactResultInfo(finalPayback, finalPayback.PaybackContactResult)); }