/// <summary> /// Displays the form, launching the recording process /// </summary> /// <returns></returns> public new DialogResult ShowDialog() { this.opTimer.Enabled = true; this.operation = ProcessOperation.Check; this.pbCheckDiagram.Image = this.icons.Images[(int)OperationState.Running]; return(base.ShowDialog()); }
public ProcessWrapper(string fileName, string arguments, string workDir, bool createWindow, bool redirectInput, bool redirectOutput, [CanBeNull] Encoding outputEncoding) { Debug.Assert(redirectOutput == (outputEncoding != null), "redirectOutput == (outputEncoding != null)"); _redirectInput = redirectInput; _redirectOutput = redirectOutput; _process = new Process { EnableRaisingEvents = true, StartInfo = { UseShellExecute = false, ErrorDialog = false, CreateNoWindow = !createWindow, RedirectStandardInput = redirectInput, RedirectStandardOutput = redirectOutput, RedirectStandardError = redirectOutput, StandardOutputEncoding = outputEncoding, StandardErrorEncoding = outputEncoding, FileName = fileName, Arguments = arguments, WorkingDirectory = workDir } }; _logOperation = CommandLog.LogProcessStart(fileName, arguments, workDir); _process.Exited += OnProcessExit; _process.Start(); _logOperation.SetProcessId(_process.Id); }
private void ProcessChanged(int pid, string path, ProcessOperation po) { if (po == ProcessOperation.Modified) { return; } ProcessSettings ps = iss.FindByPath(path); if (ps == null || !ps.UsePassword) { return; } Task.Run(() => { switch (po) { case ProcessOperation.Started: if (path == null) { return; } Dispatcher?.Invoke(async() => { await ProcessAuthenticationViewModel.Lock(path); }); break; default: break; } }); }
public ProcessWrapper(string fileName, string arguments, string workDir, bool createWindow, bool redirectInput, bool redirectOutput, Encoding?outputEncoding, bool useShellExecute) { Debug.Assert(redirectOutput == (outputEncoding is not null), "redirectOutput == (outputEncoding is not null)"); _redirectInput = redirectInput; _redirectOutput = redirectOutput; _process = new Process { EnableRaisingEvents = true, StartInfo = { UseShellExecute = useShellExecute, Verb = useShellExecute ? "open" : string.Empty, ErrorDialog = false, CreateNoWindow = !createWindow, RedirectStandardInput = redirectInput, RedirectStandardOutput = redirectOutput, RedirectStandardError = redirectOutput, StandardOutputEncoding = outputEncoding, StandardErrorEncoding = outputEncoding, FileName = fileName, Arguments = arguments, WorkingDirectory = workDir } }; _logOperation = CommandLog.LogProcessStart(fileName, arguments, workDir); _process.Exited += OnProcessExit; try { _process.Start(); try { _logOperation.SetProcessId(_process.Id); } catch (InvalidOperationException ex) when(useShellExecute) { // _process.Start() has succeeded, ignore the failure getting the _process.Id _logOperation.LogProcessEnd(ex); } } catch (Exception ex) { Dispose(); _logOperation.LogProcessEnd(ex); throw new ExternalOperationException(fileName, arguments, workDir, ex); } }
public override void StartProcess(string command, string arguments, string workDir, Dictionary <string, string> envVariables) { ProcessOperation operation = CommandLog.LogProcessStart(command, arguments, workDir); try { var commandLine = new ArgumentBuilder { command.Quote(), arguments }.ToString(); ConsoleCommandLineOutputProcessor outputProcessor = new(commandLine.Length, FireDataReceived); ConEmuStartInfo startInfo = new() { ConsoleProcessCommandLine = commandLine, IsEchoingConsoleCommandLine = true, WhenConsoleProcessExits = WhenConsoleProcessExits.KeepConsoleEmulatorAndShowMessage, AnsiStreamChunkReceivedEventSink = outputProcessor.AnsiStreamChunkReceived, StartupDirectory = workDir }; foreach (var(name, value) in envVariables) { startInfo.SetEnv(name, value); } startInfo.ConsoleProcessExitedEventSink = (_, args) => { _nLastExitCode = args.ExitCode; operation.LogProcessEnd(_nLastExitCode); outputProcessor.Flush(); FireProcessExited(); }; startInfo.ConsoleEmulatorClosedEventSink = (sender, _) => { Validates.NotNull(_terminal); if (sender == _terminal.RunningSession) { FireTerminated(); } }; Validates.NotNull(_terminal); _terminal.Start(startInfo, ThreadHelper.JoinableTaskFactory, AppSettings.ConEmuStyle.Value, AppSettings.ConEmuConsoleFont.Name, AppSettings.ConEmuConsoleFont.Size.ToString(CultureInfo.InvariantCulture)); } catch (Exception ex) { operation.LogProcessEnd(ex); throw; } }
private void ProcessChanged(int pid, string path, ProcessOperation po) { try { if (po == ProcessOperation.Started) { if (path?.Equals(ProcessPath, SC.InvariantCultureIgnoreCase) == true) { Process p = Process.GetProcessById(pid); Processes.Add(p); if (Locked) { p.EnumerateProcessWindowHandles().ForEach(hWnd => { windowStates[hWnd] = NativeWindow.GetWindowState(hWnd); NativeWindow.ShowWindow(hWnd, ShowWindow.Hide); }); p.Suspend(); suspended[p.Id] = true; UI(ShowView); } } } if (po == ProcessOperation.Deleted) { if (path?.Equals(ProcessPath, SC.InvariantCultureIgnoreCase) == true) { Processes.Remove(Processes.FirstOrDefault(p => p.Id == pid)); suspended.Remove(pid); } if (Processes.Count == 0) { CloseView(); } } } catch { } }
private void EventArrived(object sender, EventArrivedEventArgs e) { ManagementBaseObject mbo = e.NewEvent["TargetInstance"] as ManagementBaseObject; ProcessOperation po = ProcessOperation.Started; switch (e.NewEvent.ClassPath.ClassName) { case "__InstanceModificationEvent": po = ProcessOperation.Modified; break; case "__InstanceDeletionEvent": po = ProcessOperation.Deleted; break; } ProcessChanged?.Invoke((int)(uint)mbo["ProcessId"], (string)mbo["ExecutablePath"], po); }
/// <summary> /// Parses the Input Arguments for the Operation Flag /// </summary> /// <param name="args">The arguments sent to this program.</param> /// <returns>The value of the Operation Flag; or <see cref="ProcessOperation.Default"/> if one is not provided.</returns> private static ProcessOperation _ParseForOperation(string[] args) { ProcessOperation result = ProcessOperation.Default; if (args.Any(currentArg => Regex.IsMatch(currentArg, @"(?i)^[-\/]+(irp{1}|identifyrequiredprojects)$"))) { result = ProcessOperation.IdentifyRequiredProjects; } if (args.Any(currentArg => Regex.IsMatch(currentArg, @"(?i)^[-\/]+(iap{1}|identifyaffectedprojects)$"))) { result = ProcessOperation.IdentifyAffectedProjects; } if (args.Any(currentArg => Regex.IsMatch(currentArg, @"(?i)^[-\/]+(iddc{1}|identifydirectdependencycounts)$"))) { result = ProcessOperation.IdentifyDirectDependencyCounts; } return(result); }
private void DoProcessOperation(string strExecutableFileName, ProcessOperation processOperation) { foreach (var process in Process.GetProcessesByName(strExecutableFileName)) { try { switch (processOperation) { case ProcessOperation.CloseMainWindow: process.CloseMainWindow(); return; case ProcessOperation.Kill: process.Kill(); return; } } catch (Exception) { } } }
/// <summary> /// End of recording /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void MController_ProgrammingCompleted(object sender, EventArgs e) { //An invocation is made to avoid problems between threads if (this.InvokeRequired) { this.Invoke(new EventHandler(this.MController_ProgrammingCompleted), new object[] { sender, e }); } else { try { //The message is displayed this.pbProgramMoway.Image = this.icons.Images[(int)OperationState.Finish]; this.lProgramMoway.Text = ProcessMessages.PROGRAMMOWAY_OK; this.operation = ProcessOperation.Close; //Timer is enabled to automatically close the window this.opTimer.Interval = 1000; this.opTimer.Enabled = true; } catch { } } }
/// <summary> /// Timer of launching operations /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OpTimer_Tick(object sender, EventArgs e) { //according to the operation to be executed switch (operation) { case ProcessOperation.Check: //The errors of all the diagrams are checked List <DiagramError> errors = new List <DiagramError>(); foreach (Diagram diagram in this.project.Functions) { Generator.CheckDiagram(diagram, errors); } //If there are errors, it is reported if (errors.Count != 0) { bool onlyWarnings = false; //the errors are checked foreach (DiagramError error in errors) { //If any of the errors is not a warning if (error.Type == ErrorType.Error) { onlyWarnings = true; this.opTimer.Enabled = false; //The Close button is enabled this.bClose.Enabled = true; //The error is displayed this.pbCheckDiagram.Image = this.icons.Images[(int)OperationState.Error]; this.lCheckDiagram.Text = ProcessMessages.CHECKDIAGRAM_ERROR; this.lCheckDiagram.ForeColor = Color.FromArgb(208, 0, 0); break; } } //If they are only warnings if (!onlyWarnings) { //The warning message is displayed this.pbCheckDiagram.Image = this.icons.Images[(int)OperationState.Warning]; this.lCheckDiagram.Text = ProcessMessages.CHECKDIAGRAM_WARNING; this.lCheckDiagram.ForeColor = Color.FromArgb(200, 140, 0); //it passes to the following operation this.operation = ProcessOperation.Generate; this.pbGenerateCode.Image = this.icons.Images[(int)OperationState.Running]; } //The error event is launched if (this.DiagramErrors != null) { this.DiagramErrors(this, new ProcessEventArgs(errors)); } } else { this.pbCheckDiagram.Image = this.icons.Images[(int)OperationState.Finish]; this.lCheckDiagram.Text = ProcessMessages.CHECKDIAGRAM_OK; //it passes to the following operation this.operation = ProcessOperation.Generate; this.pbGenerateCode.Image = this.icons.Images[(int)OperationState.Running]; } break; case ProcessOperation.Generate: //Generates the source code for the diagrams try { // The code is generated AsmGenerator.GenerateCode(this.project.MainFunction, this.project.Subfunctions, this.project.Variables, this.project.AsmFile); this.lGenerateCode.Text = ProcessMessages.GENERATECODE_OK; this.pbGenerateCode.Image = this.icons.Images[(int)OperationState.Finish]; //it passes to the following operation this.operation = ProcessOperation.Compile; this.pbCompileCode.Image = this.icons.Images[(int)OperationState.Running]; } catch { } break; case ProcessOperation.Compile: //The generated source code is compiled try { //The project is compiled if (AsmCompiler.Compile(this.project.AsmFile)) { this.lCompileCode.Text = ProcessMessages.COMPILECODE_OK; this.pbCompileCode.Image = this.icons.Images[(int)OperationState.Finish]; //it passes to the following operation this.operation = ProcessOperation.Program; this.opTimer.Interval = 50; this.pbProgramMoway.Image = this.icons.Images[(int)OperationState.Running]; } else { this.opTimer.Enabled = false; //The Close button is enabled this.bClose.Enabled = true; //The error is displayed this.pbCompileCode.Image = this.icons.Images[(int)OperationState.Error]; this.lCompileCode.ForeColor = Color.FromArgb(208, 0, 0); this.lCompileCode.Text = ProcessMessages.COMPILECODE_ERROR; } } //Code compilation failed catch (CompilerException ex) { this.opTimer.Enabled = false; //The Close button is enabled this.bClose.Enabled = true; //The error is displayed this.pbCompileCode.Image = this.icons.Images[(int)OperationState.Error]; this.lCompileCode.ForeColor = Color.FromArgb(208, 0, 0); switch (ex.Message) { case "File not found": this.lCompileCode.Text = ProcessMessages.FILE_NOT_FOUND; break; case "Access denied": this.lCompileCode.Text = ProcessMessages.ACCES_DENIED; break; default: this.lCompileCode.Text = ProcessMessages.COMPILECODE_ERROR; break; } } break; case ProcessOperation.Program: //Launches the recording process this.opTimer.Enabled = false; //MOway Driver events are logged Controller.Controller mController = Controller.Controller.GetController(); mController.ProgrammingProgress += new ProgressEventHandler(MController_ProgrammingProgress); mController.ProgrammingCompleted += new EventHandler(MController_ProgrammingCompleted); mController.ProgrammingCanceled += new EventHandler(MController_ProgrammingCanceled); try { //It checks the memory of the micro... int response = mController.CheckPicMemory(this.project.HexFile); if (response == 1) { //A confirmation is requested if (DialogResult.No == MowayMessageBox.Show(ProcessMessages.HEX_TOO_LARGE_201 + "\r\n" + ProcessMessages.CONTINUE, ProcessMessages.PROGRAM, MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) { //The Close button is enabled this.bClose.Enabled = true; //The error is displayed this.pbProgramMoway.Image = this.icons.Images[(int)OperationState.Error]; this.lProgramMoway.ForeColor = Color.FromArgb(208, 0, 0); this.lProgramMoway.Text = ProcessMessages.MEMORY_ERROR; return; } } else if (response == 2) { //A confirmation is requested if (DialogResult.No == MowayMessageBox.Show(ProcessMessages.HEX_TOO_LARGE_202 + "\r\n" + ProcessMessages.CONTINUE, ProcessMessages.PROGRAM, MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) { //The Close button is enabled this.bClose.Enabled = true; //The error is displayed this.pbProgramMoway.Image = this.icons.Images[(int)OperationState.Error]; this.lProgramMoway.ForeColor = Color.FromArgb(208, 0, 0); this.lProgramMoway.Text = ProcessMessages.MEMORY_ERROR; return; } } //Timer is enabled to limit the recording process to 15 seconds this.tProgramLimited.Enabled = true; //It launches the recording of the mOway mController.ProgramMoway(this.project.HexFile); } //Timer is enabled to limit the recording process to 15 seconds catch (ControllerException ex) { //The Close button is enabled this.bClose.Enabled = true; //The error is displayed this.pbProgramMoway.Image = this.icons.Images[(int)OperationState.Error]; this.lProgramMoway.ForeColor = Color.FromArgb(208, 0, 0); switch (ex.Message) { case "File not found": this.lProgramMoway.Text = ProcessMessages.FILE_NOT_FOUND; break; case "Moway disconnected": this.lProgramMoway.Text = ProcessMessages.MOWAY_DISCONNECTED; break; case "Moway busy": this.lProgramMoway.Text = ProcessMessages.MOWAY_BUSY; break; default: this.lProgramMoway.Text = ProcessMessages.PROGRAMMOWAY_ERROR; break; } } break; case ProcessOperation.Close: //Close the form this.DialogResult = DialogResult.OK; this.Close(); break; } }
static void Main(string[] args) { if (!args.Any()) { Console.WriteLine("You did not provide the required targetProject argument."); Environment.Exit(1); } // Get the DotGraph File string dotGraphFile = args.FirstOrDefault(); // See if the target project flag has been set string targetProject = _ParseForTargetProjectFlag(args); if (string.IsNullOrWhiteSpace(dotGraphFile) || !File.Exists(dotGraphFile)) { string missingDotGraphFile = "The Provided DotGraph Argument was not valid. This tool requires a valid DotGraph File."; Console.WriteLine(missingDotGraphFile); Environment.Exit(1); } if (string.IsNullOrWhiteSpace(targetProject)) { string missingTargetProject = "You must provide a `-TargetProject` to this tool."; Console.WriteLine(missingTargetProject); Environment.Exit(1); } ProcessOperation operation = _ParseForOperation(args); IDictionary <string, SortedSet <string> > loadedGraph = DotGraph.LoadDependencyGraph(dotGraphFile); string consoleOutput = string.Empty; switch (operation) { case ProcessOperation.Default: case ProcessOperation.IdentifyRequiredProjects: { consoleOutput = IdentifyRequiredProjects.Execute(targetProject, loadedGraph); break; } case ProcessOperation.IdentifyAffectedProjects: { consoleOutput = IdentifyAffectedProjects.Execute(targetProject, loadedGraph); break; } case ProcessOperation.IdentifyDirectDependencyCounts: { consoleOutput = IdentifyDirectDependencyCounts.Execute(targetProject, loadedGraph); break; } default: { Console.WriteLine($"Unknown Operation {operation.ToString()}"); Environment.Exit(1); break; } } Console.WriteLine(consoleOutput); }
public override bool Execute() { if (string.IsNullOrWhiteSpace(SccmToolsExe) || !File.Exists(SccmToolsExe)) { LogError($"Could not find sccmtools.exe '{SccmToolsExe}'", ContinueBuildOnFailure); return(ContinueBuildOnFailure); } if (!Directory.Exists(ApplicationTargetRootFolder)) { LogError($"Application source root folder (ApplicationTargetRootFolder={ApplicationTargetRootFolder}) does not exist.", ContinueBuildOnFailure); return(ContinueBuildOnFailure); } if (string.IsNullOrWhiteSpace(ApplicationSourceFolder) || !Directory.Exists(ApplicationSourceFolder)) { LogError($"Could not find application source folder '{ApplicationSourceFolder}'", ContinueBuildOnFailure); return(ContinueBuildOnFailure); } if (string.IsNullOrWhiteSpace(PackageDefinitionFile) || !File.Exists(PackageDefinitionFile)) { LogError($"Could not find package definition file '{PackageDefinitionFile}'", ContinueBuildOnFailure); return(ContinueBuildOnFailure); } Log.LogMessage(MessageImportance.Normal, $"Preparing to move '{ApplicationSourceFolder}' to application target root folder '{ApplicationTargetRootFolder}'"); var applicationFolderName = Path.GetFileName(ApplicationSourceFolder); var applicationTargetFolder = Path.Combine(ApplicationTargetRootFolder, applicationFolderName); if (Directory.Exists(applicationTargetFolder)) { LogError($"Application target folder '{applicationTargetFolder}' allready exists", ContinueBuildOnFailure); return(ContinueBuildOnFailure); } Log.LogMessage(MessageImportance.Normal, $"Moving '{ApplicationSourceFolder}'->'{applicationTargetFolder}'..."); var moved = MoveApplication(ApplicationSourceFolder, applicationTargetFolder); if (!moved) { LogError($"Failed to move application '{ApplicationSourceFolder}->{applicationTargetFolder}' allready exists", ContinueBuildOnFailure); return(ContinueBuildOnFailure); } var targetPackageDefinitionFile = PackageDefinitionFile.Replace(ApplicationSourceFolder, applicationTargetFolder); if (string.IsNullOrWhiteSpace(targetPackageDefinitionFile) || !File.Exists(targetPackageDefinitionFile)) { LogError($"Could not find target package definition file '{targetPackageDefinitionFile}'", ContinueBuildOnFailure); return(ContinueBuildOnFailure); } var sccmToolsExeArguments = $"CreateApplicationFromDefinition /packageDefinitionFile=\"{targetPackageDefinitionFile}\""; var exitCode = ProcessOperation.StartProcess(SccmToolsExe, sccmToolsExeArguments, OnOut, OnError, Log); if (exitCode != 0) { LogError("SccmTools.exe failed to create application.", ContinueBuildOnFailure); } return(ContinueBuildOnFailure || exitCode == 0); }
public override void StartProcess(string command, string arguments, string workDir, Dictionary <string, string> envVariables) { ProcessOperation operation = CommandLog.LogProcessStart(command, arguments, workDir); try { EnvironmentConfiguration.SetEnvironmentVariables(); bool ssh = GitSshHelpers.UseSsh(arguments); KillProcess(); // process used to execute external commands var outputEncoding = GitModule.SystemEncoding; var startInfo = new ProcessStartInfo { UseShellExecute = false, ErrorDialog = false, CreateNoWindow = !ssh && !AppSettings.ShowGitCommandLine, RedirectStandardInput = true, RedirectStandardOutput = true, RedirectStandardError = true, StandardOutputEncoding = outputEncoding, StandardErrorEncoding = outputEncoding, FileName = command, Arguments = arguments, WorkingDirectory = workDir }; foreach (var(name, value) in envVariables) { startInfo.EnvironmentVariables.Add(name, value); } var process = new Process { StartInfo = startInfo, EnableRaisingEvents = true }; process.OutputDataReceived += (sender, args) => FireDataReceived(new TextEventArgs((args.Data ?? "") + '\n')); process.ErrorDataReceived += (sender, args) => FireDataReceived(new TextEventArgs((args.Data ?? "") + '\n')); process.Exited += delegate { this.InvokeAsync( () => { if (_process is null) { operation.LogProcessEnd(new Exception("Process instance is null in Exited event")); return; } // The process is exited already, but this command waits also until all output is received. // Only WaitForExit when someone is connected to the exited event. For some reason a // null reference is thrown sometimes when staging/unstaging in the commit dialog when // we wait for exit, probably a timing issue... try { _process.WaitForExit(); } catch (Exception ex) { operation.LogProcessEnd(ex); } _exitcode = _process.ExitCode; operation.LogProcessEnd(_exitcode); _process = null; _outputThrottle?.FlushOutput(); FireProcessExited(); _outputThrottle?.Stop(flush: true); }).FileAndForget(); }; process.Start(); operation.SetProcessId(process.Id); _process = process; process.BeginOutputReadLine(); process.BeginErrorReadLine(); } catch (Exception ex) { operation.LogProcessEnd(ex); ex.Data.Add("command", command); ex.Data.Add("arguments", arguments); throw; } }
/// <summary> /// Timer of launching operations /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OpTimer_Tick(object sender, EventArgs e) { //according to the operation to be executed switch (operation) { case ProcessOperation.Check: //The errors of all the diagrams are checked List <DiagramError> errors = new List <DiagramError>(); foreach (Diagram diagram in this.project.Functions) { Generator.CheckDiagram(diagram, errors); } //If there are errors, it is reported if (errors.Count != 0) { bool onlyWarnings = false; //the errors are checked foreach (DiagramError error in errors) { //If any of the errors is not a warning if (error.Type == ErrorType.Error) { onlyWarnings = true; this.opTimer.Enabled = false; //The Close button is enabled this.bClose.Enabled = true; //The error is displayed this.pbCheckDiagram.Image = this.icons.Images[(int)OperationState.Error]; this.lCheckDiagram.Text = ProcessMessages.CHECKDIAGRAM_ERROR; this.lCheckDiagram.ForeColor = Color.FromArgb(208, 0, 0); break; } } //If they are only warnings if (!onlyWarnings) { //The warning message is displayed this.pbCheckDiagram.Image = this.icons.Images[(int)OperationState.Warning]; this.lCheckDiagram.Text = ProcessMessages.CHECKDIAGRAM_WARNING; this.lCheckDiagram.ForeColor = Color.FromArgb(200, 140, 0); //it passes to the following operation this.operation = ProcessOperation.Generate; this.pbGenerateCode.Image = this.icons.Images[(int)OperationState.Running]; } //The error event is launched if (this.DiagramErrors != null) { this.DiagramErrors(this, new ProcessEventArgs(errors)); } } else { this.pbCheckDiagram.Image = this.icons.Images[(int)OperationState.Finish]; this.lCheckDiagram.Text = ProcessMessages.CHECKDIAGRAM_OK; //it passes to the following operation this.operation = ProcessOperation.Generate; this.pbGenerateCode.Image = this.icons.Images[(int)OperationState.Running]; } break; case ProcessOperation.Generate: //Generates the source code for the diagrams try { //It generates the code AsmGenerator.GenerateCode(this.project.MainFunction, this.project.Subfunctions, this.project.Variables, this.project.AsmFile); this.lGenerateCode.Text = ProcessMessages.GENERATECODE_OK; this.pbGenerateCode.Image = this.icons.Images[(int)OperationState.Finish]; //it passes to the following operation this.operation = ProcessOperation.Compile; this.pbCompileCode.Image = this.icons.Images[(int)OperationState.Running]; } catch { } break; case ProcessOperation.Compile: //se compila el código fuente generado try { //The generated source code is compiled if (AsmCompiler.Compile(this.project.AsmFile)) { this.lCompileCode.Text = ProcessMessages.COMPILECODE_OK; this.pbCompileCode.Image = this.icons.Images[(int)OperationState.Finish]; //it passes to the following operation this.operation = ProcessOperation.Close; this.opTimer.Interval = 1000; } else { this.opTimer.Enabled = false; //The Close button is enabled this.bClose.Enabled = true; //The error is displayed this.pbCompileCode.Image = this.icons.Images[(int)OperationState.Error]; this.lCompileCode.ForeColor = Color.FromArgb(208, 0, 0); this.lCompileCode.Text = ProcessMessages.COMPILECODE_ERROR; } } //Code compilation failed catch (CompilerException ex) { this.opTimer.Enabled = false; //The Close button is enabled this.bClose.Enabled = true; //The error is displayed this.pbCompileCode.Image = this.icons.Images[(int)OperationState.Error]; this.lCompileCode.ForeColor = Color.FromArgb(208, 0, 0); switch (ex.Message) { case "File not found": this.lCompileCode.Text = ProcessMessages.FILE_NOT_FOUND; break; case "Access denied": this.lCompileCode.Text = ProcessMessages.ACCES_DENIED; break; default: this.lCompileCode.Text = ProcessMessages.COMPILECODE_ERROR; break; } } break; case ProcessOperation.Close: //Close the form this.DialogResult = DialogResult.OK; this.Close(); break; } }
/// <summary> /// Timer of launching operations /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OpTimer_Tick(object sender, EventArgs e) { //Timer of launching operations switch (operation) { case ProcessOperation.Check: //Checked the errors for all the Diagrams List <DiagramError> errors = new List <DiagramError>(); foreach (Diagram diagram in this.project.Functions) { Generator.CheckDiagram(diagram, errors); } //If there are errors or warnings, it is reported if (errors.Count != 0) { bool onlyWarnings = false; //The errors are checked foreach (DiagramError error in errors) { //If any of the errors is not a warning if (error.Type == ErrorType.Error) { onlyWarnings = true; this.opTimer.Enabled = false; //The Close button is enabled this.bClose.Enabled = true; //The error is displayed this.pbCheckDiagram.Image = this.icons.Images[(int)OperationState.Error]; this.lCheckDiagram.Text = ProcessMessages.CHECKDIAGRAM_ERROR; this.lCheckDiagram.ForeColor = Color.FromArgb(208, 0, 0); break; } } //If they are only warnings if (!onlyWarnings) { //The warning message is displayed this.pbCheckDiagram.Image = this.icons.Images[(int)OperationState.Warning]; this.lCheckDiagram.Text = ProcessMessages.CHECKDIAGRAM_WARNING; this.lCheckDiagram.ForeColor = Color.FromArgb(200, 140, 0); this.opTimer.Interval = 1000; //it passes to the following operation this.operation = ProcessOperation.Close; } //The error event is launched if (this.DiagramErrors != null) { this.DiagramErrors(this, new ProcessEventArgs(errors)); } } else { this.pbCheckDiagram.Image = this.icons.Images[(int)OperationState.Finish]; this.lCheckDiagram.Text = ProcessMessages.CHECKDIAGRAM_OK; this.opTimer.Interval = 1000; //it passes to the following operation this.operation = ProcessOperation.Close; } break; case ProcessOperation.Close: //Close the form this.DialogResult = DialogResult.OK; this.Close(); break; } }
public static OperationNode CreateInstance( Graphics graphics, Point location, ProcessOperation tag) { OperationNode instance = null; switch (tag.T116Leaf) { case 12158: instance = new ProductionOfMaterial(graphics, location); break; case 12159: instance = new NoMaterialProcessing(graphics, location); break; case 12161: instance = new ManualInspection(graphics, location); break; case 12165: instance = new MachineTesting(graphics, location); break; case 12168: instance = new TroubleShooting(graphics, location); break; case 12166: instance = new ProductPackaging(graphics, location); break; case 12180: instance = new ProductionOfMaterialAndManualInspection( graphics, location); break; case 12182: instance = new NoMaterialProcessingAndManualInspection( graphics, location); break; case 12221: instance = new ProductionOfMaterialAndMachineTesting( graphics, location); break; case 12222: instance = new ProductPackagingAndAccessory(graphics, location); break; case 39490: instance = new VirtualComposite(graphics, location); break; } if (instance != null) { instance.Tag = tag; } return(instance); }