public bool BackUpDB(BackupInfo backupInfo) { //调用mysqldump备份mysql数据库的语句 string backupsql = string.Format("mysqldump --host={0} --port={1} --user={2} --password={3} --default-character-set=utf8 --column-statistics=0 --lock-tables --routines --force --quick ", "152.136.73.240", "1733", "Lsa", "llfllf"); //mysqldump的路径 string mysqldump = backupInfo.MysqldumpPath; //需要备份的数据库名称 string strDB = "db_LibraryManagement"; //备份数据库的路径 string strDBpath = backupInfo.BackupPath; //判断备份的数据库路径是否存在 if (!Directory.Exists(strDBpath)) { Directory.CreateDirectory(strDBpath); } //备份数据库 if (!string.IsNullOrEmpty(strDB)) { string filePath = strDBpath + @"\" + backupInfo.BackupTime.ToString("yyyyMMdd_HHmmss") + strDB + ".sql"; string cmd = backupsql + strDB + " > " + filePath; RunCmd r = new RunCmd(); string result = r.runCmd(mysqldump, cmd); return(true); } return(false); }
private void btn_Recovery_Click(object sender, EventArgs e) { string mysqldump = textBox_MysqlDumpPath.Text.ToString(); if (File.Exists(mysqldump + "//mysqldump.exe")) { //存在 OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.OK) { //调用mysqldump备份mysql数据库的语句 string backupsql = string.Format("mysql --host={0} --default-character-set=utf8 --port={1} --user={2} --password={3} ", "152.136.73.240", "1733", "Lsa", "llfllf"); //mysql的路径 //需要备份的数据库名称 string strDB = "db_backuptest"; string filePath = ofd.FileName; MessageBox.Show(filePath, "当前选择的路径"); string cmd = backupsql + strDB + " < \"" + filePath + "\""; RunCmd r = new RunCmd(); string result = r.runCmd(mysqldump, cmd); MessageBox.Show("数据库恢复成功!", "MySQL", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("mysqldump路径错误", "提示"); } }
static void Main(string[] args) { var commentPath = $"./Files/{DateTime.Now.ToString("yyyyMMddHHmmssff")}.txt"; if (!new DouBanComment().BuildCommentsFile(commentPath)) { Console.WriteLine($"获取豆瓣评论失败"); return; } if (!File.Exists(commentPath)) { Console.WriteLine($"{commentPath}文件未找到"); return; } var jiebaFile = new JieBa().Build($"{commentPath}"); Console.WriteLine("start python..."); var res = new RunCmd().Run("python/cloud.py", jiebaFile); Console.WriteLine(res); Console.WriteLine("end python..."); Console.ReadKey(); }
private void CleanTeamProjets(bool execute) { string path = ""; if (vm.TestAttatchmentCleanerPath != null) { path = vm.TestAttatchmentCleanerPath.Replace(vm.TestAttatchmentCleanerPath.Split('\\').LastOrDefault(), string.Empty); } string total = "CD " + path + "\r\n\r\n"; foreach (TeamProjectAttachemntInfo tpa in vm.RootFolder) { if (tpa.IsSelected) { string s = GenerateTestAttatcmentCleanerStatement(tpa, path); if (execute) { RunCmd cmd = new RunCmd(); cmd.ExecuteCommandSync(s, path); } else { total += "REM " + tpa.TeamProjectName + "\r\n"; total += s + "\r\n\r\n"; } } } if (!execute) { Clipboard.SetText(total); } }
static Dictionary <string, ICmd> InitializeCommands() { Dictionary <string, ICmd> result = new Dictionary <string, ICmd>(StringComparer.InvariantCultureIgnoreCase); ICmd cmd = new InstallCmd(); result.Add(cmd.CommandName, cmd); cmd = new UninstallCmd(); result.Add(cmd.CommandName, cmd); cmd = new ServerCmd(); result.Add(cmd.CommandName, cmd); cmd = new RepofilterCmd(); result.Add(cmd.CommandName, cmd); cmd = new RepomapCmd(); result.Add(cmd.CommandName, cmd); cmd = new TriggerCmd(); result.Add(cmd.CommandName, cmd); cmd = new RunCmd(); result.Add(cmd.CommandName, cmd); cmd = new WarnEmailCmd(); result.Add(cmd.CommandName, cmd); cmd = new LogCmd(); result.Add(cmd.CommandName, cmd); return(result); }
private static void ExecuteRun(RunCmd run) { try { string content = "{"; using (StreamReader reader = new StreamReader(run.fileName)) { string line = reader.ReadLine(); while (line != null) { content += line + "\n"; line = reader.ReadLine(); } } content += "}"; //Console.WriteLine("Executing " + content); var cmd = Parser.Parse(content); //Console.WriteLine(cmd); Execute(content); } catch (FileNotFoundException e) { Console.WriteLine(e.Message); } }
private static Command CreateRunCommand(ParsingInfo info) { var cmd = new RunCmd(); cmd.fileName = info.MandatoryToken <Rules.StringToken>("fileName").Value; return(cmd); }
private string ExecuteCmus(string arg) { var res = new RunCmd().Run(_cmus, arg); Console.Write("Output cmus: " + res["output"]); Console.Write("Debug cmus: " + res["debug"]); /*if (res["debug"] != "" && res["debug"] != null)*/ /* throw new Exception("Some debugging info: " + res["debug"] + "\nOutput: " + res["output"]);*/ if (res["debug"].Contains("cmus is not running")) { throw new System.Exception("cmus not running."); /*res = new RunCmd().Run("cmus & \n", ""); * res = new RunCmd().Run(_cmus, arg);*/ } return(res["output"]); }
private Imgd FileLoader(string filePath, MaterialDef matDef, MapGenConfig config) { logger.Debug($"Load image from \"{filePath}\""); if (FileExtUtil.IsExtension(filePath, ".imd")) { return(ImageResizer.NormalizeImageSize(File.OpenRead(filePath).Using(s => Imgd.Read(s)))); } if (FileExtUtil.IsExtension(filePath, ".png")) { var imdFile = Path.ChangeExtension(filePath, ".imd"); if (config.skipConversionIfExists && File.Exists(imdFile)) { logger.Debug($"Skipping png to imd conversion, due to imd file existence and skipConversionIfExists option."); } else { try { logger.Debug($"Using ImgTool for png to imd conversion."); var imgtoolOptions = matDef.imgtoolOptions ?? config.imgtoolOptions ?? "-b 8"; var result = new RunCmd( "OpenKh.Command.ImgTool.exe", $"imd \"{filePath}\" -o \"{imdFile}\" {imgtoolOptions}" ); if (result.ExitCode != 0) { throw new Exception($"ImgTool failed ({result.ExitCode})"); } } catch (Win32Exception ex) { throw new Exception("ImgTool failed.", ex); } } return(FileLoader(imdFile, matDef, config)); } throw new NotSupportedException(Path.GetExtension(filePath)); }
public static void AdbPushFile() { //测试 //Application.OpenURL("test.bat"); //获取当前选择 var select = Selection.activeObject; var packageName = PlayerSettings.bundleIdentifier; var fullPath = AssetDatabase.GetAssetPath(select); //var fileName = getFileNameWithoutExt(fullPath); var filePath = GetFilePath(fullPath); var strTempPath = filePath.Replace("Assets/", ""); //var pushPath = "/sdcard/Android/data/cn.ultralisk.game13/files/game13/lua/Game/Ui"; var pushPath = "/sdcard/Android/data/" + packageName + "/files/" + strTempPath; var argument = "push " + fullPath + " " + pushPath; RunCmd.processCommand("adb", argument); //RunCmd.processCommand("adb", "push test.bat /sdcard/Android/data"); }
public async Task ReadStream() { serialPort = new SerialPort(Port); if (Verbose) { Console.WriteLine($"Port {Port}"); Console.WriteLine($"Connection String {TableStorageConnectionString}"); Console.WriteLine($"Table {TableStorageTable}"); Console.WriteLine($"Sampling {Sampling} sec"); Console.WriteLine($"Location name {LocationName}"); } serialPort.ReadTimeout = 1500; serialPort.WriteTimeout = 1500; serialPort.Open(); if (Verbose) { Console.WriteLine($"Serial Port -{Port}- Opened successfully."); } int b; while (true) { // read data from PM sensor while ((b = serialPort.ReadByte()) != 0xAA) { ; } slice[0] = (byte)b; if ((b = serialPort.ReadByte()) != 0xC0) { break; } slice[1] = (byte)b; for (int i = 2; i < 10; i++) { slice[i] = (byte)serialPort.ReadByte(); } // read data from temp/Hum sensor RunCmd c = new RunCmd(); var output = c.Run("/usr/bin/python3", "DHT11-reader.py", ""); // Text FORMAT - DHT11|Temp|22.0|C|UMID|69.0|% if (Verbose) { Console.WriteLine(output); } var array = output.Split('|'); if (array[0] == "DHT11" && array[1] == "Temp" && array[4] == "UMID") { Humidity = (int)Convert.ToDouble(array[5], numberProvider); Temperature = Convert.ToDouble(array[2], numberProvider); } else { Humidity = -100; Temperature = -100; Console.WriteLine("Wrong DHT11 message format"); } if (Verbose) { dump(); } if (TableStorageConnectionString != null && TableStorageTable != null) { await WriteDataToCloud(); } if (Verbose) { Console.WriteLine($"Waiting {Sampling}secs"); } Thread.Sleep(1000 * Sampling); } // serialPort.Close(); }
private void btn_run_Click(object sender, EventArgs e) { new Thread(() => { try { setEnable(false); _setlog("源文件夹:" + tb_s.Text); _setlog("目标文件夹:" + tb_t.Text); var allfile = IOExtension.GetAllFiles(tb_s.Text); if (allfile == null || allfile.Count == 0) { _setlog("源文件夹为空....,请重新选择"); setEnable(true); return; } var allfilet = IOExtension.GetAllFiles(tb_t.Text); if (allfilet != null && allfilet.Count != 0) { _setlog("目标文件夹必须为空....,请重新选择"); setEnable(true); return; } _setlog($"获取到文件{allfile.Count}个,共计大小{ IOExtension.CountSize(allfile.Sum(a => a.Length)) }"); _setlog("清除目标路径"); IOExtension.DeleteFile(tb_t.Text); _setlog("开始复制文件"); int i = copy(tb_s.Text.Trim(), tb_t.Text.Trim()); if (i != 0) { if (i == 1223) { IOExtension.DeleteFile(tb_t.Text); _setlog("用户取消,删除目标文件夹文件"); } else { _setlog(ShellFileOperation.GetErrorString(i)); } setEnable(true); return; } _setlog("复制完成,删除原始文件"); IOExtension.DeleteFile(tb_s.Text); _setlog("开始设置目录"); RunCmd cmd = new RunCmd(); cmd.Output += (str) => { if (str == "c:\\>") { _setlog($"完成,请通过\"{tb_s.Text}\"检查文件是否存在"); setEnable(true); } }; cmd.Run($"mklink /j \"{tb_s.Text}\" \"{tb_t.Text}\""); } catch (Exception ex) { _setlog(ex.Message); setEnable(true); } }).Start(); }