public async Task VanThuKyVaTraGiayTiepNhan(PhieuTiepNhanInputDto input) { var hoso = await _hoSoRepos.GetAsync(input.HoSoId); var hsxl = await _hoSoXuLyRepos.GetAsync(hoso.HoSoXuLyId_Active.Value); if (hoso.IsHoSoBS != true) { int tenantId = GetTenantIdFromHoSo(hoso); var thanhToan = new ThanhToan() { HoSoId = hoso.Id, DoanhNghiepId = hoso.DoanhNghiepId, PhiDaNop = input.PhiDaNop, NgayGiaoDich = DateTime.Now, PhiXacNhan = input.PhiDaNop, TenantId = tenantId, PhanHeId = _thuTucId, TrangThaiNganHang = (int)CommonENum.TRANG_THAI_GIAO_DICH.GIAO_DICH_THANH_CONG }; hoso.ThanhToanId_Active = await _thanhToanRepos.InsertAndGetIdAsync(thanhToan); } hsxl.VanThuId = _session.UserId; hsxl.DonViGui = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN; hsxl.NguoiGuiId = SessionCustom.UserCurrent.Id; hsxl.DonViXuLy = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN; hsxl.NguoiXuLyId = SessionCustom.UserCurrent.Id; hsxl.NgayGui = DateTime.Now; hsxl.GiayTiepNhanCA = input.GiayTiepNhanCA; hsxl.NgayHenCap = input.NgayHenCap; hsxl.NgayHenTra = input.NgayHenCap; hsxl.HinhThucCapCTJson = JsonConvert.SerializeObject(input.HinhThucCapChungChi); hsxl.TaiLieuDaNhanJson = JsonConvert.SerializeObject(input.ListTaiLieuDaNhan); hsxl.NgayTraGiayTiepNhan = DateTime.Now; #region Lưu lịch sử var _history = new XHoSoXuLyHistory(); _history.HoSoId = hoso.Id; _history.HoSoXuLyId = hsxl.Id; _history.LoaiHoSoId = hoso.LoaiHoSoId; _history.NguoiXuLyId = SessionCustom.UserCurrent.Id; _history.DonViXuLy = (int)CommonENum.DON_VI_XU_LY.MOT_CUA_TIEP_NHAN; _history.ActionEnum = (int)CommonENum.FORM_FUNCTION.MOT_CUA_RA_SOAT_HO_SO; _history.NgayXuLy = DateTime.Now; var _historyId = _hoSoXuLyHistoryRepos.InsertOrUpdateAndGetId(_history); #endregion }
public async Task <byte[]> GoToViewPhieuTiepNhan(PhieuTiepNhanInputDto input) { try { byte[] fileTemplate = null; ExcelFile xls = null; XlsFile Result = new XlsFile(true); using (FlexCelReport fr = new FlexCelReport(true)) { string DuongDan = "/ThuTuc_37/PhieuTiepNhan.xlsx"; var path = _appFolders.PDFTemplate + DuongDan; var hoso = await _hoSoRepos.GetAsync(input.HoSoId); fr.SetValue("HoVaTen", hoso.TenNguoiDaiDien); fr.SetValue("DiaChi", hoso.DiaChi); fr.SetValue("DienThoai", hoso.SoDienThoai); fr.SetValue("SoGiayTiepNhan", Utility.GetCodeRandom()); if (input.ListTaiLieuDaNhan.Count > 0) { fr.AddTable("ListTaiLieuDaNhan", input.ListTaiLieuDaNhan); } fr.SetValue("NgayHen", input.NgayHenCap.Value.ToString("dd/MM/yyyy")); var listHoSoXyLyBoSung = _hoSoXuLyRepos.GetAll().Where(x => x.HoSoId == hoso.Id && x.IsHoSoBS == true).ToList(); List <TiepNhanBoSungReport37Dto> ListTiepNhanBoSung = new List <TiepNhanBoSungReport37Dto>(); if (listHoSoXyLyBoSung.Count > 0) { if (listHoSoXyLyBoSung.Count == 1) // lần đầu nộp bổ xung { ListTiepNhanBoSung.Add(new TiepNhanBoSungReport37Dto() { SoLanBoSung = listHoSoXyLyBoSung.Count, NgayTraGiayTiepNhanStr = "ngày " + DateTime.Now.Day + " tháng " + DateTime.Now.Month + " năm " + DateTime.Now.Year }); } else { for (int i = 0; i < listHoSoXyLyBoSung.Count; i++) { var NguoiNhan = _userRepos.Get(listHoSoXyLyBoSung[i].VanThuId.Value); var tiepNhanBoSungReport37Dto = new TiepNhanBoSungReport37Dto() { SoLanBoSung = i + 1, NgayTraGiayTiepNhanStr = listHoSoXyLyBoSung[i].NgayTraGiayTiepNhan.Value.ToShortDateString() }; ListTiepNhanBoSung.Add(tiepNhanBoSungReport37Dto); } ListTiepNhanBoSung.Add(new TiepNhanBoSungReport37Dto() { SoLanBoSung = listHoSoXyLyBoSung.Count + 1, NgayTraGiayTiepNhanStr = DateTime.Now.ToShortDateString() }); } } fr.AddTable("ListTiepNhanBoSung", ListTiepNhanBoSung); var currentUser = _userRepos.Get(_session.UserId.Value); fr.SetValue("NguoiKy", currentUser.Surname + " " + currentUser.Name); var day = String.Empty; var month = String.Empty; if (DateTime.Today.Day <= 9) { day = string.Format("0{0}", DateTime.Today.Day); } else { day = DateTime.Today.Day.ToString(); } if (DateTime.Today.Month <= 9) { month = string.Format("0{0}", DateTime.Today.Month); } else { month = DateTime.Today.Month.ToString(); } string NgayKy = "Hà nội, ngày " + day + " tháng " + month + " năm " + DateTime.Today.Year; if (currentUser.TinhId.HasValue) { var tinh = _tinhRepos.Get(currentUser.TinhId.Value); NgayKy = tinh.Ten + ", ngày " + DateTime.Today.Day + " tháng " + DateTime.Today.Month + " năm " + DateTime.Today.Year; } fr.SetValue("NgayKy", NgayKy); Result.Open(path); fr.Run(Result); fr.Dispose(); xls = Result; var outS = new System.IO.MemoryStream(); using (FlexCel.Render.FlexCelPdfExport pdf = new FlexCel.Render.FlexCelPdfExport(xls, true)) { pdf.Export(outS); } fileTemplate = outS.ToArray(); return(fileTemplate); } } catch (Exception ex) { Logger.Fatal(ex.Message); return(null); } }