Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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();
            }
        }