public override Command Create() { Command command = new Command("incremental") { _idOption, _scriptNameOption, }; command.Description = CLITextResources.CreateNewIncrementalScriptFileCommandDescription; command.Handler = CommandHandler.Create <string, string>((id, scriptName) => { _consoleProcessMessages.StartProcessMessage("new incremental", id); _consoleProcessMessages.StartSpiiner(); ProcessResults processResults = _dbVersionsAPI.CreateNewIncrementalScriptFile(id, scriptName, _consoleProcessMessages.OnNotificationStateChanged); _consoleProcessMessages.StopSpinner(); _consoleProcessMessages.ProcessComplete(processResults); if (!processResults.Trace.HasError) { string newFilePath = (string)processResults.Results; _consoleProcessMessages.SetInfoMessage(CLITextResources.TheFileIsCreatedInfoMessage.Replace("[newFilePath]", newFilePath)); } }); return(command); }
public void ProcessComplete(ProcessResults processReults) { processReults.ThrowIfNull(nameof(processReults)); ClearConsoleLine(0); lock (CLIConsts.ConsolWriteSync) { if (processReults.Trace.HasError) { if (processReults.Trace.NotificationErrorType == NotificationErrorType.Attention) { SetErrorInstruction(processReults.Trace.InstructionsMessage, processReults.Trace.NotificationErrorType); } else { SetErrorInstruction(CLITextResources.ProcessCompleteWithErrors, NotificationErrorType.Error); SetErrorInstruction("--------------------------------", NotificationErrorType.Error); SetErrorMessage(processReults.Trace.GetOnlyErrorsStatesLogAsString()); SetErrorInstruction(processReults.Trace.InstructionsMessage, processReults.Trace.NotificationErrorType); } } else { _console.ForegroundColor = ConsoleColor.Green; _console.Out.WriteLine(CLITextResources.ProcessCompleteSuccessfully); _console.ForegroundColor = ConsoleColor.White; } _console.ForegroundColor = ConsoleColor.White; } }
private ProcessResults ProcessNewMessages(IList <GroupMessage> raw) { var results = new ProcessResults(); //process messages in batches to reduce the size of the Transactions //and have less loss due to an error const int batchSize = 10; for (int start = 0; start < raw.Count; start += batchSize) { NH.UsingSession(s => { var battle = s.Get <Battle>(settings.BattleId.Value); var p = new IntelReportProcessor(s, battle); for (int i = start; i < raw.Count && i < (start + batchSize); ++i) { bool isBot; p.ProcessMessage(raw[i], out isBot); results.LastMessageWasBot = isBot; s.Flush(); } results.NewStatsCount += p.NewStatsCount; }); } return(results); }
public static void TestingChain() { DelegateChain dc1 = new DelegateChain(1.5); DelegateChain dc2 = new DelegateChain(2.5); ProcessResults[] delegates = { dc1.Compute, dc2.Compute, DelegateChain.StaticCompute, }; ProcessResults cheined = delegates[0] + delegates[1] + delegates[2]; Delegate[] chain = cheined.GetInvocationList(); double acc = 0; for (var i = 0; i < chain.Length; i++) { ProcessResults current = (ProcessResults)chain[i]; acc += current(4, 5); } Console.WriteLine($"Accumulator: {acc}"); double combined = cheined(4, 5); Console.WriteLine($"Combined: {combined}"); }
private void AppendRepeatableCommand(Command command) { Command repeatableCommand = new Command("repeatable") { _idOption, }; repeatableCommand.Description = CLITextResources.FilesSignleTypeCommandDescription.Replace("[ScriptFileType]", "Repeatable"); repeatableCommand.Handler = CommandHandler.Create <string>((id) => { _consoleProcessMessages.StartProcessMessage("files repeatable", id); _consoleProcessMessages.StartSpiiner(); ProcessResults processResults = _dbVersionsAPI.GetScriptFilesState(id, _consoleProcessMessages.OnNotificationStateChanged); _consoleProcessMessages.StopSpinner(); _consoleProcessMessages.ProcessComplete(processResults); if (!processResults.Trace.HasError) { ScriptFilesState scriptFilesState = processResults.Results as ScriptFilesState; RenderFilesList(scriptFilesState.RepeatableScriptFilesComparer); } }); command.Add(repeatableCommand); }
private void AppendDevDummyDataCommand(Command command) { Command incrementalCommand = new Command("ddd") { _idOption, }; incrementalCommand.Description = CLITextResources.FilesSignleTypeCommandDescription.Replace("[ScriptFileType]", "DevDummyData"); incrementalCommand.Handler = CommandHandler.Create <string>((id) => { _consoleProcessMessages.StartProcessMessage("files ddd", id); _consoleProcessMessages.StartSpiiner(); ProcessResults processResults = _dbVersionsAPI.GetScriptFilesState(id, _consoleProcessMessages.OnNotificationStateChanged); _consoleProcessMessages.StopSpinner(); _consoleProcessMessages.ProcessComplete(processResults); if (!processResults.Trace.HasError) { ScriptFilesState scriptFilesState = processResults.Results as ScriptFilesState; if (scriptFilesState.DevDummyDataScriptFilesComparer != null) { RenderFilesList(scriptFilesState.DevDummyDataScriptFilesComparer); } } }); command.Add(incrementalCommand); }
public void AfterComplete(ProcessResults processResults) { processResults.ThrowIfNull(nameof(processResults)); _processTrace = processResults.Trace; System.Threading.Thread.Sleep(500); if (_processTrace.HasError) { NotificationsViewModelData.ProcessStatusMessage = _processTrace.InstructionsMessage; //$"{_processTrace.InstructionsMessage} -> {_processTrace.ErrorMessage}"; NotificationsViewModelData.NotificationStatus = _processTrace.NotificationErrorType switch { NotificationErrorType.Error => NotificationStatus.Error, NotificationErrorType.Attention => NotificationStatus.Attention, _ => throw new Exception($"Invalid NotificationErrorType '{_processTrace.NotificationErrorType}'"), }; } else { NotificationsViewModelData.NotificationStatus = NotificationStatus.CompleteSuccessfully; NotificationsViewModelData.ProcessStatusMessage = UITextResources.CompleteSuccessfullyMessage; } }
public override Command Create() { Command command = new Command("environment") { _idOption, _devEnvironmentOption, }; command.Description = CLITextResources.EnvironmentCommandDescription; command.Handler = CommandHandler .Create <string, bool>((id, dev) => { _consoleProcessMessages.StartProcessMessage("environment", id); ProjectConfigItem existProjectConfig = _projectConfigsAPI.GetProjectConfigById(id); if (existProjectConfig == null) { _consoleProcessMessages.SetErrorInstruction(CLITextResources.IdNotExistCommandError.Replace("[Id]", id), NotificationErrorType.Error); } else { existProjectConfig.DevEnvironment = dev; _consoleProcessMessages.StartSpiiner(); ProcessResults processResults = _projectConfigsAPI.UpdateProjectConfig(existProjectConfig, _consoleProcessMessages.OnNotificationStateChanged); _consoleProcessMessages.StopSpinner(); _consoleProcessMessages.ProcessComplete(processResults); } }); return(command); }
public override Command Create() { Command command = new Command("virtual") { _idOption, _incTargetCLIOption, }; command.Description = CLITextResources.VirtualCommandDescription; command.Handler = CommandHandler.Create <string, string>((id, incTarget) => { _consoleProcessMessages.StartProcessMessage("virtual", id); _consoleProcessMessages.StartSpiiner(); TargetScripts targetScripts = new TargetScripts(incTarget); ProcessResults processResults = _dbVersionsAPI.SetDBStateByVirtualExecution(id, targetScripts, _consoleProcessMessages.OnNotificationStateChanged); _consoleProcessMessages.StopSpinner(); _consoleProcessMessages.ProcessComplete(processResults); }); return(command); }
static void Main(string[] args) { Processor proc1 = new Processor(0.75); Processor proc2 = new Processor(0.83); ProcessResults[] delegates = new ProcessResults[] { proc1.Compute, proc2.Compute, Processor.StaticCompute }; ProcessResults chained = delegates[0] + delegates[1] + delegates[2]; Delegate[] chain = chained.GetInvocationList(); double accumulator = 0; for (int i = 0; i < chain.Length; i++) { ProcessResults current = chain[i] as ProcessResults; if (current != null) { accumulator += current(4, 5); } } Console.WriteLine("Output: {0}", accumulator); Console.ReadKey(); }
public override Command Create() { Command command = new Command("deploy") { _idOption, }; command.Description = CLITextResources.DeployCommandDescription; command.Handler = CommandHandler.Create <string>((id) => { _consoleProcessMessages.StartProcessMessage("deploy", id); _consoleProcessMessages.StartSpiiner(); ProcessResults processResults = _dbVersionsAPI.Deploy(id, _consoleProcessMessages.OnNotificationStateChanged); _consoleProcessMessages.StopSpinner(); _consoleProcessMessages.ProcessComplete(processResults); if (!processResults.Trace.HasError) { string deployFilePath = (string)processResults.Results; _consoleProcessMessages.SetInfoMessage(CLITextResources.ArtifactFileCreatedInfoMessage.Replace("[deployFilePath]", deployFilePath)); } }); return(command); }
public static async Task <string[]> RunAsync(string name, string args, CancellationToken token, bool logVerbose = true) { var info = new ProcessStartInfo { FileName = name, Arguments = args, RedirectStandardInput = true, }; Action <string> onStdout = (string o) => Log.Verbose(o); Action <string> onStderr = (string e) => Log.Verbose(e); if (!logVerbose) { onStdout = (string o) => { }; onStderr = (string e) => { }; } using (ProcessResults result = await ProcessEx.RunAsync(info, onStdout, onStderr, token)) { if (result.ExitCode != 0) { throw new Win32Exception(result.ExitCode); } return(result.StandardOutput); } }
public override Command Create() { Command command = new Command("init") { _idOption, _descriptionOption, _dbTypeOption, _serverOption, _dbNameOption, _usernameOption, _passwordOption, _backupFolderPathOption, _devEnvironmentOption, _scriptsBaseFolderPathOption, _deployArtifactFolderPathOption, _deliveryArtifactFolderPathOption, }; command.Description = CLITextResources.InitCommandDescription; command.Handler = CommandHandler .Create((ProjectConfigItem projectConfig) => { _consoleProcessMessages.StartProcessMessage("init", projectConfig.Id); _consoleProcessMessages.StartSpiiner(); ProcessResults processResults = _projectConfigsAPI.SaveNewProjectConfig(projectConfig, _consoleProcessMessages.OnNotificationStateChanged); _consoleProcessMessages.StopSpinner(); _consoleProcessMessages.ProcessComplete(processResults); }); return(command); }
public ActionResult LogIn(int?id) { if (id != null) { ViewBag.Result = ProcessResults.GetById(id.Value); } return(View()); }
public ActionResult Sources(int?result) { if (result.HasValue) { ViewBag.Result = ProcessResults.GetById(result.Value); } return(View(DataManager.Source.GetSources())); }
public ActionResult GetConcepts(int?result) { if (result.HasValue) { ViewBag.Result = ProcessResults.GetById(result.Value); } return(View(DataManager.Concept.GetConcepts(confirmed: false))); }
public ActionResult AddClassification(int?result) { if (result.HasValue) { ViewBag.Result = ProcessResults.GetById(result.Value); } return(View()); }
public ActionResult EditConcept(int id, int?result) { if (result.HasValue) { ViewBag.Result = ProcessResults.GetById(result.Value); } return(View(DataManager.Concept.GetConcept(id))); }
public ActionResult AddBranch(int enterpriseId, int?id) { if (id != null) { ViewBag.Result = ProcessResults.GetById(id.Value); } ViewBag.EntId = enterpriseId; return(View()); }
public ActionResult AddDefinition(int id, int?result) { if (result.HasValue) { ViewBag.Result = ProcessResults.GetById(result.Value); } ViewBag.ConceptId = id; return(View()); }
// // GET: /Home/ public ActionResult Index(int?result) { string s = HttpContext.Request.PhysicalApplicationPath; if (result.HasValue) { ViewBag.Result = ProcessResults.GetById(result.Value); } return(View((Object)s)); }
public ActionResult Definition(int id, int?result) { var definition = DataManager.Concept.GetDefinition(id); if (result.HasValue) { ViewBag.Result = ProcessResults.GetById(result.Value); } return(View(definition)); }
public ActionResult Classifications(int?result) { if (result.HasValue) { ViewBag.Result = ProcessResults.GetById(result.Value); } var f = DataManager.Classification.GetClassifications(); return(View(DataManager.Classification.GetClassifications())); }
public ActionResult AddSource(int?result) { var user = DataManager.DefineUser(HttpContext); if (result.HasValue) { ViewBag.Result = ProcessResults.GetById(result.Value); } return(View()); }
private void AddCleanerLogInfo(string description = "New Description") { var newLog = new CleanerLogInfo { Description = description, Severity = EventTypes.ErrorSeverity.Error }; ProcessResults.Add(newLog); }
/// <summary> /// Fonction exécuter lorsque des erreurs de validations d'affaires survient. /// </summary> /// <param name="view"> Référence de la vue implémenter par le formulaire </param> /// <param name="formatedMessage"> Message d'erreur pré-formaté </param> /// <param name="returnMessageList"> Liste des erreurs </param> /// <param name="presenterBase"> Référence du présenteur </param> public virtual void PublishBusinessValidations(View view, string formatedMessage, ProcessResults rules, IPresenterBase presenterBase) { //ProcessResults pr = new ProcessResults(); //foreach (var item in rules) //{ // pr.AddException(item); //} view.ShowBusinessValidationMessage(PresenterResources.ERR_BUSINESSVALIDATION, rules); }
public async Task <MutantTestResults> RunTests( string inputFile, string outputFile) { _log.Debug("Running tests on: " + inputFile); try { ProcessResults results = await RunNUnitConsole(_nUnitConsolePath, inputFile, outputFile); _log.Debug("Process finished."); if (!_svc.FileSystem.File.Exists(outputFile)) { string output = results.StandardOutput .Concat(results.StandardError) .Aggregate((a, b) => a + "\n" + b); if (output.Contains("Process is terminated due to StackOverflowException.")) { TmpTestNodeMethod node = new TmpTestNodeMethod("One of the tests."); node.State = TestNodeState.Failure; node.Message = "One of the tests threw StackOverflowException."; _log.Info("XUnit: One of the tests threw StackOverflowException."); return(new MutantTestResults(new List <TmpTestNodeMethod> { node })); } else { throw new Exception("Test results in file: " + outputFile + " not found. Output: " + output); } } else { Dictionary <string, TmpTestNodeMethod> tresults = _parser.ProcessResultFile(outputFile); List <TmpTestNodeMethod> testResults = tresults.Values.ToList(); var count = testResults .Select(t => t.State).GroupBy(t => t) .ToDictionary(t => t.Key, t => t.Count()); _log.Info(string.Format("XUnit test results: Passed: {0}, Failed: {1}, Inconc: {2}", count.GetOrDefault(TestNodeState.Success), count.GetOrDefault(TestNodeState.Failure), count.GetOrDefault(TestNodeState.Inconclusive))); return(new MutantTestResults(testResults)); } } catch (OperationCanceledException) { _log.Error("Test run cancelled."); return(new MutantTestResults(cancelled: true)); } }
public override Command Create() { Command command = new Command("config") { _idOption, _descriptionOption, _dbTypeOption, _serverInstanceOption, _dataBaseNameOption, _dbUsernameOption, _dbPasswordOption, _backupFolderPathOption, _scriptsBaseFolderPathOption, _deployArtifactFolderPathOption, _deliveryArtifactFolderPathOption, }; command.Description = CLITextResources.ConfigCommandDescription; command.Handler = CommandHandler .Create((ProjectConfigItem projectConfig) => { _consoleProcessMessages.StartProcessMessage("config", projectConfig.Id); ProjectConfigItem existProjectConfig = _projectConfigsAPI.GetProjectConfigById(projectConfig.Id); if (existProjectConfig == null) { _consoleProcessMessages.SetErrorInstruction(CLITextResources.IdNotExistCommandError.Replace("[Id]", projectConfig.Id), NotificationErrorType.Error); } else { OverrideProjectConfigProperties(existProjectConfig, projectConfig); _consoleProcessMessages.StartSpiiner(); ProcessResults processResults = _projectConfigsAPI.UpdateProjectConfig(existProjectConfig, _consoleProcessMessages.OnNotificationStateChanged); _consoleProcessMessages.StopSpinner(); _consoleProcessMessages.ProcessComplete(processResults); } }); Command changeIdCommand = _changeIdCommandFactory.Create(); command.Add(changeIdCommand); Command environmentCommand = _environmentCommandFactory.Create(); command.Add(environmentCommand); return(command); }
public ActionResult EditBrand(int id, int?result) { var user = DefineUser(); if (HasNoAccess(user)) { return(NoPermission()); } if (result.HasValue) { ViewBag.Result = ProcessResults.GetById(result.Value); } return(View(DataManager.Cars.GetBrand(id))); }
public ActionResult AddBrand(int?result) { var user = DefineUser(); if (HasNoAccess(user)) { return(NoPermission()); } if (result.HasValue) { ViewBag.Result = ProcessResults.GetById(result.Value); } return(View()); }
private static void AssertSuccessfulProcessCompletion(ProcessResults result) { Assert.NotNull(result); Assert.NotEqual(1, result.Process.ExitCode); Assert.Empty(result.StandardError); }
/// <summary> /// Runs a PowerShell command/script asynchronously. /// </summary> /// <param name="commandText">The text of the command to run.</param> /// <param name="pool">An open PowerShell Runspace pool this script will use to invoke its pipeline.</param> /// <param name="callback">The callback function used to process the results of the asynchronous run.</param> /// <param name="log">[Optional] The event log to log execptions to. May be null for no logging.</param> /// <param name="input">[Optional] A collection of strings representing command-line input sent to the script during execution.</param> /// <param name="stateValues">[Optional] A collection of named state values that should be passed through the invocation to the callback function.</param> /// <param name="parameterList">An array of key/value objects defining additional parameters to supply to the PowerShell script.</param> /// <returns>An WaitHandle object that can be used to determine when the scrip has completed execution. Null if an error occurred while processing the command / script.</returns> public static WaitHandle RunAsynchronously(string commandText, ref RunspacePool pool, ProcessResults callback, EventLog.EventLog log = null, PSDataCollection<string> input = null, Dictionary<String, Object> stateValues = null, params KeyValuePair<String, Object>[] parameterList) { try { // Create the script object. PS script = PS.Create(); // Use the runspace pool supplied or create a new one if not supplied. if (pool == null) { pool = RunspaceFactory.CreateRunspacePool(DEFAULT_MIN_RUNSPACES_IN_POOL, DEFAULT_MAX_RUNSPACES_IN_POOL, CreateRunspaceConnectionInfo()); } // Verify that the pool is open, otherwise open it. if (pool.RunspacePoolStateInfo.State != RunspacePoolState.Opened) { pool.Open(); } // Add the runspace pool to the script object. script.RunspacePool = pool; // Create the PowerShell command object. Command command = new Command(commandText, true); // Add parameters to the command. if (parameterList != null) { foreach (KeyValuePair<string, object> param in parameterList) { command.Parameters.Add(new CommandParameter(param.Key, param.Value)); } } // Add the command to the script object. script.Commands.AddCommand(command); // Initialize the script input object if nothing was supplied. if (input == null) { input = new PSDataCollection<string>(); } // Initialize the state object to maintain data across the invocation. PowerShellScriptState state = new PowerShellScriptState(script); // Add the callback function used to process the results of the script invocation. state.StateVariables.Add(PROCESS_RESULTS_CALLBACK, callback); // Add any state values passed into the method. if (stateValues != null) { foreach (string key in stateValues.Keys) { state.StateVariables.Add(key, stateValues[key]); } } // Invoke the command asyncronously. return (script.BeginInvoke(input, new PSInvocationSettings(), ProcessAsynchronousResults, state)).AsyncWaitHandle; } catch (Exception e) { LogException(e, log); return null; } }