Beispiel #1
0
        /// <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));
        }
Beispiel #2
0
        public Summa(string outputFilePath, string outputFilePathIsAccessDoor, bool doorAccessFlag)
        {
            _outputFilePath             = outputFilePath;
            _outputFilePathIsAccessDoor = outputFilePathIsAccessDoor;
            _isDoorAccess = doorAccessFlag;


            XmlDocument doc = null;

            try
            {
                doc = new XmlDocument();

                //XmlTextReader reader = new XmlTextReader(Application.StartupPath + System.IO.Path.DirectorySeparatorChar + @"summaIdMap.xml");
                //XmlTextReader reader = new XmlTextReader( StartupPath.text + System.IO.Path.DirectorySeparatorChar + @"summaIdMap.xml" );

                XmlTextReader reader = new XmlTextReader(_singletonConfigFile.ConfigPath);

                reader.Read();
                doc.Load(reader);
                reader.Close();

                Summa.BuildSummaIdMap(doc);
            }
            catch (System.Xml.XmlException xe)
            {
                _errorLevel     = FileLogger.LogErrorLevel.SiteIDMapFailed;
                _errorLevelFile = FileLogger.LogErrorLevelFile.ConfigFile;

                _errorStr       = @"Error loading Summa site id map file (problem with XML format?)";
                _errorStrDetail = @"";

                _singletonLogger.LogException(_errorLevel, _errorLevelFile, _errorStr, xe);
            }
            catch (Exception e)
            {
                _errorLevel     = FileLogger.LogErrorLevel.SiteIDMapFailed;
                _errorLevelFile = FileLogger.LogErrorLevelFile.ConfigFile;

                _errorStr = @"Error loading Summa site id map file";

                _singletonLogger.LogException(_errorLevel, _errorLevelFile, _errorStr, e);
            }
        }
