/// <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> /// 增加一条包含MD5值的数据 /// </summary> public int AddMd5(AMS_PlayListMd5Model model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into AMS_PlayList("); strSql.Append("Number,PlayList,ReleaseDate,EffectDate,EndDate)"); strSql.Append(" values ("); strSql.Append("@Number,@PlayList,@ReleaseDate,@EffectDate,@EndDate)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Number", SqlDbType.NVarChar, 50), new SqlParameter("@PlayList", SqlDbType.Text), new SqlParameter("@ReleaseDate", SqlDbType.DateTime), new SqlParameter("@EffectDate", SqlDbType.DateTime), new SqlParameter("@EndDate", SqlDbType.DateTime) }; parameters[0].Value = model.PlayListNo; parameters[1].Value = model.ToXml(); parameters[2].Value = model.ReleaseDate; parameters[3].Value = model.EffectDate; parameters[4].Value = model.EndDate; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条包含MD5值的数据 /// </summary> public bool UpdateMd5(AMS_PlayListMd5Model model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update AMS_PlayList set "); strSql.Append("Number=@Number,"); strSql.Append("PlayList=@PlayList,"); strSql.Append("ReleaseDate=@ReleaseDate,"); strSql.Append("EffectDate=@EffectDate,"); strSql.Append("EndDate=@EndDate"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Number", SqlDbType.NVarChar, 50), new SqlParameter("@PlayList", SqlDbType.Text), new SqlParameter("@ReleaseDate", SqlDbType.DateTime), new SqlParameter("@EffectDate", SqlDbType.DateTime), new SqlParameter("@EndDate", SqlDbType.DateTime), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.PlayListNo; parameters[1].Value = model.ToXml(); parameters[2].Value = model.ReleaseDate; parameters[3].Value = model.EffectDate; parameters[4].Value = model.EndDate; parameters[5].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }