Beispiel #1
0
        public ActionProcessor(string[] args)
        {
            processing.Add(this);
            state        = ActionStatesEnum.Initiating;
            this.context = null;

            IEnumerable <string>       curParams;
            IEnumerable <IActionParam> prms = null;

            string valFull = args.FirstOrDefault(a => a.StartsWith(string.Format(templateArgs, ActionParamNamesCore.Action)));

            string val = string.IsNullOrEmpty(valFull) ? valFull : GetParamValue(ActionParamNamesCore.Action, valFull);

            if (this.ActionExists(val))
            {
                curParams = this.usedParameters.Where(p => args.Any(a => a.StartsWith(string.Format(templateArgs, p))));
                if (curParams.Count() > 0)
                {
                    prms = curParams.Select(p => new ActionParam <string>()
                    {
                        ParamName = p, Value = GetParamValue(p, args.First(a => a.StartsWith(string.Format(templateArgs, p))))
                    }).Cast <IActionParam>();
                    this.prosessingActionParams.AddRange(prms);
                }

                this.InitiateAction(val);
            }

            state = ActionStatesEnum.Initiated;
        }
Beispiel #2
0
        public IActionResult Process()
        {
            this.CheckConsistency();
            IActionResult result = null;

            if (act != null)
            {
                MilSpace.Core.Logger.Info(string.Format("Action \"{0}\" processing", act.ActionId));
                this.started = DateTime.Now;
                state        = ActionStatesEnum.Processing;

                if (ProcessMonitor != null)
                {
                    ProcessMonitorDelegate = ProcessMonitor;
                    ProcessMonitorDelegate(act.Description, state);
                }

                currentTherad    = Thread.CurrentThread;
                manualResetEvent = new ManualResetEvent(false);
                act.Process();
                result = act.GetResult();

                MilSpace.Core.Logger.Info(string.Format("Action \"{0}\" processed", act.ActionId));
                result.PeocessId = this.ProcessId;
                state            = ActionStatesEnum.Finished;
                if (ProcessMonitor != null)
                {
                    ProcessMonitor(act.Description, state);
                }
                this.performing = false;
            }

            processing.Remove(this);
            return(result);
        }
Beispiel #3
0
        public ActionProcessor(HttpContext context)
        {
            processing.Add(this);
            state = ActionStatesEnum.Initiating;
            IEnumerable <string>       curParams;
            IEnumerable <IActionParam> prms = null;

            this.context = context;

            string val = context.Request.Params[ActionParamNamesCore.Action];

            if (this.ActionExists(val))
            {
                curParams = this.usedParameters.Where(p => context.Request.Params[p] != null);
                if (curParams.Count() > 0)
                {
                    prms = curParams.Where(x => !String.IsNullOrEmpty(context.Request.Params[x]))
                           .Select(p => new ActionParam <string>()
                    {
                        ParamName = p, Value = context.Request.Params[p]
                    }).Cast <IActionParam>();



                    this.prosessingActionParams.AddRange(prms);
                }
                this.InitiateAction(val);
            }

            state = ActionStatesEnum.Processing;
        }
Beispiel #4
0
        public ActionProcessor(IEnumerable <IActionParam> args)
        {
            processing.Add(this);
            state        = ActionStatesEnum.Initiating;
            this.context = null;
            IEnumerable <string>       curParams;
            IEnumerable <IActionParam> prms = null;

            if (args.Any(a => a.ParamName == ActionParamNamesCore.Action))
            {
                var s = args.First(a => a.ParamName == ActionParamNamesCore.Action);

                ActionParam <string> ap = (ActionParam <string>)Convert.ChangeType(args.First(a => a.ParamName == ActionParamNamesCore.Action)
                                                                                   , typeof(ActionParam <string>), null);

                string val = ap.Value;

                if (this.ActionExists(val))
                {
                    curParams = this.usedParameters.Where(p => args.Any(a => a.ParamName == p));
                    if (curParams.Count() > 0)
                    {
                        prms = args.Where(aa => this.usedParameters.Any(r => r.Equals(aa.ParamName, StringComparison.InvariantCultureIgnoreCase))).Cast <IActionParam>();
                        this.prosessingActionParams.AddRange(prms);
                    }

                    this.InitiateAction(val);
                }
            }
        }