public IActivity <TInput, TOutput, TFailOutput> CreateActivity <TInput, TOutput, TFailOutput>(IActivityFactory activityFactory) where TInput : class where TOutput : class where TFailOutput : class { return((IActivity <TInput, TOutput, TFailOutput>)activityFactory.Create <TActivity>(m_ActivityCreationParams)); }
public WorkflowState Visit <TActivity, TInput, TOutput>(GraphNode <TContext, TActivity, TInput, TOutput> node) where TActivity : IActivity <TInput, TOutput> { TActivity activity; if (typeof(TActivity) == typeof(GenericActivity)) { activity = (TActivity)(object)new GenericActivity(m_ActivityExecutor, node.ActivityType, node.Name); } else { activity = m_Factory.Create <TActivity, TInput, TOutput>(); } ActivityResult result = m_Resuming ? activity.Resume(output => node.ProcessOutput(m_Context, output), m_Closure) : activity.Execute(node.GetActivityInput(m_Context), output => node.ProcessOutput(m_Context, output)); var logItem = m_Execution.AddLog(node.Name); m_Resuming = false; logItem.Status = result; if (result == ActivityResult.Pending) { m_Execution.State = WorkflowState.InProgress; return(WorkflowState.InProgress); } if (result == ActivityResult.None) { m_Execution.State = WorkflowState.Corrupted; return(WorkflowState.Corrupted); } logItem.End = DateTime.Now; var next = node.Edges.SingleOrDefault(e => e.Condition(m_Context, result)); if (next != null) { var nextNode = m_Nodes[next.Node]; var nextResult = nextNode.Accept(this); return(nextResult); } //TODO: =="end" is not good idea if (node.Name == "end" && result == ActivityResult.Succeeded) { m_Execution.State = WorkflowState.Complete; return(WorkflowState.Complete); } m_Execution.State = WorkflowState.Corrupted; return(WorkflowState.Corrupted); }
public void Handle(EditActivityCommand command) { var activity = _activityFactory.Create(command.Id, _activityRepository); activity.Update(command.Activity, command.Description, command.Date, _activityRepository); }
public ActivityItem CreateItem(int index) { return(_activityFacotry.Create(_dataRowHolder.GetRow(index))); }
public UseCaseFactory(IActivityFactory activityFactory) { this.collection.Add(typeof(IUseCase <AddProductGoodsRequest, AddProductGoodsResponse>), new AddProductGoodsUseCase(activityFactory.Create <IValidationActivity <AddProductGoodsRequest> >(), activityFactory.Create <IAddProductActivity>(), activityFactory.Create <IGetProductActivity>(), activityFactory.Create <IAddArrivedGoodsActivity>(), activityFactory.Create <IGetArrivedGoodsActivity>())); this.collection.Add(typeof(IUseCase <EditProductGoodsRequest, EditProductGoodsResponse>), new EditProductGoodsUseCase(activityFactory.Create <IValidationActivity <EditProductGoodsRequest> >(), activityFactory.Create <IEditProductActivity>(), activityFactory.Create <IGetProductActivity>(), activityFactory.Create <IEditArrivedGoodsActivity>(), activityFactory.Create <IGetArrivedGoodsActivity>())); this.collection.Add(typeof(IUseCase <GetArrivedGoodsRequest, GetArrivedGoodsResponse>), new GetArrivedGoodsUseCase(activityFactory.Create <IGetArrivedGoodsActivity>())); this.collection.Add(typeof(IUseCase <GetProductRequest, GetProductResponse>), new GetProductUseCase(activityFactory.Create <IGetProductActivity>())); this.collection.Add(typeof(IUseCase <GetProductByDateRequest, GetProductByDateResponse>), new GetProductByDateUseCase(activityFactory.Create <IValidationActivity <GetProductByDateRequest> >(), activityFactory.Create <IGetProductsByDateActivity>())); this.collection.Add(typeof(IUseCase <GetCategoryRequest, GetCategoryResponse>), new GetCategoryUseCase(activityFactory.Create <IGetCategoryActivity>())); this.collection.Add(typeof(IUseCase <GetClassRequest, GetClassResponse>), new GetClassUseCase(activityFactory.Create <IGetClassActivity>())); this.collection.Add(typeof(IUseCase <GetDepartmentRequest, GetDepartmentResponse>), new GetDepartmentUseCase(activityFactory.Create <IGetDepartmentActivity>())); this.collection.Add(typeof(IUseCase <GetProviderRequest, GetProviderResponse>), new GetProviderUseCase(activityFactory.Create <IGetProviderActivity>())); this.collection.Add(typeof(IUseCase <GetReportDetailedRequest, GetReportDetailedResponse>), new GetReportDetailedUseCase(activityFactory.Create <IValidationActivity <GetReportDetailedRequest> >(), activityFactory.Create <IGetReportDetailedActivity>())); this.collection.Add(typeof(IUseCase <GetReportSimpleRequest, GetReportSimpleResponse>), new GetReportSimpleUseCase(activityFactory.Create <IValidationActivity <GetReportSimpleRequest> >(), activityFactory.Create <IGetReportSimpleActivity>())); this.collection.Add(typeof(IUseCase <AddSaleRequest, AddSaleResponse>), new AddSaleUseCase(activityFactory.Create <IValidationActivity <AddSaleRequest> >(), activityFactory.Create <IAddSaleActivity>(), activityFactory.Create <IGetSaleActivity>(), activityFactory.Create <IEditProductActivity>(), activityFactory.Create <IGetProductActivity>())); this.collection.Add(typeof(IUseCase <GetSaleRequest, GetSaleResponse>), new GetSaleUseCase(activityFactory.Create <IGetSaleActivity>())); this.collection.Add(typeof(IUseCase <GetSaleByClassRequest, GetSaleByClassResponse>), new GetSaleByClassUseCase(activityFactory.Create <IValidationActivity <GetSaleByClassRequest> >(), activityFactory.Create <IGetSalesByClassActivity>())); this.collection.Add(typeof(IUseCase <GetTareChangeRequest, GetTareChangeResponse>), new GetTareChangeUseCase(activityFactory.Create <IGetTareChangeActivity>())); this.collection.Add(typeof(IUseCase <GetUserRequest, GetUserResponse>), new GetUserUseCase(activityFactory.Create <IValidationActivity <GetUserRequest> >(), activityFactory.Create <IGetUserActivity>())); this.collection.Add(typeof(IUseCase <GetSellerRequest, GetSellerResponse>), new GetSellerUseCase(activityFactory.Create <IGetSellerActivity>())); }
public void Handle(DeleteActivityCommand command) { var activity = _activityFactory.Create(command.Id, _activityRepository); activity.Delete(_activityRepository); }
public void Handle(RegistrationActivityCommand command) { var activity = _activityFactory.Create(command.Activity, command.Description, command.Date); activity.Register(_activityRepository); }