Exemple #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);
        }
Exemple #2
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");
        }
        /// <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");
        }
        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);

            }
            
        }
        /// <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;
        }