/// <summary>
 /// Gets the name of the schema.
 /// </summary>
 /// <param name="dbName">Name of the db.</param>
 /// <param name="extraction">The extraction.</param>
 /// <param name="nameFormat">The name format.</param>
 /// <returns></returns>
 public SchemaName GetSchemaName(string dbName, WordsExtraction extraction, NameFormat nameFormat)
 {
     var words = GetLanguageWords(nameFormat.Culture);
     var schemaName = new SchemaName { DbName = dbName };
     schemaName.NameWords = ExtractWords(words, dbName, extraction);
     schemaName.ClassName = Format(words, schemaName.NameWords, nameFormat.Case, Singularization.DontChange);
     return schemaName;
 }
예제 #2
0
        protected override void LoadConstraints(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat, Names names)
        {
            var constraints = ReadConstraints(conn, schemaName.DbName);

            //sort tables - parents first (this is moving to SchemaPostprocess)
            //TableSorter.Sort(tables, constraints);

            foreach (DataConstraint keyColRow in constraints)
            {
                //find my table:
                string fullKeyDbName           = GetFullDbName(keyColRow.TableName, keyColRow.TableSchema);
                DbLinq.Schema.Dbml.Table table = schema.Tables.FirstOrDefault(t => fullKeyDbName == t.Name);
                if (table == null)
                {
                    bool ignoreCase = true;
                    table = schema.Tables.FirstOrDefault(t => 0 == string.Compare(fullKeyDbName, t.Name, ignoreCase));
                    if (table == null)
                    {
                        WriteErrorLine("ERROR L46: Table '" + keyColRow.TableName + "' not found for column " + keyColRow.ColumnName);
                        continue;
                    }
                }

                bool isForeignKey = keyColRow.ConstraintName != "PRIMARY" &&
                                    keyColRow.ReferencedTableName != null;

                if (isForeignKey)
                {
                    LoadForeignKey(schema, table, keyColRow.ColumnName, keyColRow.TableName, keyColRow.TableSchema,
                                   keyColRow.ReferencedColumnName, keyColRow.ReferencedTableName, keyColRow.ReferencedTableSchema,
                                   keyColRow.ConstraintName, nameFormat, names);
                }
            }
        }
예제 #3
0
 public void name_format_can_find_itself()
 {
     NameFormat.Get(NameFormat.Persistent.Uri.ToString())
     .ShouldBeTheSameAs(NameFormat.Persistent);
 }
예제 #4
0
 public string GetDisplayName(NameFormat format = NameFormat.Default, bool usePreferred = false, bool includeMiddleName = true)
 {
     return(Person != null?Person.GetName(format, usePreferred, includeMiddleName) : UserName);
 }
예제 #5
0
 protected override TableName CreateTableName(string dbTableName, string dbSchema, INameAliases nameAliases, NameFormat nameFormat)
 {
     return(CreateTableName(dbTableName, dbSchema, nameAliases, nameFormat, WordsExtraction.FromDictionary));
 }
예제 #6
0
 public void DisplayName(NameFormat name) //method looks like an object, so it can be passed to another method
 {
     System.Console.WriteLine(name(First, Last));
 }
예제 #7
0
 /// <summary>
 /// Loads the constraints.
 /// </summary>
 /// <param name="schema">The schema.</param>
 /// <param name="schemaName">Name of the schema.</param>
 /// <param name="conn">The conn.</param>
 /// <param name="nameFormat">The name format.</param>
 /// <param name="names">The names.</param>
 protected abstract void LoadConstraints(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat, Names names);
        /// <summary>
        /// Creates the name of the table given a name and schema
        /// </summary>
        /// <param name="dbTableName">Name of the db table.</param>
        /// <param name="dbSchema">The db schema.</param>
        /// <param name="nameAliases">The name aliases.</param>
        /// <param name="nameFormat">The name format.</param>
        /// <param name="extraction">The extraction.</param>
        /// <returns></returns>
        protected virtual TableName CreateTableName(string dbTableName, string dbSchema, INameAliases nameAliases, NameFormat nameFormat, WordsExtraction extraction)
        {
            // if we have an alias, use it, and don't try to analyze it (a human probably already did the job)
            var tableTypeAlias = nameAliases != null?nameAliases.GetTableTypeAlias(dbTableName, dbSchema) : null;

            if (tableTypeAlias != null)
            {
                extraction = WordsExtraction.None;
            }
            else
            {
                tableTypeAlias = dbTableName;
            }

            var tableName = NameFormatter.GetTableName(tableTypeAlias, extraction, nameFormat);

            // alias for member
            var tableMemberAlias = nameAliases != null?nameAliases.GetTableMemberAlias(dbTableName, dbSchema) : null;

            if (tableMemberAlias != null)
            {
                tableName.MemberName = tableMemberAlias;
            }

            tableName.DbName = GetFullDbName(dbTableName, dbSchema);
            return(tableName);
        }
 protected virtual TableName CreateTableName(string dbTableName, string dbSchema, INameAliases nameAliases, NameFormat nameFormat)
 {
     return(CreateTableName(dbTableName, dbSchema, nameAliases, nameFormat, GetExtraction(dbTableName)));
 }
