Exemplo n.º 1
0
        public void ListContentFluentConstructorWithNameAndItems_FillsNameAndItems()
        {
            var listContent = ListContent.Create("Name", new ListItemContent(), new ListItemContent());

            Assert.AreEqual(2, listContent.Items.Count());
            Assert.AreEqual("Name", listContent.Name);
        }
Exemplo n.º 2
0
        public void ListContentFluentConstructorWithNameAndEnumerableListItemContent_FillsNameAndItems()
        {
            var listContent = ListContent.Create("Name", new List <ListItemContent>());

            Assert.IsNotNull(listContent.Items);
            Assert.AreEqual("Name", listContent.Name);
        }
Exemplo n.º 3
0
        public void ListContentFluentAddItem_FillsNameAndItems()
        {
            var listContent = ListContent.Create("Name", new List <ListItemContent>())
                              .AddItem(ListItemContent.Create("ItemName", "Name"));

            Assert.IsNotNull(listContent.Items);
            Assert.AreEqual("Name", listContent.Name);
            Assert.AreEqual(listContent.Items.Count, 1);
            Assert.AreEqual(listContent.Items.First().Fields.Count, 1);
            Assert.AreEqual(listContent.Items.First().Fields.First().Name, "ItemName");
            Assert.AreEqual(listContent.Items.First().Fields.First().Value, "Name");
        }
Exemplo n.º 4
0
        private Content GetContent(List <ProjectReport> template, ApplicationUser user, DateTime firstDate, DateTime lastDate, Utils utils)
        {
            List <Appendix> appendices     = new List <Appendix>();
            int             count          = 1;
            var             listContentTwo = ListContent.Create("Projects List");

            for (int i = 0; i < template.Count; i++)
            {
                List <TableRowContent> tableRowContent = new List <TableRowContent>();
                for (int j = 0; j < template[i].Modules.Count; j++)
                {
                    List <FieldContent> fieldContents = new List <FieldContent>();
                    fieldContents.Add(new FieldContent("count", (j + 1).ToString()));
                    fieldContents.Add(new FieldContent("Name", template[i].Modules[j].Module.Name));
                    string desc   = "";
                    string status = "";
                    string date   = "";
                    string cause  = "";
                    string note   = "";
                    for (int x = 0; x < template[i].Modules[j].Tasks.Count; x++)
                    {
                        if (template[i].Modules[j].Tasks[x].Name is null)
                        {
                            desc += "                                " + (x + 1).ToString() + ". ";
                        }
                        else
                        {
                            desc += "                                " + (x + 1).ToString() + ". " + template[i].Modules[j].Tasks[x].Name;
                        }

                        DateTime firstDate1 = template[i].Modules[j].Tasks[x].CreateDate;
                        DateTime updateDate = template[i].Modules[j].Tasks[x].UpdateDate;

                        DateTime dateTime = DateTime.Now;


                        if (template[i].Modules[j].Tasks[x].StatusId == 1)
                        {
                            status += "                                " + (x + 1).ToString() + ". " + "В процессе";
                            int raznica = (dateTime - firstDate1).Days;
                            date += "                                " + (x + 1).ToString() + ". " + raznica.ToString() + " дней";
                        }
                        else
                        {
                            status += "                                " + (x + 1).ToString() + ". " + "Выполнено";
                            int raznica = (updateDate - firstDate1).Days;
                            date += "                                " + (x + 1).ToString() + ". " + raznica.ToString() + " дней";
                        }



                        if (template[i].Modules[j].Tasks[x].Appendix is null)
                        {
                            cause += "                                " + (x + 1).ToString() + ". ";
                        }
                        else
                        {
                            appendices.Add(template[i].Modules[j].Tasks[x].Appendix);
                            cause += "                                " + (x + 1).ToString() + ". Примечание " + count.ToString();
                            count++;
                        }

                        if (template[i].Modules[j].Tasks[x].Note is null)
                        {
                            note += "                                " + (x + 1).ToString() + ". ";
                        }
                        else
                        {
                            note += "                                " + (x + 1).ToString() + ". " + template[i].Modules[j].Tasks[x].Note;
                        }
                    }

                    fieldContents.Add(new FieldContent("Description", desc));
                    fieldContents.Add(new FieldContent("status", status));
                    fieldContents.Add(new FieldContent("date", date));
                    fieldContents.Add(new FieldContent("cause", note));
                    fieldContents.Add(new FieldContent("note", cause));
                    tableRowContent.Add(new TableRowContent(fieldContents));
                }

                listContentTwo.AddItem(new ListItemContent("Project", "Проект: " + template[i].Project.Name)
                                       .AddTable(TableContent.Create("Team members", tableRowContent)));
            }
            ListContent imageList = new ListContent("Scientists List");

            if (appendices.Count > 0)
            {
                for (int i = 0; i < appendices.Count; i++)
                {
                    string uploadPath = Path.Combine(hostingEnvironment.WebRootPath, "images");
                    string fileName   = appendices[i].FileName;
                    string FilePath   = Path.Combine(uploadPath, fileName);
                    //appendices[i].FileName.CopyTo(new FileStream(FilePath, FileMode.Create));
                    imageList.AddItem(new FieldContent("CountImage", "Примечание " + (i + 1).ToString()),
                                      new ImageContent("Photo", System.IO.File.ReadAllBytes(FilePath)),
                                      new FieldContent("NameImage", appendices[i].Name));
                }
            }
            if (imageList.Items == null)
            {
                imageList.AddItem(new FieldContent("CountImage", ""),
                                  new FieldContent("NameImage", ""));
            }

            var valuesToFill = new Content(
                listContentTwo,
                imageList,
                new FieldContent("reportName", "Отчет о выполненных задачах"),
                new FieldContent("reportDate", "За период с " + firstDate.ToString("D") + " по " + lastDate.ToString("D")),
                new FieldContent("employeePosition", user.Position.Name),
                new FieldContent("employeeQualification", user.QualificationLevel.Name),
                new FieldContent("First Parameter", utils.firstParameter),
                new FieldContent("Second Parameter", utils.secondParameter),
                new FieldContent("Third Parameter", utils.thirdParameter),
                new FieldContent("employeePositionTwo", user.Position.Name),
                new FieldContent("employeeName", user.UserName));

            return(valuesToFill);
        }
