/// <summary> /// Get activity /// </summary> /// <param name="activityId"></param> /// <returns></returns> public void GetActivity(string activityId, ActivityServiceDelegate activityCallback) { _log.Debug("Enter - GetActivity()"); if (activityId == null || activityId.Trim().Equals("") || activityCallback == null) return; var backgroundService = new ToaBackgroundServiceUtil(); /*backgroundService.RunAsync(() => { */ try { var activityModel = new WorkOrderModel(); var getActivityParam = new get_activity_parameters(); getActivityParam.activity_id = activityId; getActivityParam.user = ToaUserUtil.GetActivityUser(); activity_response response = _activityClient.get_activity(getActivityParam); // initialize toa result and activity model object var toaRequestResult = new ToaRequestResult(); toaRequestResult.DataModels.Add(activityModel); activityCallback.Invoke(toaRequestResult); } catch(Exception exception) { // Todo: logg exception } /*});*/ _log.Debug("Exit - GetActivity()"); }
/// <summary> /// Begin request for Inbound service. /// </summary> /// <param name="inboundRequest"></param> /// <param name="inboundServiceCallback"></param> public void BeginRequest(InboundRequest inboundRequest, InboundServiceDelegate inboundServiceCallback) { _log.Debug("InboundService - BeginRequest() - Start"); var backgroundService = new ToaBackgroundServiceUtil(); backgroundService.RunAsync(() => { _log.Debug("InboundService - BeginRequest() - Thread Started"); var inboundRequestElement = inboundRequest.GetInboundRequestElement(); var inboundResult = _inboundInterfaceService.inbound_interface(inboundRequestElement); //TODO: Initialize response var toaResponse = new ToaRequestResult(); inboundServiceCallback.Invoke(toaResponse); _log.Debug("InboundService - BeginRequest() - Thread Ended"); }); _log.Debug("InboundService - BeginRequest() - End"); }
/// <summary> /// Get Work Order Area mapped to zipcode /// </summary> /// <param name="capacityModel">Capacity Model object</param> /// <param name="capacityCallback">Callback method</param> public void GetWorkOrderArea(CapacityModel capacityModel, CapacityServiceDelegate capacityCallback) { _log.Notice("Inside GetWorkOrderArea"); var backgroundService = new ToaBackgroundServiceUtil(); backgroundService.RunAsync(() => { try { capacity_element[] capacityElement = capacityModel.getCapacityElement(); time_slot_info_element[] timeSlotInfoElement = capacityModel.getTimeSlotInfoElement(); long activityTravelTime = capacityModel.ActivityTravelTime; bool activityTravelTimeSpecified = capacityModel.AggregateResultsSpecified; _toaCapacityInterface.get_capacity(ToaUserUtil.GetCapacityUser(), capacityModel.QuotaDates, capacityModel.Location, capacityModel.CalculateDuration, capacityModel.CalculateDurationSpecified, capacityModel.CalculateTravelTime, capacityModel.CalculateTravelTimeSpecified, capacityModel.CalculateWorkSkill, capacityModel.CalculateWorkSkillSpecified, capacityModel.ReturnTimeSlotInfo, capacityModel.ReturnTimeSlotInfoSpecified, capacityModel.DetermineLocationByWorkZone, capacityModel.DetermineLocationByWorkZoneSpecified, capacityModel.DontAggregateResults, capacityModel.DontAggregateResultsSpecified, capacityModel.MinTimeEndOfTimeSlot, capacityModel.MinTimeEndOfTimeSlotSpecified, capacityModel.DefaultDuration, capacityModel.DefaultDurationSpecified, capacityModel.Timeslots, capacityModel.WorkSkill, capacityModel.getActivityFieldElement(), out activityTravelTime, out activityTravelTimeSpecified, out activityTravelTime, out activityTravelTimeSpecified, out capacityElement, out timeSlotInfoElement); CapacityModel response = new CapacityModel(); HashSet<string> locations = new HashSet<string>(); if (capacityElement != null) { foreach (capacity_element ce in capacityElement) { if (!locations.Contains(ce.location)) { locations.Add(ce.location); } } } response.Location = new string[locations.Count]; locations.CopyTo(response.Location); // initialize toa result and activity model object var toaRequestResult = new ToaRequestResult(); toaRequestResult.DataModels.Add(response); toaRequestResult.ResultCode = ToaRequestResultCode.Success; if (locations.Count == 0) { List<ReportMessageModel> reportMessageModel = new List<ReportMessageModel>(); _log.Error("Unable to determine work zone for given fields"); reportMessageModel.Add(new ReportMessageModel("No Work Order Areas exist for this Postal Code, please update the Postal Code field or submit with no timeslot and data selected", null, null, "Unable to determine work zone for given fields")); toaRequestResult.ReportMessages = reportMessageModel; toaRequestResult.ResultCode = ToaRequestResultCode.Failure; } capacityCallback.Invoke(toaRequestResult); } catch (Exception exception) { _log.Error("Unable to fetch Work Order Area"); _log.Error(exception.StackTrace); MessageBox.Show("No Work Order Areas exist for this Postal Code, please update the Postal Code field or submit with no timeslot and data selected"); } }); }