예제 #10
0
 /**
  * Return the territory name, given a specific territory name format.
  *
  * @param format Format to be used.
  * @return Mapcode
  */
 public string toNameFormat(NameFormat format)
 {
     CheckArgs.checkNonnull("format", format);
     if (format != NameFormat.INTERNATIONAL)
     {
         int index = fullName.IndexOf('_'); // name()
         if (index != -1)
         {
             System.Diagnostics.Debug.Assert(fullName.Length > (index + 1));
             string shortName = fullName.Substring(index + 1);
             if ((format == NameFormat.MINIMAL) || nameMap.ContainsKey(shortName))
             {
                 return shortName;
             }
         }
     }
     return ToString();
 }
예제 #11
0
        public delegate void NameFormatBlank(string a, string z); //action

        public void DisplayName(NameFormat name)
        {
            System.Console.WriteLine(name(Name, Address));
        }
예제 #12
0
        //CPS012 Add first or middle names for ambiguous last names v3.5

        //IMPORTANT: in Citavi 6.1 or below, it is only possible to identify persons with the same last name, not first or middle names.
        //Also disambiguation can only take place in a single stp, e.g. by adding first name initials only, or by adding full first names, or by adding both first and middle names.
        public IEnumerable <ITextUnit> GetTextUnits(ComponentPart componentPart, Template template, Citation citation, out bool handled)
        {
            //IMPORTANT: It is not possible Citavi 6.1 or below, to confine the name ambiguity check to the primary authors only.
            //If this is a requirement, pls. update to Citavi 6.2 or higher and make use of the latest component macr CPS012 version 4.0 or higher.
            //It is possible though to confine the disambiguation to the primary authors.
            bool disambiguatePrimaryAuthorsOnly = true;

            //When a first and/or middle name is added for disambiguation, should that be before or after the last name?
            PersonNameOrder nameOrderForAmbiguityResolution = PersonNameOrder.FirstNameLastName;

            //In case of ambiguous last names, should the disambiguation happen by adding full first names or just the initials?
            NameFormat firstNameFormatForAmbiguityResolution = NameFormat.Abbreviated;
            //NameFormat.Full					John Mike
            //NameFormat.Abbreviated			J. M.
            //NameFormat.AbbreviatedNoPeriod	J M
            //NameFormat.AbbreviatedCompact		J.M.
            //NameFormat.Compact				JM

            //Should the middle name(s) be added for disambiguation?
            MiddleNameUsage middleNameUsageForAmbiguityResolution = MiddleNameUsage.All;
            //MiddleNameUsage.FirstOnly
            //MiddleNameUsage.All

            //In case of ambiguous last names, should disambiguation happen by adding full middle names or just the initials?
            NameFormat middleNameFormatForAmbiguityResolution = NameFormat.Full;


            handled = false;

            if (citation == null || citation.Reference == null)
            {
                return(null);
            }
            if (componentPart == null || componentPart.Elements == null || !componentPart.Elements.Any())
            {
                return(null);
            }

            CitationManager citationManager = citation.CitationManager;

            if (citationManager == null)
            {
                return(null);
            }

            PersonFieldElement personFieldElement = componentPart.Elements.OfType <PersonFieldElement>().FirstOrDefault();

            if (personFieldElement == null)
            {
                return(null);
            }
            if (personFieldElement.SuppressOutput)
            {
                return(null);
            }

            #region BeforeFormatPerson: Resolve last name ambiguity

            BeforeFormatPersonEventArgs bfp;
            personFieldElement.PersonFormatter.BeforeFormatPerson +=
                (sender, e) =>
            {
                bfp = (BeforeFormatPersonEventArgs)e;
                if (bfp.Person == null)
                {
                    return;
                }
                if (disambiguatePrimaryAuthorsOnly && bfp.Index > 1)
                {
                    return;
                }

                bool isLastNameAmbiguous = citationManager.IsCitedPersonLastNameAmbiguous(bfp.Person.LastName);
                if (!isLastNameAmbiguous)
                {
                    return;
                }

                bfp.FirstNameFormat  = firstNameFormatForAmbiguityResolution;
                bfp.NameOrder        = nameOrderForAmbiguityResolution;
                bfp.MiddleNameUsage  = middleNameUsageForAmbiguityResolution;
                bfp.MiddleNameFormat = middleNameFormatForAmbiguityResolution;
            };

            #endregion

            return(null);
        }
예제 #13
0
        protected override void LoadStoredProcedures(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat)
        {
            var parameters = ReadParameters(conn, schemaName.DbName);

            foreach (var parameter in parameters)
            {
                var procedureName = CreateProcedureName(parameter.ProcedureName, parameter.Schema, nameFormat);

                Function function = schema.Functions.SingleOrDefault(f => f.Method == procedureName.MethodName);
                if (function == null)
                {
                    function = new Function {
                        Name = procedureName.DbName, Method = procedureName.MethodName
                    };
                    schema.Functions.Add(function);
                }

                if (parameter.Name == null)
                {
                    var returnParameter = new Return();
                    returnParameter.DbType = parameter.Type.SqlType;
                    returnParameter.Type   = MapDbType(parameter.Name, parameter.Type).ToString();

                    function.IsComposable = true;
                    function.Return       = returnParameter;
                }
                else
                {
                    var functionParameter = new Parameter();
                    functionParameter.DbType = parameter.Type.SqlType;
                    functionParameter.Type   = MapDbType(parameter.Name, parameter.Type).ToString();
                    if (parameter.In)
                    {
                        if (parameter.Out)
                        {
                            functionParameter.Direction = DbLinq.Schema.Dbml.ParameterDirection.InOut;
                        }
                        else
                        {
                            functionParameter.Direction = DbLinq.Schema.Dbml.ParameterDirection.In;
                        }
                    }
                    else
                    {
                        functionParameter.Direction = DbLinq.Schema.Dbml.ParameterDirection.Out;
                    }

                    var parameterName = CreateParameterName(parameter.Name, nameFormat);
                    functionParameter.Name = parameterName.CallName;

                    function.Parameters.Add(functionParameter);
                }
            }
        }
