internal PowerShellResults <JsonDictionary <object> > GetProgress(string progressId, bool async) { string text = this.workflow ?? "GetProgress"; if (!string.IsNullOrEmpty(this.schema) && this.IsWorkflowDefined(text)) { return(this.ExecuteProgressWorkflow(text, progressId)); } if (async) { DDIHelper.ProgressIdForGetListAsync = progressId; DDIParameters ddiparameters = new DDIParameters(); AsyncGetListContext registeredContext = AsyncServiceManager.GetRegisteredContext(progressId); Dictionary <string, object> dictionary; if (registeredContext != null && registeredContext.Parameters != null && registeredContext.Parameters.Parameters != null) { dictionary = registeredContext.Parameters.Parameters.RawDictionary; } else { dictionary = new Dictionary <string, object>(); } if (registeredContext != null && !string.IsNullOrEmpty(registeredContext.WorkflowOutput)) { dictionary["workflowOutput"] = registeredContext.WorkflowOutput; } dictionary["ProgressId"] = progressId; ddiparameters.Parameters = new JsonDictionary <object>(dictionary); return(this.GetListCommon(ddiparameters, null, true)); } return(AsyncServiceManager.GetProgress(progressId)); }
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); }
private void AddSortDataForAsynchronousGetList(PowerShellResults <JsonDictionary <object> > results, List <JsonDictionary <object> > outputs, IList <string> outputList, List <string> unicodeColumnNames) { AsyncGetListContext asyncGetListContext = results.AsyncGetListContext; if (asyncGetListContext != null) { int count = unicodeColumnNames.Count; if (outputs != null && outputs.Count > 0) { if (asyncGetListContext.UnicodeColumns == null) { asyncGetListContext.UnicodeColumns = new List <Tuple <int, string[], string> >(Math.Max(outputs.Count, DDIHelper.GetListDefaultResultSize * 4)); } int m = 0; int num = asyncGetListContext.UnicodeColumns.Count; while (m < outputs.Count) { Dictionary <string, object> rawDictionary = outputs[m].RawDictionary; string[] array = new string[count]; for (int j = 0; j < count; j++) { array[j] = (string)rawDictionary[unicodeColumnNames[j]]; } string rawIdentity = ((Identity)rawDictionary["Identity"]).RawIdentity; asyncGetListContext.UnicodeColumns.Add(new Tuple <int, string[], string>(num, array, rawIdentity)); m++; num++; } if (asyncGetListContext.Completed) { WSListDataHandler.< > c__DisplayClassc CS$ < > 8__locals1 = new WSListDataHandler.< > c__DisplayClassc(); List <Tuple <int, string[], string> > unicodeColumns = asyncGetListContext.UnicodeColumns; results.SortColumnNames = unicodeColumnNames.ToArray(); results.SortDataRawId = new string[unicodeColumns.Count]; for (int k = 0; k < unicodeColumns.Count; k++) { results.SortDataRawId[k] = unicodeColumns[k].Item3; } results.SortData = new int[unicodeColumnNames.Count][]; CS$ < > 8__locals1.culture = CultureInfo.CurrentCulture; int i; for (i = 0; i < unicodeColumnNames.Count; i++) { string text = unicodeColumnNames[i]; results.SortData[i] = new int[unicodeColumns.Count]; unicodeColumns.Sort((Tuple <int, string[], string> tuple1, Tuple <int, string[], string> tuple2) => string.Compare(tuple1.Item2[i], tuple2.Item2[i], true, CS$ < > 8__locals1.culture)); int num2 = -1; Tuple <int, string[], string> tuple = null; for (int l = 0; l < unicodeColumns.Count; l++) { Tuple <int, string[], string> tuple3 = unicodeColumns[l]; if (tuple == null || !string.Equals(tuple.Item2[i], tuple3.Item2[i], StringComparison.CurrentCultureIgnoreCase)) { num2++; } results.SortData[i][tuple3.Item1] = num2; tuple = tuple3; } } } } } }