public void StreamEncodingCanBeChanged() { var info = new ProcessInfo("somewhere"); var encoding = Encoding.UTF32; info.StreamEncoding = encoding; Assert.AreEqual(encoding, info.StreamEncoding); }
public static System.Diagnostics.Process CreateProcess(string path, string args, string currentDirectory) { if (!File.Exists(path)) { throw new ArgumentException("File does not exist"); } ProcessInfo proc = new ProcessInfo(); try { var inf = new StartupInfo(); inf.cb = (uint)Marshal.SizeOf(typeof(StartupInfo)); var cmd = path; if(!string.IsNullOrWhiteSpace(args)) { cmd += " " + args; } if (!CreateProcess(null, cmd, IntPtr.Zero, IntPtr.Zero, false, CREATE_BREAKAWAY_FROM_JOB | CREATE_NO_WINDOW, IntPtr.Zero, currentDirectory, ref inf, out proc)) { throw new InvalidOperationException("Couldn't create process"); } return System.Diagnostics.Process.GetProcessById(proc.ProcessId); } finally { if (proc.hProcess != IntPtr.Zero) { Interop.CloseHandle(proc.hProcess); } } }
public void Show(ProcessInfo process, string whatsHigh) { this._Process = process; this.Text = "Warning! Process taking high " + whatsHigh; this.TitleLabel.Text = "The following process is taking high " + whatsHigh + " and should be closed:"; this.ProcessNameLabel.Text = process.Title; this.PostponeButton.Text = string.Format("Postpone {0} mins", Settings.Default.Default_Postpone_Time.TotalMinutes); this.CPULabel.Text = process.CpuUsage + "%"; this.MemoryLabel.Text = (process.WorkingSet / 1048576) + " MB"; try { Process realProcess = Process.GetProcessById(process.Id); this.ProcessNameLabel.Text = realProcess.MainWindowTitle; } catch { } this.Show(); this.Refresh(); this.TopMost = true; this.DummyTextBox.Focus(); }
public void ProcessInfo_TestEqualishWorksAlwaysReturnsFalseForDifferentProcesses() { var info1 = new ProcessInfo("process.exe", "TestDocument.doc *"); var info2 = new ProcessInfo("process2.exe", "TestDocument.doc"); info1.IsEqualishTo(info2).Should().BeFalse("because they're different processes"); }
public void MinimalConstructorSetsFilename() { var filename = "nameoffile"; var info = new ProcessInfo(filename); Assert.AreEqual(filename, info.FileName); Assert.AreEqual(2, info.TimeOut.Minutes); }
public void ProcessInfo_TestEverything() { ProcessInfo p1 = new ProcessInfo(); Assert.AreEqual(0, p1.ProcessId); Assert.AreEqual(ProcessInfo.ProcessType.Unknown, p1.Type); Assert.IsNull(p1.EndPoint); Assert.IsNull(p1.Label); Assert.AreEqual(ProcessInfo.StatusCode.Unknown, p1.Status); Assert.IsNull(p1.AliveTimestamp); PublicEndPoint ep1 = new PublicEndPoint() { Host = "swcwin.serv.usu.edu", Port = 32541 }; DateTime t1 = DateTime.Now; ProcessInfo p2 = new ProcessInfo() { ProcessId = 10, Type = ProcessInfo.ProcessType.Player, EndPoint = ep1, Label = "Test Process", Status = ProcessInfo.StatusCode.Initializing, AliveTimestamp = t1 }; Assert.AreEqual(10, p2.ProcessId); Assert.AreEqual(ProcessInfo.ProcessType.Player, p2.Type); Assert.AreEqual(ep1, p2.EndPoint); Assert.AreEqual("Test Process", p2.Label); Assert.AreEqual(ProcessInfo.StatusCode.Initializing, p2.Status); Assert.AreEqual("Initializing", p2.StatusString); Assert.AreEqual(t1, p2.AliveTimestamp); }
public void StandardInputContentCanBeChanged() { var info = new ProcessInfo("somewhere"); var expected = "some data to pass in"; info.StandardInputContent = expected; Assert.AreEqual(expected, info.StandardInputContent); }
public ProcessMonitor(Process p) { m_process = p; m_info = new ProcessInfo(p); UpdateDeltas(); //m_cpucounter = new PerformanceCounter("Processor", "% Processor Time", GetPerformanceCounterProcessName(m_process.Id), true); }
public void ProcessInfo_TestEqualishWorksWithUnsavedDocumentMarkers() { var processName = "process.exe"; var info1 = new ProcessInfo(processName, "TestDocument.doc *"); var info2 = new ProcessInfo(processName, "TestDocument.doc"); info1.IsEqualishTo(info2).Should().BeTrue("because the process name is the same and the window title is basically the same!"); }
public void ShouldNotUseATimeoutIfTimeoutSetToInfiniteOnProcessInfo() { ProcessInfo processInfo = new ProcessInfo("cmd.exe", "/C @echo Hello World"); processInfo.TimeOut = ProcessInfo.InfiniteTimeout; ProcessResult result = executor.Execute(processInfo); AssertProcessExitsSuccessfully(result); Assert.AreEqual("Hello World", result.StandardOutput.Trim()); }
public void SetEnvironmentVariables() { ProcessInfo processInfo = new ProcessInfo("cmd.exe", "/C set foo", null); processInfo.EnvironmentVariables["foo"] = "bar"; ProcessResult result = executor.Execute(processInfo); AssertProcessExitsSuccessfully(result); Assert.AreEqual("foo=bar\r\n", result.StandardOutput); }
public void ProcessInfo_ConstructorShouldSetProperties() { var name = "process.exe"; var title = "window title"; var info = new ProcessInfo(name, title); info.Name.Should().BeEquivalentTo(name); info.WindowTitle.Should().BeEquivalentTo(title); }
private static void WriteToStandardInput(Process process, ProcessInfo processInfo) { if (process.StartInfo.RedirectStandardInput) { process.StandardInput.Write(processInfo.StandardInputContent); process.StandardInput.Flush(); process.StandardInput.Close(); } }
public void IfStandardInputContentIsSetThenStandardInputIsRedirected() { ProcessInfo info = new ProcessInfo("temp"); info.StandardInputContent = "Some content"; Process process = info.CreateProcess(); Assert.IsTrue(process.StartInfo.RedirectStandardInput); Assert.IsTrue(!process.StartInfo.UseShellExecute); }
public void ForceProcessTimeoutBecauseTargetIsNonTerminating() { ProcessInfo processInfo = new ProcessInfo("sleeper.exe"); processInfo.TimeOut = 100; ProcessResult result = executor.Execute(processInfo); Assert.IsTrue(result.TimedOut, "process did not time out, but it should have."); Assert.IsNotNull(result.StandardOutput, "some output should have been produced"); AssertProcessExitsWithFailure(result); }
public void IfExecutableIsFoundInWorkingDirectoryThenUseCombinedPathAsExecutablePath() { string workingDir = TempFileUtil.CreateTempDir("working"); string executablePath = TempFileUtil.CreateTempFile("working", "myExecutable"); ProcessInfo infoWithoutPathQualifiedExecutable = new ProcessInfo("myExecutable", "", workingDir); ProcessInfo infoWithPreQualifiedExecutable = new ProcessInfo(executablePath, "", workingDir); Assert.AreEqual(infoWithPreQualifiedExecutable, infoWithoutPathQualifiedExecutable); }
public AppStatus(InstallDirectoryItem appInstallation, string iconUrl, ProcessInfo processInfo, string error) { Id = appInstallation.PackageId; Version = appInstallation.PackageVersion; Instance = appInstallation.Instance; FullName = $"{appInstallation.PackageId}.{appInstallation.PackageVersion}@{appInstallation.Instance}".TrimEnd('@'); IconUrl = iconUrl; ProcessInfo = processInfo; Error = error; }
public Player() { Label = "Drew's Player"; MyProcessInfo = new ProcessInfo() { Status = ProcessInfo.StatusCode.NotInitialized, Label = Label, Type = ProcessInfo.ProcessType.Player }; CleanupSession(); }
public void ProcessInfo_TestEqualityWorks() { var info1 = new ProcessInfo("process.exe", "window title"); var info2 = new ProcessInfo("process.exe", "window title"); var info3 = new ProcessInfo("process.exe", "different window title"); var info4 = new ProcessInfo("proc.exe", "window title"); info1.Equals(info2).Should().BeTrue("because the two objects have the same process/window title"); info1.Equals(info3).Should().BeFalse("because the window titles are different"); info1.Equals(info4).Should().BeFalse("because the process titles are different"); }
static extern bool CreateProcess( string lpApplicationName, string lpCommandLine, ref SECURITY_ATTRIBUTES lpProcessAttributes, ref SECURITY_ATTRIBUTES lpThreadAttributes, bool bInheritHandles, uint dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, [In] ref StartupInfo lpStartupInfo, out ProcessInfo lpProcessInformation);
public void ProcessSuccessRequiresZeroExitCode() { int[] successExitCodes = { 1, 3, 5 }; ProcessInfo info = new ProcessInfo(@"""c:\nant\nant.exe""", null, string.Format(@"""{0}""", Path.GetTempPath())); Assert.IsTrue(info.ProcessSuccessful(0)); Assert.IsFalse(info.ProcessSuccessful(1)); Assert.IsFalse(info.ProcessSuccessful(2)); Assert.IsFalse(info.ProcessSuccessful(-1)); }
public static void LaunchApp(string strPath, string strParms) { pi = new ProcessInfo(); byte[] si = new byte[128]; CreateProcess(strPath, strParms, IntPtr.Zero, IntPtr.Zero, 0, 0, IntPtr.Zero, IntPtr.Zero, si, pi); // This line can be commented out if you do not want to wait for the process to exit //WaitForSingleObject(pi.hProcess, 0xFFFFFFFF); //int exitCode = 0; //GetExitCodeProcess(pi.hProcess, ref exitCode); //exitApp(); return; }
private static Process Start(ProcessInfo processInfo) { var process = processInfo.CreateProcess(); Log.Debug(string.Format( "Attempting to start process [{0}] in working directory [{1}] with arguments [{2}]", process.StartInfo.FileName, process.StartInfo.WorkingDirectory, process.StartInfo.Arguments)); var isNewProcess = process.Start(); if (! isNewProcess) Log.Debug("Reusing existing process..."); return process; }
public override IEnumerator<object> LoadInto(ProcessInfo process) { if (ScriptText == null) yield return Reload(); Program.PythonModuleToScript[ModuleName] = Name; yield return Program.LoadPythonScript( process, ModuleName, ScriptText ); DisposeFuturesForProcess(process); }
/// <summary> /// Executes the specified process info. /// </summary> /// <param name="processInfo">The process info.</param> /// <returns></returns> /// <remarks></remarks> public virtual ProcessResult Execute(ProcessInfo processInfo) { string projectName = Thread.CurrentThread.Name; using (RunnableProcess p = new RunnableProcess(processInfo, projectName, processInfo == null ? null : processInfo.PublicArguments)) { p.ProcessOutput += ((sender, e) => OnProcessOutput(e)); ProcessMonitor.MonitorProcessForProject(p.Process, projectName); ProcessResult run = p.Run(); ProcessMonitor.RemoveMonitorForProject(projectName); return run; } }
public void Initialize() { MyProcessInfo = new ProcessInfo() { Status = ProcessInfo.StatusCode.Initializing, Type = ProcessInfo.ProcessType.BalloonStore, Label = Options.Label }; RegistryEndPoint = new PublicEndPoint(Options.Registry); GameManagerEndPoint = new PublicEndPoint(Options.GameManagerEndPoint); Identity = new IdentityInfo() { Alias = Options.Alias, ANumber = Options.ANumber, FirstName = Options.FirstName, LastName = Options.LastName }; SetupCommSubsystem(new BalloonStoreConversationFactory() { DefaultMaxRetries = Options.Retries, DefaultTimeout = Options.Timeout, Process = this }, minPort: Options.MinPort, maxPort: Options.MaxPort); Game = new GameInfo(); PennyBankPublicKey = new PublicKey(); WaterSources = new List<GameProcessData>(); BalloonStores = new List<GameProcessData>(); UmbrellaSuppliers = new List<GameProcessData>(); Players = new List<GameProcessData>(); Balloons = new ResourceSet<Balloon>(); CachedPennies = new List<Penny>(); rsa = new RSACryptoServiceProvider(); rsaSigner = new RSAPKCS1SignatureFormatter(rsa); rsaSigner.SetHashAlgorithm("SHA1"); Hasher = new SHA1Managed(); RSAParameters parameters = rsa.ExportParameters(false); PublicKey = new PublicKey() { Exponent = parameters.Exponent, Modulus = parameters.Modulus }; NextId = 0; NumIds = 0; }
/// <summary> /// Checks the after A while if a process is still running. If running, then kill it. /// </summary> /// <param name="processToKill">The process to kill.</param> private void CheckAfterAWhileIfItsStillRunning(ProcessInfo processToKill) { if (_ProcessKillTimer == default(Timer)) { _ProcessKillTimer = new Timer(); _ProcessKillTimer.Tick += new EventHandler(_ProcessKillTimer_Tick); } if (!_ProcessesToKill.Contains(processToKill)) _ProcessesToKill.Add(processToKill); _ProcessKillTimer.Interval = Convert.ToInt32(Settings.Default.How_Long_To_Wait_Before_Killing_Process_If_Normal_Close_Does_Not_Work.TotalMilliseconds); _ProcessKillTimer.Start(); }
/// <summary> /// 执行方法 /// </summary> /// <param name="processInfo"></param> /// <param name="processParams"></param> public static object ExecuteProcess(ProcessInfo processInfo, Dictionary<string, object> processParams) { if (processInfo == null) return null; if (!processInfo.IsActive) { return null; } switch (processInfo.Type) { case ProcessType.CSharp: string[] ss = processInfo.ExecuteParam.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (ss.Length != 2) { throw new ArgumentException("processInfo.ExecuteParam of " + processInfo.Name + " count should be 2", "ExecuteParam"); } if (processParams == null) { return Feng.Utils.ReflectionHelper.RunStaticMethod(ss[0], ss[1], null); } else { object[] p = new object[processParams.Count]; int i = 0; foreach (object j in processParams.Values) { p[i] = j; i++; } return Feng.Utils.ReflectionHelper.RunStaticMethod(ss[0], ss[1], p); } case ProcessType.PythonFile: { return PythonHelper.ExecutePythonFile(processInfo.ExecuteParam, processParams); } case ProcessType.PythonStatement: { return PythonHelper.ExecutePythonStatement(processInfo.ExecuteParam, processParams); } case ProcessType.Python: { return TryExecutePython(processInfo.ExecuteParam, processParams); } default: throw new NotSupportedException("processInfo.Type of " + processInfo.Name + "is Invalid!"); } }
public Connection(IPAddress remote, IPAddress local, int owningProcessId) { Remote = remote; Local = local; ProcessInfo = new ProcessInfo(owningProcessId, null); Task t1 = new Task(() => { FillInArinInfo(Remote); }); t1.Start(); Task t2 = new Task(() => { FillInGeoLocation(Remote); }); t2.Start(); Task t3 = new Task(() => { FillInHostName(Remote); }); t3.Start(); Task t4 = new Task(() => { FillInProcessName(owningProcessId); }); t4.Start(); }
public void ProcessSuccessIsDeterminedBySuccessExitCodes() { int[] successExitCodes = { 1, 3, 5 }; ProcessInfo info = new ProcessInfo(@"""c:\nant\nant.exe""", null, string.Format(@"""{0}""", Path.GetTempPath()), ProcessPriorityClass.Normal, successExitCodes); Assert.IsFalse(info.ProcessSuccessful(0)); Assert.IsTrue(info.ProcessSuccessful(1)); Assert.IsFalse(info.ProcessSuccessful(2)); Assert.IsTrue(info.ProcessSuccessful(3)); Assert.IsFalse(info.ProcessSuccessful(4)); Assert.IsTrue(info.ProcessSuccessful(5)); Assert.IsFalse(info.ProcessSuccessful(6)); }
public void Start() { ProcessInfo actual = SynergyCommandBuilder.Start(connection, project); ValidateProcessInfo(actual, @"start -nogui -q -m -h ""localhost"" -d ""\\server\share\dbname"" -p ""MyProject-MyProject_Int"" -n ""jdoe"" -pw ""password"" -r ""build_mgr"" -u ""C:\cmsynergy\uidb"" -home ""C:\cmsynergy\jdoe"""); }
public void Reconfigure() { ProcessInfo actual = SynergyCommandBuilder.Reconfigure(connection, project); ValidateProcessInfo(actual, @"reconfigure /recurse /keep_subprojects /project ""MyProject-MyProject_Int"""); }
public void GetSubProjects() { ProcessInfo actual = SynergyCommandBuilder.GetSubProjects(connection, project); ValidateProcessInfo(actual, @"query hierarchy_project_members('MyProject-MyProject_Int:project:1', 'none')"); }
public ProcessRunner(ProcessInfo processInfo, int processIndex, int processCount, ReadyToRunJittedMethods jittedMethods, AutoResetEvent processExitEvent) { _processInfo = processInfo; _processIndex = processIndex; _processCount = processCount; _jittedMethods = jittedMethods; _processExitEvent = processExitEvent; _cancellationTokenSource = new CancellationTokenSource(); _stopwatch = new Stopwatch(); _stopwatch.Start(); _state = StateIdle; _logWriter = new StreamWriter(_processInfo.Parameters.LogPath); if (_processInfo.Parameters.ProcessPath.IndexOf(' ') >= 0) { _logWriter.Write($"\"{_processInfo.Parameters.ProcessPath}\""); } else { _logWriter.Write(_processInfo.Parameters.ProcessPath); } _logWriter.Write(' '); _logWriter.WriteLine(_processInfo.Parameters.Arguments); _logWriter.WriteLine("<<<<"); ProcessStartInfo psi = new ProcessStartInfo() { FileName = _processInfo.Parameters.ProcessPath, Arguments = _processInfo.Parameters.Arguments, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, }; foreach (KeyValuePair <string, string> environmentOverride in _processInfo.Parameters.EnvironmentOverrides) { psi.EnvironmentVariables[environmentOverride.Key] = environmentOverride.Value; } _process = new Process(); _process.StartInfo = psi; _process.EnableRaisingEvents = true; _process.Exited += new EventHandler(ExitEventHandler); Interlocked.Exchange(ref _state, StateRunning); _process.Start(); if (_processInfo.Parameters.CollectJittedMethods) { _jittedMethods.AddProcessMapping(_processInfo, _process); } _outputCapture = new StringBuilder(); _outputHandler = new DataReceivedEventHandler(StandardOutputEventHandler); _process.OutputDataReceived += _outputHandler; _process.BeginOutputReadLine(); _errorHandler = new DataReceivedEventHandler(StandardErrorEventHandler); _process.ErrorDataReceived += _errorHandler; _process.BeginErrorReadLine(); Task.Run(TimeoutWatchdog); }
public void GetDcmDelimiter() { ProcessInfo actual = SynergyCommandBuilder.GetDcmDelimiter(connection); ValidateProcessInfo(actual, @"dcm /show /delimiter"); }
public IAnalysisResult AnalyzeData(IMatrixData mdata, Parameters param, ProcessInfo processInfo) { return(new SelectRowsManuallyResult(mdata)); }
public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables, ref IDocumentData[] documents, ProcessInfo processInfo) { int nameCol = param.GetParam <int>("New column names").Value; List <string> colNames; if (nameCol >= 0) { HashSet <string> taken = new HashSet <string>(); colNames = new List <string>(); foreach (string n in mdata.StringColumns[nameCol]) { string n1 = StringUtils.GetNextAvailableName(n, taken); taken.Add(n1); colNames.Add(n1); } } else { colNames = new List <string>(); for (int i = 0; i < mdata.RowCount; i++) { colNames.Add("Column" + (i + 1)); } } List <string> rowNames = mdata.ColumnNames; mdata.Values = mdata.Values.Transpose(); if (mdata.IsImputed != null) { mdata.IsImputed = mdata.IsImputed.Transpose(); } if (mdata.Quality != null) { mdata.Quality = mdata.Quality.Transpose(); } List <string> stringColumnNames = mdata.StringColumnNames; List <string> categoryColumnNames = mdata.CategoryColumnNames; List <string> numericColumnNames = mdata.NumericColumnNames; List <string> multiNumericColumnNames = mdata.MultiNumericColumnNames; List <string> stringColumnDescriptions = mdata.StringColumnDescriptions; List <string> categoryColumnDescriptions = mdata.CategoryColumnDescriptions; List <string> numericColumnDescriptions = mdata.NumericColumnDescriptions; List <string> multiNumericColumnDescriptions = mdata.MultiNumericColumnDescriptions; List <string[]> stringColumns = mdata.StringColumns; List <string[][]> categoryColumns = GetCategoryColumns(mdata); List <double[]> numericColumns = mdata.NumericColumns; List <double[][]> multiNumericColumns = mdata.MultiNumericColumns; mdata.SetAnnotationColumns(new List <string>(new[] { "Name" }), new List <string>(new[] { "Name" }), new List <string[]>(new[] { rowNames.ToArray() }), mdata.CategoryRowNames, mdata.CategoryRowDescriptions, GetCategoryRows(mdata), mdata.NumericRowNames, mdata.NumericRowDescriptions, mdata.NumericRows, new List <string>(), new List <string>(), new List <double[][]>()); mdata.ColumnNames = colNames; List <string> colDescr = new List <string>(); foreach (string s in colNames) { colDescr.Add(""); } mdata.ColumnDescriptions = colDescr; mdata.SetAnnotationRows(stringColumnNames, stringColumnDescriptions, stringColumns, categoryColumnNames, categoryColumnDescriptions, categoryColumns, numericColumnNames, numericColumnDescriptions, numericColumns, multiNumericColumnNames, multiNumericColumnDescriptions, multiNumericColumns); }
private void RaiseLastFrameRenderEvent(ProcessInfo processData, FrameInfo frameData) { RaiseEvent(new FrameRenderRoutedEventArgs { ProcessData = processData, FrameData = frameData }); }
public IMatrixData ProcessData(IMatrixData[] inputData, Parameters param, ref IMatrixData[] supplTables, ref IDocumentData[] documents, ProcessInfo processInfo) { IMatrixData mdata1 = inputData[0]; IMatrixData mdata2 = inputData[1]; string[] header1 = new string[mdata1.RowCount]; for (int i = 0; i < mdata1.RowCount; i++) { if (mdata1.Name != mdata1.AltName) { header1[i] = mdata1.AltName; } else { header1[i] = mdata1.Name; } } string[] header2 = new string[mdata2.RowCount]; for (int i = 0; i < mdata2.RowCount; i++) { if (mdata2.Name == mdata2.AltName) { header2[i] = mdata1.AltName; } else { header2[i] = mdata2.AltName; } } int nrows1 = mdata1.RowCount; int nrows2 = mdata2.RowCount; int nrows = nrows1 + nrows2; string[] expColNames = SpecialSort(mdata1.ColumnNames, mdata2.ColumnNames, out Dictionary <string, int> dic1, out Dictionary <string, int> dic2); double[,] ex = new double[nrows, expColNames.Length]; for (int i = 0; i < ex.GetLength(0); i++) { for (int j = 0; j < ex.GetLength(1); j++) { ex[i, j] = double.NaN; } } for (int i = 0; i < expColNames.Length; i++) { if (dic1.ContainsKey(expColNames[i])) { int ind = dic1[expColNames[i]]; for (int j = 0; j < nrows1; j++) { ex[j, i] = mdata1.Values.Get(j, ind); } } if (dic2.ContainsKey(expColNames[i])) { int ind = dic2[expColNames[i]]; for (int j = 0; j < nrows2; j++) { ex[nrows1 + j, i] = mdata2.Values.Get(j, ind); } } } string[] numColNames = SpecialSort(mdata1.NumericColumnNames, mdata2.NumericColumnNames, out dic1, out dic2); List <double[]> numCols = new List <double[]>(); for (int i = 0; i < numColNames.Length; i++) { numCols.Add(new double[nrows]); for (int j = 0; j < nrows; j++) { numCols[numCols.Count - 1][j] = double.NaN; } } for (int i = 0; i < numColNames.Length; i++) { if (dic1.ContainsKey(numColNames[i])) { int ind = dic1[numColNames[i]]; for (int j = 0; j < nrows1; j++) { numCols[i][j] = mdata1.NumericColumns[ind][j]; } } if (dic2.ContainsKey(numColNames[i])) { int ind = dic2[numColNames[i]]; for (int j = 0; j < nrows2; j++) { numCols[i][nrows1 + j] = mdata2.NumericColumns[ind][j]; } } } string[] stringColNames = SpecialSort(mdata1.StringColumnNames, mdata2.StringColumnNames, out dic1, out dic2); List <string[]> stringCols = new List <string[]>(); for (int i = 0; i < stringColNames.Length; i++) { stringCols.Add(new string[nrows]); for (int j = 0; j < nrows; j++) { stringCols[stringCols.Count - 1][j] = ""; } } for (int i = 0; i < stringColNames.Length; i++) { if (dic1.ContainsKey(stringColNames[i])) { int ind = dic1[stringColNames[i]]; for (int j = 0; j < nrows1; j++) { stringCols[i][j] = mdata1.StringColumns[ind][j]; } } if (dic2.ContainsKey(stringColNames[i])) { int ind = dic2[stringColNames[i]]; for (int j = 0; j < nrows2; j++) { stringCols[i][nrows1 + j] = mdata2.StringColumns[ind][j]; } } } string[] catColNames = SpecialSort(mdata1.CategoryColumnNames, mdata2.CategoryColumnNames, out dic1, out dic2); List <string[][]> catCols = new List <string[][]>(); for (int i = 0; i < catColNames.Length; i++) { catCols.Add(new string[nrows][]); for (int j = 0; j < nrows; j++) { catCols[catCols.Count - 1][j] = new string[0]; } } for (int i = 0; i < catColNames.Length; i++) { if (dic1.ContainsKey(catColNames[i])) { int ind = dic1[catColNames[i]]; for (int j = 0; j < nrows1; j++) { catCols[i][j] = mdata1.GetCategoryColumnEntryAt(ind, j); } } if (dic2.ContainsKey(catColNames[i])) { int ind = dic2[catColNames[i]]; for (int j = 0; j < nrows2; j++) { catCols[i][nrows1 + j] = mdata2.GetCategoryColumnEntryAt(ind, j); } } } string[] multiNumColNames = SpecialSort(mdata1.MultiNumericColumnNames, mdata2.MultiNumericColumnNames, out dic1, out dic2); List <double[][]> multiNumCols = new List <double[][]>(); for (int i = 0; i < multiNumColNames.Length; i++) { multiNumCols.Add(new double[nrows][]); for (int j = 0; j < nrows; j++) { multiNumCols[multiNumCols.Count - 1][j] = new double[0]; } } for (int i = 0; i < multiNumColNames.Length; i++) { if (dic1.ContainsKey(multiNumColNames[i])) { int ind = dic1[multiNumColNames[i]]; for (int j = 0; j < nrows1; j++) { multiNumCols[i][j] = mdata1.MultiNumericColumns[ind][j]; } } if (dic2.ContainsKey(multiNumColNames[i])) { int ind = dic2[multiNumColNames[i]]; for (int j = 0; j < nrows2; j++) { multiNumCols[i][nrows1 + j] = mdata2.MultiNumericColumns[ind][j]; } } } string MatrixName = "Matrix Name"; string MatrixDescription = "Description"; string[] listnames = header1.Concat(header2).ToArray(); //IMPORTANT!!!!! TODO: check if the name of the matrix if changed IMatrixData result = PerseusFactory.CreateMatrixData(ex, expColNames.ToList()); result.NumericColumnNames = new List <string>(numColNames); result.NumericColumnDescriptions = result.NumericColumnNames; result.NumericColumns = numCols; result.StringColumnNames = new List <string>(stringColNames); result.StringColumns = stringCols; result.CategoryColumnNames = new List <string>(catColNames); result.CategoryColumnDescriptions = result.CategoryColumnNames; result.CategoryColumns = catCols; result.MultiNumericColumnNames = new List <string>(multiNumColNames); result.MultiNumericColumnDescriptions = result.MultiNumericColumnNames; result.MultiNumericColumns = multiNumCols; HashSet <string> taken = new HashSet <string>(result.StringColumnNames); result.AddStringColumn(MatrixName, MatrixName, listnames); taken.Add(MatrixName); return(result); }
private void RaiseRenderEvent(ProcessInfo processData) { RaiseEvent(new RenderRoutedEventArgs { ProcessData = processData }); }
internal ProcessStartedEventArgs(ProcessInfo processInfo) : base(processInfo) { }
public void Stop() { ProcessInfo actual = SynergyCommandBuilder.Stop(connection); ValidateProcessInfo(actual, "stop"); }
public void UseReconfigureTemplate() { ProcessInfo actual = SynergyCommandBuilder.UseReconfigureTemplate(connection, project); ValidateProcessInfo(actual, @"reconfigure_properties /reconf_using template /recurse ""MyProject-MyProject_Int"""); }
/// <summary> /// 将速度(单位 B/s)转换为字符串表示 /// </summary> /// <param name="speed"></param> /// <returns></returns> public static string GetSpeedString(long speed) { return(ProcessInfo.GetStorageSizeString(speed) + "/s"); }
public void GetWorkArea() { ProcessInfo actual = SynergyCommandBuilder.GetWorkArea(connection, project); ValidateProcessInfo(actual, @"info /format ""%wa_path\%name"" /project ""MyProject-MyProject_Int"""); }
public void GetNewObjects() { ProcessInfo actual = SynergyCommandBuilder.GetObjectPaths(connection, project); ValidateProcessInfo(actual, @"finduse @"); }
public void GetDcmSettings() { ProcessInfo actual = SynergyCommandBuilder.GetDcmSettings(connection); ValidateProcessInfo(actual, @"dcm /show /settings"); }
public static bool ProcessDataAddAnnotation(int nrows, IAnnotationProvider annotationProvider, Parameters para, string[] baseIds, ProcessInfo processInfo, out string[] name, out int[] catColInds, out int[] textColInds, out int[] numColInds, out string[][][] catCols, out string[][] textCols, out double[][] numCols) { const bool deHyphenate = true; ParameterWithSubParams <int> spd = para.GetParamWithSubParams <int>("Source"); int ind = spd.Value; Parameters param = spd.GetSubParameters(); var types = annotationProvider.Sources.Select(s => s.annotation.Select(annotation => annotation.type).ToArray()).ToArray(); var type = types[ind]; var names = annotationProvider.Sources.Select(s => s.annotation.Select(annotation => annotation.name).ToArray()).ToArray(); name = names[ind]; int[] addtlSources = para.GetParam <int[]>("Additional sources").Value; addtlSources = ArrayUtils.Remove(addtlSources, ind); int[] selection = param.GetParam <int[]>("Annotations to be added").Value; if (!IsValidSelection(name, addtlSources, types, names, type, selection, out string errString)) { catColInds = new int[] { }; textColInds = new int[] { }; numColInds = new int[] { }; catCols = new string[][][] { }; textCols = new string[][] { }; numCols = new double[][] { }; processInfo.ErrString = errString; return(false); } type = ArrayUtils.SubArray(type, selection); name = ArrayUtils.SubArray(name, selection); HashSet <string> allIds = GetAllIds(baseIds, deHyphenate); var files = annotationProvider.Sources.Select(s => s.source).ToArray(); Dictionary <string, string[]> mapping = ReadMapping(allIds, files[ind], selection); foreach (int addtlSource in addtlSources) { Dictionary <string, string[]> mapping1 = ReadMapping(allIds, files[addtlSource], selection); foreach (string key in mapping1.Keys.Where(key => !mapping.ContainsKey(key))) { mapping.Add(key, mapping1[key]); } } SplitIds(type, out textColInds, out catColInds, out numColInds); catCols = new string[catColInds.Length][][]; for (int i = 0; i < catCols.Length; i++) { catCols[i] = new string[nrows][]; } textCols = new string[textColInds.Length][]; for (int i = 0; i < textCols.Length; i++) { textCols[i] = new string[nrows]; } numCols = new double[numColInds.Length][]; for (int i = 0; i < numCols.Length; i++) { numCols[i] = new double[nrows]; } for (int i = 0; i < nrows; i++) { string[] ids = baseIds[i].Length > 0 ? baseIds[i].Split(';') : new string[0]; HashSet <string>[] catVals = new HashSet <string> [catCols.Length]; for (int j = 0; j < catVals.Length; j++) { catVals[j] = new HashSet <string>(); } HashSet <string>[] textVals = new HashSet <string> [textCols.Length]; for (int j = 0; j < textVals.Length; j++) { textVals[j] = new HashSet <string>(); } List <double>[] numVals = new List <double> [numCols.Length]; for (int j = 0; j < numVals.Length; j++) { numVals[j] = new List <double>(); } foreach (string id in ids) { if (mapping.ContainsKey(id)) { string[] values = mapping[id]; AddCatVals(ArrayUtils.SubArray(values, catColInds), catVals); AddTextVals(ArrayUtils.SubArray(values, textColInds), textVals); AddNumVals(ArrayUtils.SubArray(values, numColInds), numVals); } else if (id.Contains("-")) { string q = id.Substring(0, id.IndexOf('-')); if (mapping.ContainsKey(q)) { string[] values = mapping[q]; AddCatVals(ArrayUtils.SubArray(values, catColInds), catVals); AddTextVals(ArrayUtils.SubArray(values, textColInds), textVals); AddNumVals(ArrayUtils.SubArray(values, numColInds), numVals); } } } for (int j = 0; j < catVals.Length; j++) { string[] q = catVals[j].ToArray(); Array.Sort(q); catCols[j][i] = q; } for (int j = 0; j < textVals.Length; j++) { string[] q = textVals[j].ToArray(); Array.Sort(q); textCols[j][i] = StringUtils.Concat(";", q); } for (int j = 0; j < numVals.Length; j++) { numCols[j][i] = ArrayUtils.Median(numVals[j]); } } return(true); }
public void GetLastReconfigureTime() { ProcessInfo actual = SynergyCommandBuilder.GetLastReconfigureTime(connection, project); ValidateProcessInfo(actual, @"attribute /show reconf_time ""MyProject-MyProject_Int:project:1"""); }
public void ProcessData(IMatrixData mdata, Parameters para, ref IMatrixData[] supplTables, ref IDocumentData[] documents, ProcessInfo processInfo) { ProcessData(mdata, _annotationProvider, para, processInfo); }
public void SetProjectRelease() { ProcessInfo actual = SynergyCommandBuilder.SetProjectRelease(connection, project); ValidateProcessInfo(actual, @"attribute /m release /v ""MyProduct/1.0"" @ "); }
public void LoadData(INetworkData ndata, Parameters param, ref IData[] supplData, ProcessInfo processInfo) { var remoteExe = GetExectuable(param); if (string.IsNullOrWhiteSpace(remoteExe)) { processInfo.ErrString = Resources.RemoteExeNotSpecified; } var outFolder = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); if (!TryGetCodeFile(param, out string codeFile)) { processInfo.ErrString = $"Code file '{codeFile}' was not found"; return; } var suppFiles = SupplDataTypes.Select(Utils.CreateTemporaryPath).ToArray(); var commandLineArguments = GetCommandLineArguments(param); var args = $"{codeFile} {commandLineArguments} {outFolder} {string.Join(" ", suppFiles)}"; Debug.WriteLine($"executing > {remoteExe} {args}"); if (Utils.RunProcess(remoteExe, args, processInfo.Status, out string processInfoErrString) != 0) { processInfo.ErrString = processInfoErrString; return; } FolderFormat.Read(ndata, outFolder, processInfo); supplData = Utils.ReadSupplementaryData(suppFiles, SupplDataTypes, processInfo); }
public static void ProcessData(IDataWithAnnotationColumns mdata, IAnnotationProvider annotationProvider, Parameters para, ProcessInfo processInfo) { string[] baseIds = GetBaseIds(mdata, annotationProvider, para); bool success = ProcessDataAddAnnotation(mdata.RowCount, annotationProvider, para, baseIds, processInfo, out string[] name, out int[] catColInds, out int[] textColInds, out int[] numColInds, out string[][][] catCols, out string[][] textCols, out double[][] numCols); if (!success) { return; } for (int i = 0; i < catCols.Length; i++) { mdata.AddCategoryColumn(name[catColInds[i]], "", catCols[i]); } for (int i = 0; i < textCols.Length; i++) { mdata.AddStringColumn(name[textColInds[i]], "", textCols[i]); } for (int i = 0; i < numCols.Length; i++) { mdata.AddNumericColumn(name[numColInds[i]], "", numCols[i]); } }
public void Heartbeat() { ProcessInfo actual = SynergyCommandBuilder.Heartbeat(connection); ValidateProcessInfo(actual, "status"); }
public void GetTaskObjects() { ProcessInfo actual = SynergyCommandBuilder.GetTaskObjects(connection, project); ValidateProcessInfo(actual, @"task /show objects /no_sort /u @"); }
public void GetProjectName() { ProcessInfo actual = SynergyCommandBuilder.GetProjectFullName(connection, project); ValidateProcessInfo(actual, @"properties /format ""%objectname"" /p ""MyProject-MyProject_Int"""); }
public void UpdateReconfigureProperites() { ProcessInfo actual = SynergyCommandBuilder.UpdateReconfigureProperites(connection, project); ValidateProcessInfo(actual, @"reconfigure_properties /refresh /recurse ""MyProject-MyProject_Int"""); }
public void Reconcile() { ProcessInfo actual = SynergyCommandBuilder.Reconcile(connection, project, @"c:\ccm_wa\project-ver\project\folder"); ValidateProcessInfo(actual, @"reconcile /consider_uncontrolled /missing_wa_file /recurse /update_wa ""c:\ccm_wa\project-ver\project\folder"""); }
unsafe void CheckProxyPort() { var rPort = Preference.Instance.Network.Port; var rUpstreamProxy = Preference.Instance.Network.UpstreamProxy; var rIsPortAvailable = true; var rIsUpstreamProxyAvailable = false; if (!rUpstreamProxy.Enabled || rUpstreamProxy.Host != "127.0.0.1") { rIsUpstreamProxyAvailable = true; } var rBufferSize = 0; NativeMethods.IPHelperApi.GetExtendedTcpTable(IntPtr.Zero, ref rBufferSize, true, NativeConstants.AF.AF_INET, NativeConstants.TCP_TABLE_CLASS.TCP_TABLE_OWNER_PID_LISTENER); var rBuffer = stackalloc byte[rBufferSize]; NativeMethods.IPHelperApi.GetExtendedTcpTable((IntPtr)rBuffer, ref rBufferSize, true, NativeConstants.AF.AF_INET, NativeConstants.TCP_TABLE_CLASS.TCP_TABLE_OWNER_PID_LISTENER); var rTable = (NativeStructs.MIB_TCPTABLE *)rBuffer; var rRow = &rTable->table; for (var i = 0; i < rTable->dwNumEntries; i++, rRow++) { if (rRow->dwLocalAddr != LoopbackAddress) { continue; } if (rRow->LocalPort == rPort) { rIsPortAvailable = false; try { ProcessThatOccupyingPort = new ProcessInfo(Process.GetProcessById(rRow->dwOwningPid)); } catch { ProcessThatOccupyingPort = null; } } if (!rIsUpstreamProxyAvailable && rRow->LocalPort == rUpstreamProxy.Port) { rIsUpstreamProxyAvailable = true; } } if (rIsPortAvailable) { ProcessThatOccupyingPort = null; } IsPortAvailable = rIsPortAvailable; IsUpstreamProxyAvailable = rIsUpstreamProxyAvailable; OnPropertyChanged(nameof(IsPortAvailable)); OnPropertyChanged(nameof(IsUpstreamProxyAvailable)); OnPropertyChanged(nameof(ProcessThatOccupyingPort)); }
public void AddTasksToFolder() { ProcessInfo actual = SynergyCommandBuilder.AddTasksToFolder(connection, project, result); ValidateProcessInfo(actual, @"folder /modify /add_tasks ""100,2000,30000"" /y ""1234"""); }