Esempio n. 1
0
        private static List <SearchResultModel> CreateResultItems(DataTable datas)
        {
            List <SearchResultModel> items = new List <SearchResultModel>();

            foreach (DataRow dr in datas.Rows)
            {
                string img       = dr["Image"].ToString().Trim();
                string imageJSON = dr["Icon"].ToString().Trim();
                if (imageJSON != string.Empty)
                {
                    ResourceImagesModels imgItem = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(imageJSON);
                    if (!string.IsNullOrWhiteSpace(imgItem.Img))
                    {
                        img = imgItem.Img;
                    }
                }

                items.Add(new SearchResultModel {
                    MenuID  = (long)dr["MenuID"],
                    CardNo  = (long)dr["CardNo"],
                    Title   = dr["Title"].ToString().Trim(),
                    Summary = dr["Summary"].ToString(),
                    Image   = img
                });
            }

            return(items);
        }
Esempio n. 2
0
        public ActionResult PosterSelect(long siteId, long menuId, long articleId)
        {
            ViewBag.SiteID = siteId;
            ViewBag.MenuID = menuId;

            IEnumerable <ArticlePosterModels> items = ArticlePosterDAO.GetIssueItems(menuId);
            string uploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId).TrimEnd('/') + "/";

            foreach (ArticlePosterModels p in items)
            {
                if (!string.IsNullOrWhiteSpace(p.Photo))
                {
                    ResourceImagesModels photo = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(p.Photo);
                    if (photo.Img != string.Empty)
                    {
                        p.Photo = uploadUrl + photo.Img;
                    }
                }
            }

            IEnumerable <long> curPosterIds = ArticleDAO.GetItemPosters(articleId).Select(p => p.ID);

            if (curPosterIds == null)
            {
                curPosterIds = new List <long>();
            }
            ViewBag.Posters = curPosterIds;

            ViewBag.Int64Converter = new WorkV3.Golbal.Int64Converter();
            return(View(items));
        }
Esempio n. 3
0
        public static void SetItem(ResourceImagesModels item)
        {
            SQLData.Database    db       = new SQLData.Database(WebInfo.Conn);
            SQLData.TableObject tableObj = db.GetTableObject("ResourceImages");
            tableObj.GetDataFromObject(item);

            string sql   = "Select 1 From ResourceImages Where ID = " + item.ID;
            bool   isNew = db.GetFirstValue(sql) == null;

            if (isNew)
            {
                tableObj.Insert();
            }
            else
            {
                string[] removeFields = { "ID", "SiteID", "SourceNo", "SourceType", "Ver", "AreaID", "Creator", "CreateTime" };
                foreach (string f in removeFields)
                {
                    tableObj.Remove(f);
                }

                SQLData.ParameterCollection keys = new SQLData.ParameterCollection();
                keys.Add("@ID", item.ID);
                keys.Add("@SiteID", item.SiteID);
                keys.Add("@SourceNo", item.SourceNo);
                keys.Add("@SourceType", item.SourceType);
                keys.Add("@Ver", item.Ver);
                keys.Add("@AreaID", item.AreaID);

                tableObj.Update(keys);
            }
        }
Esempio n. 4
0
        public ActionResult Edit(long siteId, long menuId, ArticleIntroModels item, IEnumerable <ParagraphModels> paragraphs, string deletedParagraphs)
        {
            if (!string.IsNullOrWhiteSpace(item.Icon))
            {
                ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(item.Icon);
                if (imgModel.ID == 0)   // 新上傳的圖片
                {
                    HttpPostedFileBase postedFile         = Request.Files["fIcon"];
                    string             fIconBase64        = Request.Form["fIconBase64"];
                    string             fIconBase64_Resize = Request.Form["fIconBase64_Resize"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        item.Icon = string.Empty;
                    }
                    else
                    {
                        string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesByMenuID(postedFile, siteId, menuId, fIconBase64, fIconBase64_Resize);
                        imgModel.ID  = 1;
                        imgModel.Img = saveName;

                        item.Icon = Newtonsoft.Json.JsonConvert.SerializeObject(imgModel);
                    }
                }
            }

            item.MenuID     = menuId;
            item.Creator    = MemberDAO.SysCurrent.Id;
            item.CreateTime = DateTime.Now;
            item.Modifier   = item.Creator;
            item.ModifyTime = item.CreateTime;

            ArticleIntroDAO.SetItem(item);

            if (paragraphs?.Count() > 0)
            {
                for (int i = 0, len = paragraphs.Count(); i < len; ++i)
                {
                    ParagraphModels p = paragraphs.ElementAt(i);
                    p.Sort     = (byte)i;
                    p.SourceNo = item.ID;
                    ParagraphDAO.SetItem(p);
                }
            }

            if (!string.IsNullOrWhiteSpace(deletedParagraphs))
            {
                IEnumerable <long> delParagraphIds = deletedParagraphs.Split(',').Select(p => long.Parse(p));
                ParagraphDAO.Delete(delParagraphIds);
            }

            ViewBag.SiteID    = siteId;
            ViewBag.MenuID    = menuId;
            ViewBag.Success   = true;
            ViewBag.DateFmt   = WebInfo.DateFmt; // View 中,WebInfo 會出現命名衝突
            ViewBag.UploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId);

            return(View(item));
        }
        void AdsCustomizeEditSaveImage(long siteId, long menuId, AdsCustomizeModel item)
        {
            if (!string.IsNullOrWhiteSpace(item.PCPicture))
            {
                ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(item.PCPicture);
                if (imgModel.ID == 0)
                {
                    // 新上傳的圖片
                    HttpPostedFileBase postedFile              = Request.Files["fPCPicture"];
                    string             postedFileBase64        = Request.Form["fPCPictureBase64"];
                    string             postedFileBase64_Resize = Request.Form["fPCPictureBase64_Resize"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        item.PCPicture = string.Empty;
                    }
                    else
                    {
                        string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesByMenuID(postedFile, siteId, menuId, postedFileBase64, postedFileBase64_Resize);
                        imgModel.ID  = 1;
                        imgModel.Img = saveName;

                        item.PCPicture = Newtonsoft.Json.JsonConvert.SerializeObject(imgModel);
                    }
                }
            }
            if (!string.IsNullOrWhiteSpace(item.MobilePicture))
            {
                ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(item.MobilePicture);
                if (imgModel.ID == 0)
                {
                    // 新上傳的圖片
                    HttpPostedFileBase postedFile              = Request.Files["fMobilePicture"];
                    string             postedFileBase64        = Request.Form["fMobilePictureBase64"];
                    string             postedFileBase64_Resize = Request.Form["fMobilePictureBase64_Resize"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        item.MobilePicture = string.Empty;
                    }
                    else
                    {
                        string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesByMenuID(postedFile, siteId, menuId, postedFileBase64, postedFileBase64_Resize);
                        imgModel.ID  = 1;
                        imgModel.Img = saveName;

                        item.MobilePicture = Newtonsoft.Json.JsonConvert.SerializeObject(imgModel);
                    }
                }
            }
        }
