示例#1
0
 private void CheckFileAvailability()
 {
     try
     {
         var dbDetails = _metaData.ReadAllDetails();
         using (var conn = _sqlDatabaseFactory.GetConnection())
         {
             foreach (DataRow row in dbDetails.Rows)
             {
                 var pathToFile = row.Field <string>("PathToFile");
                 if (!File.Exists(pathToFile))
                 {
                     var command = conn.CreateCommand();
                     command.CommandText = "DELETE FROM DbDetails WHERE PathToFile=@pathToFile";
                     command.Parameters.AddWithValue("@pathToFile", pathToFile);
                     conn.Open();
                     command.ExecuteNonQuery();
                     conn.Close();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#2
0
        public DataTable ReadAllDetails()
        {
            DataTable table = new DataTable();

            using (var conn = _sqlDatabaseFactory.GetConnection())
            {
                var command = conn.CreateCommand();
                command.CommandText = "Select * from DbDetails";
                SqlDataAdapter da = new SqlDataAdapter();
                using (da = new SqlDataAdapter(command))
                {
                    da.Fill(table);
                }
            }
            return(table);
        }