Example #1
0
        private void DrawReportFooterSummary(PagingSetup pagingSetup, PdfDocument document,
                                             RemovalNote removalNote, string removalUser)
        {
            ReportUtils.DrawParagraphLine(pagingSetup, document,
                                          pagingSetup.RegularFont, XParagraphAlignment.Justify,
                                          pagingSetup.RegularLineHeight,
                                          string.Format("Người hủy: {0} Ngày hủy: {1}",
                                                        removalUser, removalNote.RemovalDate.ToString(CommonConstant.DateFormatDisplay)));

            ReportUtils.DrawParagraphLine(pagingSetup, document,
                                          pagingSetup.RegularFont, XParagraphAlignment.Justify,
                                          pagingSetup.RegularLineHeight,
                                          string.Format("Lý do hủy: {0}", removalNote.RemovalReason));

            ReportUtils.DrawParagraphLine(pagingSetup, document,
                                          pagingSetup.RegularFont, XParagraphAlignment.Left,
                                          pagingSetup.RegularLineHeight,
                                          string.Format("Phương pháp hủy mẫu:.............................................................................................................................................."));

            ReportUtils.DrawParagraphLine(pagingSetup, document,
                                          pagingSetup.RegularFont, XParagraphAlignment.Justify,
                                          pagingSetup.RegularLineHeight,
                                          string.Format("Quản lý mẫu kiểm tra:..........................................................................................................Ngày.....tháng.....năm....."));

            ReportUtils.DrawParagraphLine(pagingSetup, document,
                                          pagingSetup.RegularFont, XParagraphAlignment.Justify,
                                          pagingSetup.RegularLineHeight,
                                          string.Format("Quản lý an toàn:..................................................................................................................Ngày.....tháng.....năm....."));

            ReportUtils.DrawParagraphLine(pagingSetup, document,
                                          pagingSetup.RegularFont, XParagraphAlignment.Justify,
                                          pagingSetup.RegularLineHeight,
                                          string.Format("Trưởng PTN phê duyệt:........................................................................................................Ngày.....tháng.....năm....."));
        }