Esempio n. 6
0
        public ActionResult Edit(long siteId, long menuId, FormModel item, string fields, string admins)
        {
            if (!string.IsNullOrWhiteSpace(item.Image))
            {
                ResourceImagesModels imgModel = JsonConvert.DeserializeObject <ResourceImagesModels>(item.Image);
                if (imgModel.ID == 0)   // 新上傳的圖片
                {
                    HttpPostedFileBase postedFile = Request.Files["fImage"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        item.Image = string.Empty;
                    }
                    else
                    {
                        item.Image = Golbal.UpdFileInfo.SaveFilesBySiteID(postedFile, siteId, formDesignFileDir);
                    }
                }
                else
                {
                    item.Image = imgModel.Img;
                }
            }

            item.SourceID = menuId;
            item.SiteID   = siteId;
            FormDAO.SetItem(item);

            FieldDesignItem[] fieldList = null;
            if (!string.IsNullOrWhiteSpace(fields))
            {
                fieldList = JsonConvert.DeserializeObject <FieldDesignItem[]>(fields);
            }
            item.SetFields(fieldList);

            FormAdmin[] adminList = null;
            if (!string.IsNullOrWhiteSpace(admins))
            {
                adminList = JsonConvert.DeserializeObject <FormAdmin[]>(admins);
            }
            item.SetAdmins(adminList);

            ViewBag.UploadUrl    = Golbal.UpdFileInfo.GetVPathBySiteID(siteId, formDesignFileDir).TrimEnd('/');
            ViewBag.SiteID       = siteId;
            ViewBag.MenuID       = menuId;
            ViewBag.SitePage     = FormDAO.GetFormPage(item.ID);
            ViewBag.Int64Convert = new WorkV3.Golbal.Int64Converter();
            ViewBag.Exit         = true;
            return(View(item));
        }
