当前位置: 首页>>代码示例>>C#>>正文


C# NativeActivityContext.Abort方法代码示例

本文整理汇总了C#中NativeActivityContext.Abort方法的典型用法代码示例。如果您正苦于以下问题:C# NativeActivityContext.Abort方法的具体用法?C# NativeActivityContext.Abort怎么用?C# NativeActivityContext.Abort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NativeActivityContext的用法示例。


在下文中一共展示了NativeActivityContext.Abort方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InternalExecute

        private void InternalExecute(NativeActivityContext context, ActivityInstance instance)
        {
            //grab the index of the current Activity
            var currentActivityIndex = _currentIndex.Get(context);
            if (currentActivityIndex > 0)
            {
                var lastChild = children[currentActivityIndex - 1];
                //Get result here, it is sync or async????
                RunningResult = RunningResult && ((IPassData)lastChild).GetResult();

                if (!RunningResult)
                {
                    if (ErrorLevel == OnError.AlwaysReturnTrue)
                        RunningResult = true;
                    if (ErrorLevel == OnError.Terminate)
                    {
                        Log.Fatal("Workflow terminated according OnError.Terminate");
                        context.Abort();
                    }
                    if (ErrorLevel == OnError.Continue)
                    {
                        //do nothing, just continue
                    }
                    if (ErrorLevel == OnError.JustShowWarning)
                    {
                        Log.Warn("Warning:\n" + lastChild.DisplayName + " Error happened, but we ignore it");
                        RunningResult = true;
                    }
                    if (ErrorLevel == OnError.StopCurrentScript)
                    {
                        Log.Error("Error:\n" + lastChild.DisplayName + " Error happened, stop current script.");
                        return;
                    }
                }
                //set variables value ((AutomationActivity)nextChild).Name to _runningResult
                AddVariable(lastChild.DisplayName.Replace(" ", "_").Replace(":","_"), RunningResult.ToString());
                SetVariableValueByContext(context, lastChild.DisplayName.Replace(" ", "_").Replace(":", "_"), RunningResult.ToString());
            }
            if (currentActivityIndex == children.Count)
            {
                //if the currentActivityIndex is equal to the count of MySequence's Activities
                //MySequence is complete
                SetFinalResult();
                return;
            }

            if (_onChildComplete == null)
            {
                //on completion of the current child, have the runtime call back on this method
                _onChildComplete = InternalExecute;
            }

            //grab the next Activity in MySequence.Activities and schedule it
            var nextChild = children[currentActivityIndex];
            ((IPassData) nextChild).PassData(InstanceId, UserData);
            var child = nextChild as AutomationActivity;
            if (child != null)
            {
                child.SetHost(Host);
                child.SetParentResultId(ResultId);
            }
            context.ScheduleActivity(nextChild, _onChildComplete);

            ////Get result here, it is sync or async???? not important, this is a template, should not calculate the result

            //_runningResult = _runningResult && ((IPassData)nextChild).GetResult();
            //if (!_runningResult)
            //{
            //    if (ErrorLevel == OnError.AlwaysReturnTrue)
            //        _runningResult = true;
            //    //if (ErrorLevel == OnError.Terminate)
            //    //{
            //    //    //terminate the instance (send a status to instance)
            //    //}
            //    if (ErrorLevel == OnError.Continue)
            //    {
            //        //do nothing, just continue
            //    }
            //    if (ErrorLevel == OnError.JustShowWarning)
            //    {
            //        //do nothing, log warning
            //        Log.Warn("Warning:\n" + DisplayName + " Error happened, but we ignore it");
            //        _runningResult = true;
            //    }
            //    if (ErrorLevel == OnError.StopCurrentScript)
            //    {
            //        //log error, then return
            //    }
            //}

            //increment the currentIndex
            _currentIndex.Set(context, ++currentActivityIndex);
        }
开发者ID:bperreault,项目名称:autox,代码行数:93,代码来源:TestCaseActivity.cs

