Example #1
0
        private static void RunOptions(Options opts)
        {
            System.IO.StreamReader file = new System.IO.StreamReader(opts.deliveriesFile);
            string fname = Path.Combine(Path.GetDirectoryName(opts.deliveriesFile), "DeliveriesReport.rtf");
            string line;
            int    delCnt = 0;
            int    stpCnt = 0;

            using (RTFDocument doc = new RTFDocument(fname))
            {
                doc.SetMargin(0.5F, 0.5F, 1.0F, 1.0F);
                while ((line = file.ReadLine()) != null)
                {
                    string[] vals = line.Split(" ");
                    if (vals[0] == "DeliverID:" && vals[3] != "0")
                    {
                        delCnt++;
                        var p = doc.AppendParagraph();

                        p.style.alignment  = Alignment.Left;
                        p.style.spaceAfter = 400;

                        var t = p.AppendText($"DeliveryID: {vals[1]} with {vals[3]} stops.\n");
                        t.style.bold       = true;
                        t.style.color      = new Color(0, 0, 0);
                        t.style.fontFamily = "Courier New";
                        int cnt      = int.Parse(vals[3]);
                        int rsp      = 45;
                        int numMeals = 0;
                        int totMeals = 0;
                        var rand     = new Random();
                        for (int ii = 0; ii < cnt; ii++)
                        {
                            t = p.AppendText("_".PadLeft(65, '_') + "\n");
                            t.style.fontFamily = "Courier New";
                            stpCnt++;
                            vals       = file.ReadLine().Split(":")[1].Split("|");
                            totMeals  += numMeals = int.Parse(vals[11]);
                            t.content += $"{vals[0]} {vals[1]}" + sp(vals[0] + vals[1], rsp);
                            t.content += $"<b># of Meals: {numMeals}</b>\n";
                            t.content += $"  {vals[2]} {vals[3]}" + sp(vals[2] + vals[3], rsp - 1) + "Phone Numbers:\n";
                            string pn = vals[9] != "" ? String.Format("{0:(###) ###-####}", Int64.Parse(vals[9])) : "";
                            t.content += $"  {vals[4]}" + sp(vals[4], rsp) + $"Home: {pn}\n";
                            pn         = vals[8] != "" ? String.Format("{0:(###)###-####}", Int64.Parse(vals[8])) : "";
                            t.content += $"  {vals[5]}, {vals[6]} {vals[7]}" + sp(vals[5] + vals[6] + vals[7], rsp - 3) + $"Cell: {pn}\n";
                            t.content += $"  Delivery Notes: {vals[12]}\n";
                        }
                        t = p.AppendText("\n".PadRight(15, '=') + $" Meal Total: {totMeals} " + "\n\n".PadLeft(15, '='));
                        t.style.fontFamily = "Courier New";
                        t.style.fontSize  += 4;
                        p.PageBreak        = true;
                    }
                }
            }
            Console.Out.WriteLine($"Processed {delCnt} deliveries with a total of {stpCnt} stops written to {fname}");
        }