Esempio n. 7
0
        private void SaveIconAndArchive(long siteId, long menuId, ArticleModels item)
        {
            if (!string.IsNullOrWhiteSpace(item.Icon))
            {
                ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(item.Icon);
                if (imgModel.ID == 0)   // 新上傳的圖片
                {
                    HttpPostedFileBase postedFile              = Request.Files["fIcon"];
                    string             postedFileBase64        = Request.Form["fIconBase64"];
                    string             postedFileBase64_Resize = Request.Form["fIconBase64_Resize"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        item.Icon = string.Empty;
                    }
                    else
                    {
                        string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesByMenuID(postedFile, siteId, menuId, postedFileBase64, postedFileBase64_Resize);
                        imgModel.ID  = 1;
                        imgModel.Img = saveName;

                        item.Icon = Newtonsoft.Json.JsonConvert.SerializeObject(imgModel);
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(item.Archive))
            {
                ResourceFilesModels archiveModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceFilesModels>(item.Archive);
                if (archiveModel.Id == 0)
                {
                    HttpPostedFileBase postedFile = Request.Files["fArchive"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        item.Icon = string.Empty;
                    }
                    else
                    {
                        string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesByMenuID(postedFile, siteId, menuId);
                        archiveModel.Id       = 1;
                        archiveModel.FileInfo = saveName;
                        archiveModel.FileSize = postedFile.ContentLength;

                        item.Archive = Newtonsoft.Json.JsonConvert.SerializeObject(archiveModel);
                    }
                }
            }
        }
Esempio n. 8
0
        private IEnumerable <ArticlePosterModels> GetPoster(ArticleModels item, string posters)
        {
            if (posters == null || posters.Count() == 0)
            {
                return(new ArticlePosterModels[] { });
            }

            IEnumerable <ArticlePosterModels> articlePosters = ArticleDAO.GetItemPosters(item.ID);

            foreach (ArticlePosterModels p in articlePosters)
            {
                if (!string.IsNullOrWhiteSpace(p.Photo))
                {
                    ResourceImagesModels photo = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(p.Photo);
                    if (photo.Img != string.Empty)
                    {
                        p.Photo = photo.Img;
                    }
                }
            }
            return(articlePosters);
        }
Esempio n. 9
0
        public ActionResult PosterEdit(long siteId, long menuId, ArticlePosterModels item)
        {
            if (!Utility.CheckIsLogin())
            {
                Response.Redirect(Url.Action("Login", "Home"));
            }
            ViewBag.SiteID    = siteId;
            ViewBag.MenuID    = menuId;
            ViewBag.UploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId);
            ViewBag.Exit      = true;

            if (!string.IsNullOrWhiteSpace(item.Photo))
            {
                ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(item.Photo);
                if (imgModel.ID == 0)   // 新上傳的圖片
                {
                    HttpPostedFileBase postedFile          = Request.Files["fPhoto"];
                    string             fPhotoBase64        = Request.Form["fPhotoBase64"];
                    string             fPhotoBase64_Resize = Request.Form["fPhotoBase64_Resize"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        item.Photo = string.Empty;
                    }
                    else
                    {
                        string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesByMenuID(postedFile, siteId, menuId, fPhotoBase64, fPhotoBase64_Resize);
                        imgModel.ID  = 1;
                        imgModel.Img = saveName;

                        item.Photo = Newtonsoft.Json.JsonConvert.SerializeObject(imgModel);
                    }
                }
            }

            ArticlePosterDAO.SetItem(item);

            return(View(item));
        }
Esempio n. 10
0
        public static void CopyIcon(string sourceIcon, long sourceSiteID, long sourceMenuID, long targetSiteID, long targetMenuID)
        {
            if (string.IsNullOrEmpty(sourceIcon))
            {
                return;
            }
            ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(sourceIcon);
            string sourceFolder           = WorkV3.Golbal.UpdFileInfo.GetUPathByMenuID(sourceSiteID, sourceMenuID);
            string targetFolder           = WorkV3.Golbal.UpdFileInfo.GetUPathByMenuID(targetSiteID, targetMenuID);

            if (sourceFolder == targetFolder)
            {
                return;
            }
            if (!System.IO.Directory.Exists(targetFolder))
            {
                System.IO.Directory.CreateDirectory(targetFolder);
            }
            if (System.IO.File.Exists(sourceFolder + "\\" + imgModel.Img))
            {
                System.IO.File.Copy(sourceFolder + "\\" + imgModel.Img, targetFolder + "\\" + imgModel.Img, true);
            }
        }
Esempio n. 11
0
        public ActionResult Setting(long cardNo, ArticleSetModels item)
        {
            SitePage page = CardsDAO.GetPage(cardNo);

            SettingInit(cardNo, page);

            if (item.SortMode == "隨機排序")
            {
                item.SortField = "NewID()";
            }

            if (!string.IsNullOrWhiteSpace(item.DefaultImg))
            {
                ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(item.DefaultImg);
                if (imgModel.ID == 0)   // 新上傳的圖片
                {
                    HttpPostedFileBase postedFile = Request.Files["fDefaultImg"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        item.DefaultImg = string.Empty;
                    }
                    else
                    {
                        string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesByMenuID(postedFile, page.SiteID, page.MenuID);
                        imgModel.ID  = 1;
                        imgModel.Img = saveName;

                        item.DefaultImg = Newtonsoft.Json.JsonConvert.SerializeObject(imgModel);
                    }
                }
            }

            ArticleSetDAO.SetItem(item);

            ViewBag.Success = true;
            return(View(item));
        }
Esempio n. 12
0
        public ActionResult Setting(long siteId, WorkV3.Models.ArticleSettingModels item, string[] ExtendReadMenus, string[] ExtendReadMenus2, string[] ReadModeSet)
        {
            long menuId = item.MenuID;

            ViewBag.Menu  = MenusDAO.GetInfo(siteId, menuId);
            ViewBag.Types = ArticleTypesDAO.GetIssueItems(menuId);
            //ViewBag.ListCards = WorkV3.Models.DataAccess.MenusDAO.GetListCards("Article").Where(c => c.ID != menuId);
            ViewBag.ListCards    = WorkV3.Models.DataAccess.MenusDAO.GetListCards("Article"); // shan 20180102 依 CC 要求修改為本單元亦列入, 且預設勾選
            ViewBag.ListCards2   = WorkV3.Models.DataAccess.MenusDAO.GetListCards("Article"); // shan 20180102 依 CC 要求修改為本單元亦列入, 且預設勾選
            ViewBag.ListIdentity = CategoryDAO.GetIssueItems(IdentityType);

            ViewBag.SiteID    = siteId;
            ViewBag.MenuID    = menuId;
            ViewBag.UploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId).TrimEnd('/');

            ViewBag.MemberRegSet = MemberShipRegSetDAO.GetItem(siteId);

            List <WorkV3.ViewModels.CommentType> ReplyItemList = WorkV3.ViewModels.CommentTypeLibs.GetCommitTypeList();

            ViewBag.ReplyItemList = ReplyItemList;

            if (item.SortMode == "隨機排序")
            {
                item.SortField = "NewID()";
            }
            if (ExtendReadMenus != null)
            {
                string eMenus = "";
                foreach (string ExtendReadMenu in ExtendReadMenus)
                {
                    if (!string.IsNullOrEmpty(ExtendReadMenu))
                    {
                        eMenus += ExtendReadMenu + ",";
                    }
                }
                eMenus = eMenus.Trim(',');
                item.ExtendReadMenus = eMenus;
            }
            else
            {
                item.ExtendReadMenus = string.Empty;
            }
            if (ExtendReadMenus2 != null)
            {
                string eMenus = "";
                foreach (string ExtendReadMenu in ExtendReadMenus2)
                {
                    if (!string.IsNullOrEmpty(ExtendReadMenu))
                    {
                        eMenus += ExtendReadMenu + ",";
                    }
                }
                eMenus = eMenus.Trim(',');
                item.ExtendReadMenus2 = eMenus;
            }
            else
            {
                item.ExtendReadMenus2 = string.Empty;
            }

            if (ReadModeSet != null)
            {
                string readModeSetStr = "";
                foreach (string readModeSet in ReadModeSet)
                {
                    if (!string.IsNullOrEmpty(readModeSet))
                    {
                        readModeSetStr += readModeSet + ",";
                    }
                }
                readModeSetStr   = readModeSetStr.Trim(',');
                item.ReadModeSet = readModeSetStr;
            }
            else
            {
                item.ReadModeSet = string.Empty;
            }

            if (!string.IsNullOrWhiteSpace(item.DefaultImg))
            {
                ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(item.DefaultImg);
                if (imgModel.ID == 0)
                { // 新上傳的圖片
                    HttpPostedFileBase postedFile               = Request.Files["fDefaultImg"];
                    string             fDefaultImgBase64        = Request.Form["fDefaultImgBase64"];
                    string             fDefaultImgBase64_Resize = Request.Form["fDefaultImgBase64_Resize"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        item.DefaultImg = string.Empty;
                    }
                    else
                    {
                        string saveName = WorkV3.Golbal.UpdFileInfo.SaveFilesByMenuID(postedFile, siteId, menuId, fDefaultImgBase64, fDefaultImgBase64_Resize);
                        imgModel.ID  = 1;
                        imgModel.Img = saveName;

                        item.DefaultImg = Newtonsoft.Json.JsonConvert.SerializeObject(imgModel);
                    }
                }
            }

            WorkV3.Models.DataAccess.ArticleSettingDAO.SetItem(item);

            ViewBag.Success = true;
            return(View(item));
        }
