/// <summary> /// 通过ID获取作品文件 /// </summary> /// <param name="fileID">文件ID</param> /// <returns></returns> public WorksFile GetWorksFileByID(string fileID) { long lfileID = long.Parse(fileID); WorksFile file = db.WorksFile.FirstOrDefault(w => w.WorksFileID == lfileID); return(file); }
/// <summary> /// 添加作品文件 /// </summary> /// <param name="worksFile"></param> /// <returns></returns> public long Create(WorksFile worksFile) { db.WorksFile.Add(worksFile); db.SaveChanges(); long fileID = worksFile.WorksFileID; return(fileID); }
public static long GetWorksId(string wName) { var db = new LAActivityEntities(); WorksFile works = db.WorksFile.FirstOrDefault(w => w.FileName.Equals(wName)); long WorksId = works.WorksFileID; return(WorksId); }
/// <summary> /// 更新作品文件 /// </summary> /// <param name="worksFile"></param> public void Update(WorksFile worksFile) { WorksFile file1 = db.WorksFile.FirstOrDefault(w => w.WorksFileID == worksFile.WorksFileID); file1.FileName = worksFile.FileName; file1.FilePath = worksFile.FilePath; file1.FileSize = worksFile.FileSize; db.SaveChanges(); }
/// <summary> /// 多媒体文件(包括音视频)的显示:播放窗口 /// </summary> /// <param name="serviceWorks">数据服务层接口</param> /// <param name="worksId">作品ID</param> /// <param name="typeId"></param> /// <returns></returns> private void ShowMedias(long worksId, int typeId) { StringBuilder htmlContent = new StringBuilder(); List <WorksFile> mediaFiles = Bll.WorksBll.GetWorksFile(worksId.ToString(), typeId.ToString()); if (mediaFiles.Count > 0) { WorksFile mediaFile = mediaFiles.OrderByDescending(wf => wf.WorksFileID).FirstOrDefault();//因为可能有多个文档重复上传,所以此处先处理成该作品最后一次上传的文档为作品文档。 Works works = Bll.WorksBll.GetWorksSubmitById(worksId.ToString()); string periodId = works.PeriodID.ToString(); Periods period = Bll.WorksBll.GetPeriodsById(periodId).FirstOrDefault(); string siteUrl = "http://va.neu.edu.cn"; if (period != null) { string courseId = period.CourseID.ToString(); List <Course> cs = Bll.WorksBll.GetCourseById(courseId); Course course = cs.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; }
public static long UpdateWorksFileForSize(WorksFile dr) { using (ContestEntities db = new ContestEntities()) { WorksFile file = db.WorksFile.SingleOrDefault(p => p.WorksFileID == dr.WorksFileID); file.FileSize = dr.FileSize; file.Modified = dr.Modified; file.ModifiedBy = dr.ModifiedBy; db.SaveChanges(); return(1); } }
public static long InsertWorkFile(string fileName, string filePath, int fSize, long flag) { var db = new LAActivityEntities(); WorksFile works = new WorksFile(); works.FileName = fileName; works.FilePath = filePath; works.FileSize = fSize; works.CreatedBy = DAL.UserDAL.GetUserId(); works.Created = DateTime.Now; works.Flag = flag; db.WorksFile.Add(works); db.SaveChanges(); return(works.WorksFileID); }
/// <summary> /// 作品附件 /// </summary> private void GetWorksFile(long worksId, int typeId) { SPSite site = SPContext.Current.Site; string siteUrl = site.Url; siteUrl = siteUrl.Substring(siteUrl.IndexOf("/", 8)); List <WorksFile> ds = WorksFile.GetFilesByWorksID(worksId); StringBuilder txtContent = new StringBuilder(); foreach (WorksFile dr in ds) { FileType ft = FileType.GetTypeById(dr.FileTypeId); string typeName = ft.TypeName; if (ft.ParentID != 0) { typeName = FileType.GetParentTypeBYId(ft.ParentID).TypeName; } typeId = 0;//1:文档;2:图片;3:音频;4:视频;5:其它;其中3和3统归为媒体类;0表示所有 switch (typeId) { case 1: //图片附件,显示为图片 txtContent.AppendLine("<img src='" + dr.FilePath + "' width='500px'/><br />" + dr.FileName); txtContent.AppendLine("<br/>"); break; case 3: case 4: //音视频附件:显示为播放窗口 txtContent.AppendLine("<iframe type='text/html' width='400' height='300' src='" + siteUrl + "/_layouts/15/videoembedplayer.aspx?site=e6bc1a4ae9eb4d22a35ac16c80eedb79&web=0764a19a1b224278861c15141c7a91a8&folder=57bfb4d317814fd49078be8cd9da899f&img=''&title=1&lHome=1&lOwner=1'></iframe>"); break; case 2: //文档附件:在线浏览 txtContent.Append("<iframe src='" + siteUrl + "/_layouts/15/WopiFrame.aspx?sourcedoc=" + dr.FilePath + "&action=embedview' width='379px' height='252px' frameborder='0'></iframe>"); txtContent.AppendLine("<br/>"); break; default: //其它附件:提供下载 txtContent.AppendLine("<a href='" + dr.FilePath + "'>" + dr.FileName + "<br />"); txtContent.AppendLine("<br/>"); break; } } if (txtContent.ToString().Length > 0) { txtContent.Remove(txtContent.Length - 5, 5); } DivWorksFile.Controls.Clear(); DivWorksFile.Controls.Add(new LiteralControl(txtContent.ToString())); }
public static long InsertWorksImages(WorksFile dr) { using (ContestEntities db = new ContestEntities()) { WorksFile file = new WorksFile(); file.WorksID = dr.WorksID; file.Type = dr.Type; file.FileName = dr.FileName; file.FilePath = dr.FilePath; file.FileSize = dr.FileSize; file.Created = dr.Created; file.CreatedBy = dr.CreatedBy; db.WorksFile.Add(file); db.SaveChanges(); return(file.WorksFileID); } }
private static List <WorksFile> ImageFile() { List <WorksFile> wfiles = new List <WorksFile>(); WorksFile wfile = new WorksFile(1, "image1", 1, "286x220", "/WorksShow/gallery/images/pic2.jpg"); wfiles.Add(wfile); wfile = new WorksFile(2, "image2", 1, "640x426", "/WorksShow/gallery/images/pic1.jpg"); wfiles.Add(wfile); wfile = new WorksFile(3, "image3", 1, "768x1024", "/WorksShow/gallery/images/pic3.jpg"); wfiles.Add(wfile); wfile = new WorksFile(4, "image4", 1, "900x596", "/WorksShow/gallery/images/pic4.jpg"); wfiles.Add(wfile); return(wfiles); }