private void SheduleOrderPeriodicalNotificationsInternal(Order order, OrderPeriodicalNotificationType notificationType, IDictionary<TaskParamsKey, object> additionalParams)
		{
			var taskPeriod = GetTaskPeriodTypesAndStartPoint(order, notificationType);
			DateTime? minStartDate = CalculateNextRunTime(taskPeriod.InitialNotificationType.Value, taskPeriod.StartPoint.Value);

			_taskManager.SheduleOrderPeriodicalNotificationTask(order.Id, minStartDate, notificationType, additionalParams);
		}
		public void SheduleOrderPeriodicalNotifications(Order order, OrderPeriodicalNotificationType notificationType)
		{
			if (new OrderPeriodicalNotificationType[]
				{ OrderPeriodicalNotificationType.UpdateRequestNotification, OrderPeriodicalNotificationType.UpdateRequestEscalation,
				OrderPeriodicalNotificationType.ConditionCreatedNotification, OrderPeriodicalNotificationType.ConditionResponseEscalation }
				.Contains(notificationType))
			{
				throw new NotSupportedException();
			}
			SheduleOrderPeriodicalNotificationsInternal(order, notificationType, null);
		}
Пример #3
0
		private void SendNotificationEmail(OrderPeriodicalNotificationType notificationType)
		{
			string orderId = GetParamValue(TaskParamsKey.OrderId);
			var order = _orderManager.GetOrderById(int.Parse(orderId));

			if (order.IsTestOrder || !IsTaskAvaibleByOrder(order, notificationType))
			{
				return;
			}
			Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

			switch (notificationType)
			{
				case OrderPeriodicalNotificationType.CompleteInspectionEscalation:
					SendCompleteInspectionEscalation(order);
					break;
				case OrderPeriodicalNotificationType.CompleteInspectionNotification:
					SendCompleteInspectionNotification(order);
					break;
				case OrderPeriodicalNotificationType.ConditionResponseEscalation:
					SendConditionCreatedEscalation(order);
					break;
				case OrderPeriodicalNotificationType.ConditionCreatedNotification:
					SendConditionCreatedNotification(order);
					break;
				case OrderPeriodicalNotificationType.SheduleInspectionEscalation:
					SendSheduleInspectionEscalation(order);
					break;
				case OrderPeriodicalNotificationType.SheduleInspectionNotification:
					SendSheduleInspectionNotification(order);
					break;
				case OrderPeriodicalNotificationType.SubmitAppraisalEscalation:
					SendSubmitAppraisalEscalation(order);
					break;
				case OrderPeriodicalNotificationType.SubmitAppraisalNotification:
					SendSubmitAppraisalNotification(order);
					break;
				case OrderPeriodicalNotificationType.UpdateRequestEscalation:
					SendUpdateRequestEscalation(order);
					break;
				case OrderPeriodicalNotificationType.UpdateRequestNotification:
					SendUpdateRequestNotification(order);
					break;
				case OrderPeriodicalNotificationType.ValueReconsiderationCreated:
					SendValueReconsiderationCreatedNotification(order);
					break;
				default: throw new ArgumentOutOfRangeException("Unknown OrderPeriodicalNotificationType. OrderPeriodicalNotificationType: " + notificationType.ToString());
			}
		}
Пример #4
0
		private bool IsTaskAvaibleByOrder(Order order, OrderPeriodicalNotificationType notificationType)
		{
			var result = true;
			if (order.OrderStatus == OrderStatus.Cancelled ||
				order.OrderStatus == OrderStatus.CreationProcess ||
				order.OrderStatus == OrderStatus.Draft ||
				order.OrderStatus == OrderStatus.PendingAssignment ||
				order.OrderStatus == OrderStatus.Rejected)
			{
				result = false;
			}
			if (order.OrderStatus == OrderStatus.Completed)
			{
				if (
					notificationType == OrderPeriodicalNotificationType.UpdateRequestNotification ||
					notificationType == OrderPeriodicalNotificationType.ConditionCreatedNotification
					)
				{
					result = true;
				}
				else
				{
					result = false;
				}
			}
			return result;
		}
