public ReportDynamicModel(ReportDynamic reportDynamic) { reportDynamic = reportDynamic ?? new ReportDynamic(); // init report Init(reportDynamic); // get columns var reportColumns = ReportColumnServices.GetAll().Where(r => r.ReportId == reportDynamic.Id && !r.IsDeleted).ToList(); // get report width Width = ReportHelper.ReportWidth(PaperKind, Orientation); // get header width HeaderWidth = ReportHelper.ReportConlumnTypeWidth(reportColumns, ReportColumnType.Header); // get header group width HeaderGroupWidth = ReportHelper.ReportConlumnTypeWidth(reportColumns, ReportColumnType.HeaderGroup); // get detail width DetailWidth = ReportHelper.ReportConlumnTypeWidth(reportColumns, ReportColumnType.Detail); // get footer group width FooterGroupWidth = ReportHelper.ReportConlumnTypeWidth(reportColumns, ReportColumnType.FooterGroup); // get footer width FooterWidth = ReportHelper.ReportConlumnTypeWidth(reportColumns, ReportColumnType.Footer) - Constant.IndexColumnWidth; }
/// <summary> /// Get paging by condition /// </summary> /// <param name="keyword"></param> /// <param name="reportId"></param> /// <param name="parentId"></param> /// <param name="isGroup"></param> /// <param name="type"></param> /// <param name="status"></param> /// <param name="isDeleted"></param> /// <param name="order"></param> /// <param name="start"></param> /// <param name="limit"></param> /// <returns></returns> public static PageResult <ReportColumnModel> GetPaging(string keyword, int reportId, int?parentId, bool?isGroup, ReportColumnType?type, ReportColumnStatus?status, bool?isDeleted, string order, int start, int limit) { // init condition var condition = "1=1"; // keyword if (!string.IsNullOrEmpty(keyword)) { condition += " AND [Name] LIKE N'%{0}%'".FormatWith(keyword.EscapeQuote()); } // report id if (reportId > 0) { condition += " AND [ReportId]={0}".FormatWith(reportId); } // parent id if (parentId != null) { condition += " AND [ParentId]={0}".FormatWith(parentId.Value); } // is group if (isGroup != null) { condition += " AND [IsGroup]={0}".FormatWith(isGroup.Value ? 1 : 0); } // deleted if (isDeleted != null) { condition += " AND [IsDeleted]={0}".FormatWith(isDeleted.Value ? 1 : 0); } // status if (status != null) { condition += " AND [Status]={0}".FormatWith((int)status.Value); } // report column type if (type != null) { condition += " AND [Type]={0}".FormatWith((int)type.Value); } // get result var result = ReportColumnServices.GetPaging(condition, order, start, limit); // return return(new PageResult <ReportColumnModel>(result.Total, result.Data.Select(r => new ReportColumnModel(r)).ToList())); }
/// <summary> /// Get all by condition /// </summary> /// <param name="keyword"></param> /// <param name="reportId"></param> /// <param name="parentId"></param> /// <param name="isGroup"></param> /// <param name="type"></param> /// <param name="status"></param> /// <param name="isDeleted"></param> /// <param name="order"></param> /// <param name="limit"></param> /// <returns></returns> public static List <ReportColumnModel> GetAll(string keyword, int reportId, int?parentId, bool?isGroup, ReportColumnType?type, ReportColumnStatus?status, bool?isDeleted, string order, int?limit) { // init condition var condition = "1=1"; // keyword if (keyword != null) { condition += " AND ([Name] LIKE N'%{0}%' OR [FieldName] LIKE N'%{0}%')".FormatWith(keyword); } // report id if (reportId > 0) { condition += " AND [ReportId]={0}".FormatWith(reportId); } // parent id if (parentId != null) { condition += " AND [ParentId]={0}".FormatWith(parentId.Value); } // is group if (isGroup != null) { condition += " AND [IsGroup]={0}".FormatWith(isGroup.Value ? 1 : 0); } // deleted if (isDeleted != null) { condition += " AND [IsDeleted]={0}".FormatWith(isDeleted.Value ? 1 : 0); } // status if (status != null) { condition += " AND [Status]={0}".FormatWith((int)status.Value); } // report column type if (type != null) { condition += " AND [Type]={0}".FormatWith((int)type.Value); } // return return(ReportColumnServices.GetAll(condition, order, limit).Select(e => new ReportColumnModel(e)).ToList()); }
/// <summary> /// Update /// </summary> /// <param name="model"></param> /// <returns></returns> public static ReportColumnModel Update(ReportColumnModel model) { var entity = new ReportColumn(); // check validate parent column if (!ValidateUpdateColumn(model.Id, model.Width, model.ParentId)) { return(null); } // fill entity model.FillEntity(ref entity); return(new ReportColumnModel(ReportColumnServices.Update(entity))); }
/// <summary> /// Constructor /// </summary> /// <param name="reportColumn"></param> public ReportColumnModel(ReportColumn reportColumn) { // init report column object reportColumn = reportColumn ?? new ReportColumn(); // get children report column var childrenReportColumn = ReportColumnServices.GetAll(Condition.FormatWith(reportColumn.ReportId, reportColumn.Id, 0)); // set width remain if (childrenReportColumn.Count > 0) { WidthRemain = reportColumn.Width - childrenReportColumn.Sum(r => r.Width); } else { WidthRemain = reportColumn.Width; } // init model props Init(reportColumn); // set name to config name ConfigName = Name; }
/// <summary> /// Get by id /// </summary> /// <param name="id"></param> /// <returns></returns> public static ReportColumnModel GetById(int id) { var entity = ReportColumnServices.GetById(id); return(entity != null ? new ReportColumnModel(entity) : null); }