public bool UpdateStatus(string employeeId, int requestId)
        {
            var temp = _payslipDetailReponsitory.FindAll().Where(x => x.EmployeeID == employeeId && x.RequestID == requestId).FirstOrDefault();

            temp.Status = Status.success;
            _requestDetailReponsitory.Commit();
            return(true);
        }
Пример #2
0
        public bool ConvertHtmlToPdf(int RequestID)
        {
            var payslips = _payslipDetailReponsitory.FindAll().Where(x => x.RequestID == RequestID).ToList();
            var request  = _requestDetailService.GetById(RequestID);
            var temp     = _requestDetailReponsitory.FindById(RequestID);

            _requestDetailReponsitory.Commit();
            string month = months[request.PayslipForMonth];

            if (payslips == null)
            {
                return(false);
            }

            foreach (var item in payslips)
            {
                PdfDocument  checkPDF        = null;
                InputPdfFile model           = InputPdfFile(item);
                string       StringHtml      = _viewRenderService.RenderToStringAsync(@"../../Pages/PayslipTemplate", model).GetAwaiter().GetResult();
                string       folderPath      = @"..\OSDPayslip.Web\wwwroot\PDF\" + RequestID.ToString();
                string       pdfPath         = folderPath + @"\" + model.Id + "_Payslips_" + month + ".pdf";
                var          pdfPrintOptions = new PdfPrintOptions()
                {
                    DPI = 300,
                };

                if (!Directory.Exists(folderPath))
                {
                    Directory.CreateDirectory(folderPath);
                }
                HtmlToPdf Renderer = new HtmlToPdf(pdfPrintOptions);
                Renderer.PrintOptions.PaperSize = PdfPrintOptions.PdfPaperSize.A2;
                checkPDF = Renderer.RenderHtmlAsPdf(StringHtml).SaveAs(pdfPath);
                if (checkPDF != null)
                {
                    PdfDocument         Pdf = PdfDocument.FromFile(pdfPath);
                    PdfSecuritySettings securitySettings = Pdf.SecuritySettings;
                    securitySettings.UserPassword = CreatePassWord(model.IdentidyId, model.BirthDay);
                    if (Pdf.Password != null)
                    {
                        Pdf.SaveAs(pdfPath);
                    }
                }
            }

            return(true);
        }
 public void Save()
 {
     _requestDetailReponsitory.Commit();
 }