/// <summary> /// /// </summary> /// <param name="doc"></param> /// <returns></returns> public static string GetStoreId(XmlDocument doc) { XmlNode terminalNode = null; try { terminalNode = doc.DocumentElement.SelectSingleNode("/Transaction/Terminal"); } catch (XPathException xpe) { throw xpe; } return(Summa.GetSummaSiteId(terminalNode.Attributes["SiteID"].Value)); }
public static string GetSummaSiteId(string mmSiteId) { if (_summaSiteIdMap == null) { XmlDocument doc = null; try { doc = new XmlDocument(); XmlTextReader reader = new XmlTextReader(Application.StartupPath + System.IO.Path.DirectorySeparatorChar + @"summaIdMap.xml"); reader.Read(); doc.Load(reader); Summa.BuildSummaIdMap(doc); } catch (Exception e) { Console.WriteLine("Error loading Summa site id map file: {0}", e.ToString()); //throw; } } string summaSiteId; try { if (_summaSiteIdMap != null) { summaSiteId = _summaSiteIdMap[mmSiteId]; } else { summaSiteId = mmSiteId; logger.Log(LogLevel.Error, "Summa site id map has not been initialised (missing id map file?), returning original value"); } } catch (KeyNotFoundException knfe) { summaSiteId = mmSiteId; logger.LogException(LogLevel.Error, "Menumate site id not found, returning original value", knfe); } return(summaSiteId); }
internal static string GetStoreId(XmlDocument doc) { return(Summa.GetSummaSiteId(doc.DocumentElement.Attributes["SiteID"].Value)); }
/// <summary>Starts communication with client.</summary> public void Process(string Transaction, string outputFilePath) { StreamWriter streamWriter = new StreamWriter(NetStream); try { // All writes will be done immediately and not cached: streamWriter.AutoFlush = true; // Start loop and handle commands: //logger.Debug("XML Received :" + Transaction); // Convert to an xml object. XmlDocument xmlData = new XmlDocument(); // TODO exception handling!! xmlData.LoadXml(Transaction); string messageId = SummaCommon.GetMessageId(xmlData); //logger.Info("Creating output files in " + outputFilePath); if (xmlData.FirstChild.Name == "xml") { if (xmlData.DocumentElement.Name == "Request") { if (xmlData.DocumentElement.Attributes.GetNamedItem("Type").Value == "Status") { // Send the xml responce. XmlDocument xmlResponse = BuildResponse(messageId, "ACK", ""); streamWriter.WriteLine(xmlResponse.OuterXml); // Process the xml object. logger.Debug("XML Response : " + xmlResponse.OuterXml); } else { streamWriter.WriteLine(BuildResponse("1", "NAK", "Unknown Request Type").OuterXml); logger.Error("Error occured: Not an xml Document"); } } else { // create instance of summa interface IPOSMessage summa = new Summa(outputFilePath); try { summa.Process(xmlData); streamWriter.WriteLine(BuildResponse(messageId, "ACK", "").OuterXml); logger.Info("Transaction OK, id = " + messageId); } catch (SummaException se) { // fail streamWriter.WriteLine(BuildResponse(messageId, "NAK", se.Message).OuterXml); Summa.logger.Error("Summa returned an error, " + se.ToString()); Summa.failedTxLogger.Error(se.Data); } } } else { string message = "Not an XML Document"; streamWriter.WriteLine(BuildResponse("1", "NAK", message).OuterXml); logger.Error("Error occured: " + message); } } catch (Exception ex) { // Generate a negitive xml responce here. streamWriter.WriteLine(BuildResponse("1", "NAK", ex.Message).OuterXml); logger.Error("An Exception occured: " + ex.ToString()); logger.Error("Raw Data Received: " + Transaction); } finally { streamWriter.Close(); streamWriter.Dispose(); } }
private string GetStoreId(XmlNode customerNode) { return(Summa.GetSummaSiteId(customerNode.Attributes["SiteID"].Value)); }