示例#1
0
 public TypeContext(DataBase dataBase, IEnumerable <TypeInfo> typeInfos)
 {
     this.dataBase   = dataBase;
     this.repository = dataBase.Repository;
     this.basePath   = Path.Combine(dataBase.BasePath, CremaSchema.TypeDirectory);
     this.Initialize(typeInfos);
     this.CremaHost.UserContext.Dispatcher.Invoke(() => this.CremaHost.UserContext.Users.UsersLoggedOut += Users_UsersLoggedOut);
     this.CremaHost.Debug("TypeContext is created.");
 }
示例#2
0
 public TableContext(DataBase dataBase, IEnumerable <TableInfo> tableInfos)
 {
     this.dataBase   = dataBase;
     this.repository = dataBase.Repository;
     this.CremaHost.Debug(Resources.Message_TableContextInitialize);
     this.basePath = Path.Combine(dataBase.BasePath, CremaSchema.TableDirectory);
     this.Initialize(tableInfos);
     this.CremaHost.UserContext.Dispatcher.Invoke(() => this.CremaHost.UserContext.Users.UsersLoggedOut += Users_UsersLoggedOut);
     this.CremaHost.Debug(Resources.Message_TableContextIsCreated);
 }
示例#3
0
 public DataBaseTransaction(Authentication authentication, DataBase dataBase, DataBaseRepositoryHost repository)
 {
     this.authentication  = authentication;
     this.dataBase        = dataBase;
     this.repository      = repository;
     this.typeInfos       = dataBase.TypeContext.Types.Select((Type item) => item.TypeInfo).ToArray();
     this.tableInfos      = dataBase.TableContext.Tables.Select((Table item) => item.TableInfo).ToArray();
     this.transactionPath = Path.Combine(dataBase.CremaHost.WorkingPath, CremaPath.Transaction, $"{dataBase.ID}");
     this.domainPath      = Path.Combine(dataBase.CremaHost.WorkingPath, CremaPath.Domain, $"{dataBase.ID}");
     DirectoryUtility.Copy(this.domainPath, this.transactionPath);
     this.repository.BeginTransaction(dataBase.Name);
     this.authentication.Expired += Authentication_Expired;
 }
示例#4
0
        public void Modify(DataBaseRepositoryHost repository)
        {
            var uri = new Uri(this.dataBase.TableContext.BasePath);

            foreach (var item in this)
            {
                var dataTable = item.Key;
                var table     = item.Value;

                var path1 = table.Path;
                var path2 = dataTable.CategoryPath + dataTable.TableName;

                var schemaUri = new Uri(uri.ToString() + path1 + CremaSchema.SchemaExtension);
                var xmlUri    = new Uri(uri.ToString() + path1 + CremaSchema.XmlExtension);

                if (table.TemplatedParent == null)
                {
                    repository.Modify(schemaUri.LocalPath, dataTable.GetXmlSchema());
                }
                repository.Modify(xmlUri.LocalPath, dataTable.GetXml());
            }
        }
示例#5
0
        public void Modify(DataBaseRepositoryHost repository, Func <Type, bool> predicate)
        {
            var uri = new Uri(this.dataBase.TypeContext.BasePath);

            foreach (var item in this)
            {
                var dataType = item.Key;
                var type     = item.Value;

                if (predicate(type) == false)
                {
                    continue;
                }

                var path1 = type.Path;
                var path2 = dataType.CategoryPath + dataType.Name;

                var schemaUri = new Uri(uri.ToString() + path1 + CremaSchema.SchemaExtension);

                if (dataType.DataSet == null)
                {
                    repository.Delete(schemaUri.LocalPath);
                }
                else
                {
                    repository.Modify(schemaUri.LocalPath, dataType.GetXmlSchema());

                    if (path1 != path2)
                    {
                        var targetSchemaUri = new Uri(uri.ToString() + path2 + CremaSchema.SchemaExtension);

                        repository.Move(schemaUri.LocalPath, targetSchemaUri.LocalPath);
                    }
                }
            }
        }
示例#6
0
 public void Modify(DataBaseRepositoryHost repository)
 {
     this.Modify(repository, item => true);
 }