internal static bool TestConnection(bool showSuccess, ArchAngel.Providers.EntityModel.UI.PropertyGrids.ucDatabaseInformation dbInfo) { Monitor.Enter(databaseLock); try { if (!dbInfo.ReadyToProceed()) return false; dbInfo.SetDatabaseOperationResults(new DatabaseOperationResults("Testing connection...", true)); IDatabaseLoader loader = DatabasePresenter.CreateDatabaseLoader(dbInfo); try { loader.TestConnection(); if (showSuccess) dbInfo.SetDatabaseOperationResults(new DatabaseOperationResults("Connection Test", true)); return true; } catch (DatabaseLoaderException e) { DatabaseOperationResults results = new DatabaseOperationResults("Connection Test", false, e.ActualMessage); dbInfo.SetDatabaseOperationResults(results); return false; } } finally { Monitor.Exit(databaseLock); } }
public TreeListNode AddTreeListNode(ArchAngel.Providers.Database.Model.Column column, bool selectedOnly) { TreeListNode newNode = null; ArchAngel.Providers.Database.Model.Filter.OrderByColumn orderColumn = null; foreach (ArchAngel.Providers.Database.Model.Filter.OrderByColumn orderCol in Owner.Filter.OrderByColumns) { if (orderCol.Column.Name == column.Name && orderCol.Column.Parent.Name == column.Parent.Name) { orderColumn = orderCol; break; } } if (orderColumn != null && selectedOnly) { newNode = treeList1.AppendNode(new object[] { orderColumn.Column.Parent.Name, orderColumn.Column.Name, orderColumn.SortOperator }, null); newNode.StateImageIndex = 1; newNode.Tag = orderColumn; } else if (orderColumn == null && !selectedOnly) { newNode = treeList1.AppendNode(new object[] { column.Parent.Name, column.Name, "" }, null); newNode.StateImageIndex = 0; newNode.Tag = column; } return newNode; }
public TreeListNode AddTreeListNode(ArchAngel.Providers.Database.Model.Column column) { TreeListNode newNode; ArchAngel.Providers.Database.Model.Filter.FilterColumn filterColumn = null; foreach (ArchAngel.Providers.Database.Model.Filter.FilterColumn filterCol in Owner.Filter.FilterColumns) { if (filterCol.Column.Name == column.Name && filterCol.Column.Parent.Name == column.Parent.Name) { filterColumn = filterCol; break; } } if (filterColumn != null) { newNode = treeList1.AppendNode(new object[] { filterColumn.Column.Parent.Name, filterColumn.Column.Name, filterColumn.Column.Alias, filterColumn.LogicalOperator, filterColumn.CompareOperator }, null); newNode.StateImageIndex = 1; newNode.Tag = filterColumn; } else { newNode = treeList1.AppendNode(new object[] { column.Parent.Name, column.Name, column.Alias, "", "" }, null); newNode.StateImageIndex = 0; newNode.Tag = column; } return newNode; }
internal void Populate(ArchAngel.Interfaces.ProjectOptions.DatabaseScripts.MaintenanceScript script, string scriptType) { Script = script; CurrentScriptType = scriptType; switch (scriptType) { case "Default": SetText(Script.Header); break; //case "Header": // SetText(Script.Header); // break; //case "Create": // SetText(Script.Create); // break; //case "Update": // SetText(Script.Update); // break; //case "Delete": // SetText(Script.Delete); // break; default: throw new NotImplementedException("Script type not handled yet: " + scriptType); } if (!IntelliSenseIsInitialized) SetupIntelliSense(); }
private void AddPropertyToPropertiesGrid(ArchAngel.Providers.EntityModel.Model.EntityLayer.Property property, bool hasMultiSchemas) { SlyceTreeGridItem gridItem = new SlyceTreeGridItem(); gridItem.Tag = property; gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.Name)); gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.Type)); gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.NHibernateType)); int numTables = MappedTables.Count; IColumn mappedColumn = property.MappedColumn(); string mappedColumnName; if (mappedColumn == null) mappedColumnName = ""; else if (numTables == 1) mappedColumnName = mappedColumn.Name; else if (hasMultiSchemas) mappedColumnName = string.Format("{0}.{1}.{2}", mappedColumn.Parent.Schema, mappedColumn.Parent.Name, mappedColumn.Name); else mappedColumnName = string.Format("{0}.{1}", mappedColumn.Parent.Name, mappedColumn.Name); gridItem.SubItems.Add(new SlyceTreeGridCellItem(mappedColumnName)); gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.IsKeyProperty)); gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.ReadOnly)); foreach (ArchAngel.Interfaces.ITemplate.IUserOption uo in property.Ex.OrderBy(u => u.Name)) { if (uo.DataType == typeof(bool?)) { bool? nullableBoolValue = (bool?)uo.Value; gridItem.SubItems.Add(new SlyceTreeGridCellItem(false, true, nullableBoolValue.HasValue ? nullableBoolValue.Value : false)); } else if (uo.DataType == typeof(string)) gridItem.SubItems.Add(new SlyceTreeGridCellItem((string)uo.Value)); else if (uo.DataType == typeof(int)) gridItem.SubItems.Add(new SlyceTreeGridCellItem((int)uo.Value)); else if (uo.DataType == typeof(bool)) gridItem.SubItems.Add(new SlyceTreeGridCellItem((bool)uo.Value)); else if (uo.DataType.ToString() == "ArchAngel.Interfaces.NHibernateEnums.PropertyAccessTypes") gridItem.SubItems.Add(new SlyceTreeGridCellItem(uo.Value.ToString())); else if (uo.DataType.ToString() == "ArchAngel.Interfaces.NHibernateEnums.PropertyGeneratedTypes") gridItem.SubItems.Add(new SlyceTreeGridCellItem(uo.Value.ToString())); else throw new NotImplementedException("Type not handled yet: " + uo.DataType.Name); } gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.FractionalDigits, ApplicableOptions.Digits)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.FutureDate, ApplicableOptions.Date)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.IntegerDigits, ApplicableOptions.Digits)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.MaximumLength, ApplicableOptions.Length)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.MinimumLength, ApplicableOptions.Length)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.MaximumValue, ApplicableOptions.Value)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.MinimumValue, ApplicableOptions.Value)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.NotEmpty, ApplicableOptions.NotEmpty)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.Nullable, ApplicableOptions.Nullable)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.PastDate, ApplicableOptions.Date)); gridItem.SubItems.Add(CreateNewNullableCell(property, property.ValidationOptions.RegexPattern, ApplicableOptions.RegexPattern)); gridItem.SubItems.Add(new SlyceTreeGridCellItem(property.ValidationOptions.Validate, (ValidationOptions.GetApplicableValidationOptionsForType(property.Type) & ApplicableOptions.Validate) != ApplicableOptions.Validate)); slyceGrid1.Items.Add(gridItem); }
private string GetText(ArchAngel.Interfaces.Template.File scriptFile, int startPos) { string body; for (int i = 0; i < SearchHelper.FoundLocations.Count; i++) { if (SearchHelper.FoundLocations[i].ScriptFile == scriptFile) { body = SearchHelper.FoundLocations[i].Body; if (body.Length == 0) { continue; } int lineStart = startPos; // Find the start of the line while (lineStart > 0 && lineStart < body.Length) { if (body[lineStart] == '\n' || body[lineStart] == '\r') { lineStart += 1; break; } lineStart -= 1; } int lineEnd = lineStart;// startPos; // Find the end of the line while (lineEnd >= 0 && lineEnd < body.Length) { if (body[lineEnd] == '\n' || body[lineEnd] == '\r') { //lineEnd -= 1; break; } lineEnd += 1; } // Get the text of the line in question int textLength = lineEnd - lineStart; string returnVal = ""; if (textLength > 0 && lineStart >= 0 && lineStart < body.Length && (lineStart + textLength) < body.Length) { returnVal = body.Substring(lineStart, textLength); if (returnVal.Length > 0) { // Remove any tabs from the line text returnVal = returnVal.Replace("\t", " "); } } return returnVal; } } return ""; }
public FormAction(ArchAngel.Interfaces.BaseAction action) { InitializeComponent(); ucHeading1.Text = ""; CurrentAction = action; Populate(); }
public ucFilterReturnOrder(ArchAngel.Providers.Database.Controls.FormFilter2 owner) { InitializeComponent(); HasNext = true; HasPrev = true; Owner = owner; PageHeader = "Result Ordering"; PageDescription = "Select which columns you want to order the results by."; Populate(); }
public frmActionEdit(ArchAngel.Interfaces.BaseAction action) { InitializeComponent(); Controller.ShadeMainForm(); ucHeading1.Text = ""; this.Text = "Edit Action: " + action.DisplayName; CurrentAction = action; Populate(); }
public ucFilterSummary(ArchAngel.Providers.Database.Controls.FormFilter2 owner) { InitializeComponent(); HasNext = false; HasPrev = true; HasFinish = true; PageHeader = "Filter Summary"; PageDescription = "Check that all the information is correct."; Owner = owner; }
public FormScriptObject(ScriptObject[] scriptObjects, ArchAngel.Providers.Database.Model.Database parentDatabase) { InitializeComponent(); this.BackColor = Slyce.Common.Colors.BackgroundColor; this.ParentDatabase = parentDatabase; _scriptObjects = scriptObjects; ucHeading1.Text = ""; Controller.ShadeMainForm(); }
public ucFilterWhere(ArchAngel.Providers.Database.Controls.FormFilter2 owner) { InitializeComponent(); HasNext = true; HasPrev = true; Owner = owner; PageHeader = "Custom Where Clause"; PageDescription = "If you want a custom 'where' clause for the SQL, add it here."; Populate(); }
public ucFilterColumns(ArchAngel.Providers.Database.Controls.FormFilter2 owner) { InitializeComponent(); HasNext = true; HasPrev = false; Owner = owner; NextText = "&Next >"; PageHeader = "Filter Columns"; PageDescription = "Select which columns you want to use to filter the results. Specify how they should be filtered."; Populate(); }
public ucFilterStart(ArchAngel.Providers.Database.Controls.FormFilter2 owner) { InitializeComponent(); HasNext = true; HasPrev = true; Owner = owner; PageHeader = "Filter Info"; PageDescription = "Provide basic information about the filter, such as name."; Populate(); Controller.Instance.OnDataChanged += new ITemplate.DataChangedEventDelegate(Instance_OnDataChanged); }
public FormObjectOptionEdit(ArchAngel.Interfaces.ITemplate.IOption option, ArchAngel.Interfaces.ITemplate.IUserOption userOption, ArchAngel.Interfaces.IScriptBaseObject iteratorObject) { InitializeComponent(); IteratorObject = iteratorObject; this.BackColor = Slyce.Common.Colors.BackgroundColor; ucHeading1.Text = ""; CurrentOption = option; UserOption = userOption; OriginalValue = UserOption.Value; Controller.ShadeMainForm(); Populate(); }
public TypeOfDiff DisplayNodeFiles(TreeListNode node, DiffFile currentDiffFile, ArchAngel.Providers.CodeProvider.CSharp.MapInfoType mapInfo, AutoMergeTypes autoMergeType, OriginTypes originType) { CurrentDiffFile = currentDiffFile; CurrentMapInfo = mapInfo; OriginType = originType; Type type = null; if (mapInfo.UserObject != null) { type = mapInfo.UserObject.GetType(); } else if (mapInfo.TemplateObject != null) { type = mapInfo.TemplateObject.GetType(); } else if (mapInfo.PrevGenObject != null) { type = mapInfo.PrevGenObject.GetType(); } string userText = null; string templateText = null; string prevGenText = null; string mergedText = null; if (type == typeof(ArchAngel.Providers.CodeProvider.CSharp.Class) || type == typeof(ArchAngel.Providers.CodeProvider.CSharp.Interface) || type == typeof(ArchAngel.Providers.CodeProvider.CSharp.Namespace) || type == typeof(ArchAngel.Providers.CodeProvider.CSharp.Struct)) { userText = mapInfo.UserObject == null ? null : ((ArchAngel.Providers.CodeProvider.CSharp.Class)mapInfo.UserObject).ToString(false); templateText = mapInfo.TemplateObject == null ? null : ((ArchAngel.Providers.CodeProvider.CSharp.Class)mapInfo.TemplateObject).ToString(false); prevGenText = mapInfo.PrevGenObject == null ? null : ((ArchAngel.Providers.CodeProvider.CSharp.Class)mapInfo.PrevGenObject).ToString(false); } else { userText = mapInfo.UserObject == null ? null : mapInfo.UserObject.ToString(); templateText = mapInfo.TemplateObject == null ? null : mapInfo.TemplateObject.ToString(); prevGenText = mapInfo.PrevGenObject == null ? null : mapInfo.PrevGenObject.ToString(); } if (mapInfo.Parent != null) { mergedText = mapInfo.Parent.ToString(); } else if (mapInfo.MergedObject != null) { mergedText = mapInfo.MergedObject.ToString(); } return DisplayNodeFiles(node, CurrentDiffFile, autoMergeType, userText, templateText, prevGenText, mergedText, mapInfo.DiffType, OriginType); }
private static void AddScriptBodies(ArchAngel.Interfaces.Template.Folder folder, string filesDir) { foreach (var subFolder in folder.Folders) AddScriptBodies(subFolder, filesDir); foreach (var file in folder.Files) { string filePath = Path.Combine(filesDir, string.Format("File_{0}.vnh_script", file.Id)); file.Script.Body = File.ReadAllText(filePath); } foreach (var file in folder.StaticFiles) { string filePath = Path.Combine(filesDir, string.Format("StaticFile_{0}_Skip.vnh_script", file.Id)); file.SkipThisFileScript = File.ReadAllText(filePath); } }
public void InitialiseNHibernateProject(ArchAngel.NHibernateHelper.ProviderInfo providerInfo, PreGenerationData data) { if (providerInfo.ProjectOrigin != ProviderInfo.ProjectType.FromExistingVisualStudioProject) { if (providerInfo.NhConfigFile.ProviderInfo == null) providerInfo.NhConfigFile.ProviderInfo = providerInfo; string outputFolder = null; string tempFolder = null; if (ArchAngel.Interfaces.SharedData.CurrentProject == null) throw new Exception("CurrentProject is null."); if (ArchAngel.Interfaces.SharedData.CurrentProject.ScriptProject != null) { outputFolder = ArchAngel.Interfaces.SharedData.CurrentProject.ScriptProject.OutputFolder; tempFolder = ArchAngel.Interfaces.SharedData.CurrentProject.ScriptProject.TempFolder; } ArchAngel.Interfaces.SharedData.CurrentProject.ScriptProject = FillScriptModel(providerInfo.EntityProviderInfo.MappingSet, null, providerInfo.NhConfigFile); ArchAngel.Interfaces.SharedData.CurrentProject.ScriptProject.OutputFolder = outputFolder; ArchAngel.Interfaces.SharedData.CurrentProject.ScriptProject.TempFolder = tempFolder; return; } XmlDocument csprojDocument = null; string filename; if (providerInfo.CsProjFile == null || !providerInfo.CsProjFile.FileExists) { // Find the csproj file we are going to use csprojDocument = GetCSProjDocument(data, out filename); if (csprojDocument != null) providerInfo.CsProjFile = new CSProjFile(csprojDocument, filename); } if (!providerInfo.NhConfigFile.FileExists) { if (csprojDocument == null) csprojDocument = GetCSProjDocument(data, out filename); else filename = providerInfo.CsProjFile.FilePath; providerInfo.NhConfigFile = ProjectLoader.GetNhConfigFile(providerInfo.CsProjFile, fileController); } ArchAngel.Interfaces.SharedData.CurrentProject.ScriptProject = FillScriptModel(providerInfo.EntityProviderInfo.MappingSet, providerInfo.CsProjFile, providerInfo.NhConfigFile); }
public static string ProcessComponentTemplate(Entity entity, ArchAngel.Providers.EntityModel.Model.EntityLayer.Component component) { System.Text.StringBuilder sb = new StringBuilder(((SourceCodeMultiLineType)SharedData.CurrentProject.GetUserOption("ComponentTemplate")).Value); string specName = component.Specification.Name; string componentName = component.Name; sb.Replace("#entity.Name#", entity.Name); sb.Replace("#component.Name#", component.Name); sb.Replace("#component.Type#", specName); bool usePrivateSetter = (bool)SharedData.CurrentProject.GetUserOption("UsePrivateSettersOnProperties") || (bool)component.GetUserOptionValue("Component_UsePrivateSetter"); ProcessIfStatement(sb, "component.SetterIsPrivate", usePrivateSetter); return RemoveTrailingLineBreaks(sb.ToString()); }
private void GetProject(ArchAngel.Providers.EntityModel.Model.MappingLayer.MappingSet mappingSet, XmlDocument csprojDocument, string filename) { var hbmFiles = ProjectLoader.GetHBMFilesFromCSProj(new CSProjFile(csprojDocument, filename), fileController); // Load HBMs var mappings = hbmFiles.Select(f => MappingFiles.Version_2_2.Utility.Open(f)).ToList(); // Parse the CSharp files var csharpFiles = ProjectLoader.GetCSharpFilesFromCSProj(new CSProjFile(csprojDocument, filename), fileController); ParseResults parseResults = ParseResults.ParseCSharpFiles(csharpFiles); //foreach (ArchAngel.Providers.CodeProvider.DotNet.Class c in parseResults.parsedClasses) //{ //} //mappingSet.CodeParseResults = parseResults; // Clear the current mapped class. //mappingSet.EntitySet.Entities.ForEach(e => e.MappedClass = null); // Map the Entity objects to the parsed Class var entities = mappingSet.EntitySet.Entities.ToDictionary(e => e.Name); foreach (var hm in mappings) { foreach (var hClass in hm.Classes()) { var fullClassName = HibernateMappingHelper.ResolveFullClassName(hClass, hm); var shortClassName = HibernateMappingHelper.ResolveShortClassName(hClass, hm); // try find the entity Entity entity; if (entities.TryGetValue(shortClassName, out entity)) { // try find class in parse results var parsedClass = parseResults.FindClass(fullClassName, entity.Properties.Select(p => p.Name).ToList()); entity.MappedClass = parsedClass; } else { //Log.InfoFormat("Could not find entity for class named {0} in the NHibernate project on disk.", shortClassName); } } } }
public FormDatabase(IDatabase database, ArchAngel.Providers.EntityModel.Model.MappingLayer.MappingSet mappingSet) { InitializeComponent(); Instance = this; ArchAngel.Interfaces.SharedData.AboutToSave += new EventHandler(SharedData_AboutToSave); modelChanges1.RefreshCalled += new EventHandler(RefreshWasCalled); labelTablePrefixes.Top = ucDatabaseInformation1.BottomOfControls + 20; textBoxTablePrefixes.Top = labelTablePrefixes.Top; labelColumnPrefixes.Top = textBoxTablePrefixes.Bottom + 5; textBoxColumnPrefixes.Top = labelColumnPrefixes.Top; labelTableSuffixes.Top = textBoxColumnPrefixes.Bottom + 5; textBoxTableSuffixes.Top = labelTableSuffixes.Top; labelColumnSuffixes.Top = textBoxTableSuffixes.Bottom + 5; textBoxColumnSuffixes.Top = labelColumnSuffixes.Top; buttonResync.Top = textBoxColumnSuffixes.Bottom + 20; buttonTestConnection.Top = buttonResync.Top; if (DesignMode) return; superTabConnectionSettings.SelectedTab = superTabItemConnection; MappingSet = mappingSet; ucDatabaseInformation1.UsernameChanged += (sender, e) => UsernameChanged.RaiseEvent(sender, e); ucDatabaseInformation1.PasswordChanged += (sender, e) => PasswordChanged.RaiseEvent(sender, e); ucDatabaseInformation1.SelectedDatabaseChanged += (sender, e) => SelectedDatabaseChanged.RaiseEvent(sender, e); ucDatabaseInformation1.SelectedDatabaseTypeChanged += (sender, e) => SelectedDatabaseTypeChanged.RaiseEvent(sender, e); ucDatabaseInformation1.ServerNameChanged += (sender, e) => ServerNameChanged.RaiseEvent(sender, e); Database = database; if (Database != null) labelHeader.Text = Database.Name; else labelHeader.Text = "No Database Selected"; PopulatePrefixes(); buttonImport.Enabled = false; }
public static string GetRelativeFilenameForEntityCSharpFile(ArchAngel.Interfaces.Scripting.NHibernate.Model.IEntity entity, string csprojFullFilePath) { return ArchAngel.NHibernateHelper.HibernateMappingHelper.GetRelativeFilenameForEntityCSharpFile((Entity)entity.ScriptObject, csprojFullFilePath); }
public static string GetEntityName(ArchAngel.Interfaces.Scripting.NHibernate.Model.ITable table) { object[] parms = new object[] { table }; string body = (string)EntityNameMethod.Invoke(null, parms); if (body.StartsWith(" ")) body = body.Substring(10); return body; }
/// <summary> /// Creates a property for an key in a joined subclass in a Fluent project. /// </summary> /// <param name="newEntity"></param> /// <param name="mapping"></param> /// <param name="hKey"></param> /// <returns></returns> private Property CreateProperty(Entity newEntity, Mapping mapping, key hKey, ArchAngel.Providers.EntityModel.Model.DatabaseLayer.ITable table) { Property prop; //mapping. string columnName; if (!string.IsNullOrEmpty(hKey.column1)) columnName = hKey.column1.UnBackTick(); else columnName = hKey.column[0].name.UnBackTick(); ArchAngel.Providers.EntityModel.Model.EntityLayer.Property existingProperty = newEntity.Properties.SingleOrDefault(p => p.MappedColumn() != null && p.MappedColumn().Name.ToLowerInvariant() == columnName.ToLowerInvariant()); if (existingProperty != null) { existingProperty.IsKeyProperty = true; return existingProperty; } //if (hKey.column1 != null) // prop = CreateProperty(newEntity, mapping, hKey.type, hKey.name, hKey.column1, hKey.length); //else // prop = CreateProperty(newEntity, mapping, hKey.type, hKey.name, hKey.column[0].name, hKey.length); //if (hKey.column1 != null) // prop = CreateProperty(newEntity, mapping, hKey.type, hKey.name, hKey.column1, hKey.length); //else //string csharpType = ArchAngel.Interfaces.ProjectOptions.TypeMappings.Utility.GetCSharpTypeName(newEntity.MappedTables().ElementAt(0).Database.DatabaseType.ToString(), hKey.column[0].sqltype); ArchAngel.Providers.EntityModel.Model.DatabaseLayer.IColumn column = table.Columns.SingleOrDefault(c => c.Name.ToLowerInvariant() == columnName.ToLowerInvariant().UnBackTick()); ArchAngel.Interfaces.ProjectOptions.TypeMappings.Utility.ColumnInfo columnInfo = new Interfaces.ProjectOptions.TypeMappings.Utility.ColumnInfo(); string type; bool nullability; if (column != null) { type = column.OriginalDataType; nullability = column.IsNullable; columnInfo.Precision = column.Precision; columnInfo.Scale = column.Scale; columnInfo.Size = column.Size; } else { type = hKey.column[0].sqltype; if (hKey.column[0].notnullSpecified) nullability = !hKey.column[0].notnull; else nullability = false; } columnInfo.IsNullable = nullability; columnInfo.Name = columnName; columnInfo.TypeName = type; string csharpType = ArchAngel.Interfaces.ProjectOptions.TypeMappings.Utility.GetCSharpTypeName(table.Database.DatabaseType.ToString(), columnInfo); prop = CreateProperty(newEntity, mapping, csharpType, columnName, columnName, "0"); return prop; }
private ArchAngel.Interfaces.Scripting.DatabaseChanges.IChangedTable GetChangedTable(ArchAngel.Interfaces.Scripting.DatabaseChanges.IDatabase database, ITable oldTable) { ArchAngel.Interfaces.Scripting.DatabaseChanges.IChangedTable table = database.ChangedTables.SingleOrDefault(t => t.Name == oldTable.Name && t.Schema == oldTable.Schema); if (table == null) { table = new ArchAngel.Interfaces.Scripting.DatabaseChanges.IChangedTable(database.Name) { Name = oldTable.Name, Schema = oldTable.Schema }; database.ChangedTables.Add(table); } return table; }
void MappingEditor_TableRemoved(ArchAngel.Providers.EntityModel.Model.DatabaseLayer.ITable table) { BusyPopulating = true; bool changed = false; MappedTables.Remove(table); var mapping = Entity.Mappings().SingleOrDefault(m => m.FromTable == table); if (mapping != null) mapping.Delete(); if (MessageBox.Show(this, "Remove all entity properties that are mapped to this table's columns?", "Remove properties", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { for (int i = Entity.Properties.Count() - 1; i >= 0; i--) { Property property = Entity.Properties.ElementAt(i); IColumn mappedColumn = property.MappedColumn(); if (mappedColumn != null && mappedColumn.Parent == table) { Entity.RemoveProperty(property); changed = true; } } } else { foreach (Property property in Entity.Properties) { IColumn mappedColumn = property.MappedColumn(); if (mappedColumn != null && mappedColumn.Parent == table) { property.SetMappedColumn(null); changed = true; } } } BusyPopulating = false; DrawEntityMappings(); if (changed || MappedTables.Count == 1) { PopulateEntityPropertyEditor(); } }
void MappingEditor_TableAdded(ArchAngel.Providers.EntityModel.Model.DatabaseLayer.ITable table) { MappedTables.Add(table); DrawEntityMappings(); PopulateEntityPropertyEditor(); }
public void InitialiseEntityModel(ArchAngel.Providers.EntityModel.ProviderInfo providerInfo, PreGenerationData data) { providerInfo.MappingSet.CodeParseResults = null; // Clear the current mapped class. providerInfo.MappingSet.EntitySet.Entities.ForEach(e => e.MappedClass = null); // Find the csproj file we are going to use string filename; var csprojDocument = GetCSProjDocument(data, out filename); if (csprojDocument == null) return; CSProjFile csproj = new CSProjFile(csprojDocument, filename); var hbmFiles = ProjectLoader.GetHBMFilesFromCSProj(csproj, fileController); // Load HBMs foreach (string hbmFilePath in hbmFiles) { if (!File.Exists(hbmFilePath)) throw new FileNotFoundException(string.Format("A file is defined is your csproj file [{0}], but it cannot be found: [{1}]", filename, hbmFilePath), hbmFilePath); } var mappings = hbmFiles.Select(f => MappingFiles.Version_2_2.Utility.Open(f)).ToList(); // Parse the CSharp files var csharpFiles = ProjectLoader.GetCSharpFilesFromCSProj(csproj, fileController); var parseResults = ParseResults.ParseCSharpFiles(csharpFiles); providerInfo.MappingSet.CodeParseResults = parseResults; // Clear the current mapped class. providerInfo.MappingSet.EntitySet.Entities.ForEach(e => e.MappedClass = null); // Map the Entity objects to the parsed Class var entities = providerInfo.MappingSet.EntitySet.Entities.ToDictionary(e => e.Name); foreach (var hm in mappings) { foreach (var hClass in hm.Classes()) { var fullClassName = HibernateMappingHelper.ResolveFullClassName(hClass, hm); var shortClassName = HibernateMappingHelper.ResolveShortClassName(hClass, hm); // try find the entity Entity entity; if (entities.TryGetValue(shortClassName, out entity)) { // try find class in parse results var parsedClass = parseResults.FindClass(fullClassName, entity.Properties.Select(p => p.Name).ToList()); entity.MappedClass = parsedClass; } else { Log.InfoFormat("Could not find entity for class named {0} in the NHibernate project on disk.", shortClassName); } } } // Now, try to map entities that haven't been found yet foreach (var entity in entities.Select(v => v.Value).Where(e => e.MappedClass == null)) { string entityName = entity.Name; // try find class in parse results var parsedClass = parseResults.FindClass(entityName, entity.Properties.Select(p => p.Name).ToList()); entity.MappedClass = parsedClass; } }
public bool ShowEditDatabase(ArchAngel.Providers.Database.BLL.ConnectionStringHelper connectionString) { //CurrentAction = Action.EditDatabase; this.Text = "Edit Database"; comboBoxDatabaseTypes.Text = connectionString.CurrentDbType.ToString(); comboBoxDatabases.Text = connectionString.DatabaseName; comboBoxServers.Text = connectionString.ServerName; textBoxPassword.Text = connectionString.Password; textBoxUserName.Text = connectionString.UserName; checkBoxUseIntegratedSecurity.Checked = connectionString.UseIntegratedSecurity; buttonSave.Text = "OK"; Cursor = Cursors.Default; //ShowPanel(pnlOutput); this.ShowDialog(this.ParentForm); comboBoxDatabases.Focus(); return SaveClicked; }
public static string GetPropertyName(ArchAngel.Interfaces.Scripting.NHibernate.Model.IColumn column) { object[] parms = new object[] { column }; string body = (string)PropertyNameMethod.Invoke(null, parms); if (body.StartsWith(" ")) body = body.Substring(10); return body; }