Exemplo n.º 1
0
        private static void CreateBuyerSummeryLists(ISourceReader reader, string base_out_put_folder)
        {
            var buyers       = reader.GetBuyers();
            var reservations = reader.GetReservations();

            var output_folder = base_out_put_folder + "\\BuyerSummeryLists";

            if (!Directory.Exists(output_folder))
            {
                Directory.CreateDirectory(output_folder);
            }

            foreach (var buyer in buyers)
            {
                var new_file_path = output_folder + "\\" + buyer.Id + "-" + buyer.Name + ".xlsx";

                File.Copy("Templates\\ReceiverSummeryTemplate01.xlsx", new_file_path, true);

                var workbook   = new XLWorkbook(new_file_path);
                var work_sheet = workbook.Worksheets.First();

                BuyerSummeryFileCreator.Create(work_sheet, buyer,
                                               reservations.Where(x => x.Buyer.Id == buyer.Id));

                workbook.Save();
            }
        }
Exemplo n.º 2
0
        public static IList <string> MakeFileForLugbulkDatabase(ISourceReader reader)
        {
            var lines = new List <string>();

            // Elements
            // [tblElements]: [ElementId], [BlId], [Description], [BLColor], [TlgColor], [TlgColorId]
            //      ,[Price], [SumQuantity], [Remainder]

            lines.Add("-- Elements --");
            var elements = reader.GetElements();

            foreach (var element in elements)
            {
                lines.Add(string.Format("INSERT INTO tblElements (ElementId, BlId, Description, BLColor) VALUES ({0}, '{1}', '{2}', '{3}')",
                                        element.ElementID, element.BricklinkId, element.BricklinkDescription, element.BricklinkColor));
            }
            lines.Add("");

            // Buyers
            // [tblBuyers]: [Username], [MoneySum], [BrickAmount]
            lines.Add("-- Buyers --");
            var buyers = reader.GetBuyers();

            foreach (var buyer in buyers)
            {
                // [tblBuyers]: [Username], [MoneySum], [BrickAmount]
                lines.Add(string.Format("INSERT INTO tblBuyers (Username) VALUES ('{0}')", buyer.Name));
            }
            lines.Add("");

            // Amounts
            // [tblBuyersAmounts]: [Username], [ElementId], [Amount], [Difference]
            lines.Add("-- Amounts --");
            var amounts = reader.GetReservations();

            foreach (var amount in amounts)
            {
                // [tblBuyers]: [Username], [MoneySum], [BrickAmount]
                lines.Add(string.Format("INSERT INTO tblBuyersAmounts (Username, ElementId, Amount) VALUES ('{0}', {1}, {2})",
                                        amount.Buyer.Name, amount.Element.ElementID, amount.Amount));
            }
            lines.Add("");

            //File.WriteAllLines("lugbulk_data.sql", lines);
            return(lines);
        }
Exemplo n.º 3
0
        private static void CreateBuyersList(ISourceReader reader, string base_out_put_folder)
        {
            File.Copy("Templates\\ReceiversListTemplate01.xlsx", base_out_put_folder + "\\BuyersList.xlsx", true);

            var workbook   = new XLWorkbook(base_out_put_folder + "\\BuyersList.xlsx");
            var work_sheet = workbook.Worksheets.First();

            var buyers = reader.GetBuyers();

            for (int i = 0; i < buyers.Count; i++)
            {
                work_sheet.Cell(i + 2, "A").Value = buyers[i].Id;
                work_sheet.Cell(i + 2, "A").Style.Alignment
                .SetHorizontal(XLAlignmentHorizontalValues.Center);
                work_sheet.Cell(i + 2, "B").Value = buyers[i].Name;
            }

            workbook.Save();
        }