|
|
using Business.TPApi; using Repository.TrustDoc; using Business.TrustDoc; using Common; using Common.Model; using Common.Helper; using Common.Model.TPSendMoney; using log4net; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; using System.Runtime.Remoting.Messaging; using System.Text; using System.Net.Http; using Repository.KFTCRepository; using System.Net;
namespace Business.TrustDoc { public class TrustDocBusiness : ITrustDocBusiness { private readonly ITrustDocRepository _trustrepo; private readonly ThirdPartyAPI _tpApi = new ThirdPartyAPI(); private static readonly ILog Log = LogManager.GetLogger(typeof(TrustDocBusiness)); private readonly IKftcProcessRepository _repo;
public string Token { get; set; } public string TrustDocURL { get; set; }
public TrustDocBusiness(ITrustDocRepository trustrepo, KftcProcessRepository repo) { _trustrepo = trustrepo; _repo = repo; TrustDocURL = ApplicationConfig.ReadWebConfig("TrustDocURL", ""); Token = ApplicationConfig.ReadWebConfig("TrustToken", ""); }
public JsonRxResponse Webhook(TrustDocModel doc) { JsonRxResponse jsonRx = new JsonRxResponse(); try { jsonRx = _trustrepo.Webhook(doc); Log.Debug("Webhook | DB RESPONSE : " + JsonConvert.SerializeObject(jsonRx));
if (!jsonRx.ErrorCode.Equals("0")) { Log.Debug("Webhook | Error occurred while calling CustomerKYC..."); return jsonRx; } return jsonRx; } catch (Exception ex) { Log.Error("Something Went Wrong, Please Try Again!!", ex); jsonRx.SetResponse("1", "Error occurred while fetching data."); return jsonRx; } }
public JsonRxResponse CompareData(TrustDocRequest request, string id, string user, string customerId) { DbResult _dbResult = new DbResult();
JsonRxResponse jsonResponse = new JsonRxResponse();
try { HttpClient client = new HttpClient(); var bodyData = JsonConvert.SerializeObject(request);
//LogicalThreadContext.Properties[LoggerProperty.METHODNAME] = "CompareData";
LogicalThreadContext.Properties[LoggerProperty.CREATEDBY] = user; Log.Debug("CompareData | REQUEST : " + bodyData);
_dbResult= _repo.LogRequest(user, "TrustDoc", "comparing_data", customerId, bodyData, id);
client.DefaultRequestHeaders.Add("Authorization", $"Bearer {Token}");
var jbdContent = new StringContent(bodyData, Encoding.UTF8, "application/json");
var URL = TrustDocURL + "verifications/" + id + "/comparing_data";
System.Net.ServicePointManager.SecurityProtocol = (SecurityProtocolType)(0xc0 | 0x300 | 0xc00); System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
var resp = client.PutAsync(URL, jbdContent).Result;
string resultData = resp.Content.ReadAsStringAsync().Result;
Log.Debug("CompareData | RESPONSE : " + resultData);
_repo.LogResponse(_dbResult.Id, resultData, ((int)resp.StatusCode).ToString(), _dbResult.Extra2);
if (resp.IsSuccessStatusCode) { jsonResponse.ErrorCode = "0"; jsonResponse.Msg = "Success"; jsonResponse.Data = resp; } else { ErrorJosn errorJson = JsonConvert.DeserializeObject<ErrorJosn>(resultData); //JsonResponse jsonResponseData = JsonConvert.DeserializeObject<JsonResponse>(errorJson.Message);
jsonResponse.ErrorCode = "1"; jsonResponse.Msg = errorJson.Message; jsonResponse.Data = errorJson; } return jsonResponse; }
catch (Exception ex) { var e = new JsonRxResponse() { ErrorCode = "1", Msg = (ex.InnerException == null ? ex.Message : ex.InnerException.Message) };
_repo.LogResponse(_dbResult.Id, _dbResult.Extra2, "999", JsonConvert.SerializeObject(e));
return e;
} } } }
|