/// <summary> /// Method Name : AlertGenerationForAllOrderedMoves /// Author : Pratik Soni /// Creation Date : 28 Feb 2018 /// Purpose : Loops through all moves and generates alerts for all. /// Revision : /// <param name="moveModelList">List of model for which alerts needs to be generated.</param> /// </summary> /// private void AlertGenerationForAllMoves(List <MoveModel> moveModelList) { string requestContentForBookedMove; string apiPath; HttpResponseMessage httpResponseMessage; string startDate; foreach (var dtoMove in moveModelList) { startDate = GetBeginningDayOfService(dtoMove); if (string.IsNullOrEmpty(startDate)) { continue; } //Generate JSON for Booked move (which are in ORDERED status) Notification Confirmation requestContentForBookedMove = beginningOfDayOfServiceGenerator.GenerateJSON(dtoMove.ContactOfMoveId, startDate); //POST AlertJson in CRM apiPath = General.GetAPIPath(resourceManager.GetString("AlertService"), dtoMove.ContactOfMoveId); httpResponseMessage = apiHelper.InvokePostAPI(apiPath, requestContentForBookedMove); if (!httpResponseMessage.IsSuccessStatusCode) { logger.Info(resourceManager.GetString("logAlertCreatedForMove") + dtoMove.MoveId); } } }
/// <summary> /// Method Name : AlertGenerationForAllOrderedMoves /// Author : Pratik Soni /// Creation Date : 26 Feb 2018 /// Purpose : Loops through all moves and generates alerts for all. /// Revision : /// <paramref name="failedMoveModelList">referenced parameter to pass the list of failed moves for which error occured while alert generation.</paramref> /// <paramref name="moveModelList">List of model for which alerts needs to be generated.</paramref> /// </summary> /// private void AlertGenerationForAllOrderedMoves(ref List <MoveModel> failedMoveModelList, List <MoveModel> moveModelList) { string requestContentForBookedMove; string apiPath; HttpResponseMessage httpResponseMessage; foreach (var dtoMove in moveModelList) { //Generate JSON for Booked move (which are in ORDERED status) Notification Confirmation requestContentForBookedMove = bookYourMoveGenerator.GenerateJSON(dtoMove.ContactOfMoveId, resourceManager.GetString("alertDescription_BookYourMove")); //POST AlertJson in CRM apiPath = General.GetAPIPath(resourceManager.GetString("AlertService"), dtoMove.ContactOfMoveId); httpResponseMessage = apiHelper.InvokePostAPI(apiPath, requestContentForBookedMove); if (!httpResponseMessage.IsSuccessStatusCode) { logger.Info(resourceManager.GetString("logAlertCreatedForMove") + dtoMove.MoveId); failedMoveModelList.Add(dtoMove); } } }
/// <summary> /// Method Name : AlertGenerationForAllMoves /// Author : Pratik Soni /// Creation Date : 26 Feb 2018 /// Purpose : Loops through all moves and generates alerts for all. /// Revision : /// <paramref name="failedMoveModelList">referenced parameter to pass the list of failed moves for which error occured while alert generation.</paramref> /// <paramref name="moveModelList">List of model for which alerts needs to be generated.</paramref> /// </summary> /// private void AlertGenerationForAllMoves(ref List <MoveModel> failedMoveModelList, List <MoveModel> moveModelList) { string requestContentForPreMove; string alertDescription = string.Empty; string date; string apiPath; DateTime moveStartDate; HttpResponseMessage httpResponseMessage; foreach (var dtoMove in moveModelList) { //Use packDate, and if it is blank use loadDate as MoveStartDate date = (string.IsNullOrEmpty(dtoMove.MoveDetails_PackStartDate) ? dtoMove.MoveDetails_LoadStartDate : dtoMove.MoveDetails_PackStartDate); moveStartDate = DateTime.Parse(date, new CultureInfo("en-US"), DateTimeStyles.None); alertDescription = ValidateMoveAndGetAlertDescription(moveStartDate); // If current move is not satisfying the switch case, continue with next move if (string.IsNullOrEmpty(alertDescription)) { continue; } //Generate JSON for PreMove Notification Confirmation requestContentForPreMove = preMoveConfirmationNotification.GenerateJSON(dtoMove.ContactOfMoveId, moveStartDate.ToString(resourceManager.GetString("ShortUSDateFormat")), moveStartDate.AddDays(1).ToString(resourceManager.GetString("ShortUSDateFormat")), alertDescription); //POST AlertJson in CRM apiPath = General.GetAPIPath(resourceManager.GetString("AlertService"), dtoMove.ContactOfMoveId); httpResponseMessage = apiHelper.InvokePostAPI(apiPath, requestContentForPreMove); if (!httpResponseMessage.IsSuccessStatusCode) { logger.Info(resourceManager.GetString("logAlertCreatedForMove") + dtoMove.MoveId); failedMoveModelList.Add(dtoMove); } } }