Esempio n. 13
0
        /// <summary>
        /// 最新消息內頁, 需傳入Token
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public ApiResult <ArticlesDetailResult> Post([FromBody] ArticlesDetailRequest data)
        {
            ApiResult <ArticlesDetailResult> result = new ApiResult <ArticlesDetailResult>();

            try
            {
                ArticlesDetailResultCode rcode = ArticlesDetailResultCode.Success;
                if (string.IsNullOrEmpty(data.SiteSN))
                {
                    rcode          = ArticlesDetailResultCode.SiteNull;
                    result.Success = false;
                    result.Code    = (int)rcode;
                    result.Message = rcode.GetMessage();
                    return(result);
                }

                long SiteID = GetSiteID(data.SiteSN);
                if (SiteID <= 0)
                {
                    rcode          = ArticlesDetailResultCode.SiteNull;
                    result.Success = false;
                    result.Code    = (int)rcode;
                    result.Message = rcode.GetMessage();
                    return(result);
                }

                long   menuId     = CardsDAO.GetMenuID(data.CardNo);
                string uploadUrl  = Golbal.UpdFileInfo.GetVPathByMenuID(SiteID, menuId);
                string uploadPath = Golbal.UpdFileInfo.GetUPathByMenuID(SiteID, menuId).TrimEnd('\\');

                ArticleModels item = ArticleDAO.GetItemByCard(data.CardNo);

                #region 主影片
                MainVision mainVisionsItem = null;
                if (item.isShowVideo && item.VideoID != null)
                {
                    int    width = 0, height = 0;
                    string link = item.VideoID, shotUrl = item.VideoImg;

                    if (item.VideoType == "custom")
                    {
                        link = uploadUrl + item.VideoID;
                    }

                    string imgSource = "";
                    if (item.VideoImgIsCustom)
                    {
                        ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(item.VideoImg);
                        shotUrl = uploadUrl + imgModel.Img;

                        imgSource = $"{uploadPath}\\{imgModel.Img}";
                    }
                    else
                    {
                        imgSource = item.VideoImg;
                    }

                    GetImageWidthAndHeight(imgSource, out width, out height);

                    mainVisionsItem = new MainVision()
                    {
                        Type      = item.VideoType,
                        Link      = link,
                        ImgUrl    = shotUrl,
                        ImgWidth  = width,
                        ImgHeight = height
                    };
                }
                #endregion

                #region Paragraph
                List <ParagraphItem> paragraphList = new List <ParagraphItem>();
                if (item == null)
                {
                    rcode          = ArticlesDetailResultCode.ArticlesNull;
                    result.Success = false;
                    result.Code    = (int)rcode;
                    result.Message = rcode.GetMessage();
                    return(result);
                }
                else
                {
                    paragraphList = GetParagraphItem(item.ID, uploadUrl, uploadPath);
                }
                #endregion

                #region 文章類別
                IEnumerable <ArticleTypesModels> ItemTypes = ArticleDAO.GetItemTypes(item.ID);
                List <ArticleTypes> articleTypesItem       = new List <ArticleTypes>();
                foreach (var type in ItemTypes)
                {
                    articleTypesItem.Add(new ArticleTypes()
                    {
                        Name  = type.Name,
                        Color = GetColorCode(type.Color)
                    });
                }
                #endregion

                result.Content = new ArticlesDetailResult()
                {
                    Title         = item.Title,
                    IssueDate     = item.IssueDate?.ToString("yyyy.MM.dd"),
                    ArticleTypes  = articleTypesItem,
                    MainVision    = mainVisionsItem,
                    ParagraphList = paragraphList
                };

                result.Success = true;
                result.Code    = (int)rcode;
                result.Message = rcode.GetMessage();
                return(result);
            }
            catch (Exception ex)
            {
                result.Code    = (int)ResultCode.Exception;
                result.Success = false;
                result.Message = ex.ToString();
            }

            return(result);
        }
Esempio n. 14
0
        public ActionResult Edit(long siteId, long menuId, string type, long?id, long?templateId)
        {
            ViewBag.SiteID       = siteId;
            ViewBag.MenuID       = menuId;
            ViewBag.Types        = ArticleTypesDAO.GetIssueItems(menuId);
            ViewBag.Series       = ArticleSeriesDAO.GetIssueItems(menuId);
            ViewBag.Categories   = CategoryDAO.GetItems(FavorityType);
            ViewBag.Sites        = WorkV3.Models.DataAccess.SitesDAO.GetDatas();
            ViewBag.UploadUrl    = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(siteId, menuId);
            ViewBag.ListIdentity = CategoryDAO.GetIssueItems(IdentityType);

            int cardStyleID             = 1;
            List <CardsModels> cardItem = CardsDAO.GetPageData(siteId, menuId);

            foreach (var cards in cardItem)
            {
                if (cards.CardsType == "Article")
                {
                    cardStyleID = cards.StylesID;
                    break;
                }
            }

            ArticleModels item = null;

            if (id != null)
            {
                item = ArticleDAO.GetItem((long)id);
                SetLinkDetailViewBag(item.LinkDetail);
            }

            if (item == null && templateId != null)
            {
                MenusModels menu         = MenusDAO.GetInfo(siteId, menuId);
                long        newArticleId = WorkLib.GetItem.NewSN();
                long        cardNo       = WorkV3.Golbal.PubFunc.AddPage(siteId, menuId, menu.SN, "Article", "Content", true, CardStyleId: cardStyleID);
                ArticleDAO.Copy((long)templateId, newArticleId, cardNo, menuId, siteId, true);
                item                 = ArticleDAO.GetItem(newArticleId);
                item.VideoType       = "youtube";
                ViewBag.FromTemplate = true;
            }

            if (item == null)
            {
                item = new ArticleModels {
                    ID = WorkLib.GetItem.NewSN(), Type = type, IsIssue = true
                };
                ViewBag.ArticleTypes      = new long[] { };
                ViewBag.ArticleSeries     = new long[] { };
                ViewBag.ArticleCategories = new long[] { };
                ViewBag.ArticlePosters    = new ArticlePosterModels[] { };
            }
            else
            {
                ViewBag.ArticleTypes      = ArticleDAO.GetItemTypes(item.ID);
                ViewBag.ArticleSeries     = ArticleDAO.GetItemSeries(item.ID);
                ViewBag.ArticleCategories = ArticleDAO.GetItemCategories(item.ID);

                IEnumerable <ArticlePosterModels> posters = ArticleDAO.GetItemPosters(item.ID);
                foreach (ArticlePosterModels p in posters)
                {
                    if (!string.IsNullOrWhiteSpace(p.Photo))
                    {
                        ResourceImagesModels photo = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(p.Photo);
                        if (photo.Img != string.Empty)
                        {
                            p.Photo = photo.Img;
                        }
                    }
                }
                ViewBag.ArticlePosters = posters;
            }
            ViewBag.showMainVideo = false;
            if (item.VideoID != "")
            {
                ViewBag.showMainVideo = true;
            }

            return(View(item));
        }
