[Test] public virtual void testTenantDeleteAuthorizations() { // create tenant ITenant tenant = new TenantEntity("tenant"); identityService.SaveTenant(tenant); // create global auth IAuthorization basePerms = authorizationService.CreateNewAuthorization(AuthorizationFields.AuthTypeGlobal); basePerms.Resource = Resources.Tenant; basePerms.ResourceId = AuthorizationFields.Any; basePerms.AddPermission(Permissions.All); basePerms.RemovePermission(Permissions.Delete); // revoke Delete authorizationService.SaveAuthorization(basePerms); // turn on authorization processEngineConfiguration.SetAuthorizationEnabled(true); identityService.AuthenticatedUserId = jonny2; try { identityService.DeleteTenant("tenant"); Assert.Fail("exception expected"); } catch (AuthorizationException e) { Assert.AreEqual(1, e.MissingAuthorizations.Count); MissingAuthorization info = e.MissingAuthorizations[0]; Assert.AreEqual(jonny2, e.UserId); AuthorizationTestUtil.AssertExceptionInfo(Permissions.Delete.ToString(), Resources.Tenant.ToString() /*.ResourceName()*/, "tenant", info); } }
/// <summary> /// Write Notification Details To Table Storage /// </summary> /// <param name="tenantClient"></param> /// <param name="fileID"></param> /// <param name="fileUploadStatus"></param> public bool WriteNotificationToStorage(string TenantId,String fileID, String fileUploadStatus, string notificationMode, string recipientDetail, bool isNotified) { try { bool notifyStatus = false; string notificationStatusTableName = eZeeFlow.Common.Constants.notificationStatusTableName; string timeString = (DateTime.MaxValue.Ticks - DateTime.UtcNow.Ticks).ToString("d19"); TenantEntity tenant = new TenantEntity(TenantId, timeString); tenant.FileID = fileID; tenant.FileUploadStatus = fileUploadStatus; tenant.NotificationMode = notificationMode; tenant.RecipientDetail = recipientDetail; tenant.IsNotified = isNotified; TableHelper _tableHelper = new TableHelper(Common.Constants.StorageConnectionString); notifyStatus = _tableHelper.InsertEntity(notificationStatusTableName, tenant); return notifyStatus; } catch (Exception ex) { DataHubTraceListener traceListener = new DataHubTraceListener(); traceListener.WriteLog(Categories.Error, "Eventing", ex.Message.ToString(), ex.StackTrace.ToString()); return false; } }
public void TestGetRentalPeriod_ReturnMonthlyPeriod_IfPeriodTypeIsMonthly() { var tenant = new TenantEntity { PeriodType = RentPeriodType.Monthly, PaidTo = new DateTime(2009, 12, 1) }; var rentalPeriod = tenant.GetRentalPeriod() as MonthlyRentalPeriod; Assert.IsNotNull(rentalPeriod); Assert.AreEqual(new DateTime(2009, 12, 1), rentalPeriod.PeriodStartDate); }
public async Task <LoginResultDto> Login(string userNameOrEmailAddress, string plainPassword, string tenancyName = null) { if (userNameOrEmailAddress.IsNullOrEmpty()) { throw new ArgumentNullException("userNameOrEmailAddress"); } if (plainPassword.IsNullOrEmpty()) { throw new ArgumentNullException("plainPassword"); } TenantEntity tenant = null; if (!_multiTenancyConfig.IsEnabled) { tenant = await GetDefaultTenantAsync(); } else if (!string.IsNullOrWhiteSpace(tenancyName)) { tenant = await _tenantRepository.FirstOrDefaultAsync(t => t.TenancyName == tenancyName); if (tenant == null) { return(new LoginResultDto(LoginResultType.InvalidTenancyName)); } if (!tenant.IsActive) { return(new LoginResultDto(LoginResultType.TenantIsNotActive)); } } using (CurrentUnitOfWork.DisableFilter(AbpDataFilters.MustHaveTenant)) { var user = await _repository.FirstOrDefaultAsync(x => x.TenantId == tenant.Id && (x.UserName == userNameOrEmailAddress || x.Email == userNameOrEmailAddress)); if (user == null) { return(new LoginResultDto(LoginResultType.InvalidUserNameOrEmailAddress)); } var verificationResult = new PasswordHasher().VerifyHashedPassword(user.Password, plainPassword); if (verificationResult != PasswordVerificationResult.Success) { return(new LoginResultDto(LoginResultType.InvalidPassword)); } if (!user.IsActive) { return(new LoginResultDto(LoginResultType.UserIsNotActive)); } return(new LoginResultDto(user.MapTo <UserEditDto>(), CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie))); } }
public void TestGetRentalPeriod_Return4WeeklyPeriod_IfPeriodTypeIsFourWeekly() { var tenant = new TenantEntity { PeriodType = RentPeriodType.FourWeekly, PaidTo = new DateTime(2009, 12, 1) }; var rentalPeriod = tenant.GetRentalPeriod() as WeeklyRentalPeriod; Assert.IsNotNull(rentalPeriod); Assert.AreEqual(new DateTime(2009, 12, 1), rentalPeriod.PeriodStartDate); Assert.AreEqual(4, rentalPeriod.NumberOfWeeksInPeriod); }
public void TestRentPerDay_Fortnightly_RentDivideBy14() { var tenant = new TenantEntity { PeriodType = RentPeriodType.Fortnightly, Rent = 100 }; var rentPerDay = tenant.RentPerDay; Assert.AreEqual((decimal)100 / 14, rentPerDay); }
public void TestRentPerDay_FourWeekly_RentDivideBy28() { var tenant = new TenantEntity { PeriodType = RentPeriodType.FourWeekly, Rent = 100 }; var rentPerDay = tenant.RentPerDay; Assert.AreEqual((decimal)100 / 28, rentPerDay); }
public void NotUseFullPeriod_TenantHasPaidTo_ReturnTodayMinusPaidTo() { var calculator = new MyArrearCalculator { CalculatingDate = CalculationDate, UseFullPeriod = false }; var tenant = new TenantEntity { PaidTo = new DateTime(2009, 11, 30) }; int days = calculator.CalculateDays(tenant); Assert.AreEqual(1, days); }
public void ShouldIgnoreTimePartOfPaidToDate() { var calculator = new MyArrearCalculator { CalculatingDate = CalculationDate, UseFullPeriod = false }; var tenant = new TenantEntity { PaidTo = new DateTime(2009, 11, 30, 23, 59, 59) }; int days = calculator.CalculateDays(tenant); Assert.AreEqual(1, days); }
public void CreditPaid_ShouldTakeAwayDaysCoveredByCreditPaid() { var calculator = new MyArrearCalculator { CalculatingDate = CalculationDate, UseFullPeriod = false }; var tenant = new TenantEntity { PaidTo = new DateTime(2009, 11, 29), PeriodType = RentPeriodType.Weekly, Credit = 1, Rent = 7 }; int days = calculator.CalculateDays(tenant); Assert.AreEqual(1, days); //2 days from 2009-11-29 to 2009-12-1, 1 day covered by credit, }
public void HasVacatingDate_ShouldUseVacatingDate_IfVacatingDateIsLessThanCalculationDate() { var calculator = new MyArrearCalculator { CalculatingDate = CalculationDate, UseFullPeriod = false }; var tenant = new TenantEntity { PaidTo = new DateTime(2009, 11, 29), VacatingDate = new DateTime(2009, 11, 30) }; int days = calculator.CalculateDays(tenant); Assert.AreEqual(1, days); }
public void NotUseFullPeriod_TenantHasNoPaidTo_Return0() { var calculator = new MyArrearCalculator { UseFullPeriod = false }; var tenant = new TenantEntity { PaidTo = null }; int days = calculator.CalculateDays(tenant); Assert.AreEqual(0, days); }
private void RegisterTenant(string name, string id) { var tableClient = storageAccount.CreateCloudTableClient(); var table = tableClient.GetTableReference("Tenants"); var tenantEntity = new TenantEntity(id) { Tenant = name }; var insertOperation = TableOperation.Insert(tenantEntity); table.Execute(insertOperation); }
public Task <int> Save(TenantEntity roleEntity, string keyValue, HttpContext context) { if (!string.IsNullOrEmpty(keyValue)) { //roleEntity.Modify(keyValue, context); return(service.UpdateAsync(roleEntity)); } else { //roleEntity.Create(context); return(service.InsertAsync(roleEntity)); } }
protected override void InterceptChange(TenantEntity entity, UpdateOperations operations) { base.InterceptChange(entity, operations); if (operations == UpdateOperations.Add) { var aeProp = entity.GetType().GetProperty("AccountingEntityID"); if (aeProp != null) { var accountingEntity = CurrentDataSource.AccountingEntities.Single(x => x.AppTenantID == TenantFilter.AppTenantID); aeProp.GetSetMethod().Invoke(entity, new object[] { accountingEntity.ID }); } } }
public virtual IdentityOperationResult deleteTenant(string tenantId) { checkAuthorization(Permissions.DELETE, Resources.TENANT, tenantId); TenantEntity tenant = findTenantById(tenantId); if (tenant != null) { deleteTenantMembershipsOfTenant(tenantId); deleteAuthorizations(Resources.TENANT, tenantId); DbEntityManager.delete(tenant); return(new IdentityOperationResult(null, IdentityOperationResult.OPERATION_DELETE)); } return(new IdentityOperationResult(null, IdentityOperationResult.OPERATION_NONE)); }
public virtual ITenant SaveTenant(ITenant tenant) { TenantEntity tenantEntity = (TenantEntity)tenant; if (tenantEntity.Revision == 0) { CheckAuthorization(Permissions.Create, Resources.Tenant, null); CommandContext.GetDbEntityManager <TenantEntity>().Add(tenantEntity); CreateDefaultAuthorizations(tenant); } else { CheckAuthorization(Permissions.Update, Resources.Tenant, tenant.Id); CommandContext.GetDbEntityManager <TenantEntity>().Update(tenantEntity); } return(tenantEntity); }
[Test] public virtual void testTenantCreateAuthorizations() { // add base permission which allows nobody to create tenants: IAuthorization basePerms = authorizationService.CreateNewAuthorization(AuthorizationFields.AuthTypeGlobal); basePerms.Resource = Resources.Tenant; basePerms.ResourceId = AuthorizationFields.Any; basePerms.AddPermission(Permissions.All); // add all then remove 'create' basePerms.RemovePermission(Permissions.Create); authorizationService.SaveAuthorization(basePerms); processEngineConfiguration.SetAuthorizationEnabled(true); identityService.AuthenticatedUserId = jonny2; try { identityService.NewTenant("tenant"); Assert.Fail("exception expected"); } catch (AuthorizationException e) { Assert.AreEqual(1, e.MissingAuthorizations.Count); MissingAuthorization info = e.MissingAuthorizations[0]; Assert.AreEqual(jonny2, e.UserId); AuthorizationTestUtil.AssertExceptionInfo(Permissions.Create.ToString(), Resources.Tenant.ToString() /*.ResourceName()*/, null, info); } // circumvent auth check to get new transient userobject ITenant tenant = new TenantEntity("tenant"); try { identityService.SaveTenant(tenant); Assert.Fail("exception expected"); } catch (AuthorizationException e) { Assert.AreEqual(1, e.MissingAuthorizations.Count); MissingAuthorization info = e.MissingAuthorizations[0]; Assert.AreEqual(jonny2, e.UserId); AuthorizationTestUtil.AssertExceptionInfo(Permissions.Create.ToString(), Resources.Tenant.ToString() /*.ResourceName()*/, null, info); } }
public virtual IdentityOperationResult createTenantUserMembership(string tenantId, string userId) { checkAuthorization(Permissions.CREATE, Resources.TENANT_MEMBERSHIP, tenantId); TenantEntity tenant = findTenantById(tenantId); UserEntity user = findUserById(userId); ensureNotNull("No tenant found with id '" + tenantId + "'.", "tenant", tenant); ensureNotNull("No user found with id '" + userId + "'.", "user", user); TenantMembershipEntity membership = new TenantMembershipEntity(); membership.Tenant = tenant; membership.User = user; DbEntityManager.insert(membership); createDefaultTenantMembershipAuthorizations(tenant, user); return(new IdentityOperationResult(null, IdentityOperationResult.OPERATION_CREATE)); }
public async Task CreateTenant(CreateTenantDto input) { var tenant = new TenantEntity(input.TenancyName, input.DisplayName) { IsActive = input.IsActive }; if (await _repository.FirstOrDefaultAsync(x => x.TenancyName == tenant.TenancyName) != null) { throw new UserFriendlyException(string.Format(L("TenancyNameIsAlreadyTaken"), tenant.TenancyName)); } await _repository.InsertAsync(tenant); await CurrentUnitOfWork.SaveChangesAsync(); //To get new tenant's id. //We are working entities of new tenant, so changing tenant filter CurrentUnitOfWork.SetFilterParameter(AbpDataFilters.MayHaveTenant, AbpDataFilters.Parameters.TenantId, tenant.Id); }
public virtual IdentityOperationResult saveTenant(Tenant tenant) { TenantEntity tenantEntity = (TenantEntity)tenant; string operation = null; if (tenantEntity.Revision == 0) { operation = IdentityOperationResult.OPERATION_CREATE; checkAuthorization(Permissions.CREATE, Resources.TENANT, null); DbEntityManager.insert(tenantEntity); createDefaultAuthorizations(tenant); } else { operation = IdentityOperationResult.OPERATION_UPDATE; checkAuthorization(Permissions.UPDATE, Resources.TENANT, tenant.Id); DbEntityManager.merge(tenantEntity); } return(new IdentityOperationResult(tenantEntity, operation)); }
public virtual IdentityOperationResult createTenantGroupMembership(string tenantId, string groupId) { checkAuthorization(Permissions.CREATE, Resources.TENANT_MEMBERSHIP, tenantId); TenantEntity tenant = findTenantById(tenantId); GroupEntity group = findGroupById(groupId); ensureNotNull("No tenant found with id '" + tenantId + "'.", "tenant", tenant); ensureNotNull("No group found with id '" + groupId + "'.", "group", group); TenantMembershipEntity membership = new TenantMembershipEntity(); membership.Tenant = tenant; membership.Group = group; DbEntityManager.insert(membership); createDefaultTenantMembershipAuthorizations(tenant, group); return(new IdentityOperationResult(null, IdentityOperationResult.OPERATION_CREATE)); }
protected virtual void InterceptChange(TenantEntity entity, UpdateOperations operations) { if (TenantFilter.AppTenantID == 0) { throw new HttpRequestValidationException(); } if (operations == UpdateOperations.Add) { entity.AppTenantID = TenantFilter.AppTenantID; } if (operations == UpdateOperations.Change) { int originalTenant = CurrentDataSource.Entry(entity).OriginalValues.GetValue <int>("AppTenantID"); if (originalTenant != TenantFilter.AppTenantID) { throw new HttpRequestValidationException(); } if (originalTenant != entity.AppTenantID) { throw new Exception("Entity cannot move across tenants"); } } if (operations == UpdateOperations.Delete) { int originalTenant = CurrentDataSource.Entry(entity).OriginalValues.GetValue <int>("AppTenantID"); if (originalTenant != TenantFilter.AppTenantID) { throw new HttpRequestValidationException(); } } }
public static bool IsEdible(this ISharedTenant sharedTenant, TenantEntity tenant) => sharedTenant.IsEdible(tenant.Name);
public void TestRentPerDay_Monthly_12MonthRentDivideBy365() { var tenant = new TenantEntity { PeriodType = RentPeriodType.Monthly, Rent = 100 }; var rentPerDay = tenant.RentPerDay; Assert.AreEqual((decimal)100 * 12 / 365 , rentPerDay); }
static void AzureStorageTableExamples() { // Getting configuration from the App.config file and get access to the CloudStorageAccount. // Azure access Key should is stored in the App.config String storageKeyValue = CloudConfigurationManager.GetSetting("AzureStorageAccount"); // Just in case to check whether reading the correct value Console.WriteLine("Storage Account Key Used" + storageKeyValue); CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageKeyValue); // Create the table client. CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); // Retrieve a reference to the table. CloudTable table = tableClient.GetTableReference("tenant"); table.CreateIfNotExists(); // Lesson 1 Table Insert TenantEntity tenant1 = new TenantEntity("Neson", "De Jesus", "Canada"); tenant1.Email = "*****@*****.**"; tenant1.PhoneNumber = "911-911-9111"; TableOperation tOper = TableOperation.Insert(tenant1); // Lesson 2 Batch Insert TableBatchOperation batchInsertOperation = new TableBatchOperation(); TenantEntity tenant2 = new TenantEntity("Vivek", "Menon", "USA"); tenant2.Email = "*****@*****.**"; tenant2.PhoneNumber = "911-911-9111"; batchInsertOperation.Insert(tenant2); TenantEntity tenant3 = new TenantEntity("Sanders", "John", "USA"); tenant3.Email = "*****@*****.**"; tenant3.PhoneNumber = "911-911-9111"; batchInsertOperation.Insert(tenant3); table.ExecuteBatch(batchInsertOperation); // Lession 3: Accesing the table data TableQuery <TenantEntity> query = new TableQuery <TenantEntity>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "USA")); foreach (TenantEntity tenant in table.ExecuteQuery(query)) { Console.WriteLine("{0}, {1}, {2}, {3}", tenant.firstName, tenant.lastName, tenant.Email, tenant.PhoneNumber); } // Lesson 4: Multiple condition in where clause TableQuery <TenantEntity> queryMultipleWhereContidion = new TableQuery <TenantEntity>().Where( TableQuery.CombineFilters( TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "USA"), TableOperators.And, TableQuery.GenerateFilterCondition("lastName", QueryComparisons.Equal, "Sanders"))); foreach (TenantEntity tenant in table.ExecuteQuery(queryMultipleWhereContidion)) { Console.WriteLine("{0}, {1}, {2}, {3}", tenant.firstName, tenant.lastName, tenant.Email, tenant.PhoneNumber); } // Lesson 5: Single record retrieval TableOperation retrieveOperation = TableOperation.Retrieve <TenantEntity>("Sanders", "John"); TableResult retrievedResult = table.Execute(retrieveOperation); if (retrievedResult.Result != null) { Console.WriteLine(((TenantEntity)retrievedResult.Result).PhoneNumber); } else { Console.WriteLine("The phone number could not be retrieved."); } Console.ReadLine(); }
public async Task <Tenant> CreateOrUpdateTenantAsync( Tenant tenant, IEnumerable <AuthenticationRule> authenticationRules, IReadOnlyDictionary <string, int> quotas) { using (var ctx = new AdminEntities(this.connectionString)) { var now = DateTime.UtcNow; var entity = await ctx.Tenants.GetAsync( tenant.SubscriptionId, tenant.ResourceGroupName, tenant.AccountName, false); if (entity == null) { entity = new TenantEntity { SubscriptionId = tenant.SubscriptionId, ResourceGroup = tenant.ResourceGroupName, AccountName = tenant.AccountName, Location = tenant.Location, SKU = tenant.SKU, Tags = JsonConvert.SerializeObject(tenant.Tags), State = tenant.State.ToString(), Created = now, LastModified = now, Address = tenant.Address, ResourceDescription = JsonConvert.SerializeObject(new TenantDescription { AuthenticationRules = authenticationRules.ToList(), ChannelSettings = new List <ChannelSetting>() }), ResourceId = tenant.ResourceId }; ctx.Tenants.Add(entity); ctx.Quotas.AddRange(quotas.Select(pair => new QuotaEntity { AccountName = tenant.AccountName, QuotaName = pair.Key, Remaining = pair.Value, Quota = pair.Value, CreatedTime = now, LastUpdatedTime = now })); } else { // Update-able properties: Tags, State and Address entity.Tags = JsonConvert.SerializeObject(tenant.Tags); entity.State = tenant.State.ToString(); entity.Address = tenant.Address; entity.LastModified = now; } await ctx.SaveChangesAsync(); return(entity.ToTenant()); } }
public void TestGetRentalPeriod_ReturnMonthlyPeriod_PaidToLastDay() { var tenant = new TenantEntity { PeriodType = RentPeriodType.Monthly, PaidTo = new DateTime(2009, 12, 1), PaidToLastDay = true }; var rentalPeriod = tenant.GetRentalPeriod() as MonthlyRentalPeriod; Assert.IsTrue(rentalPeriod.PaidToLastDayOfMonth); }
public async Task <IActionResult> SubmitForm(TenantEntity tenantEntity, string keyValue) { await tenantService.Save(tenantEntity, keyValue, HttpContext); return(Success("操作成功。")); }
public void TestVacatingBefore_ShouldIgnoreTime() { var tenant = new TenantEntity { VacatingDate = new DateTime(2000, 1, 1, 1, 0, 0) }; bool result = tenant.VacatingBefore(new DateTime(2000, 1, 1, 12, 0, 0)); Assert.IsFalse(result); }
public void TestCreditedDays_ReturnCreditDividByRentPerDay() { var tenant = new TenantEntity { Credit = 3, PeriodType = RentPeriodType.Weekly, Rent = 7 }; Assert.AreEqual(3, tenant.CreditedDays); }
public void TestVacatingBefore_ReturnTrue_IfVacatingDateLessThanGivenDate() { var tenant = new TenantEntity { VacatingDate = new DateTime(2000, 1, 1) }; bool result = tenant.VacatingBefore(new DateTime(2000, 1, 2)); Assert.IsTrue(result); }
public void TestVacatingBefore_ReturnFalse_IfVacatingDateIsNull() { var tenant = new TenantEntity { VacatingDate = null }; bool result = tenant.VacatingBefore(new DateTime(2000, 1, 1)); Assert.IsFalse(result); }
public void TestCreditedDays_Return0_IfCreditIs0() { var tenant = new TenantEntity { Credit = 0 }; Assert.AreEqual(0, tenant.CreditedDays); }
public async Task <TenantViewModel> Handle(AddOrUpdateTenantCommand request, CancellationToken cancellationToken) { var isNew = false; // PRESENTATION/APPLICATION LAYER var tenantViewModel = request.Tenant; // PERSISTENCE LAYER using (var transaction = await context.Database.BeginTransactionAsync()) { var sqlTransaction = transaction.GetDbTransaction(); TenantEntity tenantEntity = null; // Check for existing slug/key on a different tenant. var slug = tenantViewModel.Slug.Sluggify(); var id = await facade.QueryFirstOrDefaultAsync <int?>( @"SELECT TOP 1 Id FROM Tenants WITH(NOLOCK) WHERE Slug = @slug AND (@Id IS NULL OR Id <> @Id)", new { slug, tenantViewModel.Id }, sqlTransaction); if (id != null) { throw new ApplicationLayerException("Tenant slug already in use by another tenant."); } else { tenantViewModel.Slug = slug; } // Update. if (tenantViewModel.Id != null) { var tenantId = (int)tenantViewModel.Id; tenantEntity = context.Tenants.Find(tenantId); if (tenantEntity == null) { throw new ApplicationLayerException($"Tenant with ID {tenantId} is in the customer's access list, but does not seem to exist."); } mapper.Map(tenantViewModel, tenantEntity); } else { // Add. var customerId = await facade.QueryFirstOrDefaultAsync <int>("SELECT TOP 1 Id FROM Customers WHERE AspNetUsersId = @AspNetUsersId", request, sqlTransaction); tenantEntity = mapper.Map(tenantViewModel); tenantEntity.CustomerId = customerId; await context.Tenants.AddAsync(tenantEntity); isNew = true; } await context.SaveChangesAsync(); tenantViewModel.Id = tenantEntity.Id; if (isNew) { await context.TenantAspNetUsers.AddAsync(new TenantAspNetUserEntity { AspNetUsersId = request.AspNetUsersId, TenantId = tenantEntity.Id }); await context.SaveChangesAsync(); } await transaction.CommitAsync(); } return(tenantViewModel); }
public static void InitFreameworkDbData(this IApplicationBuilder app, IServiceProvider applicationServices, string webRootPath, EvolutionDBContext dbContext) { var sqlServerDatabase = dbContext.Database; //try //{ // int r = sqlServerDatabase.ExecuteSqlCommand("select count(*) from Sys_User"); // return; //} //catch(Exception ex) //{ // //这个ex是可预期的。 //} try { sqlServerDatabase.EnsureDeleted(); } catch { } if (sqlServerDatabase.EnsureCreated()) { //sqlServerDatabase.Migrate(); DataInitTool.OpenExcel("InitData.xlsx", webRootPath); DataInitTool.ProcessSheet("Sys_DbBackup", colums => { DbBackupEntity entity = new DbBackupEntity(); entity.Id = colums[0]; entity.BackupType = colums[1]; entity.DbName = colums[2]; entity.FileName = colums[3]; entity.FileSize = colums[4]; entity.FilePath = colums[5]; entity.BackupTime = DateTime.Parse(colums[6]); entity.EnabledMark = bool.Parse(colums[9]); entity.CreateTime = DateTime.MinValue; dbContext.DbBackups.Add(entity); }); DataInitTool.ProcessSheet("Sys_FilterIP", colums => { FilterIPEntity entity = new FilterIPEntity(); entity.Id = colums[0]; entity.Type = bool.Parse(colums[1]); entity.StartIP = colums[2]; entity.EndIP = colums[3]; entity.EnabledMark = bool.Parse(colums[6]); entity.Description = colums[7]; entity.CreateTime = DateTime.Parse(colums[8]); entity.TenantId = colums[14]; dbContext.FilterIPs.Add(entity); }); DataInitTool.ProcessSheet("Sys_Items", colums => { ItemsEntity entity = new ItemsEntity(); entity.Id = colums[0]; entity.ParentId = colums[1]; entity.EnCode = colums[2]; entity.FullName = colums[3]; entity.IsTree = GetDefaultBool(colums[4], false); entity.Layers = int.Parse(colums[5]); entity.SortCode = int.Parse(colums[6]); entity.DeleteMark = GetDefaultBool(colums[7], false); entity.EnabledMark = GetDefaultBool(colums[8], true); entity.CreateTime = DateTime.MinValue; entity.TenantId = colums[16]; dbContext.Items.Add(entity); }); DataInitTool.ProcessSheet("Sys_ItemsDetail", colums => { ItemsDetailEntity entity = new ItemsDetailEntity(); entity.Id = colums[0]; entity.ItemId = colums[1]; entity.ParentId = colums[2]; entity.ItemCode = colums[3]; entity.ItemName = colums[4]; entity.IsDefault = GetDefaultBool(colums[6], false); entity.SortCode = int.Parse(colums[8]); entity.DeleteMark = GetDefaultBool(colums[9], false); entity.EnabledMark = GetDefaultBool(colums[10], true); entity.TenantId = colums[18]; dbContext.ItemsDetails.Add(entity); }); DataInitTool.ProcessSheet("Sys_Log", colums => { LogEntity entity = new LogEntity(); entity.Id = colums[0]; entity.Date = DateTime.Parse(colums[1]); entity.Account = colums[2]; entity.NickName = colums[3]; entity.Type = colums[4]; entity.IPAddress = colums[5]; entity.IPAddressName = colums[6]; entity.ModuleName = colums[8]; entity.Result = bool.Parse(colums[9]); entity.Description = colums[10]; entity.CreateTime = DateTime.MinValue; entity.CreatorUserId = colums[12]; entity.TenantId = colums[13]; dbContext.Logs.Add(entity); }); DataInitTool.ProcessSheet("Sys_Menu", colums => { MenuEntity entity = new MenuEntity(); entity.Id = colums[0]; entity.ParentId = colums[1]; entity.Layers = int.Parse(colums[2]); entity.FullName = colums[4]; entity.Icon = colums[5]; entity.UrlAddress = colums[6]; entity.Target = colums[7]; entity.IsMenu = bool.Parse(colums[8]); entity.IsExpand = bool.Parse(colums[9]); entity.IsPublic = bool.Parse(colums[10]); entity.AllowEdit = bool.Parse(colums[11]); entity.AllowDelete = bool.Parse(colums[12]); entity.SortCode = int.Parse(colums[13]); entity.DeleteMark = bool.Parse(colums[14]); entity.EnabledMark = bool.Parse(colums[15]); entity.Description = colums[16]; entity.CreateTime = DateTime.MinValue; entity.LastModifyTime = DateTime.MinValue; entity.LastModifyUserId = colums[20]; entity.TenantId = colums[23]; dbContext.Menus.Add(entity); }); DataInitTool.ProcessSheet("Sys_MenuButton", colums => { MenuButtonEntity entity = new MenuButtonEntity(); entity.Id = colums[0]; entity.MenuId = colums[1]; entity.ParentId = colums[2]; if (!string.IsNullOrEmpty(colums[3])) { entity.Layers = int.Parse(colums[3]); } entity.EnCode = colums[4]; entity.FullName = colums[5]; if (!string.IsNullOrEmpty(colums[7])) { entity.Location = int.Parse(colums[7]); } entity.JsEvent = colums[8]; entity.UrlAddress = colums[9]; if (!string.IsNullOrEmpty(colums[10])) { entity.Split = bool.Parse(colums[10]); } if (!string.IsNullOrEmpty(colums[11])) { entity.IsPublic = bool.Parse(colums[11]); } if (!string.IsNullOrEmpty(colums[12])) { entity.AllowEdit = bool.Parse(colums[12]); } if (!string.IsNullOrEmpty(colums[13])) { entity.AllowDelete = bool.Parse(colums[13]); } if (!string.IsNullOrEmpty(colums[14])) { entity.SortCode = int.Parse(colums[14]); } if (!string.IsNullOrEmpty(colums[15])) { entity.DeleteMark = bool.Parse(colums[15]); } if (!string.IsNullOrEmpty(colums[16])) { entity.EnabledMark = bool.Parse(colums[16]); } entity.CreateTime = DateTime.MinValue; entity.LastModifyTime = DateTime.MinValue; entity.LastModifyUserId = colums[20]; entity.TenantId = colums[24]; dbContext.ModuleButtons.Add(entity); }); DataInitTool.ProcessSheet("Sys_Organize", colums => { OrganizeEntity entity = new OrganizeEntity(); entity.Id = colums[0]; entity.ParentId = colums[1]; entity.Layers = int.Parse(colums[2]); entity.EnCode = colums[3]; entity.FullName = colums[4]; entity.ShortName = colums[5]; entity.CategoryId = colums[6]; entity.ManagerId = colums[7]; entity.Address = colums[14]; entity.SortCode = int.Parse(colums[17]); entity.DeleteMark = bool.Parse(colums[18]); entity.EnabledMark = bool.Parse(colums[19]); entity.CreateTime = DateTime.MinValue; entity.TenantId = colums[27]; dbContext.Organizes.Add(entity); }); DataInitTool.ProcessSheet("Sys_Role", colums => { RoleEntity entity = new RoleEntity(); entity.Id = colums[0]; entity.OrganizeId = colums[1]; entity.Category = int.Parse(colums[2]); entity.EnCode = colums[3]; entity.FullName = colums[4]; entity.Type = colums[5]; entity.AllowEdit = bool.Parse(colums[6]); entity.AllowDelete = bool.Parse(colums[7]); entity.SortCode = int.Parse(colums[8]); entity.DeleteMark = bool.Parse(colums[9]); entity.EnabledMark = bool.Parse(colums[10]); entity.CreateTime = DateTime.MinValue; entity.LastModifyTime = DateTime.MinValue; entity.LastModifyUserId = colums[15]; entity.TenantId = colums[18]; dbContext.Roles.Add(entity); }); DataInitTool.ProcessSheet("Sys_RoleAuthorize", colums => { RoleAuthorizeEntity entity = new RoleAuthorizeEntity(); entity.Id = colums[0]; entity.ItemType = int.Parse(colums[1]); entity.ItemId = colums[2]; entity.ObjectType = int.Parse(colums[3]); entity.ObjectId = colums[4]; //entity.SortCode = int.Parse(colums[5]); entity.CreateTime = DateTime.MinValue; entity.CreatorUserId = colums[7]; entity.TenantId = colums[8]; dbContext.RoleAuthorize.Add(entity); }); DataInitTool.ProcessSheet("Sys_User", colums => { UserEntity entity = new UserEntity(); entity.Id = colums[0]; entity.Account = colums[1]; entity.RealName = colums[2]; entity.NickName = colums[3]; entity.Gender = bool.Parse(colums[5]); entity.MobilePhone = colums[7]; entity.OrganizeId = colums[13]; entity.DepartmentId = colums[14]; entity.RoleId = colums[15]; entity.DutyId = colums[16]; entity.IsAdministrator = bool.Parse(colums[17]); entity.DeleteMark = bool.Parse(colums[19]); entity.EnabledMark = bool.Parse(colums[20]); entity.Description = colums[21]; entity.CreateTime = DateTime.MinValue; entity.LastModifyTime = DateTime.MinValue; entity.LastModifyUserId = colums[25]; entity.TenantId = colums[28]; dbContext.Users.Add(entity); }); DataInitTool.ProcessSheet("Sys_UserLogOn", colums => { UserLogOnEntity entityt = new UserLogOnEntity(); entityt.Id = colums[0]; entityt.UserId = colums[1]; entityt.UserPassword = colums[2]; entityt.UserSecretkey = colums[3]; if (!string.IsNullOrEmpty(colums[9])) { entityt.PreviousVisitTime = DateTime.Parse(colums[9]); } if (!string.IsNullOrEmpty(colums[10])) { entityt.LastVisitTime = DateTime.Parse(colums[10]); } if (!string.IsNullOrEmpty(colums[13])) { entityt.LogOnCount = int.Parse(colums[13]); } entityt.TenantId = colums[20]; dbContext.UserLogOn.Add(entityt); }); DataInitTool.ProcessSheet("Sys_Tenant", colums => { TenantEntity entityt = new TenantEntity(); entityt.Id = colums[0]; entityt.EnCode = colums[1]; entityt.FullName = colums[2]; entityt.CreateTime = DateTime.MinValue; entityt.LastModifyTime = DateTime.MinValue; dbContext.Tenants.Add(entityt); }); dbContext.SaveChanges(); } }