internal void InsertCmd(Cmd cmd) { SqlCeConnection con = new SqlCeConnection(connectionString); try { con.Open(); //SqlCeDataAdapter adapter = new SqlCeDataAdapter( // "insert into cmd (name, description, path, arg) values (" + // "'" + cmd.name + "'," + // "'" + cmd.description + "'," + // "'" + cmd.path + "'," + // "'" + cmd.arg + "'" + // ")", con); //SqlCeCommand sqlCmd = adapter.InsertCommand; //int count = sqlCmd.ExecuteNonQuery(); SqlCeCommand sqlCmd = con.CreateCommand(); sqlCmd.CommandText = "insert into cmd (name, description, path, arg) values (" + "'" + cmd.name + "'," + "'" + cmd.description + "'," + "'" + cmd.path + "'," + "'" + cmd.arg + "'" + ")"; int count = sqlCmd.ExecuteNonQuery(); } finally { if (con != null) { con.Close(); } } }
internal List<Cmd> GetFileCmdList(string dir, string pattern) { List<Cmd> list = new List<Cmd>(); if (!Directory.Exists(dir)) { return list; } List<string> exeList = new List<string>(); if (pattern == null) { exeList.AddRange(Directory.GetFiles(dir)); } else { exeList.AddRange(Directory.GetFiles(dir, pattern)); } foreach (string path in exeList) { Cmd command = new Cmd(); //command.name = Path.GetFileName(path); command.name = path; //command.type = Cmd.CommandType.Execution; command.path = path; command.arg = ""; list.Add(command); } return list; }
internal List<Cmd> GetDbList() { List<Cmd> list = new List<Cmd>(); SqlCeConnection con = new SqlCeConnection(connectionString); try { con.Open(); SqlCeDataAdapter adapter = new SqlCeDataAdapter( "select * from cmd order by name", con); DataSet dataSet = new DataSet(); adapter.Fill(dataSet, "Cmd"); DataTable table = dataSet.Tables["Cmd"]; foreach (DataRow row in table.Rows) { Cmd cmd = new Cmd(); cmd.name = (string)row["name"]; cmd.description = (string)row["description"]; cmd.path = (string)row["path"]; cmd.arg = (string)row["arg"]; list.Add(cmd); } } finally { if (con != null) { con.Close(); } } return list; }
internal static Cmd CreateSettingCmd() { Cmd cmd = new Cmd(); cmd.name = "Setting"; cmd.type = Cmd.CmdType.Setting; return cmd; }
internal static Cmd CreateCmdWithPath(string path) { Cmd cmd = new Cmd(); cmd.name = path; cmd.path = path; return cmd; }
/// <summary> /// 引数のコマンドがDB未登録なら、登録する。 /// </summary> /// <param name="cmd"></param> internal void Save(Cmd cmd) { if (!Contains(cmdList, cmd)) { cmdList.Add(cmd); dbDao.InsertCmd(cmd); } }
internal static Cmd CreateCmdWithCmdLine(string cmdLine) { string[] arr = SplitCmdLine(cmdLine); Cmd cmd = new Cmd(); cmd.name = cmdLine; cmd.path = arr[0]; cmd.arg = arr[1]; return cmd; }
public CmdForm() { InitializeComponent(); cmd = new Cmd(); }
internal CmdDecorator(Cmd cmd) { this.cmd = cmd; }
/// <summary> /// 実行内容の同一性を判定する。 /// </summary> /// <param name="cmd"></param> /// <returns></returns> public bool EqualsCmdLine(Cmd cmd) { return this.path.Equals(cmd.path) && this.arg.Equals(cmd.arg); }
private bool Contains(List<Cmd> cmdList, Cmd targetCmd) { bool result = false; foreach (Cmd cmd in cmdList) { if (cmd.EqualsCmdLine(targetCmd)) { result = true; break; } } return result; }