Add project files.

This commit is contained in:
Thomas Savine
2020-03-06 16:07:06 +00:00
parent e7b186c7e3
commit 70de9715ce
300 changed files with 43679 additions and 0 deletions
@@ -0,0 +1,71 @@
using Sarand.Core.Base;
using Sarand.Core.Dbas.Base;
using Sarand.Win.Dbas.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sarand.OperationsMgr.Win.Dbas.Data
{
//=======================================================================
public abstract class OpnDbDataItem : DbDataItem
{
//-------------------------------------------------------------------
// Definitions.
/// <summary>
/// Database information - object supplied by main application.
/// <para>NB Application may have multiple databases with schema differences.</para>
/// <para>Each instance of a DbDataItem must be database specific.</para>
/// </summary>
public class OpnDatabaseInfo : IDatabaseInfo
{
// Data members.
private readonly List<DbDfnTable> tables;
private static readonly String defaultSchemaName = "dbo";
// Construction.
public OpnDatabaseInfo(String databaseName, List<DbDfnTable> tables)
{
}
// Properties.
public String DatabaseName { get; }
public String Context { get { return StringUtil.OnEmpty(DatabaseName, "UnknownDb"); } }
// Database schema.
public DbDfnTable GetTableDefinition (String schemaName, String tableName)
{
foreach (DbDfnTable table in tables.FindAll(item => item.Name.EqualsCI(tableName)))
{
if (StringUtil.OnEmpty(table.Schema, defaultSchemaName).EqualsCI(StringUtil.OnEmpty(schemaName, defaultSchemaName)))
return table;
}
return null;
}
public bool TableExists (String schemaName, String tableName)
{
return GetTableDefinition(schemaName, tableName) != null;
}
public bool ColumnExists (String schemaName, String tableName, String columnName)
{
DbDfnTable table = GetTableDefinition(schemaName, tableName);
if (table == null) return false;
return table.HasColumnByName(columnName);
}
public List<DbDfnColumn> GetColumnsForTable (String schemaName, String tableName)
{
DbDfnTable table = GetTableDefinition(schemaName, tableName);
if (table != null) return table.Columns;
return new List<DbDfnColumn>();
}
}
//-------------------------------------------------------------------
// Construction.
protected OpnDbDataItem (IDatabaseInfo dbInfo) : base(dbInfo)
{
}
//-------------------------------------------------------------------
}
//=======================================================================
}