コード例 #1
0
    /// <summary>
    /// Execute the operation synchronously.
    /// </summary>
    /// <returns></returns>
    public override Row?Execute(object?state = null)
    {
        var executionToken = Prepare();

        Table?table = null;

        executionToken.Execute(cmd =>
        {
            using (var reader = cmd.ExecuteReader(CommandBehavior))
            {
                table = new Table(reader, Converter);
                return(table.Rows.Count);
            }
        }, state);

        if (table !.Rows.Count == 0)
        {
            if (!m_RowOptions.HasFlag(RowOptions.PreventEmptyResults))
            {
                return(null);
            }
            else
            {
                throw new MissingDataException($"No rows were returned and {nameof(RowOptions)}.{nameof(RowOptions.PreventEmptyResults)} was enabled.");
            }
        }
コード例 #2
0
        protected override Spell GetEntity(ModelBuilder builder)
        {
            Spell spell = GetSpell();
            Table?table = GetTable(new TableBuilder());

            builder.AddTable(spell, table);
            builder.AddSourcePage(spell, GetSourcePage(), e => e.SourcePageId);
            builder.AddTraits(spell, GetTraits());
            builder.AddTextBlocks(spell, GetSpellDetailBlocks(), e => e.Details);
            builder.AddRollableEffects(spell, GetRollableEffects(), e => e.RollableEffects);
            builder.AddActionEffects(spell, GetActionEffects(), e => e.ActionEffects);
            builder.AddStaggeredEffect(spell, GetStaggeredEffect(), e => e.StaggeredEffectId);
            builder.HasJoinData <Spell, SpellComponent>(spell, GetSpellComponents());
            builder.HasJoinData <Spell, Creature>(spell, GetSummonedCreatures());

            foreach (SpellHeightening heightening in GetHeightenings())
            {
                builder.AddTextBlocks(heightening, heightening.Details, e => e.Details);

                heightening.Details = new TextBlock[0];
                heightening.SpellId = spell.Id;

                builder.AddData(heightening);
            }

            spell.TableId = table?.Id;
            return(spell);
        }
コード例 #3
0
        public static ICollection <ExecutionResult> ComputeBuildInColumns(ICollection <ExecutionResult> results)
        {
            if (results == null)
            {
                throw new ArgumentNullException(nameof(results), "Parameter cannot be null.");
            }

            if (results.Count == 0)
            {
                return(new List <ExecutionResult>(0));
            }

            var processedResults = new List <ExecutionResult>(results.Count);

            foreach (var result in results)
            {
                var   tableSet = result.TableSet.Select(inputTable => ComputeExpandedTable(result.Database, inputTable)).ToList();
                Table?informationMessageTable = null;

                if (result.InformationMessages.HasValue)
                {
                    informationMessageTable = ComputeExpandedTable(result.Database, result.InformationMessages.Value);
                }

                var executionResult = new ExecutionResult(result.Database, tableSet, informationMessageTable);
                processedResults.Add(executionResult);
            }

            return(processedResults);
        }
コード例 #4
0
 bool TryGetTable(string tableName, out Table?table)
 {
     if (tableName == null)
     {
         throw new ArgumentNullException(nameof(tableName));
     }
     return(_Tables.TryGetValue(tableName, out table));
 }
コード例 #5
0
    public QueueManager(Table table, SqlTransaction transaction, Table dedupeTable) :
        base(table, transaction)
    {
        dedupe           = true;
        this.dedupeTable = dedupeTable;

        InitSendSql();
    }
コード例 #6
0
    public QueueManager(Table table, SqlConnection connection, Table dedupeTable) :
        base(table, connection)
    {
        dedupe           = true;
        this.dedupeTable = dedupeTable;

        InitSendSql();
    }
コード例 #7
0
        public QueueManager(Table table, DbTransaction transaction, Table dedupeTable) :
            base(table, transaction)
        {
            Guard.AgainstNull(dedupeTable, nameof(dedupeTable));
            dedupe           = true;
            this.dedupeTable = dedupeTable;

            InitSendSql();
        }
コード例 #8
0
        public SqlTableValuedFunctionExpression(ObjectName sqlFunction, Table?viewTable, Type?singleColumnType, Alias alias, IEnumerable <Expression> arguments)
            : base(DbExpressionType.SqlTableValuedFunction, alias)
        {
            if ((viewTable == null) == (singleColumnType == null))
            {
                throw new ArgumentException("Either viewTable or singleColumn should be set");
            }

            this.SqlFunction      = sqlFunction;
            this.ViewTable        = viewTable;
            this.SingleColumnType = singleColumnType;
            this.Arguments        = arguments.ToReadOnly();
        }
コード例 #9
0
        internal SubModuleLua(string moduleFolder, string scriptName, string subModuleClassType)
        {
            _subModuleScript = new Script();
            _subModuleScript.Globals["base"] = new EmptySubModule();

            var subModuleFilePath = Path.Combine(moduleFolder, "Lua", scriptName);

            if (File.Exists(subModuleFilePath))
            {
                _subModuleScript.DoString(File.ReadAllText(subModuleFilePath));
            }

            _subModule = _subModuleScript.Globals?[subModuleClassType] as Table;
        }
コード例 #10
0
        /// <summary>
        /// Execute the operation synchronously.
        /// </summary>
        /// <returns></returns>
        public override Table Execute(object?state)
        {
            Table?table = null;

            Prepare().Execute(cmd =>
            {
                using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
                {
                    table = new Table(reader);
                    return(table.Rows.Count);
                }
            }, state);

            return(table !);
        }
コード例 #11
0
    public override List <TMaster> Execute(object?state = null)
    {
        Table?table = null;

        Prepare().Execute(cmd =>
        {
            using (var reader = cmd.ExecuteReader(CommandBehavior))
            {
                table = new Table(reader, Converter);
                return(table.Rows.Count);
            }
        }, state);

        return(GenerateObjects(table !));
    }
コード例 #12
0
        public override ImmutableDictionary <TKey, TObject> Execute(object?state = null)
        {
            Table?table = null;

            Prepare().Execute(cmd =>
            {
                using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess))
                {
                    table = new Table(reader);
                    return(table.Rows.Count);
                }
            }, state);

            return(ToDictionary(table !));
        }