Example #2
0
        private void DrawReportSummary(PagingSetup pagingSetup, PdfDocument document,
                                       SampleSpecInfo sampleSpecInfo)
        {
            ReportUtils.IncreaseLineHeight(pagingSetup, document, pagingSetup.RegularLineHeight);

            ReportUtils.DrawParagraphLine(pagingSetup, document, PagingSetup.CreateDefaultPDFRegularFont(),
                                          XParagraphAlignment.Left, pagingSetup.RegularLineHeight,
                                          string.Format("Mã bệnh phẩm: {0}", sampleSpecInfo.SampleSpecId));

            ReportUtils.DrawParagraphLine(pagingSetup, document, PagingSetup.CreateDefaultPDFRegularFont(),
                                          XParagraphAlignment.Left, pagingSetup.RegularLineHeight,
                                          string.Format("Tên bệnh nhân: {0}", sampleSpecInfo.PatientName));

            ReportUtils.DrawParagraphLine(pagingSetup, document, PagingSetup.CreateDefaultPDFRegularFont(),
                                          XParagraphAlignment.Left, pagingSetup.RegularLineHeight,
                                          string.Format("Giới tính: {0}", sampleSpecInfo.SexDisplay));

            ReportUtils.DrawParagraphLine(pagingSetup, document, PagingSetup.CreateDefaultPDFRegularFont(),
                                          XParagraphAlignment.Left, pagingSetup.RegularLineHeight,
                                          string.Format("Năm sinh: {0}", sampleSpecInfo.YearOfBirth));

            ReportUtils.DrawParagraphLine(pagingSetup, document, PagingSetup.CreateDefaultPDFRegularFont(),
                                          XParagraphAlignment.Left, pagingSetup.RegularLineHeight,
                                          string.Format("Nguồn: {0}", sampleSpecInfo.LocationId));

            ReportUtils.DrawParagraphLine(pagingSetup, document, PagingSetup.CreateDefaultPDFRegularFont(),
                                          XParagraphAlignment.Left, pagingSetup.RegularLineHeight,
                                          string.Format("Thời gian nhập: {0}", sampleSpecInfo.DateInputDisplay));

            ReportUtils.DrawParagraphLine(pagingSetup, document, PagingSetup.CreateDefaultPDFRegularFont(),
                                          XParagraphAlignment.Left, pagingSetup.RegularLineHeight,
                                          string.Format("Danh sách nhập"));
        }
        public async Task <IPaging <MessageDtoForPaging> > Get(MessageType messageType
                                                               , string receiverUsername, string searchTerm, string sortItem, string sortOrder
                                                               , PagingQueryString pagingQueryString)
        {
            IPaging <MessageDtoForPaging> model = new MessageDtoPagingList();

            var receiver = await _authRepository.FindUserByUsernameAsync(receiverUsername);

            if (receiver != null)
            {
                var query = !string.IsNullOrEmpty(searchTerm)
                ? _messageRepository.Get(q => q.MessageType == messageType && q.ReceiverId == receiver.Id &&
                                         q.Title.Contains(searchTerm.ToLower()), includeProperties: "Sender,Receiver")
                : _messageRepository.Get(q => q.MessageType == messageType && q.ReceiverId == receiver.Id
                                         , includeProperties: "Sender,Receiver");
                //total number of items
                int queryCount = query.Count();
                switch (sortItem)
                {
                case "title":
                    query = sortOrder == "asc" ? query.OrderBy(o => o.Title)
                            : query.OrderByDescending(o => o.Title);
                    break;

                case "date":
                    query = sortOrder == "asc" ? query.OrderBy(o => o.Date)
                            : query.OrderByDescending(o => o.Date);
                    break;

                default:
                    query = query.OrderByDescending(o => o.Id);
                    break;
                }

                List <Message> queryResult;
                if (pagingQueryString != null) //with paging
                {
                    var pageSetup = new PagingSetup(pagingQueryString.Page, pagingQueryString.PageSize);
                    queryResult = query.Skip(pageSetup.Offset).Take(pageSetup.Next).ToList();
                    //paging controls
                    var controls = pageSetup.GetPagingControls(queryCount, PagingStrategy.ReturnNull);
                    if (controls != null)
                    {
                        model.PagesCount = controls.PagesCount;
                        model.NextPage   = controls.NextPage;
                        model.PrevPage   = controls.PrevPage;
                    }
                }
                else //without paging
                {
                    queryResult = query.ToList();
                }
                model.PagingList = Mapper.Map <List <MessageDtoForPaging> >(queryResult);
            }

            return(model);
        }
        public IPaging <RestrictedAccessTimeDto> Get(string searchTerm, string sortItem, string sortOrder
                                                     , PagingQueryString pagingQueryString)
        {
            IPaging <RestrictedAccessTimeDto> model = new RestrictedAccessTimeDtoPagingList();

            var query = //!string.IsNullOrEmpty(searchTerm)
                        //? _restrictedAccessTimeRepository.Get(q => q.Title.Contains(searchTerm.ToLower()))
                        //:
                        _restrictedAccessTimeRepository.Get();
            //total number of items
            int queryCount = query.Count();

            switch (sortItem)
            {
            case "date":
                query = sortOrder == "asc" ? query.OrderBy(o => o.Date)
                        : query.OrderByDescending(o => o.Date);
                break;

            case "from_time":
                query = sortOrder == "asc" ? query.OrderBy(o => o.FromTime)
                        : query.OrderByDescending(o => o.FromTime);
                break;

            case "to_time":
                query = sortOrder == "asc" ? query.OrderBy(o => o.ToTime)
                        : query.OrderByDescending(o => o.ToTime);
                break;

            default:
                query = query.OrderByDescending(o => o.Id);
                break;
            }

            List <RestrictedAccessTime> queryResult;

            if (pagingQueryString != null) //with paging
            {
                var pageSetup = new PagingSetup(pagingQueryString.Page, pagingQueryString.PageSize);
                queryResult = query.Skip(pageSetup.Offset).Take(pageSetup.Next).ToList();
                //paging controls
                var controls = pageSetup.GetPagingControls(queryCount, PagingStrategy.ReturnNull);
                if (controls != null)
                {
                    model.PagesCount = controls.PagesCount;
                    model.NextPage   = controls.NextPage;
                    model.PrevPage   = controls.PrevPage;
                }
            }
            else //without paging
            {
                queryResult = query.ToList();
            }
            model.PagingList = Mapper.Map <List <RestrictedAccessTimeDto> >(queryResult);

            return(model);
        }
        public FileContentResult ExportHistory(string startDate, string endDate)
        {
            MemoryStream stream = new MemoryStream();

            try
            {
                DateTime startDateValue = DateTime.Today.AddDays(-ExportHistoryDefaultRange);
                DateTime endDateValue   = DateTime.Today;

                if (!string.IsNullOrEmpty(startDate))
                {
                    startDateValue = DateTime.ParseExact(startDate,
                                                         CommonConstant.UniversalDateFormat, CultureInfo.InvariantCulture);
                }

                if (!string.IsNullOrEmpty(endDate))
                {
                    endDateValue = DateTime.ParseExact(endDate,
                                                       CommonConstant.UniversalDateFormat, CultureInfo.InvariantCulture);
                }

                var reportDetailList = _reportService.GetExportHistory(new ReportService.GetExportHistoryParam()
                {
                    EndDate   = endDateValue,
                    StartDate = startDateValue
                });

                PagingSetup pagingSetup = ReportUtils.CreateDefaultPagingSetup();
                pagingSetup.PageOrientation = PageOrientation.Landscape;
                pagingSetup.PageSize        = PageSize.A4;
                PdfDocument document = ReportUtils.CreateDefaultPdfDocument(pagingSetup);

                ReportUtils.DrawReportHeader(pagingSetup, document, "Thống kê mẫu đã xuất", labID);
                ExportHistoryDrawReportSummary(pagingSetup, document, startDateValue, endDateValue);

                var gridTable = new ReportGridTable <ReportExportHistoryInfo>()
                {
                    Columns = ExportHistoryImportGridColumns(),
                    Datas   = reportDetailList
                };

                ReportUtils.DrawGrid(gridTable, pagingSetup, document);
                ReportUtils.DrawReportFooter(pagingSetup, document, labID);
                document.Save(stream);
            }
            catch (BusinessException exception)
            {
                _logger.DebugFormat("BusinessException: {0}-{1}", exception.ErrorCode, exception.Message);
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("Iternal error {0}", exception));
            }
            stream.Flush();
            return(File(stream.ToArray(), "application/pdf"));
        }
