private static void ApplyHeader2(WordprocessingDocument doc, CommitteeVM data) { // Get the main document part. MainDocumentPart mainDocPart = doc.MainDocumentPart; HeaderPart headerPart1 = mainDocPart.AddNewPart <HeaderPart>("r97"); Header header1 = new Header(); header1.Append(CreateParagraph(" استمارة رقم 14 د ", JustificationValues.Right, "", "12pt")); header1.Append(CreateParagraph($"أسماء السادة أعضاء لجنة {data.Name} رقم ({data.Number}) ", JustificationValues.Center, "", "15pt", true)); header1.Append(CreateParagraph($"الدور {data.Term} {data.SchoolYear} ", JustificationValues.Left, "", "12pt")); headerPart1.Header = header1; SectionProperties sectionProperties1 = mainDocPart.Document.Body.Descendants <SectionProperties>().FirstOrDefault(); if (sectionProperties1 == null) { sectionProperties1 = new SectionProperties() { }; mainDocPart.Document.Body.Append(sectionProperties1); } HeaderReference headerReference1 = new HeaderReference() { Type = HeaderFooterValues.Default, Id = "r97" }; sectionProperties1.InsertAt(headerReference1, 0); }
public IHttpActionResult GetCommittee(int id) { var committee = _db.CommitteesRepository.FindBy(id); var model = new CommitteeVM(committee); return(Ok(model)); }
public static void CreateDoc(string fileName, CommitteeVM data, byte part = 1) { // Create a Wordprocessing document. using (WordprocessingDocument myDoc = WordprocessingDocument.Create(fileName, WordprocessingDocumentType.Document)) { // Add a new main document part. MainDocumentPart mainPart = myDoc.AddMainDocumentPart(); HeaderPart headerPart = mainPart.AddNewPart <HeaderPart>(); FooterPart footerPart = mainPart.AddNewPart <FooterPart>(); //Create DOM tree for simple document. mainPart.Document = new Document(); Body body = new Body(); mainPart.Document.Append(body); SectionProperties sectionProps = new SectionProperties(); PageMargin pageMargin = new PageMargin() { Top = 1008, Right = (UInt32Value)1008U, Bottom = 1008, Left = (UInt32Value)1008U, Header = (UInt32Value)720U, Footer = (UInt32Value)720U, Gutter = (UInt32Value)0U }; sectionProps.Append(pageMargin); mainPart.Document.Body.Append(sectionProps); switch (part) { case 1: //Add master Table AddMasterTable(data, mainPart); ApplyHeader(myDoc, data); break; case 2: //Add third table AddThirdTable(data, mainPart); ApplyHeader2(myDoc, data); break; case 3: //Add second table AddSecondTable(data, mainPart); ApplyHeader2(myDoc, data); break; } ApplyFooter(myDoc); // Save changes to the main document part. mainPart.Document.Save(); } }
public IHttpActionResult SaveCommitteeMembers([FromBody] CommitteeVM committee) { if (!ModelState.IsValid) { return(BadRequest()); } var committeeObj = _db.CommitteesRepository.FindBy(committee.Id); committeeObj.DoctorName = committee.DoctorName; committeeObj.DoctorStartDate = committee.DoctorStartDate; committeeObj.StudentCount = committee.StudentCount; committeeObj.ChiefStartDate = committee.ChiefStartDate; committeeObj.ChiefEndDate = committee.ChiefEndDate; committeeObj.SuperInspectorStartDate = committee.SuperInspectorStartDate; committeeObj.SuperInspectorEndDate = committee.SuperInspectorEndDate; if (committeeObj.Chief == null) { committeeObj.Chief = new Member(); } committeeObj.Chief.Name = committee.Chief.Name; committeeObj.Chief.JobId = committee.Chief.JobObj.Id; committeeObj.Chief.SchoolId = committee.Chief.School.Id; committeeObj.Chief.StartDate = committee.Chief.StartDate; committeeObj.Chief.EndDate = committee.Chief.EndDate; committeeObj.Chief.EvaluationDate = committee.Chief.EvaluationDate; committeeObj.Chief.CommitteeId = committee.Id; committeeObj.Chief.Phone = committee.Chief.Phone; if (committeeObj.SuperInspector == null) { committeeObj.SuperInspector = new Member(); } committeeObj.SuperInspector.Name = committee.SuperInspector.Name; committeeObj.SuperInspector.JobId = committee.SuperInspector.JobObj.Id; committeeObj.SuperInspector.SchoolId = committee.SuperInspector.School.Id; committeeObj.SuperInspector.StartDate = committee.SuperInspector.StartDate; committeeObj.SuperInspector.EndDate = committee.SuperInspector.EndDate; committeeObj.SuperInspector.EvaluationDate = committee.SuperInspector.EvaluationDate; committeeObj.SuperInspector.CommitteeId = committee.Id; committeeObj.SuperInspector.Phone = committee.SuperInspector.Phone; _db.Commit(); return(Ok(committee)); }
public IHttpActionResult SaveCommittee([FromBody] CommitteeVM committee) { if (!ModelState.IsValid) { return(BadRequest()); } if (committee.Id == 0) { var c = new Committee(); c.DateCreated = DateTime.Now; c.Number = GetCommitteeNumber(); c.Name = committee.Name; //committeeObj.Number = committee.Number; c.Phone = committee.Phone; c.Address = committee.Address; c.SchoolYear = committee.SchoolYear; c.Term = committee.Term; //c.LearningManagementId = committee.LearningManagementId; c.SchoolId = committee.SchoolId; c.StudentCount = committee.StudentCount; c.CommitteType = committee.CommitteType; c.LearningType = committee.LearningType; _db.CommitteesRepository.Add(c); } else { var committeeObj = _db.CommitteesRepository.FindBy(committee.Id); committeeObj.Name = committee.Name; //committeeObj.Number = committee.Number; committeeObj.Phone = committee.Phone; committeeObj.Address = committee.Address; committeeObj.SchoolYear = committee.SchoolYear; committeeObj.Term = committee.Term; //committeeObj.LearningManagementId = committee.LearningManagementId; committeeObj.SchoolId = committee.SchoolId; committeeObj.StudentCount = committee.StudentCount; committeeObj.CommitteType = committee.CommitteType; committeeObj.LearningType = committee.LearningType; } _db.Commit(); return(Ok(committee)); }
public ActionResult ComitteeStructure(int id, string format = "", byte part = 1) { var committee = _db.CommitteesRepository.FindBy(id); var committeeVM = new CommitteeVM(committee); //Response.Hea ders.Clear(); //Response.Headers.Add("Content-Type", "application/msword"); //Response.Headers.Add("Content-Disposition", $"attachment; filename='committee-{committee.Number}.doc"); if (format.Equals("msword")) { var fileName = Server.MapPath(ConfigurationManager.AppSettings["reportFiles"] + "report1.docx"); Helpers.ReportGenerator.CreateDoc(fileName, committeeVM, part); return(File(fileName, "application/msword", $"ComitteeStructure{id}-{DateTime.Now}-{part}.docx")); } return(View(committeeVM)); }
private static void ApplyHeader(WordprocessingDocument doc, CommitteeVM data) { // Get the main document part. MainDocumentPart mainDocPart = doc.MainDocumentPart; HeaderPart headerPart1 = mainDocPart.AddNewPart <HeaderPart>("r97"); Header header1 = new Header(); Table table = new Table(); TableProperties props = new TableProperties( new TableWidth() { Width = "100%", Type = TableWidthUnitValues.Auto }); props.BiDiVisual = new BiDiVisual(); table.AppendChild <TableProperties>(props); var tr = new TableRow(); //cell 1 var tc = new TableCell(); tc.Append(CreateParagraph("")); tc.Append(CreateParagraph("وزارة التربية و التعليم والتعليم الفني الادارة العامة للامتحانات", JustificationValues.Center)); tc.Append(CreateParagraph($"لجنة الإدارة لامتحان دبلوم المدارس الثانوية الصناعية نظام السنوات الثلاث قطاع {data.Sector}", JustificationValues.Center)); var tableWidth = new TableCellWidth { Type = TableWidthUnitValues.Auto, Width = "28%" }; tc.Append(new TableCellProperties(tableWidth)); //cell 2 var tc2 = new TableCell(); tc2.Append(CreateParagraph("كشـف ", JustificationValues.Center)); tc2.Append(CreateParagraph("أسماء السادة أعضاء لجنة سير الامتحان ", JustificationValues.Center, "", "12pt", true)); var table2 = new Table(); table2.AppendChild <TableProperties>(new TableProperties { TableWidth = new TableWidth() { Width = "90%", Type = TableWidthUnitValues.Auto }, BiDiVisual = new BiDiVisual(), TablePositionProperties = new TablePositionProperties { TablePositionXAlignment = HorizontalAlignmentValues.Center } }); var row1 = new TableRow(); row1.Append(CreateTableCell("الدور", "", JustificationValues.Left, "50%", "", "10pt", true)); row1.Append(CreateTableCell(data.Term, "", JustificationValues.Left, "50%", "", "10pt")); var row2 = new TableRow(); row2.Append(CreateTableCell("أسم اللجنة", "", JustificationValues.Left, "50%", "", "10pt", true)); row2.Append(CreateTableCell(data.Name, "", JustificationValues.Left, "50%", "", "10pt")); var row3 = new TableRow(); row3.Append(CreateTableCell("مديرية / إدارة", "", JustificationValues.Left, "50%", "", "10pt", true)); row3.Append(CreateTableCell(data.LearningManagement, "", JustificationValues.Left, "50%", "", "10pt")); var row4 = new TableRow(); row4.Append(CreateTableCell("عنــوان اللجنة", "", JustificationValues.Left, "50%", "", "10pt", true)); row4.Append(CreateTableCell(data.Address, "", JustificationValues.Left, "50%", "", "10pt")); table2.Append(row1); table2.Append(row2); table2.Append(row3); table2.Append(row4); tc2.Append(table2); tc2.Append(CreateParagraph("")); var tableWidth2 = new TableCellWidth { Type = TableWidthUnitValues.Auto, Width = "47%" }; tc2.Append(new TableCellProperties(tableWidth2)); //cell 3 var tc3 = new TableCell(); tc3.Append(CreateParagraph(" استمارة رقم 13 د ", JustificationValues.Right, "", "12pt")); var table3 = new Table(); table3.AppendChild <TableProperties>(new TableProperties { TableWidth = new TableWidth() { Width = "90%", Type = TableWidthUnitValues.Auto }, BiDiVisual = new BiDiVisual(), TablePositionProperties = new TablePositionProperties { TablePositionXAlignment = HorizontalAlignmentValues.Center } }); var row5 = new TableRow(); row5.Append(CreateTableCell("رقم اللجنة", "", JustificationValues.Left, "50%", "", "10pt", true)); row5.Append(CreateTableCell(data.Number.ToString(), "", JustificationValues.Left, "50%", "", "10pt")); var row6 = new TableRow(); row6.Append(CreateTableCell("نوع اللجنة", "", JustificationValues.Left, "50%", "", "10pt", true)); row6.Append(CreateTableCell(data.CommitteType, "", JustificationValues.Left, "50%", "", "10pt")); var row7 = new TableRow(); row7.Append(CreateTableCell("عدد الطلبة", "", JustificationValues.Left, "50%", "", "10pt", true)); row7.Append(CreateTableCell(data.StudentCount.ToString(), "", JustificationValues.Left, "50%", "", "10pt")); table3.Append(row5); table3.Append(row6); table3.Append(row7); tc3.Append(table3); tc3.Append(CreateParagraph("")); var tableWidth3 = new TableCellWidth { Type = TableWidthUnitValues.Auto, Width = "25%" }; tc3.Append(new TableCellProperties(tableWidth3)); tr.Append(tc); tr.Append(tc2); tr.Append(tc3); table.Append(tr); header1.Append(table); headerPart1.Header = header1; SectionProperties sectionProperties1 = mainDocPart.Document.Body.Descendants <SectionProperties>().FirstOrDefault(); if (sectionProperties1 == null) { sectionProperties1 = new SectionProperties() { }; mainDocPart.Document.Body.Append(sectionProperties1); } HeaderReference headerReference1 = new HeaderReference() { Type = HeaderFooterValues.Default, Id = "r97" }; sectionProperties1.InsertAt(headerReference1, 0); }
private static void AddMasterTable(CommitteeVM data, MainDocumentPart mainPart) { Table table = new Table(); TableProperties props = new TableProperties( new TableWidth() { Width = "100%", Type = TableWidthUnitValues.Auto }, new TableBorders( new TopBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 12 }, new BottomBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 12 }, new LeftBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 12 }, new RightBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 12 }, new InsideHorizontalBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 8 }, new InsideVerticalBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 8 })); props.BiDiVisual = new BiDiVisual(); table.AppendChild <TableProperties>(props); var headerRow = new TableRow(); var bgColor = "#cccccc"; //var data = GetData(); headerRow.Append(CreateTableCell("م", bgColor, JustificationValues.Center, "5%")); headerRow.Append(CreateTableCell("الإسم", bgColor, JustificationValues.Center, "20%")); headerRow.Append(CreateTableCell("الوظيفة", bgColor, JustificationValues.Center, "45%")); var cell4 = CreateTableCell("الملاحظات", bgColor, JustificationValues.Center); TableCellProperties tableCellProperties = new TableCellProperties() { TableCellVerticalAlignment = new TableCellVerticalAlignment { Val = TableVerticalAlignmentValues.Center }, HorizontalMerge = new HorizontalMerge() { Val = MergedCellValues.Restart } }; cell4.Append(tableCellProperties); headerRow.Append(cell4); var cell5 = CreateTableCell(""); cell5.Append(new TableCellProperties { HorizontalMerge = new HorizontalMerge { Val = MergedCellValues.Continue } }); headerRow.Append(cell5); headerRow.TableRowProperties = new TableRowProperties(); headerRow.TableRowProperties.AppendChild(new TableHeader()); table.Append(headerRow); // add cheif and supervisor var row2 = new TableRow(); row2.Append(CreateTableCell("", "", JustificationValues.Center)); var c1 = CreateTableCell("رئيس اللجنة", bgColor, JustificationValues.Left, "", "Arial", "14pt", true, true); c1.Append(CreateParagraph(data.Chief.Name)); row2.Append(c1); row2.Append(CreateTableCell(data.Chief.Job)); var r2c2 = CreateTableCell($"إستلام وإمتحان:- {data.Chief.StartDate}"); r2c2.Append(CreateParagraph($"تسليم: {data.Chief.EndDate}")); row2.Append(r2c2); row2.Append(CreateTableCell($"تقدير الدرجات:- {data.Chief.EvaluationDate}")); table.Append(row2); var row3 = new TableRow(); row3.Append(CreateTableCell("", "", JustificationValues.Center)); var c2 = CreateTableCell("المراقب الأول", bgColor, JustificationValues.Left, "", "Arial", "14pt", true, true); c2.Append(CreateParagraph(data.SuperInspector.Name)); row3.Append(c2); row3.Append(CreateTableCell(data.SuperInspector.Job)); row3.Append(CreateTableCell("")); row3.Append(CreateTableCell("")); table.Append(row3); var row4 = new TableRow(); row4.Append(CreateTableCell("", "", JustificationValues.Center)); row4.Append(CreateTableCell("المراقبون", bgColor, JustificationValues.Left, "", "Arial", "12pt", true)); row4.Append(CreateTableCell("")); row4.Append(CreateTableCell("")); row4.Append(CreateTableCell("")); table.Append(row4); var counter = 1; foreach (var item in data.Inspectors) { var tr = new TableRow(); tr.Append(CreateTableCell($"{counter++}", "", JustificationValues.Center)); tr.Append(CreateTableCell(item.Name)); tr.Append(CreateTableCell($"{item.Job} {item.Speciality} {item.School.Title}")); tr.Append(CreateTableCell(item.StartDate)); tr.Append(CreateTableCell(item.EvaluationDate)); table.Append(tr); } var row5 = new TableRow(); row5.Append(CreateTableCell("", "", JustificationValues.Center)); row5.Append(CreateTableCell("المعاونـــــون", bgColor, JustificationValues.Left, "", "Arial", "12pt", true)); row5.Append(CreateTableCell("")); row5.Append(CreateTableCell("")); row5.Append(CreateTableCell("")); table.Append(row5); counter = 1; foreach (var item in data.Assistances) { var tr = new TableRow(); tr.Append(CreateTableCell($"{counter++}", "", JustificationValues.Center)); tr.Append(CreateTableCell(item.Name)); tr.Append(CreateTableCell($"{item.Job} {item.Speciality} {item.School.Title}")); tr.Append(CreateTableCell(item.StartDate)); tr.Append(CreateTableCell(item.EvaluationDate)); table.Append(tr); } var row6 = new TableRow(); row6.Append(CreateTableCell("", "", JustificationValues.Center)); row6.Append(CreateTableCell("الطبيب", bgColor, JustificationValues.Left, "", "Arial", "12pt", true)); row6.Append(CreateTableCell(data.DoctorName)); row6.Append(CreateTableCell("")); row6.Append(CreateTableCell("")); table.Append(row6); var row = table.GetFirstChild <TableRow>(); mainPart.Document.Append(table); //var last = new Paragraph( // new Run( // new Break() { Type = BreakValues.Page })); //mainPart.Document.Append(last); }
private static void AddSecondTable(CommitteeVM data, MainDocumentPart mainPart) { Table table = new Table(); TableProperties props = new TableProperties( new TableWidth() { Width = "100%", Type = TableWidthUnitValues.Auto }, new TableBorders( new TopBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 12 }, new BottomBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 12 }, new LeftBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 12 }, new RightBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 12 }, new InsideHorizontalBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 8 }, new InsideVerticalBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 8 })); props.BiDiVisual = new BiDiVisual(); table.AppendChild <TableProperties>(props); var headerRow = new TableRow(); var bgColor = "#cccccc"; headerRow.Append(CreateTableCell("م", bgColor, JustificationValues.Center, "5%")); headerRow.Append(CreateTableCell("الأســــــــــم", bgColor, JustificationValues.Center, "20%")); headerRow.Append(CreateTableCell("الوظيفة", bgColor, JustificationValues.Center, "45%")); headerRow.Append(CreateTableCell("ملاحظات", bgColor, JustificationValues.Center, "45%")); headerRow.Append(CreateTableCell("", bgColor, JustificationValues.Center, "45%")); headerRow.Append(CreateTableCell("", bgColor, JustificationValues.Center, "45%")); table.Append(headerRow); foreach (var item in data.Labs) { var tr = new TableRow(); tr.Append(CreateTableCell("")); tr.Append(CreateTableCell(item.Title, bgColor, JustificationValues.Left, "", "", "12pt", true)); tr.Append(CreateTableCell("")); tr.Append(CreateTableCell("")); tr.Append(CreateTableCell("")); tr.Append(CreateTableCell("")); table.Append(tr); var counter = 1; foreach (var member in item.Members) { var tr2 = new TableRow(); tr2.Append(CreateTableCell($"{counter++}", "", JustificationValues.Center)); tr2.Append(CreateTableCell(member.Name)); tr2.Append(CreateTableCell($"{member.Job} {member.Speciality} {member.School.Title}")); tr2.Append(CreateTableCell(member.CommitteRole)); tr2.Append(CreateTableCell(member.StartDate)); tr2.Append(CreateTableCell(member.EvaluationDate)); table.Append(tr2); } } foreach (var item in data.Divisions) { var tr = new TableRow(); tr.Append(CreateTableCell("")); tr.Append(CreateTableCell(item.Title, bgColor, JustificationValues.Left, "", "", "12pt", true)); tr.Append(CreateTableCell("")); tr.Append(CreateTableCell("")); tr.Append(CreateTableCell("امتحان")); tr.Append(CreateTableCell("تقدير درجات")); table.Append(tr); var counter = 1; foreach (var member in item.Members) { var tr2 = new TableRow(); tr2.Append(CreateTableCell($"{counter++}", "", JustificationValues.Center)); tr2.Append(CreateTableCell(member.Name)); tr2.Append(CreateTableCell($"{member.Job} {member.Speciality} {member.School.Title}")); tr2.Append(CreateTableCell(member.CommitteRole)); tr2.Append(CreateTableCell(member.StartDate)); tr2.Append(CreateTableCell(member.EvaluationDate)); table.Append(tr2); } } mainPart.Document.Append(table); //mainPart.Document.Append( new Paragraph( // new Run( // new Break() { Type = BreakValues.Page }))); }
private static void AddThirdTable(CommitteeVM data, MainDocumentPart mainPart) { Table table = new Table(); TableProperties props = new TableProperties( new TableWidth() { Width = "100%", Type = TableWidthUnitValues.Auto }, new TableBorders( new TopBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 12 }, new BottomBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 12 }, new LeftBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 12 }, new RightBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 12 }, new InsideHorizontalBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 8 }, new InsideVerticalBorder { Val = new EnumValue <BorderValues>(BorderValues.Single), Size = 8 })); props.BiDiVisual = new BiDiVisual(); table.AppendChild <TableProperties>(props); var headerRow = new TableRow(); var bgColor = "#cccccc"; headerRow.Append(CreateTableCell("م", bgColor, JustificationValues.Center, "5%")); headerRow.Append(CreateTableCell("الأســــــــــم", bgColor, JustificationValues.Center, "20%")); headerRow.Append(CreateTableCell("الوظيفة", bgColor, JustificationValues.Center, "45%")); headerRow.Append(CreateTableCell("ملاحظات", bgColor, JustificationValues.Center, "45%")); table.Append(headerRow); var counter = 1; foreach (var member in data.TheoroticalMembers) { var tr = new TableRow(); tr.Append(CreateTableCell($"{counter++}", "", JustificationValues.Center)); tr.Append(CreateTableCell(member.Name)); tr.Append(CreateTableCell($"{member.Job}")); tr.Append(CreateTableCell(member.TheoroticalDate)); table.Append(tr); } foreach (var member in data.Observers) { var tr = new TableRow(); tr.Append(CreateTableCell($"{counter++}", "", JustificationValues.Center)); tr.Append(CreateTableCell(member.Name)); tr.Append(CreateTableCell($"{member.Job}")); tr.Append(CreateTableCell(member.StartDate)); table.Append(tr); } mainPart.Document.Append(table); }