Пример #5
0
		private void AddNextTask(Order order, OrderPeriodicalNotificationType orderNotificationType, IDictionary<TaskParamsKey, object> additionalParams = null)
		{
			var nextRunTime = _orderPeriodicalManager.GetNextPeriodicalNotificationDate(order, orderNotificationType);
			if (nextRunTime.HasValue)
			{
				var parameters = new Dictionary<TaskParamsKey, string>();
				parameters.Add(TaskParamsKey.OrderId, order.Id.ToString());
				parameters.Add(TaskParamsKey.OrderPeriodicalNotificationTaskType, orderNotificationType.ToString());
				if (additionalParams != null)
				{
					foreach (var param in additionalParams)
					{
						parameters.Add(param.Key, param.Value.ToString());
					}
				}
				AddNew(TaskTypeEnum.OrderPeriodicalNotification, parameters, nextRunTime.Value, this.Task.Id);
			}
		}
		private OrderNotificationTaskPeriods GetTaskPeriodTypesAndStartPoint(Order order, OrderPeriodicalNotificationType notificationType)
		{
			bool isRush = order.AppraisalInfo.Rush;

			OrderNotificationType? startPeriodType = null;
			OrderNotificationType? periodType = null;
			//start point for calculations. for example, Due Date or InspectionShedulledDate
			DateTime? startPoint = null;

			#region Detect config keys and startPoint for current notification type

			switch (notificationType)
			{

				#region Order Period Notifications
				case OrderPeriodicalNotificationType.SheduleInspectionNotification:
					startPeriodType = isRush ?
						OrderNotificationType.SheduleInspectionNotificationInitialRush :
						OrderNotificationType.SheduleInspectionNotificationInitialNoRush;
					periodType = isRush ?
						OrderNotificationType.SheduleInspectionNotificationPeriodRush :
						OrderNotificationType.SheduleInspectionNotificationPeriodNoRush;
					startPoint = order.DueDate;
					break;
				case OrderPeriodicalNotificationType.CompleteInspectionNotification:
					startPeriodType = isRush ?
						OrderNotificationType.CompleteInspectionNotificationInitialRush :
						OrderNotificationType.CompleteInspectionNotificationInitialNoRush;
					periodType = isRush ?
					OrderNotificationType.CompleteInspectionNotificationPeriodRush :
					OrderNotificationType.CompleteInspectionNotificationPeriodNoRush;
					startPoint = order.DueDate;
					break;
				case OrderPeriodicalNotificationType.SubmitAppraisalNotification:
					startPeriodType = isRush ?
						OrderNotificationType.SubmitAppraisalNotificationInitialRush :
						OrderNotificationType.SubmitAppraisalNotificationInitialNoRush;
					periodType = isRush ?
						OrderNotificationType.SubmitAppraisalNotificationPeriodRush :
						OrderNotificationType.SubmitAppraisalNotificationPeriodNoRush;
					startPoint = order.DueDate;
					break;
				case OrderPeriodicalNotificationType.UpdateRequestNotification:
					startPeriodType = isRush ?
						OrderNotificationType.UpdateRequestNotificationInitialRush :
						OrderNotificationType.UpdateRequestNotificationInitialNoRush;
					periodType = isRush ?
						OrderNotificationType.UpdateRequestNotificationPeriodRush :
						OrderNotificationType.UpdateRequestNotificationPeriodNoRush;
					startPoint = DateTime.Now;
					break;
				case OrderPeriodicalNotificationType.ConditionCreatedNotification:
					startPeriodType = isRush ?
					OrderNotificationType.ConditionCreatedNotificationInitialRush :
					OrderNotificationType.ConditionCreatedNotificationInitialNoRush;
					periodType = isRush ?
					OrderNotificationType.ConditionCreatedNotificationPeriodRush :
					OrderNotificationType.ConditionCreatedNotificationPeriodNoRush;
					startPoint = DateTime.Now;
					break;
				case OrderPeriodicalNotificationType.ValueReconsiderationCreated:
					startPeriodType = isRush ?
					OrderNotificationType.ValueReconsiderationCreatedNotificationInitialRush :
					OrderNotificationType.ValueReconsiderationCreatedInitialNoRush;
					periodType = isRush ?
					OrderNotificationType.ValueReconsiderationCreatedPeriodRush :
					OrderNotificationType.ValueReconsiderationCreatedPeriodNoRush;
					startPoint = DateTime.Now;
					break;
				#endregion

				#region Order Period Escalations
				case OrderPeriodicalNotificationType.SheduleInspectionEscalation:
					startPeriodType = isRush ?
					OrderNotificationType.SheduleInspectionEscalationInitialRush :
					OrderNotificationType.SheduleInspectionEscalationInitialNoRush;
					periodType = isRush ?
					OrderNotificationType.SheduleInspectionEscalationPeriodRush :
					OrderNotificationType.SheduleInspectionEscalationPeriodNoRush;
					startPoint = order.DueDate;
					break;
				case OrderPeriodicalNotificationType.CompleteInspectionEscalation:
					startPeriodType = isRush ?
					OrderNotificationType.CompleteInspectionEscalationInitialRush :
					OrderNotificationType.CompleteInspectionEscalationInitialNoRush;
					periodType = isRush ?
						OrderNotificationType.CompleteInspectionEscalationPeriodRush :
						OrderNotificationType.CompleteInspectionEscalationPeriodNoRush;
					startPoint = order.DueDate;
					break;
				case OrderPeriodicalNotificationType.SubmitAppraisalEscalation:
					startPeriodType = isRush ?
						OrderNotificationType.SubmitAppraisalEscalationInitialRush :
						OrderNotificationType.SubmitAppraisalEscalationInitialNoRush;
					periodType = isRush ?
						OrderNotificationType.SubmitAppraisalEscalationPeriodRush :
						OrderNotificationType.SubmitAppraisalEscalationPeriodNoRush;
					startPoint = order.DueDate;
					break;
				case OrderPeriodicalNotificationType.UpdateRequestEscalation:
					startPeriodType = isRush ?
						OrderNotificationType.UpdateRequestEscalationInitialRush :
						OrderNotificationType.UpdateRequestEscalationInitialNoRush;
					periodType = isRush ?
						OrderNotificationType.UpdateRequestEscalationPeriodRush :
						OrderNotificationType.UpdateRequestEscalationPeriodNoRush;
					startPoint = DateTime.Now;
					break;
				case OrderPeriodicalNotificationType.ConditionResponseEscalation:
					startPeriodType = isRush ?
							OrderNotificationType.ConditionResponseEscalationInitialRush :
							OrderNotificationType.ConditionResponseEscalationInitialNoRush;
					periodType = isRush ?
							OrderNotificationType.ConditionResponseEscalationPeriodRush :
							OrderNotificationType.ConditionResponseEscalationPeriodNoRush;
					startPoint = DateTime.Now;
					break;
				#endregion
				default: throw new ArgumentOutOfRangeException("Unknown OrderPeriodicalNotificationType type. OrderPeriodicalNotificationType: " + notificationType.ToString());
			}

			#endregion

			if (!startPoint.HasValue)
				throw new ArgumentNullException("Start point for Order Period Notification cannot be null. Notification type: " + notificationType.ToString());

			OrderNotificationTaskPeriods taskPeriods = new OrderNotificationTaskPeriods();

			taskPeriods.StartPoint = startPoint;
			taskPeriods.InitialNotificationType = startPeriodType;
			taskPeriods.PeriodNotificationType = periodType;

			return taskPeriods;
		}
		public DateTime? GetNextPeriodicalNotificationDate(Order order, OrderPeriodicalNotificationType notificationType)
		{
			var taskPeriod = GetTaskPeriodTypesAndStartPoint(order, notificationType);
			return CalculateNextRunTime(taskPeriod.PeriodNotificationType.Value, DateTime.Now);
		}
		public void SheduleOrderLinkedEntityPeriodicalNotifications(Order order, OrderPeriodicalNotificationType notificationType, Guid linkedEntityId)
		{
			SheduleOrderPeriodicalNotificationsInternal(order, notificationType, new Dictionary<TaskParamsKey, object>() { { TaskParamsKey.LinkedEntityId, linkedEntityId } });
		}
