Exemplo n.º 1
0
        /// <summary>
        /// Begin request for Inbound service.
        /// </summary>
        /// <param name="inboundRequest"></param>
        /// <param name="inboundServiceCallback"></param>
        public ToaRequestResult BeginSyncRequest(InboundRequest inboundRequest)
        {
            _log.Debug("InboundService - BeginRequest() - Start");
            var inboundRequestElement = inboundRequest.GetInboundRequestElement();

            _log.Debug(ToaLogMessages.InboundServiceRequest, Json.Encode(inboundRequestElement));

            //Validate the current sitename.
            if (!ToaCommonUtil.ValidateCurrentSiteName())
            {
                return(null);
            }

            var inboundResult = _inboundInterfaceService.inbound_interface(inboundRequestElement);

            _log.Debug(ToaLogMessages.InboundServiceResponse, Json.Encode(inboundResult));

            //TODO: Initialize response
            var toaResponse = new ToaRequestResult();

            _log.Notice("Started processing response element");
            toaResponse.processResponseElement(inboundResult);
            _log.Debug("InboundService - BeginRequest() - End");
            return(toaResponse);
        }
Exemplo n.º 2
0
        /// <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()");
        }
Exemplo n.º 3
0
        /// <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()");
        }
Exemplo n.º 4
0
        /// <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");
        }
Exemplo n.º 5
0
        /// <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");
                }
            });
        }
Exemplo n.º 6
0
        /// <summary>
        /// Get Quota for month
        /// </summary>
        /// <param name="capacityModel"></param>
        /// <returns></returns>
        public ToaRequestResult GetQuotaForMonth(CapacityModel capacityModel)
        {
            _log.Notice("Inside GetQuotaForMonth");
            var toaRequestResult = new ToaRequestResult();

            try
            {
                capacity_element[]       capacityElement     = capacityModel.getCapacityElement();
                time_slot_info_element[] timeSlotInfoElement = capacityModel.getTimeSlotInfoElement();
                long activityTravelTime          = capacityModel.ActivityTravelTime;
                bool activityTravelTimeSpecified = capacityModel.ActivityTravelTimeSpecified;
                long activityDuration            = capacityModel.ActivityDuration;
                bool activityDurationSpecified   = capacityModel.ActivityDurationSpecified;

                _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 activityDuration, out activityDurationSpecified, out activityTravelTime, out activityTravelTimeSpecified, out capacityElement, out timeSlotInfoElement);

                CapacityModel response = new CapacityModel();

                if (activityDuration != null)
                {
                    response.ActivityDuration = activityDuration;
                }

                if (activityTravelTime != null)
                {
                    response.ActivityTravelTime = activityTravelTime;
                }

                Dictionary <DateTime, DayQuota> dayQuota = new Dictionary <DateTime, DayQuota>();
                if (capacityElement != null)
                {
                    foreach (capacity_element ce in capacityElement)
                    {
                        if (dayQuota.ContainsKey(ce.date))
                        {
                            DayQuota quota = dayQuota[ce.date];
                            if (quota.TimeSlotQuota == null)
                            {
                                quota.TimeSlotQuota = new Dictionary <string, float>();
                            }
                            float quotaAvailable = (((ce.available - (activityDuration + activityTravelTime)) * 100) / ce.quota);

                            quota.TimeSlotQuota.Add(ce.time_slot, quotaAvailable);
                        }
                        else
                        {
                            DayQuota quota = new DayQuota();
                            quota.QuotaDate     = ce.date;
                            quota.TimeSlotQuota = new Dictionary <string, float>();
                            float quotaAvailable = (((ce.available - (activityDuration + activityTravelTime)) * 100) / ce.quota);
                            quota.TimeSlotQuota.Add(ce.time_slot, quotaAvailable);
                            dayQuota.Add(ce.date, quota);
                        }
                    }
                }

                _log.Debug("Monthy Quota Response: ", Json.Encode(capacityElement));
                _log.Debug("TimeSlots: ", Json.Encode(timeSlotInfoElement));

                HashSet <string> timeSlotSet = new HashSet <string>();
                if (timeSlotInfoElement != null)
                {
                    foreach (time_slot_info_element ts in timeSlotInfoElement)
                    {
                        timeSlotSet.Add(ts.label);
                    }
                }

                if (timeSlotSet.Count > 0)
                {
                    response.Timeslots = new string[timeSlotSet.Count];
                    timeSlotSet.CopyTo(response.Timeslots);
                    Array.Sort(response.Timeslots);
                }

                DateTime currentDate = DateTime.Today;
                bool     todayExists = Array.IndexOf(capacityModel.QuotaDates, currentDate) >= 0;

                //Fix the closing quota issue
                if (todayExists)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        if (dayQuota.ContainsKey(currentDate))
                        {
                            DayQuota quota = dayQuota[currentDate];
                            foreach (string timeSlot in response.Timeslots)
                            {
                                if (!quota.TimeSlotQuota.ContainsKey(timeSlot))
                                {
                                    quota.TimeSlotQuota.Add(timeSlot, 0);
                                }
                            }
                        }
                        else
                        {
                            DayQuota quota = new DayQuota();
                            quota.QuotaDate     = currentDate;
                            quota.TimeSlotQuota = new Dictionary <string, float>();
                            foreach (string timeSlot in response.Timeslots)
                            {
                                quota.TimeSlotQuota.Add(timeSlot, 0);
                            }
                            dayQuota.Add(currentDate, quota);
                        }

                        currentDate = DateTime.Today.AddDays(1);
                        bool currentDateExists = Array.IndexOf(capacityModel.QuotaDates, currentDate) >= 0;
                        if (!currentDateExists)
                        {
                            break;
                        }
                    }
                }

                response.DayQuota = dayQuota;
                // initialize  toa result and activity model object

                toaRequestResult.DataModels.Add(response);
                if (dayQuota.Count == 0 || timeSlotSet.Count == 0)
                {
                    toaRequestResult.ResultCode = ToaRequestResultCode.Failure;
                }
                else
                {
                    toaRequestResult.ResultCode = ToaRequestResultCode.Success;
                }

                return(toaRequestResult);
            }
            catch (Exception exception)
            {
                _log.Error("Unable to fetch Quota for given dates");
                _log.Error(exception.StackTrace);
                MessageBox.Show("No quota available for the Work Order Type and Work Order Area selected.  Please reselect, if you continue to receive this warning, please contact support for assistance.",
                                "Warning: No Quota Available", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                toaRequestResult.ResultCode = ToaRequestResultCode.Failure;
            }
            return(toaRequestResult);
        }
