/// <summary> /// /// </summary> /// <param name="warehouseOrder"></param> public void InsertOrder(WarehouseOrder warehouseOrder) { try { WarehouseLogger.LogMessage(Resources.MessagingInsertOrder, warehouseOrder.Identifier, warehouseOrder.Title, warehouseOrder.Timestamp); WarehouseServer.InsertOrder(warehouseOrder); } catch (Exception ex) { WarehouseLogger.LogException(ex); } }
/// <summary> /// /// </summary> /// <param name="orderIdentifier"></param> public void DeleteOrder(Guid orderIdentifier) { try { WarehouseLogger.LogMessage(Resources.MessagingCancelOrder, orderIdentifier); WarehouseServer.DeleteOrder(orderIdentifier); } catch (Exception ex) { WarehouseLogger.LogException(ex); } }
/// <summary> /// /// </summary> /// <param name="orderIdentifier"></param> /// <returns></returns> public bool DispatchOrder(Guid orderIdentifier) { try { WarehouseLogger.LogMessage(Resources.RemotingDispatchOrder, orderIdentifier); if (_bookstore.DispatchOrder(orderIdentifier) != Response.Success) { return(false); } WarehouseServer.DeleteOrder(orderIdentifier); return(true); } catch (Exception ex) { WarehouseLogger.LogException(ex); } return(false); }
/// <summary> /// /// </summary> public WarehouseRemoting() { WarehouseLogger.LogMessage(Resources.RemotingEstablish, nameof(IBookstoreRemoting), WarehouseCommon.BookstoreAddress); _bookstore = (IBookstoreRemoting)RemotingServices.Connect(typeof(IBookstoreRemoting), WarehouseCommon.BookstoreAddress); }
/// <summary> /// /// </summary> private static void Main() { try { Console.CursorVisible = false; Console.Title = Resources.WindowTitle; Console.BackgroundColor = ConsoleColor.DarkCyan; Console.ForegroundColor = ConsoleColor.Cyan; Console.Clear(); Console.WriteLine(Resources.Header); if (File.Exists(WarehouseCommon.TransactionsFilename)) { WarehouseLogger.LogMessage(Resources.SerializationRead, WarehouseCommon.TransactionsFilename); using (var reader = new FileStream(WarehouseCommon.TransactionsFilename, FileMode.Open)) { _orders = (WarehouseOrders)Serializer.Deserialize(reader) ?? new WarehouseOrders(); } WarehouseLogger.LogMessage(Resources.SerializationDone, _orders.Orders.Count, nameof(WarehouseOrders)); } else { _orders = new WarehouseOrders(); _orders.Serialize(Serializer, WarehouseCommon.TransactionsFilename); WarehouseLogger.LogMessage(Resources.SerializationWrite, WarehouseCommon.TransactionsFilename); } ChannelServices.RegisterChannel(new TcpChannel(new Hashtable { { "port", WarehouseCommon.WarehousePort } }, new BinaryClientFormatterSinkProvider(), new BinaryServerFormatterSinkProvider { TypeFilterLevel = TypeFilterLevel.Full }), false); WarehouseLogger.LogMessage(Resources.RemotingRegisterService, nameof(IBookstoreRemoting)); RemotingConfiguration.RegisterActivatedServiceType(typeof(IBookstoreRemoting)); WarehouseLogger.LogMessage(Resources.RemotingRegisterService, nameof(IWarehouseRemoting)); RemotingConfiguration.RegisterActivatedServiceType(typeof(WarehouseServer)); WarehouseLogger.LogMessage(Resources.RemotingMarshalService, nameof(WarehouseRemoting)); _warehouseRemoting = new WarehouseRemoting(); RemotingServices.Marshal(_warehouseRemoting, WarehouseCommon.WarehouseEndpoint); WarehouseLogger.LogMessage(Resources.RemotingInitialized, WarehouseCommon.WarehouseAddress); WarehouseLogger.LogMessage(Resources.MessagingInitialize, MessagingCommon.InitializeWarehouseQueue().QueueName); _serviceHost = new ServiceHost(typeof(WarehouseService)); _serviceHost.Open(); WarehouseLogger.LogMessage(Resources.MessagingRunning); Console.ReadKey(true); _serviceHost.Close(); } catch (Exception ex) { WarehouseLogger.LogException(ex); Console.BackgroundColor = ConsoleColor.DarkRed; Console.ForegroundColor = ConsoleColor.Red; WarehouseLogger.LogMessage(Resources.ExceptionCaught); } }
/// <summary> /// /// </summary> private static void SerializeTransactions() { WarehouseLogger.LogMessage(Resources.SerializationWrite, WarehouseCommon.TransactionsFilename); _orders.Serialize(Serializer, WarehouseCommon.TransactionsFilename); }