public class Rpt_AllTeacherAbsents : IReportBase
{
#region IReportBase
public string ReportFileName { get; set; }
#endregion IReportBase
#region Properties
public bool ShowTeacherInSeperatePage { get; set; }
public List<TeachersAbsentRow> DataSource { get; set; }
public string StartDate { get; set; }
public string EndDate { get; set; }
public bool ShowFooter { get; set; }
public TermViewModel Term { get; set; }
#endregion Properties
#region Constructors
public Rpt_AllTeacherAbsents()
{
}
public Rpt_AllTeacherAbsents(List<TeachersAbsentRow> dataSource, TermViewModel term, string startDate = "", string endDate = "", bool showFooter = true, bool showTeacherInSeperatePage = false)
{
ShowFooter = showFooter;
DataSource = dataSource;
Term = term;
StartDate = startDate;
EndDate = endDate;
ShowTeacherInSeperatePage = showTeacherInSeperatePage;
}
#endregion Constructors
public IPdfReportData Create()
{
return new PdfReport()
.DocumentPreferences(doc =>
{
doc.RunDirection(PdfRunDirection.RightToLeft);
doc.Orientation(PageOrientation.Landscape);
doc.PageSize(PdfPageSize.A4);
doc.DocumentMetadata(new DocumentMetadata
{
...
});
})
.DefaultFonts(fonts =>
{
fonts.Size(8);
fonts.Path(FontHelper.GetFontPath(FarsiFonts.BYekan),
//fonts.Path(Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts\\BYekan.ttf",
Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts\\tahoma.ttf");
})
.PagesFooter(footer =>
{
#region Footer
if (ShowFooter)
{
footer.XHtmlFooter(rptFooter =>
{
IPdfFont ipf = footer.PdfFont;
ipf.Size = 9;
rptFooter.PageFooterProperties(new XFooterBasicProperties
{
RunDirection = PdfRunDirection.RightToLeft,
ShowBorder = true,
PdfFont = ipf,
TotalPagesCountTemplateHeight = 10,
TotalPagesCountTemplateWidth = 50,
SpacingBeforeTable = 25f,
InlineCss = "border:0px solid;border-top:1px solid black;"
});
//RazorMachine rm = new RazorMachine();
rptFooter.AddPageFooter(pageFooter =>
{
return HeaderAndFooterUtility.InitCommonFooter(Term, pageFooter);
});
});
}
#endregion
})
.PagesHeader(header =>
{
header.CustomHeader(new CH_Rpt_AllTeacherAbsents(Term, StartDate, EndDate)
{
PdfRptFont = header.PdfFont
});
})
.MainTableTemplate(template =>
{
template.CustomTemplate(new GrayTemplate(false));
})
.MainTablePreferences(table =>
{
#region
table.ShowHeaderRow(true);
table.SpacingAfter(10f);
table.ColumnsWidthsType(TableColumnWidthType.Absolute);
table.NumberOfDataRowsPerPage(0);
table.GroupsPreferences(new GroupsPreferences
{
GroupType = GroupType.HideGroupingColumns,
SpacingBeforeAllGroupsSummary = 1f,
SpacingAfterAllGroupsSummary = 5,
NewGroupAvailableSpacingThreshold = 30,
RepeatHeaderRowPerGroup = true,
ShowOneGroupPerPage = ShowTeacherInSeperatePage,
});
#endregion
})
.MainTableDataSource(dataSource =>
{
dataSource.StronglyTypedList<TeachersAbsentRow>(DataSource);
})
.MainTableSummarySettings(summarySettings =>
{
//summarySettings.OverallSummarySettings("جمع ساعات تدریس : ");
// summarySettings.PreviousPageSummarySettings("Previous Page Summary");
// summarySettings.PageSummarySettings("Page Summary");
})
.MainTableColumns(columns =>
{
#region Columns
columns.AddColumn(column =>
{
column.PropertyName("rowNo");
column.IsRowNumber(true);
column.CellsHorizontalAlignment(HorizontalAlignment.Center);
column.IsVisible(true);
column.Order(0);
column.Width(40);
column.HeaderCell("#", horizontalAlignment: HorizontalAlignment.Center);
});
columns.AddColumn(column =>
{
column.PropertyName<TeachersAbsentRow>(x => x.TeacherCode);
column.CellsHorizontalAlignment(HorizontalAlignment.Center);
column.IsVisible(true);
column.Order(2);
column.Width(100);
column.HeaderCell("کد استاد", horizontalAlignment: HorizontalAlignment.Right);
column.Group(true, (val1, val2) =>
{
return val1.ToString() == val2.ToString();
});
});
columns.AddColumn(column =>
{
column.PropertyName<TeachersAbsentRow>(x => x.LessonCode);
column.CellsHorizontalAlignment(HorizontalAlignment.Left);
column.IsVisible(true);
column.Order(2);
column.Width(100);
column.HeaderCell("کد درس", horizontalAlignment: HorizontalAlignment.Center);
});
columns.AddColumn(column =>
{
column.PropertyName<TeachersAbsentRow>(x => x.LessonName);
column.CellsHorizontalAlignment(HorizontalAlignment.Center);
column.IsVisible(true);
column.Order(2);
column.Width(200);
column.HeaderCell("نام درس", horizontalAlignment: HorizontalAlignment.Center);
});
columns.AddColumn(column =>
{
column.PropertyName<TeachersAbsentRow>(x => x.Date);
column.CellsHorizontalAlignment(HorizontalAlignment.Center);
column.IsVisible(true);
column.Order(2);
column.Width(90);
column.HeaderCell("تاریخ", horizontalAlignment: HorizontalAlignment.Center);
});
columns.AddColumn(column =>
{
column.PropertyName<TeachersAbsentRow>(x => x.StartTimeToEndTime);
column.CellsHorizontalAlignment(HorizontalAlignment.Center);
column.IsVisible(true);
column.Order(2);
column.Width(120);
column.HeaderCell("ساعت", horizontalAlignment: HorizontalAlignment.Center);
});
columns.AddColumn(column =>
{
column.PropertyName<TeachersAbsentRow>(x => x.TrendCode);
column.CellsHorizontalAlignment(HorizontalAlignment.Center);
column.IsVisible(true);
column.Order(2);
column.Width(90);
column.HeaderCell("کد رشته", horizontalAlignment: HorizontalAlignment.Center);
});
columns.AddColumn(column =>
{
column.PropertyName<TeachersAbsentRow>(x => x.TrendName);
column.CellsHorizontalAlignment(HorizontalAlignment.Center);
column.IsVisible(true);
column.Order(2);
column.Width(180);
column.HeaderCell("عنوان رشته", horizontalAlignment: HorizontalAlignment.Center);
});
columns.AddColumn(column =>
{
column.PropertyName<TeachersAbsentRow>(x => x.PlaceFullName);
column.CellsHorizontalAlignment(HorizontalAlignment.Center);
column.IsVisible(true);
column.Order(2);
column.Width(130);
column.HeaderCell("مکان برگزاری", horizontalAlignment: HorizontalAlignment.Center);
});
#endregion
})
.MainTableEvents(events =>
{
#region Events
#region Alternate Row Colors
events.CellCreated(args =>
{
});
#endregion
events.DataSourceIsEmpty(message: "داده ای برای مشاهده وجود ندارد.");
events.CellCreated(args =>
{
if (args.RowType == RowType.DataTableRow)
{
}
});
#endregion
})
.Export(export =>
{
})
.Generate(data => data.AsPdfFile(ReportFileName));
}
}