Exemple #1
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;
            }
        }
Exemple #2
0
        public override void SetupData(System.Xml.XmlDocument doc)
        {
            XmlNodeList payments = null;

            try {
                payments = doc.DocumentElement.SelectNodes("/ListPaymentTypes/Payment");

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

                    csvData[counter].Add(SummaPaymentTypeCommon.GetPaymentTypeId(paymentTypeNode));
                    csvData[counter].Add(SummaPaymentTypeCommon.GetPaymentTypeName(paymentTypeNode));
                    csvData[counter].Add(SummaPaymentTypeCommon.GetStoreId(doc));

                    counter++;
                    csvLineData.Add(new StringBuilder());
                }
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing payment method types", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Exemple #3
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;
            }
        }
Exemple #4
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;
            }
        }
Exemple #5
0
        public override void SetupData(XmlDocument doc)
        {
            XmlNodeList groups = null;

            try {
                groups = doc.DocumentElement.SelectNodes("/ListGroups/Group");

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

                    csvData[counter].Add(SummaGroupsCommon.GetGroupId(groupNode));
                    csvData[counter].Add(SummaGroupsCommon.GetGroupName(groupNode));
                    csvData[counter].Add(SummaGroupsCommon.GetStoreId(doc));

                    counter++;

                    csvLineData.Add(new StringBuilder());
                }
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing groups", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Exemple #6
0
        /// <summary>
        /// Deconstruct xml document and populate internal data fields
        /// </summary>
        /// <param name="doc"></param>
        public override void SetupData(XmlDocument doc)
        {
            try {
                csvData.Add(new List <string>());
                csvLineData.Add(new StringBuilder());

                csvData[0].Add(SummaTransactionCommon.GetTransactionId(doc));
                csvData[0].Add(SummaTransactionCommon.GetTransactionType(doc));
                csvData[0].Add(SummaTransactionCommon.GetTerminalID(doc));
                csvData[0].Add(SummaTransactionCommon.GetCustomerId(doc));
                csvData[0].Add(SummaTransactionCommon.GetSalesTotal(doc));
                csvData[0].Add(SummaTransactionCommon.GetDateStamp(doc));
                csvData[0].Add(SummaTransactionCommon.GetPromotionId(doc));
                csvData[0].Add(SummaTransactionCommon.GetOperatorId(doc));
                csvData[0].Add(SummaTransactionCommon.GetExtra1(doc));
                csvData[0].Add(SummaTransactionCommon.GetExtra2(doc));
                csvData[0].Add(SummaTransactionCommon.GetExtra3(doc));
                csvData[0].Add(SummaTransactionCommon.GetStoreId(doc));
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing transaction", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Exemple #7
0
        /// <summary>
        /// Setup internal data values for each product.
        /// </summary>
        /// <param name="doc"></param>
        public override void SetupData(XmlDocument doc) {

            XmlNodeList products = null;
            try {
                products = doc.DocumentElement.SelectNodes("/Transaction/Receipt/Product");

                int counter = 0;
                foreach (XmlNode productNode in products) {

                    csvData.Add(new List<string>());
                    csvData[counter].Add(SummaTransactionCommon.GetTransactionId(doc));
                    csvData[counter].Add(SummaTransactionProductCommon.GetProductId(productNode));
                    csvData[counter].Add(SummaTransactionProductCommon.GetQuantity(productNode));
                    csvData[counter].Add(SummaTransactionProductCommon.GetUnitPrice(productNode));
                    csvData[counter].Add(SummaTransactionProductCommon.GetDiscount(productNode));
                    csvData[counter].Add(SummaTransactionProductCommon.GetPromotionId(productNode));
                    csvData[counter].Add(SummaTransactionProductCommon.GetBarcode(productNode));
                    csvData[counter].Add(SummaTransactionCommon.GetStoreId(doc));

                    counter++;

                    csvLineData.Add(new StringBuilder());
                }
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing transaction detail", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Exemple #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;
            }
        }
        public override void SetupData(XmlDocument doc)
        {
            XmlNodeList methods = null;

            try {
                methods = doc.DocumentElement.SelectNodes("/Transaction/Receipt/Payment");

                int counter = 0;
                foreach (XmlNode paymentNode in methods)
                {
                    csvData.Add(new List <string>());
                    csvData[counter].Add(SummaTransactionCommon.GetTransactionId(doc));
                    csvData[counter].Add(SummaPaymentMethodsCommon.GetPaymentId(paymentNode));
                    csvData[counter].Add(SummaPaymentMethodsCommon.GetCardNumber(paymentNode));
                    csvData[counter].Add(SummaPaymentMethodsCommon.GetSalesValue(paymentNode));
                    csvData[counter].Add(SummaTransactionCommon.GetStoreId(doc));

                    counter++;

                    csvLineData.Add(new StringBuilder());
                }
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing transaction payment methods", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Exemple #10
0
        public override void SetupData(System.Xml.XmlDocument doc)
        {
            XmlNodeList operators = null;

            try {
                operators = doc.DocumentElement.SelectNodes("/ListStaff/Staff");

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

                    csvData[counter].Add(SummaOperatorsCommon.GetOperatorId(operatorNode));
                    csvData[counter].Add(SummaOperatorsCommon.GetOperatorName(operatorNode));
                    csvData[counter].Add(SummaOperatorsCommon.GetStoreId(doc));

                    counter++;
                    csvLineData.Add(new StringBuilder());
                }
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing operators", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Exemple #11
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;
            }
        }
Exemple #12
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;
            }
        }
Exemple #13
0
        public override void SetupData(System.Xml.XmlDocument doc)
        {
            XmlNodeList inAndOuts = null;

            try {
                inAndOuts = doc.DocumentElement.SelectNodes("/ListRoster/TimeClock");

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

                    csvData[counter].Add(GetEmployeeId(inAndOutNode));
                    csvData[counter].Add(GetStartHour1(inAndOutNode));
                    csvData[counter].Add(GetEndHour1(inAndOutNode));
                    csvData[counter].Add(GetStartHour2(inAndOutNode));
                    csvData[counter].Add(GetEndHour2(inAndOutNode));
                    csvData[counter].Add(GetBreak(inAndOutNode));
                    csvData[counter].Add(GetRosterDate(inAndOutNode));
                    csvData[counter].Add(GetStoreId(doc));

                    counter++;
                    csvLineData.Add(new StringBuilder());
                }
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing roster", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Exemple #14
0
        public override void SetupData(System.Xml.XmlDocument doc)
        {
            XmlNodeList departments = null;

            try {
                departments = doc.DocumentElement.SelectNodes("/ListCategories/Category");

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

                    csvData[counter].Add(SummaDepartmentsCommon.GetDepartmentId(categoryNode));
                    csvData[counter].Add(SummaDepartmentsCommon.GetDepartmentName(categoryNode));
                    csvData[counter].Add(SummaDepartmentsCommon.GetDepartmentGroupId(categoryNode));
                    csvData[counter].Add(SummaDepartmentsCommon.GetStoreId(doc));

                    counter++;
                    csvLineData.Add(new StringBuilder());
                }
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing departments", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Exemple #15
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;
            }
        }
Exemple #16
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;
            }
        }
