protected override void OnStart(string[] args) { try { ////Resolve IMessageStorage from IocManager //Schemas.IMessageStorage messageQueueStorage = IoCManager.Instance.Resolve<Schemas.IMessageStorage>(); //if (messageQueueStorage == null) // throw new NullReferenceException("Couldn't assign IMessageStorage"); ////Resolve Configuration DB Repository //IConnectedConfDBRepository connectedConfDBRepository = // IoCManager.Instance.Resolve<IConnectedConfDBRepository>(); _service = IoCManager.Instance.ResolveIfRegistered <InboundService>(); //_service = new InboundService(messageQueueStorage, connectedConfDBRepository); _serviceHost = new ServiceHost(_service); _serviceHost.Open(); _loger.WriteLog( "Connected Inbound Service Started. ", global::Common.Enums.LogType.Info, "Connected Inbound Service"); } catch (Exception exception) { _loger.WriteLog( "Connected Inbound Service couldn't started. Error message : " + exception.Message + (!string.IsNullOrEmpty(exception.InnerException.Message) ? ", Inner exception : " + exception.InnerException.Message : ""), global::Common.Enums.LogType.Error, "Connected Inbound Service"); throw exception; } }
protected override void DoSetUp() { MsmqUtil.Delete(DestinationQueueName); Console.WriteLine("Creating new service"); service = new InboundService(ListenUri, DestinationQueueName); service.Start(); }
static void Main(string[] args) { //TODO : NInject this two repositories //Select message queueu entities Schemas.IMessageStorage messageQueueStorage = new Connected.MessageStorage.MessageQueueStorage(); //Select configuration repository Connected.DAL.Configuration.Repositories.IConnectedConfDBRepository connectedConfDBRepository = new Connected.DAL.Configuration.Repositories.EF.ConnectedConfDBRepository(); //TODO : NInject this Connected.Common.LogManagement.ILoger loger = new Connected.Common.LogManagement.EventLoger(); //Host Inbound service InboundService service = new InboundService(messageQueueStorage, connectedConfDBRepository); try { ServiceHost serviceHost = new ServiceHost(service); serviceHost.Open(); Console.WriteLine("---------------------------------------------------------"); Console.WriteLine("Connected Inbound Service Started. To Stop, Press any key....."); Console.WriteLine("---------------------------------------------------------"); Console.WriteLine("Service Url :http://localhost:85/ConnectedRouterService"); loger.WriteLog( "Connected Inbound Service Started. Service Url :http://localhost:85/ConnectedRouterService", global::Common.Enums.LogType.Info, "Connected Inbound Service"); } catch (Exception exception) { Console.WriteLine("Error in Hosting Connected Inbound Service"); Console.WriteLine("Press any key to Quit!............."); Console.WriteLine(exception.Message); Console.WriteLine(exception.StackTrace); loger.WriteLog( "Connected Inbound Service couldn't started. Error message : " + exception.Message + (!string.IsNullOrEmpty(exception.InnerException.Message) ? ", Inner exception : " + exception.InnerException.Message : ""), global::Common.Enums.LogType.Error, "Connected Inbound Service"); } Console.ReadLine(); }
void InitHttpListener() { log.Info("Starting inbound service..."); inboundService = new InboundService(ListenUri, DestinationQueue); inboundService.Start(); }
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); } }
protected override void DoSetUp() { Console.WriteLine("Creating new service"); service = new InboundService(ListenUri, DestinationQueueName); service.Start(); }