Esempio n. 1
0
        private void WriteTenants(PersistenceStorage.PersistentDataContext persistenceDb, Application app)
        {
            if ((app.Tenants != null) && (app.Tenants.Count > 0))
            {
                List <Tenant> removedTenants = new List <Tenant>();

                foreach (Tenant tenant in app.Tenants)
                {
                    if (tenant.RowState == EntityState.New)
                    {
                        PersistenceStorage.Tenant pTenant = new PersistenceStorage.Tenant();
                        pTenant.Name            = tenant.Name;
                        pTenant.ApplicationID   = tenant.ApplicationId;
                        pTenant.UpperScaleLimit = tenant.UpperScaleLimit;
                        pTenant.ScalingFactor   = tenant.ScalingFactor;

                        persistenceDb.Tenant.InsertOnSubmit(pTenant);
                        Log.Info(typeof(Database), "New application " + app.Name + " tenant " + tenant.Name + " added");
                    }
                    else if (tenant.RowState == EntityState.Modified)
                    {
                        PersistenceStorage.Tenant pTenant = persistenceDb.Tenant.FirstOrDefault(x => x.ID == tenant.Id);
                        pTenant.Name            = tenant.Name;
                        pTenant.UpperScaleLimit = tenant.UpperScaleLimit;
                        pTenant.ScalingFactor   = tenant.ScalingFactor;

                        Log.Info(typeof(Database), "Application " + app.Name + " tenant " + tenant.Name + " updated");
                    }
                    else if (tenant.RowState == EntityState.Removed)
                    {
                        PersistenceStorage.Tenant pTenant = persistenceDb.Tenant.FirstOrDefault(x => x.ID == tenant.Id);
                        persistenceDb.Tenant.DeleteOnSubmit(pTenant);

                        removedTenants.Add(tenant);
                    }
                }

                foreach (Tenant removed in removedTenants)
                {
                    app.Tenants.Remove(removed);
                    Log.Info(typeof(Database), "Application " + app.Name + " tenant " + removed.Name + " removed");
                }
            }
        }
Esempio n. 2
0
        private void WriteTenants(PersistenceStorage.PersistentDataContext persistenceDb, Application app)
        {
            if ((app.Tenants != null) && (app.Tenants.Count > 0))
            {
                List<Tenant> removedTenants = new List<Tenant>();

                foreach (Tenant tenant in app.Tenants)
                {
                    if (tenant.RowState == EntityState.New)
                    {
                        PersistenceStorage.Tenant pTenant = new PersistenceStorage.Tenant();
                        pTenant.Name = tenant.Name;
                        pTenant.ApplicationID = tenant.ApplicationId;
                        pTenant.UpperScaleLimit = tenant.UpperScaleLimit;
                        pTenant.ScalingFactor = tenant.ScalingFactor;

                        persistenceDb.Tenant.InsertOnSubmit(pTenant);
                        Log.Info(typeof(Database), "New application " + app.Name + " tenant " + tenant.Name + " added");
                    }
                    else if (tenant.RowState == EntityState.Modified)
                    {
                        PersistenceStorage.Tenant pTenant = persistenceDb.Tenant.FirstOrDefault(x => x.ID == tenant.Id);
                        pTenant.Name = tenant.Name;
                        pTenant.UpperScaleLimit = tenant.UpperScaleLimit;
                        pTenant.ScalingFactor = tenant.ScalingFactor;

                        Log.Info(typeof(Database), "Application " + app.Name + " tenant " + tenant.Name + " updated");
                    }
                    else if (tenant.RowState == EntityState.Removed)
                    {
                        PersistenceStorage.Tenant pTenant = persistenceDb.Tenant.FirstOrDefault(x => x.ID == tenant.Id);
                        persistenceDb.Tenant.DeleteOnSubmit(pTenant);

                        removedTenants.Add(tenant);
                    }
                }

                foreach (Tenant removed in removedTenants)
                {
                    app.Tenants.Remove(removed);
                    Log.Info(typeof(Database), "Application " + app.Name + " tenant " + removed.Name + " removed");
                }
            }
        }
Esempio n. 3
0
 private void Tenant_Detach(Tenant entity)
 {
     this.SendPropertyChanging();
     entity.Application = null;
 }