示例#1
0
        private static Task GetDbDumpTask(Config config)
        {
            return Task.Factory.StartNew(() =>
            {
                var process = new Process
                {
                    StartInfo = new ProcessStartInfo(config.MongoDumpPath, config.MongoDumpArgs)
                    {
                        CreateNoWindow = true,
                        UseShellExecute = false,
                        RedirectStandardOutput = true,
                        RedirectStandardError = true
                    }
                };
                process.OutputDataReceived += (a, e) => Trace.TraceInformation(e.Data);
                process.ErrorDataReceived += (a, e) => Trace.TraceEvent(TraceEventType.Error, 0, e.Data);

                process.Start();
                process.BeginErrorReadLine();
                process.BeginOutputReadLine();
                process.WaitForExit();
                process.CancelErrorRead();
                process.CancelOutputRead();
                process.Close();

                Trace.TraceInformation("Dump completed!");
            });
        }
示例#2
0
 private static Task GetDownloadFilesTask(Config config)
 {
     return Task.Factory.StartNew(() =>
     {
         // download file
         new WebClient().DownloadFile(new Uri(config.DownloadFilesUrl), config.FilesPath);
         Trace.TraceInformation("Download Completed!");
     });
 }