コード例 #13
0
ファイル: TableMaterializer`2.cs プロジェクト: docevaad/Chain
    /// <summary>
    /// Execute the operation asynchronously.
    /// </summary>
    /// <param name="cancellationToken">The cancellation token.</param>
    /// <param name="state">User defined state, usually used for logging.</param>
    /// <returns></returns>
    public override async Task <Table> ExecuteAsync(CancellationToken cancellationToken, object?state = null)
    {
        Table?table = null;

        await Prepare().ExecuteAsync(async cmd =>
        {
            using (var reader = await cmd.ExecuteReaderAsync(CommandBehavior, cancellationToken).ConfigureAwait(false))
            {
                table = new Table(reader, Converter);
                return(table.Rows.Count);
            }
        }, cancellationToken, state).ConfigureAwait(false);

        return(table !);
    }
コード例 #14
0
        public override async Task <ImmutableDictionary <TKey, TObject> > ExecuteAsync(CancellationToken cancellationToken, object?state = null)
        {
            Table?table = null;

            await Prepare().ExecuteAsync(async cmd =>
            {
                using (var reader = await cmd.ExecuteReaderAsync(CommandBehavior.SequentialAccess, cancellationToken).ConfigureAwait(false))
                {
                    table = new Table(reader);
                    return(table.Rows.Count);
                }
            }, cancellationToken, state).ConfigureAwait(false);

            return(ToDictionary(table !));
        }
コード例 #15
0
        public SubModuleLua()
        {
            _subModuleScript = new Script();
            _subModuleScript.Globals["base"] = new EmptySubModule();

            if (ModuleInfoHelper.GetModuleByType(typeof(SubModuleLua)) is { } moduleInfo)
            {
                var subModuleFilePath = Path.Combine(moduleInfo.Folder, "Lua", "SubModule.lua");
                if (File.Exists(subModuleFilePath))
                {
                    _subModuleScript.DoString(File.ReadAllText(subModuleFilePath));
                }

                _subModule = _subModuleScript.Globals?["SubModule"] as Table;
            }
        }
コード例 #16
0
        public override string GenerateRowColumnText(Table?msgTbl = null)
        {
            StringBuilder outputBuilder = new();

            foreach (var byteArray in Data)
            {
                List <string> rowStrings = new();

                foreach (byte b in byteArray)
                {
                    rowStrings.Add(b.ToString());
                }

                outputBuilder.AppendJoin(',', rowStrings);
                outputBuilder.Append('\n');
            }

            return(outputBuilder.ToString());
        }
コード例 #17
0
    /// <summary>
    /// Execute the operation synchronously.
    /// </summary>
    /// <returns></returns>
    public override Row Execute(object?state = null)
    {
        var executionToken = Prepare();

        Table?table = null;

        executionToken.Execute(cmd =>
        {
            using (var reader = cmd.ExecuteReader(CommandBehavior))
            {
                table = new Table(reader, Converter);
                return(table.Rows.Count);
            }
        }, state);

        if (table !.Rows.Count == 0)
        {
            throw new MissingDataException($"No rows were returned. It was this expected, use `.ToRowOrNull` instead of `.ToRow`.");
        }
コード例 #18
0
        public readonly Table?ViewTable;             //used for updates

        public EmbeddedEntityExpression(Type type, Expression hasValue, IEnumerable <FieldBinding> bindings, FieldEmbedded?fieldEmbedded, Table?viewTable)
            : base(DbExpressionType.EmbeddedInit, type)
        {
            if (bindings == null)
            {
                throw new ArgumentNullException(nameof(bindings));
            }

            if (hasValue == null || hasValue.Type != typeof(bool))
            {
                throw new ArgumentException("hasValue should be a boolean expression");
            }

            HasValue = hasValue;

            Bindings = bindings.ToReadOnly();

            FieldEmbedded = fieldEmbedded;
            ViewTable     = viewTable;
        }
コード例 #19
0
        public Table GetTable(int id)
        {
            var qry = from t in _context.Tables.Include("Business")
                      where t.ID == id
                      select t;
            Table?table = qry.SingleOrDefault();

            if (table != null)
            {
                if (_userManager.IsInRoleAsync(_user, UserRoleType.RestaurantOwner.ToString()).Result)
                {
                    if (table.Business.OwnerID == _user.Id)
                    {
                        return(table);
                    }
                }
                else if (_userManager.IsInRoleAsync(_user, UserRoleType.Admin.ToString()).Result)
                {
                    return(table);
                }
            }
            return(null);
        }
コード例 #20
0
        //--- Methods ---
        public override async Task InitializeAsync(LambdaConfig config)
        {
            // initialize twitter client
            Auth.SetApplicationOnlyCredentials(
                config.ReadText("TwitterApiKey"),
                config.ReadText("TwitterApiSecretKey"),
                true
                );
            _twitterSearchQuery     = config.ReadText("TwitterQuery");
            _twitterLanguageFilter  = new HashSet <string>(config.ReadCommaDelimitedList("TwitterLanguageFilter"));
            _twitterSentimentFilter = config.ReadText("TwitterSentimentFilter");

            // initialize Comprehend client
            _comprehendClient = new AmazonComprehendClient();

            // initialize DynamoDB table
            var dynamoClient = new AmazonDynamoDBClient();

            _table = Table.LoadTable(dynamoClient, config.ReadDynamoDBTableName("Table"));

            // initialize SNS client
            _snsClient         = new AmazonSimpleNotificationServiceClient();
            _notificationTopic = config.ReadText("TweetTopic");
        }
コード例 #21
0
ファイル: Program.cs プロジェクト: jpmac26/P3TableExporter
        static void Main(string[] args)
        {
            FileInfo?InputTableInfo = null;
            FileInfo?OutputTextInfo = null;
            FileInfo?MsgTblInfo     = null;

            // Validate input args: Preliminary checks
            if (args.Length == 0)
            {
                PrintUsage("Error: No input arguments provided!");
                return;
            }
            else if (args.Length > 3)
            {
                PrintUsage("Error: Too many input arguments provided! (max. 3)");
                return;
            }

            // Validate input args: process via PowerArgs
            try
            {
                var parsed = Args.Parse <LaunchArgs>(args);

                InputTableInfo = new(parsed.InputTablePath);
            }
            catch (ArgException ex)
            {
                throw;
            }

            // Validate input args: First arg (always input TBL)
            InputTableInfo = new(args[0]);
            if (!InputTableInfo.Exists)
            {
                PrintUsage("Error: Input table file does not exist!");
                return;
            }
            else if (InputTableInfo.Extension.ToUpperInvariant() != ".TBL")
            {
                PrintUsage("Error: Input table file does not have the .TBL extension! Are you sure it's valid?");
                return;
            }
            else if (InputTableInfo.Length > int.MaxValue)
            {
                PrintUsage("Error: Input file has an absurdly large size (>2 GB)! This is absolutely invalid.");
                return;
            }

            // Validate input args: Remaining arguments
            for (int a = 1; a < args.Length; ++a)
            {
                string   arg     = args[a];
                FileInfo argInfo = new(arg);

                if (!argInfo.Exists)
                {
                    PrintUsage($"Error: File {arg} does not exist!");
                    return;
                }

                // We don't know what kind of file the current argument is because they're both optional,
                // so determine which file this is based on the extension.
                if (argInfo.Extension.ToUpperInvariant() == ".CSV")
                {
                    if (OutputTextInfo == null)
                    {
                        OutputTextInfo = argInfo;
                    }
                    else
                    {
                        PrintUsage("Error: An output CSV path was already provided!");
                        return;
                    }
                }
                else if (argInfo.Name.ToUpperInvariant() == "MSG.TBL")
                {
                    if (MsgTblInfo == null)
                    {
                        MsgTblInfo = argInfo;
                    }
                    else
                    {
                        PrintUsage("Error: Path to MSG.TBL was already provided!");
                        return;
                    }
                }
            }

            // Validate input args: Output CSV path, if one wasn't specified
            if (OutputTextInfo == null)
            {
                // Copy the input path but change the extension to "csv"
                string outPath = InputTableInfo.FullName.Split(".")[0] + ".csv";
                OutputTextInfo = new(outPath);
            }

            // Okay, all of our input arguments should be validated now, and we should have some sort of valid state.
            _ = 0;  // Breakpoint spot

            // Build the input table from the TBL file
            Table InputTable = new(InputTableInfo);

            // If MSG.TBL is defined, load it too!
            Table?MessageTable = null;

            if (MsgTblInfo != null)
            {
                MessageTable = new(MsgTblInfo);
            }

            _ = 0;  // Breakpoint spot

            // If the data we're writing to the file is shorter than the existing data,
            // it could result in undesirable leftover garbage, so we outright delete the
            // file first to ensure that we start with a clean slate.
            OutputTextInfo.Delete();

            // Output each segment of the input table
            using FileStream outputStream   = OutputTextInfo.OpenWrite();
            using StreamWriter outputWriter = new(outputStream);
            StringBuilder outputBuilder = new();

            foreach (TableSegment segment in InputTable.Segments)
            {
                // The first row of each table will be populated with the table name.
                outputBuilder.Append(segment.GetType().ToString() + '\n');

                // The second row of each table will be populated with the name of its values,
                // and following rows will contain actual table data.
                try
                {
                    outputBuilder.Append(segment.GenerateRowColumnText(MessageTable));
                }
                catch (NotImplementedException ex)
                {
                    // Most tables' output functions are not implemented yet, so this
                    // catch block lets us at least test the ones I have implemented.
                }

                // Append a final newline, then proceed to the next segment.
                outputBuilder.Append('\n');
            }

            _ = 0;  // Breakpoint spot

            // Append credits/tagline
            outputBuilder.Append("Data exported with P3TableExporter by CaptainSwag101\n");
            outputBuilder.Append($"Last modified: {DateTime.Today.ToShortDateString()}");

            // When our output is totally built, write it to the output CSV file.
            outputWriter.Write(outputBuilder.ToString());
            outputWriter.Flush();
        }
コード例 #22
0
        public override string GenerateRowColumnText(Table?msgTbl = null)
        {
            StringBuilder outputBuilder = new();

            List <string> rowStrings = new();

            for (int col = 0; col < 21; ++col)
            {
                string colName = col switch
                {
                    0 => "Strength Growth Weight",
                    1 => "Magic Growth Weight",
                    2 => "Endurance Growth Weight",
                    3 => "Agility Growth Weight",
                    4 => "Luck Growth Weight",
                    5 => "Skill 0",
                    6 => "Skill 1",
                    7 => "Skill 2",
                    8 => "Skill 3",
                    9 => "Skill 4",
                    10 => "Skill 5",
                    11 => "Skill 6",
                    12 => "Skill 7",
                    13 => "Skill 8",
                    14 => "Skill 9",
                    15 => "Skill 10",
                    16 => "Skill 11",
                    17 => "Skill 12",
                    18 => "Skill 13",
                    19 => "Skill 14",
                    20 => "Skill 15",
                    _ => "ERROR"
                };
                rowStrings.Add(colName);
            }
            outputBuilder.AppendJoin(',', rowStrings);
            outputBuilder.Append('\n');

            // Extract Skill names from MSG.TBL
            string[]? skillNames = null;
            if (msgTbl != null)
            {
                foreach (TableSegment segment in msgTbl.Segments)
                {
                    if (segment is SkillNames skillNameSegment)
                    {
                        skillNames = skillNameSegment.Names;
                    }
                }
            }

            foreach (var growthAndSkills in Data)
            {
                rowStrings.Clear();

                // Write weighted stat growth values
                rowStrings.Add((growthAndSkills.StatGrowthWeights.Strength + 10).ToString() + '%');
                rowStrings.Add((growthAndSkills.StatGrowthWeights.Magic + 10).ToString() + '%');
                rowStrings.Add((growthAndSkills.StatGrowthWeights.Endurance + 10).ToString() + '%');
                rowStrings.Add((growthAndSkills.StatGrowthWeights.Agility + 10).ToString() + '%');
                rowStrings.Add((growthAndSkills.StatGrowthWeights.Luck + 10).ToString() + '%');

                // Write skills
                foreach (var skill in growthAndSkills.Skills)
                {
                    string skillText = "";

                    if (!skill.Learnable || skill.SkillID == 0)
                    {
                        break;
                        //skillText += "(Unlearnable) ";
                    }

                    if (skillNames != null)
                    {
                        skillText += skillNames[skill.SkillID];
                    }
                    else
                    {
                        skillText += skill.SkillID.ToString();
                    }

                    skillText += $" (base level + {skill.PendingLevels})";

                    rowStrings.Add(skillText);
                }

                outputBuilder.AppendJoin(',', rowStrings);
                outputBuilder.Append('\n');
            }

            return(outputBuilder.ToString());
        }
    }
コード例 #23
0
 public void Sit(Table table) => _table = table;
コード例 #24
0
 public override string GenerateRowColumnText(Table?msgTbl = null)
 {
     throw new NotImplementedException();
 }
コード例 #25
0
 public abstract string GenerateRowColumnText(Table?msgTbl = null);
コード例 #26
0
        /// <summary>
        /// Loads the table and column schema details from the database.
        /// </summary>
        /// <param name="db">The <see cref="DatabaseBase"/>.</param>
        /// <param name="refDataSchema">The reference data schema.</param>
        /// <param name="autoSecurity">Indicates whether the UserRole security should be automatically applied.</param>
        /// <param name="skipSqlSpecific">Indicates whether to skip the Microsoft SQL Server specific metadata queries.</param>
        public static async Task <List <Table> > LoadTablesAndColumnsAsync(DatabaseBase db, string?refDataSchema = null, bool autoSecurity = false, bool skipSqlSpecific = false)
        {
            if (db == null)
            {
                throw new ArgumentNullException(nameof(db));
            }

            var   tables = new List <Table>();
            Table?table  = null;

            await db.SqlStatement((await ResourceManager.GetResourceContentAsync("SelectTableAndColumns.sql").ConfigureAwait(false)) !).SelectQueryAsync((dr) =>
            {
                var ct = TableMapper.Default.MapFromDb(dr, Mapper.OperationTypes.Get) !;
                if (table == null || table.Schema != ct.Schema || table.Name != ct.Name)
                {
                    tables.Add(table = ct);
                }

                table.Columns.Add(ColumnMapper.Default.MapFromDb(dr, Mapper.OperationTypes.Get) !);
                if (autoSecurity && table.Schema != refDataSchema)
                {
                    table.UserRole = $"{table.Schema}.{table.Name}";
                }
            }).ConfigureAwait(false);

            // Configure all the single column primary and unique constraints.
            foreach (var pks in db.SqlStatement((await ResourceManager.GetResourceContentAsync("SelectTablePrimaryKey.sql").ConfigureAwait(false)) !).SelectQueryAsync((dr) =>
            {
                return(new
                {
                    ConstraintName = dr.GetValue <string>("CONSTRAINT_NAME"),
                    TableSchema = dr.GetValue <string>("TABLE_SCHEMA"),
                    TableName = dr.GetValue <string>("TABLE_NAME"),
                    TableColumnName = dr.GetValue <string>("COLUMN_NAME"),
                    IsPrimaryKey = dr.GetValue <string>("CONSTRAINT_TYPE").StartsWith("PRIMARY", StringComparison.InvariantCultureIgnoreCase),
                });
            }).GetAwaiter().GetResult().GroupBy(x => x.ConstraintName))
            {
                // Only single column unique columns are supported.
                if (pks.Count() > 1 && !pks.First().IsPrimaryKey)
                {
                    continue;
                }

                // Set the column flags as appropriate.
                foreach (var pk in pks)
                {
                    var col = (from t in tables
                               from c in t.Columns
                               where t.Schema == pk.TableSchema && t.Name == pk.TableName && c.Name == pk.TableColumnName
                               select c).Single();

                    if (pk.IsPrimaryKey)
                    {
                        col.IsPrimaryKey = true;
                        col.IsIdentity   = col.DefaultValue != null;
                    }
                    else
                    {
                        col.IsUnique = true;
                    }
                }
            }

            if (!skipSqlSpecific)
            {
                // Configure all the single column foreign keys.
                foreach (var fks in db.SqlStatement((await ResourceManager.GetResourceContentAsync("SelectTableForeignKeys.sql").ConfigureAwait(false)) !).SelectQueryAsync((dr) =>
                {
                    return(new
                    {
                        ConstraintName = dr.GetValue <string>("FK_CONSTRAINT_NAME"),
                        TableSchema = dr.GetValue <string>("FK_SCHEMA_NAME"),
                        TableName = dr.GetValue <string>("FK_TABLE_NAME"),
                        TableColumnName = dr.GetValue <string>("FK_COLUMN_NAME"),
                        ForeignSchema = dr.GetValue <string>("UQ_SCHEMA_NAME"),
                        ForeignTable = dr.GetValue <string>("UQ_TABLE_NAME"),
                        ForiegnColumn = dr.GetValue <string>("UQ_COLUMN_NAME")
                    });
                }).ConfigureAwait(false).GetAwaiter().GetResult().GroupBy(x => x.ConstraintName).Where(x => x.Count() == 1))
                {
                    var fk  = fks.Single();
                    var col = (from t in tables
                               from c in t.Columns
                               where t.Schema == fk.TableSchema && t.Name == fk.TableName && c.Name == fk.TableColumnName
                               select c).Single();

                    col.ForeignSchema    = fk.ForeignSchema;
                    col.ForeignTable     = fk.ForeignTable;
                    col.ForeignColumn    = fk.ForiegnColumn;
                    col.IsForeignRefData = col.ForeignSchema == refDataSchema;
                }

                await db.SqlStatement((await ResourceManager.GetResourceContentAsync("SelectTableIdentityColumns.sql").ConfigureAwait(false)) !).SelectQueryAsync((dr) =>
                {
                    var t               = tables.Single(x => x.Schema == dr.GetValue <string>("TABLE_SCHEMA") && x.Name == dr.GetValue <string>("TABLE_NAME"));
                    var c               = t.Columns.Single(x => x.Name == dr.GetValue <string>("COLUMN_NAME"));
                    c.IsIdentity        = true;
                    c.IdentitySeed      = 1;
                    c.IdentityIncrement = 1;
                }).ConfigureAwait(false);

                await db.SqlStatement((await ResourceManager.GetResourceContentAsync("SelectTableAlwaysGeneratedColumns.sql").ConfigureAwait(false)) !).SelectQueryAsync((dr) =>
                {
                    var t = tables.Single(x => x.Schema == dr.GetValue <string>("TABLE_SCHEMA") && x.Name == dr.GetValue <string>("TABLE_NAME"));
                    var c = t.Columns.Single(x => x.Name == dr.GetValue <string>("COLUMN_NAME"));
                    t.Columns.Remove(c);
                }).ConfigureAwait(false);

                await db.SqlStatement((await ResourceManager.GetResourceContentAsync("SelectTableGeneratedColumns.sql").ConfigureAwait(false)) !).SelectQueryAsync((dr) =>
                {
                    var t        = tables.Single(x => x.Schema == dr.GetValue <string>("TABLE_SCHEMA") && x.Name == dr.GetValue <string>("TABLE_NAME"));
                    var c        = t.Columns.Single(x => x.Name == dr.GetValue <string>("COLUMN_NAME"));
                    c.IsComputed = true;
                }).ConfigureAwait(false);
            }

            // Auto-determine reference data relationships even where no foreign key defined.
            foreach (var t in tables)
            {
                foreach (var col in t.Columns.Where(x => !x.IsForeignRefData && x.Name !.Length > 2 && x.Name.EndsWith("Id", StringComparison.InvariantCulture)))
                {
                    var rt = tables.Where(x => x.Name != t.Name && x.Name == col.Name ![0..^ 2] && x.Schema == refDataSchema).SingleOrDefault();
コード例 #27
0
        public override string GenerateRowColumnText(Table?msgTbl = null)
        {
            StringBuilder outputBuilder = new();

            // First row is column names
            List <string> rowStrings = new();

            for (int col = 0; col < 13; ++col)
            {
                string colName = col switch
                {
                    0 => "Persona Name",
                    1 => "Type",
                    2 => "Arcana",
                    3 => "Base Level",
                    4 => "Strength",
                    5 => "Magic",
                    6 => "Endurance",
                    7 => "Agility",
                    8 => "Luck",
                    9 => "Unknown1",
                    10 => "Inheritance",
                    11 => "Special Flags",
                    12 => "Unknown2",
                    _ => "ERROR"
                };
                rowStrings.Add(colName);
            }
            outputBuilder.AppendJoin(',', rowStrings);
            outputBuilder.Append('\n');

            // Extract Persona names from MSG.TBL
            string[]? personaNames = null;
            if (msgTbl != null)
            {
                foreach (TableSegment segment in msgTbl.Segments)
                {
                    if (segment is PersonaNames personaNameSegment)
                    {
                        personaNames = personaNameSegment.Names;
                    }
                }
            }

            // Extract arcana names from MSG.TBL
            string[]? arcanaNames = null;
            if (msgTbl != null)
            {
                foreach (TableSegment segment in msgTbl.Segments)
                {
                    if (segment is ArcanaNames arcanaNameSegment)
                    {
                        arcanaNames = arcanaNameSegment.Names;
                    }
                }
            }

            // Remaining rows are data
            for (int i = 0; i < Data.Length; ++i)
            {
                rowStrings.Clear();

                if (personaNames != null)
                {
                    rowStrings.Add(personaNames[i]);
                }
                else
                {
                    rowStrings.Add(i.ToString());
                }

                rowStrings.Add(Data[i].Type.ToString());

                if (arcanaNames != null)
                {
                    rowStrings.Add(arcanaNames[Data[i].Arcana]);
                }
                else
                {
                    rowStrings.Add(Data[i].Arcana.ToString());
                }

                rowStrings.Add(Data[i].BaseLevel.ToString());
                rowStrings.Add(Data[i].Stats.Strength.ToString());
                rowStrings.Add(Data[i].Stats.Magic.ToString());
                rowStrings.Add(Data[i].Stats.Endurance.ToString());
                rowStrings.Add(Data[i].Stats.Agility.ToString());
                rowStrings.Add(Data[i].Stats.Luck.ToString());
                rowStrings.Add(Data[i].Unknown1.ToString());

                if (Data[i].Inheritance >= 0 && Data[i].Inheritance < InheritanceStrings.Length)
                {
                    rowStrings.Add(InheritanceStrings[Data[i].Inheritance]);
                }
                else
                {
                    rowStrings.Add(Data[i].Inheritance.ToString());
                }

                if (Data[i].Flags == 9984)
                {
                    rowStrings.Add("Can Give Heart Item");
                }
                else if (Data[i].Flags == 12800)
                {
                    rowStrings.Add("Party Members Only");
                }
                else if (Data[i].Flags == 0)
                {
                    rowStrings.Add("None");
                }
                else
                {
                    rowStrings.Add(Data[i].Flags.ToString());
                }

                rowStrings.Add(Data[i].Unknown2.ToString());

                outputBuilder.AppendJoin(',', rowStrings);
                outputBuilder.Append('\n');
            }

            return(outputBuilder.ToString());
        }
    }
コード例 #28
0
 public ExecutionResult(Database database, IList <Table> tableSet, Table?informationMessages)
 {
     Database            = database ?? throw new ArgumentNullException(nameof(database));
     TableSet            = tableSet ?? throw new ArgumentNullException(nameof(tableSet));
     InformationMessages = informationMessages;
 }
コード例 #29
0
        public static Table?Create(IParser parser)
        {
            Table?table = parser.Create();

            return(table);
        }
        public static void AddTable <TOwner>(this ModelBuilder builder, TOwner owner, Table?table)
            where TOwner : BaseEntity
        {
            if (table == null)
            {
                return;
            }

            table.OwnerId = owner.Id;

            for (int iColumn = 0; iColumn < table.Columns.Count(); iColumn++)
            {
                Column column = table.Columns.ElementAt(iColumn);
                column.Order   = iColumn;
                column.TableId = table.Id;
                builder.AddData(column);
            }

            for (int iRow = 0; iRow < table.Rows.Count(); iRow++)
            {
                Row row = table.Rows.ElementAt(iRow);

                for (int iCell = 0; iCell < row.Cells.Count(); iCell++)
                {
                    Cell cell = row.Cells.ElementAt(iCell);
                    cell.RowId = row.Id;
                    cell.Order = iCell;
                    builder.AddData(cell);
                }

                row.TableId = table.Id;
                row.Order   = iRow;
                row.Cells   = new Cell[0];

                builder.AddData(row);
            }

            table.Rows    = new Row[0];
            table.Columns = new Column[0];

            builder.AddData(table);
        }