示例#1
0
        public int UpdateDataInfoObject(IDataInfo dataInfoObject)
        {
            LabelNodeDataInfo obj = dataInfoObject as LabelNodeDataInfo;

            if (String.IsNullOrEmpty(obj.Text) == false && obj.Text.Length > DALConfig.MaxTextFieldSize)
            {
                obj.Text = obj.Text.Substring(0, DALConfig.MaxTextFieldSize);
            }
            if (dataInfoObject == null || obj == null)
            {
                return(0);
            }
            bool        isNew = false;
            LabelNodeDB dbobj = repository.GetLabelNodeDBWithoutInfoNodeDBsByPath(obj.Path);

            if (dbobj == null)
            {
                dbobj = new LabelNodeDB();
                isNew = true;
            }
            dbobj.ModifyTime = obj.ModifyTime;
            dbobj.Label      = obj.Text;
            dbobj.Path       = obj.Path;
            // dbobj.RTFText = (String.IsNullOrEmpty(obj.RTFText)) ? null : Encoding.UTF8.GetBytes(obj.RTFText);
            if (isNew)
            {
                return(repository.AddLabelNodeDB(dbobj));
            }
            else
            {
                return(repository.UpdateLabelNodeDB(dbobj));
            }
        }
示例#2
0
 private void ShowDataObjectInUI(LabelNodeDataInfo obj)
 {
     if (obj != null)
     {
         dgFiles.ItemsSource = obj.AttachInfoNodeInfos;
     }
 }
示例#3
0
        public IDataInfo GetDataInfoObjectByPath(string nodePath)
        {
            LabelNodeDB dbobj = repository.GetLabelNodeDBWithoutInfoNodeDBsByPath(nodePath);
            ObservableCollection <DBInfoNodeInfo> infos = repository.GetDBInfoNodeInfosOfLabelNodeDB(nodePath);


            LabelNodeDataInfo nodeInfo = LabelNodeHelper.changeToLabelNodeDataInfo(dbobj);

            if (nodeInfo != null)
            {
                nodeInfo.AttachInfoNodeInfos = infos;
            }

            return(nodeInfo);
        }
示例#4
0
        /// <summary>
        /// 转换为LabelNodeDataInfo,不理会附属文件集合
        /// </summary>
        /// <param name="dbobj"></param>
        /// <returns></returns>
        public static LabelNodeDataInfo changeToLabelNodeDataInfo(LabelNodeDB dbobj)
        {
            if (dbobj == null)
            {
                return(null);
            }
            LabelNodeDataInfo obj = new LabelNodeDataInfo()
            {
                Text = String.IsNullOrEmpty(dbobj.Label) ? "" : dbobj.Label,
                //  RTFText = dbobj.RTFText == null ? "" : Encoding.UTF8.GetString(dbobj.RTFText),
                Path       = dbobj.Path,
                ModifyTime = dbobj.ModifyTime.Value,
                ID         = dbobj.ID
            };

            return(obj);
        }
示例#5
0
        /// <summary>
        /// 转换为LabelNode对象,不理会附属文件集合
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static LabelNodeDB changeToLabelNodeDB(LabelNodeDataInfo 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);
            }

            LabelNodeDB dbObj = new LabelNodeDB()
            {
                ModifyTime = obj.ModifyTime,
                Path       = obj.Path,
                //RTFText = String.IsNullOrEmpty(obj.RTFText) ? null : Encoding.UTF8.GetBytes(obj.RTFText),
                Label = String.IsNullOrEmpty(obj.Text) ? "" : obj.Text,
                ID    = obj.ID
            };

            return(dbObj);
        }