Esempio n. 15
0
        public static ViewModels.SEORelationModel GetContentSEO(long SiteID, long MenuID, long PageNo)
        {
            ViewModels.SEORelationModel seoModel = new ViewModels.SEORelationModel();
            string newUploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(SiteID, MenuID).TrimEnd('/') + "/";
            //WorkLib.WriteLog.Write(true, MenuID.ToString());
            List <ZonesModels> zoneList = ZonesDAO.GetPageData(SiteID, PageNo);

            if (zoneList != null && zoneList.Count > 0)
            {
                for (int i = 0; i < zoneList.Count; i++)
                {
                    List <CardsModels> cardList = CardsDAO.GetZoneData(SiteID, zoneList[i].No);
                    if (cardList != null && cardList.Count > 0)
                    {
                        switch (cardList[0].CardsType)
                        {
                        case "Article":
                            ArticleModels articleModel = ArticleDAO.GetItemByCard(cardList[0].No);

                            if (articleModel != null)
                            {
                                var authors = ArticleDAO.GetItemPosters(articleModel.ID);
                                if (authors != null && authors.Count() > 0)
                                {
                                    foreach (ArticlePosterModels auhtor in authors)
                                    {
                                        seoModel.Author += auhtor.Name + ";";
                                    }
                                    seoModel.Author = seoModel.Author.Trim(';');
                                }
                                IEnumerable <ArticleTypesModels> types = articleModel.GetTypes();
                                seoModel.Keywords = string.Join(";", types.Select(t => t.Name));

                                if (!string.IsNullOrEmpty(articleModel.Icon))     // 取得[內文/頁面細節/自行設定代表圖]
                                {
                                    ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(articleModel.Icon);
                                    seoModel.SocialImage = newUploadUrl + imgModel.Img;
                                }
                                else
                                {
                                    if (articleModel.CustomIcon)     // 取得[內文 主影片 自行上傳圖片]
                                    {
                                        if (!string.IsNullOrEmpty(articleModel.VideoImg))
                                        {
                                            ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(articleModel.VideoImg);
                                            seoModel.SocialImage = newUploadUrl + imgModel.Img;
                                        }
                                    }
                                    else
                                    {
                                        if (!string.IsNullOrEmpty(articleModel.VideoImg))
                                        {
                                            seoModel.SocialImage = articleModel.VideoImg;     //[ 內文 主影片 影片截圖]
                                        }
                                    }
                                }
                                var paragraphs = ParagraphDAO.GetItems(articleModel.ID);
                                if (paragraphs != null && paragraphs.Count() > 0)
                                {
                                    foreach (ParagraphModels paragraph in paragraphs)
                                    {
                                        //都沒取到圖, 則繼續取段落的圖
                                        if (string.IsNullOrEmpty(seoModel.SocialImage))
                                        {
                                            if (paragraph.MatchType == "img")
                                            {
                                                IEnumerable <ResourceImagesModels> images = paragraph.GetImages().Where(m => m.IsShow);
                                                if (images != null && images.Count() > 0)
                                                {
                                                    ResourceImagesModels imgModel = images.FirstOrDefault();
                                                    seoModel.SocialImage = newUploadUrl + imgModel.Img;
                                                }
                                            }
                                        }
                                        if (!string.IsNullOrWhiteSpace(paragraph.Contents))
                                        {
                                            if (string.IsNullOrEmpty(seoModel.Description))
                                            {
                                                seoModel.Description = paragraph.Contents.TrimTags().Truncate(100);
                                            }
                                        }
                                    }
                                }
                            }
                            break;

                        case "ArticleIntro":
                            ArticleIntroModels articleIntroModel = ArticleIntroDAO.GetItem(cardList[0].No);
                            if (articleIntroModel != null)
                            {
                                ArticleSettingModels             setting = ArticleSettingDAO.GetItem(MenuID);
                                IEnumerable <ArticleTypesModels> types   = ArticleTypesDAO.GetItems(MenuID);
                                if (setting.Types != "all")
                                {
                                    IEnumerable <long> allowTypeIds = setting.GetTypes();
                                    types             = types.Where(t => allowTypeIds.Contains(t.ID));
                                    seoModel.Keywords = string.Join(",", types.Select(t => t.Name));
                                }
                                else
                                {
                                    seoModel.Keywords = string.Join(",", types.Select(t => t.Name));
                                }

                                if (!string.IsNullOrEmpty(articleIntroModel.Icon))     // 取得[內文/頁面細節/自行設定代表圖]
                                {
                                    ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(articleIntroModel.Icon);
                                    seoModel.SocialImage = newUploadUrl + imgModel.Img;
                                }
                                var paragraphs = ParagraphDAO.GetItems(articleIntroModel.ID);
                                if (paragraphs != null && paragraphs.Count() > 0)
                                {
                                    foreach (ParagraphModels paragraph in paragraphs)
                                    {
                                        //都沒取到圖, 則繼續取段落的圖
                                        if (string.IsNullOrEmpty(seoModel.SocialImage))
                                        {
                                            if (paragraph.MatchType == "img")
                                            {
                                                IEnumerable <ResourceImagesModels> images = paragraph.GetImages().Where(m => m.IsShow);
                                                if (images != null && images.Count() > 0)
                                                {
                                                    ResourceImagesModels imgModel = images.FirstOrDefault();
                                                    seoModel.SocialImage = newUploadUrl + imgModel.Img;
                                                }
                                            }
                                        }
                                        if (!string.IsNullOrWhiteSpace(paragraph.Contents))
                                        {
                                            if (string.IsNullOrEmpty(seoModel.Description))
                                            {
                                                seoModel.Description = paragraph.Contents.TrimTags().Truncate(100);
                                            }
                                        }
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
            }
            return(seoModel);
        }
Esempio n. 16
0
        /*
         * public static string GetContentTypeKeyword(long SiteID, long MenuID, long PageNo)
         * {
         *  string type_keywords = "";
         *  List<ZonesModels> zoneList = ZonesDAO.GetPageData(SiteID, PageNo);
         *  if (zoneList != null && zoneList.Count > 0)
         *  {
         *      for (int i = 0; i < zoneList.Count; i++)
         *      {
         *          List<CardsModels> cardList = CardsDAO.GetZoneData(SiteID, zoneList[i].No);
         *          if (cardList != null && cardList.Count > 0)
         *          {
         *              switch (cardList[0].CardsType)
         *              {
         *                  case "Article":
         *                      ArticleModels articleModel = ArticleDAO.GetItemByCard(cardList[0].No);
         *                      if (articleModel != null)
         *                      {
         *                          IEnumerable<ArticleTypesModels> types = articleModel.GetTypes();
         *                          type_keywords = string.Join(";", types.Select(t => t.Name));
         *                      }
         *                      break;
         *                  case "ArticleIntro":
         *                      ArticleIntroModels articleIntroModel = ArticleIntroDAO.GetItem(cardList[0].No);
         *                      if (articleIntroModel != null)
         *                      {
         *                          ArticleSettingModels setting = ArticleSettingDAO.GetItem(MenuID);
         *                          IEnumerable<ArticleTypesModels> types = ArticleTypesDAO.GetItems(MenuID);
         *                          if (setting.Types != "all")
         *                          {
         *                              IEnumerable<long> allowTypeIds = setting.GetTypes();
         *                              types = types.Where(t => allowTypeIds.Contains(t.ID));
         *                              type_keywords = string.Join(",", types.Select(t => t.Name));
         *                          }
         *                          else
         *                          {
         *                              type_keywords = string.Join(",", types.Select(t => t.Name));
         *                          }
         *                      }
         *                      break;
         *                  case "Event":
         *                      EventModels eventModel = EventDAO.GetItemByCard(cardList[0].No);
         *                      if (eventModel != null)
         *                      {
         *                          IEnumerable<EventTypesModels> types = eventModel.GetTypes();
         *                          type_keywords = string.Join(";", types.Select(t => t.Name));
         *                      }
         *                      break;
         *                  case "Questionnaire":
         *                      QuestionnaireModel questionnaireModel = QuestionnaireDAO.GetItemByCardNo(cardList[0].No);
         *                      if (questionnaireModel != null)
         *                      {
         *                          var selecttypes = questionnaireModel.GetTypes();
         *                          var qTypes = QuestionnaireTypeDAO.GetItems();
         *                          qTypes.Where(q => selecttypes.Contains(q.ID));
         *                          type_keywords = string.Join(";", qTypes.Select(t => t.Name));
         *                      }
         *                      break;
         *              }
         *          }
         *      }
         *  }
         *  return type_keywords;
         * }
         */
        public static string GetContentImage(long SiteID, long MenuID, long PageNo)
        {
            List <ZonesModels> zoneList     = ZonesDAO.GetPageData(SiteID, PageNo);
            string             newUploadUrl = WorkV3.Golbal.UpdFileInfo.GetVPathByMenuID(SiteID, MenuID).TrimEnd('/') + "/";

            if (zoneList != null && zoneList.Count > 0)
            {
                for (int i = 0; i < zoneList.Count; i++)
                {
                    List <CardsModels> cardList = CardsDAO.GetZoneData(SiteID, zoneList[i].No);
                    if (cardList != null && cardList.Count > 0)
                    {
                        switch (cardList[0].CardsType)
                        {
                        case "Article":
                            ArticleModels articleModel = ArticleDAO.GetItemByCard(cardList[0].No);
                            if (articleModel != null)
                            {
                                if (!string.IsNullOrEmpty(articleModel.Icon))     // 取得[內文/頁面細節/自行設定代表圖]
                                {
                                    ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(articleModel.Icon);
                                    return(newUploadUrl + imgModel.Img);
                                }
                                else
                                {
                                    if (articleModel.CustomIcon)     // 取得[內文 主影片 自行上傳圖片]
                                    {
                                        if (!string.IsNullOrEmpty(articleModel.VideoImg))
                                        {
                                            ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(articleModel.VideoImg);
                                            return(newUploadUrl + imgModel.Img);
                                        }
                                    }
                                    else
                                    {
                                        if (!string.IsNullOrEmpty(articleModel.VideoImg))
                                        {
                                            return(articleModel.VideoImg);    //[ 內文 主影片 影片截圖]
                                        }
                                    }
                                    //都沒取到圖, 則繼續取段落的圖
                                    var paragraphs = ParagraphDAO.GetItems(articleModel.ID);
                                    if (paragraphs != null && paragraphs.Count() > 0)
                                    {
                                        foreach (ParagraphModels paragraph in paragraphs)
                                        {
                                            if (paragraph.MatchType == "img")
                                            {
                                                IEnumerable <ResourceImagesModels> images = paragraph.GetImages().Where(m => m.IsShow);
                                                if (images != null && images.Count() > 0)
                                                {
                                                    ResourceImagesModels imgModel = images.FirstOrDefault();
                                                    return(newUploadUrl + imgModel.Img);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            break;

                        case "ArticleIntro":
                            ArticleIntroModels articleIntroModel = ArticleIntroDAO.GetItem(cardList[0].No);
                            if (articleIntroModel != null)
                            {
                                if (!string.IsNullOrEmpty(articleIntroModel.Icon))     // 取得[內文/頁面細節/自行設定代表圖]
                                {
                                    ResourceImagesModels imgModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(articleIntroModel.Icon);
                                    return(newUploadUrl + imgModel.Img);
                                }
                                else
                                {
                                    //都沒取到圖, 則繼續取段落的圖
                                    var paragraphs = ParagraphDAO.GetItems(articleIntroModel.ID);
                                    if (paragraphs != null && paragraphs.Count() > 0)
                                    {
                                        foreach (ParagraphModels paragraph in paragraphs)
                                        {
                                            if (paragraph.MatchType == "img")
                                            {
                                                IEnumerable <ResourceImagesModels> images = paragraph.GetImages().Where(m => m.IsShow);
                                                if (images != null && images.Count() > 0)
                                                {
                                                    ResourceImagesModels imgModel = images.FirstOrDefault();
                                                    return(newUploadUrl + imgModel.Img);
                                                }
                                            }
                                        }
                                    }
                                }
                                //ArticleSettingModels newSetting = ArticleSettingDAO.GetItem(MenuID);
                                //string img = articleIntroModel.GetFirstImg(newSetting);
                                //if (!string.IsNullOrEmpty(img))
                                //    return newUploadUrl + img;
                            }
                            break;
                        }
                    }
                }
            }
            return("");
        }
Esempio n. 17
0
        public ActionResult FieldSetting(long formId, FieldModel item, byte?oldRepeatLimit)
        {
            item.ParentID = formId;

            FormModel form = FormDAO.GetItem(formId);

            if (!string.IsNullOrWhiteSpace(item.Template))
            {
                ResourceFilesModels fileModel = JsonConvert.DeserializeObject <ResourceFilesModels>(item.Template);
                if (fileModel.Id == 0)   // 新上傳的檔案
                {
                    HttpPostedFileBase postedFile = Request.Files["fTemplate"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        item.Template = string.Empty;
                    }
                    else
                    {
                        item.Template = Golbal.UpdFileInfo.SaveFilesBySiteID(postedFile, (long)form.SiteID, formDesignFileDir);
                    }
                }
                else
                {
                    item.Template = fileModel.FileInfo;
                }
            }

            if (!string.IsNullOrWhiteSpace(item.Image))
            {
                ResourceImagesModels imgModel = JsonConvert.DeserializeObject <ResourceImagesModels>(item.Image);
                if (imgModel.ID == 0)   // 新上傳的圖片
                {
                    HttpPostedFileBase postedFile = Request.Files["fImage"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        item.Image = string.Empty;
                    }
                    else
                    {
                        item.Image = Golbal.UpdFileInfo.SaveFilesBySiteID(postedFile, (long)form.SiteID, formDesignFileDir);
                    }
                }
                else
                {
                    item.Image = imgModel.Img;
                }
            }

            if (!string.IsNullOrWhiteSpace(item.VideoCustomPhoto))
            {
                ResourceImagesModels imgModel = JsonConvert.DeserializeObject <ResourceImagesModels>(item.VideoCustomPhoto);
                if (imgModel.ID == 0)
                { // 新上傳的圖片
                    HttpPostedFileBase postedFile = Request.Files["youtubeCustomImg"];
                    if (postedFile == null || postedFile.ContentLength == 0)
                    {
                        item.VideoCustomPhoto = string.Empty;
                    }
                    else
                    {
                        item.VideoCustomPhoto = Golbal.UpdFileInfo.SaveFilesBySiteID(postedFile, (long)form.SiteID, formDesignFileDir);
                    }
                }
                else
                {
                    item.VideoCustomPhoto = imgModel.Img;
                }
            }

            FieldDAO.SetItem(item);

            ViewBag.UploadUrl    = Golbal.UpdFileInfo.GetVPathBySiteID((long)form.SiteID, formDesignFileDir).TrimEnd('/');
            ViewBag.SiteID       = form.SiteID;
            ViewBag.MenuID       = form.SourceID;
            ViewBag.FormID       = formId;
            ViewBag.CustomFolder = formDesignFileDir;
            ViewBag.Exit         = true;
            if (item.TypeID == "input" && oldRepeatLimit == (byte)FieldRepeatLimit.可任意報名 && item.RepeatLimit != (byte)FieldRepeatLimit.可任意報名)
            {
                ViewBag.IsFirst = true;
            }

            return(View($"Field{ item.TypeID }", item));
        }
Esempio n. 18
0
        /// <summary>
        /// 取得段落
        /// </summary>
        /// <param name="Id"></param>
        /// <param name="uploadUrl"></param>
        /// <param name="uploadPath"></param>
        /// <returns></returns>
        public List <ParagraphItem> GetParagraphItem(long Id, string uploadUrl, string uploadPath)
        {
            List <ParagraphItem> paragraphList = new List <ParagraphItem>();

            IEnumerable <ParagraphModels> paragraphs = ParagraphDAO.GetItems(Id);

            foreach (var paragraph in paragraphs)
            {
                string matchType = (paragraph.MatchType ?? string.Empty).ToLower();
                if (matchType == "img")
                {
                    IEnumerable <ResourceImagesModels> images = paragraph.GetImages().Where(m => m.IsShow);
                    if (images == null)
                    {
                        continue;
                    }

                    if (images.Count() > 1)
                    {
                        List <ParagraphImageList> imgList = new List <ParagraphImageList>();

                        foreach (var img in images)
                        {
                            int width = 0, height = 0;
                            GetImageWidthAndHeight($"{uploadPath}\\{img.Img}", out width, out height);
                            imgList.Add(new ParagraphImageList()
                            {
                                Url    = uploadUrl + img.Img,
                                Width  = width,
                                Height = height
                            });
                        }

                        paragraphList.Add(new ParagraphItem()
                        {
                            Type        = "ImageGroup",
                            ContentList = imgList
                        });
                    }
                    else
                    {
                        foreach (var img in images)
                        {
                            int width = 0, height = 0;
                            GetImageWidthAndHeight($"{uploadPath}\\{img.Img}", out width, out height);
                            ParagraphImage imgItem = new ParagraphImage
                            {
                                Type    = "Image",
                                Content = uploadUrl + img.Img,
                                Width   = width,
                                Height  = height
                            };
                            paragraphList.Add(imgItem);
                        }
                    }

                    if (!string.IsNullOrWhiteSpace(paragraph.Title))
                    {
                        paragraphList.Add(new ParagraphItem {
                            Type = "Title", Content = paragraph.Title
                        });
                    }

                    if (!string.IsNullOrWhiteSpace(paragraph.Contents))
                    {
                        paragraphList.Add(new ParagraphItem {
                            Type = "Text", Content = paragraph.Contents
                        });
                    }
                }
                else if (matchType == "video")
                {
                    ResourceVideosModels video = paragraph.GetVideo();
                    string shotUrl = string.Empty, videoUrl = string.Empty;

                    if (video.Type == "custom")
                    {
                        videoUrl = uploadUrl + video.Link;
                        if (!string.IsNullOrWhiteSpace(video.Screenshot))
                        {
                            ResourceImagesModels img = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(video.Screenshot);
                            shotUrl = uploadUrl + img.Img;
                        }
                    }
                    else
                    {
                        videoUrl = video.Link;
                        shotUrl  = video.Screenshot;
                        if (video.ScreenshotIsCustom && !string.IsNullOrWhiteSpace(shotUrl))
                        {
                            ResourceImagesModels img = Newtonsoft.Json.JsonConvert.DeserializeObject <ResourceImagesModels>(shotUrl);
                            shotUrl = uploadUrl + img.Img;
                        }
                    }
                    paragraphList.Add(new ParagraphVideo
                    {
                        Type       = "Video",
                        Content    = videoUrl,
                        VideoType  = video.Type,
                        Screenshot = shotUrl
                    });

                    if (!string.IsNullOrWhiteSpace(paragraph.Title))
                    {
                        paragraphList.Add(new ParagraphItem {
                            Type = "Title", Content = paragraph.Title
                        });
                    }

                    if (!string.IsNullOrWhiteSpace(paragraph.Contents))
                    {
                        paragraphList.Add(new ParagraphItem {
                            Type = "Text", Content = paragraph.Contents
                        });
                    }
                }
                else if (matchType == "file")
                {
                    if (!string.IsNullOrWhiteSpace(paragraph.Title))
                    {
                        paragraphList.Add(new ParagraphItem {
                            Type = "Title", Content = paragraph.Title
                        });
                    }

                    if (!string.IsNullOrWhiteSpace(paragraph.Contents))
                    {
                        paragraphList.Add(new ParagraphItem {
                            Type = "Text", Content = paragraph.Contents
                        });
                    }

                    IEnumerable <ResourceFilesModels> files = paragraph.GetFiles();
                    foreach (var file in files)
                    {
                        paragraphList.Add(new ParagraphFile
                        {
                            Type    = "File",
                            Content = uploadUrl + file.FileInfo,
                            Name    = (string.IsNullOrWhiteSpace(file.ShowName) ? System.Text.RegularExpressions.Regex.Replace(file.FileInfo, @"\.[^\.]*$", string.Empty) : file.ShowName)
                        });
                    }
                }
                else if (matchType == "link")
                {
                    if (!string.IsNullOrWhiteSpace(paragraph.Title))
                    {
                        paragraphList.Add(new ParagraphItem {
                            Type = "Title", Content = paragraph.Title
                        });
                    }

                    if (!string.IsNullOrWhiteSpace(paragraph.Contents))
                    {
                        paragraphList.Add(new ParagraphItem {
                            Type = "Text", Content = paragraph.Contents
                        });
                    }

                    IEnumerable <ResourceLinksModels> links = paragraph.GetLinks();
                    foreach (var link in links)
                    {
                        paragraphList.Add(new ParagraphFile
                        {
                            Type    = "Link",
                            Content = link.LinkInfo,
                            Name    = link.Descriptions
                        });
                    }
                }
                else if (matchType == "voice")
                {
                    if (!string.IsNullOrWhiteSpace(paragraph.Title))
                    {
                        paragraphList.Add(new ParagraphItem {
                            Type = "Title", Content = paragraph.Title
                        });
                    }

                    if (!string.IsNullOrWhiteSpace(paragraph.Contents))
                    {
                        paragraphList.Add(new ParagraphItem {
                            Type = "Text", Content = paragraph.Contents
                        });
                    }

                    IEnumerable <ResourceVoicesModels> voices = paragraph.GetVoices();
                    foreach (var voice in voices)
                    {
                        paragraphList.Add(new ParagraphItem
                        {
                            Type    = "Voice",
                            Content = uploadUrl + voice.Path
                        });
                    }
                }
                else if (string.IsNullOrWhiteSpace(matchType))
                {
                    if (!string.IsNullOrWhiteSpace(paragraph.Title))
                    {
                        paragraphList.Add(new ParagraphItem {
                            Type = "Title", Content = paragraph.Title
                        });
                    }

                    if (!string.IsNullOrWhiteSpace(paragraph.Contents))
                    {
                        paragraphList.Add(new ParagraphItem {
                            Type = "Text", Content = paragraph.Contents
                        });
                    }
                }
            }

            return(paragraphList);
        }