示例#1
0
 /// <summary>
 /// 在UI上显示数据对象
 /// </summary>
 private void ShowDataObjectInUI(DetailTextInfo obj)
 {
     if (obj != null)
     {
         richTextBox1.Rtf = obj.RTFText;
     }
 }
        public static DetailTextInfo changeToDetailTextInfo(DetailTextDB dbobj)
        {
            if (dbobj == null)
            {
                return null;
            }
            DetailTextInfo obj = new DetailTextInfo()
            {
                Text = String.IsNullOrEmpty(dbobj.Text)?"":dbobj.Text,
                RTFText = dbobj.RTFText==null?"":Encoding.UTF8.GetString(dbobj.RTFText),
                Path = dbobj.Path,
                ModifyTime = dbobj.ModifyTime,
                ID = dbobj.ID

            };
            return obj;
        }
示例#3
0
        public static DetailTextInfo changeToDetailTextInfo(DetailTextDB dbobj)
        {
            if (dbobj == null)
            {
                return(null);
            }
            DetailTextInfo obj = new DetailTextInfo()
            {
                Text       = String.IsNullOrEmpty(dbobj.Text)?"":dbobj.Text,
                RTFText    = dbobj.RTFText == null?"":Encoding.UTF8.GetString(dbobj.RTFText),
                Path       = dbobj.Path,
                ModifyTime = dbobj.ModifyTime,
                ID         = dbobj.ID
            };

            return(obj);
        }
示例#4
0
        /// <summary>
        /// 根据节点路径提取节点数据,如果未找到,返回null
        /// </summary>
        /// <param name="nodePath"></param>
        /// <returns></returns>
        public IDataInfo GetDataInfoObjectByPath(string nodePath)
        {
            if (String.IsNullOrEmpty(nodePath))
            {
                return(null);
            }
            DetailTextDB dbobj = repository.GetDataInfoObjectByPath(nodePath);

            if (dbobj == null)
            {
                return(null);
            }
            DetailTextInfo infoObj = DetailTextHelper.changeToDetailTextInfo(dbobj);

            //设置数据己装入标记
            infoObj.HasBeenLoadFromStorage = true;
            return(infoObj);
        }
        public static DetailTextDB changeToDetailTextDB(DetailTextInfo 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);
            }

            DetailTextDB dbObj = new DetailTextDB()
            {
                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;
        }
示例#6
0
        public static DetailTextDB changeToDetailTextDB(DetailTextInfo 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);
            }

            DetailTextDB dbObj = new DetailTextDB()
            {
                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);
        }
示例#7
0
        /// <summary>
        /// 将对象的当前值写入数据库
        /// </summary>
        /// <param name="dataInfoObject"></param>
        /// <returns></returns>
        public int UpdateDataInfoObject(IDataInfo dataInfoObject)
        {
            DetailTextInfo obj = dataInfoObject as DetailTextInfo;

            if (obj.Text.Length > DALConfig.MaxTextFieldSize)
            {
                obj.Text = obj.Text.Substring(0, DALConfig.MaxTextFieldSize);
            }
            if (dataInfoObject == null || obj == null)
            {
                return(0);
            }
            bool         isNew = false;
            DetailTextDB dbobj = repository.GetDataInfoObjectByPath(obj.Path);

            if (dbobj == null)
            {
                dbobj = new DetailTextDB();
                isNew = true;
            }
            if (String.IsNullOrEmpty(dbobj.Text) == false && String.IsNullOrEmpty(obj.Text))
            {
                ShowWarningInfo(String.Format("更新节点{0}时,发现数据库记录中的Text字段不为空,但尝试写入一个空的字串,这有可能是个错误,特此提示。", obj.Path));
            }
            dbobj.ModifyTime = obj.ModifyTime;
            dbobj.Text       = obj.Text;
            dbobj.Path       = obj.Path;
            dbobj.RTFText    = (String.IsNullOrEmpty(obj.RTFText))?null:Encoding.UTF8.GetBytes(obj.RTFText);
            if (isNew)
            {
                return(repository.Create(dbobj));
            }
            else
            {
                return(repository.Update(dbobj));
            }
        }
示例#8
0
        /// <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;
        }
 /// <summary>
 /// 在UI上显示数据对象
 /// </summary>
 private void ShowDataObjectInUI(DetailTextInfo obj)
 {
     if (obj != null)
     {
         richTextBox1.Rtf = obj.RTFText;
     }
 }