Example #2
0
        private void GenReport(string deliveriesFile)
        {
            System.IO.StreamReader file = new System.IO.StreamReader(deliveriesFile + "_Deliveries.txt");
            string fname = deliveriesFile + "_DeliveriesReport.rtf";
            string line;
            int    delCnt  = 0;
            int    stpCnt  = 0;
            int    mealCnt = 0;
            Dictionary <string, int> restCnt = new Dictionary <string, int>();

            using (RTFDocument doc = new RTFDocument(fname))
            {
                doc.SetMargin(0.5F, 0.5F, 1.0F, 1.0F);
                while ((line = file.ReadLine()) != null)
                {
                    string[] vals = line.Split(' ');
                    if (vals[0] == "DeliverID:" && vals[3] != "0")
                    {
                        delCnt++;
                        var p = doc.AppendParagraph();

                        p.style.alignment  = RTFExporter.Alignment.Left;
                        p.style.spaceAfter = 400;

                        var t = p.AppendText($"DeliveryID: {vals[1]} with {vals[3]} stops.\n");
                        t.style.bold       = true;
                        t.style.color      = new RTFExporter.Color(0, 0, 0);
                        t.style.fontFamily = "Courier New";
                        int cnt      = int.Parse(vals[3]);
                        int rsp      = 45;
                        int numMeals = 0;
                        int totMeals = 0;
                        var rand     = new Random();
                        for (int ii = 0; ii < cnt; ii++)
                        {
                            t = p.AppendText("_".PadLeft(65, '_') + "\n");
                            t.style.fontFamily = "Courier New";
                            stpCnt++;
                            vals       = file.ReadLine().Split('^')[1].Split('|');
                            totMeals  += numMeals = int.Parse(vals[11]);
                            t.content += $"{vals[0]} {vals[1]}" + sp(vals[0] + vals[1], rsp);
                            t.content += $"<b># of Meals: {numMeals}</b>\n";
                            t.content += $"  {vals[2]} {vals[3]}" + sp(vals[2] + vals[3], rsp - 1) + "Phone Numbers:\n";
                            string pn = vals[9] != "" ? String.Format("{0:(###) ###-####}", Int64.Parse(vals[9])) : "";
                            t.content += $"  {vals[4]}" + sp(vals[4], rsp) + $"Home: {pn}\n";
                            pn         = vals[8] != "" ? String.Format("{0:(###)###-####}", Int64.Parse(vals[8])) : "";
                            t.content += $"  {vals[5]}, {vals[6]} {vals[7]}" + sp(vals[5] + vals[6] + vals[7], rsp - 3) + $"Cell: {pn}\n";
                            t.content += $"  Delivery Notes: {vals[12]}\n";
                            t.content += $"  Restaurant: {vals[15]}\n";
                            if (restCnt.ContainsKey(vals[15]))
                            {
                                restCnt[vals[15]] = restCnt[vals[15]] + numMeals;
                            }
                            else
                            {
                                restCnt[vals[15]] = numMeals;
                            }
                        }
                        mealCnt           += totMeals;
                        t                  = p.AppendText("\n".PadRight(15, '=') + $" Meal Total: {totMeals} " + "\n\n".PadLeft(15, '='));
                        t.style.fontFamily = "Courier New";
                        t.style.fontSize  += 4;
                        p.PageBreak        = true;
                    }
                }
            }
            DebugOut($"\nProcessed {delCnt} deliveries with a total of {stpCnt} stops and {mealCnt} meals written to {fname}");
            string restOut = "Restaurant counts: \n";

            foreach (var pair in restCnt)
            {
                restOut += pair.Key + sp(pair.Key, 60) + $"\t=> {pair.Value}\n";
            }
            DebugOut(restOut);
        }
Example #3
0
        private static RTFDocument AddTalkable(RTFDocument document, Talkable character, Options options)
        {
            RTFTextStyle style        = new RTFTextStyle(false, false, 12, "Courier", Color.black);
            RTFTextStyle styleAllcaps = new RTFTextStyle(false, false, false, false, true, false, 12, "Courier", Color.black, Underline.None);

            RTFParagraphStyle noIndent             = new RTFParagraphStyle(Alignment.Left, new Indent(0, 0, 0), 0, 400);
            RTFParagraphStyle messageContentIndent = new RTFParagraphStyle(Alignment.Left, new Indent(0, 2.54f, 0), 0, 400);

            var presentation = document.AppendParagraph(noIndent);

            presentation.AppendText(character.name, styleAllcaps);

            var characterDescription = DictionariesHelper.ContainsKey(character.description, options.currentLanguage);
            var text = string.Empty;

            text = ", " + characterDescription.value;

            if (text[text.Length - 1] != '.')
            {
                text += ".";
            }

            presentation.AppendText(text, style);

            for (var i = 0; i < character.contexts.Length; i++)
            {
                var context    = character.contexts[i];
                var contextPar = document.AppendParagraph(noIndent);
                var name       = DictionariesHelper.ContainsKey(context.name, options.currentLanguage);

                contextPar.AppendText(string.Format("CTX {0}\n", i), styleAllcaps);
                contextPar.AppendText(name.value, style);

                foreach (var column in context.columns)
                {
                    for (var j = 0; j < column.messages.Length; j++)
                    {
                        var messagePar = document.AppendParagraph(messageContentIndent);
                        messagePar.AppendText("\t\t" + column.emitter + "\n", styleAllcaps);

                        var screenplayNotes = DictionariesHelper.ContainsKey(column.messages[j].screenplayNotes, options.currentLanguage);

                        if (screenplayNotes != null)
                        {
                            if (screenplayNotes.value != "")
                            {
                                messagePar.AppendText("\t(" + screenplayNotes.value + ")\n", style);
                            }
                        }

                        var content = DictionariesHelper.ContainsKey(column.messages[j].content, options.currentLanguage);

                        if (column.messages.Length > 1)
                        {
                            messagePar.AppendText("(" + j + "): " + content.value, style);
                        }

                        else
                        {
                            messagePar.AppendText(content.value, style);
                        }
                    }
                }
            }
            return(document);
        }