private void AddScanRecordAndUpdateUserKycStatus(ArcScanRecord record, UserArc userArc, RemitRecord remitRecord) { using var transaction = dbContext.Database.BeginTransaction(); try { // for demo if (configuration["IsDemo"] != null && bool.Parse(configuration["IsDemo"]) == true) { var demoArcArray = configuration.GetSection("DemoArc").Get <string[]>(); if (Array.IndexOf(demoArcArray, userArc.ArcNo) > -1) { remitRecord.TransactionStatus = (short)RemitTransactionStatusEnum.SuccessfulAmlVerification; userArc.KycStatus = (short)KycStatusEnum.PASSED_KYC_FORMAL_MEMBER; } } // arcScanRecordService.AddScanRecord(record); userArc.LastArcScanRecordId = record.Id; userArc.UpdateTime = DateTime.UtcNow; dbContext.UserArc.Update(userArc); dbContext.SaveChanges(); remitRecord.ArcScanRecordId = record.Id; dbContext.RemitRecord.Update(remitRecord); dbContext.SaveChanges(); transaction.Commit(); return; } catch (Exception ex) { logger.LogError(ex, null); transaction.Rollback(); } }
public async Task SystemVerifyArcForRegisterProcess(long userId) { UserArc userArc = GetUserArcById(userId); if (userArc.ArcIssueDate == null || userArc.ArcExpireDate == null) { logger.LogError("ARC data error"); throw new Exception("ARC Data not sufficient"); } ArcValidationResult arcValidationResult = arcValidationTask.Validate(workingRootPath, userArc.ArcNo, ((DateTime)userArc.ArcIssueDate).ToString("yyyyMMdd"), ((DateTime)userArc.ArcExpireDate).ToString("yyyyMMdd"), userArc.BackSequence).Result; logger.LogInformation("IsSuccessful:{1}", arcValidationResult.IsSuccessful); logger.LogInformation("result:{1}", arcValidationResult.Result); if (arcValidationResult.IsSuccessful) { ArcScanRecord record = new ArcScanRecord() { ArcStatus = (short)SystemArcVerifyStatusEnum.PASS, ScanTime = DateTime.UtcNow, Description = arcValidationResult.Result, Event = (byte)ArcScanEvent.Register }; userArc.KycStatus = (short)KycStatusEnum.ARC_PASS_VERIFY; // for demo if (configuration["IsDemo"] != null && bool.Parse(configuration["IsDemo"]) == true) { userArc.KycStatus = (short)KycStatusEnum.AML_PASS_VERIFY; } // userArc.KycStatusUpdateTime = DateTime.UtcNow; AddScanRecordAndUpdateUserKycStatus(record, userArc); // send mail await SendMailForRegisterArc(true, receivers, userId); } else { ArcScanRecord record = new ArcScanRecord() { ArcStatus = (short)SystemArcVerifyStatusEnum.FAIL, ScanTime = DateTime.UtcNow, Description = arcValidationResult.Result, Event = (byte)ArcScanEvent.Register }; userArc.KycStatus = (short)KycStatusEnum.FAILED_KYC; userArc.KycStatusUpdateTime = DateTime.UtcNow; AddScanRecordAndUpdateUserKycStatus(record, userArc); // send mail await SendMailForRegisterArc(false, receivers, userId); } }
public async Task SystemVerifyArcForRemitProcess(RemitRecord remitRecord, long userId) { UserArc userArc = userService.GetUserArcById(userId); if (userArc.ArcIssueDate == null || userArc.ArcExpireDate == null) { throw new Exception("ARC Data not sufficient"); } ArcValidationResult arcValidationResult = arcValidationTask.Validate(workingRootPath, userArc.ArcNo, ((DateTime)userArc.ArcIssueDate).ToString("yyyyMMdd"), ((DateTime)userArc.ArcExpireDate).ToString("yyyyMMdd"), userArc.BackSequence).Result; if (arcValidationResult.IsSuccessful) { ArcScanRecord record = new ArcScanRecord() { ArcStatus = (short)SystemArcVerifyStatusEnum.PASS, ScanTime = DateTime.UtcNow, Description = arcValidationResult.Result, Event = (byte)ArcScanEvent.Remit }; remitRecord.TransactionStatus = (short)RemitTransactionStatusEnum.SuccessfulArcVerification; // for demo if (configuration["IsDemo"] != null && bool.Parse(configuration["IsDemo"]) == true) { remitRecord.TransactionStatus = (short)RemitTransactionStatusEnum.SuccessfulAmlVerification; } // AddScanRecordAndUpdateUserKycStatus(record, userArc, remitRecord); // send mail await SendMailForRemitArc(true, receivers, userId); } else { ArcScanRecord record = new ArcScanRecord() { ArcStatus = (short)SystemArcVerifyStatusEnum.FAIL, ScanTime = DateTime.UtcNow, Description = arcValidationResult.Result, Event = (byte)ArcScanEvent.Remit }; remitRecord.TransactionStatus = (short)RemitTransactionStatusEnum.FailedVerified; userArc.KycStatus = (short)KycStatusEnum.FAILED_KYC; userArc.KycStatusUpdateTime = DateTime.UtcNow; AddScanRecordAndUpdateUserKycStatus(record, userArc, remitRecord); // send mail await SendMailForRemitArc(false, receivers, userId); // push notification await notificationService.SaveAndSendNotification((int)userId, "Unsuccessful Remit", "You do not pass The KYC procedure", "en-US"); } }
public void AddScanRecord(ArcScanRecord record) { dbContext.ArcScanRecord.Add(record); dbContext.SaveChanges(); }