/// <summary> /// Determines which converter rule we need based on a node within the incoming AcordLife file. /// </summary> /// <param name="TXLife">The TXLife incoming file.</param> /// <returns>The converter rule that should be run, based on the incoming file.</returns> private ConverterRule GetConverterRule(string TXLife) { XmlDocument xmlDoc = new XmlDocument(); try { xmlDoc.LoadXml(TXLife); } catch (Exception ex) { internalErrors.Add($"Could not read the xml file to determine how to map for conversion, the error was, \"{ex.Message}\"."); publicErrors.Add($"Could not read the xml file to validate the incoming account."); } string companyName = string.Empty; XmlNodeList xnl = null; //grab the userloginname from the file and let's get our file like this. xnl = xmlDoc.GetElementsByTagName("UserLoginName"); if (xnl != null && xnl.Count > 0 && !string.IsNullOrEmpty(xnl[0].InnerText)) { companyName = xnl[0].InnerText; } ConverterRule p = null; if (!string.IsNullOrEmpty(companyName)) { //now, process the client rules from the login name in the incoming request. p = ProcessClientRules(companyName.Trim()); } return(p); }
private string RunConversion(string xmlContent, ConverterRule cc) { string parms = xmlContent; object o = null; try { o = Acord60Mins.Reflection.RunMethod(ConvertersDLLPath, cc.Class.Trim(), "Process", parms); return((string)o); } catch (Exception ex) { internalErrors.Add($"Could not convert, running the converter failed, the error was, \"{ex.Message}\"."); publicErrors.Add("We were unable to process the transaction, conversion failed."); } return(xmlContent); }
private ConverterRule ProcessClientRules(string AccountName) { ConverterRules cc = null; try { cc = ConverterRules.NewFromFile(RulesPath); } catch (Exception ex) { internalErrors.Add($"Could not load converter rules file, the error was, \"{ex.Message}\"."); publicErrors.Add($"Could not get internal rules to convert the file."); } ConverterRule crr = cc.ConverterRule.Where(t => String.Equals(t.Name, AccountName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); return(crr); }
/// <summary> /// The client conversion is processed based on the converterrules.xml file /// and the conversion method is run through reflection. /// </summary> /// <param name="txLifeRequest"></param> /// <returns></returns> public string ProcessClientConverion(string txLifeRequest) { //grab the converter rule from the converterrules.xml file and //run the conversion from the converters.dll file. ConverterRule converterRule = GetConverterRule(txLifeRequest); //Did we get a rule back? If not, carry on, nothing to see here. if (!string.IsNullOrEmpty(converterRule?.Class)) { //if we did get a converter rule back, run it here. txLifeRequest = RunConversion(txLifeRequest, converterRule); } //send back our txlife post conversion. return(txLifeRequest); }