public TriggerOperationNode(string content) { ParentNode = null; Operation = null; Content = content; Operation = new TriggerOperation(); TriggerOperation.Name = content; }
private bool CreateBrokerOrder(CreateOrChangeOrder order) { #if VERIFYSIDE if (!VerifySide(order)) { return(false); } #endif lock (orderMapLocker) { try { orderMap.Add(order.BrokerOrder, order); if (trace) { log.Trace("Added order " + order.BrokerOrder); } } catch (ArgumentException) { throw new ApplicationException("A broker order id of " + order.BrokerOrder + " was already added."); } } TriggerOperation operation = default(TriggerOperation); switch (order.Type) { case OrderType.BuyMarket: case OrderType.SellMarket: break; case OrderType.BuyStop: case OrderType.SellLimit: operation = TriggerOperation.GreaterOrEqual; break; case OrderType.BuyLimit: case OrderType.SellStop: operation = TriggerOperation.LessOrEqual; break; case OrderType.StopLoss: default: throw new ArgumentOutOfRangeException(); } if (triggers != null) { var triggerId = triggers.AddTrigger(order.LogicalSerialNumber, TriggerData.Price, operation, order.Price, TriggerCallback); serialTriggerMap[order.LogicalSerialNumber] = triggerId; } SortAdjust(order); IsChanged = true; OrderChanged(); return(true); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { var hash = 41; // Suitable nullity checks etc, of course :) if (Id != null) { hash = hash * 57 + Id.GetHashCode(); } if (Body != null) { hash = hash * 57 + Body.GetHashCode(); } if (TriggerOperation != null) { hash = hash * 57 + TriggerOperation.GetHashCode(); } if (TriggerType != null) { hash = hash * 57 + TriggerType.GetHashCode(); } if (Rid != null) { hash = hash * 57 + Rid.GetHashCode(); } if (Ts != null) { hash = hash * 57 + Ts.GetHashCode(); } if (Self != null) { hash = hash * 57 + Self.GetHashCode(); } if (Etag != null) { hash = hash * 57 + Etag.GetHashCode(); } return(hash); } }
/// <summary> /// Returns true if Trigger instances are equal /// </summary> /// <param name="other">Instance of Trigger to be compared</param> /// <returns>Boolean</returns> public bool Equals(Trigger other) { // credit: http://stackoverflow.com/a/10454552/677735 if (other == null) { return(false); } return (( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( Body == other.Body || Body != null && Body.Equals(other.Body) ) && ( TriggerOperation == other.TriggerOperation || TriggerOperation != null && TriggerOperation.Equals(other.TriggerOperation) ) && ( TriggerType == other.TriggerType || TriggerType != null && TriggerType.Equals(other.TriggerType) ) && ( Rid == other.Rid || Rid != null && Rid.Equals(other.Rid) ) && ( Ts == other.Ts || Ts != null && Ts.Equals(other.Ts) ) && ( Self == other.Self || Self != null && Self.Equals(other.Self) ) && ( Etag == other.Etag || Etag != null && Etag.Equals(other.Etag) )); }
public DataSyncMenuProvider(IocManager _iocManager, IFormIOSchemeManager _formIOSchemeManager, IDataSyncSettingsManager _dataSyncSettingManager, DataSyncOperator _dataSyncOperator, DataCapture _dataCapture, TriggerOperation _triggerOperation ) { iocManager = _iocManager; formIOSchemeManager = _formIOSchemeManager; dataSyncSettingManager = _dataSyncSettingManager; dataSyncOperator = _dataSyncOperator; dataCapture = _dataCapture; triggerOperation = _triggerOperation; Logger = NullLogger.Instance; }
private static async Task CreateTrigger( string triggerId, string triggerBody, TriggerType triggerType, TriggerOperation triggerOperation) { var triggerProps = new TriggerProperties { Id = triggerId, Body = triggerBody, TriggerType = triggerType, TriggerOperation = triggerOperation }; var container = Shared.Client.GetContainer("mydb", "mystore"); var result = await container.Scripts.CreateTriggerAsync(triggerProps); Console.WriteLine($"Created trigger {triggerId}; ({result.RequestCharge} RUs)"); }
private async static Task <Trigger> CreateTrigger( DocumentClient client, string triggerId, string triggerBody, TriggerType triggerType, TriggerOperation triggerOperation) { var triggerDefinition = new Trigger { Id = triggerId, Body = triggerBody, TriggerType = triggerType, TriggerOperation = triggerOperation }; var result = await client.CreateTriggerAsync(MyStoreCollectionUri, triggerDefinition); var trigger = result.Resource; Console.WriteLine($" Created trigger {trigger.Id}; RID: {trigger.ResourceId}"); return(trigger); }
public SqlContainerImpl WithTrigger(string name, string body, TriggerType type, TriggerOperation operation, CreateUpdateOptions options) { return(this.WithTrigger(name, new SqlTriggerResource(id: name, body: body, triggerType: type, triggerOperation: operation), options)); }
public async Task <Trigger> SaveTriggerAsync(Connection connection, DocumentCollection collection, string id, string trigger, TriggerType triggerType, TriggerOperation triggerOperation, string altLink) { var item = new Trigger { Id = id, Body = trigger, TriggerType = triggerType, TriggerOperation = triggerOperation }; var client = GetClient(connection); if (!string.IsNullOrEmpty(altLink)) { var oldId = altLink.Split('/').Last(); if (item.Id != oldId) { var itemList = await GetTriggersAsync(connection, collection).ConfigureAwait(false); if (itemList.Any(t => t.Id == item.Id)) { throw new Exception("An item with the same id already exists!"); } } await client.DeleteTriggerAsync(altLink).ConfigureAwait(false); } var response = await client.CreateTriggerAsync(collection.SelfLink, item).ConfigureAwait(false); return(response.Resource); }
SqlContainer.Update.IUpdate SqlContainer.Update.IWithChildResource.WithTrigger(string name, string body, TriggerType type, TriggerOperation operation, CreateUpdateOptions options) { return(this.WithTrigger(name, body, type, operation, options)); }
private static async Task UpsertTriggerAsync(Container container, string scriptFileName, TriggerOperation triggerOperation, TriggerType triggerType) { string scriptId = Path.GetFileNameWithoutExtension(scriptFileName); if (await TriggerExists(container, scriptId)) { await container.Scripts.ReplaceTriggerAsync(new TriggerProperties { Id = scriptId, Body = File.ReadAllText(scriptFileName), TriggerOperation = triggerOperation, TriggerType = triggerType }); } else { await container.Scripts.CreateTriggerAsync(new TriggerProperties { Id = scriptId, Body = File.ReadAllText(scriptFileName), TriggerOperation = triggerOperation, TriggerType = triggerType }); } }
public DoDBTriggerMenuAction(IocManager _iocManager, TriggerOperation _triggerOperation) { iocManager = _iocManager; triggerOperation = _triggerOperation; Logger = NullLogger.Instance; }
public TriggerOperationNode(TriggerOperation triggerOperation) { Operation = triggerOperation; ParentNode = null; }
SqlContainer.Definition.IWithAttach <UpdateParentT> SqlContainer.Definition.IWithChildResource <UpdateParentT> .WithTrigger(string name, string body, TriggerType type, TriggerOperation operation, CreateUpdateOptions options) { return(this.WithTrigger(name, body, type, operation, options)); }
//create the triggers if desnot exists... private async static Task CreateTriggerIfNotExists(DocumentClient client, string triggerId, string triggerBody, TriggerType triggerType, TriggerOperation triggerOperation) { Uri collectionLink = UriFactory.CreateDocumentCollectionUri(DbName, CollectionName); var triggerDefinition = new Trigger { Id = triggerId, Body = triggerBody, TriggerType = triggerType, TriggerOperation = triggerOperation }; bool needToCreate = false; Uri triggerUri = UriFactory.CreateTriggerUri(DbName, CollectionName, triggerId); try { await client.ReadTriggerAsync(triggerUri); } catch (DocumentClientException dce) { if (dce.StatusCode != HttpStatusCode.NotFound) { throw; } else { needToCreate = true; } } if (needToCreate) { await client.CreateTriggerAsync(collectionLink, triggerDefinition); } }
public static void DoDBTriggerOperationCilck(IocManager iocManager, DataSyncDirection dataSyncDirection, TriggerOperation triggerOperation, ILogger logger) { try { DataSyncConfig config = GetDataSyncConfig(); if (config != null) { string result = triggerOperation.DoDBTriggerOperation(config, dataSyncDirection); TextShowDialog textShowDialog = new TextShowDialog(); textShowDialog.SetText(result); textShowDialog.ShowDialog(); } else { logger.Warn("未找到数据同步的配置。/DataOperation/DataCaptureConfig.json"); } } catch (Exception ex) { EventBus.Default.Trigger(new NonUIExceptionEventData { UnhandledExceptionEventArgs = new UnhandledExceptionEventArgs(ex, false) }); } }
private async Task TryUpdateTrigger(string name, string content, TriggerType triggerType, TriggerOperation triggerOperation) { // Partitioned Collections do not support upserts, so check if they exist, and delete/re-insert them if they've changed. var insertTrigger = false; try { var triggerUri = UriFactory.CreateTriggerUri(_options.DatabaseName, _options.CollectionName, name); var triggerResponse = await _dbClient.ReadTriggerAsync(triggerUri); var trigger = triggerResponse.Resource; if (trigger == null || !Equals(trigger.Body, content)) { insertTrigger = true; await _dbClient.DeleteTriggerAsync(triggerUri); } } catch (DocumentClientException dce) { if (dce.StatusCode == HttpStatusCode.NotFound) { insertTrigger = true; } else { throw; } } catch (Exception exc) { _logger.LogError(exc, $"Failure Updating Trigger {name}"); throw; } if (insertTrigger) { var trigger = new Trigger() { Id = name, Body = content, TriggerType = triggerType, TriggerOperation = triggerOperation }; await _dbClient.CreateTriggerAsync(UriFactory.CreateDocumentCollectionUri(_options.DatabaseName, _options.CollectionName), trigger); } }