/// <summary>
        /// Get the quota for a given month
        /// </summary>
        public ToaRequestResultCode getQuotaForMonth()
        {
            _log.Notice("Inside getQuotaForMonth");
            CapacityModel request = new CapacityModel();

            request.QuotaDates                   = getQuotaDates();
            request.CalculateDuration            = true;
            request.CalculateDurationSpecified   = true;
            request.CalculateTravelTime          = true;
            request.CalculateTravelTimeSpecified = true;
            request.CalculateWorkSkill           = true;
            request.CalculateWorkSkillSpecified  = true;
            request.ReturnTimeSlotInfo           = true;
            request.ReturnTimeSlotInfoSpecified  = true;
            request.Location = new string[] { Bucket };

            ActivityField zipField = new ActivityField();

            zipField.Name  = "czip";
            zipField.Value = PostalCode;

            ActivityField workType = new ActivityField();

            workType.Name  = "aworktype";
            workType.Value = WorkOrderType;

            List <ActivityField> activityFields = new List <ActivityField>();

            activityFields.Add(zipField);
            activityFields.Add(workType);

            request.ActivityField = activityFields.ToArray();

            ICapacityService service  = CapacityService.GetService();
            ToaRequestResult response = service.GetQuotaForMonth(request);

            if (response.ResultCode == ToaRequestResultCode.Failure)
            {
                return(response.ResultCode);
            }

            CapacityModel model = (CapacityModel)response.DataModels[0];

            monthlyQuota = null;
            monthlyQuota = model.DayQuota;

            List <string> timeSlots = new List <string>();

            timeSlots.Add("All Slots");
            timeSlots.AddRange(model.Timeslots);

            TimeSlotItems = new ObservableCollection <string>(timeSlots);

            CurrentTimeSlot = "All Slots";
            //CurrentDateSelected = DisplayDate;
            this.showQuotaForTimeSlots();
            //this.RequestRefresh();
            return(response.ResultCode);
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        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");
            }
        }
예제 #4
0
 /// <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);
     }
 }
예제 #5
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);
        }
예제 #6
0
 public void ShowResponseReportMessages(ToaRequestResult requestResult)
 {
     // Todo: Show report dialog with result
 }
예제 #7
0
        public void Handler()
        {
            InboundRequest   inboundRequest = null;
            ToaRequestResult inboundResult  = null;
            int?           aid            = null;
            WorkOrderModel workOrderModel = null;

            try
            {
                _log.Notice("Starting WorkOrderSave Handler.");
                object wotype          = EventHandlerServices.GetEventHandlerService().getFieldFromWorOrderRecord(_workOrderRecord, "WO_Type");
                object overrideRequest = EventHandlerServices.GetEventHandlerService().getFieldFromWorOrderRecord(_workOrderRecord, "Override_Request");
                object timeSlot        = EventHandlerServices.GetEventHandlerService().getFieldFromWorOrderRecord(_workOrderRecord, "WO_Time_Slot");
                object wodate          = EventHandlerServices.GetEventHandlerService().getFieldFromWorOrderRecord(_workOrderRecord, "WO_Date");
                object resolutionDue   = EventHandlerServices.GetEventHandlerService().getFieldFromWorOrderRecord(_workOrderRecord, "Resolution_Due");

                if (null == wotype)
                {
                    return;
                }

                if (overrideRequest != null)
                {
                    if (timeSlot == null || wodate == null)
                    {
                        return;
                    }
                }
                else
                {
                    if (timeSlot == null || wodate == null)
                    {
                        if (resolutionDue == null)
                        {
                            return;
                        }
                    }
                }

                _log.Notice("Converting from RecordContext to WorkOrder Model started");
                workOrderModel = EventHandlerServices.GetEventHandlerService().GetWorkOrderModel(_recordContext);
                _log.Notice("Convertion from RecordContext to WorkOrder Model completed");

                //Appointments 'key' fields are set in the constuctor of below object
                var activitySettings = new ActivitySettingsModel();
                //Inventory 'key' fields are set in the constuctor of below object
                var inventorySettings = new InventorySettingsModel();

                _log.Notice("Initialize InboundRequest");
                inboundRequest = new InboundRequest(new List <IToaModel>()
                {
                    workOrderModel
                });
                inboundRequest.PropertiesMode    = Client.Common.PropertiesMode.Replace;
                inboundRequest.AllowChangeDate   = Client.Common.AllowChangeDate.Yes;
                inboundRequest.ActivitySettings  = activitySettings;
                inboundRequest.InventorySettings = inventorySettings;
                _log.Notice("Invoking TOA Server using Inbound API Started");
                inboundResult = InboundService.GetService().BeginSyncRequest(inboundRequest);

                if (inboundResult != null)
                {
                    _log.Notice("Invoking TOA Server using Inbound API Completed");
                    ToaExceptionManager manager = new ToaExceptionManager();
                    _log.Notice("Processing Inbound API Response Result");
                    aid = manager.ProcessInboundResult(inboundResult);
                    _log.Notice("Completed Processing Inbound API Response Result");
                    if (aid == null)
                    {
                        _cancelEventArgs.Cancel = true;
                        return;
                    }
                }
                else
                {
                    foreach (IGenericField field in _workOrderRecord.GenericFields)
                    {
                        if (field.Name.Equals("WO_Status"))
                        {
                            TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
                            field.DataValue.Value = textInfo.ToTitleCase(ToaStringsUtil.GetString(Client.Common.ActivityStatus.NotCreated));
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex.StackTrace);
                MessageBox.Show(ToaExceptionMessages.UnexpectedError, ToaExceptionMessages.TitleError,
                                MessageBoxButton.OK, MessageBoxImage.Error);
            }

            try
            {
                _log.Notice("Updating WorkOrder Record.");
                workOrderModel.TOA_AID = (aid != null) ? aid : 0;
                UpdateWorkOrderRecord(inboundResult, workOrderModel);
                _log.Notice("WorkOrder Record Updated.");
                _log.Notice("Exiting WorkOrderSave Handler.");
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message, ex.StackTrace);
                MessageBox.Show(ToaExceptionMessages.UnexpectedError, ToaExceptionMessages.TitleError,
                                MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }