Ejemplo n.º 1
0
 public override void OnActionExecuting(OnActionExecuting(ActionExecutingContext filterContext)
 {
     
     // get user name + ip address + controlleraction 
     var controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
     var action = filterContext.ActionDescriptor.ActionName;
     var ip = filterContext.HttpContext.Request.UserHostAddress;
     var dateTime = filterContext.HttpContext.Timestamp;
     var user = GetUserName(filterContext.HttpContext);
 }
Ejemplo n.º 2
0
        private JobTaskResult RunAction(IEnumerable <Task <JobTaskResult> > parentTasks)
        {
            if (parentTasks.Any(x => x.Result.ActionCanceled))
            {
                State = JobState.ActionSkipped;
                OnActionFailed?.Invoke(this, new JobFailedArgs {
                    Exception = new Exception("Skipped because one of parent tasks failed")
                });
                return(JobTaskResult.Failed());
            }

            var result        = new JobTaskResult();
            var withSemaphore = jobsContext.UseActionSemaphore;

            if (withSemaphore)
            {
                State = JobState.ActionWaitForSemaphore;
                jobsContext.ActionSemaphore.Wait();
            }

            try
            {
                OnActionExecuting?.Invoke(this, new JobArgs());
                State = JobState.ActionExecuting;
                Action(new JobActionFeed(result));

                if (result.ActionCanceled)
                {
                    state = JobState.ActionCanceled;
                }
                else
                {
                    OnActionExecuted?.Invoke(this, new JobArgs());
                    state = JobState.ActionExecuted;
                }
            }
            catch (Exception ex)
            {
                var args = new JobFailedArgs
                {
                    Exception = ex
                };

                result.ActionCanceled = true;
                OnActionFailed?.Invoke(this, args);
                State = JobState.ActionFailed;
            }

            if (withSemaphore)
            {
                jobsContext.ActionSemaphore.Release();
            }

            return(result);
        }