Example #6
0
        public IPaging <UserLogDto> Get(string userId, string searchTerm, string sortItem
                                        , string sortOrder, PagingQueryString pagingQueryString)
        {
            IPaging <UserLogDto> model = new UserLogDtoPagingList();

            var query = !string.IsNullOrEmpty(searchTerm)
                ? _userLoggerRepository.Get(q => q.UserId == userId &&
                                            q.User.UserName.ToLower().Contains(searchTerm.ToLower())
                                            , includeProperties: "User")
                : _userLoggerRepository.Get(q => q.UserId == userId, includeProperties: "User");
            //total number of items
            int queryCount = query.Count();

            switch (sortItem)
            {
            case "username":
                query = sortOrder == "asc" ? query.OrderBy(o => o.User.UserName)
                        : query.OrderByDescending(o => o.User.UserName);
                break;

            case "date":
                query = sortOrder == "asc" ? query.OrderBy(o => o.Date)
                        : query.OrderByDescending(o => o.Date);
                break;

            default:
                query = query.OrderByDescending(o => o.Date);
                break;
            }

            List <UserLog> queryResult;

            if (pagingQueryString != null) //with paging
            {
                var pageSetup = new PagingSetup(pagingQueryString.Page, pagingQueryString.PageSize);
                queryResult = query.Skip(pageSetup.Offset).Take(pageSetup.Next).ToList();
                //paging controls
                var controls = pageSetup.GetPagingControls(queryCount, PagingStrategy.ReturnNull);
                if (controls != null)
                {
                    model.PagesCount = controls.PagesCount;
                    model.NextPage   = controls.NextPage;
                    model.PrevPage   = controls.PrevPage;
                }
            }
            else //without paging
            {
                queryResult = query.ToList();
            }
            model.PagingList = Mapper.Map <List <UserLogDto> >(queryResult);

            return(model);
        }
        public IPaging <ApprovalProcDtoForPaging> Get(string searchTerm, string sortItem
                                                      , string sortOrder, PagingQueryString pagingQueryString)
        {
            IPaging <ApprovalProcDtoForPaging> model = new ApprovalProcDtoPagingList();

            var query = !string.IsNullOrEmpty(searchTerm)
                ? _approvalProcRepository.Get(q => q.Title.Contains(searchTerm.ToLower())
                                              , includeProperties: "ParentProc")
                : _approvalProcRepository.Get(includeProperties: "ParentProc");

            //total number of items
            int queryCount = query.Count();

            switch (sortItem)
            {
            case "title":
                query = sortOrder == "asc" ? query.OrderBy(o => o.Title)
                        : query.OrderByDescending(o => o.Title);
                break;

            case "parent_title":
                query = sortOrder == "asc" ? query.OrderBy(o => o.ParentProc.Title)
                        : query.OrderByDescending(o => o.ParentProc.Title);
                break;

            default:
                query = query.OrderByDescending(o => o.Id);
                break;
            }

            List <ApprovalProc> queryResult;

            if (pagingQueryString != null) //with paging
            {
                var pageSetup = new PagingSetup(pagingQueryString.Page, pagingQueryString.PageSize);
                queryResult = query.Skip(pageSetup.Offset).Take(pageSetup.Next).ToList();
                //paging controls
                var controls = pageSetup.GetPagingControls(queryCount, PagingStrategy.ReturnNull);
                if (controls != null)
                {
                    model.PagesCount = controls.PagesCount;
                    model.NextPage   = controls.NextPage;
                    model.PrevPage   = controls.PrevPage;
                }
            }
            else //without paging
            {
                queryResult = query.ToList();
            }
            model.PagingList = Mapper.Map <List <ApprovalProcDtoForPaging> >(queryResult);

            return(model);
        }
        private void ExportHistoryDrawReportSummary(PagingSetup pagingSetup, PdfDocument document,
                                                    DateTime startDate, DateTime endDate)
        {
            var options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

            ReportUtils.DrawParagraphLine(pagingSetup, document, new XFont("Tahoma", 12, XFontStyle.Bold, options),
                                          XParagraphAlignment.Center, pagingSetup.RegularLineHeight,
                                          string.Format("Từ ngày: {0} - Đến ngày: {1}",
                                                        startDate.ToString(CommonConstant.DateFormatDisplay),
                                                        endDate.ToString(CommonConstant.DateFormatDisplay)));

            ReportUtils.IncreaseLineHeight(pagingSetup, document, pagingSetup.RegularLineHeight);
        }
        private void DrawReportFooter(PagingSetup pagingSetup, PdfDocument document,
                                      string userExportName, string userExportTo)
        {
            double signatureHeaderHeight    = pagingSetup.RegularLineHeight;
            double signatureContainerHeight = 100;
            double signatureContentName     = pagingSetup.RegularLineHeight;
            double footerGridHeight         = signatureHeaderHeight + signatureContainerHeight + signatureContentName;

            if (!ReportUtils.IsHeightInPage(pagingSetup, document, footerGridHeight))
            {
                ReportUtils.BreakPage(pagingSetup, document);
            }

            ReportUtils.DrawGridLine(new List <CellDisplay>()
            {
                new CellDisplay()
                {
                    Ratio = 50, DisplayText = "Người xuất mẫu", CellAlign = XStringFormats.Center, PaddingLeft = 10
                },
                new CellDisplay()
                {
                    Ratio = 50, DisplayText = "Người nhận mẫu", CellAlign = XStringFormats.Center, PaddingLeft = 10
                },
            }, pagingSetup, document, pagingSetup.GridHeaderFont, signatureHeaderHeight);

            ReportUtils.DrawGridLine(new List <CellDisplay>()
            {
                new CellDisplay()
                {
                    Ratio = 50, DisplayText = "", CellAlign = XStringFormats.Center, PaddingLeft = 10
                },
                new CellDisplay()
                {
                    Ratio = 50, DisplayText = "", CellAlign = XStringFormats.Center, PaddingLeft = 10
                },
            }, pagingSetup, document, pagingSetup.RegularFont, signatureContainerHeight);

            ReportUtils.DrawGridLine(new List <CellDisplay>()
            {
                new CellDisplay()
                {
                    Ratio = 50, DisplayText = userExportName, CellAlign = XStringFormats.Center, PaddingLeft = 10
                },
                new CellDisplay()
                {
                    Ratio = 50, DisplayText = userExportTo, CellAlign = XStringFormats.Center, PaddingLeft = 10
                },
            }, pagingSetup, document, pagingSetup.RegularFont, signatureContentName);
        }