Exemple #17
0
        public override void SetupData(XmlDocument doc)
        {
            XmlNodeList customers = null;

            try {
                customers = doc.DocumentElement.SelectNodes("/ListMembers/Member");

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

                    csvData[counter].Add(GetCustomerId(customerNode));
                    csvData[counter].Add(GetCustomerTitle(customerNode));
                    csvData[counter].Add(GetFirstName(customerNode));
                    csvData[counter].Add(GetMiddleName(customerNode));
                    csvData[counter].Add(GetLastName(customerNode));
                    csvData[counter].Add(GetNickName(customerNode));
                    csvData[counter].Add(GetGender(customerNode));
                    csvData[counter].Add(GetCustomerDOB(customerNode));
                    csvData[counter].Add(GetEnrolmentDate(customerNode));
                    csvData[counter].Add(GetCustomerCode(customerNode));
                    csvData[counter].Add(GetExternalCustomerId(customerNode));
                    csvData[counter].Add(GetActiveStatus(customerNode));
                    csvData[counter].Add(GetAddress1(customerNode));
                    csvData[counter].Add(GetAddress2(customerNode));
                    csvData[counter].Add(GetSuburb(customerNode));
                    csvData[counter].Add(GetCity(customerNode));
                    csvData[counter].Add(GetState(customerNode));
                    csvData[counter].Add(GetCountry(customerNode));
                    csvData[counter].Add(GetPostalAddress1(customerNode));
                    csvData[counter].Add(GetPostalAddress2(customerNode));
                    csvData[counter].Add(GetPostalAddressSuburb(customerNode));
                    csvData[counter].Add(GetPostalAddressCity(customerNode));
                    csvData[counter].Add(GetPostalAddressState(customerNode));
                    csvData[counter].Add(GetPostalAddressCountry(customerNode));
                    csvData[counter].Add(PostalCode(customerNode));
                    csvData[counter].Add(GetPhoneMobile(customerNode));
                    csvData[counter].Add(GetPhoneWork(customerNode));
                    csvData[counter].Add(GetPhoneHome(customerNode));
                    csvData[counter].Add(GetFax(customerNode));
                    csvData[counter].Add(GetEmail(customerNode));
                    csvData[counter].Add(GetBankAccount1(customerNode));
                    csvData[counter].Add(GetBankAccount2(customerNode));
                    csvData[counter].Add(GetBankAccount3(customerNode));
                    csvData[counter].Add(GetBankAccount4(customerNode));
                    csvData[counter].Add(GetWebsite(customerNode));
                    csvData[counter].Add(GetCompany(customerNode));
                    csvData[counter].Add(GetJobTitle(customerNode));
                    csvData[counter].Add(GetEthnicityId(customerNode));
                    csvData[counter].Add(GetMarriedStatus(customerNode));
                    csvData[counter].Add(GetNumberOfChildren(customerNode));
                    csvData[counter].Add(GetRankingId(customerNode));
                    csvData[counter].Add(GetIncomeId(customerNode));
                    csvData[counter].Add(GetOccupationId(customerNode));
                    csvData[counter].Add(GetCustomerGroupId(customerNode));
                    csvData[counter].Add(GetCurrentBalance(customerNode));
                    csvData[counter].Add(GetRewardBalance(customerNode));
                    csvData[counter].Add(GetGiftBalance(customerNode));
                    csvData[counter].Add(GetVoucherBalance(customerNode));
                    csvData[counter].Add(GetLogin(customerNode));
                    csvData[counter].Add(GetPassword(customerNode));
                    csvData[counter].Add(GetLastModified(customerNode));
                    csvData[counter].Add(GetIPAddress(customerNode));
                    csvData[counter].Add(GetExtra1(customerNode));
                    csvData[counter].Add(GetExtra2(customerNode));
                    csvData[counter].Add(GetExtra3(customerNode));
                    csvData[counter].Add(GetExtra4(customerNode));
                    csvData[counter].Add(GetExtra5(customerNode));
                    csvData[counter].Add(GetExtra6(customerNode));
                    csvData[counter].Add(GetExtra7(customerNode));
                    csvData[counter].Add(GetExtra8(customerNode));
                    csvData[counter].Add(GetExtra9(customerNode));
                    csvData[counter].Add(GetExtra10(customerNode));
                    csvData[counter].Add(GetComments(customerNode));
                    csvData[counter].Add(GetCardId(customerNode));
                    csvData[counter].Add(GetCardExpiryDate(customerNode));
                    csvData[counter].Add(GetCardActiveStatus(customerNode));
                    csvData[counter].Add(GetCardPrintStatus(customerNode));
                    csvData[counter].Add(GetStoreId(customerNode));

                    counter++;
                    csvLineData.Add(new StringBuilder());
                }
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing customer", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Exemple #18
0
        public override void SetupData(XmlDocument doc)
        {
            List <string> productIds = new List <string>();

            XmlNodeList menus = null;

            try {
                menus = doc.DocumentElement.SelectNodes("//Menu");

                int lineCounter = 0;
                foreach (XmlNode menuNode in menus)
                {
                    XmlNodeList courses = null;

                    courses = menuNode.SelectNodes("./Courses/Course");


                    foreach (XmlNode courseNode in courses)
                    {
                        XmlNodeList items = null;

                        items = courseNode.SelectNodes("./Items/Item");


                        foreach (XmlNode itemNode in items)
                        {
                            XmlNodeList sizes = null;

                            sizes = itemNode.SelectNodes("./Sizes/Size");


                            foreach (XmlNode sizeNode in sizes)
                            {
                                csvData.Add(new List <string>());

                                string productId = SummaProductsListCommon.GetProductId(menuNode, courseNode, itemNode, sizeNode);

                                if (productIds.Contains(productId))
                                {
                                    Summa.logger.Debug("Duplicate Product Id found: {0}, {1] ",
                                                       productId,
                                                       SummaProductsListCommon.GetProductName(menuNode, courseNode, itemNode, sizeNode));
                                }
                                else
                                {
                                    productIds.Add(productId);

                                    csvData[lineCounter].Add(productId);
                                    csvData[lineCounter].Add(SummaProductsListCommon.GetProductName(menuNode, courseNode, itemNode, sizeNode));
                                    csvData[lineCounter].Add(SummaProductsListCommon.GetProductBarcode(itemNode));
                                    csvData[lineCounter].Add(SummaProductsListCommon.GetProductPrice1(sizeNode));
                                    csvData[lineCounter].Add(SummaProductsListCommon.GetProductPrice2(sizeNode));
                                    csvData[lineCounter].Add(SummaProductsListCommon.GetProductGroupId(sizeNode));
                                    csvData[lineCounter].Add(SummaProductsListCommon.GetProductDepartmentId(sizeNode));
                                    csvData[lineCounter].Add(SummaProductsListCommon.GetProductCost(sizeNode));
                                    csvData[lineCounter].Add(SummaProductsListCommon.GetStoreId(doc));

                                    lineCounter++;
                                    csvLineData.Add(new StringBuilder());
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e) {
                SummaException se = new SummaException("Problem processing products", e);
                se.Data = doc.OuterXml;
                throw se;
            }
        }
Exemple #19
0
        public void WriteDataToCSV()
        {
            // TODO investigate threading issues, this method must be thread safe!
            // exceptions will bubble up and be caught by Summa.cs

            // internal sanity check
            if (fieldLengths.Length != shouldQuoteField.Length)
            {
                throw new Exception("Internal error: fieldsLengths and sholdQuoteField arrays should be same length!");
            }

            if (csvData.Count > 0)
            {
                if (csvData[0] != null)
                {
                    if (csvData[0].Count != fieldLengths.Length)
                    {
                        throw new Exception("Internal error: CSV data item count and fieldLengths data structures should be same length!");
                    }
                }
            }


            try {
                BuildCSVLines();

                FileMode createMode;
                if (AppendToFile)
                {
                    createMode = FileMode.Append;
                }
                else
                {
                    createMode = FileMode.Create;
                }

                using (FileStream csvFile = File.Open(FULLFILEPATH, createMode, FileAccess.Write, FileShare.None)) {
                    ASCIIEncoding asciiEncoder = new ASCIIEncoding();

                    foreach (StringBuilder b in csvLineData)
                    {
                        byte[] bytesToWrite = asciiEncoder.GetBytes(b.ToString());
                        csvFile.Write(bytesToWrite, 0, bytesToWrite.Length);
                    }

                    csvFile.Flush();
                    csvFile.Close();
                }
            }
            catch (IOException ioe) {
                string message = "Unable to write to " + FULLFILEPATH;
                Summa.logger.ErrorException(message, ioe);
                SummaException se = new SummaException(message, ioe);

                StringBuilder allCsvData = new StringBuilder();
                foreach (StringBuilder sb in csvLineData)
                {
                    allCsvData.Append(sb);
                }
                se.Data = allCsvData.ToString();

                throw se;
            }
        }