Exemplo n.º 7
0
        /// <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");
        }
 private void UpdateWorkOrderRecord(ToaRequestResult inboundResult, WorkOrderModel workOrderModel)
 {
     IList<IGenericField> fields = _workOrderRecord.GenericFields;
     if (null != fields)
     {
         foreach (IGenericField field in fields)
         {
             switch (field.Name)
             {
                 case "External_ID":
                     if (null != workOrderModel.TOA_AID)
                         field.DataValue.Value = workOrderModel.TOA_AID;                            
                     break;
                 case "WO_Status":
                     
                     if (null != workOrderModel.TOA_AID && workOrderModel.TOA_AID != 0)
                     {
                         // Change work order status if activity is cancelled in TOA
                         if (workOrderModel.CancelReason != null && !workOrderModel.CancelReason.Trim().Equals(""))
                         {
                             workOrderModel.Status = Client.Common.ActivityStatus.Cancelled;                                                                        
                         }
                         else // Set Update Activity
                         {
                             workOrderModel.Status = Client.Common.ActivityStatus.Pending;  
                         }                                
                     }
                     else
                     {
                         workOrderModel.Status = Client.Common.ActivityStatus.NotCreated;  
                     }
                     field.DataValue.Value = ToaStringsUtil.GetString(workOrderModel.Status);
                     break;
                 case "Duration":
                     if (null != workOrderModel.Duration)
                     {
                         field.DataValue.Value = Int32.Parse(workOrderModel.Duration);
                     }
                     break;
                 default:
                     break;
             }
         }
         _recordContext.RefreshWorkspace();
         _log.Notice("WorkOrder saved");
     }
 }
 /// <summary>
 /// Process CapacityServiceResult
 /// </summary>
 /// <param name="capacityServiceResult"></param>
 public void ProcessCapacityServiceResult(ToaRequestResult capacityServiceResult)
 {
     if (capacityServiceResult.ResultCode != Common.ToaRequestResultCode.Success)
     {
         StringBuilder errorMessage = new StringBuilder();
         foreach (ReportMessageModel reportMessage in capacityServiceResult.ReportMessages)
         {
             errorMessage.Append(reportMessage.Result);
             _log.Error("Error Result: " + reportMessage.Result);
             _log.Error("Error Description: " + reportMessage.Description);
         }
         MessageBox.Show(errorMessage.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Begin request for Inbound service.
        /// </summary>
        /// <param name="inboundRequest"></param>
        /// <param name="inboundServiceCallback"></param>
        public ToaRequestResult BeginSyncRequest(InboundRequest inboundRequest)
        {
            _log.Debug("InboundService - BeginRequest() - Start");
            var inboundRequestElement = inboundRequest.GetInboundRequestElement();
            _log.Debug(ToaLogMessages.InboundServiceRequest,Json.Encode(inboundRequestElement));

            //Validate the current sitename.
            if (!ToaCommonUtil.ValidateCurrentSiteName())
            {
                return null;
            }

            var inboundResult = _inboundInterfaceService.inbound_interface(inboundRequestElement);
            _log.Debug(ToaLogMessages.InboundServiceResponse, Json.Encode(inboundResult));

            //TODO: Initialize response
            var toaResponse = new ToaRequestResult();
            _log.Notice("Started processing response element");
            toaResponse.processResponseElement(inboundResult);
            _log.Debug("InboundService - BeginRequest() - End");
            return toaResponse;
        }
Exemplo n.º 11
0
        public int? ProcessInboundResult(ToaRequestResult inboundResult)
        {
            int? aid = null;
            HashSet<string> errors = new HashSet<string>();
            bool ErrorDialogShown = false;
            
            {
                if (inboundResult.DataModels.Count > 0)
                {
                    WorkOrderModel workOrderModel = null;
                    List<IToaModel>.Enumerator e = inboundResult.DataModels.GetEnumerator();
                    while (e.MoveNext())
                    {
                        IToaModel model = e.Current;
                        if (model is WorkOrderModel)
                        {
                            workOrderModel = (WorkOrderModel)model;

                            foreach (ReportMessageModel reportMessage in workOrderModel.ReportMessages)
                            {
                                if (!reportMessage.Code.Equals(ActivityProperty.TOA_Report_Success_Code))
                                {
                                    errors.Add(reportMessage.Code);
                                    _log.Error(reportMessage.Code, reportMessage.Description);
                                }
                            }

                            List<InventoryModel> inventories = workOrderModel.ActivityInventories;
                            if (null != inventories && inventories.Count > 0)
                            {
                                foreach (InventoryModel inventory in inventories)
                                {
                                    List<ReportMessageModel> reportMessages = inventory.ReportMessages;
                                    foreach (ReportMessageModel reportMessage in reportMessages)
                                    {
                                        if (!reportMessage.Code.Equals(ActivityProperty.TOA_Report_Success_Code))
                                        {
                                            errors.Add(reportMessage.Code);
                                            _log.Error(reportMessage.Code, reportMessage.Description);
                                        }
                                    }
                                }
                            }

                            foreach (string errorcode in errors)
                            {
                                if (!ErrorDialogShown)
                                {
                                    ShowErrorOrWarningDialog(errorcode);
                                    ErrorDialogShown = true;
                                }

                                if (ErrorsNotToSave.Contains(errorcode))
                                {
                                    return null;
                                }
                            }

                            aid = workOrderModel.TOA_AID;
                        }
                    }
                }
            }
            return aid;
        }
Exemplo n.º 12
0
 public void ShowResponseReportMessages(ToaRequestResult requestResult)
 {
     // Todo: Show report dialog with result
 }
Exemplo n.º 13
0
        /// <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");
                }
            });
        }