Beispiel #3
0
        /// <summary>Starts communication with client.</summary>
        public void Process(string Transaction, string outputFilePath, string outputFilePathIsAccessDoor, bool doorAccessFlag)
        {
            StreamWriter streamWriter = new StreamWriter(NetStream);

            try
            {
                // All writes will be done immediately and not cached:
                streamWriter.AutoFlush = true;

                // Start loop and handle commands:
                // Convert to an xml object.
                XmlDocument xmlData = new XmlDocument();
                xmlData.LoadXml(Transaction);

                // USED TO DEBUG. Save the xmal file reveived from Menumate
                //xmlData.Save(string.Format(@"{0}XMLData{1}.xml", @".\archive\", Transaction.GetHashCode()));

                string messageId = SummaCommon.GetMessageId(xmlData);

                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", "");
                            string      hResponse   = ResponseWithHeader(xmlResponse.OuterXml);
                            streamWriter.WriteLine(hResponse);

                            // Process the xml object.
                            _singletonLogger.Log("XML Response : " + hResponse);
                        }
                        else
                        {
                            streamWriter.WriteLine(ResponseWithHeader(BuildResponse("1", "NAK", "Unknown Request Type").OuterXml));

                            _singletonLogger.LogError(FileLogger.LogErrorLevel.InternalXMLError,
                                                      FileLogger.LogErrorLevelFile.RequestXMLFile,
                                                      @"Error occured: Not an xml Document", Transaction);

                            _singletonLogger.LogWarning(@"Summa failed processing a Menumate XML file.  See the log file for details");
                        }
                    }
                    else
                    {
                        // create instance of summa interface
                        IPOSMessage summa = new Summa(outputFilePath, outputFilePathIsAccessDoor, doorAccessFlag);

                        try
                        {
                            summa.Process(xmlData);
                            streamWriter.WriteLine(ResponseWithHeader(BuildResponse(messageId, "ACK", "").OuterXml));

                            _singletonLogger.Log("Transaction OK, id = " + messageId);
                        }
                        catch (SummaException se)
                        {
                            // fail
                            streamWriter.WriteLine(ResponseWithHeader(BuildResponse(messageId, "NAK", se.Message).OuterXml));

                            //_singletonLogger.LogError("Summa returned an error, " + se.ToString());
                            //_singletonLogger.LogException(@"Failed to process an XML file", se);

                            //:::::::::::::::::::::::::::::::::::::::::::::::::::::::
                            // Save the document to a file and auto-indent the output.
                            //:::::::::::::::::::::::::::::::::::::::::::::::::::::::
                            SaveXML.SaveInFolder(@"XML Failed", xmlData);
                        }
                        catch (XPathException xpe)
                        {
                            // fail
                            streamWriter.WriteLine(ResponseWithHeader(BuildResponse(messageId, "NAK", xpe.Message).OuterXml));

                            //_singletonLogger.LogError("Summa returned an error, " + xpe.ToString());
                            //_singletonLogger.LogException(@"Failed to process an XML file", xpe);

                            //:::::::::::::::::::::::::::::::::::::::::::::::::::::::
                            // Save the document to a file and auto-indent the output.
                            //:::::::::::::::::::::::::::::::::::::::::::::::::::::::
                            SaveXML.SaveInFolder(@"XML Failed", xmlData);
                        }
                    }
                }
                else
                {
                    string message = "Not an XML Document";
                    streamWriter.WriteLine(ResponseWithHeader(BuildResponse("1", "NAK", message).OuterXml));

                    _singletonLogger.LogError(FileLogger.LogErrorLevel.InternalXMLError,
                                              FileLogger.LogErrorLevelFile.UnknownXMLFile,
                                              "Not an XML Document: ", Transaction);

                    _singletonLogger.LogWarning(@"Summa failed processing a Menumate XML file.  See the log file for details");


                    //logger.Error("Error occured: " + message);

                    //:::::::::::::::::::::::::::::::::::::::::::::::::::::::
                    // Save the document to a file and auto-indent the output.
                    //:::::::::::::::::::::::::::::::::::::::::::::::::::::::
                    SaveXML.SaveInFolder(@"XML Failed", xmlData);
                }
            }
            catch (Exception ex)
            {
                // Generate a negitive xml responce here.
                streamWriter.WriteLine(ResponseWithHeader(BuildResponse("1", "NAK", ex.Message).OuterXml));

                _singletonLogger.LogError(FileLogger.LogErrorLevel.InternalXMLError,
                                          FileLogger.LogErrorLevelFile.UnknownXMLFile,
                                          string.Format(@"An Exception occured: {0}", ex.Message),
                                          Transaction);

                _singletonLogger.LogWarning(@"Summa failed processing a Menumate XML file.  See the log file for details");

                //_singletonLogger.LogError(@"Raw Data Received: " + Transaction);

                //logger.Error("An Exception occured: " + ex.ToString());
                //logger.Error("Raw Data Received: " + Transaction);

                //:::::::::::::::::::::::::::::::::::::::::::::::::::::::
                // Save Transaction string.
                //:::::::::::::::::::::::::::::::::::::::::::::::::::::::
                SaveXML.SaveInFolder(@"XML Failed", Transaction);
            }
            finally
            {
                streamWriter.Close();
                streamWriter.Dispose();
            }
        }
Beispiel #4
0
 internal static string GetStoreId(XmlDocument doc)
 {
     return(Summa.GetSummaSiteId(doc.DocumentElement.Attributes["SiteID"].Value));
 }
Beispiel #5
0
        internal static string GetStoreId(XmlDocument doc)
        {
            Summa.ErrorLevelFile = FileLogger.LogErrorLevelFile.TransactionXMLFile;

            return(Summa.GetSummaSiteId(doc.DocumentElement.Attributes["SiteID"].Value));
        }
Beispiel #6
0
 private string GetStoreId(XmlNode customerNode)
 {
     return(Summa.GetSummaSiteId(customerNode.Attributes["SiteID"].Value));
 }