/// <summary> /// 图片文件的显示:相册 /// </summary> /// <param name="serviceWorks"></param> /// <param name="worksId"></param> /// <returns></returns> private void ShowImages(IServiceWorks serviceWorks, long worksId) { StringBuilder htmlContent = new StringBuilder(); List <VAWcfService.WorksFile> imagesList = serviceWorks.GetWorksFile(worksId.ToString(), "2"); if (imagesList.Count > 0) { VAWcfService.Works works = serviceWorks.GetWorksSubmitById(worksId.ToString()); string periodId = works.PeriodID.ToString(); Periods period = serviceWorks.GetPeriodsById(periodId).FirstOrDefault(); string courseId = period.CourseID.ToString(); Course course = serviceWorks.GetCourseById(courseId).FirstOrDefault(); string siteUrl = "http://va.neu.edu.cn"; if (course != null) { siteUrl += course.Url; } htmlContent.AppendLine("<fieldset><legend>作品图片</legend>"); htmlContent.AppendLine("<div class='box'>"); htmlContent.AppendLine("<div id ='imgs' class='imgs'>"); foreach (var file in imagesList) { htmlContent.AppendLine("<img src='" + siteUrl + file.FilePath + "' onClick='$(this).ImgZoomIn();' height='200'>"); } htmlContent.AppendLine("</div>"); htmlContent.AppendLine("</div>"); htmlContent.AppendLine("</fieldset>"); ImagesDiv.InnerHtml = htmlContent.ToString(); } else { ImagesDiv.Visible = false; } }
/// <summary> /// 多媒体文件(包括音视频)的显示:播放窗口 /// </summary> /// <param name="serviceWorks">数据服务层接口</param> /// <param name="worksId">作品ID</param> /// <param name="typeId"></param> /// <returns></returns> private void ShowMedias(IServiceWorks serviceWorks, long worksId, int typeId) { StringBuilder htmlContent = new StringBuilder(); List <VAWcfService.WorksFile> mediaFiles = serviceWorks.GetWorksFile(worksId.ToString(), typeId.ToString()); if (mediaFiles.Count > 0) { VAWcfService.WorksFile mediaFile = mediaFiles.OrderByDescending(wf => wf.WorksFileID).FirstOrDefault();//因为可能有多个文档重复上传,所以此处先处理成该作品最后一次上传的文档为作品文档。 VAWcfService.Works works = serviceWorks.GetWorksSubmitById(worksId.ToString()); string periodId = works.PeriodID.ToString(); Periods period = serviceWorks.GetPeriodsById(periodId).FirstOrDefault(); string siteUrl = "http://va.neu.edu.cn"; if (period != null) { string courseId = period.CourseID.ToString(); Course course = serviceWorks.GetCourseById(courseId).FirstOrDefault(); if (course != null) { siteUrl += course.Url; } } if (mediaFile != null) { MediaDiv.Visible = true; //string mediaHtml = "<iframe type='text/html' width='640' height='360'"; //mediaHtml += "src='"+ siteUrl + "/_layouts/15/videoembedplayer.aspx?site=" + mediaFile.FilePath + "title=1'></iframe>"; htmlContent.AppendLine("<div class='plist'>"); htmlContent.AppendLine("<a href='" + siteUrl + mediaFile.FilePath + "' name='" + mediaFile.FileName + "'"); htmlContent.AppendLine("<img class='listpic' src='images/start.jpg' alt='" + mediaFile.FileName + "' width='200' height='150'>"); string txtExtend = mediaFile.FileName.Substring(mediaFile.FileName.LastIndexOf(".", StringComparison.Ordinal) + 1).ToLower(); if (txtExtend == "mp3") { htmlContent.AppendLine("<span class='v_bq_hong'>讲解音频</span><span class='v_bg'></span>"); } else { htmlContent.AppendLine("<span class='v_bq_lan'>讲解视频</span><span class='v_bg'></span>"); } htmlContent.AppendLine("<span class='v_bq_vico'></span></a>"); htmlContent.AppendLine("<h2><a href='" + siteUrl + mediaFile.FilePath + "' name='" + mediaFile.FileName + "'>" + mediaFile.FileName + "</a></h2><p>" + mediaFile.Created + "</p>"); htmlContent.AppendLine("</div>"); } //} MediaList.InnerHtml = htmlContent.ToString(); } else { MediaDiv.Visible = false; } //return htmlContent; }
////师生点评 //private void GetComments(long worksId) //{ // divScore.Controls.Clear(); // List<CSWorksExpertUser> ds = GetDSWorksComments; // List<CSWorksExpertUser> dv = ds.Where(p => p.UserID == DAL.Common.LoginID).ToList(); // if (dv.Count > 0) // Page.ClientScript.RegisterStartupScript(this.GetType(), "message", "<script defer>YiComments();</script>"); // lblPersons.Text = ds.Count.ToString(); // gvComments.DataSource = dv; // gvComments.DataBind(); // float avg = 0; // int tCount = 0; // foreach (CSWorksExpertUser dr in ds) // { // if (dr.Score.HasValue && dr.Score > 0) // { // avg = avg + (float)dr.Score; // tCount = tCount + 1; // } // } // if (tCount > 0) // avg = avg / tCount; // int score = (int)avg; // string txt = ""; // for (int i = 0; i < score; i++) // { // txt += "<img src='images/star_red.gif'/>"; // } // int j = score; // if (avg > score) // { // j = j + 1; // txt += "<img src='images/star_red2.gif'/>"; // } // for (int i = j; i < 5; i++) // { // txt += "<img src='images/star_gray.gif'/>"; // } // divScore.Controls.Add(new LiteralControl(txt)); //} /// <summary> /// 初始化作品图片显示 /// </summary> /// <param name="worksId"></param> /// <returns></returns> public static string ImagesHtml(long worksId)// { string imageshtml = ""; using (ChannelFactory <IServiceWorks> channelFactory = new ChannelFactory <IServiceWorks>("ServiceWorks")) { IServiceWorks proxy = channelFactory.CreateChannel(); //getall List <VAWcfService.WorksFile> imageFiles = proxy.GetWorksFile(worksId.ToString(), "2"); foreach (var file in imageFiles) { } } return(imageshtml); }
/// <summary> /// 其它文件显示:下载列表 /// </summary> /// <param name="serviceWorks"></param> /// <param name="worksId"></param> /// <returns></returns> private void ShowOthers(IServiceWorks serviceWorks, long worksId) { StringBuilder htmlContent = new StringBuilder(); List <VAWcfService.WorksFile> otherFiles = serviceWorks.GetWorksFile(worksId.ToString(), "5"); if (otherFiles.Count > 0) { htmlContent.AppendLine("<fieldset><le其它附件: (点击文件名可下载)</span><br/>"); foreach (var file in otherFiles) { htmlContent.AppendLine("<a href='" + file.FilePath + "'>" + file.FileName + "</a>"); htmlContent.AppendLine("<br/>"); } OthersDiv.InnerHtml = htmlContent.ToString(); } else { OthersDiv.Visible = false; } }
/// <summary> /// 文档文件的显示:在线浏览 /// </summary> /// <param name="serviceWorks"></param> /// <param name="worksId"></param> /// <returns></returns> private void ShowDocuments(IServiceWorks serviceWorks, long worksId) { StringBuilder htmlContent = new StringBuilder(); List <VAWcfService.WorksFile> docFiles = serviceWorks.GetWorksFile(worksId.ToString(), "1"); if (docFiles.Count > 0) { SPSite spsite = SPContext.Current.Site; VAWcfService.Works works = serviceWorks.GetWorksSubmitById(worksId.ToString()); string periodId = works.PeriodID.ToString(); Periods period = serviceWorks.GetPeriodsById(periodId).FirstOrDefault(); if (period != null) { string courseId = period.CourseID.ToString(); Course course = serviceWorks.GetCourseById(courseId).FirstOrDefault(); string siteUrl = "http://va.neu.edu.cn"; string cUrl = ""; if (course != null) { cUrl = course.Url.Substring(0, course.Url.Length - 1); } siteUrl += cUrl; var docFile = docFiles.OrderByDescending(f => f.WorksFileID).FirstOrDefault();//因为可能有多个文档重复上传,所以此处先处理成该作品最后一次上传的文档为作品文档。 //if (docFiles.Count ==1) //{ //var file = docFiles[0]; if (docFile != null) { htmlContent.AppendLine("<fieldset><legend>作品文档:<a href='" + siteUrl + docFile.FilePath + "'>" + docFile.FileName + "</a></legend>"); htmlContent.AppendLine("<div style='width:100%;text-align:center'><iframe src='" + siteUrl + "/_layouts/15/WopiFrame.aspx?sourcedoc=" + cUrl + HttpUtility.UrlEncode(docFile.FilePath) + "&action=embedview' width='600px' height='400px' frameborder='0'></iframe></div>"); htmlContent.AppendLine("</fieldset>"); } //} //else //{ // htmlContent.AppendLine("<div>作品文档:</div>"); // htmlContent.AppendLine("<table style='border:1px solid #666666'>"); // htmlContent.AppendLine("<tr><td valign='top'>"); // htmlContent.AppendLine("<fieldset><legend>文档列表</legend>"); // foreach (var file in docFiles) // { // string url = siteUrl + "/_layouts/15/WopiFrame.aspx?sourcedoc= " + cUrl + HttpUtility.UrlEncode(docFiles[0].FilePath) + "&action=embedview"; // htmlContent.AppendLine("<dt onClick='return showframe('" + url + "')' style='cursor: pointer;'>"+ file.FileName+ "</dt>"); // } // htmlContent.AppendLine("</fieldset>"); // htmlContent.AppendLine("</td><td>"); // htmlContent.AppendLine("<fieldset style='border:1px solid #444444'><legend>文档预览</legend>"); // htmlContent.AppendLine("<iframe id='myIframe' src='"+ siteUrl + "/_layouts/15/WopiFrame.aspx?sourcedoc=" + cUrl + HttpUtility.UrlEncode(docFiles[0].FilePath) + "&action=embedview' width='400px' height='300px' frameborder='0'></iframe>"); // htmlContent.AppendLine("</fieldset>"); // htmlContent.AppendLine("</td></tr>"); // htmlContent.AppendLine("</table>"); //} } DocsDiv.InnerHtml = htmlContent.ToString(); } else { DocsDiv.Visible = false; } }