Ejemplo n.º 1
0
 private async Task AlterTableAsync(string tableName, IList <TableColumn> tableColumns, string pluginId, IList <string> dropColumnNames = null)
 {
     try
     {
         await _settingsManager.Database.AlterTableAsync(tableName,
                                                         GetRealTableColumns(tableColumns), dropColumnNames);
     }
     catch (Exception ex)
     {
         await ErrorLogRepository.AddErrorLogAsync(pluginId, ex, string.Empty);
     }
 }
Ejemplo n.º 2
0
        private async Task <(bool IsSuccess, Exception Ex)> CreateTableAsync(string tableName, IList <TableColumn> tableColumns, string pluginId, bool isContentTable)
        {
            try
            {
                await _settingsManager.Database.CreateTableAsync(tableName, tableColumns);
            }
            catch (Exception ex)
            {
                await ErrorLogRepository.AddErrorLogAsync(pluginId, ex, string.Empty);

                return(false, ex);
            }

            if (isContentTable)
            {
                try
                {
                    await _settingsManager.Database.CreateIndexAsync(tableName, $"IX_{tableName}_General", $"{nameof(Content.Top)} DESC", $"{nameof(Content.Taxis)} DESC", $"{nameof(Content.Id)} DESC");
                }
                catch (Exception ex)
                {
                    await ErrorLogRepository.AddErrorLogAsync(pluginId, ex, string.Empty);

                    return(false, ex);
                }

                try
                {
                    await _settingsManager.Database.CreateIndexAsync(tableName, $"IX_{tableName}_Taxis", $"{nameof(Content.Taxis)} DESC");
                }
                catch (Exception ex)
                {
                    await ErrorLogRepository.AddErrorLogAsync(pluginId, ex, string.Empty);

                    return(false, ex);
                }
            }

            return(true, null);
        }