Exemplo n.º 14
0
        /// <summary>
        /// Get Quota for month
        /// </summary>
        /// <param name="capacityModel"></param>
        /// <returns></returns>
        public ToaRequestResult GetQuotaForMonth(CapacityModel capacityModel)
        {
            _log.Notice("Inside GetQuotaForMonth");
            var toaRequestResult = new ToaRequestResult();
            try
            {
                capacity_element[] capacityElement = capacityModel.getCapacityElement();
                time_slot_info_element[] timeSlotInfoElement = capacityModel.getTimeSlotInfoElement();
                long activityTravelTime = capacityModel.ActivityTravelTime;
                bool activityTravelTimeSpecified = capacityModel.ActivityTravelTimeSpecified;
                long activityDuration = capacityModel.ActivityDuration;
                bool activityDurationSpecified = capacityModel.ActivityDurationSpecified;

                _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 activityDuration, out activityDurationSpecified, out activityTravelTime, out activityTravelTimeSpecified, out capacityElement, out timeSlotInfoElement);
            
                CapacityModel response = new CapacityModel();
                
                if (activityDuration != null)
                {
                    response.ActivityDuration = activityDuration;
                }

                if (activityTravelTime != null)
                {
                    response.ActivityTravelTime = activityTravelTime;
                }

                Dictionary<DateTime, DayQuota> dayQuota = new Dictionary<DateTime, DayQuota>();
                if (capacityElement != null)
                {
                    foreach (capacity_element ce in capacityElement)
                    {
                        if (dayQuota.ContainsKey(ce.date))
                        {
                            DayQuota quota = dayQuota[ce.date];
                            if (quota.TimeSlotQuota == null)
                            {
                                quota.TimeSlotQuota = new Dictionary<string, float>();
                            }
                            float quotaAvailable = (((ce.available - (activityDuration + activityTravelTime)) * 100) / ce.quota);

                            quota.TimeSlotQuota.Add(ce.time_slot, quotaAvailable);
                        }
                        else
                        {
                            DayQuota quota = new DayQuota();
                            quota.QuotaDate = ce.date;
                            quota.TimeSlotQuota = new Dictionary<string, float>();
                            float quotaAvailable = (((ce.available - (activityDuration + activityTravelTime)) * 100) / ce.quota);
                            quota.TimeSlotQuota.Add(ce.time_slot, quotaAvailable);
                            dayQuota.Add(ce.date, quota);
                        }
                    }
                }

                _log.Debug("Monthy Quota Response: ", Json.Encode(capacityElement));
                _log.Debug("TimeSlots: ", Json.Encode(timeSlotInfoElement));

                HashSet<string> timeSlotSet = new HashSet<string>();
                if (timeSlotInfoElement != null)
                {
                    foreach (time_slot_info_element ts in timeSlotInfoElement)
                    {
                        timeSlotSet.Add(ts.label);
                    }
                }

                if (timeSlotSet.Count > 0)
                {
                    response.Timeslots = new string[timeSlotSet.Count];
                    timeSlotSet.CopyTo(response.Timeslots);
                    Array.Sort(response.Timeslots);
                }

                DateTime currentDate = DateTime.Today;
                bool todayExists = Array.IndexOf(capacityModel.QuotaDates, currentDate) >= 0;

                //Fix the closing quota issue
                if (todayExists)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        if (dayQuota.ContainsKey(currentDate))
                        {
                            DayQuota quota = dayQuota[currentDate];
                            foreach (string timeSlot in response.Timeslots)
                            {
                                if (!quota.TimeSlotQuota.ContainsKey(timeSlot))
                                {
                                    quota.TimeSlotQuota.Add(timeSlot, 0);
                                }
                            }
                        }
                        else
                        {
                            DayQuota quota = new DayQuota();
                            quota.QuotaDate = currentDate;
                            quota.TimeSlotQuota = new Dictionary<string, float>();
                            foreach (string timeSlot in response.Timeslots)
                            {
                                quota.TimeSlotQuota.Add(timeSlot, 0);
                            }
                            dayQuota.Add(currentDate, quota);
                        }

                        currentDate = DateTime.Today.AddDays(1);
                        bool currentDateExists = Array.IndexOf(capacityModel.QuotaDates, currentDate) >= 0;
                        if (!currentDateExists)
                        {
                            break;
                        }
                    }
                }    
                    
                response.DayQuota = dayQuota;
                // initialize  toa result and activity model object
                
                toaRequestResult.DataModels.Add(response);
                if (dayQuota.Count == 0 || timeSlotSet.Count == 0)
                {
                    toaRequestResult.ResultCode = ToaRequestResultCode.Failure;
                }
                else
                {
                    toaRequestResult.ResultCode = ToaRequestResultCode.Success;
                }

                return toaRequestResult;
            }
            catch (Exception exception)
            {
                _log.Error("Unable to fetch Quota for given dates");
                _log.Error(exception.StackTrace);
                MessageBox.Show("No quota available for the Work Order Type and Work Order Area selected.  Please reselect, if you continue to receive this warning, please contact support for assistance.",
                    "Warning: No Quota Available", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                toaRequestResult.ResultCode = ToaRequestResultCode.Failure;
            }
            return toaRequestResult;
        }
 /// <summary>
 /// Callback method that will be invoked after the work order area request is successful.
 /// </summary>
 /// <param name="result">TOARequestResult object</param>
 public void WorkOrderAreaCallback(ToaRequestResult result)
 {
     _log.Notice("Inside Callback Method WorkOrderAreaCallback");
     CapacityModel model = (CapacityModel)result.DataModels[0];
     WorkOrderAreaItems = new ObservableCollection<string>(model.Location);
     ToaExceptionManager manager = new ToaExceptionManager();
     manager.ProcessCapacityServiceResult(result);
 }