/// <summary> /// Retorna um objeto DatabaseStructureDTO contendo o schema do Banco de dados. /// </summary> /// <param name="schema">Nome do schema representado no Banco de dados. Ex.: emp0001</param> public DatabaseStructureDTO GetSchema(string schema) { try { dbCommand = db.GetSqlStringCommand("SELECT nspname FROM pg_namespace" + " WHERE nspname = @schema;"); db.AddInParameter(dbCommand, "@schema", DbType.String, schema); using (IDataReader DR = db.ExecuteReader(dbCommand)) { DR.Read(); DatabaseStructureDTO tab = new DatabaseStructureDTO(); tab.Name = DR["nspname"].ToString(); return(tab); } } catch { throw; } }
public static Status Submit(int id, string leadin, string count, string newsitems, string highlightitems) { Status stat = new Status(); GenericDatabase db = new GenericDatabase(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString, DbProviderFactories.GetFactory("MySql.Data.MySqlClient")); DbCommand cmd = db.GetStoredProcCommand("ins_media"); DateTime dte = DateTime.Now; string name = ""; name = "BOD_News_" + GetWeekNumber(dte).ToString() + "_" + id.ToString() + "_" + dte.Year.ToString(); db.AddOutParameter(cmd, "ReturnCode", DbType.Int32, 8); db.AddOutParameter(cmd, "ErrorMessage", DbType.String, 500); db.AddOutParameter(cmd, "NewID", DbType.Int32, 8); db.AddInParameter(cmd, "InID", DbType.Int32, id); db.AddInParameter(cmd, "InName", DbType.String, name); db.AddInParameter(cmd, "InLeadin", DbType.String, leadin); db.AddInParameter(cmd, "InCount", DbType.String, count); db.AddInParameter(cmd, "InNewsItems", DbType.String, newsitems); db.AddInParameter(cmd, "InHighlightItems", DbType.String, highlightitems); db.ExecuteNonQuery(cmd); stat.ReturnCode = db.GetParameterValue(cmd, "ReturnCode") != null ? (Int32)db.GetParameterValue(cmd, "ReturnCode") : 0; stat.ErrorMessage = name + ".html"; stat.NewID = db.GetParameterValue(cmd, "NewID") != null?db.GetParameterValue(cmd, "NewID").ToString() : "0"; Entry item = new Entry(); item.Name = name; item.LeadIn = leadin; item.NewItems = newsitems; item.HighlightItems = highlightitems; item.Count = count; CreateHTML(item); return(stat); }
/// <summary> /// Verifica a existência de um Banco de dados específico no servidor. /// </summary> /// <param name="databasename">Nome do Banco de dados</param> /// <returns>VERDADEIRO caso já exista o Banco de dados</returns> public bool ExistsDatabase(string databasename) { try { dbCommand = db.GetSqlStringCommand("SELECT datname FROM pg_database" + " WHERE datname = @databasename;"); db.AddInParameter(dbCommand, "@databasename", DbType.String, databasename); using (IDataReader DR = db.ExecuteReader(dbCommand)) { DR.Read(); DR["datname"].ToString(); return(true); } } catch { return(false); } }