예제 #1
0
        /// <summary>
        /// 在线预览
        /// </summary>
        /// <param name="appId">附件id</param>
        /// <param name="ext">文件扩展名</param>
        /// <returns></returns>
        public ActionResult ViewOnline(string appId, string ext, string resId)
        {
            string  AnnexName     = ""; //附件名称
            string  Author        = ""; //作者
            string  UserName      = ""; //上传者
            string  Tag           = ""; //标签
            string  UploadTime    = ""; //上传时间
            decimal Review_num    = 0;  //评价数
            decimal Page_view_num = 0;  //浏览数
            decimal Download_num  = 0;  //下载数
            decimal Grage         = 0;  //评分

            using (JSZX_ResourceEntities db = new JSZX_ResourceEntities())
            {
                Resource res    = new Resource();
                string   userId = CommonUtil.GetSession(Session, "id");
                res.AddViewNum(resId, appId, userId, db);
                View_Appendix model = db.View_Appendix.First(t => t.ID.Equals(appId));
                AnnexName     = model.FILE_NAME;
                Author        = model.AUTHOR;
                UserName      = model.USER_NAME;
                Tag           = model.LABEL;
                UploadTime    = Convert.ToDateTime(model.UPLOAD_TIME == null ? "1900/01/01 00:00:00" : model.UPLOAD_TIME.ToString()).ToString("yyyy/MM/dd HH:mm:ss");
                Review_num    = model.REVIEW_NUM == null ? 0 : Convert.ToDecimal(model.REVIEW_NUM);
                Page_view_num = model.PAGE_VIEW_NUM == null ? 0 : Convert.ToDecimal(model.PAGE_VIEW_NUM);
                Download_num  = model.DOWNLOAD_NUM == null ? 0 : Convert.ToDecimal(model.DOWNLOAD_NUM);
                Grage         = model.GRADE == null ? 0 : Convert.ToDecimal(model.GRADE);
                ResourceList relist = new ResourceList();
                string       retStr = "";
                GetTypeListString(relist, db, model.TYPE_ID, ref retStr);
                ViewData["retStr"] = retStr;
            }

            ViewData["appId"]         = appId;
            ViewData["AnnexName"]     = string.IsNullOrEmpty(AnnexName) ? "" : Path.GetFileNameWithoutExtension(AnnexName);
            ViewData["AnnexType"]     = Constant.GetDocType(string.IsNullOrEmpty(AnnexName) ? "" : Path.GetExtension(AnnexName));
            ViewData["Author"]        = string.IsNullOrEmpty(Author) ? "" : Author;
            ViewData["UserName"]      = string.IsNullOrEmpty(UserName) ? "" : UserName;
            ViewData["Tag"]           = string.IsNullOrEmpty(Tag) ? "" : Tag.Replace(",", " ");
            ViewData["UploadTime"]    = UploadTime;
            ViewData["Review_num"]    = Review_num.ToString();
            ViewData["Page_view_num"] = Page_view_num.ToString();
            ViewData["Download_num"]  = Download_num.ToString();
            ViewData["Grage"]         = Grage.ToString();

            string fileName = appId + ext;

            ViewData["fileName"] = fileName;
            ViewData["extName"]  = "other";
            ViewData["resId"]    = resId;

            ext = ext.ToLower();

            string fileType = Constant.GetFileType(ext);

            if (fileType == "0")
            {
                ViewData["extName"] = ".swf";
            }
            else if (fileType == "1")
            {
                ViewData["extName"] = ".flv";
            }
            else if (fileType == "2")
            {
                ViewData["extName"] = ".jpg";
            }

            string pageId = "020101";
            string id     = CommonUtil.GetSession(Session, "id");

            ResourceList   rslist = new ResourceList();
            AthorityModels am     = rslist.GetAthority(id, pageId);

            /**根据用户是否登录,显示收藏按钮。 2014-12-18 5920 start**/
            if (string.IsNullOrEmpty(id))
            {
                ViewData["IsShowCollection"] = "0";
            }
            else
            {
                ViewData["IsShowCollection"] = "1";
            }
            /**根据用户是否登录,显示收藏按钮。 2014-12-18 5920 end**/

            ViewData["DownLoadAthority"] = am.DownLoadAthority;

            return(View());
        }