Esempio n. 1
0
        /// <summary>
        /// 更新附件資料
        /// </summary>
        protected override bool UpdateData(string mdfAccount)
        {
            ArticlePictureParams param = new ArticlePictureParams()
            {
                PicId         = attId,
                FileSavedName = fileSavedName,
                FileSize      = fileSize,
                SortNo        = sortNo,
                FileMIME      = fileMIME,
                PostAccount   = postAccount
            };

            ArticlePublisherLogic artPub = new ArticlePublisherLogic(null);
            bool result = artPub.UpdateArticlePictureData(param);

            if (result)
            {
                //zh-TW
                if (result && LangManager.IsEnableEditLangZHTW())
                {
                    ArticlePictureMultiLangParams paramZhTw = new ArticlePictureMultiLangParams()
                    {
                        PicId        = attId,
                        CultureName  = LangManager.CultureNameZHTW,
                        PicSubject   = attSubjectZhTw,
                        IsShowInLang = isShowInLangZhTw,
                        PostAccount  = postAccount
                    };

                    result = artPub.UpdateArticlePictureMultiLangData(paramZhTw);
                }

                //en
                if (result && LangManager.IsEnableEditLangEN())
                {
                    ArticlePictureMultiLangParams paramEn = new ArticlePictureMultiLangParams()
                    {
                        PicId        = attId,
                        CultureName  = LangManager.CultureNameEN,
                        PicSubject   = attSubjectEn,
                        IsShowInLang = isShowInLangEn,
                        PostAccount  = postAccount
                    };

                    result = artPub.UpdateArticlePictureMultiLangData(paramEn);
                }

                if (!result)
                {
                    errState = AttFileErrState.UpdateMultiLangDataFailed;
                }
            }
            else
            {
                errState = AttFileErrState.UpdateDataFailed;
            }

            return(result);
        }
Esempio n. 2
0
        protected override bool LoadData()
        {
            bool result = false;

            if (attId != Guid.Empty)
            {
                ArticlePublisherLogic artPub = new ArticlePublisherLogic(null);
                ArticlePicture        pic    = artPub.GetArticlePictureDataForBackend(attId);

                if (pic == null)
                {
                    errState = AttFileErrState.LoadDataFailed;
                    return(false);
                }

                contextId     = pic.ArticleId;
                filePath      = GetDirectoryName();
                fileSavedName = pic.FileSavedName;
                fileSize      = pic.FileSize;
                sortNo        = pic.SortNo.Value;
                fileMIME      = pic.FileMIME;
                fileFullName  = string.Format("{0}{1}/{2}", GetAttRootDirectoryFullName(), filePath, fileSavedName);
                postAccount   = pic.PostAccount;
                postDate      = pic.PostDate.Value;

                if (pic.MdfDate.HasValue)
                {
                    mdfAccount = pic.MdfAccount;
                    mdfDate    = pic.MdfDate.Value;
                }

                //zh-TW
                if (LangManager.IsEnableEditLangZHTW())
                {
                    ArticlePictureMultiLang picZhTw = artPub.GetArticlePictureMultiLangDataForBackend(attId, LangManager.CultureNameZHTW);

                    if (picZhTw == null)
                    {
                        errState = AttFileErrState.LoadMultiLangDataFailed;
                        return(false);
                    }

                    attSubjectZhTw   = picZhTw.PicSubject;
                    isShowInLangZhTw = picZhTw.IsShowInLang;

                    if (picZhTw.MdfDate.HasValue)
                    {
                        DateTime mdfDateZhTw = picZhTw.MdfDate.Value;

                        if (!mdfDate.HasValue || mdfDateZhTw > mdfDate.Value)
                        {
                            mdfAccount = picZhTw.MdfAccount;
                            mdfDate    = mdfDateZhTw;
                        }
                    }
                }

                //en
                if (LangManager.IsEnableEditLangEN())
                {
                    ArticlePictureMultiLang picEn = artPub.GetArticlePictureMultiLangDataForBackend(attId, LangManager.CultureNameEN);

                    if (picEn == null)
                    {
                        errState = AttFileErrState.LoadMultiLangDataFailed;
                        return(false);
                    }

                    attSubjectEn   = picEn.PicSubject;
                    isShowInLangEn = picEn.IsShowInLang;

                    if (picEn.MdfDate.HasValue)
                    {
                        DateTime mdfDateEn = picEn.MdfDate.Value;

                        if (!mdfDate.HasValue || mdfDateEn > mdfDate.Value)
                        {
                            mdfAccount = picEn.MdfAccount;
                            mdfDate    = mdfDateEn;
                        }
                    }
                }

                result = true;
            }
            else if (contextId != null)
            {
                // new one
                sortNo = GetNextSortNo();

                result = true;
            }

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 新增附件資料
        /// </summary>
        protected virtual bool InsertData(string postAccount)
        {
            Guid newAttId = Guid.NewGuid();

            AttachFileParams param = new AttachFileParams()
            {
                AttId         = newAttId,
                ArticleId     = contextId.Value,
                FilePath      = filePath,
                FileSavedName = fileSavedName,
                FileSize      = fileSize,
                SortNo        = sortNo,
                FileMIME      = fileMIME,
                DontDelete    = dontDelete,
                PostAccount   = postAccount
            };

            ArticlePublisherLogic artPub = new ArticlePublisherLogic(null);
            bool result = artPub.InsertAttachFileData(param);

            if (result)
            {
                attId = newAttId;

                //zh-TW
                if (result && LangManager.IsEnableEditLangZHTW())
                {
                    AttachFileMultiLangParams paramZhTw = new AttachFileMultiLangParams()
                    {
                        AttId        = attId,
                        CultureName  = LangManager.CultureNameZHTW,
                        AttSubject   = attSubjectZhTw,
                        IsShowInLang = isShowInLangZhTw,
                        PostAccount  = postAccount
                    };

                    result = artPub.InsertAttachFileMultiLangData(paramZhTw);
                }

                //en
                if (result && LangManager.IsEnableEditLangEN())
                {
                    AttachFileMultiLangParams paramEn = new AttachFileMultiLangParams()
                    {
                        AttId        = attId,
                        CultureName  = LangManager.CultureNameEN,
                        AttSubject   = attSubjectEn,
                        IsShowInLang = isShowInLangEn,
                        PostAccount  = postAccount
                    };

                    result = artPub.InsertAttachFileMultiLangData(paramEn);
                }

                if (!result)
                {
                    errState = AttFileErrState.InsertMultiLangDataFailed;
                }
            }
            else
            {
                errState = AttFileErrState.InsertDataFailed;
            }

            return(result);
        }