示例#1
0
        private static async Task DropModelNodeInside(ModelNode sourceNode, DesignNode targetNode)
        {
            //注意:目标节点可能是模型根目录
            if (targetNode.NodeType == DesignNodeType.ModelRootNode)
            {
                var rootNode = (ModelRootNode)targetNode;
                if (rootNode.AppID != sourceNode.Model.AppId)
                {
                    throw new InvalidOperationException("无法拖动模型节点至不同的Application内");
                }

                sourceNode.Parent.Nodes.Remove(sourceNode);
                targetNode.Nodes.Add(sourceNode);
                sourceNode.Model.FolderId = null;
                await StagedService.SaveModelAsync(sourceNode.Model); //直接保存
            }
            else if (targetNode.NodeType == DesignNodeType.FolderNode)
            {
                var targetFolder = ((FolderNode)targetNode).Folder;
                var rootFolder   = targetFolder.GetRoot();
                if (rootFolder.AppId != sourceNode.Model.AppId)
                {
                    throw new InvalidOperationException("无法拖动模型节点至不同的Application内");
                }

                sourceNode.Parent.Nodes.Remove(sourceNode);
                targetNode.Nodes.Add(sourceNode);
                sourceNode.Model.FolderId = targetFolder.Id;
                await StagedService.SaveModelAsync(sourceNode.Model); //直接保存
            }
            else
            {
                throw new NotSupportedException();
            }
        }
示例#2
0
        internal async Task SaveAsync()
        {
            if (!IsCheckoutByMe)
            {
                throw new Exception("StoreNode has not checkout");
            }

            //保存节点模型
            await StagedService.SaveModelAsync(Model);
        }
示例#3
0
        /// <summary>
        /// 保存模型节点
        /// </summary>
        internal async Task SaveAsync(object[] modelInfos)
        {
            if (!IsCheckoutByMe)
            {
                throw new Exception("ModelNode has not checkout");
            }

            //TODO: 更新相关模型的内容,另考虑事务保存模型及相关代码
            if (Model.PersistentState != PersistentState.Deleted)
            {
                switch (Model.ModelType)
                {
                case ModelType.Service:
                {
                    //TODO:*****更新服务模型代理类
                    // if (!this._document.ParsedDocument.HasErrors)
                    // {
                    //     TypeSystemService.UpdateServiceProxyDocument(this.TargetNode.RoslynDocumentId,
                    //                                              this.TargetNode.SyncProxyDocumentId,
                    //                                              this.TargetNode.AsyncProxyDocumentId,
                    //                                              this.TargetModel);
                    // }

                    //保存初始化或更改过的代码
                    string sourceCode;
                    if (modelInfos != null && modelInfos.Length == 1)
                    {
                        sourceCode = (string)modelInfos[0];
                    }
                    else
                    {
                        var doc        = DesignTree.DesignHub.TypeSystem.Workspace.CurrentSolution.GetDocument(RoslynDocumentId);
                        var sourceText = await doc.GetTextAsync();

                        sourceCode = sourceText.ToString();
                    }

                    await StagedService.SaveServiceCodeAsync(Model.Id, sourceCode);
                }
                break;

                case ModelType.View:
                {
                    if (modelInfos != null)
                    {
                        await StagedService.SaveViewCodeAsync(Model.Id, (string)modelInfos[0], (string)modelInfos[1], (string)modelInfos[2]);

                        await StagedService.SaveViewRuntimeCodeAsync(Model.Id, (string)modelInfos[3]);
                    }
                }
                break;

                case ModelType.Report:
                    await StagedService.SaveReportCodeAsync(Model.Id, (string)modelInfos[0]);

                    break;
                }

                //注意:不在此更新RoslynDocument, 实体模型通过设计命令更新,服务模型通过前端代码编辑器实时更新
            }

            //保存节点模型
            await StagedService.SaveModelAsync(Model);
        }