public void UpdateTerm(UpdateTermInputDto input) { Logger.Info("UpdateTerm() - Started."); Logger.DebugFormat("UpdateTerm() - Start checking before update Term in TR Booking Header. Parameters sent:{0}" + "unitID = {1}{0}" , Environment.NewLine, input.unitID); var check = (from bh in _trBookingHeaderRepo.GetAll() where bh.unitID == input.unitID && bh.cancelDate == null select bh).FirstOrDefault(); Logger.DebugFormat("UpdateTerm() - Ended checking before update Term in TR Booking Header."); if (check != null) { //history var checkHistory = (from A in _trBookingHeaderHistory.GetAll() orderby A.Id descending where A.bookCode == check.bookCode select A).FirstOrDefault(); var dataToInsertHistory = new TR_BookingHeaderHistory { bankName = check.bankName, bankNo = check.bankNo, bankRekeningPemilik = check.bankRekeningPemilik, BFPayTypeCode = check.BFPayTypeCode, bookCode = check.bookCode, bookDate = check.bookDate, discBFCalcType = check.discBFCalcType, cancelDate = check.cancelDate, DPCalcType = check.DPCalcType, entityID = check.entityID, eventID = check.eventID, facadeID = check.facadeID, SADStatusID = check.SADStatusID, scmCode = check.scmCode, shopBusinessID = check.shopBusinessID, isPenaltyStop = check.isPenaltyStop, promotionID = check.promotionID, isSK = check.isSK, isSMS = check.isSMS, KPRBankCode = check.KPRBankCode, memberCode = check.memberCode, sumberDanaID = check.sumberDanaID, memberName = check.memberName, nomorRekeningPemilik = check.nomorRekeningPemilik, PPJBDue = check.PPJBDue, psCode = check.psCode, netPriceComm = check.netPriceComm, NUP = check.NUP, remarks = check.remarks, termID = check.termID, transID = check.transID, termRemarks = check.termRemarks, tujuanTransaksiID = check.tujuanTransaksiID, unitID = check.unitID, historyNo = checkHistory == null?Convert.ToByte(0) : Convert.ToByte(checkHistory.historyNo + 1) }; var update = check.MapTo <TR_BookingHeader>(); update.termID = input.termID; try { _trBookingHeaderHistory.Insert(dataToInsertHistory); CurrentUnitOfWork.SaveChanges(); Logger.DebugFormat("UpdateTerm() - Start update Term in TR Booking Header. Parameters sent:{0}" + "termID = {1}{0}" , Environment.NewLine, input.termID); _trBookingHeaderRepo.Update(update); CurrentUnitOfWork.SaveChanges(); Logger.DebugFormat("UpdateTerm() - Ended update Term in TR Booking Header"); _iPriceAppService.GeneratePrice(input); } catch (DataException ex) { Logger.ErrorFormat("UpdateTerm() - ERROR DataException. Result = {0}", ex.Message); throw new UserFriendlyException("Db Error: " + ex.Message); } catch (Exception ex) { Logger.ErrorFormat("UpdateTerm() - ERROR Exception. Result = {0}", ex.Message); throw new UserFriendlyException("Error: " + ex.Message); } } else { throw new UserFriendlyException("Booking Cancelled!"); } Logger.Info("UpdateTerm() - Finished."); }
public void CreateMsFinType(CreateMsFinTypeInputDto input) { Logger.Info("CreateMsFinType() - Started."); Logger.DebugFormat("CreateMsFinType() - Start checking before insert Fin Type. Parameters sent:{0}" + "finTypeCode = {1}{0}" , Environment.NewLine, input.finTypeCode); bool checkFinType = (from A in _msFinTypeRepo.GetAll() where A.finTypeCode == input.finTypeCode select A).Any(); Logger.DebugFormat("CreateMsFinType() - Ended checking before insert Fin Type. Result = {0}", checkFinType); if (!checkFinType) { var createMsFinType = new LK_FinType { finTypeCode = input.finTypeCode, finTypeDesc = input.finTypeDesc, finTimes = input.finTimes, pctComm = input.pctComm, isCommStd = true, isCashStd = true, oldFinTypeCode = "-", pctCommLC = 10, pctCommTB = 10 }; try { Logger.DebugFormat("CreateMsFinType() - Start insert Fin Type. Parameters sent:{0}" + "finTypeCode = {1}{0}" + "finTypeDesc = {2}{0}" + "finTimes = {3}{0}" + "pctComm = {4}{0}" + "isCommStd = {5}{0}" + "isCashStd = {6}{0}" + "oldFinTypeCode = {7}{0}" + "pctCommLC = {8}{0}" + "pctCommTB = {9}{0}" , Environment.NewLine, input.finTypeCode, input.finTypeDesc, input.finTimes, input.pctComm, true, true , "-", 10, 10); _msFinTypeRepo.Insert(createMsFinType); CurrentUnitOfWork.SaveChanges(); //execution saved inside try Logger.DebugFormat("CreateMsFinType() - Ended insert Fin Type."); } catch (DataException ex) { Logger.ErrorFormat("CreateMsFinType() - ERROR DataException. Result = {0}", ex.Message); throw new UserFriendlyException("Db Error: " + ex.Message); } catch (Exception ex) { Logger.ErrorFormat("CreateMsFinType() - ERROR Exception. Result = {0}", ex.Message); throw new UserFriendlyException("Error: " + ex.Message); } } else { throw new UserFriendlyException("Data already exist"); } }
public virtual void Publish( string notificationName, NotificationData data = null, EntityIdentifier entityIdentifier = null, NotificationSeverity severity = NotificationSeverity.Info, UserIdentifier[] userIds = null, UserIdentifier[] excludedUserIds = null, int?[] tenantIds = null) { if (notificationName.IsNullOrEmpty()) { throw new ArgumentException("NotificationName can not be null or whitespace!", nameof(notificationName)); } if (!tenantIds.IsNullOrEmpty() && !userIds.IsNullOrEmpty()) { throw new ArgumentException("tenantIds can be set only if userIds is not set!", nameof(tenantIds)); } if (tenantIds.IsNullOrEmpty() && userIds.IsNullOrEmpty()) { tenantIds = new[] { AbpSession.TenantId }; } var notificationInfo = new NotificationInfo(_guidGenerator.Create()) { NotificationName = notificationName, EntityTypeName = entityIdentifier?.Type.FullName, EntityTypeAssemblyQualifiedName = entityIdentifier?.Type.AssemblyQualifiedName, EntityId = entityIdentifier?.Id.ToJsonString(), Severity = severity, UserIds = userIds.IsNullOrEmpty() ? null : userIds.Select(uid => uid.ToUserIdentifierString()).JoinAsString(","), ExcludedUserIds = excludedUserIds.IsNullOrEmpty() ? null : excludedUserIds.Select(uid => uid.ToUserIdentifierString()).JoinAsString(","), TenantIds = tenantIds.IsNullOrEmpty() ? null : tenantIds.JoinAsString(","), Data = data?.ToJsonString(), DataTypeName = data?.GetType().AssemblyQualifiedName }; _store.InsertNotification(notificationInfo); CurrentUnitOfWork.SaveChanges(); //To get Id of the notification if (userIds != null && userIds.Length <= MaxUserCountToDirectlyDistributeANotification) { //We can directly distribute the notification since there are not much receivers foreach (var notificationDistributorType in _notificationConfiguration.Distributers) { using (var notificationDistributer = _iocResolver.ResolveAsDisposable <INotificationDistributer>(notificationDistributorType)) { notificationDistributer.Object.Distribute(notificationInfo.Id); } } } else { //We enqueue a background job since distributing may get a long time _backgroundJobManager.Enqueue <NotificationDistributionJob, NotificationDistributionJobArgs>( new NotificationDistributionJobArgs( notificationInfo.Id ) ); } }
public void UpdateMsFinType(UpdateMsFinTypeInputDto input) { Logger.Info("UpdateMsFinType() - Started."); Logger.DebugFormat("UpdateMsFinType() - Start checking before update Fin Type. Parameters sent:{0}" + "finTypeCode = {1}{0}" , Environment.NewLine, input.finTypeCode); bool checkCode = (from A in _msFinTypeRepo.GetAll() where A.Id != input.fintypeID && A.finTypeCode == input.finTypeCode select A).Any(); Logger.DebugFormat("UpdateMsFinType() - Ended checking before update Fin Type. Result = {0}", checkCode); if (!checkCode) { Logger.DebugFormat("UpdateMsFinType() - Start get data before update Fin Type. Parameters sent:{0}" + "finTypeCode = {1}{0}" , Environment.NewLine, input.finTypeCode); var getMsFinType = (from A in _msFinTypeRepo.GetAll() where A.Id == input.fintypeID select A).FirstOrDefault(); Logger.DebugFormat("UpdateMsFinType() - Ended get data before update Fin Type."); var update = getMsFinType.MapTo <LK_FinType>(); update.finTypeDesc = input.finTypeDesc; update.finTimes = input.finTimes; update.pctComm = input.pctComm; try { Logger.DebugFormat("UpdateMsFinType() - Start update Fin Type. Parameters sent:{0}" + "finTypeDesc = {1}{0}" + "finTimes = {2}{0}" + "pctComm = {3}{0}" , Environment.NewLine, input.finTypeDesc, input.finTimes, input.pctComm); _msFinTypeRepo.Update(update); CurrentUnitOfWork.SaveChanges(); //execution saved inside try Logger.DebugFormat("UpdateMsFinType() - Ended update Fin Type."); } catch (DataException ex) { Logger.ErrorFormat("UpdateMsFinType() - ERROR DataException. Result = {0}", ex.Message); throw new UserFriendlyException("Db Error: " + ex.Message); } catch (Exception ex) { Logger.ErrorFormat("UpdateMsFinType() - ERROR Exception. Result = {0}", ex.Message); throw new UserFriendlyException("Error: " + ex.Message); } } else { Logger.ErrorFormat("UpdateMsFinType() - ERROR Result = {0}.", "The FinType Already Exist!"); throw new UserFriendlyException("The FinType Already Exist!"); } Logger.Info("UpdateMsFinType() - Finished."); }
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 <DangKyCongBoRequest>(); 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 DangKyCongBoRequest(); #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 DangKyCongBo _request.DangKyCongBo = item.MapTo <DangKyCongBoModel>(); _request.DangKyCongBo.GiayXacNhanToBase64String = FileToBase64String(item.GiayTiepNhan); _request.DangKyCongBo.NgayCapChungNhan = item.NgayTraKetQua.Value.ToString("yyyy-MM-dd HH:mm:ss"); _request.DangKyCongBo.TenVaDiaChiCoSoSanXuat = item.TenCoSoSanXuat + " " + item.DiaChiCoSoSanXuat; _request.DangKyCongBo.ChatLieuBaoBiVaQuyCachDongGoi = item.ChatLieuBaoBi + " " + item.QuyCachDongGoi; //Loại hồ sơ NiisId var loaiHoSo = await _loaiHoSoRepos.FirstOrDefaultAsync(item.LoaiHoSoId.Value); if (loaiHoSo != null) { _request.DangKyCongBo.NhomSanPhamDKCBId = loaiHoSo.NiisId; } //QuocGia nhap khau if (item.QuocGiaNhapKhauId != null) { var quocGia = await _quocGiaRepos.FirstOrDefaultAsync(item.QuocGiaNhapKhauId.Value); if (quocGia != null) { _request.DangKyCongBo.QuocGiaNhapKhauId = quocGia.NiisId; } } //Chi tieu chat luong chu yeu if (!string.IsNullOrEmpty(item.ChiTieuChatLuongChuYeuJson)) { } #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.DangKyCongBo.Guid = guid; _vfaHoSo.Guid = guid; } else { _request.DangKyCongBo.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/dangKyCongBoApi/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); } }