Esempio n. 1
0
 public static DataTable CreateTable(this AbpSql s, string query)
 {
     using SqlConnection cn = new SqlConnection(s.CN);
     cn.Open();
     using IDataReader dtr = new SqlCommand(query, cn).ExecuteReader(CommandBehavior.CloseConnection);
     return(AsIDataReader(dtr));
 }
Esempio n. 2
0
        public static async Task <DataTable> CreateTableAsync(this AbpSql s, string query)
        {
            using SqlConnection cn = new SqlConnection(s.CN);
            await cn.OpenAsync();

            using IDataReader dtr = await new SqlCommand(query, cn).ExecuteReaderAsync(CommandBehavior.CloseConnection);
            return(AsIDataReader(dtr));
        }
Esempio n. 3
0
 public static byte[] DownloadFile(this AbpSql s, string name)
 {
     using SqlConnection cn = new SqlConnection(s.CN);
     using SqlCommand cmd   = cn.CreateCommand();
     cmd.CommandText        = $@"SELECT FileBytes FROM {s.TABLE} WHERE  FileName = @name";
     cmd.Parameters.AddWithValue("@name", name);
     cn.Open();
     byte[] result = cmd.ExecuteScalar() as byte[];
     cn.Close();
     return(result);
 }
Esempio n. 4
0
 public static void UploadFile(this AbpSql s, byte[] bytes, string file)
 {
     try
     {
         using SqlConnection cn = new SqlConnection(s.CN);
         using SqlCommand cmd   = new SqlCommand
               {
                   CommandText = $@"insert into {s.TABLE} (FileBytes,FileName,FileType,UploadDate) values (@data,@name,@ext,@upload)",
                   Connection  = cn,
                   CommandType = CommandType.Text
               };
         cmd.Parameters.Add("@data", SqlDbType.VarBinary, bytes.Length).Value = bytes;
         cmd.Parameters.Add("@name", SqlDbType.VarChar).Value    = file.Split('.')[0];
         cmd.Parameters.Add("@ext", SqlDbType.VarChar).Value     = file.Split('.')[1];
         cmd.Parameters.Add("@upload", SqlDbType.DateTime).Value = DateTime.Now;
         cn.Open();
         cmd.ExecuteNonQuery();
         cn.Close();
     }
     catch (Exception)
     {
     }
 }
Esempio n. 5
0
 public AbpSqlEvents(AbpSql SqlObject, Action <object, PropertyChangedEventArgs> PropertyMethod, int interval = 1000)
 {
     s = SqlObject;
     _PropertyMethod = PropertyMethod;
     _interval       = interval;
 }