예제 #14
0
 public PrimaryUser(NameFormat name, ContactNumberFormat phoneNumber, string city, string cnic) : base(name, phoneNumber, city)
 {
     this.cnic = cnic;
 }
 /// <summary>
 /// Gets the name of the parameter.
 /// </summary>
 /// <param name="dbName">Name of the db.</param>
 /// <param name="extraction">The extraction.</param>
 /// <param name="nameFormat">The name format.</param>
 /// <returns></returns>
 public ParameterName GetParameterName(string dbName, WordsExtraction extraction, NameFormat nameFormat)
 {
     var words = GetLanguageWords(nameFormat.Culture);
     var parameterName = new ParameterName { DbName = dbName };
     parameterName.NameWords = ExtractWords(words, dbName, extraction);
     parameterName.CallName = Format(words, parameterName.NameWords, Case.camelCase, Singularization.DontChange);
     return parameterName;
 }
        /// <summary>
        /// Creates the name of the column.
        /// </summary>
        /// <param name="dbColumnName">Name of the db column.</param>
        /// <param name="dbTableName">Name of the db table.</param>
        /// <param name="dbSchema">The db schema.</param>
        /// <param name="nameAliases">The name aliases.</param>
        /// <param name="nameFormat">The name format.</param>
        /// <returns></returns>
        protected virtual ColumnName CreateColumnName(string dbColumnName, string dbTableName, string dbSchema, INameAliases nameAliases, NameFormat nameFormat)
        {
            var columnNameAlias = nameAliases != null?nameAliases.GetColumnMemberAlias(dbColumnName, dbTableName, dbSchema) : null;

            WordsExtraction extraction;

            if (columnNameAlias != null)
            {
                extraction = WordsExtraction.None;
            }
            else
            {
                extraction      = GetExtraction(dbColumnName);
                columnNameAlias = dbColumnName;
            }
            var columnName = NameFormatter.GetColumnName(columnNameAlias, extraction, nameFormat);
            // The member name can not be the same as the class
            // we add a "1" (just like SqlMetal does)
            var tableName = CreateTableName(dbTableName, dbSchema, nameAliases, nameFormat);

            if (columnName.PropertyName == tableName.ClassName)
            {
                columnName.PropertyName = columnName.PropertyName + "1";
            }

            if (startsWithNumber.IsMatch(columnName.PropertyName))
            {
                columnName.PropertyName = "_" + columnName.PropertyName;
            }

            columnName.DbName = dbColumnName;
            return(columnName);
        }
 /// <summary>
 /// Gets the name of the column.
 /// </summary>
 /// <param name="dbName">Name of the db.</param>
 /// <param name="extraction">The extraction.</param>
 /// <param name="nameFormat">The name format.</param>
 /// <returns></returns>
 public ColumnName GetColumnName(string dbName, WordsExtraction extraction, NameFormat nameFormat)
 {
     var words = GetLanguageWords(nameFormat.Culture);
     var columnName = new ColumnName { DbName = dbName };
     columnName.NameWords = ExtractWords(words, dbName, extraction);
     // if no extraction (preset name, just copy it)
     if (extraction == WordsExtraction.None)
         columnName.PropertyName = dbName;
     else
         columnName.PropertyName = Format(words, columnName.NameWords, nameFormat.Case, Singularization.DontChange);
     return columnName;
 }
        /// <summary>
        /// Creates the name of the procedure.
        /// </summary>
        /// <param name="dbProcedureName">Name of the db procedure.</param>
        /// <param name="dbSchema">The db schema.</param>
        /// <param name="nameFormat">The name format.</param>
        /// <returns></returns>
        protected virtual ProcedureName CreateProcedureName(string dbProcedureName, string dbSchema, NameFormat nameFormat)
        {
            var procedureName = NameFormatter.GetProcedureName(dbProcedureName, GetExtraction(dbProcedureName), nameFormat);

            procedureName.DbName = GetFullDbName(dbProcedureName, dbSchema);
            return(procedureName);
        }
