private void SetParamsBlockNumber(GridBSSConfi confi, string asset, bool unblock) { try { paramList = new List <RequestParam>(); BSSParams bssParams = new BSSParams(); AddParam(bssParams.AssetId, asset); if (unblock) { AddParam(bssParams.AssetStatus, ((int)AssetStatus.New).ToString()); AddParam(bssParams.UnBlockAsset, "true"); } else { AddParam(bssParams.AssetStatus, ((int)AssetStatus.Blocked).ToString()); AddParam(bssParams.UnBlockAsset, "false"); } AddParam(bssParams.EntityId, confi.GridEntityId.ToString()); } catch (Exception ex) { throw ex; } }
private void SetParams(GridBSSConfi confi, int serviceCode) { try { paramList = new List <RequestParam>(); BSSParams bssParams = new BSSParams(); AddParam(bssParams.AssetStatus, ((int)AssetStatus.New).ToString()); AddParam(bssParams.CategoryId, serviceCode.ToString()); AddParam(bssParams.ProductId, confi.GridProductId.ToString()); AddParam(bssParams.Offset, confi.GridDefaultOffset.ToString()); AddParam(bssParams.Limit, confi.GridDefaultLimit.ToString()); AddParam(bssParams.EntityId, confi.GridEntityId.ToString()); } catch (Exception ex) { throw ex; } }
public GridBSSConfi GetGridConfig(List <Dictionary <string, string> > configDict) { try { GridBSSConfi config = new GridBSSConfi(); config.GridId = int.Parse(configDict.Single(x => x["key"] == "GridId")["value"]); #if DEBUG config.BSSAPIUrl = configDict.Single(x => x["key"] == "BSSAPILocalUrl")["value"]; #else config.BSSAPIUrl = configDict.Single(x => x["key"] == "BSSAPIUrl")["value"]; #endif config.GridDefaultAssetLimit = int.Parse(configDict.Single(x => x["key"] == "GridDefaultAssetLimit")["value"]); config.GridDefaultLimit = int.Parse(configDict.Single(x => x["key"] == "GridDefaultLimit")["value"]); config.GridDefaultOffset = int.Parse(configDict.Single(x => x["key"] == "GridDefaultOffset")["value"]); config.GridEntityId = int.Parse(configDict.Single(x => x["key"] == "GridEntityId")["value"]); config.GridProductId = int.Parse(configDict.Single(x => x["key"] == "GridProductId")["value"]); config.GridSourceNode = configDict.Single(x => x["key"] == "GridSourceNode")["value"]; config.GridUserName = configDict.Single(x => x["key"] == "GridUserName")["value"]; config.GridInvoiceRecordLimit = int.Parse(configDict.Single(x => x["key"] == "GridInvoiceRecordLimit")["value"]); return(config); } catch (Exception ex) { throw ex; } }
private void SetParamsForInvoiceRequest(GridBSSConfi confi, string accountNumber, int rangeInMonths) { try { paramList = new List <RequestParam>(); BSSParams bssParams = new BSSParams(); AddParam(bssParams.Limit, confi.GridInvoiceRecordLimit.ToString()); AddParam(bssParams.Status, ((int)Status.Confirm).ToString()); // verify whether status need to input at any time pending/confirm if (rangeInMonths > 0) { DateTime endDate = DateTime.Now; DateTime startDate = endDate.AddMonths(-(rangeInMonths)); // AddParam(bssParams.FromDate, startDate.ToString("yyyy-MM-dd")); //"2016-11-15 // AddParam(bssParams.ToDate, endDate.ToString("yyyy-MM-dd")); //"2016-11-15 } AddParam(bssParams.AccountId, accountNumber); AddParam(bssParams.EntityId, confi.GridEntityId.ToString()); } catch (Exception ex) { throw ex; } }
public async Task <BSSUpdateResponseObject> UpdateAssetBlockNumber(GridBSSConfi confi, BSSAssetRequest assetReq, string asset, bool unblock) { try { ApiClient client = new ApiClient(new Uri(confi.BSSAPIUrl)); BSSUpdateRequest request = new BSSUpdateRequest(); SetParam param = new SetParam(); UpdateRequestObject req = new UpdateRequestObject(); BSSOrderInformation orderInformation = new BSSOrderInformation(); var requestUrl = GetRequestUrl(confi.BSSAPIUrl, ref client); // set param list SetParamsBlockNumber(confi, asset, unblock); param.param = paramList; request.request_id = assetReq.request_id; request.request_timestamp = DateTime.Now.ToString("ddMMyyyyhhmmss"); request.action = BSSApis.UpdateAssetStatus.ToString(); request.userid = assetReq.userid; request.username = confi.GridUserName; request.source_node = confi.GridSourceNode; // set order information orderInformation.customer_name = ""; orderInformation.order_type = BSSApis.UpdateAssetStatus.ToString(); // sert parameter list in order information orderInformation.dataset = param; // set order information to request request.order_information = orderInformation; req.Request = request; Log.Information(JsonConvert.SerializeObject(req)); return(await client.PostAsync <BSSUpdateResponseObject, UpdateRequestObject>(requestUrl, req)); } catch (Exception ex) { throw ex; } }
public async Task <int> FinalBuddyProcessing() { try { BSSAPIHelper bsshelper = new BSSAPIHelper(); OrderDataAccess _orderAccess = new OrderDataAccess(_iconfiguration); DatabaseResponse configResponse = await _orderAccess.GetConfiguration(ConfiType.BSS.ToString()); GridBSSConfi config = bsshelper.GetGridConfig((List <Dictionary <string, string> >)configResponse.Results); DatabaseResponse serviceCAF = await _orderAccess.GetBSSServiceCategoryAndFee(ServiceTypes.Free.ToString()); try { foreach (BuddyCheckList b in buddyActionList) { int process = await ProcessBuddy(b, config, (((List <ServiceFees>)serviceCAF.Results)).FirstOrDefault().ServiceCode); } List <BuddyCheckList> unProcessedBuddies = buddyActionList.Where(b => b.IsProcessed == false).ToList(); if (unProcessedBuddies != null && unProcessedBuddies.Count > 0) { foreach (BuddyCheckList upBuddy in unProcessedBuddies) { DatabaseResponse upBuddyCreateResponse = await _orderAccess.CreatePendingBuddyList(upBuddy); } return(0); } else { ProcessOrderQueueMessage(buddyActionList[0].OrderID); return(1); } } catch (Exception ex) { LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); return(0); } } catch (Exception ex) { LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); return(0); } }
public async Task <int> RemoveBuddyHandler(int orderID, int customerID) { try { OrderDataAccess _orderAccess = new OrderDataAccess(_iconfiguration); DatabaseResponse checkBuddyResponse = await _orderAccess.CheckBuddyToRemove(orderID); if (checkBuddyResponse.ResponseCode == (int)DbReturnValue.RecordExists && checkBuddyResponse.Results != null) { BuddyToRemove buddyToRemove = (BuddyToRemove)checkBuddyResponse.Results; if (buddyToRemove.BuddyRemovalID > 0 && buddyToRemove.IsRemoved == 0 && buddyToRemove.IsPorted != 1) { BSSAPIHelper bsshelper = new BSSAPIHelper(); DatabaseResponse configResponse = await _orderAccess.GetConfiguration(ConfiType.BSS.ToString()); GridBSSConfi config = bsshelper.GetGridConfig((List <Dictionary <string, string> >)configResponse.Results); DatabaseResponse serviceCAF = await _orderAccess.GetBSSServiceCategoryAndFee(ServiceTypes.Free.ToString()); DatabaseResponse requestIdToUpdateRes = await _orderAccess.GetBssApiRequestId(GridMicroservices.Order.ToString(), BSSApis.UpdateAssetStatus.ToString(), customerID, (int)BSSCalls.ExistingSession, buddyToRemove.MobileNumber); BSSUpdateResponseObject bssUpdateResponse = new BSSUpdateResponseObject(); try { bssUpdateResponse = await bsshelper.UpdateAssetBlockNumber(config, (BSSAssetRequest)requestIdToUpdateRes.Results, buddyToRemove.MobileNumber, true); DatabaseResponse updateBuddyRemoval = await _orderAccess.UpdateBuddyRemoval(buddyToRemove.BuddyRemovalID); } catch (Exception ex) { LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical) + EnumExtensions.GetDescription(CommonErrors.BuddyRemovalFailed) + " for Order : " + orderID); } } return(1); } else { return(0); } } catch (Exception ex) { LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); return(0); } }
public async Task <BSSQueryPlanResponseObject> GetUsageHistory(GridBSSConfi confi, string mobileNumber, string requestId) { try { ApiClient client = new ApiClient(new Uri(confi.BSSAPIUrl)); BSSQueryPlanRequest request = new BSSQueryPlanRequest(); QueryPlanRequestObject req = new QueryPlanRequestObject(); QueryPlanDataset dataset = new QueryPlanDataset(); var requestUrl = GetRequestUrl(confi.BSSAPIUrl, ref client); SetParamsForUsageRequest(confi, mobileNumber); dataset.param = paramList; List <string> filters = new List <string>(); filters.Add("base_plan/add_on"); dataset.filters = filters; request.request_id = requestId; request.request_timestamp = DateTime.Now.ToString("ddMMyyyyhhmmss"); request.action = BSSApis.QueryPlan.ToString(); request.userid = confi.GridId.ToString(); request.username = confi.GridUserName; request.source_node = confi.GridSourceNode; request.dataset = dataset; req.Request = request; Log.Information(JsonConvert.SerializeObject(req)); return(await client.PostAsync <BSSQueryPlanResponseObject, QueryPlanRequestObject>(requestUrl, req)); } catch (Exception ex) { throw ex; } }
private void SetParamsOutstandingPaymentRequest(GridBSSConfi confi, string accountNumber) { try { paramList = new List <RequestParam>(); BSSParams bssParams = new BSSParams(); AddParam(bssParams.AccountId, accountNumber); } catch (Exception ex) { throw ex; } }
public async Task <BSSInvoiceResponseObject> GetBSSCustomerInvoice(GridBSSConfi confi, string requestId, string accountNumber, int dateRange) { try { ApiClient client = new ApiClient(new Uri(confi.BSSAPIUrl)); BSSInvoiceRequest request = new BSSInvoiceRequest(); BSSInvoiceRequestObject req = new BSSInvoiceRequestObject(); SetParam dataset = new SetParam(); var requestUrl = GetRequestUrl(confi.BSSAPIUrl, ref client); SetParamsForInvoiceRequest(confi, accountNumber, dateRange); dataset.param = paramList; request.request_id = requestId; request.request_timestamp = DateTime.Now.ToString("ddMMyyyyhhmmss"); request.action = BSSApis.GetInvoiceDetails.ToString(); request.userid = confi.GridId.ToString(); request.username = confi.GridUserName; request.source_node = confi.GridSourceNode; request.dataset = dataset; req.Request = request; Log.Information(JsonConvert.SerializeObject(req)); return(await client.PostAsync <BSSInvoiceResponseObject, BSSInvoiceRequestObject>(requestUrl, req)); } catch (Exception ex) { throw ex; } }
public async Task <ResponseObject> GetAssetInventory(GridBSSConfi confi, int serviceCode, BSSAssetRequest assetRequest, int count) { try { ApiClient client = new ApiClient(new Uri(confi.BSSAPIUrl)); BSSAssetRequest request = new BSSAssetRequest(); SetParam param = new SetParam(); RequestObject req = new RequestObject(); var requestUrl = GetRequestUrl(confi.BSSAPIUrl, ref client); SetParams(confi, serviceCode, count); param.param = paramList; request.request_id = assetRequest.request_id; request.request_timestamp = DateTime.Now.ToString("ddMMyyyyhhmmss"); request.action = BSSApis.GetAssets.ToString(); request.userid = assetRequest.userid; request.username = confi.GridUserName; request.source_node = confi.GridSourceNode; request.dataset = param; req.Request = request; Log.Information(JsonConvert.SerializeObject(req)); return(await client.PostAsync <ResponseObject, RequestObject>(requestUrl, req)); } catch (Exception ex) { throw ex; } }
private void SetParamsForUsageRequest(GridBSSConfi confi, string mobileNumber) { try { paramList = new List <RequestParam>(); BSSParams bssParams = new BSSParams(); AddParam(bssParams.ServiceId, mobileNumber); AddParam(bssParams.ConnectionType, ((int)ConnectionTypes.Prepaid).ToString()); AddParam(bssParams.EntityId, confi.GridEntityId.ToString()); } catch (Exception ex) { throw ex; } }
public async Task <BuddyCheckList> ProcessBuddy(BuddyCheckList buddy) { try { BSSAPIHelper bsshelper = new BSSAPIHelper(); BuddyDataAccess _buddyAccess = new BuddyDataAccess(); DatabaseResponse configResponse = await _buddyAccess.GetConfiguration(ConfiType.BSS.ToString(), _connectionString); GridBSSConfi config = bsshelper.GetGridConfig((List <Dictionary <string, string> >)configResponse.Results); LogInfo.Information(JsonConvert.SerializeObject(config)); DatabaseResponse serviceCAF = await _buddyAccess.GetBSSServiceCategoryAndFee(ServiceTypes.Free.ToString(), _connectionString); DatabaseResponse requestIdRes = await _buddyAccess.GetBssApiRequestId(GridMicroservices.Order.ToString(), BSSApis.GetAssets.ToString(), buddy.CustomerID, (int)BSSCalls.NewSession, "", _connectionString); ResponseObject res = new ResponseObject(); try { res = await bsshelper.GetAssetInventory(config, (((List <ServiceFees>)serviceCAF.Results)).FirstOrDefault().ServiceCode, (BSSAssetRequest)requestIdRes.Results); LogInfo.Information(JsonConvert.SerializeObject(res)); } catch (Exception ex) { LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical) + EnumExtensions.GetDescription(CommonErrors.BSSConnectionFailed)); buddy.IsProcessed = false; return(buddy); } string AssetToSubscribe = string.Empty; if (res != null && (int.Parse(res.Response.asset_details.total_record_count) > 0)) { AssetToSubscribe = bsshelper.GetAssetId(res); BSSNumbers numbers = new BSSNumbers(); numbers.FreeNumbers = bsshelper.GetFreeNumbers(res); //insert these number into database string json = bsshelper.GetJsonString(numbers.FreeNumbers); // json insert DatabaseResponse updateBssCallFeeNumbers = await _buddyAccess.UpdateBSSCallNumbers(json, ((BSSAssetRequest)requestIdRes.Results).userid, ((BSSAssetRequest)requestIdRes.Results).BSSCallLogID, _connectionString); //Block number _connectionString DatabaseResponse requestIdToUpdateRes = await _buddyAccess.GetBssApiRequestId(GridMicroservices.Order.ToString(), BSSApis.UpdateAssetStatus.ToString(), buddy.CustomerID, (int)BSSCalls.ExistingSession, AssetToSubscribe, _connectionString); BSSUpdateResponseObject bssUpdateResponse = new BSSUpdateResponseObject(); try { bssUpdateResponse = await bsshelper.UpdateAssetBlockNumber(config, (BSSAssetRequest)requestIdToUpdateRes.Results, AssetToSubscribe, false); } catch (Exception ex) { LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical) + EnumExtensions.GetDescription(CommonErrors.BSSConnectionFailed)); buddy.IsProcessed = false; return(buddy); } if (bssUpdateResponse != null && bsshelper.GetResponseCode(bssUpdateResponse) == "0") { // update buddy process BuddyNumberUpdate buddyToProcess = new BuddyNumberUpdate { OrderSubscriberID = buddy.OrderSubscriberID, UserId = ((BSSAssetRequest)requestIdRes.Results).userid, NewMobileNumber = AssetToSubscribe }; LogInfo.Information(JsonConvert.SerializeObject(buddyToProcess)); DatabaseResponse buddyProcessResponse = await _buddyAccess.ProcessBuddyPlan(buddyToProcess, _connectionString); LogInfo.Information(JsonConvert.SerializeObject(buddyProcessResponse)); if (buddyProcessResponse.ResponseCode == (int)DbReturnValue.CreateSuccess || buddyProcessResponse.ResponseCode == (int)DbReturnValue.BuddyAlreadyExists) { // update process status buddy.IsProcessed = true; return(buddy); } else { // buddy process failed buddy.IsProcessed = false; return(buddy); } } else { // buddy block failed buddy.IsProcessed = false; return(buddy); } } else { // no assets returned buddy.IsProcessed = false; return(buddy); } } catch (Exception ex) { LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); buddy.IsProcessed = false; return(buddy); } }
public async Task <List <Recordset> > GetInvoiceList(int customerID) { BSSAPIHelper bsshelper = new BSSAPIHelper(); OrderDataAccess _orderAccess = new OrderDataAccess(_iconfiguration); DatabaseResponse systemConfigResponse = await _orderAccess.GetConfiguration(ConfiType.System.ToString()); DatabaseResponse bssConfigResponse = await _orderAccess.GetConfiguration(ConfiType.BSS.ToString()); GridBSSConfi bssConfig = bsshelper.GetGridConfig((List <Dictionary <string, string> >)bssConfigResponse.Results); GridSystemConfig systemConfig = bsshelper.GetGridSystemConfig((List <Dictionary <string, string> >)systemConfigResponse.Results); DatabaseResponse accountResponse = await _orderAccess.GetCustomerBSSAccountNumber(customerID); if (accountResponse.ResponseCode == (int)DbReturnValue.RecordExists) { if (!string.IsNullOrEmpty(((BSSAccount)accountResponse.Results).AccountNumber)) { // Get default daterange in month from config by key - BSSInvoiceDefaultDateRangeInMonths DatabaseResponse dateRangeResponse = ConfigHelper.GetValueByKey(ConfigKeys.BSSInvoiceDefaultDateRangeInMonths.ToString(), _iconfiguration); int rangeInMonths = int.Parse(((string)dateRangeResponse.Results)); DatabaseResponse requestIdRes = await _orderAccess.GetBssApiRequestId(GridMicroservices.Customer.ToString(), BSSApis.GetInvoiceDetails.ToString(), customerID, 0, ""); BSSInvoiceResponseObject invoiceResponse = await bsshelper.GetBSSCustomerInvoice(bssConfig, ((BSSAssetRequest)requestIdRes.Results).request_id, ((BSSAccount)accountResponse.Results).AccountNumber, rangeInMonths); if (invoiceResponse.Response.result_code == "0") { // Get download link prefix from config DatabaseResponse downloadLinkResponse = ConfigHelper.GetValueByKey(ConfigKeys.BSSInvoiceDownloadLink.ToString(), _iconfiguration); string downloadLinkPrefix = (string)downloadLinkResponse.Results; foreach (Recordset recordset in invoiceResponse.Response.invoice_details.recordset) { recordset.download_url = downloadLinkPrefix + recordset.bill_id; } return(invoiceResponse.Response.invoice_details.recordset); } else { LogInfo.Warning(EnumExtensions.GetDescription(CommonErrors.NoInvoiceFound) + " : " + customerID); return(new List <Recordset>()); } } else { LogInfo.Warning(EnumExtensions.GetDescription(CommonErrors.MandatoryFieldMissing) + " for Customer - " + customerID); return(new List <Recordset>()); } } else { LogInfo.Warning(EnumExtensions.GetDescription(CommonErrors.FailedToGetBillingAccount)); return(new List <Recordset>()); } }
public async Task <int> ProcessBuddy(BuddyCheckList buddy, GridBSSConfi config, int serviceCode) { try { BSSAPIHelper bsshelper = new BSSAPIHelper(); OrderDataAccess _orderAccess = new OrderDataAccess(_iconfiguration); DatabaseResponse requestIdRes = await _orderAccess.GetBssApiRequestId(GridMicroservices.Order.ToString(), BSSApis.GetAssets.ToString(), buddy.CustomerID, (int)BSSCalls.NewSession, ""); ResponseObject res = new ResponseObject(); try { res = await bsshelper.GetAssetInventory(config, serviceCode, (BSSAssetRequest)requestIdRes.Results); } catch (Exception ex) { LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical) + EnumExtensions.GetDescription(CommonErrors.BSSConnectionFailed)); buddy.IsProcessed = false; return(0); } string AssetToSubscribe = string.Empty; if (res != null) { AssetToSubscribe = bsshelper.GetAssetId(res); BSSNumbers numbers = new BSSNumbers(); numbers.FreeNumbers = bsshelper.GetFreeNumbers(res); //insert these number into database string json = bsshelper.GetJsonString(numbers.FreeNumbers); // json insert DatabaseResponse updateBssCallFeeNumbers = await _orderAccess.UpdateBSSCallNumbers(json, ((BSSAssetRequest)requestIdRes.Results).userid, ((BSSAssetRequest)requestIdRes.Results).BSSCallLogID); } else { return(0); } if (res != null && (int.Parse(res.Response.asset_details.total_record_count) > 0)) { //Block number DatabaseResponse requestIdToUpdateRes = await _orderAccess.GetBssApiRequestId(GridMicroservices.Order.ToString(), BSSApis.UpdateAssetStatus.ToString(), buddy.CustomerID, (int)BSSCalls.ExistingSession, AssetToSubscribe); BSSUpdateResponseObject bssUpdateResponse = await bsshelper.UpdateAssetBlockNumber(config, (BSSAssetRequest)requestIdToUpdateRes.Results, AssetToSubscribe, false); if (bsshelper.GetResponseCode(bssUpdateResponse) == "0") { // update buddy process BuddyNumberUpdate buddyToProcess = new BuddyNumberUpdate { OrderSubscriberID = buddy.OrderSubscriberID, UserId = ((BSSAssetRequest)requestIdRes.Results).userid, NewMobileNumber = AssetToSubscribe }; DatabaseResponse buddyProcessResponse = await _orderAccess.ProcessBuddyPlan(buddyToProcess); if (buddyProcessResponse.ResponseCode == (int)DbReturnValue.CreateSuccess) { // update process status buddy.IsProcessed = true; return(1); } else { // buddy process failed buddy.IsProcessed = false; return(0); } } else { // buddy block failed buddy.IsProcessed = false; LogInfo.Error(EnumExtensions.GetDescription(CommonErrors.UpdateAssetBlockingFailed)); return(0); } } else { // no assets returned buddy.IsProcessed = false; LogInfo.Error(EnumExtensions.GetDescription(CommonErrors.GetAssetFailed)); return(0); } } catch (Exception ex) { buddy.IsProcessed = false; LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); return(0); } }
public async Task <int> HandleRollbackOnAdditionalBuddyProcessingFailure(int customerID, int orderID, List <AdditionalBuddy> additionalBuddies) { try { OrderDataAccess _orderAccess = new OrderDataAccess(_iconfiguration); BSSAPIHelper bsshelper = new BSSAPIHelper(); DatabaseResponse configResponse = await _orderAccess.GetConfiguration(ConfiType.BSS.ToString()); GridBSSConfi config = bsshelper.GetGridConfig((List <Dictionary <string, string> >)configResponse.Results); DatabaseResponse serviceCAF = await _orderAccess.GetBSSServiceCategoryAndFee(ServiceTypes.Free.ToString()); //unblock all subscribers for the order foreach (AdditionalBuddy buddy in additionalBuddies) { // unblock mainline subscriber - not ported if (buddy.IsPorted == 0) { DatabaseResponse requestIdToUnblockSubscribers = await _orderAccess.GetBssApiRequestId(GridMicroservices.Order.ToString(), BSSApis.UpdateAssetStatus.ToString(), customerID, (int)BSSCalls.ExistingSession, buddy.MobileNumber); BSSUpdateResponseObject bssUpdateAdditionalBuddyMainlineUnblockResponse = new BSSUpdateResponseObject(); try { bssUpdateAdditionalBuddyMainlineUnblockResponse = await bsshelper.UpdateAssetBlockNumber(config, (BSSAssetRequest)requestIdToUnblockSubscribers.Results, buddy.MobileNumber, true); if (bsshelper.GetResponseCode(bssUpdateAdditionalBuddyMainlineUnblockResponse) != "0") { //failed to unblock subscriber number add it to buddy removal table DatabaseResponse logUnblockFailedSubscriber = await _orderAccess.LogUnblockFailedMainline(orderID, buddy); if (logUnblockFailedSubscriber.ResponseCode != (int)DbReturnValue.CreateSuccess) { LogInfo.Warning("Unlocking failed subscriber loging to BuddyRemoval table failed for OrderID:" + orderID + ", MobileNumber:" + buddy.MobileNumber); } } } catch { //failed to unblock subscriber number add it to buddy removal table DatabaseResponse logUnblockFailedSubscriber = await _orderAccess.LogUnblockFailedMainline(orderID, buddy); if (logUnblockFailedSubscriber.ResponseCode != (int)DbReturnValue.CreateSuccess) { LogInfo.Warning("Unlocking failed subscriber loging to BuddyRemoval table failed for OrderID:" + orderID + ", MobileNumber:" + buddy.MobileNumber); } } } } //remove additional buddy for the order from additional buddy table DatabaseResponse removeAdditionalBuddyRes = await _orderAccess.RemoveAdditionalBuddyOnRollBackOrder(orderID); //rollback order DatabaseResponse rollbackResponse = await _orderAccess.RollBackOrder(orderID, "Rollback while processing additional buddy line"); return(1); } catch (Exception ex) { LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); return(0); } }
public async Task <string> GetNumberFromBSS(int CustomerID) { OrderDataAccess _orderAccess = new OrderDataAccess(_iconfiguration); BSSAPIHelper bsshelper = new BSSAPIHelper(); DatabaseResponse configResponse = await _orderAccess.GetConfiguration(ConfiType.BSS.ToString()); GridBSSConfi config = bsshelper.GetGridConfig((List <Dictionary <string, string> >)configResponse.Results); DatabaseResponse serviceCAF = await _orderAccess.GetBSSServiceCategoryAndFee(ServiceTypes.Free.ToString()); DatabaseResponse requestIdRes = await _orderAccess.GetBssApiRequestId(GridMicroservices.Order.ToString(), BSSApis.GetAssets.ToString(), CustomerID, (int)BSSCalls.NewSession, ""); ResponseObject res = new ResponseObject(); try { res = await bsshelper.GetAssetInventory(config, (((List <ServiceFees>)serviceCAF.Results)).FirstOrDefault().ServiceCode, (BSSAssetRequest)requestIdRes.Results); if (res != null && res.Response != null && res.Response.asset_details != null && (int.Parse(res.Response.asset_details.total_record_count) > 0)) { BSSNumbers numbers = new BSSNumbers(); numbers.FreeNumbers = bsshelper.GetFreeNumbers(res); string number = numbers.FreeNumbers[0].MobileNumber; string json = bsshelper.GetJsonString(numbers.FreeNumbers); // json insert DatabaseResponse updateBssCallFreeNumbers = await _orderAccess.UpdateBSSCallNumbers(json, ((BSSAssetRequest)requestIdRes.Results).userid, ((BSSAssetRequest)requestIdRes.Results).BSSCallLogID); DatabaseResponse requestIdToUpdateMainLineRes = await _orderAccess.GetBssApiRequestId(GridMicroservices.Order.ToString(), BSSApis.UpdateAssetStatus.ToString(), CustomerID, (int)BSSCalls.ExistingSession, number); BSSUpdateResponseObject bssUpdateResponse = new BSSUpdateResponseObject(); try { //line blocking bssUpdateResponse = await bsshelper.UpdateAssetBlockNumber(config, (BSSAssetRequest)requestIdToUpdateMainLineRes.Results, number, false); if (bsshelper.GetResponseCode(bssUpdateResponse) == "0") { return(number); } else { return(""); } } catch (Exception ex) { LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical) + EnumExtensions.GetDescription(CommonErrors.BSSConnectionFailed)); return(""); } } else { return(""); } } catch (Exception ex) { LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical) + EnumExtensions.GetDescription(CommonErrors.BSSConnectionFailed)); return(""); } }
public async Task <BSSAccountQuerySubscriberResponse> GetBSSOutstandingPayment(GridBSSConfi confi, string requestId, string accountNumber) { try { ApiClient client = new ApiClient(new Uri(confi.BSSAPIUrl)); BSSQueryPlanRequest request = new BSSQueryPlanRequest(); QueryPlanRequestObject req = new QueryPlanRequestObject(); QueryPlanDataset dataset = new QueryPlanDataset(); var requestUrl = GetRequestUrl(confi.BSSAPIUrl, ref client); SetParamsOutstandingPaymentRequest(confi, accountNumber); dataset.param = paramList; List <string> filters = new List <string>(); filters.Add("account"); dataset.filters = filters; request.request_id = requestId; request.request_timestamp = DateTime.Now.ToString("ddMMyyyyhhmmss"); request.action = BSSApis.QuerySubscriber.ToString(); request.userid = confi.GridId.ToString(); request.username = confi.GridUserName; request.source_node = confi.GridSourceNode; request.dataset = dataset; req.Request = request; Log.Information(JsonConvert.SerializeObject(req)); return(await client.PostAsync <BSSAccountQuerySubscriberResponse, QueryPlanRequestObject>(requestUrl, req)); } catch (Exception ex) { throw ex; } }
public async Task <int> AddRemoveBuddyHandler(int orderID, int customerID) { try { OrderDataAccess _orderAccess = new OrderDataAccess(_iconfiguration); // call remove buddy handler here int isRemoved = await RemoveBuddyHandler(orderID, customerID); DatabaseResponse checkAdditionalBuddyResponse = await _orderAccess.CheckAdditionalBuddy(orderID); // check additional Buddy if (checkAdditionalBuddyResponse.ResponseCode == (int)DbReturnValue.RecordExists && checkAdditionalBuddyResponse.Results != null) { List <AdditionalBuddy> additionalBuddies = (List <AdditionalBuddy>)checkAdditionalBuddyResponse.Results; foreach (AdditionalBuddy buddy in additionalBuddies) { if (buddy.OrderAdditionalBuddyID > 0 && buddy.IsProcessed == 0) { BSSAPIHelper bsshelper = new BSSAPIHelper(); DatabaseResponse configResponse = await _orderAccess.GetConfiguration(ConfiType.BSS.ToString()); GridBSSConfi config = bsshelper.GetGridConfig((List <Dictionary <string, string> >)configResponse.Results); DatabaseResponse serviceCAF = await _orderAccess.GetBSSServiceCategoryAndFee(ServiceTypes.Free.ToString()); DatabaseResponse requestIdToGetAdditionalBuddy = await _orderAccess.GetBssApiRequestId(GridMicroservices.Order.ToString(), BSSApis.GetAssets.ToString(), customerID, (int)BSSCalls.NewSession, ""); ResponseObject res = new ResponseObject(); BSSNumbers numbers = new BSSNumbers(); //get a free number for additional buddy try { res = await bsshelper.GetAssetInventory(config, (((List <ServiceFees>)serviceCAF.Results)).FirstOrDefault().ServiceCode, (BSSAssetRequest)requestIdToGetAdditionalBuddy.Results); } catch (Exception ex) { LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical) + EnumExtensions.GetDescription(CommonErrors.BSSConnectionFailed)); // need to unblock all subscribers for the order and roll back the order and return int buddyRollback = await HandleRollbackOnAdditionalBuddyProcessingFailure(customerID, orderID, additionalBuddies); // rollback on bss failure return(3); } if (res != null && res.Response != null && res.Response.asset_details != null && (int.Parse(res.Response.asset_details.total_record_count) > 0)) { numbers.FreeNumbers = bsshelper.GetFreeNumbers(res); //insert these number into database string json = bsshelper.GetJsonString(numbers.FreeNumbers); // json insert DatabaseResponse updateBssCallFeeNumbers = await _orderAccess.UpdateBSSCallNumbers(json, ((BSSAssetRequest)requestIdToGetAdditionalBuddy.Results).userid, ((BSSAssetRequest)requestIdToGetAdditionalBuddy.Results).BSSCallLogID); DatabaseResponse requestIdToUpdateAdditionalBuddyRes = await _orderAccess.GetBssApiRequestId(GridMicroservices.Order.ToString(), BSSApis.UpdateAssetStatus.ToString(), customerID, (int)BSSCalls.ExistingSession, numbers.FreeNumbers[0].MobileNumber); BSSUpdateResponseObject bssUpdateAdditionalBuddyResponse = new BSSUpdateResponseObject(); // block the number for additional buddy try { bssUpdateAdditionalBuddyResponse = await bsshelper.UpdateAssetBlockNumber(config, (BSSAssetRequest)requestIdToUpdateAdditionalBuddyRes.Results, numbers.FreeNumbers[0].MobileNumber, false); // create buddy subscriber with blocked number and the existing main line if (bsshelper.GetResponseCode(bssUpdateAdditionalBuddyResponse) == "0") { CreateBuddySubscriber additinalBuddySubscriberToCreate = new CreateBuddySubscriber { OrderID = orderID, MobileNumber = numbers.FreeNumbers[0].MobileNumber, MainLineMobileNumber = buddy.MobileNumber, UserId = ((BSSAssetRequest)requestIdToUpdateAdditionalBuddyRes.Results).userid }; DatabaseResponse createAdditionalBuddySubscriberResponse = await _orderAccess.CreateBuddySubscriber(additinalBuddySubscriberToCreate); // update if (createAdditionalBuddySubscriberResponse.ResponseCode == (int)DbReturnValue.CreateSuccess) { DatabaseResponse updateBuddyProcessedResponse = await _orderAccess.UpdateAdditionalBuddyProcessing(buddy.OrderAdditionalBuddyID); } } } catch (Exception ex) { LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical) + EnumExtensions.GetDescription(CommonErrors.BuddyRemovalFailed) + " for Order : " + orderID); } } else { // rollback on no assets retunred int buddyRollback = await HandleRollbackOnAdditionalBuddyProcessingFailure(customerID, orderID, additionalBuddies); return(2); } } } } return(1); } catch (Exception ex) { LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical)); return(0); } }