public async Task DongDau(VanThuXuLy37InputDto input)
        {
            var vanThuId = _session.UserId;

            try
            {
                var hoSo = await _hoSoRepos.FirstOrDefaultAsync(x => x.Id == input.HoSoId);

                var hosoxl = await _hoSoXuLyRepos.FirstOrDefaultAsync(input.HoSoXuLyId);

                if (hosoxl != null && hoSo != null && hosoxl.Id > 0)
                {
                    //hoSo.TrangThaiHoSo = (int)CommonENum.TRANG_THAI_HO_SO.SUA_DOI_BO_SUNG;

                    hosoxl.DonViXuLy     = (int)CommonENum.DON_VI_XU_LY.DOANH_NGHIEP;
                    hosoxl.DonViGui      = (int)CommonENum.DON_VI_XU_LY.VAN_THU;
                    hosoxl.NguoiGuiId    = _session.UserId;
                    hosoxl.NguoiXuLyId   = hoSo.CreatorUserId;
                    hosoxl.NgayGui       = DateTime.Now;
                    hosoxl.VanThuDaDuyet = true;

                    hosoxl.VanThuId          = vanThuId;
                    hosoxl.VanThuIsCA        = true;
                    hosoxl.VanThuNgayDongDau = DateTime.Now;
                    hosoxl.DuongDanTepCA     = input.DuongDanTepCA;
                    hosoxl.YKienGui          = null;

                    await _hoSoRepos.UpdateAsync(hoSo);

                    await _hoSoXuLyRepos.UpdateAsync(hosoxl);

                    if (hosoxl.HoSoIsDat != true)
                    {
                        #region HoSo_Clone

                        var hoSoClone = new XHoSoDto();
                        hoSo.MapTo(hoSoClone);
                        hoSoClone.PId = hoSo.PId != null ? hoSo.PId : hoSo.Id;
                        var  insertInput = hoSoClone.MapTo <XHoSo>();
                        long idClone     = await _hoSoRepos.InsertAndGetIdAsync(insertInput);

                        CurrentUnitOfWork.SaveChanges();
                        var teps = _hoSoTepDinhKemRepos.GetAll()
                                   .Where(x => x.HoSoId == input.HoSoId);

                        foreach (var tep in teps)
                        {
                            var tepNew = new XHoSoTepDinhKem
                            {
                                HoSoId         = insertInput.Id,
                                IsActive       = tep.IsActive,
                                DuongDanTep    = tep.DuongDanTep,
                                IsCA           = tep.IsCA,
                                DaTaiLen       = tep.DaTaiLen,
                                LoaiTepDinhKem = tep.LoaiTepDinhKem,
                                MoTaTep        = tep.MoTaTep,
                                TenTep         = tep.TenTep
                            };
                            await _hoSoTepDinhKemRepos.InsertAsync(tepNew);
                        }
                        #endregion
                    }

                    #region Lưu lịch sử
                    var _history = new XHoSoXuLyHistory();
                    _history.ThuTucId     = hosoxl.ThuTucId;
                    _history.HoSoXuLyId   = hosoxl.Id;
                    _history.HoSoId       = hosoxl.HoSoId;
                    _history.IsHoSoBS     = hosoxl.IsHoSoBS;
                    _history.NguoiXuLyId  = _session.UserId;
                    _history.NoiDungYKien = null;
                    _history.TrangThaiCV  = hosoxl.TrangThaiCV;
                    _history.DonViXuLy    = (int)CommonENum.DON_VI_XU_LY.VAN_THU;
                    _history.ActionEnum   = (int)CommonENum.FORM_FUNCTION.VAN_THU_DONG_DAU;

                    _history.HoSoIsDat     = hosoxl.HoSoIsDat;
                    _history.HoSoIsDat_Pre = hosoxl.HoSoIsDat;

                    await _hoSoXuLyHistoryRepos.InsertAndGetIdAsync(_history);

                    #endregion
                }
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex.Message);
            }
        }
        public async Task TaoBanSaoHoSo(long hoSoId)
        {
            var hoSo = await _hoSoRepos.GetAsync(hoSoId);

            if (hoSo != null)
            {
                var hoSoClone = new XHoSoDto();
                hoSoClone                   = hoSo.MapTo <XHoSoDto>();
                hoSoClone.Id                = 0;
                hoSoClone.IsCA              = false;
                hoSoClone.PId               = null;
                hoSoClone.CreationTime      = DateTime.Now;
                hoSoClone.TrangThaiHoSo     = null;
                hoSoClone.HoSoXuLyId_Active = null;
                hoSoClone.MotCuaChuyenId    = null;
                hoSoClone.PhongBanId        = null;
                hoSoClone.IsHoSoBS          = null;
                hoSoClone.GiayTiepNhan      = null;
                hoSoClone.GiayTiepNhanFull  = null;
                hoSoClone.MaHoSo            = null;
                hoSoClone.SoDangKy          = null;
                hoSoClone.StrThuMucHoSo     = "HOSO_" + DateTime.Now.ToString("yyyyMMdd_HHmmss");

                //SttHoso
                hoSoClone.NamHoSo = DateTime.Now.Year;
                int?sttHoSoMax = _hoSoRepos.GetAll().Where(x => x.DoanhNghiepId == hoSoClone.DoanhNghiepId && x.NamHoSo == hoSoClone.NamHoSo).Max(x => x.SttHoSo);

                if (sttHoSoMax != null)
                {
                    hoSoClone.SttHoSo = 1;
                }
                else
                {
                    hoSoClone.SttHoSo = sttHoSoMax + 1;
                }

                var _hsClone = hoSoClone.MapTo <XHoSo>();
                _hsClone.Id = await _hoSoRepos.InsertAndGetIdAsync(_hsClone);

                #region Copy tệp đính kèm

                var tepdk = _hoSoTepDinhKemRepos.GetAll().Where(x => x.HoSoId == hoSo.Id);
                foreach (var item in tepdk)
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(item.DuongDanTep))
                        {
                            var fileName  = item.DuongDanTep.Split('\\').LastOrDefault();
                            var name      = fileName.Split('.').FirstOrDefault();
                            var extention = fileName.Split('.').LastOrDefault();
                            var urlPath   = item.DuongDanTep.Replace(name, name + "_" + _hsClone.Id);
                            var tep       = new XHoSoTepDinhKem()
                            {
                                CreationTime   = DateTime.Now,
                                HoSoId         = _hsClone.Id,
                                DuongDanTep    = urlPath,
                                TenTep         = urlPath,
                                IsCA           = item.IsCA,
                                MoTaTep        = item.MoTaTep,
                                LoaiTepDinhKem = item.LoaiTepDinhKem,
                                ThuTucId       = item.ThuTucId,
                                DaTaiLen       = item.DaTaiLen,
                                IsActive       = item.IsActive
                            };
                            var dkClone = tep.MapTo <XHoSoTepDinhKem>();
                            await _hoSoTepDinhKemRepos.InsertAsync(dkClone);

                            #region Tạo bản sao tệp đính kèm

                            var    pathName     = item.DuongDanTep.Replace(fileName, string.Empty);
                            string HCC_FILE_PDF = GetUrlFileDefaut();
                            var    folderPath   = Path.Combine(HCC_FILE_PDF, pathName);
                            if (!Directory.Exists(folderPath))
                            {
                                Directory.CreateDirectory(folderPath);
                            }
                            var    sourceFile = System.IO.Path.Combine(folderPath, fileName);
                            string destFile   = System.IO.Path.Combine(folderPath, name + "_" + _hsClone.Id + "." + extention);
                            if (File.Exists(sourceFile))
                            {
                                System.IO.File.Copy(sourceFile, destFile, true);
                            }

                            #endregion Tạo bản sao tệp đính kèm
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Fatal(ex.Message);
                    }
                }

                #endregion Copy tệp đính kèm
            }
        }