예제 #19
0
        /// <summary>
        /// Gets the name of the association.
        /// </summary>
        /// <param name="dbManyName">Name of the db many.</param>
        /// <param name="dbOneName">Name of the db one.</param>
        /// <param name="dbConstraintName">Name of the db constraint.</param>
        /// <param name="foreignKeyName">Name of the foreign key.</param>
        /// <param name="extraction">The extraction.</param>
        /// <param name="nameFormat">The name format.</param>
        /// <returns></returns>
        public AssociationName GetAssociationName(string dbManyName, string dbOneName, string dbConstraintName,
                                                  string foreignKeyName, WordsExtraction extraction, NameFormat nameFormat)
        {
            var words           = GetLanguageWords(nameFormat.Culture);
            var associationName = new AssociationName {
                DbName = dbManyName
            };

            associationName.NameWords           = ExtractWords(words, dbManyName, extraction);
            associationName.ManyToOneMemberName = Format(words, dbOneName, nameFormat.Case, GetSingularization(Singularization.Singular, nameFormat));
            // TODO: this works only for PascalCase
            if (dbManyName == dbOneName)
            {
                associationName.ManyToOneMemberName = foreignKeyName.Replace(',', '_') + associationName.ManyToOneMemberName;
            }
            // TODO: support new extraction
            associationName.OneToManyMemberName = Format(words, dbManyName, nameFormat.Case, GetSingularization(Singularization.Plural, nameFormat));
            return(associationName);
        }
        /// <summary>
        /// Creates the name of the association.
        /// </summary>
        /// <param name="dbManyName">Name of the db many.</param>
        /// <param name="dbManySchema">The db many schema.</param>
        /// <param name="dbOneName">Name of the db one.</param>
        /// <param name="dbOneSchema">The db one schema.</param>
        /// <param name="dbConstraintName">Name of the db constraint.</param>
        /// <param name="foreignKeyName">Name of the foreign key.</param>
        /// <param name="nameFormat">The name format.</param>
        /// <returns></returns>
        protected virtual AssociationName CreateAssociationName(string dbManyName, string dbManySchema,
                                                                string dbOneName, string dbOneSchema, string dbConstraintName, string foreignKeyName, NameFormat nameFormat)
        {
            var associationName = NameFormatter.GetAssociationName(dbManyName, dbOneName,
                                                                   dbConstraintName, foreignKeyName, GetExtraction(dbManyName), nameFormat);

            associationName.DbName = GetFullDbName(dbManyName, dbManySchema);
            return(associationName);
        }
예제 #21
0
        protected override void LoadConstraints(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat, Names names)
        {
            var constraints = ReadConstraints(conn, schemaName.DbName);

            foreach (DataConstraint constraint in constraints)
            {
                //find my table:
                string constraintFullDbName    = GetFullDbName(constraint.TableName, constraint.TableSchema);
                DbLinq.Schema.Dbml.Table table = schema.Tables.FirstOrDefault(t => constraintFullDbName == t.Name);
                if (table == null)
                {
                    WriteErrorLine("ERROR L100: Table '" + constraint.TableName + "' not found for column " + constraint.ColumnName);
                    continue;
                }

                //if (table.Name.StartsWith("E"))
                //    Logger.Write("---Dbg");

                if (constraint.ConstraintType == "P")
                {
                    //A) add primary key
                    DbLinq.Schema.Dbml.Column pkColumn = table.Type.Columns.Where(c => c.Name == constraint.ColumnName).First();
                    pkColumn.IsPrimaryKey = true;
                }
                else if (constraint.ConstraintType == "R")
                {
                    //if not PRIMARY, it's a foreign key. (constraint_type=="R")
                    //both parent and child table get an [Association]
                    DataConstraint referencedConstraint = constraints.FirstOrDefault(c => c.ConstraintName == constraint.ReverseConstraintName);
                    if (constraint.ReverseConstraintName == null || referencedConstraint == null)
                    {
                        WriteErrorLine("ERROR L127: given R_contraint_name='" + constraint.ReverseConstraintName + "', unable to find parent constraint");
                        continue;
                    }

                    LoadForeignKey(schema, table, constraint.ColumnName, constraint.TableName, constraint.TableSchema,
                                   referencedConstraint.ColumnName, referencedConstraint.TableName,
                                   referencedConstraint.TableSchema,
                                   constraint.ConstraintName, nameFormat, names);
                }
                // custom type, this is a trigger
                else if (constraint.ConstraintType == "T" && constraint.ColumnName != null)
                {
                    var column = table.Type.Columns.Where(c => c.Name == constraint.ColumnName).First();
                    column.Expression    = constraint.Expression;
                    column.IsDbGenerated = true;
                }
            }

            //GuessSequencePopulatedFields(schema);
        }
 /// <summary>
 /// Creates the name of the schema.
 /// </summary>
 /// <param name="databaseName">Name of the database.</param>
 /// <param name="connection">The connection.</param>
 /// <param name="nameFormat">The name format.</param>
 /// <returns></returns>
 protected virtual SchemaName CreateSchemaName(string databaseName, IDbConnection connection, NameFormat nameFormat)
 {
     if (string.IsNullOrEmpty(databaseName))
     {
         databaseName = connection.Database;
         if (string.IsNullOrEmpty(databaseName))
         {
             throw new ArgumentException("Could not deduce database name from connection string. Please specify /database=<databaseName>");
         }
     }
     return(NameFormatter.GetSchemaName(databaseName, GetExtraction(databaseName), nameFormat));
 }
예제 #23
0
 /// <summary>
 /// Adds a new Franchise Manager record into the database
 /// </summary>
 /// <param name="fullName"></param>
 /// <param name="phoneNumber"></param>
 /// <param name="city"></param>
 /// <param name="location"></param>
 public FranchiseManager(NameFormat fullName, ContactNumberFormat phoneNumber, string city, Location location) : base(fullName, phoneNumber, city)
 {
 }
        protected virtual ParameterName CreateParameterName(string dbParameterName, NameFormat nameFormat)
        {
            var parameterName = NameFormatter.GetParameterName(dbParameterName, GetExtraction(dbParameterName), nameFormat);

            return(parameterName);
        }
