예제 #1
0
        public void ActivityDelete()
        {
            var activityNew = new UpdateActivity <TE>();
            var invokerNew  = new WorkflowInvoker(activityNew);
            var te          = new TE();

            te.AsDynamic().TECODE          = "TestNameDel";
            te.AsDynamic().TETYPECODE_R    = "EURO";
            te.AsDynamic().TECURRENTPLACE  = "TestName";
            te.AsDynamic().TECREATIONPLACE = "TestName";
            te.AsDynamic().TESTATUS        = 123;
            te.AsDynamic().TEMAXWEIGHT     = 123;
            var parameters = new Dictionary <string, object> {
                { "Key", te }
            };

            invokerNew.Invoke(parameters, DefaultTimeOut);

            var activity = new DeleteActivity <TE>();
            var invoker  = new WorkflowInvoker(activity);

            invoker.Invoke(parameters, DefaultTimeOut);

            var activityCheck   = new GetByKeyActivity <TE>();
            var invokerCheck    = new WorkflowInvoker(activityCheck);
            var parametersCheck = new Dictionary <string, object> {
                { "Key", "TestNameDel" }
            };
            var results = invokerCheck.Invoke(parametersCheck, DefaultTimeOut);

            Assert.True(results.Count != 0);
        }
예제 #2
0
        public void DeleteActivityRun( )
        {
            var person = new Person( );

            person.Save( );
            ToDelete.Add(person.Id);

            var deleteActivity = new DeleteActivity( );

            deleteActivity.Save( );
            ToDelete.Add(deleteActivity.Id);

            var nextActivity = ( DeleteImplementation )deleteActivity.As <WfActivity>( ).CreateWindowsActivity( );

            var inputs = new Dictionary <string, object>
            {
                {
                    "Record", person
                }
            };

            RunActivity(nextActivity, inputs);

            Assert.That(Entity.Exists(person.Id), Is.False);
        }
예제 #3
0
        public object Delete(DeleteActivity request)
        {
            var entity = request.ConvertTo <Activity>();

            return(InTransaction(db =>
            {
                Logic.Remove(entity);
                return new CommonResponse();
            }));
        }
        public override Activity ToSdkObject()
        {
            var activity = new DeleteActivity(this.Name, this.Dataset);

            activity.Recursive = this.Recursive;
            activity.MaxConcurrentConnections = this.MaxConcurrentConnections;
            activity.EnableLogging            = this.EnableLogging;
            activity.LogStorageSettings       = this.LogStorageSettings?.ToSdkObject();
            activity.LinkedServiceName        = this.LinkedServiceName;
            activity.Policy = this.Policy?.ToSdkObject();
            SetProperties(activity);
            return(activity);
        }
예제 #5
0
        private async Task ConfirmActivityDeletionCommandExecutionAsync(object paramter)
        {
            var deleteActivityCommand = new DeleteActivity(_activityToDeleteId);

            var deleteActivityCommandResult = await _dispatcher.DispatchCommandAndGetResultAsync(deleteActivityCommand);

            if (deleteActivityCommandResult.Successful == false)
            {
                // TODO
            }

            ActivityDeleted?.Invoke(new ActivityDeletedEventArgs(_activityToDeleteId));
        }
예제 #6
0
        public DeleteResult DeleteOne <T>(T item) where T : IMongoEntity
        {
            var result = GetCollection <T>().DeleteOne(t => t.Id == item.Id);

            if (ShouldWriteLog <T>())
            {
                var deleteActivity = new DeleteActivity(GetUserNameFunc())
                {
                    CollectionName = GetCollectionName(typeof(T)), ObjId = item.Id, DeletedObj = item
                };
                Save((UserActivity)deleteActivity);
            }
            return(result);
        }
예제 #7
0
        public bool Handle(DeleteActivity request)
        {
            var cannotDelete = _dispatcher
                               .Fetch(new OccurrencesQuery(DateTime.Today, TimeSpan.FromDays(365)))
                               .Any(n => n.ActivityKey == request.Key);

            if (cannotDelete)
            {
                return(false);
            }

            var activity = _activityDataStorage.Find(request.Key);

            return(_activityDataStorage.Delete(activity));
        }
예제 #8
0
 public DeleteResult DeleteOne <T>(Expression <Func <T, bool> > filter) where T : IMongoEntity
 {
     if (ShouldWriteLog <T>())
     {
         T item = Find(filter).FirstOrDefault();
         if (item != null)
         {
             var deleteActivity = new DeleteActivity(GetUserNameFunc())
             {
                 CollectionName = GetCollectionName(typeof(T)), ObjId = item.Id, DeletedObj = item
             };
             Save((UserActivity)deleteActivity);
         }
     }
     return(GetCollection <T>().DeleteOne(filter));
 }
예제 #9
0
 public DeleteResult DeleteOne <T>(string id) where T : IMongoEntity
 {
     if (ShouldWriteLog <T>())
     {
         T item = FindById <T>(id);
         if (item != null)
         {
             var deleteActivity = new DeleteActivity(GetUserNameFunc())
             {
                 CollectionName = GetCollectionName(typeof(T)), ObjId = item.Id, DeletedObj = item
             };
             Save((UserActivity)deleteActivity);
         }
     }
     return(GetCollection <T>().DeleteOne(t => t.Id == id));
 }