Example #10
0
        private void DrawReportSummary(PagingSetup pagingSetup, PdfDocument document,
                                       RemovalNote removalNote)
        {
            var options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

            ReportUtils.DrawParagraphLine(pagingSetup, document, new XFont("Tahoma", 12, XFontStyle.Bold, options),
                                          XParagraphAlignment.Center, pagingSetup.RegularLineHeight,
                                          string.Format("Mã hủy: {0}", removalNote.RemovalId));

            ReportUtils.IncreaseLineHeight(pagingSetup, document, pagingSetup.RegularLineHeight);

            ReportUtils.DrawParagraphLine(pagingSetup, document, PagingSetup.CreateDefaultPDFRegularFont(),
                                          XParagraphAlignment.Left, pagingSetup.RegularLineHeight,
                                          "Danh sách hủy: ");
        }
        public FileContentResult Print(string id)
        {
            MemoryStream stream = new MemoryStream();

            try
            {
                var exportInfo        = _tubeSampleService.GetExportInfo(id);
                var exportUserInfo    = _userService.GetLoginUserInfo(exportInfo.ExportUserId);
                var exportForUserInfo = _userService.GetLoginUserInfo(exportInfo.ExportForUserId);

                PagingSetup pagingSetup = ReportUtils.CreateDefaultPagingSetup();
                PdfDocument document    = ReportUtils.CreateDefaultPdfDocument(pagingSetup);
                ReportUtils.DrawReportHeader(pagingSetup, document, "PHIẾU XUẤT MẪU", labID);
                DrawReportHeaderSummary(pagingSetup, document, exportInfo);

                var gridTable = new ReportGridTable <ExportNoteDetail>()
                {
                    Columns = ExportGridColumns(),
                    Datas   = exportInfo.ExportNoteDetails
                };

                ReportUtils.DrawGrid(gridTable, pagingSetup, document);

                ReportUtils.IncreaseLineHeight(pagingSetup, document, pagingSetup.RegularLineHeight);

                DrawReportFooterSummary(pagingSetup, document, exportInfo);

                DrawReportFooter(pagingSetup, document,
                                 exportUserInfo == null ? exportInfo.ExportUserId : exportUserInfo.FullName,
                                 exportForUserInfo == null ? exportInfo.ExportForUserId : exportForUserInfo.FullName);

                ReportUtils.DrawReportFooter(pagingSetup, document, labID);
                document.Save(stream);
            }
            catch (BusinessException exception)
            {
                _logger.DebugFormat("BusinessException: {0}-{1}", exception.ErrorCode, exception.Message);
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("Iternal error {0}", exception));
            }
            stream.Flush();
            return(File(stream.ToArray(), "application/pdf"));
        }
        private void DrawReportFooterSummary(PagingSetup pagingSetup, PdfDocument document,
                                             ExportNote exportNote)
        {
            ReportUtils.DrawParagraphLine(pagingSetup, document,
                                          pagingSetup.RegularFont, XParagraphAlignment.Left,
                                          pagingSetup.RegularLineHeight,
                                          string.Format("Mục đích sử dụng: {0}", exportNote.ExportReason));

            ReportUtils.DrawParagraphLine(pagingSetup, document,
                                          pagingSetup.RegularFont, XParagraphAlignment.Left,
                                          pagingSetup.RegularLineHeight,
                                          string.Format("Ngày xuất mẫu: {0}", exportNote.ExportDateDisplay));

            ReportUtils.DrawParagraphLine(pagingSetup, document,
                                          pagingSetup.RegularFont, XParagraphAlignment.Left,
                                          pagingSetup.RegularLineHeight,
                                          string.Format("Ngày in: {0}",
                                                        DateTime.Now.ToString(CommonConstant.DateTimeFormatDisplay)));
        }
        public FileContentResult SampleStatistics()
        {
            MemoryStream stream = new MemoryStream();

            try
            {
                var reportDetailList = _reportService.GetSampleStatistics();

                PagingSetup pagingSetup = ReportUtils.CreateDefaultPagingSetup();
                pagingSetup.PageOrientation = PageOrientation.Landscape;
                pagingSetup.PageSize        = PageSize.A4;
                PdfDocument document = ReportUtils.CreateDefaultPdfDocument(pagingSetup);
                PdfPage     page     = document.Pages[0];
                ReportUtils.DrawReportHeader(pagingSetup, document, "Thống kê tổng hợp", labID);
                ReportUtils.IncreaseLineHeight(pagingSetup, document, pagingSetup.RegularLineHeight);

                var gridTable = new ReportGridTable <ReportSampleStatisticInfo>()
                {
                    Columns = SampleStatisticsImportGridColumns(),
                    Datas   = reportDetailList
                };

                ReportUtils.DrawGrid(gridTable, pagingSetup, document);
                ReportUtils.DrawReportFooter(pagingSetup, document, labID);
                document.Save(stream);
            }
            catch (BusinessException exception)
            {
                _logger.DebugFormat("BusinessException: {0}-{1}", exception.ErrorCode, exception.Message);
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("Iternal error {0}", exception));
            }
            stream.Flush();
            return(File(stream.ToArray(), "application/pdf"));
        }