示例2: InternalExecute

        private void InternalExecute(NativeActivityContext context, ActivityInstance instance)
        {
            if (_onChildComplete == null)
            {
                _onChildComplete = InternalExecute;
            }
            Log.Info("in CallTestScreenActivity internalexecute");
            var steps = GetSteps(context);
            Host.SetCommand(steps);
            var rElement = Host.GetResult();

            Log.Info("CallTestScreen Receive result from Host:\n"+rElement);
            foreach (var stepElement in rElement.Descendants())
            {
                stepElement.SetAttributeValue(Constants.PARENT_ID, ResultId);
                var ret = stepElement.GetAttributeValue(Constants.RESULT);
                if (!string.IsNullOrEmpty(ret))
                {
                    stepElement.SetAttributeValue("Original", ret);
                    stepElement.SetAttributeValue("Final", ret);
                    RunningResult = ret.Equals(Constants.SUCCESS) && RunningResult;
                }
                else
                    RunningResult = false;
                if (!RunningResult)
                {
                    if (ErrorLevel == OnError.AlwaysReturnTrue)
                        RunningResult = true;
                    if (ErrorLevel == OnError.Terminate)
                    {
                        Log.Fatal("Workflow terminated according OnError.Terminate");
                        context.Abort();
                    }
                    if (ErrorLevel == OnError.Continue)
                    {
                        //do nothing, just continue
                    }
                    if (ErrorLevel == OnError.JustShowWarning)
                    {
                        Log.Warn("Warning:\n" + DisplayName + " Error happened, but we ignore it");
                        RunningResult = true;
                    }
                    if (ErrorLevel == OnError.StopCurrentScript)
                    {
                        //we cannot stop it here, just pass the result to higher level, until it reach the testscript level, then testscript will stop itself
                        Log.Error("Error:\n" + DisplayName + " Error happened, stop current script.");

                    }
                }
                //handle the get value here
                var action = stepElement.GetAttributeValue("Action");
                if (action.Equals("GetValue"))
                {
                    var data = stepElement.GetAttributeValue("Data");
                    if (!string.IsNullOrEmpty(data))
                    {
                        var pos = data.IndexOf("=>", StringComparison.Ordinal);
                        try
                        {
                            //var attr = data.Substring(0, pos);
                            var variable = data.Substring(pos + 2);
                            if (!string.IsNullOrEmpty(variable))
                            {
                                var value = stepElement.GetAttributeValue(variable);
                                if (!string.IsNullOrEmpty(value))
                                {

                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error(ExceptionHelper.FormatStackTrace("GetValue Failed:", ex));
                        }
                    }
                }
                //result.SetAttributeValue(Constants.UI_OBJECT, UIObject);
                stepElement.SetAttributeValue(Constants._TYPE, "Result");
                DBFactory.GetData().Save(stepElement);
            }
            SetFinalResult();
        }
开发者ID:bperreault,项目名称:autox,代码行数:82,代码来源:CallTestScreenActivity.cs

示例3: InternalExecute

        private void InternalExecute(NativeActivityContext context, ActivityInstance instance)
        {
            //this method turn async way to sync.

            //grab the index of the current Activity
            var currentActivityIndex = _currentIndex.Get(context);
            if (currentActivityIndex > 0)
            {
                var lastChild = children[currentActivityIndex - 1];
                //Get result here, it is sync or async????
                RunningResult = RunningResult && ((IPassData)lastChild).GetResult();

                if (!RunningResult)
                {
                    if (ErrorLevel == OnError.AlwaysReturnTrue)
                        RunningResult = true;
                    if (ErrorLevel == OnError.Terminate)
                    {
                        Log.Fatal("Workflow terminated according OnError.Terminate");
                        context.Abort();
                    }
                    if (ErrorLevel == OnError.Continue)
                    {
                        //do nothing, just continue
                    }
                    if (ErrorLevel == OnError.JustShowWarning)
                    {
                        Log.Warn("Warning:\n" + lastChild.DisplayName + " Error happened, but we ignore it");
                        RunningResult = true;
                    }
                    if (ErrorLevel == OnError.StopCurrentScript)
                    {
                        Log.Error("Error:\n" + lastChild.DisplayName + " Error happened, stop current script.");
                        return;
                    }
                }
                //set variables value ((AutomationActivity)nextChild).Name to _runningResult
                AddVariable(lastChild.DisplayName.Replace(" ", "_").Replace(":", "_"), RunningResult.ToString());
                SetVariableValueByContext(context, lastChild.DisplayName.Replace(" ", "_").Replace(":", "_"), RunningResult.ToString());
            }
            if (currentActivityIndex == children.Count)
            {
                //if the currentActivityIndex is equal to the count of MySequence's Activities
                //Suite is complete, then we close the browser here
                //TODO please reconsider here, this means: suite must be totally independent, it will open & close browser itself. Then if it is called by others, must be very careful!!!!!!
                var steps =
                    XElement.Parse("<AutoX.Steps  OnError=\"" + ErrorLevel + "\" InstanceId=\"" + InstanceId + "\"/>");
                var close = XElement.Parse("<Step Action=\"Close\" />");
                steps.Add(close);
                Host.SetCommand(steps);
                Host.GetResult();
                return;
            }

            if (_onChildComplete == null)
            {
                //on completion of the current child, have the runtime call back on this method
                _onChildComplete = InternalExecute;
            }

            //grab the next Activity in MySequence.Activities and schedule it
            var nextChild = children[currentActivityIndex];
            var childEnabled = false;
            var child = nextChild as AutomationActivity;
            if (child != null)
            {
                child.SetHost(Host);
                child.InstanceId = InstanceId;
                child.SetParentResultId(ResultId);
                childEnabled = child.Enabled;
            }
            //if enabled, run it, don't think to use while, it is a recursive, async cycle here!
            if (childEnabled)
            {
                context.ScheduleActivity(nextChild, _onChildComplete);

            }
            //increment the currentIndex
            _currentIndex.Set(context, ++currentActivityIndex);
        }
开发者ID:bperreault,项目名称:autox,代码行数:80,代码来源:TestSuiteActivity.cs


注:本文中的NativeActivityContext.Abort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。