diff --git a/Source/DealerSelection.Api.Models/LsqData.cs b/Source/DealerSelection.Api.Models/LsqData.cs new file mode 100644 index 0000000..6e3c960 --- /dev/null +++ b/Source/DealerSelection.Api.Models/LsqData.cs @@ -0,0 +1,149 @@ +using Newtonsoft.Json; + +namespace DealerSelection.Api.Models; + +public class LsqData +{ + public LsqData(string bu, string model_Code, string color, string customer_Name, + string location_of_the_customer + , string dealer_Code, string mobile, string otp_verified, string pincode + , string enquiry_mode, string source, string sub_source, string referral_URL + , string composite_Key, string enquiry_Classification + , string auto_model, string bu_Sub_type, string sitcore_Booking_ID + , string booking_Status, string cc_Avenue_Transaction_ID, string booking_receipt_Number + , string booking_amount_TRM, string test_ride_date, string test_ride_slot + , string test_ride_location, string utmSource, string utmMedium, string sourceCampaign + , string utmContent, string consentToWhatsapp, string leadPlatform) + { + BU = bu; + ModelCode = model_Code; + Color = color; + CustomerName = customer_Name; + Locationofthecustomer = location_of_the_customer; + DealerCode = dealer_Code; + MobileNumber = mobile; + OtpVerified = otp_verified; + PinCode = pincode; + EnquiryMode = enquiry_mode; + Source = source; + SubSource = sub_source; + ReferralURL = referral_URL; + CompositeKey = composite_Key; + EnquiryClassification = enquiry_Classification; + AutoModel = auto_model; + BuSubtype = bu_Sub_type; + SitecoreBookingID = sitcore_Booking_ID; + BookingStatus = booking_Status; + CCAvenueTransactionID = cc_Avenue_Transaction_ID; + BookingReceiptNumber = booking_receipt_Number; + BookingAmountTRM = booking_amount_TRM; + TestRideDate = test_ride_date; + TestRideSlot = test_ride_slot; + TestRideLocation = test_ride_location; + UtmSource = utmSource; + UtmMedium = utmMedium; + SourceCampaign = sourceCampaign; + UtmContent = utmContent; + ConsentToWhatsapp = consentToWhatsapp; + LeadPlatform = leadPlatform; + + } + + + + [JsonProperty("bu")] + public string BU { get; } + + [JsonProperty("model_Code")] + public string ModelCode { get; } + + [JsonProperty("color")] + public string Color { get; } + + [JsonProperty("customer_Name")] + public string CustomerName { get; } + + [JsonProperty("location_of_the_customer")] + public string Locationofthecustomer { get; } + + [JsonProperty("dealer_Code")] + public string DealerCode { get; } + + [JsonProperty("mobile")] + public string MobileNumber { get; } + + [JsonProperty("otp_verified")] + public string OtpVerified { get; } + + [JsonProperty("pincode")] + public string PinCode { get; } + + [JsonProperty("enquiry_mode")] + public string EnquiryMode { get; } + + [JsonProperty("source")] + public string Source { get; } + + [JsonProperty("sub_source")] + public string SubSource { get; } + + [JsonProperty("referral_URL")] + public string ReferralURL { get; } + + [JsonProperty("composite_Key")] + public string CompositeKey { get; } + + [JsonProperty("enquiry_Classification")] + public string EnquiryClassification { get; } + + [JsonProperty("auto_model")] + public string AutoModel { get; } + + [JsonProperty("bu_Sub_type")] + public string BuSubtype { get; } + + [JsonProperty("sitcore_Booking_ID")] + public string SitecoreBookingID { get; } + + [JsonProperty("booking_Status")] + public string BookingStatus { get; } + + [JsonProperty("cc_Avenue_Transaction_ID")] + public string CCAvenueTransactionID { get; } + + [JsonProperty("booking_receipt_Number")] + public string BookingReceiptNumber { get; } + + [JsonProperty("booking_amount_TRM")] + public string BookingAmountTRM { get; } + + [JsonProperty("test_ride_date")] + public string TestRideDate { get; } + + [JsonProperty("test_ride_slot")] + public string TestRideSlot{ get; } + + [JsonProperty("test_ride_location")] + public string TestRideLocation { get; } + + [JsonProperty("utmSource")] + public string UtmSource { get; } + + [JsonProperty("utmMedium")] + public string UtmMedium { get; } + + [JsonProperty("sourceCampaign")] + public string SourceCampaign { get; } + + [JsonProperty("utmContent")] + public string UtmContent { get; } + + [JsonProperty("consentToWhatsapp")] + public string ConsentToWhatsapp { get; } + + [JsonProperty("leadPlatform")] + public string LeadPlatform { get; } + + + +} diff --git a/Source/DealerSelection.Api.Models/LsqSuccessData.cs b/Source/DealerSelection.Api.Models/LsqSuccessData.cs new file mode 100644 index 0000000..13e2ccc --- /dev/null +++ b/Source/DealerSelection.Api.Models/LsqSuccessData.cs @@ -0,0 +1,149 @@ +using Newtonsoft.Json; + +namespace DealerSelection.Api.Models; + +public class LsqSuccessData +{ + public LsqSuccessData(string bu, string model_Code, string color, string customer_Name, + string location_of_the_customer + , string dealer_Code, string mobile, string otp_verified, string pincode + , string enquiry_mode, string source, string sub_source, string referral_URL + , string composite_Key, string enquiry_Classification + , string auto_model, string bu_Sub_type, string sitcore_Booking_ID + , string booking_Status, string cc_Avenue_Transaction_ID, string booking_receipt_Number + , string booking_amount_TRM, string test_ride_date, string test_ride_slot + , string test_ride_location, string utmSource, string utmMedium, string sourceCampaign + , string utmContent, string consentToWhatsapp, string leadPlatform, string isDefaultDealer) + { + BU= bu; + ModelCode= model_Code; + Color= color; + CustomerName= customer_Name; + Locationofthecustomer= location_of_the_customer; + DealerCode= dealer_Code; + MobileNumber= mobile; + OtpVerified= otp_verified; + PinCode= pincode; + EnquiryMode= enquiry_mode; + Source= source; + SubSource= sub_source; + ReferralURL= referral_URL; + CompositeKey= composite_Key; + EnquiryClassification = enquiry_Classification; + AutoModel= auto_model; + BuSubtype = bu_Sub_type; + SitecoreBookingID = sitcore_Booking_ID; + BookingStatus = booking_Status; + CCAvenueTransactionID = cc_Avenue_Transaction_ID; + BookingReceiptNumber = booking_receipt_Number; + BookingAmountTRM= booking_amount_TRM; + TestRideDate= test_ride_date; + TestRideSlot = test_ride_slot; + TestRideLocation= test_ride_location; + UtmSource = utmSource; + UtmMedium= utmMedium; + SourceCampaign= sourceCampaign; + UtmContent = utmContent; + ConsentToWhatsapp= consentToWhatsapp; + LeadPlatform= leadPlatform; + IsDefaultDealer= isDefaultDealer; + + } + [JsonProperty("bu")] + public string BU { get; } + + [JsonProperty("model_Code")] + public string ModelCode { get; } + + [JsonProperty("color")] + public string Color { get; } + + [JsonProperty("customer_Name")] + public string CustomerName { get; } + + [JsonProperty("location_of_the_customer")] + public string Locationofthecustomer { get; } + + [JsonProperty("dealer_Code")] + public string DealerCode { get; } + + [JsonProperty("mobile")] + public string MobileNumber { get; } + + [JsonProperty("otp_verified")] + public string OtpVerified { get; } + + [JsonProperty("pincode")] + public string PinCode { get; } + + [JsonProperty("enquiry_mode")] + public string EnquiryMode { get; } + + [JsonProperty("source")] + public string Source { get; } + + [JsonProperty("sub_source")] + public string SubSource { get; } + + [JsonProperty("referral_URL")] + public string ReferralURL { get; } + + [JsonProperty("composite_Key")] + public string CompositeKey { get; } + + [JsonProperty("enquiry_Classification")] + public string EnquiryClassification { get; } + + [JsonProperty("auto_model")] + public string AutoModel { get; } + + [JsonProperty("bu_Sub_type")] + public string BuSubtype { get; } + + [JsonProperty("sitcore_Booking_ID")] + public string SitecoreBookingID { get; } + + [JsonProperty("booking_Status")] + public string BookingStatus { get; } + + [JsonProperty("cc_Avenue_Transaction_ID")] + public string CCAvenueTransactionID { get; } + + [JsonProperty("booking_receipt_Number")] + public string BookingReceiptNumber { get; } + + [JsonProperty("booking_amount_TRM")] + public string BookingAmountTRM { get; } + + [JsonProperty("test_ride_date")] + public string TestRideDate { get; } + + [JsonProperty("test_ride_slot")] + public string TestRideSlot{ get; } + + [JsonProperty("test_ride_location")] + public string TestRideLocation { get; } + + [JsonProperty("utmSource")] + public string UtmSource { get; } + + [JsonProperty("utmMedium")] + public string UtmMedium { get; } + + [JsonProperty("sourceCampaign")] + public string SourceCampaign { get; } + + [JsonProperty("utmContent")] + public string UtmContent { get; } + + [JsonProperty("consentToWhatsapp")] + public string ConsentToWhatsapp { get; } + + [JsonProperty("leadPlatform")] + public string LeadPlatform { get; } + + [JsonProperty("isDefaultDealer")] + public string IsDefaultDealer { get; } + + +} diff --git a/Source/DealerSelection.Api.Models/WebEngageEvent.cs b/Source/DealerSelection.Api.Models/WebEngageEvent.cs index 6f3a281..e86bd6d 100644 --- a/Source/DealerSelection.Api.Models/WebEngageEvent.cs +++ b/Source/DealerSelection.Api.Models/WebEngageEvent.cs @@ -6,7 +6,7 @@ public class WebEngageEventData { public WebEngageEventData(string bookingID, string bookingStatus, string bookingAmount, string bookingReceiptLink,string dealerFlag, string fullName, string phoneNumber, string motorcycleName, string motorcycleCode, string location, string dealerName, - string dealerPhoneNumber) + string dealerPhoneNumber,string bookingCompletionDate) { BookingID = bookingID; BookingStatus = bookingStatus; @@ -19,7 +19,8 @@ public class WebEngageEventData MotorcycleCode = motorcycleCode; Location = location; DealerName = dealerName; - DealerPhoneNumber = dealerPhoneNumber; + DealerPhoneNumber = dealerPhoneNumber; + BookingCompletionDate= bookingCompletionDate; } @@ -61,6 +62,9 @@ public class WebEngageEventData [JsonProperty("Dealer Phone Number")] public string DealerPhoneNumber { get; } + [JsonProperty("BookingCompletionDate")] + public string BookingCompletionDate { get; } + } public class WebEngageEvent { diff --git a/Source/DealerSelection.Api/AssignDealerApi.cs b/Source/DealerSelection.Api/AssignDealerApi.cs index d973481..c75f17c 100644 --- a/Source/DealerSelection.Api/AssignDealerApi.cs +++ b/Source/DealerSelection.Api/AssignDealerApi.cs @@ -129,7 +129,7 @@ public class AssignDealerApi : IAssignDealerApi // Send Message to Webengage to Initiate BOT WebEngageEventData eventData = new WebEngageEventData(customerInfo.BookingId, "SUCCESS", customerInfo.AmountPaid, "", "N", - customerInfo.CustomerName, customerInfo.MobileNumber, customerInfo.ModelName, customerInfo.ModelCode, customerInfo.CustomerLat, "", ""); + customerInfo.CustomerName, customerInfo.MobileNumber, customerInfo.ModelName, customerInfo.ModelCode, customerInfo.CustomerLat, "", "",customerInfo.CompletionDate.ToString()); WebEngageEvent events = new WebEngageEvent(customerInfo.MobileNumber, cfg.WebengageEventName, eventData); await WebEngageEventsAPICall(events, cfg, customerInfo.RecordId); } diff --git a/Source/DealerSelection.Api/BatchJobApi.cs b/Source/DealerSelection.Api/BatchJobApi.cs index 0dc6edc..6856c69 100644 --- a/Source/DealerSelection.Api/BatchJobApi.cs +++ b/Source/DealerSelection.Api/BatchJobApi.cs @@ -5,6 +5,7 @@ using DealerSelection.Api.Interface; using DealerSelection.Api.Models.Enum; using Microsoft.Extensions.Logging; using System.Collections.Generic; +using static iTextSharp.text.pdf.AcroFields; public class BatchJobApi : IBatchJobApi { @@ -38,5 +39,24 @@ public class BatchJobApi : IBatchJobApi } } + public async Task LeadCreateApiCall(int buId) + { + try + { + List lsqCustomerDataList = + await Repository.GetDataForLsqPush(buId); + + foreach (var lsqCustomerData in lsqCustomerDataList) + { + await MulesoftApi.InsertLSQData(lsqCustomerData); + // await MulesoftApi.CallBookingApi(buId, lsqCustomerData); + } + } + catch (Exception ex) + { + _logger.LogError("PendingStatusUpdateApi LeadCreateApiCall " + ex.Message.ToString()); + } + } + } \ No newline at end of file diff --git a/Source/DealerSelection.Api/CCAvenueApi.cs b/Source/DealerSelection.Api/CCAvenueApi.cs index 5865621..73cb5e9 100644 --- a/Source/DealerSelection.Api/CCAvenueApi.cs +++ b/Source/DealerSelection.Api/CCAvenueApi.cs @@ -109,7 +109,14 @@ public class CCAvenueApi : ICCAvenueApi catch (Exception ex) { _logger.LogError($"DS Api:-BU:- {customerInfo.BuId} + RefundOrder Error for bookingId:- {bookingId} - {ex.StackTrace}"); - throw ex; + RefundStatusResponse _refundStatusResponse = new(); + { + _refundStatusResponse.refund_status = 1; + _refundStatusResponse.reason = ex.Message; + }; + response = new RefundApiResponse("1", _refundStatusResponse); + response.Status = "1"; + //throw ex; } } else diff --git a/Source/DealerSelection.Api/CommonUtil/CustomConfig.cs b/Source/DealerSelection.Api/CommonUtil/CustomConfig.cs index 68acb89..4dd0ef6 100644 --- a/Source/DealerSelection.Api/CommonUtil/CustomConfig.cs +++ b/Source/DealerSelection.Api/CommonUtil/CustomConfig.cs @@ -34,6 +34,10 @@ namespace DealerSelection.Api.CommonUtil public static CustomCfg GetCustomCfg(int buId) { CustomCfg cfg = new CustomCfg(); + + cfg.WebEngageLicenseCode = ConfigurationHelper.GetSetting("WebEngageLicenseCode", true); + cfg.WebEngageAuthToken = ConfigurationHelper.GetSetting("WebEngageAuthToken", true); + cfg.WebengageApiHost = ConfigurationHelper.GetSetting("WebengageApiHost", true); switch (buId) { case 1: @@ -41,20 +45,41 @@ namespace DealerSelection.Api.CommonUtil cfg.CCAvenueAccessCode = ConfigurationHelper.GetSetting("KtmCfg:CCAvenueAccessCode", true); cfg.CCAvenueMerchantCode = ConfigurationHelper.GetSetting("KtmCfg:CCAvenueMerchantCode", true); cfg.CCAvenueWorkingKey = ConfigurationHelper.GetSetting("KtmCfg:CCAvenueWorkingKey", true); - cfg.WebengageEventName = ConfigurationHelper.GetSetting("KtmCfg:WebengageEventName", true); - cfg.WebEngageLicenseCode = ConfigurationHelper.GetSetting("KtmCfg:WebEngageLicenseCode", true); - cfg.WebEngageAuthToken = ConfigurationHelper.GetSetting("KtmCfg:WebEngageAuthToken", true); - cfg.WebengageApiHost = ConfigurationHelper.GetSetting("KtmCfg:WebengageApiHost", true); + cfg.WebengageEventName = ConfigurationHelper.GetSetting("KtmCfg:WebengageEventName", true); cfg.BuId = buId; cfg.DeafaultDealerCode = ConfigurationHelper.GetSetting("KtmCfg:DefaultDealerCode", true); - //cfg.ClientId = ConfigurationHelper.GetSetting("KtmCfg:ClientId", true); - //cfg.ClientSecret = ConfigurationHelper.GetSetting("KtmCfg:ClientSecret", true); - // cfg.Key = ConfigurationHelper.GetSetting("KtmCfg:Key", true); - // cfg.Audience = ConfigurationHelper.GetSetting("KtmCfg:Audience", true); - // cfg.Issuer = ConfigurationHelper.GetSetting("KtmCfg:Issuer", true); - // cfg.Role = ConfigurationHelper.GetSetting("KtmCfg:Role", true); - // cfg.ExpireMinutes = ConfigurationHelper.GetSetting("KtmCfg:ExpireMinutes", true); - break; + + break; + case 2: + cfg.BuCode = ConfigurationHelper.GetSetting("BajajCfg:BuCode", true); + cfg.CCAvenueAccessCode = ConfigurationHelper.GetSetting("BajajCfg:CCAvenueAccessCode", true); + cfg.CCAvenueMerchantCode = ConfigurationHelper.GetSetting("BajajCfg:CCAvenueMerchantCode", true); + cfg.CCAvenueWorkingKey = ConfigurationHelper.GetSetting("BajajCfg:CCAvenueWorkingKey", true); + cfg.WebengageEventName = ConfigurationHelper.GetSetting("BajajCfg:WebengageEventName", true); + cfg.BuId = buId; + cfg.DeafaultDealerCode = ConfigurationHelper.GetSetting("BajajCfg:DefaultDealerCode", true); + + break; + case 3: + cfg.BuCode = ConfigurationHelper.GetSetting("TriumphCfg:BuCode", true); + cfg.CCAvenueAccessCode = ConfigurationHelper.GetSetting("TriumphCfg:CCAvenueAccessCode", true); + cfg.CCAvenueMerchantCode = ConfigurationHelper.GetSetting("TriumphCfg:CCAvenueMerchantCode", true); + cfg.CCAvenueWorkingKey = ConfigurationHelper.GetSetting("TriumphCfg:CCAvenueWorkingKey", true); + cfg.WebengageEventName = ConfigurationHelper.GetSetting("TriumphCfg:WebengageEventName", true); + cfg.BuId = buId; + cfg.DeafaultDealerCode = ConfigurationHelper.GetSetting("TriumphCfg:DefaultDealerCode", true); + + break; + case 4: + cfg.BuCode = ConfigurationHelper.GetSetting("HusqvarnaCfg:BuCode", true); + cfg.CCAvenueAccessCode = ConfigurationHelper.GetSetting("HusqvarnaCfg:CCAvenueAccessCode", true); + cfg.CCAvenueMerchantCode = ConfigurationHelper.GetSetting("HusqvarnaCfg:CCAvenueMerchantCode", true); + cfg.CCAvenueWorkingKey = ConfigurationHelper.GetSetting("HusqvarnaCfg:CCAvenueWorkingKey", true); + cfg.WebengageEventName = ConfigurationHelper.GetSetting("HusqvarnaCfg:WebengageEventName", true); + cfg.BuId = buId; + cfg.DeafaultDealerCode = ConfigurationHelper.GetSetting("HusqvarnaCfg:DefaultDealerCode", true); + + break; default: cfg.BuId = buId; break; diff --git a/Source/DealerSelection.Api/MulesoftApi.cs b/Source/DealerSelection.Api/MulesoftApi.cs index 1219d6c..f1faa1a 100644 --- a/Source/DealerSelection.Api/MulesoftApi.cs +++ b/Source/DealerSelection.Api/MulesoftApi.cs @@ -162,7 +162,11 @@ public class MulesoftApi : IMulesoftApi { try { - await UpdateDetails(customerInfo, DealerSelectionJobStatus.Complete); + if (customerInfo.Status == "Successful") + { + await UpdateDetails(customerInfo, DealerSelectionJobStatus.Complete); + } + var responseApi = await CallLSQBookingApi(customerInfo); } @@ -192,7 +196,7 @@ public class MulesoftApi : IMulesoftApi string mx_Composite_Key = string.Empty, enquiryClassification = string.Empty, autoModel = string.Empty, dealerCode = string.Empty, status = string.Empty, bookingId = string.Empty, cCTransactionId = string.Empty, receiptId = string.Empty, - amountPaid = string.Empty, leadPlatform = "Website", isSuccessBooking = "True", isDefaultDealer="No"; + amountPaid = string.Empty, leadPlatform = "Website", isSuccessBooking = "True", isDefaultDealer = "No"; string utmSource = GetUTMDetails(customerInfo.ReferralUrl, "utm_source"); @@ -223,57 +227,51 @@ public class MulesoftApi : IMulesoftApi receiptId = customerInfo.ReceiptId; amountPaid = customerInfo.AmountPaid; - if (customerInfo.IsRegisterInterestRequest || string.IsNullOrWhiteSpace(customerInfo.DealerCode) || string.IsNullOrWhiteSpace(customerInfo.ModelCode)) + if (customerInfo.DealerCode == cfg.DeafaultDealerCode) { - enquiryClassification = "Cold"; - autoModel = "No"; - dealerCode = string.Empty; + isDefaultDealer = "Yes"; } - else + string pincode = customerInfo.PinCode; + //default pincode value, incase pincode column is empty for the record + if (string.IsNullOrEmpty(pincode)) + pincode = "400070"; + + dynamic message = null; + if (customerInfo.Status == "Successful" && !string.IsNullOrWhiteSpace(customerInfo.DealerCode) + && !string.IsNullOrWhiteSpace(customerInfo.ModelCode)) { enquiryClassification = "Hot"; autoModel = "Yes"; + + LsqSuccessData lsqData = new LsqSuccessData(cfg.BuCode, customerInfo.ModelCode, customerInfo.ColorCode, customerInfo.CustomerName + , "", dealerCode, customerInfo.MobileNumber, "true", pincode, "Digital" + , mx_Source_Of_Enquiry, mx_Enquiry_Sub_source, "", mx_Composite_Key, enquiryClassification + , autoModel, "", bookingId, status, cCTransactionId, receiptId, amountPaid + , "", "", "", utmSource, utmMedium, sourceCampaign, utmContent, customerInfo.IsWhatsappOptIn.ToString() + , leadPlatform, isDefaultDealer); + + message = JsonConvert.SerializeObject(lsqData); } - if (customerInfo.Status != "Successful") + else { + enquiryClassification = "Cold"; + autoModel = "No"; status = string.Empty; bookingId = string.Empty; cCTransactionId = string.Empty; receiptId = string.Empty; amountPaid = string.Empty; isSuccessBooking = "False"; - isDefaultDealer = ""; - } - if(customerInfo.DealerCode==cfg.DeafaultDealerCode) - { - isDefaultDealer = "Yes"; - } - string pincode = customerInfo.PinCode; - //default pincode value, incase pincode column is empty for the record - if (string.IsNullOrEmpty(pincode)) - pincode = "400070"; - string message = "{\"bu\": \"" + cfg.BuCode + "\", \"model_Code\": \"" + customerInfo.ModelCode + "\"," + - "\"color\": \"" + customerInfo.ColorCode + "\"," + - "\"customer_Name\": \"" + customerInfo.CustomerName + "\"" + - ", \"location_of_the_customer\": \"\", \"dealer_Code\": \"" + dealerCode + "\", " + - "\"mobile\": \"" + customerInfo.MobileNumber + "\"" + - ", \"otp_verified\": \"true\", \"pincode\": \"" + pincode + "\"," + - " \"enquiry_mode\": \"Digital\"" + - ", \"source\": \"" + mx_Source_Of_Enquiry + "\", \"sub_source\": \"" + mx_Enquiry_Sub_source + "\"," + - " \"referral_URL\": \"\"" + - ", \"composite_Key\": \"" + mx_Composite_Key + "\", \"enquiry_Classification\": \"" + enquiryClassification + "\"," + - " \"auto_model\": \"" + autoModel + "\"" + - ", \"bu_Sub_type\": \"\", \"sitcore_Booking_ID\": \"" + bookingId + "\", " + - "\"booking_Status\": \"" + status + "\"" + - ", \"cc_Avenue_Transaction_ID\": \"" + cCTransactionId + "\"," + - " \"booking_receipt_Number\": \"" + receiptId + "\"," + - " \"booking_amount_TRM\": \"" + amountPaid + "\"," + - " \"test_ride_date\": \"\", \"test_ride_slot\": \"\"" + - ", \"test_ride_location\": \"\"," + - "\"utmSource\": \"" + utmSource + "\", \"utmMedium\":\"" + utmMedium + "\"," + - " \"sourceCampaign\": \"" + sourceCampaign + "\", \"utmContent\":\"" + utmContent + "\"," + - " \"consentToWhatsapp\": \"" + customerInfo.IsWhatsappOptIn + "\",\"leadPlatform\": \"" + leadPlatform + "\" ,\"isDefaultDealer\": \"" + isDefaultDealer + "\"}"; + LsqData lsqData = new LsqData(cfg.BuCode, customerInfo.ModelCode, customerInfo.ColorCode, customerInfo.CustomerName + , "", "", customerInfo.MobileNumber, "true", pincode, "Digital" + , mx_Source_Of_Enquiry, mx_Enquiry_Sub_source, "", mx_Composite_Key, enquiryClassification + , autoModel, "", bookingId, status, cCTransactionId, receiptId, amountPaid + , "", "", "", utmSource, utmMedium, sourceCampaign, utmContent, customerInfo.IsWhatsappOptIn.ToString() + , leadPlatform); + + message = JsonConvert.SerializeObject(lsqData); + } diff --git a/Source/DealerSelection.Api/YellowAIApi.cs b/Source/DealerSelection.Api/YellowAIApi.cs index d3bf388..610db55 100644 --- a/Source/DealerSelection.Api/YellowAIApi.cs +++ b/Source/DealerSelection.Api/YellowAIApi.cs @@ -3,6 +3,7 @@ using DealerSelection.Api.Interface; using DealerSelection.Api.Models; using DealerSelection.Api.Models.Enum; using DealerSelection.Common.Exceptions; +using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using System.Text.RegularExpressions; using CustomerDetailRepo = DealerSelection.Api.Infrastructure.CustomerDetail; @@ -46,6 +47,11 @@ public class YellowAIApi : IYellowAIApi customerDetailInfo.DealerSelectedMode = DealerSelectedMode.Bot.ToString(); await MulesoftApi.InsertLSQData(customerDetailInfo); } + else + { + _logger.LogWarning($"No Data found : {request.RequestDetail()}."); + throw new ValidationException("No Data Found"); + } } else { @@ -57,7 +63,7 @@ public class YellowAIApi : IYellowAIApi catch(Exception ex) { _logger.LogError($"Some error occured: {ex.StackTrace}."); - throw new ValidationException($"Some error occured: {ex.StackTrace}."); + throw new Exception($"Some error occured: {ex.Message}."); } _logger.LogInformation($"DS Api:-UpdateSelectedDealer End :- MobileNumber {request.MobileNumber} BuCode {request.BuCode} BuSubType {request.BuSubType}" + diff --git a/Source/DealerSelection.Infrastructure/BatchJob/IRepository.cs b/Source/DealerSelection.Infrastructure/BatchJob/IRepository.cs index 4c37b6a..cd67938 100644 --- a/Source/DealerSelection.Infrastructure/BatchJob/IRepository.cs +++ b/Source/DealerSelection.Infrastructure/BatchJob/IRepository.cs @@ -6,4 +6,6 @@ namespace DealerSelection.Api.Infrastructure.BatchJob; public interface IRepository { Task> Get24HrOldRecordsForJobProcessing(); + + Task> GetDataForLsqPush(int buId); } \ No newline at end of file diff --git a/Source/DealerSelection.Infrastructure/BatchJob/Repository.cs b/Source/DealerSelection.Infrastructure/BatchJob/Repository.cs index 822e044..2e72bfd 100644 --- a/Source/DealerSelection.Infrastructure/BatchJob/Repository.cs +++ b/Source/DealerSelection.Infrastructure/BatchJob/Repository.cs @@ -34,4 +34,27 @@ public class Repository : RepositoryBaseDapperAsync, IRepository } } + public async Task> GetDataForLsqPush(int buId) + { + try + { + using (SqlConnection cxn = await OpenCxnAsync()) + { + IEnumerable lsqDto = await cxn.QueryAsync(Procedure.GetDataForLsqPush, + new + { + buId + }, + commandType: CommandType.StoredProcedure); + return lsqDto.ToList(); + } + } + catch (Exception ex) + { + _logger.LogError("BU:- " + buId.ToString() + "Error at Repository:Mulesoft in GetDataForLsqPush " + ex.Message.ToString()); + throw new UnexpectedDataException($"Error at Repository:Mulesoft in GetDataForLsqPush for BuId: {buId}.", ex); + } + + } + } \ No newline at end of file diff --git a/Source/DealerSelection.Infrastructure/Mulesoft/IRepository.cs b/Source/DealerSelection.Infrastructure/Mulesoft/IRepository.cs index 3a33a17..37326e2 100644 --- a/Source/DealerSelection.Infrastructure/Mulesoft/IRepository.cs +++ b/Source/DealerSelection.Infrastructure/Mulesoft/IRepository.cs @@ -3,8 +3,8 @@ namespace DealerSelection.Api.Infrastructure.Mulesoft; public interface IRepository { - Task GetCustomerInfo(int buId, string bookingId); + //Task GetCustomerInfo(int buId, string bookingId); Task UpdateMulesoftResponse(int buId,int recordId,string bookingId,string message,string isSuccessBooking, LeadData leadData); Task InsertAndUpdateDealerRecord(DealerDetailDto dto); - Task> GetDataForLsqPush(int buId); +// Task> GetDataForLsqPush(int buId); } \ No newline at end of file diff --git a/Source/DealerSelection.Infrastructure/Mulesoft/MulesoftCustomerInfoDto.cs b/Source/DealerSelection.Infrastructure/Mulesoft/MulesoftCustomerInfoDto.cs index fc5c12d..991979e 100644 --- a/Source/DealerSelection.Infrastructure/Mulesoft/MulesoftCustomerInfoDto.cs +++ b/Source/DealerSelection.Infrastructure/Mulesoft/MulesoftCustomerInfoDto.cs @@ -29,6 +29,8 @@ public class MulesoftCustomerInfoDto public string CustomerLong { get; set; } public string DealerSelectedMode { get; set; } + public DateTime CompletionDate { get; set; } + } public class LeadData diff --git a/Source/DealerSelection.Infrastructure/Mulesoft/Repository.cs b/Source/DealerSelection.Infrastructure/Mulesoft/Repository.cs index 5e79b78..8b3b527 100644 --- a/Source/DealerSelection.Infrastructure/Mulesoft/Repository.cs +++ b/Source/DealerSelection.Infrastructure/Mulesoft/Repository.cs @@ -14,28 +14,28 @@ public class Repository : RepositoryBaseDapperAsync, IRepository _logger = logger; } - public async Task GetCustomerInfo(int buId, string bookingId) - { - try - { - using (SqlConnection cxn = await OpenCxnWithMappingAsync()) - { - IEnumerable cusotmerInfo = await cxn.QueryAsync(Procedure.GetCustomerInfoOnBookingId, - new - { - buId, - bookingId - }, - commandType: CommandType.StoredProcedure); - return cusotmerInfo.ToList().FirstOrDefault(); - } - } - catch (Exception ex) - { - _logger.LogError($"DS Repo:-BU:- " + buId.ToString() + " Error at Repository:Mulesoft in GetCustomerInfo." + ex.Message.ToString()); - throw new UnexpectedDataException($"Error at Repository:Mulesoft in GetCustomerInfo for BuId: {buId} and BookingId: {bookingId}.", ex); - } - } + //public async Task GetCustomerInfo(int buId, string bookingId) + //{ + // try + // { + // using (SqlConnection cxn = await OpenCxnWithMappingAsync()) + // { + // IEnumerable cusotmerInfo = await cxn.QueryAsync(Procedure.GetCustomerInfoOnBookingId, + // new + // { + // buId, + // bookingId + // }, + // commandType: CommandType.StoredProcedure); + // return cusotmerInfo.ToList().FirstOrDefault(); + // } + // } + // catch (Exception ex) + // { + // _logger.LogError($"DS Repo:-BU:- " + buId.ToString() + " Error at Repository:Mulesoft in GetCustomerInfo." + ex.Message.ToString()); + // throw new UnexpectedDataException($"Error at Repository:Mulesoft in GetCustomerInfo for BuId: {buId} and BookingId: {bookingId}.", ex); + // } + //} public async Task UpdateMulesoftResponse(int buId, int recordId, string bookingId, string message, string isSuccessBooking, LeadData leadData) { @@ -109,26 +109,26 @@ public class Repository : RepositoryBaseDapperAsync, IRepository } } - public async Task> GetDataForLsqPush(int buId) - { - try - { - using (SqlConnection cxn = await OpenCxnAsync()) - { - IEnumerable lsqDto = await cxn.QueryAsync(Procedure.GetDataForLsqPush, - new - { - buId - }, - commandType: CommandType.StoredProcedure); - return lsqDto.ToList(); - } - } - catch (Exception ex) - { - _logger.LogError($"DS Repo-BU:- " + buId.ToString() + "Error at Repository:Mulesoft in GetDataForLsqPush " + ex.Message.ToString()); - throw new UnexpectedDataException($"Error at Repository:Mulesoft in GetDataForLsqPush for BuId: {buId}.", ex); - } + //public async Task> GetDataForLsqPush(int buId) + //{ + // try + // { + // using (SqlConnection cxn = await OpenCxnAsync()) + // { + // IEnumerable lsqDto = await cxn.QueryAsync(Procedure.GetDataForLsqPush, + // new + // { + // buId + // }, + // commandType: CommandType.StoredProcedure); + // return lsqDto.ToList(); + // } + // } + // catch (Exception ex) + // { + // _logger.LogError($"DS Repo-BU:- " + buId.ToString() + "Error at Repository:Mulesoft in GetDataForLsqPush " + ex.Message.ToString()); + // throw new UnexpectedDataException($"Error at Repository:Mulesoft in GetDataForLsqPush for BuId: {buId}.", ex); + // } - } + //} } \ No newline at end of file diff --git a/Source/DealerSelection.Interface/IBatchJobApi.cs b/Source/DealerSelection.Interface/IBatchJobApi.cs index 7b73db8..9689d44 100644 --- a/Source/DealerSelection.Interface/IBatchJobApi.cs +++ b/Source/DealerSelection.Interface/IBatchJobApi.cs @@ -2,6 +2,8 @@ public interface IBatchJobApi { - Task Process24HrOldRecords(); - + Task Process24HrOldRecords(); + + Task LeadCreateApiCall(int buId); + } \ No newline at end of file diff --git a/Source/DealerSelection.WebApi/Controllers/BatchJobController.cs b/Source/DealerSelection.WebApi/Controllers/BatchJobController.cs index 01ad541..8c80a41 100644 --- a/Source/DealerSelection.WebApi/Controllers/BatchJobController.cs +++ b/Source/DealerSelection.WebApi/Controllers/BatchJobController.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Swashbuckle.AspNetCore.Annotations; +using System.ComponentModel.DataAnnotations; namespace DealerSelection.WebApi.Controllers; @@ -29,4 +30,19 @@ public class BatchJobController : ControllerBase { await Api.Process24HrOldRecords(); } + + /// + /// Update Booking Status + /// + /// + /// + [HttpGet] + [ProducesResponseType(StatusCodes.Status200OK)] + [SwaggerOperation(Tags = new[] { "BatchJob" })] + [Route("PartialFullLeadPush/{buId}")] + public async Task PartialFullLeadPush([Required] int buId) + { + + await Api.LeadCreateApiCall(buId); + } } \ No newline at end of file diff --git a/Source/DealerSelection.WebApi/appsettings.json b/Source/DealerSelection.WebApi/appsettings.json index 0779b91..e4b306b 100644 --- a/Source/DealerSelection.WebApi/appsettings.json +++ b/Source/DealerSelection.WebApi/appsettings.json @@ -34,6 +34,9 @@ "MuleSoftCacheGetActiveState": "30", "MuleSoftCacheGetActiveCity": "30", "MuleSoftCacheModelDetails": "30", + "WebEngageLicenseCode": "~71680635", + "WebEngageAuthToken": "3b5e4004-cef4-4bde-86c6-c8a9944cd846", + "WebengageApiHost": "https://api.webengage.com/v1/accounts/", "KtmCfg": { "Buid": 1, "BuCode": "PB", @@ -41,10 +44,7 @@ "CCAvenueAccessCode": "AVLM05KI16AB00MLBA", "CCAvenueMerchantCode": "350479", "CCAvenueWorkingKey": "F40694C5358CF9D2826C4545D6FAE337", - "WebengageEventName": "KTM Booking Dealer Status", - "WebEngageLicenseCode": "~71680635", - "WebEngageAuthToken": "3b5e4004-cef4-4bde-86c6-c8a9944cd846", - "WebengageApiHost": "https://api.webengage.com/v1/accounts/" + "WebengageEventName": "KTM Booking Dealer Status" }, "BajajCfg": { "Buid": 2, @@ -53,10 +53,25 @@ "CCAvenueAccessCode": "AVNL05KI17AO76LNOA", "CCAvenueMerchantCode": "350479", "CCAvenueWorkingKey": "6FD791AC3A7177E9139215B32278AFDB", - "WebengageEventName": "BA - Booking Status", - "WebEngageLicenseCode": "~71680635", - "WebEngageAuthToken": "3b5e4004-cef4-4bde-86c6-c8a9944cd846", - "WebengageApiHost": "https://api.webengage.com/v1/accounts/" + "WebengageEventName": "" + }, + "TriumphCfg": { + "Buid": 3, + "BuCode": "TRM", + "DefaultDealerCode": "Bajaj", + "CCAvenueAccessCode": "AVEB04KE93CJ71BEJC", + "CCAvenueMerchantCode": "284786", + "CCAvenueWorkingKey": "C3673417B0712B2A4FE9618F7723C850", + "WebengageEventName": "" + }, + "HusqvarnaCfg": { + "Buid": 4, + "BuCode": "PB", + "DefaultDealerCode": "Bajaj", + "CCAvenueAccessCode": "AVRE05KK36CL99ERLC", + "CCAvenueMerchantCode": "350479", + "CCAvenueWorkingKey": "BA1433F7A2D39F01CA9EE95ED5218A72", + "WebengageEventName": "" }, "Logging": { "LogLevel": { diff --git a/Source/WebJobService/Program.cs b/Source/WebJobService/Program.cs index 84a5ef7..6e9c9a5 100644 --- a/Source/WebJobService/Program.cs +++ b/Source/WebJobService/Program.cs @@ -27,12 +27,14 @@ public class Program : ServiceRegistry var config = builder.Build(); var aiUrl = config["AZURE_LOGGING"]; + Console.WriteLine("Logging AddApplicationInsights started"); registry.AddLogging(x => x.AddApplicationInsights( configureTelemetryConfiguration: (config) => config.ConnectionString = aiUrl, configureApplicationInsightsLoggerOptions: (options) => { } ).AddFilter("traces", LogLevel.Trace)); - + Console.WriteLine("Logging AddApplicationInsights Ended"); + registry.For() .Use() @@ -66,11 +68,12 @@ public class Program : ServiceRegistry var container = new Container(registry); - + Console.WriteLine("Logging Run Started"); IService service = container.GetInstance(); service.Run(); + Console.WriteLine("Logging Run Ended"); // Handling finalizing when process is ended - + } diff --git a/Source/WebJobService/Service.cs b/Source/WebJobService/Service.cs index 7ca90e8..7422b64 100644 --- a/Source/WebJobService/Service.cs +++ b/Source/WebJobService/Service.cs @@ -24,8 +24,9 @@ public class Service : IService public void Run() { - _logger.LogError($"WJ:-Service Started"); - // GetRecordToProcess().Wait(); + _logger.LogInformation($"WJ:-Service Started at {DateTime.Now} "); + Console.WriteLine("ILogger Started"); + GetRecordToProcess().Wait(); _logger.LogInformation($"WJ:-Service Completed"); } diff --git a/Source/WebJobService/WebJobService.csproj b/Source/WebJobService/WebJobService.csproj index 261fee5..953f6aa 100644 --- a/Source/WebJobService/WebJobService.csproj +++ b/Source/WebJobService/WebJobService.csproj @@ -40,8 +40,10 @@ + +