Exemple #1
0
        public bool GetAllFolders(out List <DbFolder> entries, long id)
        {
            entries = new List <DbFolder>();

            string sql = $"SELECT * from app_{id}_folders";

            IDbCommand     dbcmd       = dbCon.CreateCommand();
            IDbDataAdapter dataAdapter = dbCore.GetNewDataAdapter();

            dbcmd.CommandText = sql;
            var dataSet = new DataSet();

            dataAdapter.SelectCommand = dbcmd;
            dataAdapter.Fill(dataSet);
            DataTable dataTable = dataSet.Tables[0];

            foreach (DataRow dRow in dataTable.Rows)
            {
                var fEntry = new DbFolder
                {
                    Id                = ulong.Parse(dRow["id"].ToString()),
                    Path              = dRow["path"].ToString(),
                    CreationTimeUtc   = DateTime.Parse(dRow["creation"].ToString()),
                    LastAccessTimeUtc = DateTime.Parse(dRow["access"].ToString()),
                    LastWriteTimeUtc  = DateTime.Parse(dRow["modification"].ToString()),
                    Attributes        = (FileAttributes)int.Parse(dRow["attributes"].ToString())
                };

                entries.Add(fEntry);
            }

            return(true);
        }
Exemple #2
0
        public bool AddFolderToApp(DbFolder folder, long app)
        {
            IDbCommand     dbcmd = GetFolderCommand(folder);
            IDbTransaction trans = dbCon.BeginTransaction();

            dbcmd.Transaction = trans;

            string sql =
                $"INSERT INTO `app_{app}_folders` (`path`, `creation`, `access`, `modification`, `attributes`)" +
                " VALUES (@path, @creation, @access, @modification, @attributes)";

            dbcmd.CommandText = sql;

            dbcmd.ExecuteNonQuery();
            trans.Commit();
            dbcmd.Dispose();

            return(true);
        }
Exemple #3
0
        IDbCommand GetFolderCommand(DbFolder folder)
        {
            IDbCommand dbcmd = dbCon.CreateCommand();

            IDbDataParameter param1 = dbcmd.CreateParameter();
            IDbDataParameter param4 = dbcmd.CreateParameter();
            IDbDataParameter param5 = dbcmd.CreateParameter();
            IDbDataParameter param6 = dbcmd.CreateParameter();
            IDbDataParameter param7 = dbcmd.CreateParameter();

            param1.ParameterName = "@path";
            param4.ParameterName = "@creation";
            param5.ParameterName = "@access";
            param6.ParameterName = "@modification";
            param7.ParameterName = "@attributes";

            param1.DbType = DbType.String;
            param4.DbType = DbType.String;
            param5.DbType = DbType.String;
            param6.DbType = DbType.String;
            param7.DbType = DbType.Int32;

            param1.Value = folder.Path;
            param4.Value = folder.CreationTimeUtc.ToString("yyyy-MM-dd HH:mm");
            param5.Value = folder.LastAccessTimeUtc.ToString("yyyy-MM-dd HH:mm");
            param6.Value = folder.LastWriteTimeUtc.ToString("yyyy-MM-dd HH:mm");
            param7.Value = (int)folder.Attributes;

            dbcmd.Parameters.Add(param1);
            dbcmd.Parameters.Add(param4);
            dbcmd.Parameters.Add(param5);
            dbcmd.Parameters.Add(param6);
            dbcmd.Parameters.Add(param7);

            return(dbcmd);
        }