public InterfaceLibrary.NodeDataObject ChangeTo(InterfaceLibrary.NodeDataObject sourceObject, String EFConnectionString) { FolderInfo folderInfo = sourceObject.DataItem as FolderInfo; NodeDataObject dataObject = NodeFactory.CreateDataInfoNode("DetailText", EFConnectionString); DetailTextInfo detailInfo = dataObject.DataItem as DetailTextInfo; detailInfo.Path = sourceObject.DataItem.Path; detailInfo.Text = folderInfo.Text; detailInfo.RTFText = folderInfo.RTFText; //在数据库中删除记录 sourceObject.AccessObject.DeleteDataInfoObject(folderInfo); //在数据库中创建对象 dataObject.AccessObject.Create(detailInfo); return(dataObject); }
/// <summary> /// 依据节点类型创建"空白"的数据信息对象,其HasBeenLoadFromStorage属性为false /// (无需数据存储的节点,如OnlyText例此,其HasBeenLoadFromStorage始终为true) /// </summary> /// <param name="NodeType"></param> /// <returns></returns> public static NodeDataObject CreateDataInfoNode(String NodeType, String EFConnectionString) { NodeDataObject nodeDataObject = new NodeDataObject(); if (NodeType == "OnlyText") { nodeDataObject.DataItem = new OnlyTextInfo() { MainWindow = _mainWindow }; nodeDataObject.AccessObject = null; } if (NodeType == "Folder") { FolderInfo info = new FolderInfo() { MainWindow = _mainWindow }; FolderAccess access = new FolderAccess(EFConnectionString); info.SetRootControlDataAccessObj(access); nodeDataObject.DataItem = info; //设置数据未装入标记 nodeDataObject.DataItem.HasBeenLoadFromStorage = false; nodeDataObject.AccessObject = access; } if (NodeType == "DetailText") { DetailTextInfo info = new DetailTextInfo() { MainWindow = _mainWindow }; DetailTextAccess accessObj = new DetailTextAccess(EFConnectionString); info.SetRootControlDataAccessObj(accessObj); nodeDataObject.DataItem = info; //设置数据未装入标记 nodeDataObject.DataItem.HasBeenLoadFromStorage = false; nodeDataObject.AccessObject = accessObj; } return(nodeDataObject); }