Example #14
0
        public FileContentResult Print(string id)
        {
            MemoryStream stream = new MemoryStream();

            try
            {
                var sampleSpec = _tubeSampleService.GetSampleSpec(id);
                var importNote = _tubeSampleService.GetImportInfo(id);
                //var historyData = _tubeSampleService.GetImportHistory(id);

                PagingSetup pagingSetup = ReportUtils.CreateDefaultPagingSetup();
                PdfDocument document    = ReportUtils.CreateDefaultPdfDocument(pagingSetup);
                PdfPage     page        = document.Pages[0];
                ReportUtils.DrawReportHeader(pagingSetup, document, "Thông tin phiếu nhập", labID);
                DrawReportSummary(pagingSetup, document, sampleSpec);

                var gridTable = new ReportGridTable <ImportNoteDetail>()
                {
                    Columns = ImportGridColumns(),
                    Datas   = importNote.ImportNoteDetails
                };

                ReportUtils.DrawGrid(gridTable, pagingSetup, document);
                ReportUtils.DrawReportFooter(pagingSetup, document, labID);
                document.Save(stream);
            }
            catch (BusinessException exception)
            {
                _logger.DebugFormat("BusinessException: {0}-{1}", exception.ErrorCode, exception.Message);
            }
            catch (Exception exception)
            {
                _logger.Error(string.Format("Iternal error {0}", exception));
            }
            stream.Flush();
            return(File(stream.ToArray(), "application/pdf"));
        }
        public IPaging <PersonnelDismissalEntranceDto> Get(string username, string fromDate, string toDate
                                                           , string searchTerm, string sortItem, string sortOrder, PagingQueryString pagingQueryString)
        {
            IPaging <PersonnelDismissalEntranceDto> model = new PersonnelDismissalEntranceDtoPagingList();

            IQueryable <PersonnelDismissalEntrance> query = null;

            var personnel = _personnelRepository.Get(q => q.Code == username).SingleOrDefault();

            if (personnel != null)
            {
                query = !string.IsNullOrEmpty(searchTerm)
                ? _personnelDismissalEntranceRepository
                        .Get(q => q.PersonnelId == personnel.Id &&
                             (q.Personnel.Name.Contains(searchTerm.ToLower()) ||
                              q.Personnel.LastName.Contains(searchTerm.ToLower()))
                             , includeProperties: "Personnel")
                : _personnelDismissalEntranceRepository.Get(q => q.PersonnelId == personnel.Id
                                                            , includeProperties: "Personnel");
            }
            else
            {
                query = !string.IsNullOrEmpty(searchTerm)
                ? _personnelDismissalEntranceRepository
                        .Get(q => q.Personnel.Name.Contains(searchTerm.ToLower()) ||
                             q.Personnel.LastName.Contains(searchTerm.ToLower())
                             , includeProperties: "Personnel")
                : _personnelDismissalEntranceRepository.Get(includeProperties: "Personnel");
            }

            if (!string.IsNullOrEmpty(fromDate))
            {
                var fromDateConverted = DateTime.Parse(fromDate);
                query = query.Where(q => q.StartDate >= fromDateConverted);
            }
            if (!string.IsNullOrEmpty(toDate))
            {
                var toDateConverted = DateTime.Parse(toDate);
                query = query.Where(q => q.StartDate <= toDateConverted);
            }

            //total number of items
            int queryCount = query.Count();

            switch (sortItem)
            {
            case "personnel_full_name":
                query = sortOrder == "asc" ? query.OrderBy(o => o.Personnel.Name + " " + o.Personnel.LastName)
                        : query.OrderByDescending(o => o.Personnel.Name + " " + o.Personnel.LastName);
                break;

            case "personnel_code":
                query = sortOrder == "asc" ? query.OrderBy(o => o.Personnel.Code)
                        : query.OrderByDescending(o => o.Personnel.LastName);
                break;

            case "enter":
                query = sortOrder == "asc" ? query.OrderBy(o => o.StartDate).ThenBy(o => o.Start)
                        : query.OrderByDescending(o => o.StartDate).ThenByDescending(o => o.Start);
                break;

            default:
                query = query.OrderByDescending(o => o.StartDate).ThenByDescending(o => o.Start);
                break;
            }

            List <PersonnelDismissalEntrance> queryResult;

            if (pagingQueryString != null) //with paging
            {
                var pageSetup = new PagingSetup(pagingQueryString.Page, pagingQueryString.PageSize);
                queryResult = query.Skip(pageSetup.Offset).Take(pageSetup.Next).ToList();
                //paging controls
                var controls = pageSetup.GetPagingControls(queryCount, PagingStrategy.ReturnNull);
                if (controls != null)
                {
                    model.PagesCount = controls.PagesCount;
                    model.NextPage   = controls.NextPage;
                    model.PrevPage   = controls.PrevPage;
                }
            }
            else //without paging
            {
                queryResult = query.ToList();
            }
            model.PagingList = Mapper.Map <List <PersonnelDismissalEntranceDto> >(queryResult);

            return(model);
        }