Exemplo n.º 5
0
        private Content GetContent(List <ProjectReport> template, ApplicationUser user, DateTime firstDate, DateTime lastDate)
        {
            var listContentTwo = ListContent.Create("Projects List");

            for (int i = 0; i < template.Count; i++)
            {
                List <TableRowContent> tableRowContent = new List <TableRowContent>();
                for (int j = 0; j < template[i].Modules.Count; j++)
                {
                    List <FieldContent> fieldContents = new List <FieldContent>();
                    fieldContents.Add(new FieldContent("count", (j + 1).ToString()));
                    fieldContents.Add(new FieldContent("Name", template[i].Modules[j].Module.Name));
                    string desc   = "";
                    string status = "";
                    string date   = "";
                    string cause  = "";
                    string note   = "";
                    for (int x = 0; x < template[i].Modules[j].Tasks.Count; x++)
                    {
                        if (template[i].Modules[j].Tasks[x].Name is null)
                        {
                            desc += "\n";
                        }
                        else
                        {
                            desc += "                                " + (x + 1).ToString() + ". " + template[i].Modules[j].Tasks[x].Name;
                        }

                        DateTime firstDate1 = template[i].Modules[j].Tasks[x].CreateDate;
                        DateTime updateDate = template[i].Modules[j].Tasks[x].UpdateDate;

                        DateTime dateTime = DateTime.Now;


                        if (template[i].Modules[j].Tasks[x].StatusId == 1)
                        {
                            status += "                                " + (x + 1).ToString() + ". " + "В процессе";
                            int raznica = (dateTime - firstDate1).Days;
                            date += "                                " + (x + 1).ToString() + ". " + raznica.ToString() + " дней";
                        }
                        else
                        {
                            status += "                                " + (x + 1).ToString() + ". " + "Выполнено";
                            int raznica = (updateDate - firstDate1).Days;
                            date += "                                " + (x + 1).ToString() + ". " + raznica.ToString() + " дней";
                        }



                        if (template[i].Modules[j].Tasks[x].Appendix is null)
                        {
                            cause += "\n";
                        }
                        else
                        {
                            cause += "                                " + (x + 1).ToString() + ". " + template[i].Modules[j].Tasks[x].Appendix.Name;
                        }

                        if (template[i].Modules[j].Tasks[x].Note is null)
                        {
                            note += "\n";
                        }
                        else
                        {
                            note += "                                " + (x + 1).ToString() + ". " + template[i].Modules[j].Tasks[x].Note;
                        }
                    }

                    fieldContents.Add(new FieldContent("Description", desc));
                    fieldContents.Add(new FieldContent("status", status));
                    fieldContents.Add(new FieldContent("date", date));
                    fieldContents.Add(new FieldContent("cause", cause));
                    fieldContents.Add(new FieldContent("note", note));
                    tableRowContent.Add(new TableRowContent(fieldContents));
                }

                listContentTwo.AddItem(new ListItemContent("Project", "Проект: " + template[i].Project.Name)
                                       .AddTable(TableContent.Create("Team members", tableRowContent)));
            }

            var valuesToFill = new Content(
                listContentTwo,
                new FieldContent("reportName", "Отчет о выполненных задачах"),
                new FieldContent("reportDate", "За период с " + firstDate.ToString("D") + " по " + lastDate.ToString("D")),
                new FieldContent("employeePosition", user.Position.Name),
                new FieldContent("employeeQualification", user.QualificationLevel.Name),
                new FieldContent("employeePositionTwo", user.Position.Name),
                new FieldContent("employeeName", user.UserName));

            return(valuesToFill);
        }