Beispiel #1
0
        public async Task <KetQuaLienThong> LienThongNhieuHoSo()
        {
            try
            {
                KetQuaLienThong KetQua = new KetQuaLienThong();
                KetQua = await _dangKyQuangCaoLTDomainService.AotuLienThongHoSo(_session.TenantId);

                return(KetQua);
            }
            catch (Exception ex)
            {
                _logger.Fatal(ex.Message);
                return(null);
            }
        }
Beispiel #2
0
        public async Task <KetQuaLienThong> LienThongHoSo(List <XCallApiInput> input)
        {
            try
            {
                KetQuaLienThong KetQua = new KetQuaLienThong();
                KetQua = await _dangKyQuangCaoLTDomainService.LienThongHoSo(input, _session.TenantId.Value);

                return(KetQua);
            }
            catch (Exception ex)
            {
                _logger.Fatal(ex.Message);
                return(null);
            }
        }
Beispiel #3
0
        public async Task <KetQuaLienThong> AotuLienThongHoSo(int?chiCucId)
        {
            try
            {
                var KetQua = new KetQuaLienThong();
                if (_callApiAppService.IsAccountLienThong(chiCucId.Value))
                {
                    var input = new XPagingInput();

                    string strTinh = RemoveUnicodeTinh(chiCucId.Value);

                    int _chiCucId = chiCucId == null ? 0 : chiCucId.Value;
                    var query     = QueryAll(input, _chiCucId);
                    var list      = await query.Where(p => p.TrangThaiLienThong != (int)CommonENum.TRANG_THAI_LIEN_THONG.DA_LIEN_THONG_THANH_CONG)
                                    .OrderBy(p => p.HoSoId)
                                    .ToListAsync();

                    if (list.Count > 0)
                    {
                        List <XCallApiInput> inputCallApi = list.MapTo <List <XCallApiInput> >();

                        KetQua = await LienThongHoSo(inputCallApi, _chiCucId, strTinh);
                    }
                    else
                    {
                        KetQua.TrangThaiLienThongRequest = (int)CommonENum.TRANG_THAI_LIEN_THONG_REQUEST.KHONG_CO_HO_SO_HOAC_DA_LIEN_THONG;
                    }
                }
                else
                {
                    KetQua.TrangThaiLienThongRequest = (int)CommonENum.TRANG_THAI_LIEN_THONG_REQUEST.CHUA_CO_TAI_KHOAN;
                }

                return(KetQua);
            }
            catch (Exception ex)
            {
                _logger.Fatal(ex.Message);
                return(null);
            }
        }
        public async Task <KetQuaLienThong> LienThongHoSo(List <XCallApiInput> input, int chiCucId, string strTinh = "")
        {
            KetQuaLienThong KetQua = new KetQuaLienThong();

            try
            {
                var objToken = await _callApiAppService.AutoGetToKen(chiCucId);

                if (objToken == null)
                {
                    KetQua.TrangThaiLienThongRequest = (int)CommonENum.TRANG_THAI_LIEN_THONG_REQUEST.CHUA_CO_TAI_KHOAN;
                    return(KetQua);
                }
                if (input != null && input.Count > 0)
                {
                    var _list         = new List <CoSoDuDieuKienRequest>();
                    int countTongHoSo = 0;
                    foreach (var item in input)
                    {
                        var _vfaHoSo = await _vfaHoSoRepos.GetAsync(item.Id);

                        if (_vfaHoSo.TrangThaiLienThong == (int)CommonENum.TRANG_THAI_LIEN_THONG.DA_LIEN_THONG_THANH_CONG)
                        {
                            KetQua.TrangThaiLienThongRequest = (int)CommonENum.TRANG_THAI_LIEN_THONG_REQUEST.KHONG_CO_HO_SO_HOAC_DA_LIEN_THONG;
                            continue;
                        }

                        var _request = new CoSoDuDieuKienRequest();

                        #region DoanhNgiep
                        _request.DoanhNghiep = item.MapTo <DoanhNghiepModel>();
                        var tinh = await _tinhRepos.FirstOrDefaultAsync(item.TinhId.Value);

                        if (tinh != null)
                        {
                            _request.DoanhNghiep.TinhId = tinh.NiisId;
                        }
                        var huyen = await _huyenRepos.FirstOrDefaultAsync(item.HuyenId.Value);

                        if (huyen != null)
                        {
                            _request.DoanhNghiep.HuyenId = (int)huyen.NiisId;
                        }
                        var xa = await _xaRepos.FirstOrDefaultAsync(item.XaId.Value);

                        if (xa != null)
                        {
                            _request.DoanhNghiep.XaId = (int)xa.NiisId;
                        }
                        #endregion

                        #region CoSoDuDieuKien
                        _request.CoSoDuDieuKien = item.MapTo <CoSoDuDieuKienModel>();
                        _request.CoSoDuDieuKien.GiayXacNhanToBase64String = FileToBase64String(item.GiayTiepNhan);
                        _request.CoSoDuDieuKien.NgayCapChungNhan          = item.NgayTraKetQua.Value.ToString("yyyy-MM-dd HH:mm:ss");
                        //Tinh, Huyen, Xa
                        var tinhHoSo = await _tinhRepos.FirstOrDefaultAsync(item.HoSoTinhId.Value);

                        if (tinhHoSo != null)
                        {
                            _request.CoSoDuDieuKien.TinhId = tinhHoSo.NiisId;
                        }
                        var huyenHoSo = await _huyenRepos.FirstOrDefaultAsync(item.HoSoHuyenId.Value);

                        if (huyenHoSo != null)
                        {
                            _request.CoSoDuDieuKien.HuyenId = (int)huyenHoSo.NiisId;
                        }
                        var xaHoSo = await _xaRepos.FirstOrDefaultAsync(item.HoSoXaId.Value);

                        if (xaHoSo != null)
                        {
                            _request.CoSoDuDieuKien.XaId = (int)xaHoSo.NiisId;
                        }
                        #endregion

                        #region Update TrangThaiLienThong
                        _vfaHoSo.TrangThaiLienThong = (int)CommonENum.TRANG_THAI_LIEN_THONG.DA_LIEN_THONG_KHONG_THANH_CONG;
                        _vfaHoSo.NgayLienThong      = DateTime.Now;

                        //Guid
                        if (string.IsNullOrEmpty(_vfaHoSo.Guid))
                        {
                            string guid = "";
                            if (string.IsNullOrEmpty(strTinh))
                            {
                                guid = CreateGuid(_vfaHoSo.Id, RemoveUnicodeTinh(chiCucId));
                            }
                            else
                            {
                                guid = CreateGuid(_vfaHoSo.Id, strTinh);
                            }
                            _request.CoSoDuDieuKien.Guid = guid;
                            _vfaHoSo.Guid = guid;
                        }
                        else
                        {
                            _request.CoSoDuDieuKien.Guid = _vfaHoSo.Guid;
                        }

                        await _vfaHoSoRepos.UpdateAsync(_vfaHoSo);

                        CurrentUnitOfWork.SaveChanges();
                        #endregion

                        _list.Add(_request);
                        countTongHoSo++;
                    }
                    KetQua.TongSoHoSo = countTongHoSo;

                    string dataJson  = JsonConvert.SerializeObject(_list);
                    string api       = "api/services/app/coSoDuDieuKienApi/Insert";
                    var    objResult = await _callApiAppService.CallApi(chiCucId, dataJson, api, objToken.Result.ToString());

                    if (objResult.Result != null && objResult.Result.ListResult.Count > 0 && objResult.Success == true)
                    {
                        int countHoSoThatBai   = 0;
                        int countHoSoThanhCong = 0;
                        foreach (var result in objResult.Result.ListResult)
                        {
                            var _vfaHoSoUpdate = await _vfaHoSoRepos.FirstOrDefaultAsync(p => p.Guid == result.Guid);

                            if (_vfaHoSoUpdate != null && (result.Code == MessageErorr.Er100.Code || result.Code == MessageErorr.Er03.Code))
                            {
                                _vfaHoSoUpdate.TrangThaiLienThong     = (int)CommonENum.TRANG_THAI_LIEN_THONG.DA_LIEN_THONG_THANH_CONG;
                                _vfaHoSoUpdate.NgayLienThongThanhCong = DateTime.Now;
                                _vfaHoSoUpdate.LienThongId            = result.LienThongId;
                                await _vfaHoSoRepos.UpdateAsync(_vfaHoSoUpdate);

                                countHoSoThanhCong++;
                            }
                            else
                            {
                                countHoSoThatBai++;
                            }
                        }
                        KetQua.HoSoThanhCong             = countHoSoThanhCong;
                        KetQua.HoSoThatBai               = countHoSoThatBai;
                        KetQua.ListResult                = objResult.Result.ListResult;
                        KetQua.TrangThaiLienThongRequest = KetQua.HoSoThanhCong == 0 ? KetQua.TrangThaiLienThongRequest = (int)CommonENum.TRANG_THAI_LIEN_THONG_REQUEST.KHONG_THANH_CONG : (int)CommonENum.TRANG_THAI_LIEN_THONG_REQUEST.THANH_CONG;
                    }
                    else
                    {
                        KetQua.TrangThaiLienThongRequest = (int)CommonENum.TRANG_THAI_LIEN_THONG_REQUEST.CHUA_CO_TAI_KHOAN;
                    }
                }
                return(KetQua);
            }
            catch (Exception ex)
            {
                _logger.Fatal(ex.Message);
                KetQua.TrangThaiLienThongRequest = (int)CommonENum.TRANG_THAI_LIEN_THONG_REQUEST.KHONG_THANH_CONG;
                return(KetQua);
            }
        }
