public FileResult ExportFileGroupByClients(string userName, ReportsGridView reportsGridData, HttpContext httpContext) { var groupByClient = _reportService.ReportsGridGroupByClients(userName, reportsGridData); var result = GetExportFileWithGrouping(reportsGridData, httpContext, groupByClient); return(result); }
public ReportsGrandGridDatesView ReportsGridGroupByDates(string userName, ReportsGridView reportsGridData) { var reportsGridDates = new ReportsGrandGridDatesView { ReportsGridView = new List <ReportGridDateView> { new ReportGridDateView { Items = new List <ReportsGridItemsView>() } } }; var timeEntriesForGrouping = GetTimeEntriesForGrouping(userName, reportsGridData); if (!timeEntriesForGrouping.Any()) { return(reportsGridDates); } var timeEntriesGroupByDate = timeEntriesForGrouping .GroupBy(i => i.Date) .ToDictionary(key => key.Key, key => key.Select(value => value)); var result = reportsGridDates.GetViewReportsGrandGridClients(timeEntriesGroupByDate, Mapper); return(result); }
private void FillDatesByDateStaticOrDateFromTo(ReportsGridView reportsGridView, ref DateTime dateFrom, ref DateTime dateTo) { var dateStaticId = reportsGridView.CurrentQuery.DateStaticId; var isFilledDateStaticIdAndDateFromDateTo = dateStaticId != null && reportsGridView.CurrentQuery?.DateFrom != null && reportsGridView.CurrentQuery?.DateTo != null; var isFilledOnlyDateFromDateTo = dateStaticId == null && reportsGridView.CurrentQuery?.DateFrom != null && reportsGridView.CurrentQuery?.DateTo != null; if (!isFilledDateStaticIdAndDateFromDateTo && !isFilledOnlyDateFromDateTo) { throw new CoralTimeDangerException("Wrong input conditional: to get entities by DateStaticId or Date From/To properties."); } if (isFilledDateStaticIdAndDateFromDateTo) { var dateStaticExtend = CreateDateStaticExtend(dateStaticId); dateFrom = dateStaticExtend.DateFrom; dateTo = dateStaticExtend.DateTo; } if (isFilledOnlyDateFromDateTo) { dateFrom = (DateTime)reportsGridView.CurrentQuery?.DateFrom; dateTo = (DateTime)reportsGridView.CurrentQuery?.DateTo; } }
public ReportsGrandGridTimeEntryView ReportsGridGroupByNone(string userName, ReportsGridView reportsGridData) { var reportsGridTimeEntry = new ReportsGrandGridTimeEntryView { ReportsGridView = new List <ReportGridTimeEntryView> { new ReportGridTimeEntryView { Items = new List <ReportsGridItemsView>() } } }; var timeEntriesForGrouping = GetTimeEntriesForGrouping(userName, reportsGridData); if (!timeEntriesForGrouping.Any()) { return(reportsGridTimeEntry); } var timeEntriesGroupByNone = timeEntriesForGrouping .GroupBy(x => x.Id) .ToDictionary(key => key.Key, key => key.Select(value => value).OrderBy(value => value.Date).AsEnumerable()); var result = reportsGridTimeEntry.GetViewReportsGrandGridTimeEntries(timeEntriesGroupByNone, Mapper); return(result); }
public async Task <FileResult> ExportFileGroupByClientsAsync(ReportsGridView reportsGridData, HttpContext httpContext) { var groupByClient = _reportService.ReportsGridGroupByClients(reportsGridData); var result = await GetExportFileWithGroupingAsync(reportsGridData, httpContext, groupByClient); return(result); }
public ReportsGrandGridProjectsView ReportsGridGroupByProjects(ReportsGridView reportsGridData) { var reportsGridProjects = new ReportsGrandGridProjectsView { ReportsGridView = new List <ReportGridProjectView> { new ReportGridProjectView { Items = new List <ReportsGridItemsView>() } } }; var timeEntriesForGrouping = GetTimeEntriesForGrouping(reportsGridData); if (!timeEntriesForGrouping.Any()) { return(reportsGridProjects); } var timeEntriesGroupByProjects = timeEntriesForGrouping.ToList() .GroupBy(i => i.Project) .OrderBy(x => x.Key.Name) .ToDictionary(key => key.Key, key => key.OrderBy(value => value.Date).AsEnumerable()); var result = reportsGridProjects.GetViewReportsGrandGridClients(timeEntriesGroupByProjects, Mapper); return(result); }
public ReportsGrandGridMembersView ReportsGridGroupByUsers(string userName, ReportsGridView reportsGridData) { var reportsGridUsers = new ReportsGrandGridMembersView { ReportsGridView = new List <ReportGridMemberView> { new ReportGridMemberView { Items = new List <ReportsGridItemsView>() } } }; var timeEntriesForGrouping = GetTimeEntriesForGrouping(userName, reportsGridData); if (!timeEntriesForGrouping.Any()) { return(reportsGridUsers); } var timeEntriesGroupByUsers = timeEntriesForGrouping .GroupBy(i => i.Member) .OrderBy(x => x.Key.FullName) .ToDictionary(key => key.Key, key => key.Select(value => value).OrderBy(value => value.Date).AsEnumerable()); var result = reportsGridUsers.GetViewReportsGrandGridClients(timeEntriesGroupByUsers, Mapper); return(result); }
private List <TimeEntry> GetFilteredTimeEntries(ReportsGridView reportsGridView) { var memberImpersonated = MemberImpersonated; var dateFrom = new DateTime(); var dateTo = new DateTime(); FillDatesByDateStaticOrDateFromTo(reportsGridView, ref dateFrom, ref dateTo); // By Dates (default grouping, i.e. "Group by None"; direct order). var timeEntriesByDateOfUser = GetTimeEntryByDate(memberImpersonated, dateFrom, dateTo); // By Projects. if (reportsGridView.CurrentQuery?.ProjectIds != null && reportsGridView.CurrentQuery.ProjectIds.Length > 0) { CheckAndSetIfInFilterChooseSingleProject(reportsGridView, timeEntriesByDateOfUser); timeEntriesByDateOfUser = timeEntriesByDateOfUser.Where(x => reportsGridView.CurrentQuery.ProjectIds.Contains(x.ProjectId)); } // By Members. if (reportsGridView.CurrentQuery?.MemberIds != null && reportsGridView.CurrentQuery.MemberIds.Length > 0) { timeEntriesByDateOfUser = timeEntriesByDateOfUser.Where(x => reportsGridView.CurrentQuery.MemberIds.Contains(x.MemberId)); } // By Clients that has Projects. if (reportsGridView.CurrentQuery?.ClientIds != null && reportsGridView.CurrentQuery.ClientIds.Length > 0) { timeEntriesByDateOfUser = timeEntriesByDateOfUser.Where(x => reportsGridView.CurrentQuery.ClientIds.Contains(x.Project.ClientId) || x.Project.ClientId == null && reportsGridView.CurrentQuery.ClientIds.Contains(WithoutClient.Id)); } return(timeEntriesByDateOfUser.ToList()); }
public ReportsGrandGridClients ReportsGridGroupByClients(string userName, ReportsGridView reportsGridData) { var reportsGridClients = new ReportsGrandGridClients { ReportsGridView = new List <ReportGridClientView> { new ReportGridClientView { Items = new List <ReportsGridItemsView>() } } }; var timeEntriesForGrouping = GetTimeEntriesForGrouping(userName, reportsGridData); if (!timeEntriesForGrouping.Any()) { return(reportsGridClients); } var timeEntriesGroupByClients = timeEntriesForGrouping .GroupBy(i => i.Project.Client == null ? CreateWithOutClientInstance() : i.Project.Client) .OrderBy(x => x.Key.Name) .ToDictionary(key => key.Key, key => key.Select(value => value).OrderBy(value => value.Date).AsEnumerable()); var result = reportsGridClients.GetViewReportsGrandGridClients(timeEntriesGroupByClients, Mapper); return(result); }
private void SetCommonValuesForExport <T>(ReportsGridView reportsGridData) { RunSetCommonValuesForExport = true; #region Set Global Properties. // TODO change type! GroupById = reportsGridData.CurrentQuery.GroupById ?? 3; ShowColumnIds = reportsGridData.CurrentQuery.ShowColumnIds; DateFormatId = reportsGridData.DateFormatId; DateFrom = _reportService.DateFrom; DateTo = _reportService.DateTo; #endregion #region Get excluded props by Grand, Entity, NestedEntity headers in arrays. PropsGroupByAndTotalTimes = ExcludeProps(typeof(T)); PropsEntityHeadersAndRows = ExcludeProps(typeof(IReportsGridItemsView)); PropsEntitiesTotalHeaders = ExcludeProps(typeof(IReportsGrandGridView <T>)); #endregion }
private async Task <FileStreamResult> GetExportFileWithGroupingAsync <T>(ReportsGridView reportsGridData, HttpContext httpContext, IReportsGrandGridView <T> groupingList) { var fileByte = await CreateReportFileByteUpdateFileNameContentTypeAsync(reportsGridData, groupingList); var fileStreamResult = SaveFileToFileStreamResult(httpContext, fileByte); return(fileStreamResult); }
private void CheckAndSetIfInFilterChooseSingleProject(ReportsGridView reportsGridData, IQueryable <TimeEntry> timeEntriesByDateOfUser) { if (reportsGridData.CurrentQuery.ProjectIds.Length == 1) { var singleFilteredProjectId = reportsGridData.CurrentQuery.ProjectIds.FirstOrDefault(); SingleFilteredProjectName = Uow.ProjectRepository.LinkedCacheGetById(singleFilteredProjectId).Name; } }
public async Task <FileResult> ExportFileReportsGridAsync(ReportsGridView reportsGridData, HttpContext httpContext) { var groupByType = _reportService.GetReportsGrid(reportsGridData); var fileOfBytes = await CreateFileOfBytesReportsGridAsync(reportsGridData, groupByType); var fileStreamResult = SaveFileOfBytesToFileStreamResult(httpContext, fileOfBytes); return(fileStreamResult); }
public async Task <IActionResult> ReportsExportFileAsync([FromBody] ReportsGridView reportsGridData) { var result = await _service.ExportFileReportsGridAsync(reportsGridData, HttpContext); if (result == null) { return(BadRequest()); } return(result); }
public IActionResult GetGridAndSaveCurrentQuery([FromBody] ReportsGridView reportsGridView) { if (!ModelState.IsValid) { return(BadRequest("Invalid Model")); } try { var userName = this.GetUserNameWithImpersonation(); _reportsSettingsService.SaveCurrentQuery(reportsGridView.CurrentQuery, userName); // 0 - Default(none), 1 - Projects, 2 - Users, 3 - Dates, 4 - Clients. switch (reportsGridView.CurrentQuery.GroupById) { case (int)Constants.ReportsGroupBy.Project: { return(new JsonResult(_service.ReportsGridGroupByProjects(userName, reportsGridView))); } case (int)Constants.ReportsGroupBy.User: { return(new JsonResult(_service.ReportsGridGroupByUsers(userName, reportsGridView))); } case (int)Constants.ReportsGroupBy.Date: { return(new JsonResult(_service.ReportsGridGroupByDates(userName, reportsGridView))); } case (int)Constants.ReportsGroupBy.Client: { return(new JsonResult(_service.ReportsGridGroupByClients(userName, reportsGridView))); } default: { return(BadRequest("Invalid Grouping value")); } } } catch (Exception e) { _logger.LogWarning($"PostReportsGrid method with parameters ({reportsGridView});\n {e}"); var errors = ExceptionsChecker.CheckProjectsException(e); return(BadRequest(errors)); } }
public IActionResult ReportsExportFile([FromBody] ReportsGridView reportsGridData) { try { var userName = this.GetUserNameWithImpersonation(); switch (reportsGridData.CurrentQuery.GroupById) { case (int)ReportsGroupBy.Project: { return(_service.ExportFileGroupByProjects(userName, reportsGridData, HttpContext)); } case (int)ReportsGroupBy.User: { return(_service.ExportFileGroupByUsers(userName, reportsGridData, HttpContext)); } case (int)ReportsGroupBy.Date: { return(_service.ExportFileGroupByDates(userName, reportsGridData, HttpContext)); } case (int)ReportsGroupBy.Client: { return(_service.ExportFileGroupByClients(userName, reportsGridData, HttpContext)); } default: { return(_service.ExportFileGroupByNone(userName, reportsGridData, HttpContext)); } } } catch (InvalidOperationException invalidOperationException) { _logger.LogWarning(invalidOperationException.Message + $"\n {invalidOperationException}"); var errors = ExceptionsChecker.CheckRunMethodSetCommonValuesForExportException(invalidOperationException); return(BadRequest(errors)); } catch (Exception e) { _logger.LogWarning($"ReportsExportFile method with parameters ({reportsGridData});\n {e}"); var errors = ExceptionsChecker.CheckProjectsException(e); return(BadRequest(errors)); } }
public IActionResult GetReportsGridAndSaveCurrentQuery([FromBody] ReportsGridView reportsGridView) { if (!ModelState.IsValid) { return(BadRequest("Invalid Model")); } var jsonSerializatorSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver(), NullValueHandling = NullValueHandling.Ignore }; var reportsGrid = _service.GetReportsGrid(reportsGridView); return(new JsonResult(reportsGrid, jsonSerializatorSettings)); }
protected void btnYes_Click(object sender, EventArgs e) { try { dsPO_ShipmentATableAdapters.PIP_MAT_EXCEPTION_REPTableAdapter esd = new dsPO_ShipmentATableAdapters.PIP_MAT_EXCEPTION_REPTableAdapter(); esd.DeleteQuery(decimal.Parse(ReportsGridView.SelectedValue.ToString())); ReportsGridView.Rebind(); Master.ShowMessage("Report deleted."); esd.Dispose(); } catch (Exception ex) { // Master.ShowWarn(ex.Message); RadWindowManager1.RadAlert("Items Available in ESD!", 400, 150, "Warning", ""); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Master.HeadingMessage = "ESD Report"; try { if (Session["ESD_SESSION"] != null) { RadPersistenceManager1.LoadState(); ReportsGridView.Rebind(); } } catch (Exception ex) { } } }
private IQueryable <TimeEntry> GetTimeEntriesForGrouping(string userName, ReportsGridView reportsGridData) { var currentMember = Uow.MemberRepository.LinkedCacheGetByName(userName); if (currentMember == null) { throw new CoralTimeEntityNotFoundException($"Member with userName = {userName} not found."); } if (!currentMember.User.IsActive) { throw new CoralTimeEntityNotFoundException($"Member with userName = {userName} is not active."); } CommonHelpers.SetRangeOfWeekByDate(out var weekStart, out var weekEnd, DateTime.Now); DateFrom = reportsGridData.CurrentQuery?.DateFrom ?? weekStart; DateTo = reportsGridData.CurrentQuery?.DateTo ?? weekEnd; // By Dates (default grouping, i.e. "Group by None"; direct order). var timeEntriesByDateOfUser = GetTimeEntryByDate(currentMember, DateFrom, DateTo); // By Projects. if (reportsGridData.CurrentQuery?.ProjectIds != null && reportsGridData.CurrentQuery.ProjectIds.Length > 0) { CheckAndSetIfInFilterChooseSingleProject(reportsGridData, timeEntriesByDateOfUser); timeEntriesByDateOfUser = timeEntriesByDateOfUser.Where(x => reportsGridData.CurrentQuery.ProjectIds.Contains(x.ProjectId)); } // By Members. if (reportsGridData.CurrentQuery?.MemberIds != null && reportsGridData.CurrentQuery.MemberIds.Length > 0) { timeEntriesByDateOfUser = timeEntriesByDateOfUser.Where(x => reportsGridData.CurrentQuery.MemberIds.Contains(x.MemberId)); } // By Clients that has Projects. if (reportsGridData.CurrentQuery?.ClientIds != null && reportsGridData.CurrentQuery.ClientIds.Length > 0) { timeEntriesByDateOfUser = timeEntriesByDateOfUser.Where(x => reportsGridData.CurrentQuery.ClientIds.Contains(x.Project.ClientId) || x.Project.ClientId == null && reportsGridData.CurrentQuery.ClientIds.Contains(WithoutClient.Id)); } return(timeEntriesByDateOfUser); }
private async Task <byte[]> CreateFileOfBytesReportsGridAsync(ReportsGridView reportsGridView, ReportTotalView reportTotalView) { var fileOfBytes = new byte[0]; // TODO Check! UpdateFileName((DateTime)reportsGridView.CurrentQuery.DateFrom, (DateTime)reportsGridView.CurrentQuery.DateTo); switch (reportsGridView.FileTypeId ?? 0) { case (int)FileType.Excel: { FileName = FileName + ExtensionXLSX; fileOfBytes = CreateFileExcel(reportTotalView); ContentType = ContentTypeXLSX; break; } case (int)FileType.CSV: { FileName = FileName + ExtensionCSV; //file = CreateFileCSV(reportTotalView); ContentType = ContentTypeCSV; break; } case (int)FileType.PDF: { FileName = FileName + ExtensionPDF; fileOfBytes = await CreateFilePDFAsync(reportTotalView); ContentType = ContentTypePDF; break; } } return(fileOfBytes); }
private byte[] CreateReportFileByteUpdateFileNameContentType <T>(ReportsGridView reportsGridData, IReportsGrandGridView <T> groupingList) { SetCommonValuesForExport <T>(reportsGridData); var file = new byte[0]; UpdateFileName(); switch (reportsGridData.FileTypeId ?? 0) { case (int)FileType.Excel: { FileName = FileName + ExtensionXLSX; file = CreateFileExcel(groupingList); ContentType = ContentTypeXLSX; break; } case (int)FileType.CSV: { FileName = FileName + ExtensionCSV; file = CreateFileCSV(groupingList); ContentType = ContentTypeCSV; break; } case (int)FileType.PDF: { FileName = FileName + ExtensionPDF; file = CreateFilePDF(groupingList); ContentType = ContentTypePDF; break; } } return(file); }
private void CheckAndSaveCurrentQuery(ReportsGridView reportsGridView) { var queryDateFrom = reportsGridView.CurrentQuery.DateFrom; var queryDateTo = reportsGridView.CurrentQuery.DateTo; var memberImpersonatedId = MemberImpersonated.Id; var currentQuery = reportsGridView.CurrentQuery; var dateStaticId = reportsGridView.CurrentQuery.DateStaticId; if (dateStaticId != null) { var dateStaticExtend = CreateDateStaticExtend(dateStaticId); var calculateByStaticIdDateFrom = dateStaticExtend.DateFrom; var calculateByStaticIdDateTo = dateStaticExtend.DateTo; if (queryDateFrom != calculateByStaticIdDateFrom && queryDateTo != calculateByStaticIdDateTo) { throw new CoralTimeDangerException("DateFrom, DateTo from query not equals new DateFrom, DateTo that calculated by DateStaticId"); } } _reportsSettingsService.UpdateCurrentQuery(currentQuery, memberImpersonatedId); }
public ReportTotalView GetReportsGrid(ReportsGridView reportsGridView) { CheckAndSaveCurrentQuery(reportsGridView); var dateFrom = reportsGridView.CurrentQuery.DateFrom; var dateTo = reportsGridView.CurrentQuery.DateTo; var groupById = reportsGridView.CurrentQuery.GroupById; var showColumnIds = reportsGridView.CurrentQuery.ShowColumnIds; var dateFormatId = reportsGridView.DateFormatId; var reportTotalView = new ReportTotalView(groupById, showColumnIds, dateFormatId, dateFrom, dateTo); var filteredTimeEntries = GetFilteredTimeEntries(reportsGridView); if (filteredTimeEntries.Any()) { switch (reportsGridView.CurrentQuery.GroupById) { case (int)ReportsGroupByIds.Project: { var timeEntriesGroupByProjects = filteredTimeEntries .GroupBy(i => i.Project) .OrderBy(x => x.Key.Name) .ToDictionary(key => key.Key, value => value.OrderBy(x => x.Date).ToList()); return(reportTotalView.GetView(timeEntriesGroupByProjects)); } case (int)ReportsGroupByIds.Member: { var timeEntriesGroupByMembers = filteredTimeEntries .GroupBy(i => i.Member) .OrderBy(x => x.Key.FullName) .ToDictionary(key => key.Key, value => value.OrderBy(x => x.Date).ToList()); return(reportTotalView.GetView(timeEntriesGroupByMembers)); } case (int)ReportsGroupByIds.Date: { var timeEntriesGroupByDate = filteredTimeEntries .GroupBy(i => i.Date) .OrderBy(x => x.Key) .ToDictionary(key => key.Key, key => key.OrderBy(x => x.Date).ToList()); return(reportTotalView.GetView(timeEntriesGroupByDate)); } case (int)ReportsGroupByIds.Client: { var timeEntriesGroupByClients = filteredTimeEntries .GroupBy(i => i.Project.Client == null ? CreateWithOutClientInstance() : i.Project.Client) .OrderBy(x => x.Key.Name) .ToDictionary(key => key.Key, value => value.OrderBy(x => x.Date).ToList()); return(reportTotalView.GetView(timeEntriesGroupByClients)); } } } return(reportTotalView); }
public IActionResult SaveCustomQuery([FromBody] ReportsGridView reportsGridView) { _service.SaveCustomQuery(reportsGridView.CurrentQuery, this.GetUserNameWithImpersonation()); return(Ok()); }
public IActionResult SaveCustomQuery([FromBody] ReportsGridView reportsGridView) { _service.SaveCustomQuery(reportsGridView.CurrentQuery); return(Ok()); }