Beispiel #1
0
        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();
                }
            }
        }
Beispiel #2
0
        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;
        }
Beispiel #3
0
        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;
        }
Beispiel #4
0
 internal static Cmd CreateSettingCmd()
 {
     Cmd cmd = new Cmd();
     cmd.name = "Setting";
     cmd.type = Cmd.CmdType.Setting;
     return cmd;
 }
Beispiel #5
0
 internal static Cmd CreateCmdWithPath(string path)
 {
     Cmd cmd = new Cmd();
     cmd.name = path;
     cmd.path = path;
     return cmd;
 }
Beispiel #6
0
 /// <summary>
 /// 引数のコマンドがDB未登録なら、登録する。
 /// </summary>
 /// <param name="cmd"></param>
 internal void Save(Cmd cmd)
 {
     if (!Contains(cmdList, cmd))
     {
         cmdList.Add(cmd);
         dbDao.InsertCmd(cmd);
     }
 }
Beispiel #7
0
        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;
        }
Beispiel #8
0
        public CmdForm()
        {
            InitializeComponent();

            cmd = new Cmd();
        }
Beispiel #9
0
 internal CmdDecorator(Cmd cmd)
 {
     this.cmd = cmd;
 }
Beispiel #10
0
 /// <summary>
 /// 実行内容の同一性を判定する。
 /// </summary>
 /// <param name="cmd"></param>
 /// <returns></returns>
 public bool EqualsCmdLine(Cmd cmd)
 {
     return this.path.Equals(cmd.path) &&
         this.arg.Equals(cmd.arg);
 }
Beispiel #11
0
        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;
        }