예제 #25
0
        protected override void LoadStoredProcedures(Database schema, SchemaName schemaName, IDbConnection conn, NameFormat nameFormat)
        {
            var procs = ReadProcedures(conn, schemaName.DbName);

            foreach (DataStoredProcedure proc in procs)
            {
                var procedureName = CreateProcedureName(proc.specific_name, proc.db, nameFormat);

                var func = new Function();
                func.Name         = procedureName.DbName;
                func.Method       = procedureName.MethodName;
                func.IsComposable = string.Compare(proc.type, "FUNCTION") == 0;
                func.BodyContainsSelectStatement = proc.body != null &&
                                                   proc.body.IndexOf("select", StringComparison.OrdinalIgnoreCase) > -1;
                ParseProcParams(proc, func);

                schema.Functions.Add(func);
            }
        }
        /// <summary>
        /// Loads the tables in the given schema.
        /// </summary>
        /// <param name="schema">The schema.</param>
        /// <param name="schemaName">Name of the schema.</param>
        /// <param name="conn">The conn.</param>
        /// <param name="nameAliases">The name aliases.</param>
        /// <param name="nameFormat">The name format.</param>
        /// <param name="names">The names.</param>
        protected virtual void LoadTables(Database schema, SchemaName schemaName, IDbConnection conn, INameAliases nameAliases, NameFormat nameFormat, Names names)
        {
            var tables = ReadTables(conn, schemaName.DbName);

            foreach (var row in tables)
            {
                var tableName = CreateTableName(row.Name, row.Schema, nameAliases, nameFormat);
                names.TablesNames[tableName.DbName] = tableName;

                var table = new Table();
                table.Name      = tableName.DbName;
                table.Member    = tableName.MemberName;
                table.Type.Name = tableName.ClassName;
                schema.Tables.Add(table);
            }
        }
