private void mapNewBtn_Click(object sender, EventArgs e) { if (propertyListView.SelectedItems.Count > 0) { MappedProperty mappedProperty = propertyListView.SelectedItems[0].Tag as MappedProperty; if (FindTargetProperty((DbProperty)mappedProperty.Source) != null) { if (MessageBox.Show("You are trying to map a field, that has been found to be connected to a table and column, to a new custom property.\nIs this what you want?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } } using (CreatePropertyForm createPropertyForm = new CreatePropertyForm(BusinessEntity)) { createPropertyForm.BackendApplication = BackendApplication; createPropertyForm.DbProperty = mappedProperty.Source as DbProperty; if (createPropertyForm.ShowDialog() == DialogResult.OK) { try { mappedProperty.Target = createPropertyForm.Property; UpdateResponseProperty(mappedProperty); DbProperty dbProp = mappedProperty.Source as DbProperty; if (string.IsNullOrEmpty(dbProp.DbDatatype)) { if (mappedProperty.Target.Type == typeof(string)) { dbProp.DbDatatype = "VARCHAR2"; if ((dbProp.PropertyType == DbPropertyType.InOut) || (dbProp.PropertyType == DbPropertyType.Out)) { dbProp.Length = 255; } } } propertyListView.SelectedItems[0].SubItems[3].Text = mappedProperty.Target.Name; propertyListView.SelectedItems[0].SubItems[4].Text = mappedProperty.Target.Type.ToString(); detailGrid.SelectedObject = mappedProperty; // Update the colors UpdateListViewColors(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } } }
private bool IsPossibleBoolean(MappedProperty mappedProperty) { DbProperty dbProperty = mappedProperty.Source as DbProperty; return(dbProperty != null && !string.IsNullOrEmpty(dbProperty.DbDatatype) && dbProperty.DbDatatype.ToUpper() == "VARCHAR2" && dbProperty.Length == 1); }
private Cdc.MetaManager.DataAccess.Domain.Property FindTargetProperty(DbProperty property) { Dictionary <string, object> criteria = new Dictionary <string, object>(); criteria.Add("StorageInfo.TableName", property.OriginalTable); criteria.Add("StorageInfo.ColumnName", property.OriginalColumn); criteria.Add("BusinessEntity.Application.Id", BackendApplication.Id); return(MetaManagerServices.GetModelService().GetAllDomainObjectsByPropertyValues <Cdc.MetaManager.DataAccess.Domain.Property>(criteria).FirstOrDefault()); }
/// <summary> /// NUNIT Tests the db property output. /// </summary> [Test] public void TestDbPropertyOutput() { var prop = new DbProperty("TestProperty", String.Empty, "int") { ReadOnly = true, AltName = "m_pTestProperty" }; Assert.IsEmpty(prop.ToString()); Console.WriteLine(prop); Console.WriteLine(prop.Body()); Console.WriteLine(prop.GetInit()); }
public static IConnection Build(DbProperty db_configuration) { IConnection conn = null; try { ConnectionTypes conn_type = ConnectionTypeBuilder.GetConnectionType(db_configuration.ConnType); if (conn_type == ConnectionTypes.Unknown) { throw new Exception("Unknown Connection type can not be allowed."); } string conn_str = ""; conn_str = db_configuration.ConnString; conn_str = conn_str ?? string.Empty; if (string.IsNullOrWhiteSpace(conn_str)) { Hashmap h = db_configuration.Keys; if (h != null) { string[] keys_ = h.Keys(); foreach (var key in keys_) { conn_str = string.Format("{0}{1}={2};", conn_str, key, h.Get(key)); } conn_str = conn_str.TrimEnd(';'); } } // IF CLAUSE 1 if (conn_type == ConnectionTypes.External) { conn = new ExternalConnection(db_configuration.InvariantName, conn_str); } else { conn = new Connection(conn_type, conn_str); } } catch (Exception) { throw; } // RETURN return(conn); }
/// <summary> /// protected ctor of BaseDL. /// </summary> /// <param name="connectionName">connection property name</param> protected BaseDL(string connectionName) { try { conn_name = connectionName; db_property = FreeConfiguration.BuildProperty(conn_name); this.Conn = ConnectionFactory.Build(db_property); conn_type = this.Conn.ConnectionType; //ConnectionTypeBuilder.GetConnectionType(db_property.ConnType); } catch (Exception) { throw; } }
public DbProperty GetOrigin(MappedProperty mappedProperty) { mappedProperty = ModelService.GetDomainObject <MappedProperty>(mappedProperty.Id); while (mappedProperty.MapProperty != null) { mappedProperty = mappedProperty.MapProperty; } DbProperty dbProperty = mappedProperty.Source as DbProperty; if (dbProperty != null) { NHibernateUtil.Initialize(dbProperty); } return(dbProperty); }
private void mapExistingBtn_Click(object sender, EventArgs e) { if (propertyListView.SelectedItems.Count > 0) { using (FindPropertyForm findPropertyForm = new FindPropertyForm()) { MappedProperty mappedProperty = propertyListView.SelectedItems[0].Tag as MappedProperty; findPropertyForm.BackendApplication = BackendApplication; findPropertyForm.CanShowCustomProperties = true; findPropertyForm.HideServicMethodSearch = true; findPropertyForm.CanMultiSelectProperties = false; findPropertyForm.DefaultBusinessEntity = BusinessEntity; findPropertyForm.AutoSearchColumn = mappedProperty.Source.Name; if (findPropertyForm.ShowDialog() == DialogResult.OK) { Cdc.MetaManager.DataAccess.Domain.Property property = findPropertyForm.SelectedProperty; mappedProperty.Target = property; UpdateResponseProperty(mappedProperty); DbProperty dbProp = mappedProperty.Source as DbProperty; if (property.StorageInfo != null) { dbProp.DbDatatype = property.StorageInfo.StorageType; dbProp.Length = property.StorageInfo.Length; dbProp.Scale = property.StorageInfo.Scale; dbProp.Precision = property.StorageInfo.Precision; } propertyListView.SelectedItems[0].SubItems[3].Text = mappedProperty.Target.Name; propertyListView.SelectedItems[0].SubItems[4].Text = mappedProperty.Target.Type.ToString(); detailGrid.SelectedObject = mappedProperty; // Update the colors UpdateListViewColors(); } } } }
private string GetDataTypeName(MappedProperty mappedProperty) { DbProperty dbProperty = mappedProperty.Source as DbProperty; if (dbProperty != null) { if (string.IsNullOrEmpty(dbProperty.DbDatatype)) { return(string.Empty); } else if (dbProperty.DbDatatype.ToUpper() == "VARCHAR2") { return(string.Format("{0} ({1})", dbProperty.DbDatatype, dbProperty.Length)); } else if (dbProperty.DbDatatype.ToUpper() == "NUMBER") { if (dbProperty.Scale > 0) { return(string.Format("{0} ({1},{2})", dbProperty.DbDatatype, dbProperty.Precision, dbProperty.Scale)); } else { return(string.Format("{0} ({1})", dbProperty.DbDatatype, dbProperty.Precision)); } } else if (dbProperty.DbDatatype.ToUpper() == "DATE") { return(string.Format("{0}", dbProperty.DbDatatype)); } else { return(string.Format("{0} ({1},{2},{3})", dbProperty.DbDatatype, dbProperty.Length, dbProperty.Precision, dbProperty.Scale)); } } return(null); }