예제 #1
0
        public void WriteToStream(Models.Resume resume, System.IO.Stream outputStream)
        {
            using (var doc = WordprocessingDocument.Create(outputStream, WordprocessingDocumentType.Document, true))
            {
                var main = doc.AddMainDocumentPart();
                main.Document      = new Document();
                main.Document.Body = new Body();

                var body = main.Document.Body;

                BuildStyles(main);

                BuildHeader(resume, doc);

                BuildPreamble(resume, doc);

                BuildSkillHighlights(resume, doc);

                BuildExperience(resume, doc);

                body.AppendChild <SectionProperties>(new SectionProperties(new PageMargin {
                    Left = 360, Right = 360, Top = 360, Bottom = 360
                }));

                doc.Close();
            }
        }
예제 #2
0
        private void BuildSkillHighlights(Models.Resume resume, WordprocessingDocument doc)
        {
            var body = doc.MainDocumentPart.Document.Body;

            body.AppendChild(
                new Paragraph(
                    new ParagraphProperties(
                        new ParagraphStyleId {
                Val = h1TextStyleId
            },
                        new Justification {
                Val = JustificationValues.Center
            }),
                    new Run(new Text("Skill Highlights"))));

            var      table = body.AppendChild(new Table());
            TableRow row   = null;
            var      index = 0;

            foreach (var catalog in resume.Catalog)
            {
                if (catalog.Hidden)
                {
                    continue;
                }

                if (index % 4 == 0)                 // 4 columns
                {
                    row = table.AppendChild(new TableRow());
                }

                var cell = row.AppendChild(new TableCell());
                var p    = cell.AppendChild(new Paragraph());

                var h3 = p.AppendChild(new Run(new RunProperties(new Bold()), new Text(catalog.Name)));

                foreach (var skill in catalog.Skills)
                {
                    if (skill.Hidden)
                    {
                        continue;
                    }

                    p.AppendChild(new Break());
                    if (!string.IsNullOrEmpty(skill.Href))
                    {
                        p.AppendChild(CreateHyperlink(skill.Name, skill.Href, doc.MainDocumentPart));
                    }
                    else
                    {
                        p.AppendChild(new Run(new Text(skill.Name)));
                    }
                }

                index++;
            }
        }
예제 #3
0
        public JsonResult GetAllResumes()
        {
            List <Models.Resume> resumes = new List <Models.Resume>();

            try
            {
                List <Resumes> resumeList = _repository.GetResumes();
                if (resumeList != null)
                {
                    foreach (var resume in resumeList)
                    {
                        Models.Resume resumeObj = _mapper.Map <Models.Resume>(resume);
                        resumes.Add(resumeObj);
                    }
                }
            }
            catch (Exception ex)
            {
                resumes = null;
            }
            return(new JsonResult(resumes));
        }
예제 #4
0
        private void BuildExperience(Models.Resume resume, WordprocessingDocument doc)
        {
            var body = doc.MainDocumentPart.Document.Body;

            foreach (var experienceCatalog in resume.ExperienceTypes)
            {
                body.AppendChild(
                    new Paragraph(
                        new ParagraphProperties(
                            new ParagraphStyleId {
                    Val = h1TextStyleId
                },
                            new Justification {
                    Val = JustificationValues.Center
                },
                            new OutlineLevel {
                    Val = 1
                }),
                        new Run(new Text(experienceCatalog.Name))));

                foreach (var experience in experienceCatalog.Experiences)
                {
                    var table = body.AppendChild(
                        new Table(
                            new TableRow(
                                new TableCell(
                                    CreateCellProperties(TableWidthUnitValues.Pct, "60"),
                                    new Paragraph(
                                        new ParagraphProperties {
                        ParagraphStyleId = new ParagraphStyleId {
                            Val = h2TextStyleId
                        }
                    },
                                        new Run(new Text(experience.Company)))),
                                new TableCell(
                                    CreateCellProperties(TableWidthUnitValues.Pct, "40"),
                                    new Paragraph(
                                        new ParagraphProperties(
                                            new ParagraphStyleId {
                        Val = h2TextStyleId
                    },
                                            new Justification {
                        Val = JustificationValues.Right
                    }),
                                        new Run(new Text(experience.Dates)))))));

                    if (!string.IsNullOrEmpty(experience.Locale))
                    {
                        body.AppendChild(
                            new Paragraph(
                                new ParagraphProperties(
                                    new FontSize {
                            Val = "11"
                        }),
                                new Run(new Text(experience.Locale))));
                    }

                    if (!string.IsNullOrEmpty(experience.Description))
                    {
                        body.AppendChild(
                            new Paragraph(
                                new ParagraphProperties(
                                    new Indentation {
                            Left = "720"
                        }),
                                new Run(new Text(experience.Description))));
                    }

                    foreach (var position in experience.Positions)
                    {
                        body.AppendChild(
                            new Paragraph(
                                new ParagraphProperties(new SpacingBetweenLines {
                            After = "0"
                        })
                        {
                            ParagraphStyleId = new ParagraphStyleId {
                                Val = h3TextStyleId
                            }
                        },
                                new Run(new Text(position.Title))));

                        if (position.Accomplishments != null)
                        {
                            foreach (var accomplishment in position.Accomplishments)
                            {
                                body.AppendChild(
                                    new Paragraph(
                                        new ParagraphProperties(
                                            new Indentation {
                                    Left = "1200"
                                }),
                                        new Run(new Text(accomplishment))));
                            }
                        }

                        positionId++;
                    }
                }
            }
        }
예제 #5
0
        private void BuildPreamble(Models.Resume resume, WordprocessingDocument doc)
        {
            var body = doc.MainDocumentPart.Document.Body;

            body.AppendChild(
                new Paragraph(
                    new ParagraphProperties(
                        new ParagraphStyleId {
                Val = h1TextStyleId
            },
                        new OutlineLevel {
                Val = 0
            },
                        new Justification {
                Val = JustificationValues.Center
            }),
                    new Run(
                        new Text(resume.Preamble.Title))));

            body.AppendChild(new Paragraph(new Run(new Text(resume.Preamble.Content))));

            body.AppendChild(
                new Paragraph(
                    new ParagraphProperties(
                        new ParagraphStyleId {
                Val = h1TextStyleId
            },
                        new OutlineLevel {
                Val = 0
            },
                        new Justification {
                Val = JustificationValues.Center
            }),
                    new Run(new Text("Areas of Expertise"))));

            int index          = 0;
            var expertiseTable = body.AppendChild(new Table());

            expertiseTable.AppendChild(HideBorders());

            TableRow  row   = expertiseTable.AppendChild(new TableRow());
            TableCell cell1 = row.AppendChild(new TableCell(CreateCellProperties(TableWidthUnitValues.Pct, "50"))),
                      cell2 = row.AppendChild(new TableCell(CreateCellProperties(TableWidthUnitValues.Pct, "50")));

            Paragraph p1 = cell1.AppendChild(new Paragraph()),
                      p2 = cell2.AppendChild(new Paragraph());

            foreach (var e in resume.Expertise)
            {
                Paragraph p;
                if (index % 2 == 0)                 // 2 columns
                {
                    p = p1;
                }
                else
                {
                    p = p2;
                }

                if (index >= 2)
                {
                    p.AppendChild(new Break());
                }

                p.AppendChild(new Run(new Text(e)));

                index++;
            }
        }