public void Setup() { _mockery = new MockRepository(); // _dataAccessMock = _mockery.CreateMock<DataAccess>(); _batchMock = _mockery.CreateMock<Batch>(); _userMock = _mockery.CreateMock<User>(11951, "IPDuncan"); }
private MappedBatch(IBatch batch, IDictionary<string, object> data) { Id = batch.Id; TimeStamp = batch.TimeStamp; Type = batch.Type; this.data = data; }
public void SetupResult() { _mockery = new MockRepository(); _dataAccessMock = _mockery.CreateMock<DataAccess>(); _batch = new Batch(_dataAccessMock); _batchHeaderDTO = _mockery.CreateMock<BatchHeaderDTO>(); }
public static Model.Batch BatchMapper(IBatch batch, CodeAnalyzerContainer context) { Model.Batch modelBatch = context.Batch.SingleOrDefault(b => b.Id == batch.Id); if (modelBatch == null) return new Model.Batch {TimeStamp = batch.TimeStamp}; return modelBatch; }
public static Guid Persist(AddProductToOrder c, IBatch batch, Guid id) { batch.HashSetAsync(id.ToString(), new [] { new HashEntry("OrderId", c.OrderId), new HashEntry("ProductId", c.ProductId), }); return id; }
/// <summary> /// Gets the command. /// </summary> /// <param name="batch">The batch.</param> public void GetCommand(IBatch batch) { if (batch == null) throw new ArgumentNullException(nameof(batch)); batch.AddCommand(null, null, CommandType.Text, @"SELECT sys.tables.name as [Table],sys.triggers.name as Name,sys.trigger_events.type as Type, OBJECT_DEFINITION(sys.triggers.object_id) as Definition FROM sys.triggers INNER JOIN sys.trigger_events ON sys.triggers.object_id=sys.trigger_events.object_id INNER JOIN sys.tables on sys.triggers.parent_id=sys.tables.object_id"); }
public static Guid Persist(AddOrderCommand c, IBatch batch, Guid id) { batch.HashSetAsync(id.ToString(), new [] { new HashEntry("Id", c.Id), new HashEntry("Version", c.Version), new HashEntry("Customer", c.Customer), new HashEntry("OrderDate", c.OrderDate.Ticks), }); return id; }
public static Guid Persist(AddCustomerCommand c, IBatch batch, Guid id) { batch.HashSetAsync(id.ToString(), new [] { new HashEntry("Id", c.Id), new HashEntry("Version", c.Version), new HashEntry("Firstname", c.Firstname), new HashEntry("Lastname", c.Lastname), }); return id; }
public static Guid Persist(AddProductCommand c,IBatch batch, Guid id) { batch.HashSetAsync(id.ToString(), new [] { new HashEntry("Id", c.Id), new HashEntry("Version", c.Version), new HashEntry("Cost", c.Cost.ToString()), new HashEntry("Name", c.Name), }); return id; }
/// <summary> /// Gets the command. /// </summary> /// <param name="batch">The batch.</param> public void GetCommand(IBatch batch) { if (batch == null) throw new ArgumentNullException(nameof(batch)); batch.AddCommand(null, null, CommandType.Text, @"SELECT sys.procedures.name as [Procedure],sys.systypes.name as TYPE,sys.parameters.name as NAME, sys.parameters.max_length as LENGTH,sys.parameters.default_value as [DEFAULT VALUE] FROM sys.procedures INNER JOIN sys.parameters on sys.procedures.object_id=sys.parameters.object_id INNER JOIN sys.systypes on sys.systypes.xusertype=sys.parameters.system_type_id WHERE sys.systypes.xusertype <> 256"); }
/// <summary> /// Gets the command. /// </summary> /// <param name="batch">The batch.</param> public void GetCommand(IBatch batch) { if (batch == null) throw new ArgumentNullException(nameof(batch)); batch.AddCommand(null, null, CommandType.Text, @"SELECT sys.views.name as [View],OBJECT_DEFINITION(sys.views.object_id) as Definition, sys.columns.name AS [Column], sys.systypes.name AS [COLUMN_TYPE], sys.columns.max_length as [MAX_LENGTH], sys.columns.is_nullable as [IS_NULLABLE] FROM sys.views INNER JOIN sys.columns on sys.columns.object_id=sys.views.object_id INNER JOIN sys.systypes ON sys.systypes.xtype = sys.columns.system_type_id WHERE sys.systypes.xusertype <> 256"); }
public static Guid HashCreate(this Command command, IBatch batch) { var id = Guid.NewGuid(); batch.HashSetAsync(id.ToString(), new [] { new HashEntry("Type", getName[command.GetType()]), new HashEntry("SequenceNumber", command.SequenceNumber) }); Switch.On(command) .Case((AddCustomerCommand c) => AddCustomerCommandMap.Persist(c, batch, id)) .Case((AddOrderCommand c)=> AddOrderCommandMap.Persist(c, batch, id)) .Case((AddProductCommand c)=> AddProductCommandMap.Persist(c, batch, id)) .Case((AddProductToOrder c)=> AddProductToOrderMap.Persist(c, batch, id)) .ElseFail() ; return id; }
/// <summary> /// Gets the command. /// </summary> /// <param name="batch">The batch.</param> public void GetCommand(IBatch batch) { if (batch == null) throw new ArgumentNullException(nameof(batch)); batch.AddCommand(null, null, CommandType.Text, @"SELECT sys.tables.name as [Table],sys.columns.name AS [Column], sys.systypes.name AS [COLUMN_TYPE], sys.columns.max_length as [MAX_LENGTH], sys.columns.is_nullable as [IS_NULLABLE], sys.columns.is_identity as [IS_IDENTITY], sys.index_columns.index_id as [IS_INDEX], key_constraints.name as [PRIMARY_KEY], key_constraints_1.name as [UNIQUE], tables_1.name as [FOREIGN_KEY_TABLE], columns_1.name as [FOREIGN_KEY_COLUMN], sys.default_constraints.definition as [DEFAULT_VALUE] FROM sys.tables INNER JOIN sys.columns on sys.columns.object_id=sys.tables.object_id INNER JOIN sys.systypes ON sys.systypes.xtype = sys.columns.system_type_id LEFT OUTER JOIN sys.index_columns on sys.index_columns.object_id=sys.tables.object_id and sys.index_columns.column_id=sys.columns.column_id LEFT OUTER JOIN sys.key_constraints on sys.key_constraints.parent_object_id=sys.tables.object_id and sys.key_constraints.parent_object_id=sys.index_columns.object_id and sys.index_columns.index_id=sys.key_constraints.unique_index_id and sys.key_constraints.type='PK' LEFT OUTER JOIN sys.foreign_key_columns on sys.foreign_key_columns.parent_object_id=sys.tables.object_id and sys.foreign_key_columns.parent_column_id=sys.columns.column_id LEFT OUTER JOIN sys.tables as tables_1 on tables_1.object_id=sys.foreign_key_columns.referenced_object_id LEFT OUTER JOIN sys.columns as columns_1 on columns_1.column_id=sys.foreign_key_columns.referenced_column_id and columns_1.object_id=tables_1.object_id LEFT OUTER JOIN sys.key_constraints as key_constraints_1 on key_constraints_1.parent_object_id=sys.tables.object_id and key_constraints_1.parent_object_id=sys.index_columns.object_id and sys.index_columns.index_id=key_constraints_1.unique_index_id and key_constraints_1.type='UQ' LEFT OUTER JOIN sys.default_constraints on sys.default_constraints.object_id=sys.columns.default_object_id WHERE sys.systypes.xusertype <> 256"); }
public virtual void testMigrateWithQuery() { // given IProcessDefinition sourceDefinition = testHelper.DeployAndGetDefinition(ProcessModels.OneTaskProcess); IProcessDefinition targetDefinition = testHelper.DeployAndGetDefinition(ModifiableBpmnModelInstance.Modify(ProcessModels.OneTaskProcess).ChangeElementId(ProcessModels.ProcessKey, "new" + ProcessModels.ProcessKey)); IProcessInstance processInstance = engineRule.RuntimeService.StartProcessInstanceById(sourceDefinition.Id); IMigrationPlan migrationPlan = engineRule.RuntimeService.CreateMigrationPlan(sourceDefinition.Id, targetDefinition.Id).MapEqualActivities().Build(); IQueryable <IProcessInstance> query = engineRule.RuntimeService.CreateProcessInstanceQuery(); // when authRule.Init(scenario).WithUser("userId").BindResource("sourceDefinitionKey", sourceDefinition.Key).BindResource("targetDefinitionKey", targetDefinition.Key).BindResource("processInstance", processInstance.Id).Start(); batch = engineRule.RuntimeService.NewMigration(migrationPlan).ProcessInstanceQuery(query).ExecuteAsync(); // then if (authRule.AssertScenario(scenario)) { Assert.AreEqual(1, engineRule.ManagementService.CreateBatchQuery().Count()); } }
/// <summary> /// Job任务列表 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="jobName"></param> /// <param name="list"></param> protected virtual bool SaveJob <T>(string jobName, IEnumerable <T> list) { string key = $"JOB:{jobName}"; string progress = $"{JOB_PROGRESS}{jobName}"; if (this.NewExecutor().KeyExists(key)) { return(false); } IBatch batch = this.NewExecutor().CreateBatch(); foreach (T t in list) { batch.ListRightPushAsync(key, t.GetRedisValue()); } batch.HashSetAsync(progress, new[] { new HashEntry(JOB_TOTAL, list.Count()), new HashEntry(JOB_COUNT, 0) }); batch.Execute(); return(true); }
/// <summary> /// Converts an IBatch to an HTTP query string /// </summary> /// <param name="batch">The IBatch to create the HTTP query string from</param> /// <returns></returns> internal static string ToHttpQueryString(this IBatch batch) { List <string> keyValueStrings = new List <string>(); foreach (var nvp in batch.GetData().Where(nvp => nvp.Value != null)) { keyValueStrings.Add(nvp.Key + "=" + Uri.EscapeUriString(nvp.Value.ToString())); } int logNumber = 0; foreach (var log in batch.Logs) { foreach (var nvp in log.GetData().Where(nvp => nvp.Value != null)) { keyValueStrings.Add(LogsArrayName + "[" + logNumber + "][" + nvp.Key + "]=" + Uri.EscapeDataString(nvp.Value.ToString())); } logNumber++; } return(String.Join("&", keyValueStrings.ToArray())); }
public virtual void shouldFailForNonExistingExternalTaskIdAsync() { IList <ESS.FW.Bpm.Engine.Externaltask.IExternalTask> externalTasks = externalTaskService.CreateExternalTaskQuery().ToList(); List <string> externalTaskIds = new List <string>(); foreach (ESS.FW.Bpm.Engine.Externaltask.IExternalTask task in externalTasks) { externalTaskIds.Add(task.Id); } externalTaskIds.Add("nonExistingExternalTaskId"); IBatch batch = externalTaskService.SetRetriesAsync(externalTaskIds, null, 10); try { executeSeedAndBatchJobs(batch); Assert.Fail("exception expected"); } catch (NotFoundException e) { Assert.That(e.Message, Does.Contain("Cannot find external task with id nonExistingExternalTaskId")); } }
/// <summary> /// Saves an object to the database /// </summary> /// <typeparam name="ObjectType">Object type</typeparam> /// <typeparam name="PrimaryKeyType">Primary key type</typeparam> /// <param name="Object">Object to save</param> public void Save <ObjectType, PrimaryKeyType>(ObjectType Object) where ObjectType : class { Cache.RemoveByTag(typeof(ObjectType).GetName()); foreach (ISourceInfo Source in SourceProvider.Where(x => x.Writable).OrderBy(x => x.Order)) { IMapping Mapping = MapperProvider[typeof(ObjectType), Source]; if (Mapping != null) { IGenerator <ObjectType> Generator = QueryProvider.Generate <ObjectType>(Source, MapperProvider[typeof(ObjectType), Source], MapperProvider.GetStructure(Mapping.DatabaseConfigType)); IBatch TempBatch = QueryProvider.Batch(Source); CascadeSave <ObjectType>(Object, Source, Mapping, TempBatch, new List <object>()); TempBatch.Execute(); TempBatch = QueryProvider.Batch(Source); TempBatch.AddCommand(Generator.Save <PrimaryKeyType>(Object)); TempBatch.Execute(); TempBatch = QueryProvider.Batch(Source); JoinsDelete <ObjectType>(Object, Source, Mapping, TempBatch, new List <object>()); JoinsSave <ObjectType>(Object, Source, Mapping, TempBatch, new List <object>()); TempBatch.RemoveDuplicateCommands().Execute(); } } }
public IActionResult GenerateItems(int totalNumber, int numberOfBlue) { try { IBatch batch = redisConnection.GetDatabase().CreateBatch(); List <ItemViewModel> models = GenerateModels(totalNumber, numberOfBlue); foreach (ItemViewModel model in models) { HashEntry[] instanceFields = new HashEntry[] { new HashEntry("Id", model.Id), new HashEntry("Color", model.Color), new HashEntry("Name", model.Name), new HashEntry("Year", model.Year) }; string key = "Item:" + model.Id.ToString(); batch.HashSetAsync(key, instanceFields); if (model.Color == "blue") { string blueKey = blueItemIdsKey; batch.SetAddAsync(blueKey, model.Id); } } batch.Execute(); return(Ok("Ok")); } catch (Exception ex) { return(StatusCode(500, ex.Message)); } }
/// <summary> /// Called to create a batch that saves items from the joining tables /// </summary> /// <param name="Object">Object</param> /// <param name="Source">Source info</param> /// <param name="ObjectsSeen">Objects seen thus far</param> /// <returns>Batch object with the appropriate commands</returns> public override IBatch CascadeJoinsSave(ClassType Object, ISourceInfo Source, IList <object> ObjectsSeen) { QueryProvider.Manager Provider = IoC.Manager.Bootstrapper.Resolve <QueryProvider.Manager>(); Mapper.Manager MappingProvider = IoC.Manager.Bootstrapper.Resolve <Mapper.Manager>(); IMapping PropertyMapping = MappingProvider[typeof(DataType), Source]; IBatch Batch = Provider.Batch(Source); var AspectObject = Object as IORMObject; if (Object == null || (AspectObject != null && ObjectsSeen.Contains(Mapping.IDProperties.FirstOrDefault().GetValue(Object)))) { return(Provider.Batch(Source)); } if (AspectObject != null) { ObjectsSeen.Add(Mapping.IDProperties.FirstOrDefault().GetValue(Object)); } DataType Item = CompiledExpression(Object); if (Item == null) { return(Batch); } foreach (IProperty <DataType> Property in PropertyMapping.Properties) { if (!Property.Cascade && (Property is IMultiMapping || Property is ISingleMapping)) { Batch.AddCommand(Property.JoinsSave(Item, Source, ObjectsSeen.ToList())); } else if (Property.Cascade) { Batch.AddCommand(Property.CascadeJoinsSave(Item, Source, ObjectsSeen.ToList())); } } return(Batch); }
/// <summary> /// Deletes items from the joining table for the property /// </summary> /// <param name="Property">Property</param> /// <param name="Object">Object</param> /// <typeparam name="P">Property type</typeparam> /// <returns>The batch with the appropriate commands</returns> public IBatch JoinsDelete <P>(IProperty <T, P> Property, T Object) { IBatch ReturnValue = QueryProvider.Batch(Source); if (Object == null) { return(ReturnValue); } var List = (P)Property.GetValue(Object); if (List == null) { return(ReturnValue); } object CurrentID = Mapping.IDProperties.FirstOrDefault().GetValue(Object); IMapping ForeignMapping = Property.ForeignMapping; if (string.Compare(Mapping.TableName, ForeignMapping.TableName, StringComparison.Ordinal) == 0 && Property as IManyToOne != null) { ReturnValue.AddCommand(null, Object, "DELETE FROM " + Property.TableName + " WHERE " + Mapping.TableName + Mapping.IDProperties.FirstOrDefault().FieldName + "2=@0", CommandType.Text, CurrentID); } else { ReturnValue.AddCommand(null, Object, "DELETE FROM " + Property.TableName + " WHERE " + Mapping.TableName + Mapping.IDProperties.FirstOrDefault().FieldName + "=@0", CommandType.Text, CurrentID); } return(ReturnValue); }
private bool Batch <T>(IEnumerable items, Action <IBatch, T> iterator, Action <IBatch> complete = null) { if (items == null || iterator == null) { return(false); } IBatch batch = null; foreach (var item in items) { if (item == null) { continue; } if (batch == null) { batch = this.Database.CreateBatch(); } iterator(batch, (T)item); } if (batch != null) { if (complete != null) { complete(batch); } batch.Execute(); } return(batch != null); }
/// <summary> /// Gets the command. /// </summary> /// <param name="batch">The batch.</param> public void GetCommand(IBatch batch) { if (batch == null) { throw new ArgumentNullException(nameof(batch)); } batch.AddCommand(null, null, CommandType.Text, @"SELECT sys.tables.name as [Table],sys.columns.name AS [Column], sys.systypes.name AS [COLUMN_TYPE], sys.columns.max_length as [MAX_LENGTH], sys.columns.is_nullable as [IS_NULLABLE], sys.columns.is_identity as [IS_IDENTITY], sys.index_columns.index_id as [IS_INDEX], key_constraints.name as [PRIMARY_KEY], key_constraints_1.name as [UNIQUE], tables_1.name as [FOREIGN_KEY_TABLE], columns_1.name as [FOREIGN_KEY_COLUMN], sys.default_constraints.definition as [DEFAULT_VALUE] FROM sys.tables INNER JOIN sys.columns on sys.columns.object_id=sys.tables.object_id INNER JOIN sys.systypes ON sys.systypes.xtype = sys.columns.system_type_id LEFT OUTER JOIN sys.index_columns on sys.index_columns.object_id=sys.tables.object_id and sys.index_columns.column_id=sys.columns.column_id LEFT OUTER JOIN sys.key_constraints on sys.key_constraints.parent_object_id=sys.tables.object_id and sys.key_constraints.parent_object_id=sys.index_columns.object_id and sys.index_columns.index_id=sys.key_constraints.unique_index_id and sys.key_constraints.type='PK' LEFT OUTER JOIN sys.foreign_key_columns on sys.foreign_key_columns.parent_object_id=sys.tables.object_id and sys.foreign_key_columns.parent_column_id=sys.columns.column_id LEFT OUTER JOIN sys.tables as tables_1 on tables_1.object_id=sys.foreign_key_columns.referenced_object_id LEFT OUTER JOIN sys.columns as columns_1 on columns_1.column_id=sys.foreign_key_columns.referenced_column_id and columns_1.object_id=tables_1.object_id LEFT OUTER JOIN sys.key_constraints as key_constraints_1 on key_constraints_1.parent_object_id=sys.tables.object_id and key_constraints_1.parent_object_id=sys.index_columns.object_id and sys.index_columns.index_id=key_constraints_1.unique_index_id and key_constraints_1.type='UQ' LEFT OUTER JOIN sys.default_constraints on sys.default_constraints.object_id=sys.columns.default_object_id WHERE sys.systypes.xusertype <> 256"); }
public IEnumerable <T> ExecuteReader(IBatch batch) { if (SqlExecuteExtensionAction.Instance.BatchAction != null) { SqlExecuteExtensionAction.Instance.AddContext(batch); } List <T> entitybuffer = new List <T>(1024); using (var Connection = Create.Invoke()) { var reader = Connection.ExecuteReader(batch.SqlBuilder, batch.DynamicParameters, commandTimeout: 3600); var entityParser = reader.GetRowParser <T>(); while (reader.Read()) { var entity = entityParser.Invoke(reader); if (entity == null) { break; } entitybuffer.Add(entity); } } return(entitybuffer); }
public async Task <Int32> ExecuteAsync(IBatch batch, Boolean transaction = false) { if (SqlExecuteExtensionAction.Instance.BatchAction != null) { SqlExecuteExtensionAction.Instance.AddContext(batch); } Int32 result = 0; using (var Connection = Create.Invoke()) { if (transaction) { IDbTransaction dbTransaction = null; try { Connection.Open(); dbTransaction = Connection.BeginTransaction(); result = await Connection.ExecuteAsync(batch.SqlBuilder, batch.DynamicParameters, dbTransaction, commandTimeout : 3600); } catch (Exception e) { dbTransaction.Rollback(); throw e; } finally { Connection.Close(); } } else { result = await Connection.ExecuteAsync(batch.SqlBuilder, batch.DynamicParameters, commandTimeout : 3600); } } return(result); }
public Stage(Viewport viewport, IBatch batch = null) { if (viewport == null) { throw new Exception("viewport cannot be null."); } this.viewport = viewport; if (batch == null) { // todo: make spritebatch : ibatch ownsBatch = true; } else { this.batch = batch; } //root = new Group(); //root.setStage(this); viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true); }
public void CreateBulkOfMatches(List <IMatch> matches) { if (matches == null) { throw new ArgumentNullException("matches"); } // Get the overall batch identification from the Mediator. IBatch batchId = ProxyHome.Instance.RetrieveExecutionIdentification(DataAccessKeyKeeper.Instance.AccessKey); using (CodeAnalyzerContainer ctx = new CodeAnalyzerContainer()) { Model.Batch batch = new Model.Batch { TimeStamp = batchId.TimeStamp }; foreach (IMatch match in matches) { // Mapping: Domain Model => Entity Model. Model.Match m = new Model.Match() { LineNumber = match.LineNumber, CodeExtract = match.CodeExtract, RootDirectoryPath = match.RootDirectoryPath, Filename = match.Filename, Batch = batch, Status = (int)match.Result, RuleDeclaration = ToEntityModelMapper.RuleDeclarationMapper(match.RuleDeclarationRef, ctx), }; // Do the actual DB update. ctx.Match.Add(m); } ctx.SaveChanges(); } }
/// <summary> /// /// </summary> /// <param name="acDomain"></param> /// <param name="batch"></param> public BatchDescriptor(IAcDomain acDomain, IBatch batch) { if (batch == null) { throw new ArgumentNullException("batch"); } this._batch = batch; OntologyDescriptor ontology; if (!acDomain.NodeHost.Ontologies.TryGetOntology(batch.OntologyId, out ontology)) { throw new AnycmdException("意外的本体标识" + batch.OntologyId); } this.Ontology = ontology; NodeDescriptor node; if (!acDomain.NodeHost.Nodes.TryGetNodeById(batch.NodeId.ToString(), out node)) { throw new AnycmdException("意外的节点标识" + batch.NodeId); } this.Node = node; if (!batch.Type.TryParse(out _batchType)) { throw new AnycmdException("意外的批类型" + batch.Type); } }
public bool LstLPushBatch <T>(string key, List <T> lstValue, When w = When.Always) { try { IBatch batch = _cache.CreateBatch(); var tasks = new List <Task>(); string strRedisKey = GetKeyForRedis(key); foreach (T value in lstValue) { tasks.Add(batch.ListLeftPushAsync(strRedisKey, Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(value)), w)); } batch.Execute(); Task.WaitAll(tasks.ToArray()); return(true); } catch (Exception) { throw; } // throw new NotImplementedException(); }
public virtual void testSetRetriesAsync() { // given IProcessDefinition processDefinition = testRule.DeployAndGetDefinition(ExternalTaskModels.ONE_EXTERNAL_TASK_PROCESS); IProcessInstance processInstance1 = engineRule.RuntimeService.StartProcessInstanceByKey("Process"); IList <ESS.FW.Bpm.Engine.Externaltask.IExternalTask> externalTasks = engineRule.ExternalTaskService.CreateExternalTaskQuery() .ToList(); List <string> externalTaskIds = new List <string>(); foreach (ESS.FW.Bpm.Engine.Externaltask.IExternalTask task in externalTasks) { externalTaskIds.Add(task.Id); } // when authRule.Init(scenario).WithUser("userId").BindResource("batchId", "*").BindResource("processInstance1", processInstance1.Id).BindResource("processDefinition", processDefinition.Key).Start(); IBatch batch = engineRule.ExternalTaskService.SetRetriesAsync(externalTaskIds, null, 5); if (batch != null) { executeSeedAndBatchJobs(batch); } // then if (authRule.AssertScenario(scenario)) { externalTasks = engineRule.ExternalTaskService.CreateExternalTaskQuery() .ToList(); foreach (ESS.FW.Bpm.Engine.Externaltask.IExternalTask task in externalTasks) { Assert.AreEqual(5, (int)task.Retries); } } }
[Test] public virtual void testActivateBatchFailsWithWrongTenant() { // given IBatch batch = batchHelper.MigrateProcessInstanceAsync(tenant2Definition, tenant2Definition); managementService.SuspendBatchById(batch.Id); // when //identityService.SetAuthentication("user", null, singletonList(TENANT_ONE)); try { managementService.ActivateBatchById(batch.Id); Assert.Fail("exception expected"); } catch (ProcessEngineException e) { // then //Assert.That(e.Message, CoreMatchers.Does.Contain("Cannot activate batch '" + batch.Id + "' because it belongs to no authenticated tenant")); } finally { identityService.ClearAuthentication(); } }
public virtual void shouldFailForNullExternalTaskIdAsync() { IList <ESS.FW.Bpm.Engine.Externaltask.IExternalTask> externalTasks = externalTaskService.CreateExternalTaskQuery().ToList(); List <string> externalTaskIds = new List <string>(); foreach (ESS.FW.Bpm.Engine.Externaltask.IExternalTask task in externalTasks) { externalTaskIds.Add(task.Id); } externalTaskIds.Add(null); IBatch batch = null; try { batch = externalTaskService.SetRetriesAsync(externalTaskIds, null, 10); executeSeedAndBatchJobs(batch); Assert.Fail("exception expected"); } catch (BadUserRequestException e) { Assert.That(e.Message, Does.Contain("External task id cannot be null")); } }
/// <summary> /// Saves the object to the source /// </summary> /// <typeparam name="PrimaryKeyType">Primary key type</typeparam> /// <param name="Object">Object to save</param> public IBatch Save <PrimaryKeyType>(T Object) { IBatch TempBatch = QueryProvider.Batch(Source); IProperty <T> IDProperty = ((IProperty <T>)Mapping.IDProperties.FirstOrDefault()); PrimaryKeyType IDValue = IDProperty.GetValue(Object).To(default(PrimaryKeyType)); var Comparer = new GenericEqualityComparer <PrimaryKeyType>(); IParameter Param1 = null; if (Comparer.Equals(IDValue, default(PrimaryKeyType))) { return(TempBatch.AddCommand(Insert(Object))); } if (IDProperty.AutoIncrement) { return(TempBatch.AddCommand(Update(Object))); } Param1 = typeof(PrimaryKeyType).Is(typeof(string)) ? (IParameter) new StringEqualParameter(IDValue.ToString(), IDProperty.FieldName, IDValue.ToString().Length, IDProperty.FieldName, Source.ParameterPrefix) : (IParameter) new EqualParameter <PrimaryKeyType>(IDValue, IDProperty.FieldName, IDProperty.FieldName, Source.ParameterPrefix); if (Any(Param1).Execute()[0].Count == 0) { return(TempBatch.AddCommand(Insert(Object))); } return(TempBatch.AddCommand(Update(Object))); }
private void Start(IBatch batch) { var load = batch.First(); // for debug //if (load.Index == 11 && _requesting[load].Activity.Name == "PreparingToDismount") ; //if (load.Index == 11 && _requesting[load].Activity.Name == "Dismounting") ; if (!_occupying.ContainsKey(load)) { /// new to the system _occupying.Add(load, _requesting[load]); _loadToBatch.Add(load, batch); } else { /// entered in the system _occupying[load].Depart(load); _occupying[load] = _requesting[load]; _loadToBatch[load] = batch; } _occupying[load].Start(load); _requesting.Remove(load); }
public BatchUpdatedEvent(IAcSession acSession, IBatch source) : base(acSession, source) { }
/// <summary> /// Adds a batch's commands to the current batch /// </summary> /// <param name="Batch">Batch to add</param> /// <returns>This</returns> public IBatch AddCommand(IBatch Batch) { var TempValue = Batch as DatabaseBatch; if (TempValue == null) return this; Commands.Add(TempValue.Commands); return this; }
public void DeleteTag(IBatch <T> batch, uint id) { batch.Execute(GetDeleteTagStep(id)); }
public BatchRemovedEvent(IAcSession acSession, IBatch source) : base(acSession, source) { }
protected internal RedisBatch(RedisContext context, IBatch batch) : base(context) { Check.NotNull(batch, nameof(batch)); Batch = batch; }
public void DeleteEntity(IBatch <T> batch, uint id) { batch.Execute(GetDeleteEntityStep(id)); }
internal FilterContext(IDbConnection connection, IDbCommand command, Exception exception, IBatch batch = null) { this.Connection = connection; this.Command = command; this.Exception = exception; this.Batch = batch; }
private void SaveWork(IBatch<IWork> batch, IWork work) { batch.Save(work); foreach (var child in work.Children) { SaveWork(batch, child); } }
/// <summary> /// This method will be called after the batch has been prepared by the application /// but before any document/page is sent to the script. The scripts usually perform /// preparations to release the batch based on the current settings. /// </summary> public object StartBatch(IBatch batch) { m_BatchFolder = Path.Combine(m_Destination, batch.Name); bool batchFolderCreated = !Directory.Exists(m_BatchFolder); if (batchFolderCreated) Directory.CreateDirectory(m_BatchFolder); /// Again, the application will keep any object returned from this function and pass it back to the script /// in the EndBatch call. This is usually intended to facilitate cleanup. return batchFolderCreated; }
private void AddDeleteTimersOperationsToBatch(Guid processId, List <string> timersIgnoreList, IDatabase db, IBatch batch) { var keyProcessTimer = GetKeyProcessTimer(processId); var timers = db.HashGetAll(keyProcessTimer) .Where(he => !timersIgnoreList.Contains(he.Name)) .Select(he => new TimerToExecute { Name = he.Name, ProcessId = processId, TimerId = Guid.Parse(he.Value) }) .ToList(); foreach (var timer in timers) { batch.SortedSetRemoveAsync(GetKeyTimerTime(), timer.TimerId.ToString("N")); batch.HashDeleteAsync(keyProcessTimer, timer.Name); batch.HashDeleteAsync(GetKeyTimerIgnore(), timer.TimerId.ToString("N")); batch.HashDeleteAsync(GetKeyTimer(), timer.TimerId.ToString("N")); } }
public void EndBatch(IBatch batch, object handle, ReleaseResult result) { if (_settings.BatchCreation == 1) return; string pdfname = Path.Combine(_batchFolder, Path.ChangeExtension(_batchName, "pdf")); _docConverter.Convert(_documentList, pdfname, _settings.EnableChapters); }
public void SaveLink(IBatch <T> batch, uint id, Link link, uint entityId) { batch.Execute(GetUpdateLinkStep(id, link, entityId)); }
/// <summary> /// This method will be called after all documents have been sent to the script. /// The scripts usually perform the necessary cleanup based on current settings /// and the actual release conditions. /// </summary> public void EndBatch(IBatch batch, object handle, ReleaseResult result) { /// The handle should always indicate whether or not the script created the batch folder from scratch if (result != ReleaseResult.Succeeded && (bool)handle) Directory.Delete(m_BatchFolder); }
private void batchEvents_OnBatchProgress( IBatch batch, int processedItemsCount, int remainingItemsCount ) { traceProgress( ( processedItemsCount * 100 ) / ( processedItemsCount + remainingItemsCount ) ); }
public object StartIndex(IBatch batch, IDictionary<string, string> releaseData, string outputFileName) { return null; }
/// <summary> /// Creates a new instance of BatchEventArgs. /// </summary> /// <param name="Batch">The batch object associated with the event</param> public BatchEventArgs(IBatch Batch) { this.Batch = Batch; }
/// <summary> /// 增加集合时调用此方法,更新索引 /// </summary> /// <param name="batch"></param> /// <param name="keys"></param> /// <returns></returns> protected virtual Task <long> BatchOnAdded(IBatch batch, params TKey[] keys) { return(_indexSet.AsBatch().BatchAdd(batch, keys)); }
/// <summary> /// Gets the command. /// </summary> /// <param name="batch">The batch.</param> public void GetCommand(IBatch batch) { if (batch == null) throw new ArgumentNullException(nameof(batch)); batch.AddCommand(null, null, CommandType.Text, @"SELECT sys.procedures.name as NAME,OBJECT_DEFINITION(sys.procedures.object_id) as DEFINITION FROM sys.procedures"); }
// POST: api/Log public void Post([FromBody] string name, [FromBody] string message, [FromBody] string severity = INFO, IBatch pipeline = null) { var destination = $"recent:{name}:{severity}"; var batch = pipeline ?? Redis.CreateBatch(); batch.ListLeftPushAsync(destination, $"{DateTime.Now} {message}"); batch.ListTrimAsync(destination, 0, 99); batch.Execute(); }
/// <summary> /// Gets the command. /// </summary> /// <param name="batch">The batch.</param> public void GetCommand(IBatch batch) { if (batch == null) throw new ArgumentNullException(nameof(batch)); batch.AddCommand(null, null, CommandType.Text, "SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES"); }
public void DeleteLink(IBatch <T> batch, uint id) { batch.Execute(GetDeleteLinkStep(id)); }
/// <inheritdoc /> public async Task<LogBatchResult> SendBatchAsync(IBatch batch, CancellationToken c) #endif { if (batch.Logs != null) { using (HttpClient httpClient = new HttpClient()) { httpClient.Timeout = Timeout; httpClient.DefaultRequestHeaders.Add("Ver", Version.ToString()); Dictionary<string, string> headers = new Dictionary<string, string>(); foreach (var headerKey in AdditionalHttpHeaders.Keys) headers.Add(headerKey, AdditionalHttpHeaders[headerKey]); using (var stream = new MemoryStream()) { if (SerializationFormat == AudienceInsight.SerializationFormat.Xml) { #if COMPRESSION if (Compress) batch.SerializeCompressedXml(stream); else #endif batch.SerializeUncompressedXml(stream); } else if (SerializationFormat == AudienceInsight.SerializationFormat.Json) { #if COMPRESSION if (Compress) { batch.SerializeCompressedJson(stream); headers.Add("Content-Type", "application/gzip"); } else { #endif batch.SerializeUncompressedJson(stream); headers.Add("Content-Type", "application/json; charset=utf-8"); #if COMPRESSION } #endif } else if (SerializationFormat == AudienceInsight.SerializationFormat.HttpQueryString) { throw new NotImplementedException(); } else { throw new NotImplementedException(); } stream.Seek(0, SeekOrigin.Begin); var sr = new StreamReader(stream); var myStr = sr.ReadToEnd(); stream.Seek(0, SeekOrigin.Begin); using (var content = new StreamContent(stream)) { foreach (var headerKey in headers.Keys) content.Headers.Add(headerKey, headers[headerKey]); using (var response = await httpClient.PostAsync(ServiceUrl, content, c)) { response.EnsureSuccessStatusCode(); c.ThrowIfCancellationRequested(); var responseHeaders = new Dictionary<string, string>(); #if SILVERLIGHT foreach (var responseHeaderKey in response.Response.Headers.AllKeys) responseHeaders.Add(responseHeaderKey, response.Response.Headers[responseHeaderKey]); #else foreach (var responseHeader in response.Headers) responseHeaders.Add(responseHeader.Key, responseHeader.Value.FirstOrDefault()); #endif return CreateLogBatchResult(responseHeaders); } } } } } else return null; }
public void SaveEntity(IBatch <T> batch, uint id, T entity) { batch.Execute(GetUpdateEntityStep(id, entity)); }
/// <summary> /// Gets the command. /// </summary> /// <param name="batch">The batch.</param> public void GetCommand(IBatch batch) { if (batch == null) throw new ArgumentNullException(nameof(batch)); batch.AddCommand(null, null, CommandType.Text, @"SELECT SPECIFIC_NAME as NAME,ROUTINE_DEFINITION as DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE INFORMATION_SCHEMA.ROUTINES.ROUTINE_TYPE='FUNCTION'"); }
public void SaveTag(IBatch <T> batch, uint id, Tag tag, uint entityId) { batch.Execute(GetUpdateTagStep(id, tag, entityId)); }
public object StartBatch(IBatch batch) { _batchFolder = Path.Combine(_settings.ExportDirectory, batch.Name); _batchName = batch.Name; if (!Directory.Exists(_batchFolder)) Directory.CreateDirectory(_batchFolder); return null; }