예제 #27
0
        public void LoadFromFile(IniFile ini)
        {
            if (ini == null)
            {
                throw new ArgumentNullException("ini");
            }

            int optsVersion = ini.ReadInteger("Common", "OptsVersion", 0);

            fDefNameFormat             = (NameFormat)ini.ReadInteger("Common", "DefNameFormat", 0);
            fDefDateFormat             = (DateFormat)ini.ReadInteger("Common", "DefDateFormat", 0);
            fLastDir                   = ini.ReadString("Common", "LastDir", "");
            fPlacesWithAddress         = ini.ReadBool("Common", "PlacesWithAddress", false);
            fShowTips                  = ini.ReadBool("Common", "ShowTips", true);
            fInterfaceLang             = (ushort)ini.ReadInteger("Common", "InterfaceLang", 0);
            fFileBackup                = (FileBackup)ini.ReadInteger("Common", "FileBackup", 0);
            fShowDatesCalendar         = ini.ReadBool("Common", "ShowDatesCalendar", false);
            fShowDatesSign             = ini.ReadBool("Common", "ShowDatesSigns", false);
            fRemovableMediaWarning     = ini.ReadBool("Common", "RemovableMediaWarning", true);
            fLoadRecentFiles           = ini.ReadBool("Common", "LoadRecentFiles", true);
            fEmbeddedMediaPlayer       = ini.ReadBool("Common", "EmbeddedMediaPlayer", true);
            fAllowMediaStoreReferences = ini.ReadBool("Common", "AllowMediaStoreReferences", false);

            fAutosave         = ini.ReadBool("Common", "Autosave", false);
            fAutosaveInterval = ini.ReadInteger("Common", "AutosaveInterval", 10);

            fExtendedNames      = ini.ReadBool("Common", "ExtendedNames", false);
            fWomanSurnameFormat = (WomanSurnameFormat)ini.ReadInteger("Common", "WomanSurnameFormat", 0);

            fGeocoder = ini.ReadString("Common", "Geocoder", "Google");

            int kl = ini.ReadInteger("Common", "KeyLayout", AppHost.Instance.GetKeyLayout());

            AppHost.Instance.SetKeyLayout(kl);

            fChartOptions.LoadFromFile(ini);
            fPedigreeOptions.LoadFromFile(ini);
            fProxy.LoadFromFile(ini);

            int cnt = ini.ReadInteger("NameFilters", "Count", 0);

            for (int i = 0; i < cnt; i++)
            {
                string st = ini.ReadString("NameFilters", "Filter_" + i.ToString(), "");
                if (st != "")
                {
                    fNameFilters.Add(st);
                }
            }

            cnt = ini.ReadInteger("ResidenceFilters", "Count", 0);
            for (int i = 0; i < cnt; i++)
            {
                fResidenceFilters.Add(ini.ReadString("ResidenceFilters", "Filter_" + i.ToString(), ""));
            }

            cnt = ini.ReadInteger("EventFilters", "Count", 0);
            for (int i = 0; i < cnt; i++)
            {
                fEventFilters.Add(ini.ReadString("EventFilters", "EventVal_" + i.ToString(), ""));
            }

            cnt = ini.ReadInteger("Common", "MRUFiles_Count", 0);
            for (int i = 0; i < cnt; i++)
            {
                string sect = "MRUFile_" + i.ToString();
                string fn   = ini.ReadString(sect, "FileName", "");
                if (File.Exists(fn))
                {
                    MRUFile mf = new MRUFile();
                    mf.LoadFromFile(ini, sect);
                    fMRUFiles.Add(mf);
                }
                else
                {
                    MRUFile.DeleteKeys(ini, sect);
                }
            }

            cnt = ini.ReadInteger("Relations", "Count", 0);
            for (int i = 0; i < cnt; i++)
            {
                fRelations.Add(ini.ReadString("Relations", "Relation_" + i.ToString(), ""));
            }

            fIndividualListColumns.LoadFromFile(ini, "PersonsColumns");

            fListHighlightUnmarriedPersons  = ini.ReadBool("ListPersons", "HighlightUnmarried", false);
            fListHighlightUnparentedPersons = ini.ReadBool("ListPersons", "HighlightUnparented", false);

            fMWinRect.Left   = ini.ReadInteger("Common", "MWinL", -1);
            fMWinRect.Top    = ini.ReadInteger("Common", "MWinT", -1);
            fMWinRect.Right  = ini.ReadInteger("Common", "MWinW", -1);
            fMWinRect.Bottom = ini.ReadInteger("Common", "MWinH", -1);
            fMWinState       = (WindowState)((uint)ini.ReadInteger("Common", "MWinState", 0));

            cnt = ini.ReadInteger("LastBases", "Count", 0);
            for (int i = 0; i < cnt; i++)
            {
                string st = ini.ReadString("LastBases", "LB" + i.ToString(), "");
                AddLastBase(st);
            }

            fAncestorsCircleOptions.LoadFromFile(ini);
        }
        /// <summary>
        /// Loads the columns.
        /// </summary>
        /// <param name="schema">The schema.</param>
        /// <param name="schemaName">Name of the schema.</param>
        /// <param name="conn">The conn.</param>
        /// <param name="nameAliases">The name aliases.</param>
        /// <param name="nameFormat">The name format.</param>
        /// <param name="names">The names.</param>
        protected void LoadColumns(Database schema, SchemaName schemaName, IDbConnection conn, INameAliases nameAliases, NameFormat nameFormat, Names names)
        {
            var columnRows = ReadColumns(conn, schemaName.DbName);

            foreach (var columnRow in columnRows)
            {
                var columnName = CreateColumnName(columnRow.ColumnName, columnRow.TableName, columnRow.TableSchema, nameAliases, nameFormat);
                names.AddColumn(columnRow.TableName, columnName);

                //find which table this column belongs to
                string fullColumnDbName = GetFullDbName(columnRow.TableName, columnRow.TableSchema);
                DbLinq.Schema.Dbml.Table tableSchema = schema.Tables.FirstOrDefault(tblSchema => fullColumnDbName == tblSchema.Name);
                if (tableSchema == null)
                {
                    WriteErrorLine("ERROR L46: Table '" + columnRow.TableName + "' not found for column " + columnRow.ColumnName);
                    continue;
                }
                var column = new Column();
                column.Name   = columnName.DbName;
                column.Member = columnName.PropertyName;
                column.DbType = columnRow.FullType;

                if (columnRow.PrimaryKey.HasValue)
                {
                    column.IsPrimaryKey = columnRow.PrimaryKey.Value;
                }

                bool?generated = (nameAliases != null) ? nameAliases.GetColumnGenerated(columnRow.ColumnName, columnRow.TableName, columnRow.TableSchema) : null;
                if (!generated.HasValue)
                {
                    generated = columnRow.Generated;
                }
                if (generated.HasValue)
                {
                    column.IsDbGenerated = generated.Value;
                }

                AutoSync?autoSync = (nameAliases != null) ? nameAliases.GetColumnAutoSync(columnRow.ColumnName, columnRow.TableName, columnRow.TableSchema) : null;
                if (autoSync.HasValue)
                {
                    column.AutoSync = autoSync.Value;
                }

                // the Expression can originate from two sources:
                // 1. DefaultValue
                // 2. Expression
                // we use any valid source (we can't have both)
                if (column.IsDbGenerated && columnRow.DefaultValue != null)
                {
                    column.Expression = columnRow.DefaultValue;
                }

                column.CanBeNull = columnRow.Nullable;

                string columnTypeAlias = nameAliases != null?nameAliases.GetColumnForcedType(columnRow.ColumnName, columnRow.TableName, columnRow.TableSchema) : null;

                var columnType = MapDbType(columnName.DbName, columnRow);

                var columnEnumType = columnType as EnumType;
                if (columnEnumType != null)
                {
                    var enumType = column.SetExtendedTypeAsEnumType();
                    enumType.Name = columnEnumType.Name;
                    foreach (KeyValuePair <string, int> enumValue in columnEnumType.EnumValues)
                    {
                        enumType[enumValue.Key] = enumValue.Value;
                    }
                }
                else if (columnTypeAlias != null)
                {
                    column.Type = columnTypeAlias;
                }
                else
                {
                    column.Type = columnType.ToString();
                }

                tableSchema.Type.Columns.Add(column);
            }
        }
 /// <summary>
 /// Gets the singularization.
 /// </summary>
 /// <param name="singularization">The singularization.</param>
 /// <param name="nameFormat">The name format.</param>
 /// <returns></returns>
 protected virtual Singularization GetSingularization(Singularization singularization, NameFormat nameFormat)
 {
     if (!nameFormat.Pluralize)
         return Singularization.DontChange;
     return singularization;
 }
