Ejemplo n.º 1
0
        public void InvokeTypeDelete(Authentication authentication, Type type, CremaDataSet dataSet)
        {
            this.CremaHost.DebugMethod(authentication, this, nameof(InvokeTypeDelete), type);

            var dataTypes  = new DataTypeCollection(dataSet, this.DataBase);
            var dataTables = new DataTableCollection(dataSet, this.DataBase);
            var dataType   = dataSet.Types[type.Name, type.Category.Path];

            var query = from table in dataSet.Tables
                        from column in table.Columns
                        where column.CremaType == dataType
                        select column;

            var columns = query.ToArray();

            foreach (var item in columns)
            {
                item.CremaType = null;
            }

            dataSet.Types.Remove(dataType);

            try
            {
                this.Repository.Delete(type.SchemaPath);
                dataTables.Modify(this.Repository);
                this.Context.InvokeTypeItemDelete(authentication, type);
            }
            catch (Exception e)
            {
                this.CremaHost.Error(e);
                this.Repository.Revert();
                throw e;
            }
        }
Ejemplo n.º 2
0
        public void InvokeCategoryRename(Authentication authentication, TypeCategory category, string name, CremaDataSet dataSet)
        {
            this.CremaHost.DebugMethod(authentication, this, nameof(InvokeCategoryRename), category, name);

            var categoryName = new CategoryName(category.Path)
            {
                Name = name,
            };
            var dataTypes  = new DataTypeCollection(dataSet, this.DataBase);
            var dataTables = new DataTableCollection(dataSet, this.DataBase);

            foreach (var item in dataTypes)
            {
                var dataType = item.Key;
                var type     = item.Value;
                if (type.Path.StartsWith(category.Path) == false)
                {
                    continue;
                }

                dataType.CategoryPath = Regex.Replace(dataType.CategoryPath, "^" + category.Path, categoryName.Path);
            }

            try
            {
                foreach (var item in dataTypes)
                {
                    var dataType = item.Key;
                    var type     = item.Value;
                    if (type.Path.StartsWith(category.Path) == false)
                    {
                        continue;
                    }
                    this.Repository.Modify(type.SchemaPath, dataType.GetXmlSchema());
                }

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

                    if (table.TemplatedParent == null)
                    {
                        this.Repository.Modify(table.SchemaPath, dataTable.GetXmlSchema());
                    }
                    this.Repository.Modify(table.XmlPath, dataTable.GetXml());
                }

                this.Repository.Move(category.LocalPath, this.Context.GenerateCategoryPath(categoryName.Path));
                this.Context.InvokeTypeItemRename(authentication, category, name);
            }
            catch (Exception e)
            {
                this.CremaHost.Error(e);
                this.Repository.Revert();
                throw e;
            }
        }
Ejemplo n.º 3
0
        public void InvokeCategoryDelete(Authentication authentication, TypeCategory category, CremaDataSet dataSet)
        {
            this.CremaHost.DebugMethod(authentication, this, nameof(InvokeCategoryDelete), category);

            var dataTypes  = new DataTypeCollection(dataSet, this.DataBase);
            var dataTables = new DataTableCollection(dataSet, this.DataBase);

            var query = from table in dataSet.Tables
                        from column in table.Columns
                        where column.CremaType != null
                        let dataType = column.CremaType
                                       where dataType.CategoryPath.StartsWith(category.Path)
                                       select column;

            var columns = query.ToArray();

            foreach (var item in columns)
            {
                item.CremaType = null;
            }

            foreach (var item in dataTypes)
            {
                var dataType = item.Key;
                var type     = item.Value;
                if (type.Path.StartsWith(category.Path) == false)
                {
                    continue;
                }
                dataSet.Types.Remove(dataType);
            }

            try
            {
                dataTables.Modify(this.Repository);
                this.Repository.Delete(category.LocalPath);
                this.Context.InvokeTypeItemDelete(authentication, category);
            }
            catch (Exception e)
            {
                this.CremaHost.Error(e);
                this.Repository.Revert();
                throw e;
            }
        }
Ejemplo n.º 4
0
        public void InvokeTypeEndTemplateEdit(Authentication authentication, Type type, CremaDataType dataType)
        {
            this.CremaHost.DebugMethod(authentication, this, nameof(InvokeTypeEndTemplateEdit), type);

            var dataTypes  = new DataTypeCollection(dataType.DataSet, this.DataBase);
            var dataTables = new DataTableCollection(dataType.DataSet, this.DataBase);

            try
            {
                dataTypes.Modify(this.Repository, item => item == type);
                dataTables.Modify(this.Repository);
                this.Context.InvokeTypeItemChange(authentication, type);
            }
            catch (Exception e)
            {
                this.CremaHost.Error(e);
                this.Repository.Revert();
                throw e;
            }
        }
Ejemplo n.º 5
0
        public void InvokeTypeSetTags(Authentication authentication, Type type, TagInfo tags, CremaDataSet dataSet)
        {
            this.CremaHost.DebugMethod(authentication, this, nameof(InvokeTypeSetTags), type, tags);

            var dataTypes = new DataTypeCollection(dataSet, this.DataBase);
            var dataType  = dataSet.Types[type.Name, type.Category.Path];

            dataType.Tags = tags;

            try
            {
                dataTypes.Modify(this.Repository, item => item == type);
                this.Context.InvokeTypeItemChange(authentication, type);
            }
            catch (Exception e)
            {
                this.CremaHost.Error(e);
                this.Repository.Revert();
                throw e;
            }
        }
Ejemplo n.º 6
0
        public void InvokeTypeRename(Authentication authentication, Type type, string newName, CremaDataSet dataSet)
        {
            this.CremaHost.DebugMethod(authentication, this, nameof(InvokeTypeRename), type, newName);
            var dataTypes  = new DataTypeCollection(dataSet, this.DataBase);
            var dataTables = new DataTableCollection(dataSet, this.DataBase);
            var dataType   = dataSet.Types[type.Name, type.Category.Path];

            dataType.TypeName = newName;

            try
            {
                dataTypes.Modify(this.Repository, item => item == type);
                dataTables.Modify(this.Repository);
                this.Context.InvokeTypeItemRename(authentication, type, newName);
            }
            catch (Exception e)
            {
                this.CremaHost.Error(e);
                this.Repository.Revert();
                throw e;
            }
        }