Example #16
0
        public IPaging <PersonnelShiftReplacementDtoForPaging> Get(string username
                                                                   , string searchTerm, string sortItem, string sortOrder, PagingQueryString pagingQueryString)
        {
            IPaging <PersonnelShiftReplacementDtoForPaging> model = new PersonnelShiftReplacementDtoPagingList();

            IQueryable <PersonnelShiftReplacement> query = null;

            var personnel = _personnelRepository.Get(q => q.Code == username).SingleOrDefault();

            if (personnel != null)
            {
                query = !string.IsNullOrEmpty(searchTerm)
                ? _personnelShiftReplacementRepository.Get(q => q.PersonnelId == personnel.Id &&
                                                           (q.Personnel.Name.Contains(searchTerm.ToLower()) ||
                                                            q.Personnel.LastName.Contains(searchTerm.ToLower()) ||
                                                            q.ReplacedPersonnel.Name.Contains(searchTerm.ToLower()) ||
                                                            q.ReplacedPersonnel.LastName.Contains(searchTerm.ToLower()) ||
                                                            q.WorkingHour.Title.Contains(searchTerm.ToLower()) ||
                                                            q.ReplacedWorkingHour.Title.Contains(searchTerm.ToLower()))
                                                           , includeProperties: "Personnel,ReplacedPersonnel,WorkingHour,ReplacedWorkingHour")
                : _personnelShiftReplacementRepository
                        .Get(q => q.PersonnelId == personnel.Id
                             , includeProperties: "Personnel,ReplacedPersonnel,WorkingHour,ReplacedWorkingHour");
            }
            else
            {
                query = !string.IsNullOrEmpty(searchTerm)
                ? _personnelShiftReplacementRepository.Get(q => q.Personnel.Name.Contains(searchTerm.ToLower()) ||
                                                           q.Personnel.LastName.Contains(searchTerm.ToLower()) ||
                                                           q.ReplacedPersonnel.Name.Contains(searchTerm.ToLower()) ||
                                                           q.ReplacedPersonnel.LastName.Contains(searchTerm.ToLower()) ||
                                                           q.WorkingHour.Title.Contains(searchTerm.ToLower()) ||
                                                           q.ReplacedWorkingHour.Title.Contains(searchTerm.ToLower())
                                                           , includeProperties: "Personnel,ReplacedPersonnel,WorkingHour,ReplacedWorkingHour")
                : _personnelShiftReplacementRepository
                        .Get(includeProperties: "Personnel,ReplacedPersonnel,WorkingHour,ReplacedWorkingHour");
            }

            //total number of items
            int queryCount = query.Count();

            switch (sortItem)
            {
            case "personnel_name":
                query = sortOrder == "asc" ? query.OrderBy(o => o.Personnel.Name)
                        : query.OrderByDescending(o => o.Personnel.Name);
                break;

            case "personnel_last_name":
                query = sortOrder == "asc" ? query.OrderBy(o => o.Personnel.LastName)
                        : query.OrderByDescending(o => o.Personnel.LastName);
                break;

            case "working_hour_title":
                query = sortOrder == "asc" ? query.OrderBy(o => o.WorkingHour.Title)
                        : query.OrderByDescending(o => o.WorkingHour.Title);
                break;

            default:
                query = query.OrderByDescending(o => o.Id);
                break;
            }

            List <PersonnelShiftReplacement> queryResult;

            if (pagingQueryString != null) //with paging
            {
                var pageSetup = new PagingSetup(pagingQueryString.Page, pagingQueryString.PageSize);
                queryResult = query.Skip(pageSetup.Offset).Take(pageSetup.Next).ToList();
                //paging controls
                var controls = pageSetup.GetPagingControls(queryCount, PagingStrategy.ReturnNull);
                if (controls != null)
                {
                    model.PagesCount = controls.PagesCount;
                    model.NextPage   = controls.NextPage;
                    model.PrevPage   = controls.PrevPage;
                }
            }
            else //without paging
            {
                queryResult = query.ToList();
            }
            model.PagingList = Mapper.Map <List <PersonnelShiftReplacementDtoForPaging> >
                                   (queryResult);


            return(model);
        }
