public static async Task AddRandomItemsAsync(this ITableContext tableContext, Authentication authentication, DataBaseSettings settings) { await AddRandomCategoriesAsync(tableContext, authentication, settings); await AddRandomTablesAsync(tableContext, authentication, settings); await AddRandomChildTablesAsync(tableContext, authentication, settings); await AddRandomDerivedTablesAsync(tableContext, authentication, settings); }
public static async Task <ITable[]> AddRandomDerivedTableAsync(this ITableContext tableContext, Authentication authentication) { var tableCategoryCollection = tableContext.GetService(typeof(ITableCategoryCollection)) as ITableCategoryCollection; var category = await tableCategoryCollection.GetRandomTableCategoryAsync(); return(await AddRandomDerivedTableAsync(category, authentication)); }
public static async Task <ITable> AddRandomChildTableAsync(this ITableContext tableContext, Authentication authentication, DataBaseSettings settings) { var tableCollection = tableContext.GetService(typeof(ITableCollection)) as ITableCollection; var table = await tableCollection.GetRandomTableAsync(item => item.TemplatedParent == null && item.Parent == null); return(await table.AddRandomChildTableAsync(authentication, settings)); }
public static async Task <bool> GenerateCategoryAsync(this ITableContext tableContext, Authentication authentication) { var tableCategoryCollection = tableContext.GetService(typeof(ITableCategoryCollection)) as ITableCategoryCollection; var categoryName = RandomUtility.NextIdentifier(); var category = RandomUtility.Within(50) == true ? tableCategoryCollection.Root : await tableCategoryCollection.GetRandomTableCategoryAsync(); if (category.VerifyAccessType(authentication, AccessType.Master) == false) { return(false); } if (GetLevel(category, (i) => i.Parent) > 4) { return(false); } if (category.Categories.ContainsKey(categoryName) == true) { return(false); } await category.AddNewCategoryAsync(authentication, categoryName); return(true); }
public static async Task <ITable> AddRandomTableAsync(this ITableContext tableContext, Authentication authentication, DataBaseSettings settings) { var tableCategoryCollection = tableContext.GetService(typeof(ITableCategoryCollection)) as ITableCategoryCollection; var category = await tableCategoryCollection.GetRandomTableCategoryAsync(); return(await AddRandomTableAsync(category, authentication, settings)); }
public static void GenerateTables(this ITableContext context, Authentication authentication, int tryCount) { for (var i = 0; i < tryCount; i++) { context.GenerateTable(authentication); } }
// public static async Task GenerateAsync(this ITypeContext typeContext, Authentication authentication, int tryCount) // { // for (var i = 0; i < tryCount; i++) // { // await typeContext.GenerateAsync(authentication); // } // } // public static async Task GenerateAsync(this ITableContext tableContext, Authentication authentication) // { // if (RandomUtility.Within(25) == true) // await tableContext.GenerateCategoryAsync(authentication); // else // await tableContext.GenerateTableAsync(authentication); // } // public static async Task GenerateAsync(this ITableContext tableContext, Authentication authentication, int tryCount) // { // for (var i = 0; i < tryCount; i++) // { // await tableContext.GenerateAsync(authentication); // } // } public static async Task GenerateCategoriesAsync(this ITableContext tableContext, Authentication authentication, int tryCount) { for (var i = 0; i < tryCount; i++) { await tableContext.GenerateCategoryAsync(authentication); } }
public static void CreateTable(this ITableContext context, Authentication authentication) { var category = context.Categories.Random(); var template = category.NewTable(authentication); GenerateColumns(template, authentication, RandomUtility.Next(3, 10)); if (RandomUtility.Within(25) == true) { template.SetComment(authentication, RandomUtility.NextString()); } template.EndEdit(authentication); var table = template.Table; while (RandomUtility.Within(10)) { var childTemplate = table.NewTable(authentication); GenerateColumns(childTemplate, authentication, RandomUtility.Next(3, 10)); childTemplate.EndEdit(authentication); } var content = table.Content; content.EnterEdit(authentication); GenerateRows(content, authentication, RandomUtility.Next(10, 100)); foreach (var item in table.Childs) { GenerateRows(item.Content, authentication, RandomUtility.Next(10, 100)); } content.LeaveEdit(authentication); }
public static void AddRandomTables(this ITableContext tableContext, Authentication authentication, int tryCount) { for (var i = 0; i < tryCount; i++) { AddRandomTable(tableContext, authentication); } }
public static void AddRandomCategories(this ITableContext tableContext, Authentication authentication, int tryCount) { for (var i = 0; i < tryCount; i++) { tableContext.AddRandomCategory(authentication); } }
public static void AddRandomItems(this ITableContext tableContext, Authentication authentication) { AddRandomCategories(tableContext, authentication); AddRandomTables(tableContext, authentication); AddRandomChildTables(tableContext, authentication, 10); AddRandomDerivedTables(tableContext, authentication, 10); }
public TableService(ITableContext tableContext, IGithubService githubService) { NullChecker.IsNotNull(tableContext, nameof(tableContext)); NullChecker.IsNotNull(githubService, nameof(githubService)); _tableContext = tableContext; _githubService = githubService; }
public TableContextBuilder With(ITableContext context) { WithPadding(context.Padding) .WithSize(context.Size) .WithStickyHeader(context.StickyHeader); return(this); }
public NewTableViewModel(Authentication authentication, ITableCategory category, ITableTemplate template) : base(authentication, template, true) { this.category = category; this.category.Dispatcher.VerifyAccess(); this.tableContext = category.GetService(typeof(ITableContext)) as ITableContext; this.DisplayName = Resources.Title_NewTable; }
public static Task <ITableCategory[]> GetTableCategoriesAsync(this ITableContext tableContext) { if (tableContext.GetService(typeof(ITableCategoryCollection)) is ITableCategoryCollection tableCategoryCollection) { return(tableCategoryCollection.GetCategoriesAsync()); } throw new NotImplementedException(); }
public static Task <ITableCategory> GetTableCategoryAsync(this ITableContext tableContext, string categoryPath) { if (tableContext.GetService(typeof(ITableCategoryCollection)) is ITableCategoryCollection tableCategoryCollection) { return(tableCategoryCollection.GetCategoryAsync(categoryPath)); } throw new NotImplementedException(); }
public static Task <ITable> GetTableAsync(this ITableContext tableContext, string tableName) { if (tableContext.GetService(typeof(ITableCollection)) is ITableCollection tableCollection) { return(tableCollection.GetTableAsync(tableName)); } throw new NotImplementedException(); }
public PlayerRepository( CloudTable table, ITableContext tableContext, IMapper mapper) { this.tableContext = tableContext; this.table = table; this.mapper = mapper; }
/// <summary> /// 尝试同步表,有可能不成功 /// </summary> /// <param name="table"></param> private void SyncTable(ITableContext table) { bool hasRow = this.TableHasRow(table.Name); //表肯定存在,就看列存不存在 //最简单的迁移策略: //如果列在表里不存在就建,以用户定义的为准 //列元属性同步策略: //* 类型相同可以更改长度,其实也就是 varchar 可以 //* 可空转非空:检测表里是否有行,有的话要求此字段有默认值,更改之前先用默认值填充 // 现有行再转换为非空 //* 非空转可控:可以直接去掉 NOT NULL //先处理代码里定义的列 foreach (var pair in this.model.Fields) { var field = pair.Value; if (field.IsColumn) { if (!table.ColumnExists(field.Name)) { table.AddColumn(this.context.DataContext, field); } else { this.SyncColumn(table, field, hasRow); } } } //然后处理数据库里存在,但代码里未定义的列 //处理策略很简单,我们的原则是不能删除用户的数据,如果是空表直接删除该列,如果有数据就把该列设成可空 var columns = table.GetAllColumns(); var columnsToDelete = columns.Select(c => c.Name) .Except(this.model.Fields.Select(f => f.Value.Name)); //删除数据库存在,但代码未定义的 if (hasRow) { foreach (var c in columns) { if (!c.Nullable && columnsToDelete.Contains(c.Name)) { table.AlterColumnNullable(this.context.DataContext, c.Name, true); } } } else { foreach (var c in columnsToDelete) { table.DeleteColumn(this.context.DataContext, c); } } }
public static void Generate(this ITableContext context, Authentication authentication) { if (RandomUtility.Within(25) == true) { context.GenerateCategory(authentication); } else { context.GenerateTable(authentication); } }
public static async Task CopyTableAsync(this ITableContext tableContext, Authentication authentication) { var category = await tableContext.GetRandomTableItemAsync(item => item is ITableCategory) as ITableCategory; if (await tableContext.GetRandomTableItemAsync(item => item is ITable) is not ITable table) { return; } await table.CopyAsync(authentication, "Table_" + RandomUtility.NextIdentifier(), category.Path, RandomUtility.NextBoolean()); }
public TableContextTests(ITableContext context) { _context = context; _trackerEntryEntity = new TrackerEntryEntity { Username = Constants.USERNAME, Url = Constants.URL, Status = null }; }
private void CreateForeignKeys(ITableContext table, IEnumerable <IField> fields) { foreach (var f in fields) { if (f.IsColumn && f.Type == FieldType.ManyToOne) { var refModel = (IModel)this.context.GetResource(f.Relation); table.AddFK(this.context.DataContext, f.Name, refModel.TableName, OnDeleteAction.NoAction); } } }
protected TableStorageProvider(ITableContext context) { _context = context; var charArray = new char[1024]; for (int i = 0; i < charArray.Length; i++) { charArray[i] = HighestTableStorageUnicodeCharacter; } MaximumKeyValue = new string( charArray ); }
public static void CopyTable(this ITableContext context, Authentication authentication) { var category = context.Categories.Random(); var table = context.Tables.RandomOrDefault(); if (table == null) { return; } table.Copy(authentication, "Table_" + RandomUtility.NextIdentifier(), category.Path, RandomUtility.NextBoolean()); }
private void CreateTable(ITableContext table) { table.CreateTable(this.context.DataContext, this.model, this.model.Name); CreateForeignKeys(table, this.model.Fields.Values); //为 _left 和 _right 添加索引 if (this.model.Hierarchy) { //TODO 添加索引 } }
public static async Task AddRandomTablesAsync(this ITableContext tableContext, Authentication authentication, DataBaseSettings settings) { var minCount = settings.TableContext.MinTableCount; var maxCount = settings.TableContext.MaxTableCount; var count = RandomUtility.Next(minCount, maxCount); var tableCollection = tableContext.GetService(typeof(ITableCollection)) as ITableCollection; while (await tableCollection.GetCountAsync() < count) { await AddRandomTableAsync(tableContext, authentication, settings); } }
public static void ClassInit(TestContext context) { app = new CremaBootstrapper(); app.Initialize(context, nameof(ITableContext_DispatcherTest)); cremaHost = app.GetService(typeof(ICremaHost)) as ICremaHost; cremaHost.Dispatcher.Invoke(() => { authentication = cremaHost.Start(); dataBase = cremaHost.DataBases.Random(); dataBase.Load(authentication); dataBase.Enter(authentication); dataBase.Initialize(authentication); tableContext = dataBase.TableContext; }); }
public static void GenerateTable(this ITableContext context, Authentication authentication) { if (RandomUtility.Within(25) == true) { InheritTable(context, authentication); } else if (RandomUtility.Within(25) == true) { CopyTable(context, authentication); } else { CreateTable(context, authentication); } }
public static async Task GenerateTableAsync(this ITableContext tableContext, Authentication authentication) { if (RandomUtility.Within(25) == true) { await InheritTableAsync(tableContext, authentication); } else if (RandomUtility.Within(25) == true) { await CopyTableAsync(tableContext, authentication); } else { await CreateTableAsync(tableContext, authentication); } }
// Configure is called after ConfigureServices is called. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, ITableContext tableContext) { loggerFactory.MinimumLevel = LogLevel.Information; loggerFactory.AddConsole(); // Configure the HTTP request pipeline. // Add the following to the request pipeline only in development environment. if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseErrorPage(); } else { // Add Error handling middleware which catches all application specific errors and // send the request to the following path or controller action. app.UseErrorHandler("error"); } // Add static files to the request pipeline. app.UseStaticFiles(); // Add cookie-based authentication to the request pipeline. app.UseCookieAuthentication(); // Add OpenIdConnect middleware so you can login using Azure AD. app.UseOpenIdConnectAuthentication(); app.Use((context, next) => { if (context.Request.Path.StartsWithSegments("/ping")) { return context.Response.WriteAsync("pong"); } return next(); }); // Add MVC to the request pipeline. app.UseMvc(); // Initialize DB context tableContext.Configure(); }
public UrlController(ITableContext context) { _tableContext = context; }
public HomeController(ITableContext context) { _tableContext = context; }