コード例 #1
0
        public PowerShellResults <JsonDictionary <object> > Execute()
        {
            PowerShellResults <JsonDictionary <object> > result;

            using (EcpPerformanceData.DDIServiceExecution.StartRequestTimer())
            {
                switch (this.ExecutingWorkflow.AsyncMode)
                {
                case AsyncMode.AsynchronousOnly:
                    this.ExecutingWorkflow.AsyncRunning = true;
                    break;

                case AsyncMode.SynchronousAndAsynchronous:
                    this.ExecutingWorkflow.AsyncRunning = (base.DataObjectStore.AsyncType == ListAsyncType.GetListAsync || base.DataObjectStore.AsyncType == ListAsyncType.GetListPreLoad);
                    break;
                }
                if (!this.ExecutingWorkflow.AsyncRunning || DDIHelper.ForGetListProgress)
                {
                    result = this.ExecuteCore(this.ExecutingWorkflow);
                }
                else
                {
                    if (!typeof(ProgressCalculatorBase).IsAssignableFrom(this.ExecutingWorkflow.ProgressCalculator))
                    {
                        throw new ArgumentException("A valid ProgressCalculator type must be specified for async running workflow.");
                    }
                    Func <PowerShellResults> callback = delegate()
                    {
                        IList <string>      outputVariables     = this.GetOutputVariables(this.OutputVariableWorkflow);
                        AsyncGetListContext asyncGetListContext = new AsyncGetListContext
                        {
                            WorkflowOutput           = string.Join(",", outputVariables ?? ((IList <string>)Array <string> .Empty)),
                            UnicodeOutputColumnNames = this.GetUnicodeVariablesFrom(outputVariables),
                            Parameters = this.parameters
                        };
                        AsyncServiceManager.RegisterWorkflow(this.ExecutingWorkflow, asyncGetListContext);
                        return(this.ExecuteCore(this.ExecutingWorkflow));
                    };
                    AsyncTaskType taskType = AsyncTaskType.Default;
                    string        text     = this.ExecutingWorkflow.Name;
                    if (base.DataObjectStore.AsyncType == ListAsyncType.GetListAsync)
                    {
                        taskType = AsyncTaskType.AsyncGetList;
                    }
                    else if (base.DataObjectStore.AsyncType == ListAsyncType.GetListPreLoad)
                    {
                        taskType = AsyncTaskType.AsyncGetListPreLoad;
                        text    += "_PreLoad";
                    }
                    PowerShellResults powerShellResults = AsyncServiceManager.InvokeAsync(callback, null, this.UniqueLogonUserIdentity, taskType, text);
                    result = new PowerShellResults <JsonDictionary <object> >
                    {
                        ProgressId   = powerShellResults.ProgressId,
                        ErrorRecords = powerShellResults.ErrorRecords
                    };
                }
            }
            return(result);
        }
コード例 #2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="AsyncTaskInfo" /> class.
 /// </summary>
 /// <param name="friendlyName">Friendly name of the async delegate.</param>
 /// <param name="isDelegateWorker">
 ///     if set to <c>true</c> the information represents an
 ///     <see cref="IAsyncDelegateDequeuer" />, otherwise an <see cref="IAsyncLoop" />.
 /// </param>
 public AsyncTaskInfo(string friendlyName, AsyncTaskType type)
 {
     this.FriendlyName = friendlyName;
     this.Type         = type;
 }
コード例 #3
0
        public static PowerShellResults InvokeAsync(Func <PowerShellResults> callback, Action <PowerShellResults> onCompleted, string uniqueUserIdentity, AsyncTaskType taskType, string commandStringForTrace)
        {
            AsyncServiceManager.AsyncTaskBudgetManager asyncTaskBudget;
            ThrottlingType throttlingType;

            switch (taskType)
            {
            case AsyncTaskType.AsyncGetList:
                asyncTaskBudget = AsyncServiceManager.getListAsyncTaskBudget;
                throttlingType  = ThrottlingType.Default;
                break;

            case AsyncTaskType.AsyncGetListPreLoad:
                asyncTaskBudget = AsyncServiceManager.getListAsyncTaskBudget;
                throttlingType  = ThrottlingType.PerUser;
                break;

            default:
                asyncTaskBudget = AsyncServiceManager.defaultAsyncTaskBudget;
                throttlingType  = ThrottlingType.Default;
                break;
            }
            return(AsyncServiceManager.InvokeAsyncCore(callback, onCompleted, uniqueUserIdentity, asyncTaskBudget, commandStringForTrace, throttlingType));
        }