Example #17
0
        public IPaging <WorkingHourDtoForPaging> Get(int?shiftId, string searchTerm
                                                     , string sortItem, string sortOrder, PagingQueryString pagingQueryString)
        {
            IPaging <WorkingHourDtoForPaging> model = new WorkingHourDtoPagingList();

            IQueryable <WorkingHour> query = null;

            if (shiftId.HasValue)
            {
                query = !string.IsNullOrEmpty(searchTerm)
                ? _workingHourRepository.Get(q => q.ShiftId == shiftId.Value &&
                                             q.Title.Contains(searchTerm.ToLower())
                                             , includeProperties: "Shift")
                : _workingHourRepository.Get(q => q.ShiftId == shiftId.Value
                                             , includeProperties: "Shift");
            }
            else
            {
                query = !string.IsNullOrEmpty(searchTerm)
                ? _workingHourRepository.Get(q => q.Title.Contains(searchTerm.ToLower())
                                             , includeProperties: "Shift")
                : _workingHourRepository.Get(includeProperties: "Shift");
            }


            //total number of items
            int queryCount = query.Count();

            switch (sortItem)
            {
            case "title":
                query = sortOrder == "asc" ? query.OrderBy(o => o.Title)
                        : query.OrderByDescending(o => o.Title);
                break;

            case "shift_title":
                query = sortOrder == "asc" ? query.OrderBy(o => o.Shift.Title)
                        : query.OrderByDescending(o => o.Shift.Title);
                break;

            default:
                query = query.OrderByDescending(o => o.Id);
                break;
            }

            List <WorkingHour> queryResult;

            if (pagingQueryString != null) //with paging
            {
                var pageSetup = new PagingSetup(pagingQueryString.Page, pagingQueryString.PageSize);
                queryResult = query.Skip(pageSetup.Offset).Take(pageSetup.Next).ToList();
                //paging controls
                var controls = pageSetup.GetPagingControls(queryCount, PagingStrategy.ReturnNull);
                if (controls != null)
                {
                    model.PagesCount = controls.PagesCount;
                    model.NextPage   = controls.NextPage;
                    model.PrevPage   = controls.PrevPage;
                }
            }
            else //without paging
            {
                queryResult = query.ToList();
            }
            model.PagingList = Mapper.Map <List <WorkingHourDtoForPaging> >(queryResult);

            return(model);
        }