예제 #30
0
 /// <summary>
 /// Gets the singularization.
 /// </summary>
 /// <param name="singularization">The singularization.</param>
 /// <param name="nameFormat">The name format.</param>
 /// <returns></returns>
 protected virtual Singularization GetSingularization(Singularization singularization, NameFormat nameFormat)
 {
     if (!nameFormat.Pluralize)
     {
         return(Singularization.DontChange);
     }
     return(singularization);
 }
 /// <summary>
 /// Gets the name of the procedure.
 /// </summary>
 /// <param name="dbName">Name of the db.</param>
 /// <param name="extraction">The extraction.</param>
 /// <param name="nameFormat">The name format.</param>
 /// <returns></returns>
 public ProcedureName GetProcedureName(string dbName, WordsExtraction extraction, NameFormat nameFormat)
 {
     var words = GetLanguageWords(nameFormat.Culture);
     var procedureName = new ProcedureName { DbName = dbName };
     procedureName.NameWords = ExtractWords(words, dbName, extraction);
     procedureName.MethodName = Format(words, procedureName.NameWords, nameFormat.Case, Singularization.DontChange);
     return procedureName;
 }
예제 #32
0
        /// <summary>
        /// Gets the name of the procedure.
        /// </summary>
        /// <param name="dbName">Name of the db.</param>
        /// <param name="extraction">The extraction.</param>
        /// <param name="nameFormat">The name format.</param>
        /// <returns></returns>
        public ProcedureName GetProcedureName(string dbName, WordsExtraction extraction, NameFormat nameFormat)
        {
            var words         = GetLanguageWords(nameFormat.Culture);
            var procedureName = new ProcedureName {
                DbName = dbName
            };

            procedureName.NameWords  = ExtractWords(words, dbName, extraction);
            procedureName.MethodName = Format(words, procedureName.NameWords, nameFormat.Case, Singularization.DontChange);
            return(procedureName);
        }
 /// <summary>
 /// Gets the name of the table.
 /// </summary>
 /// <param name="dbName">Name of the db.</param>
 /// <param name="extraction">The extraction.</param>
 /// <param name="nameFormat">The name format.</param>
 /// <returns></returns>
 public TableName GetTableName(string dbName, WordsExtraction extraction, NameFormat nameFormat)
 {
     var words = GetLanguageWords(nameFormat.Culture);
     var tableName = new TableName { DbName = dbName };
     tableName.NameWords = ExtractWords(words, dbName, extraction);
     // if no extraction (preset name, just copy it)
     if (extraction == WordsExtraction.None)
         tableName.ClassName = tableName.DbName;
     else
         tableName.ClassName = Format(words, tableName.NameWords, nameFormat.Case, GetSingularization(Singularization.Singular, nameFormat));
     tableName.MemberName = Format(words, tableName.NameWords, nameFormat.Case, GetSingularization(Singularization.Plural, nameFormat));
     return tableName;
 }
예제 #34
0
        /// <summary>
        /// Gets the name of the parameter.
        /// </summary>
        /// <param name="dbName">Name of the db.</param>
        /// <param name="extraction">The extraction.</param>
        /// <param name="nameFormat">The name format.</param>
        /// <returns></returns>
        public ParameterName GetParameterName(string dbName, WordsExtraction extraction, NameFormat nameFormat)
        {
            var words         = GetLanguageWords(nameFormat.Culture);
            var parameterName = new ParameterName {
                DbName = dbName
            };

            parameterName.NameWords = ExtractWords(words, dbName, extraction);
            parameterName.CallName  = Format(words, parameterName.NameWords, Case.camelCase, Singularization.DontChange);
            return(parameterName);
        }
 /// <summary>
 /// Gets the name of the association.
 /// </summary>
 /// <param name="dbManyName">Name of the db many.</param>
 /// <param name="dbOneName">Name of the db one.</param>
 /// <param name="dbConstraintName">Name of the db constraint.</param>
 /// <param name="foreignKeyName">Name of the foreign key.</param>
 /// <param name="extraction">The extraction.</param>
 /// <param name="nameFormat">The name format.</param>
 /// <returns></returns>
 public AssociationName GetAssociationName(string dbManyName, string dbOneName, string dbConstraintName,
     string foreignKeyName, WordsExtraction extraction, NameFormat nameFormat)
 {
     var words = GetLanguageWords(nameFormat.Culture);
     var associationName = new AssociationName { DbName = dbManyName };
     associationName.NameWords = ExtractWords(words, dbManyName, extraction);
     associationName.ManyToOneMemberName = Format(words, dbOneName, nameFormat.Case, GetSingularization(Singularization.Singular, nameFormat));
     // TODO: this works only for PascalCase
     if (dbManyName == dbOneName)
         associationName.ManyToOneMemberName = foreignKeyName.Replace(',', '_') + associationName.ManyToOneMemberName;
     // TODO: support new extraction
     associationName.OneToManyMemberName = Format(words, dbManyName, nameFormat.Case, GetSingularization(Singularization.Plural, nameFormat));
     return associationName;
 }
