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 CreateMasterlist(ISourceReader reader, string base_out_put_folder)
        {
            var output_file = base_out_put_folder + "\\MasterList.xlsx";

            var reservations = reader.GetReservations();

            var workbook   = new XLWorkbook();
            var work_sheet = workbook.AddWorksheet("Master List");

            work_sheet.Cell(1, "A").Value = "Buyer.Id"; work_sheet.Cell(1, "A").Style.Font.Bold = true;
            work_sheet.Cell(1, "B").Value = "Buyer.Name"; work_sheet.Cell(1, "B").Style.Font.Bold = true;
            work_sheet.Cell(1, "C").Value = "Element.ElementID"; work_sheet.Cell(1, "C").Style.Font.Bold = true;
            work_sheet.Cell(1, "D").Value = "Element.BricklinkId"; work_sheet.Cell(1, "D").Style.Font.Bold = true;
            work_sheet.Cell(1, "E").Value = "Element.BricklinkDescription"; work_sheet.Cell(1, "E").Style.Font.Bold = true;
            work_sheet.Cell(1, "F").Value = "Element.BricklinkColor"; work_sheet.Cell(1, "F").Style.Font.Bold = true;
            work_sheet.Cell(1, "G").Value = "Element.MaterialColor"; work_sheet.Cell(1, "G").Style.Font.Bold = true;
            work_sheet.Cell(1, "H").Value = "Amount"; work_sheet.Cell(1, "H").Style.Font.Bold = true;

            int line_count = 2;

            foreach (var reservation in reservations)
            {
                work_sheet.Cell(line_count, "A").Value = reservation.Buyer.Id;
                work_sheet.Cell(line_count, "B").Value = reservation.Buyer.Name;
                work_sheet.Cell(line_count, "C").Value = reservation.Element.ElementID;
                work_sheet.Cell(line_count, "D").Value = reservation.Element.BricklinkId;
                work_sheet.Cell(line_count, "E").Value = reservation.Element.BricklinkDescription;
                work_sheet.Cell(line_count, "F").Value = reservation.Element.BricklinkColor;
                work_sheet.Cell(line_count, "G").Value = reservation.Element.MaterialColor;
                work_sheet.Cell(line_count, "H").Value = reservation.Amount;
                line_count++;
            }

            if (File.Exists(output_file))
            {
                File.Delete(output_file);
            }

            workbook.SaveAs(output_file);
        }
Exemplo n.º 4
0
        private static void CreatePicklists(ISourceReader reader, string base_out_put_folder)
        {
            var picklists = LugBulkPicklistCreator.CreateLists(reader.GetReservations(), reader.GetElements());

            var output_folder = base_out_put_folder + "\\Picklists\\";

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

            foreach (var picklist in picklists)
            {
                File.Copy("Templates\\PicklistTemplate01.xlsx", output_folder + picklist.ElementID + ".xlsx", true);

                var workbook   = new XLWorkbook(output_folder + picklist.ElementID + ".xlsx");
                var work_sheet = workbook.Worksheets.First();

                PicklistXlsxFileCreator.Create(work_sheet, picklist);

                workbook.Save();
            }
        }