using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using Bowin.Common.Linq.Entity; using EMISOnline.ViewModel.SystemView; using EMISOnline.DataLogic.SystemDAL; using EMISOnline.Entities; using EMISOnline.DataLogic.Student; using EMISOnline.CommonLogic.StudentServices; using EMISOnline.DataLogic.FtpFile; using EMISOnline.DataLogic.Repositories; namespace EMISOnline.CommonLogic.FtpFileServices { public class FtpVideoServices : BaseServices, IFtpVideoServices { public FTPVideoDAL FTPVideoDAL { get; set; } public CourseVideoRepository CourseVideoRepository { get; set; } public void SaveFtpVideo(EM_FTPVideo v) { EM_FTPVideo video = FTPVideoDAL.FTPVideoRepository.GetList(x => x.FTPPath == v.FTPPath).FirstOrDefault(); if (video == null) { v.FTPVideoID = Guid.NewGuid(); v.CreateTime = DateTime.Now; UnitOfWork.Add(v); EM_CourseVideo cv = new EM_CourseVideo(); cv.CourseVideoID = v.FTPVideoID; cv.Name = v.Name; cv.UploadUrl = v.FTPUrl; cv.PlayUrl = v.M3u8Url ?? v.FTPUrl; cv.RecordStatus = 1; cv.CreateTime = DateTime.Now; cv.ModifyTime = DateTime.Now; UnitOfWork.Add(cv); } else { EM_CourseVideo cv = CourseVideoRepository.GetSingle(x => x.CourseVideoID == video.FTPVideoID); cv.PlayUrl = v.M3u8Url ?? v.FTPUrl; video.FTPPath = v.FTPPath; if (!string.IsNullOrEmpty(v.FTPUrl)) video.FTPUrl = v.FTPUrl; if (!string.IsNullOrEmpty(v.Name)) video.Name = v.Name; if (!string.IsNullOrEmpty(v.M3u8Path)) video.M3u8Path = v.M3u8Path; if (!string.IsNullOrEmpty(v.M3u8Url)) video.M3u8Url = v.M3u8Url; if (v.Status.HasValue) video.Status = v.Status; video.ModifyTime = DateTime.Now; UnitOfWork.Update(video); } UnitOfWork.Commit(); } } }