//bool CanGenerate(object parameter) //{ // return Generator.IsValid; //} void Generate(object parameter) { if (!Generator.IsValid) { //foreach (var det in Generator.ValidationDetails) // ValidationDetails.Add(det); Generator.ShowValidationDetailsMessage(); return; } for (var i = 0; i < Generator.ProcessesCount; i++) { var process = new ProcessViewModel { Name = ChangeName(), Prioritet = RandomHelper.Randomizer.Next(Generator.PriorityFrom, Generator.PriorityTo + 1), }; var stagesCount = RandomHelper.Randomizer.Next(Generator.StagesCountFrom, Generator.StagesCountTo + 1); var coercedStagesCount = stagesCount % 2 == 1 ? stagesCount : stagesCount - 1; for (var j = 0; j < coercedStagesCount; j++) { var stage = new StageViewModel { Time = RandomHelper.Randomizer.Next(Generator.StageTimeFrom, Generator.StageTimeTo + 1), }; process.Stages.Add(stage); } Processes.Add(process); } }
private void BtnAdd_Click(object sender, EventArgs e) { if (!tlpProFields.AC_CheckRequiredFields(txtProName, numBurstTime, numPriority)) { ACMessageBox.ShowFillRequiredFields(); return; } var p = new OSASProcess { Id = ProDGV.Rows.Count + 1, Name = txtProName.Text, ArrivalTime = Convert.ToInt32(numArrivalTime.Value), BurstTime = Convert.ToInt32(numBurstTime.Value), RemainingTime = Convert.ToInt32(numBurstTime.Value), Priority = Convert.ToInt32(numPriority.Value), StartTime = -1 }; Processes.Add(p); RefreshDGV(Processes); tlpProFields.AC_ClearFields(); txtProName.Focus(); SelectedProcess = null; }
public void sampleData() { clearData(); Machines = 3; ProcessesAmount = 2; for (int p = 0; p < ProcessesAmount; p++) { var process = new Process(p + 1); if (p == 0) { process.Operations.Add(new Operation(10, 1, 1, p + 1)); process.Operations.Add(new Operation(20, 2, 2, p + 1)); process.Operations.Add(new Operation(30, 3, 3, p + 1)); } if (p == 1) { process.Operations.Add(new Operation(5, 1, 3, p + 1)); process.Operations.Add(new Operation(15, 2, 2, p + 1)); process.Operations.Add(new Operation(25, 3, 1, p + 1)); } Processes.Add(process); Inputs.Add(new Input(p + 1, p * 2 + 2)); } for (int m = 0; m < Machines; m++) { Buffers.Add(new Buffer(m + 1, 2)); } }
public List <Process> Get() { var process = new Process(); process.Version = "0.1.0"; process.Title = "Hello World process"; process.Description = "Hello World process"; process.Keywords = new List <string>() { "hello world" }; var link = new Link() { Rel = "canonical", Title = "Information", Href = $"{externalUri}/processes", HrefLang = "en-US" }; process.Links = new List <Link>() { link }; // todo: add inputs, outputs, example, itemtype, jobControlOptions, outputTransmission var processes = new Processes(); processes.Add(process); return(processes); }
public int Spawn(Byte[] filename, mgnat.adalib.standard.ada_string[] Args, bool insertInList) { string theArgs = to_string(Args); this.StartInfo.FileName = to_string(filename); this.StartInfo.Arguments = theArgs; try { if (this.Start()) { #if !COMPACT if (insertInList) { if (Processes == null) { Processes = new ProcessDictionary(); } Processes.Add(this.Id, this); } this.BeginOutputReadLine(); this.BeginErrorReadLine(); #endif return(this.Id); } else { return(-1); } } catch { return(-1); } }
/* * /// <summary> * /// Configure a trigger for an event to start a process. * /// </summary> * public void AddProcessTrigger(Func<RFEvent, bool> evaluator, RFEngineProcessDefinition processConfig) * { * Triggers.Add(new RFSingleCommandTrigger(e => evaluator(e) ? new RFParamProcessInstruction(processConfig.Name, null) : null)); * } */ /// <summary> /// Define a new process inside the engine triggered by a key update. /// </summary> /// <param name="processName">Unique user-friendly name.</param> /// <param name="processor"> /// Function that creates the processor (may pass static config etc.) /// </param> /// <param name="triggerKey">Key that triggers the execution (matched by root).</param> /// <returns></returns> public RFEngineProcessDefinition AddProcessWithCatalogTrigger <P>(string processName, string description, Func <IRFEngineProcessor> processor, RFCatalogKey triggerKey) where P : RFEngineProcessorParam { if (Processes.ContainsKey(processName)) { throw new Exception(String.Format("Already registered process {0}", processName)); } var p = processor(); // test instantiation //Func<RFInstruction, RFEngineProcessorParam> instanceParams = i => i.ExtractParam();// new P().ExtractFrom; var newProcess = new RFEngineProcessDefinition { Name = processName, InstanceParams = i => i.ExtractParam()?.ConvertTo <P>(), Processor = processor, Description = description, IsExclusive = p.IsExclusive }; Processes.Add(processName, newProcess); AddCatalogUpdateTrigger <RFCatalogKey>(k => k.MatchesRoot(triggerKey), newProcess); return(newProcess); }
void Import(object parameter) { try { var dlg = new OpenFileDialog(); dlg.AddExtension = true; dlg.DefaultExt = "txt"; dlg.Filter = "(Текстовые файлы)|*.txt"; dlg.Multiselect = false; var res = dlg.ShowDialog(); if (res.HasValue && res.Value) { var fileName = dlg.FileName; var processes = ProcessesFileLoader.ImportProcesses(fileName); Processes.Clear(); foreach (var process in processes) { Processes.Add(process); } } } catch (Exception ex) { var message = "Попытка импорта из файла завершилась ошибкой:"; var currentEx = ex; while (currentEx != null) { message = $"{message}\n{ex.Message}"; currentEx = ex.InnerException; } MessageBox.Show(message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void MergeProcess(List <Process> next) { //Processes.RemoveAll(p => next.All(np => p.Id != np.Id)); List <ProcessGridRowViewModel> processesToRemove = new List <ProcessGridRowViewModel>(); foreach (var process in Processes) { if (next.All(p => p.Id != process.Id)) { processesToRemove.Add(process); } } List <ProcessGridRowViewModel> processesToAdd = new List <ProcessGridRowViewModel>(); foreach (var process in next) { if (Processes.All(p => p.Id != process.Id)) { processesToAdd.Add(new ProcessGridRowViewModel(process)); } } foreach (var process in processesToAdd) { Application.Current.Dispatcher.Invoke(() => Processes.Add(process)); } foreach (var process in processesToRemove) { Application.Current.Dispatcher.Invoke(() => Processes.Remove(process)); } }
void ReloadProcesses(object o, EventArgs e) { int?id = null; if (CurrentProcess != null) { id = CurrentProcess.Id; } Processes.Clear(); Process[] processes = Process.GetProcesses(); foreach (var p in processes) { try { processTemp = new MyProcess(); processTemp.Name = p.ProcessName; processTemp.Id = p.Id; processTemp.User = p.MachineName; processTemp.Memory = p.PagedMemorySize64; Processes.Add(processTemp); } catch (Exception) { } } }
public int ImportProcesses() { DeleteExistent(); int res = 0; foreach (Record r in Items.Where(i => i.IsValid == true)) { if (!Processes.Where(i => i.Place.PlaceId == r.Place.PlaceId).Any()) { //we don't have this Place yet Process p = new Process { Place = r.Place, PlannedStart = PlannedStart, PlannedFinish = PlannedFinish, ActionTypeId = ActionType.ActionTypeId }; if (p.Add()) { res++; } Processes.Add(p); r.Process = p; } else { r.Process = Processes.Where(i => i.Place.PlaceId == r.Place.PlaceId).FirstOrDefault(); } } return(res); }
private void AddProcess(uint id) { if (_processTable.ContainsKey(id)) { return; } var p = Process.GetProcessById((int)id); _processTable.Add(id, p); DebugProcess parent; try { parent = FindProcess(Processes, (uint)p.GetParentId()); } catch { parent = null; } var dp = new DebugProcess(p, parent); if (parent != null) { parent.Children.Add(dp); } else { Processes.Add(dp); } }
private Task SaveByDefinitionAsync(BpmnDefinitions bpmn, CancellationToken cancellationToken) { foreach (var item in bpmn.Items.OfType <BpmnProcess>()) { var process = new TProcess { Id = item.Id, Name = item.Name, DefinitionId = bpmn.Id, IsExecutable = item.IsExecutable, IsClosed = item.IsClosed }; Processes.Add(process); } try { return(Context.SaveChangesAsync(cancellationToken)); } catch (DbUpdateConcurrencyException exception) { throw new BpmNetException(BpmNetConstants.Exceptions.ConcurrencyError, new StringBuilder() .AppendLine("The application was concurrently updated and cannot be persisted in its current state.") .Append("Reload the application from the database and retry the operation.") .ToString(), exception); } }
public Settings(IServiceProvider provider) { SettingsManager settingsManager = new ShellSettingsManager(provider); _settingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); if (!_settingsStore.CollectionExists("DebugAttachManagerProcesses")) { return; } IEnumerable <string> services = _settingsStore.GetSubCollectionNames("DebugAttachManagerProcesses"); foreach (var s in services) { var p = new StoredProcessInfo { ProcessName = _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "ProcessName"), Title = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "Title") ? _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "Title") : null, RemoteServerName = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "RemoteServerName") ? _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "RemoteServerName") : null, RemotePortNumber = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "RemotePortNumber") ? _settingsStore.GetInt64("DebugAttachManagerProcesses\\" + s, "RemotePortNumber") : (long?)null, Selected = _settingsStore.GetBoolean("DebugAttachManagerProcesses\\" + s, "Selected"), DebugMode = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "DebugMode") ? _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "DebugMode") : null }; Processes.Add(p.Hash, p); } if (_settingsStore.PropertyExists("DebugAttachManagerProcesses", "RemoteServer")) { RemoteServer = _settingsStore.GetString("DebugAttachManagerProcesses", "RemoteServer"); } }
public string Proces(DUETContext db, dynamic _proces) { try { var index = ((JArray)_proces.index).Select(i => (int)i).ToArray(); var x = ((JArray)_proces.x).Select(i => (int)i).ToArray(); var y = ((JArray)_proces.y).Select(i => (int)i).ToArray(); if (x.Length > 0) { if (CurrentStamp.Used == false) { CurrentStamp.Used = true; db.Stamps.Update(CurrentStamp); db.SaveChanges(); } { for (var i = 0; i < x.Length; i++) { int a = App.factor(x[i], ViewWidth, Width); int b = App.factor(y[i], ViewHeight, Height); //square int andex = index[i]; Proces proces = new Proces(Id, CurrentStamp.Id, a, b, andex); Processes.Add(proces); } db.SaveChanges(); } } return(""); } catch (Exception exception) { return("Error in Design Proces: " + exception.Message); } }
public override bool AllocateProcess(Process proc, out ProcessAllocateEventArgs arg) { // Best fit algorithm from Bergmann's class BlockFit b, newSpace; List <BlockFit> viableSpaces = new List <BlockFit>(); int size = proc.MemoryInKB; newSpace = new BlockFit(); int start_position = 0; // adds all possible fitting blocks to list viableSpaces for (int i = 0; i < avail.Count; i++) { b = avail[i]; if (b.blockLength >= size) { viableSpaces.Add(b); } } // orders the blocks so index 0 is the best fit List <BlockFit> ordered = viableSpaces.OrderBy(f => f.blockLength).ToList(); // modifies the allocated and available lists for adding this new memory block if (viableSpaces.Count != 0) { for (int i = 0; i < viableSpaces.Count; i++) { BlockFit block_check = viableSpaces[i]; if (block_check.blockLength == ordered[0].blockLength) { // creates a new allocation block newSpace.start_pos = block_check.start_pos; newSpace.blockLength = size; newSpace.ID = proc.ID; allocated.Add(newSpace); //updates the available block block_check.start_pos = block_check.start_pos + size - 1; block_check.blockLength = block_check.blockLength - size; //updates for the start position for the display start_position = newSpace.start_pos; } } } // places into memory location arg = new ProcessAllocateEventArgs { ProcessID = proc.ID, ProcessName = proc.Name, BlockLength = size, StartBlock = start_position }; Processes.Add(proc); return(true); }
public override void Launch(ProcessStartInfo processInfo, bool waitForExit) { Processes.Add(processInfo); if (waitForExit) { Completed.Add(processInfo); } }
public void CreateNProcess() { for (int i = 0; i < AmountOfProcess + 1; i++) { Process p = new Process(DelayProcess, $"PROCESSOR{i + 1}", "Exponential", QueueLength, MaxParallel); Processes.Add(p); } }
private void RegisterProcesses(IList <ProcessConfiguration> conf) { foreach (ProcessConfiguration processConfiguration in conf) { Processes.Add(new ProcessViewModel(processConfiguration)); } SubscribeToProcessesEvent(); }
private void AddProcessClickedHandler() { Processes.Add(new Process { Id = 0, Type = Process.ProcessType.Job, Status = Process.ProcessStatus.Waiting }); }
private void WorkingThreadProcess() { while (!_token.IsCancellationRequested) { for (int j = 0; j < 5; j++) { Thread.Sleep(1000); if (_token.IsCancellationRequested) { break; } } if (_token.IsCancellationRequested) { break; } IsControlEnabled = false; var all = Process.GetProcesses().Select(p => p.Id).ToList(); var currentProcesses = Processes.Select(p => p.Id).ToList(); var newProcesses = all.Except(currentProcesses).ToList(); var redundantProcesses = currentProcesses.Except(all).ToList(); foreach (int id in newProcesses) { try { App.Current.Dispatcher.Invoke(delegate { Processes.Add(new ProcessList(Process.GetProcessById(id))); }); } catch (Exception) { } } foreach (int id in redundantProcesses) { try { var process = Processes.First(x => x.Id == id); App.Current.Dispatcher.Invoke((Action) delegate { process.Killed = true; Processes.RemoveAt(Processes.IndexOf(process)); }); } catch (Exception) { } } IsControlEnabled = true; } }
private void AddProcess() { OpenFileDialog file = new OpenFileDialog(); file.ShowDialog(); if (file.SafeFileName != "") { Processes.Add(file.SafeFileName); } }
private void WorkingThreadProcess() { while (!_token.IsCancellationRequested) { for (int j = 0; j < 5; j++) { Thread.Sleep(1000); if (_token.IsCancellationRequested) { break; } } if (_token.IsCancellationRequested) { break; } IsControlEnabled = false; var t = Process.GetProcesses().Select(p => p.Id).ToList(); var currentProcesses = Processes.Select(p => p.Id).ToList(); var newProcesses = t.Except(currentProcesses).ToList(); var processesToRemove = currentProcesses.Except(t).ToList(); foreach (int id in newProcesses) { try { App.Current.Dispatcher.Invoke((Action) delegate { Processes.Add(new MyProcess(Process.GetProcessById(id))); }); } catch (Exception) { } } foreach (int id in processesToRemove) { try { var proces = from proc in Processes where proc.Id == id select proc; App.Current.Dispatcher.Invoke((Action) delegate // <--- HERE { proces.First().Kill = true; Processes.RemoveAt(Processes.IndexOf(proces.First())); }); } catch (Exception e) { } } IsControlEnabled = true; } }
public int ExecuteProgram(string code, string filePath, int?parentPid, CancellationToken token, params string[] args) { if (Processes.Count >= MaximumProcessCount) { return(-1); } var interp = CreateProcess(); var targetCode = code ?? string.Empty; targetCode = _programTemplate.Replace("%prepped_source%", targetCode); var argsTable = new Table(); for (var i = 0; i < args.Length; i++) { argsTable[i] = new DynValue(args[i]); } interp.Environment.SupplementLocalLookupTable.Add("args", new DynValue(argsTable)); var pid = _nextPid++; if (parentPid == null) { Processes.Add(pid, new Process(pid, string.Join(' ', args), interp) { FilePath = filePath }); } else { var child = new Process(pid, string.Join(' ', args), interp, parentPid) { FilePath = filePath }; var parent = Processes[parentPid.Value]; parent.Children.Add(child.Pid); Processes.Add(pid, child); } // We don't want to wait for this here. #pragma warning disable 4014 Task.Run(async() => #pragma warning restore 4014 { ReturnValues.Push(await ExecuteCode(interp, targetCode, token)); Kill(pid); }); return(pid); }
// Update the list of running processes public void UpdateProcesses() { Processes.Clear(); Process[] localAll = Process.GetProcesses(); foreach (var process in localAll) { Processes.Add(process); } }
public void CreateNProcess() { for (int i = 0; i < N + 1; i++) { double delay = random.NextDouble(); int queueLength = random.Next(0, 6); int maxParallel = random.Next(1, 5); Process p = new Process(delay, $"PROCESSOR{i + 1}", "Exponential", queueLength, maxParallel); Processes.Add(p); } }
public void AddProcess(string processName) { if (!HasProcess(processName)) { Processes.Add(processName); Log.Debug($"Adding process {processName} to definition {_index}"); } else { Log.Debug($"Definition {_index} already contains process {processName}"); } }
private void RefreshProcesses(object sender, RoutedEventArgs e) { Dispatcher.BeginInvoke((Action)(() => { var processlist = Process.GetProcesses(); Processes.Clear(); foreach (var p in processlist.OrderBy(x => x.ProcessName)) { Processes.Add(p); } })); }
private void IterateProcesses() { try { XmlDocument settings = new XmlDocument(); settings.Load(SettingsDir); var settingsRoot = settings.ChildNodes[1]; foreach (XmlNode settingsNode in settingsRoot) { foreach (XmlNode settingNode in settingsRoot.ChildNodes) { if (settingsNode.Name == "Setting") { string attrValue = settingsNode.Attributes[0].Value; if (attrValue == "ProcessName") { ProcessName = settingsNode.InnerText; } else if (attrValue == "BotWindowName") { BotWindowName = settingsNode.InnerText; } } } } } catch (Exception ex) { GeneralUtils.DisplayError(ex.ToString()); } var processes = System.Diagnostics.Process.GetProcessesByName(ProcessName); Processes.Clear(); foreach (var process in processes) { string[] processData = { process.ProcessName, process.Id.ToString() }; var listViewItem = new ListViewItem(processData); lviProcesses.Items.Add(listViewItem); IntPtr windowHandle = Process.GetWindowHandle(process.Id); Processes.Add(new Process(process.ProcessName, process.Id, process.Handle, windowHandle)); } if (Processes.Count <= 0) { GeneralUtils.DisplayError("Unable to find clients, please start the game then refresh."); } }
private void TextBox_ProcessFilter_TextChanged(object sender, TextChangedEventArgs e) { Processes.Clear(); var processes = Process.GetProcesses(); foreach (var process in processes) { if (process.ProcessName.ToLower().Contains(TextBox_ProcessFilter.Text.ToLower())) { Processes.Add(process.ProcessName); } } }
public Settings(IServiceProvider provider) { SettingsManager settingsManager = new ShellSettingsManager(provider); _settingsStore = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings); if (!_settingsStore.CollectionExists("DebugAttachManagerProcesses")) { return; } IEnumerable <string> services = _settingsStore.GetSubCollectionNames("DebugAttachManagerProcesses"); foreach (var s in services) { var p = new StoredProcessInfo { ProcessName = _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "ProcessName"), Title = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "Title") ? _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "Title") : null, RemoteServerName = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "RemoteServerName") ? _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "RemoteServerName") : null, RemotePortNumber = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "RemotePortNumber") ? _settingsStore.GetInt64("DebugAttachManagerProcesses\\" + s, "RemotePortNumber") : (long?)null, Selected = _settingsStore.GetBoolean("DebugAttachManagerProcesses\\" + s, "Selected"), DebugMode = _settingsStore.PropertyExists("DebugAttachManagerProcesses\\" + s, "DebugMode") ? _settingsStore.GetString("DebugAttachManagerProcesses\\" + s, "DebugMode") : null }; Processes.Add(p.Hash, p); } if (_settingsStore.PropertyExists("DebugAttachManagerProcesses", "RemoteServer")) { RemoteServer = _settingsStore.GetString("DebugAttachManagerProcesses", "RemoteServer"); } for (int i = 0; i < Constants.NUMBER_OF_OPTIONAL_COLUMNS; i++) { string columnName = $"Column{i}"; if (_settingsStore.PropertyExists("DebugAttachManagerProcesses", columnName)) { ProcessesColumns[i] = _settingsStore.GetBoolean("DebugAttachManagerProcesses", columnName); } else { if (i == 0) { // This is a hack, so we display PID by default ProcessesColumns[i] = true; } } } }