FtpVideoServices.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using Bowin.Common.Linq.Entity;
  7. using EMISOnline.ViewModel.SystemView;
  8. using EMISOnline.DataLogic.SystemDAL;
  9. using EMISOnline.Entities;
  10. using EMISOnline.DataLogic.Student;
  11. using EMISOnline.CommonLogic.StudentServices;
  12. using EMISOnline.DataLogic.FtpFile;
  13. using EMISOnline.DataLogic.Repositories;
  14. namespace EMISOnline.CommonLogic.FtpFileServices
  15. {
  16. public class FtpVideoServices : BaseServices, IFtpVideoServices
  17. {
  18. public FTPVideoDAL FTPVideoDAL { get; set; }
  19. public CourseVideoRepository CourseVideoRepository { get; set; }
  20. public void SaveFtpVideo(EM_FTPVideo v)
  21. {
  22. EM_FTPVideo video = FTPVideoDAL.FTPVideoRepository.GetList(x => x.FTPPath == v.FTPPath).FirstOrDefault();
  23. if (video == null)
  24. {
  25. v.FTPVideoID = Guid.NewGuid();
  26. v.CreateTime = DateTime.Now;
  27. UnitOfWork.Add(v);
  28. EM_CourseVideo cv = new EM_CourseVideo();
  29. cv.CourseVideoID = v.FTPVideoID;
  30. cv.Name = v.Name;
  31. cv.UploadUrl = v.FTPUrl;
  32. cv.PlayUrl = v.M3u8Url ?? v.FTPUrl;
  33. cv.RecordStatus = 1;
  34. cv.CreateTime = DateTime.Now;
  35. cv.ModifyTime = DateTime.Now;
  36. UnitOfWork.Add(cv);
  37. }
  38. else
  39. {
  40. EM_CourseVideo cv = CourseVideoRepository.GetSingle(x => x.CourseVideoID == video.FTPVideoID);
  41. cv.PlayUrl = v.M3u8Url ?? v.FTPUrl;
  42. video.FTPPath = v.FTPPath;
  43. if (!string.IsNullOrEmpty(v.FTPUrl)) video.FTPUrl = v.FTPUrl;
  44. if (!string.IsNullOrEmpty(v.Name)) video.Name = v.Name;
  45. if (!string.IsNullOrEmpty(v.M3u8Path)) video.M3u8Path = v.M3u8Path;
  46. if (!string.IsNullOrEmpty(v.M3u8Url)) video.M3u8Url = v.M3u8Url;
  47. if (v.Status.HasValue) video.Status = v.Status;
  48. video.ModifyTime = DateTime.Now;
  49. UnitOfWork.Update(video);
  50. }
  51. UnitOfWork.Commit();
  52. }
  53. }
  54. }