示例#1
0
        internal BusinessObjectActionReport <DataRepositoryActionStatus> Update(CMSContent cmsContent, string[] tags, bool doReindex)
        {
            BusinessObjectActionReport <DataRepositoryActionStatus> businessObjectActionReport = new BusinessObjectActionReport <DataRepositoryActionStatus>(DataRepositoryActionStatus.Success);

            businessObjectActionReport.ValidationResult = BusinessObjectManager.Validate(cmsContent);
            if (businessObjectActionReport.ValidationResult.IsValid)
            {
                int num = 0;
                try
                {
                    using (IDataStoreContext dataStoreContext = this._DataStore.CreateContext())
                    {
                        num = dataStoreContext.cms_Contents_Update(
                            cmsContent.CMSContentId
                            , cmsContent.CMSThreadId
                            , cmsContent.CMSParentContentId
                            , cmsContent.AuthorUserId
                            , cmsContent.CMSContentLevel
                            , cmsContent.Subject
                            , cmsContent.FormattedBody
                            , cmsContent.IsApproved
                            , cmsContent.IsLocked
                            , cmsContent.CMSContentType
                            , cmsContent.CMSContentStatus
                            , cmsContent.CMSExtraInfo
                            , cmsContent.CMSBaseContentId
                            , cmsContent.UrlFriendlyName
                            , tags);
                    }
                }
                catch (Exception ex)
                {
                    _Log.Error("Error at cms_Contents_Update", ex);
                    throw new DataStoreException(ex, true);
                }
                if (num != 0)
                {
                    businessObjectActionReport.Status = DataRepositoryActionStatus.SqlError;
                    _Log.ErrorFormat("CMSContent {0} was not updated from the database (ErrorCode: {1})."
                                     , DebugUtility.GetObjectString(cmsContent)
                                     , num);
                }
            }
            else
            {
                businessObjectActionReport.Status = DataRepositoryActionStatus.ValidationFailed;
                _Log.WarnFormat("CMSContent {0} was not updated at the database because the validation failed.\nReport: {1}"
                                , DebugUtility.GetObjectString(cmsContent)
                                , businessObjectActionReport.ValidationResult.ToString(TextFormat.ASCII));
            }
            return(businessObjectActionReport);
        }