/// <summary> /// 导出离线版本 /// </summary> public bool DownloadPlaylist(string downloadpath) { try { downloadpath = downloadpath + "\\MediaPlaylist_" + ServerDateTime.Now.Value.ToShortDateString(); DirectoryInfo dir = new DirectoryInfo(downloadpath); if (!dir.Exists) { dir.Create(); } else { throw new Exception("存在相同的文件夹,请重新选择目录!"); } AMS_PlayListMd5Model model = AMS_PlayListMd5Model.Parse(ToModel().ToXml()); model.Id = _id; model.ReleaseDate = _SubmitDate; if (!string.IsNullOrEmpty(_Number) && _ItemList.Count > 0 && (_BeginDate < _EndDate)) { foreach (AMS_VideoMd5Item item in model.VideoFiles) { if (item.RelativeUrl == item.Name) { FileOperate fo = new FileOperate(); if (!fo.FileDownLoad(downloadpath + "\\" + item.RelativeUrl, item.RelativeUrl, SeatManage.EnumType.SeatManageSubsystem.MediaFiles)) { throw new Exception("文件" + item.Name + "离线保存失败!"); } } else { File.Copy(item.RelativeUrl, downloadpath + "\\" + item.Name); } foreach (AMS_VideoMd5Item videoitem in model.PlayVideoItems) { videoitem.RelativeUrl = videoitem.Name; videoitem.md5value = videoitem.md5value; } } string xml = model.ToXml(); string xmlpath = downloadpath + "\\playList.xml"; //写入文件 FileStream fs = new FileStream(xmlpath, FileMode.Create, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); sw.Write(xml); sw.Close(); fs.Close(); return(true); } else { throw new Exception("信息填写错误!请仔细检查!"); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); return(false); } }
/// <summary> /// 更新播放列表 /// </summary> public bool UpdatePlaylist() { AMS_PlayListMd5Model model = AMS_PlayListMd5Model.Parse(ToModel().ToXml()); model.Id = _id; model.ReleaseDate = _SubmitDate; try { if (!string.IsNullOrEmpty(_Number) && _ItemList.Count > 0 && (_BeginDate < _EndDate)) { AMS_PlayListMd5Model samemodel = AMS_PlayListBLL.GetMd5PlaylistByNum(_Number); if (samemodel == null || samemodel.Id == _id) { foreach (AMS_VideoMd5Item item in model.VideoFiles) { if (item.RelativeUrl != item.Name) { FileOperate fo = new FileOperate(); if (!fo.UpdateFile(item.RelativeUrl, item.Name, SeatManage.EnumType.SeatManageSubsystem.MediaFiles)) { throw new Exception("文件" + item.Name + "上传失败!"); } } } foreach (AMS_VideoMd5Item videoitem in model.PlayVideoItems) { videoitem.RelativeUrl = videoitem.Name; videoitem.md5value = videoitem.md5value; } if (AMS_PlayListBLL.UpdateMd5PlayList(model) == AdvertManage.Model.Enum.HandleResult.Failed) { throw new Exception("更新播放列表失败,具体详情请查看错误日志!"); } return(true); } else { throw new Exception("已存在重复的编号!"); } } else { throw new Exception("信息填写错误!请仔细检查!"); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); return(false); } }