예제 #36
0
        public void LoadFromFile(IniFile ini)
        {
            if (ini == null)
            {
                throw new ArgumentNullException("ini");
            }

            int optsVersion = ini.ReadInteger("Common", "OptsVersion", 0);

            fDefNameFormat     = (NameFormat)ini.ReadInteger("Common", "DefNameFormat", 0);
            fDefDateFormat     = (DateFormat)ini.ReadInteger("Common", "DefDateFormat", 0);
            fLastDir           = ini.ReadString("Common", "LastDir", "");
            fPlacesWithAddress = ini.ReadBool("Common", "PlacesWithAddress", false);
            fShowTips          = ini.ReadBool("Common", "ShowTips", true);
            fInterfaceLang     = (ushort)ini.ReadInteger("Common", "InterfaceLang", 0);
            fFileBackup        = (FileBackup)ini.ReadInteger("Common", "FileBackup", 0);
            fFileBackupEachRevisionMaxCount = ini.ReadInteger("Common", "FileBackupEachRevisionMaxCount", 0);
            fShowDatesCalendar                 = ini.ReadBool("Common", "ShowDatesCalendar", false);
            fShowDatesSign                     = ini.ReadBool("Common", "ShowDatesSigns", false);
            fRemovableMediaWarning             = ini.ReadBool("Common", "RemovableMediaWarning", true);
            fLoadRecentFiles                   = ini.ReadBool("Common", "LoadRecentFiles", true);
            fEmbeddedMediaPlayer               = ini.ReadBool("Common", "EmbeddedMediaPlayer", true);
            fAllowMediaStoreReferences         = ini.ReadBool("Common", "AllowMediaStoreReferences", false);
            fAllowMediaStoreRelativeReferences = ini.ReadBool("Common", "AllowMediaStoreRelativeReferences", true); // only when AllowMediaStoreReferences is true
            fMediaStoreDefault                 = (MediaStoreType)ini.ReadInteger("Common", "MediaStoreDefault", 0); // (int)MediaStoreType.mstReference
            fAllowDeleteMediaFileFromStgArc    = ini.ReadBool("Common", "AllowDeleteMediaFileFromStgArc", true);
            fAllowDeleteMediaFileFromRefs      = ini.ReadBool("Common", "AllowDeleteMediaFileFromRefs", false);
            fDeleteMediaFileWithoutConfirm     = ini.ReadBool("Common", "DeleteMediaFileWithoutConfirm", false);
            fAutoCheckUpdates                  = ini.ReadBool("Common", "AutoCheckUpdates", true);
            fAutoSortChildren                  = ini.ReadBool("Common", "AutoSortChildren", true);
            fAutoSortSpouses                   = ini.ReadBool("Common", "AutoSortSpouses", false);
            fCharsetDetection                  = ini.ReadBool("Common", "CharsetDetection", false);
            fFirstCapitalLetterInNames         = ini.ReadBool("Common", "FirstCapitalLetterInNames", false);
            fDialogClosingWarn                 = ini.ReadBool("Common", "DialogClosingWarn", false);

            fAutosave         = ini.ReadBool("Common", "Autosave", false);
            fAutosaveInterval = ini.ReadInteger("Common", "AutosaveInterval", 10);

            fExtendedNames      = ini.ReadBool("Common", "ExtendedNames", false);
            fWomanSurnameFormat = (WomanSurnameFormat)ini.ReadInteger("Common", "WomanSurnameFormat", 0);

            fGeocoder = ini.ReadString("Common", "Geocoder", "Google");

            int kl = ini.ReadInteger("Common", "KeyLayout", AppHost.Instance.GetKeyLayout());

            AppHost.Instance.SetKeyLayout(kl);

            fTreeChartOptions.LoadFromFile(ini);
            fPedigreeOptions.LoadFromFile(ini);
            fProxy.LoadFromFile(ini);

            int cnt = ini.ReadInteger("NameFilters", "Count", 0);

            for (int i = 0; i < cnt; i++)
            {
                string st = ini.ReadString("NameFilters", "Filter_" + i.ToString(), "");
                if (st != "")
                {
                    fNameFilters.Add(st);
                }
            }

            cnt = ini.ReadInteger("ResidenceFilters", "Count", 0);
            for (int i = 0; i < cnt; i++)
            {
                fResidenceFilters.Add(ini.ReadString("ResidenceFilters", "Filter_" + i.ToString(), ""));
            }

            cnt = ini.ReadInteger("EventFilters", "Count", 0);
            for (int i = 0; i < cnt; i++)
            {
                fEventFilters.Add(ini.ReadString("EventFilters", "EventVal_" + i.ToString(), ""));
            }

            LoadMRUFromFile(ini, fMRUFiles);

            cnt = ini.ReadInteger("Relations", "Count", 0);
            for (int i = 0; i < cnt; i++)
            {
                fRelations.Add(ini.ReadString("Relations", "Relation_" + i.ToString(), ""));
            }

            fIndividualListColumns.LoadFromFile(ini, "PersonsColumns");

            fListHighlightUnmarriedPersons  = ini.ReadBool("ListPersons", "HighlightUnmarried", false);
            fListHighlightUnparentedPersons = ini.ReadBool("ListPersons", "HighlightUnparented", false);

            fMWinRect.Left   = ini.ReadInteger("Common", "MWinL", -1);
            fMWinRect.Top    = ini.ReadInteger("Common", "MWinT", -1);
            fMWinRect.Right  = ini.ReadInteger("Common", "MWinW", -1);
            fMWinRect.Bottom = ini.ReadInteger("Common", "MWinH", -1);
            fMWinState       = (WindowState)((uint)ini.ReadInteger("Common", "MWinState", 0));

            cnt = ini.ReadInteger("LastBases", "Count", 0);
            for (int i = 0; i < cnt; i++)
            {
                string st = ini.ReadString("LastBases", "LB" + i.ToString(), "");
                AddLastBase(st);
            }

            fCircleChartOptions.LoadFromFile(ini);

            fListOptions.LoadFromFile(ini);

            LoadPluginsFromFile(ini);
        }