private void InitializeThread(object state) { // Extract the initialization parameters. Guid blotterId = (Guid)state; List <DestinationItem> destinationItems = new List <DestinationItem>(); // Initialize the Destination list box try { Monitor.Enter(DataModel.SyncRoot); DataModel.Destination.DestinationRowChanged += new DestinationRowChangeEventHandler(Destination_DestinationRowChanged); BlotterRow blotterRow = DataModel.Blotter.BlotterKey.Find(blotterId); foreach (BlotterDestinationMapRow blotterDestinationRowMap in blotterRow.GetBlotterDestinationMapRows()) { DestinationRow destinationRow = blotterDestinationRowMap.DestinationRow; destinationItems.Add(new DestinationItem(destinationRow.DestinationId, destinationRow.Name, destinationRow.ShortName)); } } finally { Monitor.Exit(DataModel.SyncRoot); } Invoke(new DestinationListDelegate(InitializeListBox), destinationItems); }
public void Serialize(BinaryWriter output) { output.Write(StepId); DestinationTable.Serialize(output); DestinationRow.Serialize(output); SerializationHelper.Serialize(output.BaseStream, ForeignKey); }
private static object CreateExtraDataConnections(SQLite_Connector conn, object input) { try { Object[] data = input as Object[]; int alimId = (int)data[0]; ExtraData extra = (ExtraData)data[1]; Boolean flag = extra.Create(conn, null); if (flag) { extra.Id = (int)conn.SelectValue <long>("extras".SelectLastId(extra.PrimaryKey)); DestinationRow row = new DestinationRow() { AlimId = alimId, ConnId = extra.Id, TypeId = 2, }; return(row.Create(conn, null)); } return(false); } catch (Exception exc) { return(exc); } }
/// <summary> /// Creates the motors connections. /// </summary> /// <param name="conn">The connection.</param> /// <param name="input">The input.</param> /// <returns></returns> /// <exception cref="NotImplementedException"></exception> private static object CreateMotorsConnections(SQLite_Connector conn, object input) { try { Object[] data = input as Object[]; int alimId = (int)data[0]; IEnumerable <BigMotor> motors = (IEnumerable <BigMotor>)data[1]; Boolean flag; DestinationRow row; motors.ToList().ForEach(x => { flag = x.Create(conn, null); if (flag) { x.Id = (int)conn.SelectValue <long>("motores".SelectLastId(x.PrimaryKey)); row = new DestinationRow() { AlimId = alimId, ConnId = x.Id, TypeId = 0, }; row.Create(conn, null); } }); return(motors.Count(x => x.Id > 0) > 0); } catch (Exception exc) { return(exc); } }
public void Serialize(BinaryWriter output) { var bf = SerializationHelper.DefaultFormatter; output.Write(StepId); DestinationTable.Serialize(output); DestinationRow.Serialize(output); bf.Serialize(output.BaseStream, ForeignKey); }
/// <summary> /// Crea la inserción del alimentador /// </summary> /// <param name="conn">La conexión a SQLite.</param> /// <param name="input">La entrada para realizar la inserción.</param> /// <returns>Una bandera que indica si se realizó la conexión</returns> private static object CreateAlimentadorConnection(SQLite_Connector conn, object input) { try { Object[] data = input as Object[]; DestinationRow row = new DestinationRow() { AlimId = (int)data[0], ConnId = (int)data[1], TypeId = (int)data[2], }; return(row.Create(conn, null)); } catch (Exception exc) { return(exc); } }
static Match() { try { // Lock the data model while the object initializes itself. DataModel.DataLock.EnterReadLock(); // The destination for all orders matched through this system is fixed by a setting in the configuration file. DestinationRow destinationRow = DataModel.Destination.DestinationKeyExternalId0.Find(Guardian.Properties.Settings.Default.GuardianECN); if (destinationRow == null) { throw new Exception("There is no Destination specified in the configuration file for matched trades."); } Match.destinationId = destinationRow.DestinationId; } finally { // Release the tables. DataModel.DataLock.ExitReadLock(); } }
private void ExecuteSlice(object state) { List <WorkingOrderRow> workingOrders = state as List <WorkingOrderRow>; try { List <TradingSupportReference.DestinationOrderInfo> destinationOrders = new List <TradingSupportReference.DestinationOrderInfo>(); lock (DataModel.SyncRoot) { DestinationRow destinationRow = DataModel.Destination.DestinationKeyExternalId0.Find("GUARDIAN ECN"); foreach (WorkingOrderRow workingOrderRow in workingOrders) { decimal sourceOrderQuantity = 0.0M; foreach (SourceOrderRow sourceOrderRow in workingOrderRow.GetSourceOrderRows()) { sourceOrderQuantity += sourceOrderRow.OrderedQuantity; } Decimal destinationOrderQuantity = 0.0M; foreach (DestinationOrderRow destinationOrderRow in workingOrderRow.GetDestinationOrderRows()) { destinationOrderQuantity += destinationOrderRow.OrderedQuantity; } if (sourceOrderQuantity > destinationOrderQuantity) { TradingSupportReference.DestinationOrderInfo destinationOrderInfo = new TradingSupportReference.DestinationOrderInfo(); destinationOrderInfo.BlotterId = workingOrderRow.BlotterId; destinationOrderInfo.DestinationId = destinationRow.DestinationId; destinationOrderInfo.OrderedQuantity = sourceOrderQuantity - destinationOrderQuantity; destinationOrderInfo.OrderTypeId = workingOrderRow.OrderTypeId; destinationOrderInfo.SecurityId = workingOrderRow.SecurityId; destinationOrderInfo.SettlementId = workingOrderRow.SettlementId; destinationOrderInfo.SideCodeId = workingOrderRow.SideId; destinationOrderInfo.TimeInForceCodeId = workingOrderRow.TimeInForceId; destinationOrderInfo.WorkingOrderId = workingOrderRow.WorkingOrderId; destinationOrders.Add(destinationOrderInfo); } } } // Create a channel to the middle tier. TradingSupportReference.TradingSupportClient tradingSupportClient = new TradingSupportReference.TradingSupportClient(Guardian.Properties.Settings.Default.TradingSupportEndpoint); tradingSupportClient.CreateDestinationOrders(destinationOrders.ToArray()); // At this point the client can be shut down gracefully. tradingSupportClient.Close(); } catch (FaultException <OptimisticConcurrencyFault> optimisticConcurrencyException) { // The record is busy. this.Dispatcher.Invoke(DispatcherPriority.Normal, (MessageDelegate)((string message) => { MessageBox.Show(message, Application.Current.MainWindow.Title); }), String.Format(FluidTrade.Core.Properties.Resources.OptimisticConcurrencyError, optimisticConcurrencyException.Detail.TableName)); } catch (FaultException <RecordNotFoundFault> recordNotFoundException) { // The record is busy. this.Dispatcher.Invoke(DispatcherPriority.Normal, (MessageDelegate)((string message) => { MessageBox.Show(message, Application.Current.MainWindow.Title); }), String.Format(FluidTrade.Core.Properties.Resources.RecordNotFoundError, CommonConversion.FromArray(recordNotFoundException.Detail.Key), recordNotFoundException.Detail.TableName)); } catch (CommunicationException communicationException) { // Log communication problems. this.Dispatcher.Invoke(DispatcherPriority.Normal, (MessageDelegate)((string message) => { MessageBox.Show(message, Application.Current.MainWindow.Title); }), communicationException.Message); } catch (Exception exception) { // Log communication problems. EventLog.Error("{0}, {1}", exception.Message, exception.StackTrace); } }