/// <summary> /// 转换为FolderInfo,不理会附属文件集合 /// </summary> /// <param name="dbobj"></param> /// <returns></returns> public static FolderInfo changeToFolderInfo(FolderDB dbobj) { if (dbobj == null) { return null; } FolderInfo obj = new FolderInfo() { Text = String.IsNullOrEmpty(dbobj.Text) ? "" : dbobj.Text, RTFText = dbobj.RTFText == null ? "" : Encoding.UTF8.GetString(dbobj.RTFText), Path = dbobj.Path, ModifyTime = dbobj.ModifyTime.Value, ID = dbobj.ID }; return obj; }
/// <summary> /// 转换为FolderDB对象,不理会附属文件集合 /// </summary> /// <param name="obj"></param> /// <returns></returns> public static FolderDB changeToFolderDB(FolderInfo obj) { if (obj == null) { return null; } //注意数据库中nvarchar最大允许4000个字符 if (obj.Text != null && obj.Text.Length > DALConfig.MaxTextFieldSize) { obj.Text = obj.Text.Substring(0, DALConfig.MaxTextFieldSize); } FolderDB dbObj = new FolderDB() { ModifyTime = obj.ModifyTime, Path = obj.Path, RTFText = String.IsNullOrEmpty(obj.RTFText) ? null : Encoding.UTF8.GetBytes(obj.RTFText), Text = String.IsNullOrEmpty(obj.Text) ? "" : obj.Text, ID = obj.ID }; return dbObj; }
/// <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; }
private void ShowDataObjectInUI(FolderInfo obj) { if (obj != null) { richTextBox1.Rtf = obj.RTFText; dgFiles.ItemsSource = obj.AttachFiles; } }