Exemplo n.º 1
0
        public bool GetAllFolders(out List <DbFolder> entries, long id)
        {
            entries = new List <DbFolder>();

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

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

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

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

            foreach (DataRow dRow in dataTable.Rows)
            {
                DbFolder 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);
        }
Exemplo n.º 2
0
        public bool AddFolderToOs(DbFolder folder, long os)
        {
            IDbCommand     dbcmd = GetFolderCommand(folder);
            IDbTransaction trans = dbCon.BeginTransaction();

            dbcmd.Transaction = trans;

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

            dbcmd.CommandText = sql;

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

            return(true);
        }
Exemplo n.º 3
0
        IDbCommand GetFolderCommand(DbFolder person)
        {
            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 = person.Path;
            param4.Value = person.CreationTimeUtc.ToString("yyyy-MM-dd HH:mm");
            param5.Value = person.LastAccessTimeUtc.ToString("yyyy-MM-dd HH:mm");
            param6.Value = person.LastWriteTimeUtc.ToString("yyyy-MM-dd HH:mm");
            param7.Value = (int)person.Attributes;

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

            return(dbcmd);
        }