Пример #9
0
		public void SheduleOrderPeriodicalNotificationTask(int orderId, DateTime? startDate, OrderPeriodicalNotificationType notificationType, IDictionary<TaskParamsKey, object> additionalParams = null)
		{
			var parameters = new Dictionary<TaskParamsKey, string>();
			parameters.Add(TaskParamsKey.OrderId, orderId.ToString());
			parameters.Add(TaskParamsKey.OrderPeriodicalNotificationTaskType, notificationType.ToString());

			if (startDate.HasValue)
			{
				parameters.Add(TaskParamsKey.NextRunTime, startDate.Value.ToString());
			}
			if (additionalParams != null)
			{
				foreach (var param in additionalParams)
				{
					parameters.Add(param.Key, param.Value.ToString());
				}
			}

			_backgroundService.AddTask(TaskTypeEnum.OrderPeriodicalNotification, parameters);
		}
Пример #10
0
		public void SheduleOrderPeriodicalNotificationTask(int orderId, string emailTo, OrderPeriodicalNotificationType notificationType)
		{
			//TaskParamsKey.NextRunTime
			var parameters = GetParamsDictionary(
			NotificationType.DeclineWithInsufficientFeeReason
			);

			_backgroundService.AddTask(TaskTypeEnum.Notifications, parameters);
		}