Пример #1
0
        public int UpdateDataInfoObject(IDataInfo dataInfoObject)
        {
            FolderInfo obj = dataInfoObject as FolderInfo;

            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;
            FolderDB dbobj = repository.GetFolderDBWithoutFileInfosByPath(obj.Path);

            if (dbobj == null)
            {
                dbobj = new FolderDB();
                isNew = true;
            }
            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.AddFolderDB(dbobj));
            }
            else
            {
                return(repository.UpdateFolderDB(dbobj));
            }
        }