Example #1
0
        public bool GetAllFilesInOs(out List <DbOsFile> entries, long id)
        {
            entries = new List <DbOsFile>();

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

            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)
            {
                DbOsFile fEntry = new DbOsFile
                {
                    Id                = ulong.Parse(dRow["id"].ToString()),
                    Path              = dRow["path"].ToString(),
                    Sha256            = dRow["sha256"].ToString(),
                    Length            = long.Parse(dRow["length"].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);
        }
Example #2
0
        IDbCommand GetOsFileCommand(DbOsFile person)
        {
            IDbCommand dbcmd = dbCon.CreateCommand();

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

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

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

            param1.Value = person.Path;
            param2.Value = person.Sha256;
            param3.Value = person.Length;
            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(param2);
            dbcmd.Parameters.Add(param3);
            dbcmd.Parameters.Add(param4);
            dbcmd.Parameters.Add(param5);
            dbcmd.Parameters.Add(param6);
            dbcmd.Parameters.Add(param7);

            return(dbcmd);
        }
Example #3
0
        public bool AddFileToOs(DbOsFile file, long os)
        {
            IDbCommand     dbcmd = GetOsFileCommand(file);
            IDbTransaction trans = dbCon.BeginTransaction();

            dbcmd.Transaction = trans;

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

            dbcmd.CommandText = sql;

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

            return(true);
        }