Beispiel #1
0
        /// <summary>
        /// 获取领域对象
        /// </summary>
        /// <param name="id">领域对象ID</param>
        /// <returns>领域对象</returns>
        public DomainModel.Spi.DomainModel GetDomainModel(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException("DomainModelManager.GetDomainModel.id");
            }

            var domainModel = DacServiceManager.GetDomainModelDao().GetDomainModel(id);

            if (domainModel.RootDomainObject == null && !string.IsNullOrWhiteSpace(domainModel.RootDomainObjectID))
            {
                var modelObject = domainModel.DomainObjects.FirstOrDefault(i => i.ID == domainModel.RootDomainObjectID);

                domainModel.RootDomainObject = modelObject;
            }

            //构造领域模型树形结构
            foreach (var modelObject in domainModel.DomainObjects)
            {
                var childObjects = domainModel.DomainObjects.Where(i => i.ParentObjectID == modelObject.ID);
                if (childObjects != null)
                {
                    foreach (var tempObject in childObjects)
                    {
                        tempObject.ParentObject = modelObject;
                        modelObject.ChildDomainObjects.Add(tempObject);
                    }
                }
            }

            return(domainModel);
        }
Beispiel #2
0
        /// <summary>
        /// 数据领域对象
        /// </summary>
        /// <param name="dataObject">领域对象</param>
        public void SaveDomainModel(DomainModel.Spi.DomainModel domainModel)
        {
            if (domainModel == null)
            {
                throw new ArgumentNullException("DomainModelManager.SaveDomainModel.domainModel");
            }

            var asso      = domainModel.DomainObjects.SelectMany(i => i.Associations).ToList();
            var assoItems = asso.SelectMany(i => i.Items).ToList();

            using (var tran = new TransactionScope(TransactionScopeOption.Required))
            {
                DacServiceManager.GetDomainModelDao().SaveDomainModel(domainModel);
                foreach (var domainObject in domainModel.DomainObjects)
                {
                    DacServiceManager.GetDomainModelDao().SaveDomainObjectElements(domainObject.Elements);
                }
                if (asso.Count > 0)
                {
                    DacServiceManager.GetDomainModelDao().SaveDomainAssociation(asso);
                }
                if (assoItems.Count > 0)
                {
                    DacServiceManager.GetDomainModelDao().SaveDomainAssociationItem(assoItems);
                }

                tran.Complete();
            }
        }
        /// <summary>
        /// 数据源保存
        /// </summary>
        /// <param name="dataSource">数据源</param>
        public void SaveDataSource(DataSource dataSource)
        {
            if (dataSource == null)
            {
                throw new ArgumentNullException("DataSourceManager.SaveDataSource.dataSource");
            }

            var tables = new List <DatabaseTable>();

            dataSource.DbLinks.ForEach(i => tables.AddRange(i.Tables));

            try
            {
                using (var tran = new TransactionScope(TransactionScopeOption.Required))
                {
                    DacServiceManager.GetDataSourceDao().SaveDataSource(dataSource);
                    DacServiceManager.GetDataSourceDao().SaveDatabaseTables(tables);

                    tran.Complete();
                }
            }
            catch (Exception e)
            {
            }

            //var context = ContextHelper.GetContext().Clone() as DefaultContext;
            //Task.Run(() =>
            //{
            //    ContextHelper.SetContext(context);
            //    Thread.Sleep(1000);
            //});
        }
Beispiel #4
0
        /// <summary>
        /// 删除领域对象
        /// </summary>
        /// <param name="id">领域对象ID</param>
        public void DeleteDomainModel(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException("DomainModelManager.DeleteDomainModel.id");
            }

            DacServiceManager.GetDomainModelDao().DeleteDomainModel(id);
        }
        /// <summary>
        /// 获取数据源
        /// </summary>
        /// <param name="name">数据源ID</param>
        /// <returns>数据源</returns>
        public DataSource GetDataSource(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException("DataSourceManager.GetDataSource.id");
            }

            return(DacServiceManager.GetDataSourceDao().GetDataSource(name));
        }
        /// <summary>
        /// 删除数据源
        /// </summary>
        /// <param name="name">数据源ID</param>
        public void DeleteDataSource(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException("DataSourceManager.DeleteDataSource.id");
            }

            DacServiceManager.GetDataSourceDao().DeleteDataSource(name);
        }
Beispiel #7
0
        /// <summary>
        /// 获取数据对象
        /// </summary>
        /// <param name="id">数据对象ID</param>
        /// <returns>数据对象</returns>
        public DataObject GetDataObject(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException("DataObjectManager.GetDataObject.id");
            }

            return(DacServiceManager.GetDataObjectDao().GetDataObject(id));
        }
Beispiel #8
0
        /// <summary>
        /// 删除数据对象
        /// </summary>
        /// <param name="id">数据对象ID</param>
        public void DeleteDataObject(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentNullException("DataObjectManager.DeleteDataObject.id");
            }

            DacServiceManager.GetDataObjectDao().DeleteDataObject(id);
        }
Beispiel #9
0
        /// <summary>
        /// 数据对象保存
        /// </summary>
        /// <param name="dataObject">数据对象</param>
        public void SaveDataObject(DataObject dataObject)
        {
            if (dataObject == null)
            {
                throw new ArgumentNullException("DataObjectManager.SaveDataObject.dataObject");
            }

            DacServiceManager.GetDataObjectDao().SaveDataObject(dataObject);
        }
 /// <summary>
 /// 获取数据源
 /// </summary>
 /// <returns>数据源</returns>
 public List <DataSource> GetDataSources()
 {
     return(DacServiceManager.GetDataSourceDao().GetDataSources());
 }