Beispiel #5
0
        public async Task <KetQuaLienThong> LienThongHoSo(List <XCallApiInput> input, int chiCucId, string strTinh = "")
        {
            KetQuaLienThong KetQua = new KetQuaLienThong();

            try
            {
                var objToken = await _callApiAppService.AutoGetToKen(chiCucId);

                if (objToken == null)
                {
                    KetQua.TrangThaiLienThongRequest = (int)CommonENum.TRANG_THAI_LIEN_THONG_REQUEST.CHUA_CO_TAI_KHOAN;
                    return(KetQua);
                }
                if (input != null && input.Count > 0)
                {
                    var _list         = new List <DangKyQuangCaoRequest>();
                    int countTongHoSo = 0;
                    foreach (var item in input)
                    {
                        var _vfaHoSo = await _vfaHoSoRepos.GetAsync(item.Id);

                        if (_vfaHoSo.TrangThaiLienThong == (int)CommonENum.TRANG_THAI_LIEN_THONG.DA_LIEN_THONG_THANH_CONG)
                        {
                            KetQua.TrangThaiLienThongRequest = (int)CommonENum.TRANG_THAI_LIEN_THONG_REQUEST.KHONG_CO_HO_SO_HOAC_DA_LIEN_THONG;
                            continue;
                        }

                        var _request = new DangKyQuangCaoRequest();

                        #region DoanhNgiep
                        _request.DoanhNghiep = item.MapTo <DoanhNghiepModel>();
                        var tinh = await _tinhRepos.FirstOrDefaultAsync(item.TinhId.Value);

                        if (tinh != null)
                        {
                            _request.DoanhNghiep.TinhId = tinh.NiisId;
                        }
                        var huyen = await _huyenRepos.FirstOrDefaultAsync(item.HuyenId.Value);

                        if (huyen != null)
                        {
                            _request.DoanhNghiep.HuyenId = (int)huyen.NiisId;
                        }
                        var xa = await _xaRepos.FirstOrDefaultAsync(item.XaId.Value);

                        if (xa != null)
                        {
                            _request.DoanhNghiep.XaId = (int)xa.NiisId;
                        }
                        #endregion

                        #region DangKyQuangCao
                        _request.DangKyQuangCao.GiayXacNhanToBase64String = FileToBase64String(item.GiayTiepNhan);
                        _request.DangKyQuangCao.NgayCapChungNhan          = item.NgayTraKetQua.Value.ToString("yyyy-MM-dd HH:mm:ss");

                        //Hình thức quảng cáo
                        if (!string.IsNullOrEmpty(item.LoaiQuangCaoJson))
                        {
                            //var quangCaos = JsonConvert.DeserializeObject<List<JsonHinhThucQuangCao03Dto>>(item.LoaiQuangCaoJson);
                            //foreach (var quangCao in quangCaos)
                            //{
                            //    var loaiQuangCao = await _loaiQuangCaoRepos.FirstOrDefaultAsync(quangCao.Id);
                            //    if (loaiQuangCao != null)
                            //    {
                            //        _request.DangKyQuangCao.LoaiHinhQuangCaos.Add(loaiQuangCao.NiisId.Value);
                            //    }
                            //}
                        }
                        if (!string.IsNullOrEmpty(item.LoaiQuangCaoKhacJson))
                        {
                            _request.DangKyQuangCao.LoaiHinhQuangCaoKhacs = item.LoaiQuangCaoKhacJson;
                        }

                        //Sản phẩm
                        if (!string.IsNullOrEmpty(item.JsonSanPham))
                        {
                            //var sanPhams = JsonConvert.DeserializeObject<List<HoSoSanPhamChiTiet03Dto>>(item.JsonSanPham);
                            //foreach (var sanPham in sanPhams)
                            //{
                            //    var sanPhamRequest = new SanPhamQuangCao()
                            //    {
                            //        STT = sanPham.Stt.ToString(),
                            //        TenThucPham = sanPham.TenThucPham,
                            //        SoGiayCongBo = sanPham.SoGiayCongBo
                            //    };
                            //    _request.DangKyQuangCao.SanPhams.Add(sanPhamRequest);
                            //}
                        }
                        #endregion

                        #region Update TrangThaiLienThong
                        _vfaHoSo.TrangThaiLienThong = (int)CommonENum.TRANG_THAI_LIEN_THONG.DA_LIEN_THONG_KHONG_THANH_CONG;
                        _vfaHoSo.NgayLienThong      = DateTime.Now;

                        //Guid
                        if (string.IsNullOrEmpty(_vfaHoSo.Guid))
                        {
                            string guid = "";
                            if (string.IsNullOrEmpty(strTinh))
                            {
                                guid = CreateGuid(_vfaHoSo.Id, RemoveUnicodeTinh(chiCucId));
                            }
                            else
                            {
                                guid = CreateGuid(_vfaHoSo.Id, strTinh);
                            }
                            _request.DangKyQuangCao.Guid = guid;
                            _vfaHoSo.Guid = guid;
                        }
                        else
                        {
                            _request.DangKyQuangCao.Guid = _vfaHoSo.Guid;
                        }

                        await _vfaHoSoRepos.UpdateAsync(_vfaHoSo);

                        CurrentUnitOfWork.SaveChanges();
                        #endregion

                        _list.Add(_request);
                        countTongHoSo++;
                    }
                    KetQua.TongSoHoSo = countTongHoSo;

                    string dataJson  = JsonConvert.SerializeObject(_list);
                    string api       = "api/services/app/dangKyQuangCaoApi/Insert";
                    var    objResult = await _callApiAppService.CallApi(chiCucId, dataJson, api, objToken.Result.ToString());

                    if (objResult.Result != null && objResult.Result.ListResult.Count > 0 && objResult.Success == true)
                    {
                        int countHoSoThatBai   = 0;
                        int countHoSoThanhCong = 0;
                        foreach (var result in objResult.Result.ListResult)
                        {
                            var _vfaHoSoUpdate = await _vfaHoSoRepos.FirstOrDefaultAsync(p => p.Guid == result.Guid);

                            if (_vfaHoSoUpdate != null && (result.Code == MessageErorr.Er100.Code || result.Code == MessageErorr.Er03.Code))
                            {
                                _vfaHoSoUpdate.TrangThaiLienThong     = (int)CommonENum.TRANG_THAI_LIEN_THONG.DA_LIEN_THONG_THANH_CONG;
                                _vfaHoSoUpdate.NgayLienThongThanhCong = DateTime.Now;
                                _vfaHoSoUpdate.LienThongId            = result.LienThongId;
                                await _vfaHoSoRepos.UpdateAsync(_vfaHoSoUpdate);

                                countHoSoThanhCong++;
                            }
                            else
                            {
                                countHoSoThatBai++;
                            }
                        }
                        KetQua.HoSoThanhCong             = countHoSoThanhCong;
                        KetQua.HoSoThatBai               = countHoSoThatBai;
                        KetQua.ListResult                = objResult.Result.ListResult;
                        KetQua.TrangThaiLienThongRequest = KetQua.HoSoThanhCong == 0 ? KetQua.TrangThaiLienThongRequest = (int)CommonENum.TRANG_THAI_LIEN_THONG_REQUEST.KHONG_THANH_CONG : (int)CommonENum.TRANG_THAI_LIEN_THONG_REQUEST.THANH_CONG;
                    }
                    else
                    {
                        KetQua.TrangThaiLienThongRequest = (int)CommonENum.TRANG_THAI_LIEN_THONG_REQUEST.CHUA_CO_TAI_KHOAN;
                    }
                }
                return(KetQua);
            }
            catch (Exception ex)
            {
                _logger.Fatal(ex.Message);
                KetQua.TrangThaiLienThongRequest = (int)CommonENum.TRANG_THAI_LIEN_THONG_REQUEST.KHONG_THANH_CONG;
                return(KetQua);
            }
        }