예제 #10
0
        /// <summary>
        /// Add a delete activity
        /// </summary>
        public static Workflow AddDelete(this Workflow wf, string name, string resourceExpression = null, string fromNamed = null, string fromExit = null)
        {
            var uf = new DeleteActivity()
            {
                Name = name
            };
            var ufAs = uf.As <WfActivity>();


            if (resourceExpression != null)
            {
                ActivityTestHelper.AddExpressionToActivityArgument(wf, ufAs, "Record", resourceExpression, false);
            }

            wf.AddActivity(ufAs, fromNamed, fromExit);
            AddMissingExpressionParametersToWorkflow(wf);

            return(wf);
        }
예제 #11
0
        public ActionList GetActions(bool canManage)
        {
            if (canManage)
            {
                var result = new ActionList();

                if (this.CreatedOn.AddDays(5) > DateTime.UtcNow || this.PerformedOn == null || this.PerformedOn?.AddDays(5) > DateTime.UtcNow)
                {
                    result.Actions.Add(EditActivity.Button(this.Id));
                    result.Actions.Add(DeleteActivity.Button(this.Id));
                }

                if (this.PerformedOn == null)
                {
                    result.Actions.Add(PerformActivity.Button(this.Id));
                }

                return(result);
            }

            return(null);
        }
예제 #12
0
        public void ActivityGetByFilter()
        {
            var activityNew = new UpdateActivity <TE>();
            var invokerNew  = new WorkflowInvoker(activityNew);
            var te          = new TE();

            te.AsDynamic().TECODE          = "TestNameGetF";
            te.AsDynamic().TETYPECODE_R    = "EURO";
            te.AsDynamic().TECURRENTPLACE  = "TestName";
            te.AsDynamic().TECREATIONPLACE = "TestName";
            te.AsDynamic().TESTATUS        = 123;
            te.AsDynamic().TEMAXWEIGHT     = 123;
            var parametersNew = new Dictionary <string, object> {
                { "Key", te }
            };

            invokerNew.Invoke(parametersNew, DefaultTimeOut);

            var          activity   = new GetByFilterActivity <TE>();
            var          invoker    = new WorkflowInvoker(activity);
            var          parameters = new Dictionary <string, object>();
            const string filter     = "((TECODE = 'TestNameGetF'))";

            parameters.Add("Filter", filter);
            var results = invoker.Invoke(parameters, DefaultTimeOut);

            Assert.True(results.Count > 0);

            var activityDel   = new DeleteActivity <TE>();
            var invokerDel    = new WorkflowInvoker(activityDel);
            var parametersDel = new Dictionary <string, object> {
                { "Key", te }
            };

            invokerDel.Invoke(parametersDel, new TimeSpan(0, 0, 0, 30));
        }
예제 #13
0
        public HttpResponseMessage Delete(int activityId)
        {
            try
            {
                var editActivity = _queryProcessor.Execute(new ActivityById(activityId));
                if (editActivity == null)
                {
                    var message = string.Format("Activity Id {0} not found.", activityId);
                    throw new Exception(message);
                }

                if (editActivity.EditSourceId.HasValue)
                {
                    var activity = _queryProcessor.Execute(new ActivityById(editActivity.EditSourceId.Value));
                    if (activity != null)
                    {
                        if (activity.IsEmpty())
                        {
                            var deleteActivityCommand = new DeleteActivity(User, activity.RevisionId);
                            _deleteActivity.Handle(deleteActivityCommand);
                        }
                    }
                }

                var deleteEditActivityCommand = new DeleteActivity(User, editActivity.RevisionId);
                _deleteActivity.Handle(deleteEditActivityCommand);
            }
            catch (Exception ex)
            {
                var responseMessage = new HttpResponseMessage
                {
                    StatusCode = HttpStatusCode.NotModified,
                    Content = new StringContent(ex.Message),
                    ReasonPhrase = "Activity delete error"
                };
                throw new HttpResponseException(responseMessage);               
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }
예제 #14
0
        public HttpResponseMessage PutEdit(int activityId, [FromBody] string mode)
        {
            try
            {
                var editActivity = _queryProcessor.Execute(new ActivityById(activityId));
                if (editActivity == null)
                {
                    var message = string.Format("Activity Id {0} not found.", activityId);
                    throw new Exception(message);
                }

                if (!editActivity.EditSourceId.HasValue)
                {
                    var message = string.Format("Activity Id {0} is not being edited.", activityId);
                    throw new Exception(message);
                }

                var updateActivityCommand = new UpdateActivity(User, editActivity.EditSourceId.Value, DateTime.Now, mode)
                {
                    Values = editActivity.Values.SingleOrDefault(x => x.ModeText == editActivity.ModeText)
                };
                _updateActivity.Handle(updateActivityCommand);

                var deleteActivityCommand = new DeleteActivity(User, editActivity.RevisionId);
                _deleteActivity.Handle(deleteActivityCommand);
            }
            catch (Exception ex)
            {
                var responseMessage = new HttpResponseMessage
                {
                    StatusCode = HttpStatusCode.NotModified,
                    Content = new StringContent(ex.Message),
                    ReasonPhrase = "Activity update error"
                };
                throw new HttpResponseException(responseMessage);    
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }