예제 #1
0
        public static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.WriteLine($"First arg: {args[0]}");

                var JsonString = System.IO.File.ReadAllText(args[0]);
                if (JsonString == String.Empty)
                {
                    Console.WriteLine("We have an empty input file"); return;
                }

                TrelloData TData = new TrelloData();
                try
                {
                    TData = JsonConvert.DeserializeObject <TrelloData>(JsonString);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"We have got some errors while converting JSON file: {ex.ToString()}");
                    return;
                }

                Console.WriteLine($"Board name: {TData.name}");

                string output_filename = $"{args[0]}.docx";
                TrelloParser.MakeDocx(output_filename, TData, "План работ");
                Console.WriteLine($"Output document done: {output_filename}");
            }
            else
            {
                Console.WriteLine("Need to pass a Trello JSON file as a first argument");
            }
        }
예제 #2
0
        public static void MakeDocx(string docx_filename, TrelloData data, string caption)
        {
            using (var fs =
                       new System.IO.FileStream(docx_filename,
                                                System.IO.FileMode.Create,
                                                System.IO.FileAccess.Write))
            {
                XWPFDocument doc = new XWPFDocument();

                var p0 = doc.CreateParagraph();
                p0.Alignment = ParagraphAlignment.CENTER;
                XWPFRun r0 = p0.CreateRun();
                r0.FontFamily = "Arial";
                r0.FontSize   = 14;
                r0.IsBold     = true;
                r0.SetText(caption);

                for (int i = data.lists.Count - 1; i >= 0; i--)
                {
                    PrintParagraph(doc, 14, true, data.lists[i].name);

                    for (int j = 0; j < data.cards.Count; j++)
                    {
                        if (data.lists[i].id == data.cards[j].idList)
                        {
                            PrintParagraph(doc, 12, false, data.cards[j].name);
                            foreach (var line in ReadLines(data.cards[j].desc))
                            {
                                PrintParagraph(doc, 12, false, line);
                            }

                            //PrintParagraph(doc, 12, false, "");
                        }
                    }

                    PrintParagraph(doc, 14, false, "");
                }

                doc.Write(fs);
            }
        }