Example #1
0
        public override void SetupData(XmlDocument doc)
        {
            XmlNodeList operatorTotals = null;

            try {
                operatorTotals = doc.DocumentElement.SelectNodes("/TotalsStaff/Staff");

                int counter = 0;
                foreach (XmlNode operatorTotalNode in operatorTotals)
                {
                    csvData.Add(new List <string>());

                    csvData[counter].Add(SummaOperatorTotals.GetOperatorId(operatorTotalNode));
                    csvData[counter].Add(SummaOperatorTotals.GetQtySold(operatorTotalNode));
                    csvData[counter].Add(SummaOperatorTotals.GetTotalSales(operatorTotalNode));
                    csvData[counter].Add(SummaOperatorTotals.GetTimestamp(operatorTotalNode));
                    csvData[counter].Add(SummaCommon.GetStoreId(doc));
                    csvData[counter].Add(SummaCommon.GetTillId(doc));

                    counter++;

                    csvLineData.Add(new StringBuilder());
                }
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing operator totals", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Example #2
0
        public override void SetupData(XmlDocument doc)
        {
            XmlNodeList paymentMethodTotals = null;

            try {
                paymentMethodTotals = doc.DocumentElement.SelectNodes("/TotalsPayments/TotalPayment");

                int counter = 0;
                foreach (XmlNode paymentTotalNode in paymentMethodTotals)
                {
                    csvData.Add(new List <string>());

                    csvData[counter].Add(SummaPaymentMethodTotalsCommon.GetPaymentId(paymentTotalNode));
                    csvData[counter].Add(SummaPaymentMethodTotalsCommon.GetTransactionCount(paymentTotalNode));
                    csvData[counter].Add(SummaPaymentMethodTotalsCommon.GetTotal(paymentTotalNode));
                    csvData[counter].Add(SummaPaymentMethodTotalsCommon.GetTimestamp(paymentTotalNode));
                    csvData[counter].Add(SummaCommon.GetStoreId(doc));
                    csvData[counter].Add(SummaCommon.GetTillId(doc));

                    counter++;

                    csvLineData.Add(new StringBuilder());
                }
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing payment method totals", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Example #3
0
        public override void SetupData(System.Xml.XmlDocument doc)
        {
            XmlNodeList discounts = null;

            try {
                discounts = doc.DocumentElement.SelectNodes("/ListCalculated/Calculated");


                int counter = 0;
                foreach (XmlNode discountNode in discounts)
                {
                    csvData.Add(new List <string>());

                    csvData[counter].Add(SummaFixedListCommon.GetFixedListId(discountNode));
                    csvData[counter].Add(SummaFixedListCommon.GetName(discountNode));
                    csvData[counter].Add(SummaCommon.GetStoreId(doc));

                    counter++;
                    csvLineData.Add(new StringBuilder());
                }
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing fixed list", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Example #4
0
        public override void SetupData(XmlDocument doc)
        {
            XmlNodeList productTotals = null;

            try {
                productTotals = doc.DocumentElement.SelectNodes("/TotalsProducts/Product");

                int counter = 0;
                foreach (XmlNode productTotalNode in productTotals)
                {
                    csvData.Add(new List <string>());

                    csvData[counter].Add(SummaProductTotalsCommon.GetProductId(productTotalNode));
                    csvData[counter].Add(SummaProductTotalsCommon.GetQty(productTotalNode));
                    csvData[counter].Add(SummaProductTotalsCommon.GetTotalSales(productTotalNode));
                    csvData[counter].Add(SummaProductTotalsCommon.GetTimestamp(productTotalNode));
                    csvData[counter].Add(SummaCommon.GetStoreId(doc));
                    csvData[counter].Add(SummaCommon.GetTillId(doc));

                    counter++;

                    csvLineData.Add(new StringBuilder());
                }
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing product totals", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Example #5
0
        public override void SetupData(System.Xml.XmlDocument doc)
        {
            XmlNodeList fixedListTotals = null;

            try {
                fixedListTotals = doc.DocumentElement.SelectNodes("/TotalsCalculated/Calculated");

                int counter = 0;
                foreach (XmlNode fixedListTotalNode in fixedListTotals)
                {
                    csvData.Add(new List <string>());

                    csvData[counter].Add(SummaFixedListTotals.GetId(fixedListTotalNode));
                    csvData[counter].Add(SummaFixedListTotals.GetCount(fixedListTotalNode));
                    csvData[counter].Add(SummaFixedListTotals.GetTotalSales(fixedListTotalNode));
                    csvData[counter].Add(SummaFixedListTotals.GetTimestamp(fixedListTotalNode));
                    csvData[counter].Add(SummaCommon.GetStoreId(doc));
                    csvData[counter].Add(SummaCommon.GetTillId(doc));

                    counter++;

                    csvLineData.Add(new StringBuilder());
                }
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing fixed list totals", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Example #6
0
        public override void SetupData(XmlDocument doc)
        {
            XmlNodeList departmentTotals = null;

            try {
                departmentTotals = doc.DocumentElement.SelectNodes("/TotalsCategories/Category");


                int counter = 0;
                foreach (XmlNode departmentTotalNode in departmentTotals)
                {
                    csvData.Add(new List <string>());

                    csvData[counter].Add(SummaDepartmentTotals.GetDepartmentId(departmentTotalNode));
                    csvData[counter].Add(SummaDepartmentTotals.GetQtySold(departmentTotalNode));
                    csvData[counter].Add(SummaDepartmentTotals.GetTotalSales(departmentTotalNode));
                    csvData[counter].Add(SummaDepartmentTotals.GetTimestamp(departmentTotalNode));
                    csvData[counter].Add(SummaCommon.GetStoreId(doc));
                    csvData[counter].Add(SummaCommon.GetTillId(doc));

                    counter++;

                    csvLineData.Add(new StringBuilder());
                }
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing department totals", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Example #7
0
        public override void SetupData(System.Xml.XmlDocument doc)
        {
            XmlNodeList groupTotals = null;

            try {
                groupTotals = doc.DocumentElement.SelectNodes("/TotalsGroups/Group");

                int counter = 0;
                foreach (XmlNode groupTotalNode in groupTotals)
                {
                    csvData.Add(new List <string>());

                    csvData[counter].Add(SummaGroupTotals.GetGroupId(groupTotalNode));
                    csvData[counter].Add(SummaGroupTotals.GetQtySold(groupTotalNode));
                    csvData[counter].Add(SummaGroupTotals.GetTotalSales(groupTotalNode));
                    csvData[counter].Add(SummaGroupTotals.GetTimestamp(groupTotalNode));
                    csvData[counter].Add(SummaCommon.GetStoreId(doc));
                    csvData[counter].Add(SummaCommon.GetTillId(doc));

                    counter++;

                    csvLineData.Add(new StringBuilder());
                }
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing group totals", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Example #8
0
        public override void SetupData(XmlDocument doc)
        {
            XmlNodeList hourTotals = null;

            try {
                hourTotals = doc.DocumentElement.SelectNodes("/TotalsHourlySales/Hour");

                int counter = 0;
                foreach (XmlNode hourTotalNode in hourTotals)
                {
                    csvData.Add(new List <string>());

                    csvData[counter].Add(SummaHourlyTotalsCommon.GetHourId(hourTotalNode));
                    csvData[counter].Add(SummaHourlyTotalsCommon.GetTransQty(hourTotalNode));
                    csvData[counter].Add(SummaHourlyTotalsCommon.GetHourlyTotal(hourTotalNode));
                    csvData[counter].Add(SummaHourlyTotalsCommon.GetDateTime(hourTotalNode));
                    csvData[counter].Add(SummaCommon.GetStoreId(doc));
                    csvData[counter].Add(SummaCommon.GetTillId(doc));

                    counter++;

                    csvLineData.Add(new StringBuilder());
                }
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing hourly sales", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="doc"></param>
        /// <returns></returns>
        public static string GetDateStamp(XmlDocument doc)
        {
            XmlNode receiptNode = null;

            try {
                receiptNode = doc.DocumentElement.SelectSingleNode("/Transaction/Receipt");
            }
            catch (XPathException xpe) {
                throw xpe;
            }

            return(SummaCommon.GetSummaFormattedTimestamp(receiptNode.Attributes["Date"].Value,
                                                          receiptNode.Attributes["Time"].Value));
        }
Example #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="doc"></param>
        /// <returns></returns>
        public static string GetProductId(XmlNode node)
        {
            if (node.Attributes["Code"].Value == String.Empty)
            {
                StringBuilder b = new StringBuilder();
                b.Append(node.Attributes["Menu"].Value);
                b.Append(node.Attributes["Course"].Value);
                b.Append(node.Attributes["Item"].Value);
                b.Append(node.Attributes["Size"].Value);

                return(SummaCommon.StringToUnsignedHashValue(b.ToString()));
            }
            else
            {
                return(node.Attributes["Code"].Value);
            }
        }
Example #11
0
 internal static string GetTimestamp(XmlNode productTotalNode)
 {
     return(SummaCommon.GetSummaFormattedTimestamp(productTotalNode.Attributes["Date"].Value,
                                                   productTotalNode.Attributes["Time"].Value));
 }
Example #12
0
 internal static string GetGroupId(XmlNode groupTotalNode)
 {
     return(SummaCommon.StringToUnsignedHashValue(groupTotalNode.Attributes["Name"].Value));
 }
Example #13
0
 internal static string GetDepartmentId(XmlNode departmentTotalNode)
 {
     return(SummaCommon.StringToUnsignedHashValue(departmentTotalNode.Attributes["Name"].Value));
 }
Example #14
0
 internal static string GetProductDepartmentId(XmlNode sizeNode)
 {
     return(SummaCommon.StringToUnsignedHashValue(sizeNode.Attributes["CategoryName"].Value));
 }
Example #15
0
 internal static string GetProductGroupId(XmlNode sizeNode)
 {
     return(SummaCommon.StringToUnsignedHashValue(sizeNode.Attributes["GroupName"].Value));
 }
Example #16
0
 /// <summary>
 /// Return the Name as the Id converted to a uint.
 /// </summary>
 /// <param name="paymentTypeNode"></param>
 /// <returns></returns>
 internal static string GetPaymentTypeId(XmlNode paymentTypeNode)
 {
     return(SummaCommon.StringToUnsignedHashValue(paymentTypeNode.Attributes["Name"].Value));
 }
Example #17
0
        /// <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();
            }
        }