//Getting the list of objects to be displayed in dropdown list. public List <DataObject> GetObjects() { DatabaseDictionary _dictionary = _dataLayer.GetDatabaseDictionary(); List <DataObject> objects = _dictionary.dataObjects; return(objects); }
public Response SaveDatabaseDictionary(string project, string application, DatabaseDictionary dict) { StringBuilder sb = new StringBuilder(); Response response = new Response(); try { sb.Append(dbDictionaryFullFilePath); sb.Append("DatabaseDictionary."); sb.Append(project); sb.Append("."); sb.Append(application); sb.Append(".xml"); Utility.Write <DatabaseDictionary>(dict, sb.ToString()); response.Add("Database Dictionary saved successfully"); return(response); } catch (Exception ex) { _logger.Error("Error in SaveDatabaseDictionary: " + ex); response.Add("Error in saving database dictionary" + ex.Message); return(response); } }
public ActionResult SaveDBDictionary() { try { string scope = Request.Params["scope"]; string app = Request.Params["app"]; var reader = new StreamReader(Request.InputStream); var json = reader.ReadToEnd(); DatabaseDictionary dictionary = Utility.FromJson <DatabaseDictionary>(json); Response response = _repository.SaveDBDictionary(scope, app, dictionary); if (response.Level == StatusLevel.Success) { string dictKey = string.Format("Dictionary.{0}.{1}", scope, app); Session[dictKey] = dictionary; return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = response.Messages, stackTraceDescription = response.StatusText }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { //return Json(new { success = true, message = e.ToString() }); // return null; _logger.Error(e.ToString()); _CustomErrorLog = new CustomErrorLog(); _CustomError = _CustomErrorLog.customErrorLogger(ErrorMessages.errUISaveDBDirectory, e, _logger); return(Json(new { success = false, message = "[ Message Id " + _CustomError.msgId + "] - " + _CustomError.errMessage, stackTraceDescription = _CustomError.stackTraceDescription }, JsonRequestBehavior.AllowGet)); } }
public DatabaseDictionary GetDictionary(string projectName, string applicationName) { DatabaseDictionary databaseDictionary = new DatabaseDictionary(); try { InitializeScope(projectName, applicationName); string keyFile = string.Format("{0}{1}.{2}.key", _settings["AppDataPath"], _settings["ProjectName"], _settings["ApplicationName"]); if (File.Exists(_settings["DBDictionaryPath"])) { databaseDictionary = NHibernateUtility.LoadDatabaseDictionary( _settings["DBDictionaryPath"], keyFile); } else { databaseDictionary = new DatabaseDictionary(); NHibernateUtility.SaveDatabaseDictionary(databaseDictionary, _settings["DBDictionaryPath"], keyFile); } } catch (Exception ex) { _logger.Error("Error in GetDbDictionary: " + ex); return(null); } return(databaseDictionary); }
public Response PostDictionary(string projectName, string applicationName, DatabaseDictionary databaseDictionary) { Response response = new Response(); try { InitializeScope(projectName, applicationName); string keyFile = string.Format("{0}{1}.{2}.key", _settings["AppDataPath"], _settings["ProjectName"], _settings["ApplicationName"]); NHibernateUtility.SaveDatabaseDictionary(databaseDictionary, _settings["DBDictionaryPath"], keyFile); Response genRes = Generate(projectName, applicationName); response.Append(genRes); } catch (Exception ex) { _logger.Error("Error updating dictionary: " + ex); response.Level = StatusLevel.Error; response.Messages.Add("Error updating dictionary" + ex.Message); } return(response); }
public void GetDictionary() { DatabaseDictionary dictionary = _hibernateProvider.GetDictionary( _settings["ProjectName"], _settings["ApplicationName"]); Assert.AreNotEqual(0, dictionary.dataObjects.Count); }
//[Test] public void PostDictionary() { string dictionaryPath = String.Format( "{0}DatabaseDictionary.{1}.{2}.xml", _settings["AppDataPath"], _settings["ProjectName"], _settings["ApplicationName"] ); DatabaseDictionary dictionary = Utility.Read <DatabaseDictionary>(dictionaryPath); List <string> schemaObjects = _hibernateProvider.GetSchemaObjects( _settings["ProjectName"], _settings["ApplicationName"]); dictionary.dataObjects.Clear(); foreach (string schemaObjectName in schemaObjects) { DataObject schemaObject = _hibernateProvider.GetSchemaObjectSchema( _settings["ProjectName"], _settings["ApplicationName"], schemaObjectName ); dictionary.dataObjects.Add(schemaObject); } dictionary.enableSummary = true; Response response = _hibernateProvider.PostDictionary( _settings["ProjectName"], _settings["ApplicationName"], dictionary); Assert.AreEqual(StatusLevel.Success, response.Level); Assert.AreNotEqual(0, response.StatusList.Count); }
public Response PostDictionary(string scope, string application, DatabaseDictionary dictionary) { OutgoingWebResponseContext context = WebOperationContext.Current.OutgoingResponse; context.ContentType = "application/xml"; return(_NHibernateProvider.PostDictionary(scope, application, dictionary)); }
public override DataDictionary GetDictionary() { if (_dataDictionary == null) { try { getConfigure(); Connect(); _databaseDictionary = new DatabaseDictionary(); _databaseDictionary.dataObjects = new List <DataObject>(); foreach (BusinessObject businessObject in _config.businessObjects) { DataObject dataObject = CreateDataObject(businessObject); _databaseDictionary.dataObjects.Add(dataObject); } Utility.Write <DatabaseDictionary>(_databaseDictionary, "C:\\temp\\DatabaseDictionary.12345_000.SP3D.xml"); Generate(_settings["ProjectName"], _settings["ApplicationName"]); readDictionary(); } catch (Exception ex) { _logger.Error("connect SP3D: " + ex.ToString()); throw ex; } } return(_dataDictionary); }
public override Response Refresh(string objectType) { string keyFile = string.Format("{0}{1}.{2}.key", _settings["AppDataPath"], _settings["ProjectName"], _settings["ApplicationName"]); if (File.Exists(_settings["DBDictionaryPath"])) { _dbDictionary = NHibernateUtility.LoadDatabaseDictionary(_settings["DBDictionaryPath"], keyFile); } if (_dbDictionary == null || _dbDictionary.dataObjects == null) { Response response = new Response() { Level = StatusLevel.Error, Messages = new Messages() { "Dictionary is empty." }, }; return(response); } return(Generate(_settings["projectName"], _settings["applicationName"])); }
public static DatabaseDictionary LoadDatabaseDictionary(string path, string keyFile) { DatabaseDictionary dbDictionary = Utility.Read <DatabaseDictionary>(path); string connStr = dbDictionary.ConnectionString; if (connStr != null) { if (!Utility.IsBase64Encoded(connStr)) { // // connection string is not encrypted, encrypt and write it back // dbDictionary.ConnectionString = EncryptionUtility.Encrypt(connStr, keyFile); Utility.Write <DatabaseDictionary>(dbDictionary, path); dbDictionary.ConnectionString = connStr; } else { dbDictionary.ConnectionString = EncryptionUtility.Decrypt(connStr, keyFile); } } return(dbDictionary); }
public ActionResult DBDictionary(FormCollection form) { try { DatabaseDictionary dbDict = _repository.GetDBDictionary(form["scope"], form["app"]); return(Json(dbDict, JsonRequestBehavior.AllowGet)); } catch (Exception e) { _logger.Error(e.ToString()); if (e.InnerException != null) { string description = ((System.Net.HttpWebResponse)(((System.Net.WebException)(e.InnerException)).Response)).StatusDescription; var jsonSerialiser = new JavaScriptSerializer(); CustomError json = (CustomError)jsonSerialiser.Deserialize(description, typeof(CustomError)); return(Json(new { success = false, message = "[ Message Id " + json.msgId + "] - " + json.errMessage, stackTraceDescription = json.stackTraceDescription }, JsonRequestBehavior.AllowGet)); } else { _CustomErrorLog = new CustomErrorLog(); _CustomError = _CustomErrorLog.customErrorLogger(ErrorMessages.errUIDBDictionary, e, _logger); return(Json(new { success = false, message = "[ Message Id " + _CustomError.msgId + "] - " + _CustomError.errMessage, stackTraceDescription = _CustomError.stackTraceDescription }, JsonRequestBehavior.AllowGet)); } //throw e; } }
public override DatabaseDictionary GetDatabaseDictionary() { try { string dictionaryPath = string.Format("{0}DataDictionary.{1}.{2}.xml", _dataPath, _project, _application); if (!File.Exists(dictionaryPath)) { RefreshDataTable(string.Empty); } DataDictionary dataDictionary = IU.Utility.Read <DataDictionary>(dictionaryPath); _dbDictionary = new DatabaseDictionary() { Provider = Utility.GetDBType(_stagingConnStr).ToString(), dataObjects = dataDictionary.dataObjects }; } catch (Exception ex) { string error = "Error getting data dictionary: " + ex.Message; _logger.Error(error); throw ex; } _dbDictionary.dataVersion = "1.4"; return(_dbDictionary); }
public Response PostDictionaryToAdapterService(string projectName, string applicationName) { StringBuilder relativeUri = new StringBuilder(); string filePath = WebConfigurationManager.AppSettings["DbDictionaryFullFilePath"]; StringBuilder filename = new StringBuilder(); filename.Append(filePath); filename.Append("DatabaseDictionary."); filename.Append(projectName); filename.Append("."); filename.Append(applicationName); filename.Append(".xml"); relativeUri.Append("/"); relativeUri.Append(projectName); relativeUri.Append("/"); relativeUri.Append(applicationName); relativeUri.Append("/dbdictionary"); DatabaseDictionary dbDictionary = Utility.Read <DatabaseDictionary>(filename.ToString()); WebHttpClient httpClient = new WebHttpClient(adapterServiceUri, null); Response response = httpClient.Post <DatabaseDictionary, Response>(relativeUri.ToString(), dbDictionary, true); return(response); }
public override DatabaseDictionary GetDatabaseDictionary() { _dictionary = Utility.Read <DatabaseDictionary>(@"./../SQLDataLayer/SampleDictionary.xml"); string connStr = EncryptionUtility.Decrypt(_dictionary.ConnectionString); _conn = new SqlConnection(connStr); return(_dictionary); }
void ConstructTreeView(DatabaseDictionary dict, TreeViewItem root) { TreeViewItem tableTreeViewItem = null; TreeViewItem columnTreeViewItem = null; bool enableCheckBox = false; if (root.Name != "tvwItemSourceRoot") { enableCheckBox = true; } try { root.Tag = dict.connectionString + "~" + dict.provider; if (dict.dataObjects == null) { dict.dataObjects = new List <DataObject>(); } foreach (DataObject table in dict.dataObjects) { tableTreeViewItem = new TreeViewItem() { Header = table.tableName }; tableTreeViewItem.Tag = table; root.IsExpanded = true; foreach (org.iringtools.library.KeyProperty key in table.keyProperties) { columnTreeViewItem = new TreeViewItem(); columnTreeViewItem.Tag = key; AddTreeItem(tableTreeViewItem, columnTreeViewItem, key.columnName, "Magenta", false); AddTreeItem(columnTreeViewItem, new TreeViewItem(), "Data Length = " + key.dataLength.ToString(), null, false); AddTreeItem(columnTreeViewItem, new TreeViewItem(), "Column Type = " + key.dataType.ToString(), null, false); // AddTreeItem(columnTreeViewItem, new TreeViewItem(), "Data Type = " + key.dataType.ToString(), null, false); AddTreeItem(columnTreeViewItem, new TreeViewItem(), "Is Nullable = " + key.isNullable, null, false); AddTreeItem(columnTreeViewItem, new TreeViewItem(), "Key Type = " + key.keyType, null, false); AddTreeItem(columnTreeViewItem, new TreeViewItem(), "Property Name = " + key.propertyName, null, false); } foreach (DataProperty column in table.dataProperties) { columnTreeViewItem = new TreeViewItem(); columnTreeViewItem.Tag = column; AddTreeItem(tableTreeViewItem, columnTreeViewItem, column.columnName, null, enableCheckBox); AddTreeItem(columnTreeViewItem, new TreeViewItem(), "Data Length = " + column.dataLength.ToString(), null, false); AddTreeItem(columnTreeViewItem, new TreeViewItem(), "Column Type = " + column.dataType.ToString(), null, false); // AddTreeItem(columnTreeViewItem, new TreeViewItem(), "Data Type = " + column.dataType.ToString(), null, false); AddTreeItem(columnTreeViewItem, new TreeViewItem(), "Is Nullable = " + column.isNullable, null, false); AddTreeItem(columnTreeViewItem, new TreeViewItem(), "Property Name = " + column.propertyName, null, false); } AddTreeItem(root, tableTreeViewItem, table.tableName, null, enableCheckBox); } root.Visibility = Visibility.Visible; } catch (Exception ex) { throw new Exception(ex.Message); } }
public override void Execute(Database database, IIssueCollector issueCollector, IProviderCollection providers) { this._nodeProps = DictionaryFactory.CreateTableID <NodeProperties>(); this._foundCycles = new List <List <Table> >(); this._stack = new Stack <Table>(); this._index = 0; foreach (var table in database.Tables) { if (!this._nodeProps.ContainsKey(table)) { this.Tarjan(table); } } foreach (var cycle in this._foundCycles) { var canInsert = false; var foundTables = new Dictionary <Table, List <ForeignKey> >(); foreach (var table in cycle) { var fksValues = table.ForeignKeys.Where(p => cycle.Contains(p.PKTable)).ToList(); foundTables.Add(table, fksValues); foreach (var fkValue in fksValues) { if (fkValue.ColumnPairs.All(f => f.FKColumn.IsNullable) || (fkValue.Deferrability == Deferrability.Deferrable && fkValue.InitialMode == InitialMode.InitiallyDeferred)) { canInsert = true; } } } var issue = new Issue(this, this.DefaultSeverity.Value); issue.Name = "Cycle Dependency Between Tables"; issue.Context = IssueContext.Create(cycle); string tableList = String.Join(", ", cycle.Select(c => c.TableName)); if (tableList.Length > 20) { tableList = tableList.Substring(0, 20) + "..."; } issue.Description = new Description("Cycle dependency between {0} tables: {1}", cycle.Count, tableList); var str = new StringBuilder(); // Delete rules is no longer included in the check because of complex cycles if (!canInsert) { str.Append("There is a cycle dependency, where the referential constraints could yield problems."); str.Append("\n- Deferability and initially-deferred configurations could complicate insert, update and delete statements."); issue.ExtendedDescription = new Description("{0}\n\nThe cycle contains the tables:\n\n{1}", str.ToString(), GetTable(foundTables)); } else { issue.Severity = CycleWithoutDeferabilityProblems.Value; issue.ExtendedDescription = new Description("There is a cyclic dependency, but there are no deferability constraints that could yield problems. Consider if the cyclic dependency is needed.\n\nThe cycle contains the tables:\n\n{0}", GetTable(foundTables)); } issueCollector.ReportIssue(issue); } }
static void DoPost(string adapterServiceUri, string projectName, string applicationName, string dbDictionaryFilePath) { Console.WriteLine("Posting " + dbDictionaryFilePath + " to iRING Adapter Service..."); string relativeUri = "/" + projectName + "/" + applicationName + "/dbdictionary"; DatabaseDictionary dbDictionary = Utility.Read <DatabaseDictionary>(dbDictionaryFilePath); WebHttpClient httpClient = new WebHttpClient(adapterServiceUri, null); Response response = httpClient.Post <DatabaseDictionary, Response>(relativeUri, dbDictionary, true); Console.WriteLine(response.ToString()); }
/// <summary> /// /// </summary> /// <param name="databaseDictionary">数据库路径,必须是~/开头</param> /// <param name="fileName"></param> public XmlDataContext(string databaseDictionary, string fileName = null) { DatabaseDictionary = string.IsNullOrEmpty(databaseDictionary) ? "~/App_Data/DataBase/" : databaseDictionary; if (!DatabaseDictionary.EndsWith("/")) { DatabaseDictionary += "/"; } if (!string.IsNullOrEmpty(fileName)) { FileName = fileName; } }
private bool ValidateDatabaseDictionary(DatabaseDictionary dbDictionary) { // Validate table key foreach (DataObject dataObject in dbDictionary.dataObjects) { if (dataObject.keyProperties == null || dataObject.keyProperties.Count == 0) { throw new Exception(string.Format("Table \"{0}\" has no key. Must select keys before saving.", dataObject.tableName)); } } return(true); }
public static void SaveDatabaseDictionary(DatabaseDictionary dbDictionary, string path, string keyFile) { string connStr = dbDictionary.ConnectionString; if (connStr != null) { if (Utility.IsBase64Encoded(connStr)) { // connection string is not encrypted, encrypt it dbDictionary.ConnectionString = EncryptionUtility.Encrypt(connStr, keyFile); } } Utility.Write <DatabaseDictionary>(dbDictionary, path); }
public override DataTable GetDataTable(string tableName, IList <string> identifiers) { try { DatabaseDictionary dbDictionary = GetDatabaseDictionary(); DataObject objDef = _dbDictionary.dataObjects.Find(p => p.tableName.ToLower() == tableName.ToLower()); string whereClause = FormWhereClause(objDef, identifiers); return(GetDataTable(tableName, whereClause, 0, 0)); } catch (Exception ex) { string error = "Error getting [" + string.Join(",", identifiers.ToArray() + "] from [" + tableName + "]: " + ex.Message); _logger.Error(error); throw new Exception(error); } }
private static void BrowseTables(Table table, DatabaseDictionary <TableID, Table> seenTables, DatabaseDictionary <TableID, Table> notSeen, List <Table> cluster) { cluster.Add(table); notSeen.Remove(table); seenTables.Add(table, table); foreach (var reference in table.References.Concat(table.ReferencedBy)) { if (seenTables.ContainsKey(reference) || !SchemaID.SchemaEquals(reference.Schema, table.Schema)) { continue; } else { BrowseTables(reference, seenTables, notSeen, cluster); } } }
public static string ToSqlWhereClause(DataFilter filter, DataObject objDef) { DatabaseDictionary dbDictionary = new DatabaseDictionary(); dbDictionary.Provider = "SQL Server"; DataObject newObjDef = Utility.CloneDataContractObject <DataObject>(objDef); foreach (DataProperty prop in newObjDef.dataProperties) { prop.columnName = ToQueryItem(prop, false); } dbDictionary.dataObjects.Add(newObjDef); return(filter.ToSqlWhereClause(dbDictionary, newObjDef.tableName, string.Empty)); }
public Response Generate(string projectName, string applicationName) { Response response = new Response(); Status status = new Status(); response.StatusList.Add(status); try { status.Identifier = String.Format("{0}.{1}", projectName, applicationName); InitializeScope(projectName, applicationName); string keyFile = string.Format("{0}{1}.{2}.key", _settings["AppDataPath"], _settings["ProjectName"], _settings["ApplicationName"]); DatabaseDictionary dbDictionary = NHibernateUtility.LoadDatabaseDictionary(_settings["DBDictionaryPath"], keyFile); if (String.IsNullOrEmpty(projectName) || String.IsNullOrEmpty(applicationName)) { status.Messages.Add("Error project name and application name can not be null"); } else if (ValidateDatabaseDictionary(dbDictionary)) { EntityGenerator generator = _kernel.Get <EntityGenerator>(); string compilerVersion = "v4.0"; if (!String.IsNullOrEmpty(_settings["CompilerVersion"])) { compilerVersion = _settings["CompilerVersion"]; } response.Append(generator.Generate(compilerVersion, dbDictionary, projectName, applicationName)); status.Messages.Add("Database dictionary of [" + projectName + "." + applicationName + "] updated successfully."); } } catch (Exception ex) { _logger.Error(string.Format("Error in UpdateDatabaseDictionary: {0}", ex)); status.Level = StatusLevel.Error; status.Messages.Add(string.Format("Error updating database dictionary: {0}", ex)); } return(response); }
public void SaveDabaseDictionary(DatabaseDictionary dict, string project, string application) { StringBuilder sb = new StringBuilder(); try { sb.Append(dbDictionaryFullFilePath); sb.Append("DatabaseDictionary."); sb.Append(project); sb.Append("."); sb.Append(application); sb.Append(".xml"); Utility.Write <DatabaseDictionary>(dict, sb.ToString()); } catch (Exception ex) { } }
public Response SaveDatabaseDictionary(DatabaseDictionary dict, string project, string application) { string message = Utility.SerializeDataContract <DatabaseDictionary>(dict); StringBuilder sb = new StringBuilder(); sb.Append(_dbDictionaryServiceUri); sb.Append("/"); sb.Append(project); sb.Append("/"); sb.Append(application); sb.Append("/savedbdictionary"); _savedbdictionaryClient.Headers["Content-type"] = "application/xml"; _savedbdictionaryClient.Encoding = Encoding.UTF8; _savedbdictionaryClient.UploadStringAsync(new Uri(sb.ToString()), "POST", message); return(null); }
private void BuildNewDbDictionary(string newProvider, string newProject, string newApplication, string newDataSourceName, string newDatabaseName, string newDatabaseUserName, string newDatabaseUserPassword) { newDictionary = new StringBuilder(); newDictionary.Append("DatabaseDictionary."); newDictionary.Append(newProject); newDictionary.Append("."); newDictionary.Append(newApplication); newDictionary.Append(".xml"); string connectionstring = BuildConnectionString(newProvider, newDataSourceName, newDatabaseName, newDatabaseUserName, newDatabaseUserPassword); DataObject table = new DataObject(); DatabaseDictionary dict = new DatabaseDictionary() { connectionString = connectionstring, provider = (Provider)Enum.Parse(typeof(Provider), newProvider, true), dataObjects = new List <DataObject>() }; _dal.SaveDatabaseDictionary(dict, newProject, newApplication); }
public DatabaseDictionary GetDbDictionary(string project, string application) { DatabaseDictionary dict = new DatabaseDictionary(); StringBuilder sb = new StringBuilder(); try { sb.Append(dbDictionaryFullFilePath); sb.Append("DatabaseDictionary."); sb.Append(project); sb.Append("."); sb.Append(application); sb.Append(".xml"); dict = Utility.Read <DatabaseDictionary>(sb.ToString()); } catch (Exception ex) { } return(dict); }
public DatabaseDictionary GetDBDictionary(string scope, string application) { try { WebHttpClient client = CreateWebClient(_hibernateServiceUri); DatabaseDictionary dbDictionary = client.Get <DatabaseDictionary>(String.Format("/{0}/{1}/dictionary", scope, application)); string connStr = dbDictionary.ConnectionString; if (!String.IsNullOrEmpty(connStr)) { dbDictionary.ConnectionString = Utility.EncodeTo64(connStr); } return(dbDictionary); } catch (Exception e) { _logger.Error(e.ToString()); throw; } }
public override DataDictionary GetDictionary() { try { string path = String.Format("{0}{1}DataDictionary.{2}.{3}.xml", _baseDirectory, _xmlPath, _projectName, _applicationName); if ((File.Exists(path))) { dynamic DataDictionary = Utility.Read<DataDictionary>(path); _dataDictionary = Utility.Read<DataDictionary>(path); return _dataDictionary; } DataDictionary dataDictionary = new DataDictionary(); string configPath = String.Format("{0}Configuration.{1}.{2}.xml", _baseDirectory + _xmlPath, _projectName, _applicationName); DataDictionary configDictionary = File.Exists(configPath) ? Utility.Read<DataDictionary>(configPath) : null; if (configDictionary != null) { dataDictionary.dataObjects = configDictionary.dataObjects; _dataDictionary = dataDictionary; DatabaseDictionary _databaseDictionary = new DatabaseDictionary(); _databaseDictionary.dataObjects = _dataDictionary.dataObjects; _databaseDictionary.ConnectionString = EncryptionUtility.Encrypt(_dbConnectionString); _databaseDictionary.Provider = "MDB"; _databaseDictionary.SchemaName = "dbo"; Utility.Write<DatabaseDictionary>(_databaseDictionary, String.Format("{0}{1}DataBaseDictionary.{2}.{3}.xml", _baseDirectory, _xmlPath, _projectName, _applicationName)); Utility.Write<DataDictionary>(_dataDictionary, String.Format("{0}{1}DataDictionary.{2}.{3}.xml", _baseDirectory, _xmlPath, _projectName, _applicationName)); } return _dataDictionary; # region OLDdictionaryGenerationFromSQL //string Connectionstring = string.Empty; //string path = String.Format("{0}{1}DataDictionary.{2}.{3}.xml", _baseDirectory, _xmlPath, _projectName, _applicationName); //try //{ // if ((File.Exists(path))) // { // dynamic DataDictionary = Utility.Read<DataDictionary>(path); // _dataDictionary = Utility.Read<DataDictionary>(path); // return _dataDictionary; // } // else // { // List<string> tableNames = LoadDataTable(); // _dataDictionary = LoadDataObjects(tableNames); // DatabaseDictionary _databaseDictionary = new DatabaseDictionary(); // _databaseDictionary.dataObjects = _dataDictionary.dataObjects; // _databaseDictionary.ConnectionString = _dbConnectionString; // _databaseDictionary.Provider = "MDB"; // _databaseDictionary.SchemaName = "dbo"; // Utility.Write<DatabaseDictionary>(_databaseDictionary, String.Format("{0}{1}DataBaseDictionary.{2}.{3}.xml", _baseDirectory, _xmlPath, _projectName, _applicationName)); // Utility.Write<DataDictionary>(_dataDictionary, String.Format("{0}{1}DataDictionary.{2}.{3}.xml", _baseDirectory, _xmlPath, _projectName, _applicationName)); // return _dataDictionary; // } #endregion } catch { string error = "Error in getting dictionary"; logger.Error(error); throw new Exception(error); } }
public override DatabaseDictionary GetDatabaseDictionary() { _dictionary = Utility.Read<DatabaseDictionary>(String.Format("{0}{1}DataBaseDictionary.{2}.{3}.xml", _baseDirectory, _xmlPath, _projectName, _applicationName)); string connStr = EncryptionUtility.Decrypt(_dictionary.ConnectionString); _conn = new SqlConnection(connStr); return _dictionary; }
private bool CreateSpoolinCache() { try { if (_dictionary == null) { _dictionary = GetDatabaseDictionary(); } StringBuilder sb = new StringBuilder(); foreach (DataObject dataobject in _dictionary.dataObjects) { string tableName = dataobject.tableName; string query = string.Empty; string vInheritColumns = string.Empty; foreach (DataProperty property in dataobject.dataProperties) { string isNullable = string.Empty; if (property.isNullable) isNullable = "NULL"; else isNullable = "NOT NULL"; if (property.dataType == DataType.String) { query = "[" + property.columnName + "] [varchar] (" + property.dataLength + ") " + isNullable + ","; } else if (property.dataType == DataType.DateTime) { query = "[" + property.columnName + "] [DATETIME] " + isNullable + ","; } else if (property.dataType == DataType.Int32 || property.dataType == DataType.Boolean) // Access saves booleans in 0 &1. { query = "[" + property.columnName + "] [INT] (" + property.dataLength + ") " + isNullable + ","; } sb.Append(query); } string sKeys = string.Empty; foreach (KeyProperty key in dataobject.keyProperties) { var list = (from dProperties in _dataDictionary.dataObjects[0].dataProperties where dProperties.propertyName == key.keyPropertyName select dProperties).ToList(); string TagNo = list[0].columnName; sKeys += TagNo + ","; } if (!string.IsNullOrEmpty(sKeys)) { sKeys = sKeys.Substring(0, sKeys.LastIndexOf(',')); sKeys = "PRIMARY KEY (" + sKeys + " )"; sb.Append(sKeys); vInheritColumns = sb.ToString(); } else { vInheritColumns = sb.ToString(0, sb.Length - 1); } ConnectToSqL(); SqlCommand sqlcomm = new SqlCommand(); sqlcomm.Connection = _conn; // First, dropping the table if it exists. sqlcomm.CommandText = string.Format(SqlConstant.DROP_DB, tableName); sqlcomm.ExecuteNonQuery(); // Second, Creating the table in the cache. sqlcomm.CommandText = "CREATE TABLE [dbo].[" + tableName + "] (" + vInheritColumns + ")"; sqlcomm.ExecuteNonQuery(); } } catch (Exception ex) { logger.Info("Error occured while creating the spool in cache : " + ex.Message); return false; } finally { disconnectSqL(); } return true; }
public override Response RefreshAll() { Response response = new Response(); try { _databaseDictionary = null; System.IO.File.Delete(_dictionaryPath); GetDictionary(); response.Level = StatusLevel.Success; } catch (Exception e) { response.Level = StatusLevel.Error; response.Messages = new Messages() { e.Message }; } return response; }
public override DataDictionary GetDictionary() { if (_dataDictionary == null) { try { getConfigure(); Connect(); _databaseDictionary = new DatabaseDictionary(); _databaseDictionary.dataObjects = new List<DataObject>(); foreach (BusinessObject businessObject in _config.businessObjects) { DataObject dataObject = CreateDataObject(businessObject); _databaseDictionary.dataObjects.Add(dataObject); } Utility.Write<DatabaseDictionary>(_databaseDictionary, "C:\\temp\\DatabaseDictionary.12345_000.SP3D.xml"); Generate(_settings["ProjectName"], _settings["ApplicationName"]); readDictionary(); } catch (Exception ex) { _logger.Error("connect SP3D: " + ex.ToString()); throw ex; } } return _dataDictionary; }
public override DatabaseDictionary GetDatabaseDictionary() { _dictionary = Utility.Read<DatabaseDictionary>(@"./../SQLDataLayer/SampleDictionary.xml"); string connStr = EncryptionUtility.Decrypt(_dictionary.ConnectionString); _conn = new SqlConnection(connStr); return _dictionary; }
public static string ToSqlWhereClause(DataFilter filter, DataObject objDef) { DatabaseDictionary dbDictionary = new DatabaseDictionary(); dbDictionary.Provider = "SQL Server"; DataObject newObjDef = Utility.CloneDataContractObject<DataObject>(objDef); foreach (DataProperty prop in newObjDef.dataProperties) { prop.columnName = ToQueryItem(prop, false); } dbDictionary.dataObjects.Add(newObjDef); return filter.ToSqlWhereClause(dbDictionary, newObjDef.tableName, string.Empty); }
public override DatabaseDictionary GetDatabaseDictionary() { try { string dictionaryPath = string.Format("{0}DataDictionary.{1}.{2}.xml", _dataPath, _project, _application); if (!File.Exists(dictionaryPath)) { RefreshDataTable(string.Empty); } DataDictionary dataDictionary = IU.Utility.Read<DataDictionary>(dictionaryPath); _dbDictionary = new DatabaseDictionary() { Provider = Utility.GetDBType(_stagingConnStr).ToString(), dataObjects = dataDictionary.dataObjects }; } catch (Exception ex) { string error = "Error getting data dictionary: " + ex.Message; _logger.Error(error); throw ex; } _dbDictionary.dataVersion = "1.4"; return _dbDictionary; }
public override DataDictionary GetDictionary() { string Connectionstring = string.Empty; string path = String.Format("{0}{1}DataDictionary.{2}.{3}.xml", _baseDirectory, _xmlPath, _projectName, _applicationName); try { if ((File.Exists(path))) { dynamic DataDictionary = Utility.Read<DataDictionary>(path); _dataDictionary = Utility.Read<DataDictionary>(path); return _dataDictionary; } else { _dataDictionary = CreateDataDictionary(); DatabaseDictionary _databaseDictionary = new DatabaseDictionary(); _databaseDictionary.dataObjects = _dataDictionary.dataObjects; _databaseDictionary.ConnectionString = EncryptionUtility.Encrypt(Connectionstring); _databaseDictionary.Provider = "dummy"; _databaseDictionary.SchemaName = "dummy"; Utility.Write<DatabaseDictionary>(_databaseDictionary, String.Format("{0}{1}DataBaseDictionary.{2}.{3}.xml", _baseDirectory, _xmlPath, _projectName, _applicationName)); Utility.Write<DataDictionary>(_dataDictionary, String.Format("{0}{1}DataDictionary.{2}.{3}.xml", _baseDirectory, _xmlPath, _projectName, _applicationName)); return _dataDictionary; } } catch { string error = "Error in getting dictionary"; // _logger.Error(error); throw new ApplicationException(error); } }