public ViewModelPlayListEditWindow()
 {
     _PlayListModel = new Model.AMS_PlayList();
     MediaFileList.Clear();
     PlayFileList.Clear();
     foreach (AMS.Model.AMS_VideoItem item in _PlayListModel.MediaFiles)
     {
         ViewModelVideoItem newItem = new ViewModelVideoItem();
         newItem.Name          = item.Name;
         newItem.PlayTime      = item.PlayTime;
         newItem.ReRelativeUrl = item.ReRelativeUrl;
         newItem.SunTime       = item.SunTime;
         newItem.MD5Value      = item.MD5Value;
         MediaFileList.Add(newItem);
     }
     foreach (AMS.Model.AMS_VideoItem item in _PlayListModel.PlayFileList)
     {
         ViewModelVideoItem newItem = new ViewModelVideoItem();
         newItem.Name          = item.Name;
         newItem.PlayTime      = item.PlayTime;
         newItem.ReRelativeUrl = item.ReRelativeUrl;
         newItem.SunTime       = item.SunTime;
         newItem.MD5Value      = item.MD5Value;
         PlayFileList.Add(newItem);
     }
 }
 /// <summary>
 /// 转换playlist的model
 /// </summary>
 /// <param name="dr"></param>
 /// <returns></returns>
 private AMS.Model.AMS_PlayList DataRowToAMS_PlayListModel(DataRow dr)
 {
     AMS.Model.AMS_PlayList model = new Model.AMS_PlayList();
     model          = AMS.Model.AMS_PlayList.Parse(dr["PlayList"].ToString());
     model.Describe = dr["Describe"].ToString();
     model.Id       = int.Parse(dr["Id"].ToString());
     if (dr.Table.Columns.Contains("OperatorName"))
     {
         model.OperatorName = dr["OperatorName"].ToString();
     }
     model.PlayListName = dr["PlayListName"].ToString();
     model.ReleaseDate  = DateTime.Parse(dr["ReleaseDate"].ToString());
     return(model);
 }
 public string DeletePlayList(Model.AMS_PlayList model)
 {
     try
     {
         if (!dal_Playlist.Delete(model.Id))
         {
             return("修改播放列表失败!");
         }
         return("");
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
 public Model.AMS_PlayList GetPlayListByID(int id)
 {
     try
     {
         Model.AMS_PlayList modellist = new Model.AMS_PlayList();
         StringBuilder      sql       = new StringBuilder();
         sql.AppendFormat("ID={0}", id);
         DataSet ds = dal_PlaylistView.GetList(sql.ToString());
         modellist = DataRowToAMS_PlayListModel(ds.Tables[0].Rows[0]);
         return(modellist);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public string UpdatePlayList(Model.AMS_PlayList model)
 {
     try
     {
         AMS.Model.AMS_PlayList sameModel = dal_Playlist.GetModel(model.Number);
         if (sameModel != null && sameModel.Id != model.Id)
         {
             return("播放列表编号重复!");
         }
         model.PlayList = Model.AMS_PlayList.ToXml(model);
         if (!dal_Playlist.Update(model))
         {
             return("修改播放列表失败!");
         }
         return("");
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
 public string AddNewPlayList(Model.AMS_PlayList model)
 {
     try
     {
         AMS.Model.AMS_PlayList sameModel = dal_Playlist.GetModel(model.Number);
         if (sameModel != null)
         {
             return("播放列表编号重复!");
         }
         model.PlayList = Model.AMS_PlayList.ToXml(model);
         if (dal_Playlist.Add(model) == 0)
         {
             return("添加播放列表失败!");
         }
         return("");
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
        /// <summary>
        /// 获取播放列表,下载列表中的文件,并执行上传。
        /// 往数据库中添加,如果已存在,则执行更新
        ///
        ///  开始下载文件之前先判断文件在缓存中是否存在,已经存在则跳过,不再下载。
        ///  下载中某个文件下载错误,则返回下载失败的信息。
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static bool GetPlaylist(int id)
        {
            try
            {
                FileOperate advertfileOperate = new FileOperate();
                SeatManage.Bll.FileOperate seatmanagefileOperate = new SeatManage.Bll.FileOperate();
                seatmanagefileOperate.Downloaded += new SeatManage.Bll.EventHandleFileTransport(seatmanagefileOperate_Downloaded);
                advertfileOperate.DownloadError  += new EventHandleFileOperateError(fileOperate_DownloadError);
                Model.AMS_PlayList model = AMS.ServiceProxy.IPlayListService.GetPlayListByID(id);

                foreach (Model.AMS_VideoItem video in model.MediaFiles)
                {
                    string fileFullName = string.Format(@"{0}{1}", ServiceSet.TempFilePath, video.ReRelativeUrl);
                    //开始下载文件
                    if (!File.Exists(fileFullName))
                    {
                        bool   downloadResult = false;
                        string error          = advertfileOperate.FileDownLoad(fileFullName, video.ReRelativeUrl, SeatManage.EnumType.SeatManageSubsystem.MediaFiles);

                        if (error == "")
                        {
                            downloadResult = true;
                        }
                        else
                        {
                            downloadResult = false;
                        }

                        if (!downloadResult)
                        {
                            //下载失败,直接返回false
                            return(false);
                        }
                    }
                }

                foreach (Model.AMS_VideoItem video in model.MediaFiles)
                {
                    string fileFullName = string.Format(@"{0}{1}", ServiceSet.TempFilePath, video.ReRelativeUrl);
                    //文件下载完成,执行上传操作
                    bool uploadResult = seatmanagefileOperate.UpdateFile(fileFullName, video.ReRelativeUrl, SeatManage.EnumType.SeatManageSubsystem.MediaFiles);
                    if (!uploadResult)
                    {
                        //上传失败,直接返回false,不再尝试其他操作
                        return(false);
                    }
                }

                //判断播放列表是否存在
                SeatManage.ClassModel.AMS_PlayListMd5 seatPlayList = SeatManage.Bll.AMS_PlayList.GetMd5PlayListByNum(model.Number);
                if (seatPlayList != null)
                {
                    //播放列表存在,执行更新操作
                    SeatManage.ClassModel.AMS_PlayListMd5 playlist = SeatManage.ClassModel.AMS_PlayListMd5.Parse(model.ToXml());
                    seatPlayList.PlayListNo = model.Number;
                    playlist.ReleaseDate    = model.ReleaseDate;
                    SeatManage.Bll.AMS_PlayList.UpdateMd5Playlist(playlist);
                    //执行完成通知终端更新播放列表
                    List <SeatManage.ClassModel.TerminalInfoV2> terminalList = SeatManage.Bll.TerminalOperatorService.GetAllTeminalInfo();
                    foreach (SeatManage.ClassModel.TerminalInfoV2 terminal in terminalList)
                    {
                        terminal.IsUpdatePlayList = true;
                        SeatManage.Bll.TerminalOperatorService.UpdateTeminalSetting(terminal);
                    }
                }
                else
                {
                    SeatManage.ClassModel.AMS_PlayListMd5 playlist = SeatManage.ClassModel.AMS_PlayListMd5.Parse(model.ToXml());
                    playlist.ReleaseDate = model.ReleaseDate;
                    SeatManage.Bll.AMS_PlayList.AddMd5Playlist(playlist);
                }
                foreach (Model.AMS_VideoItem video in model.MediaFiles)
                {
                    string fileFullName = string.Format(@"{0}{1}", ServiceSet.TempFilePath, video.ReRelativeUrl);
                    if (File.Exists(fileFullName))
                    {
                        File.Delete(fileFullName);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 获取命令明细列表
        /// </summary>
        /// <param name="schoolId"></param>
        /// <param name="commandType"></param>
        /// <param name="handleResult"></param>
        /// <returns></returns>
        public List <Model.AMS_CommandDetail> GetCommandDetailList(string schoolId, AMS.Model.Enum.CommandType commandType, AMS.Model.Enum.CommandHandleResult handleResult)
        {
            StringBuilder str = new StringBuilder();
            List <AMS.Model.AMS_CommandDetail> commandDetailList = new List <Model.AMS_CommandDetail>();
            List <Model.View_CommandList>      commandList       = GetCommandList(schoolId, commandType, handleResult);

            foreach (AMS.Model.View_CommandList cmdModel in commandList)
            {
                AMS.Model.AMS_CommandDetail cmd = new Model.AMS_CommandDetail();
                switch (cmdModel.Command)
                {
                case Model.Enum.CommandType.Caputre:
                    cmd.ContentDescribe = "获取截图";
                    cmd.ContentName     = "获取截图";
                    break;

                case Model.Enum.CommandType.HardAd:
                    Model.AMS_HardAd hardAd = Dal_HardAd.GetModelByNum(cmdModel.CommandId.Value);
                    cmd.ContentName     = hardAd.Name;
                    cmd.ContentDescribe = hardAd.Describe;
                    cmd.ContentNumber   = hardAd.Number;
                    cmd.ContentID       = hardAd.ID;
                    break;

                case Model.Enum.CommandType.Playlist:
                    if (dal_Playlist.GetList(string.Format(" id={0}", cmdModel.CommandId.Value)).Tables[0].Rows.Count > 0)
                    {
                        Model.AMS_PlayList playList = DataRowToAMS_PlayListModel(dal_PlaylistView.GetList(string.Format(" id={0}", cmdModel.CommandId.Value)).Tables[0].Rows[0]);
                        cmd.ContentName     = playList.PlayListName;
                        cmd.ContentDescribe = playList.Describe;
                        cmd.ContentNumber   = playList.Number;
                        cmd.ContentID       = playList.Id;
                    }
                    break;

                case Model.Enum.CommandType.PrintTemplate:
                    if (dal_PrintTemplateView.GetList(string.Format(" id={0}", cmdModel.CommandId.Value)).Tables[0].Rows.Count > 0)
                    {
                        Model.AMS_PrintTemplate printTemplate = DataRowToAMS_PrintTemplateModel(dal_PrintTemplateView.GetList(string.Format(" id={0}", cmdModel.CommandId.Value)).Tables[0].Rows[0]);
                        cmd.ContentName     = printTemplate.Name;
                        cmd.ContentNumber   = printTemplate.Number;
                        cmd.ContentDescribe = printTemplate.Describe;
                        cmd.ContentID       = printTemplate.Id;
                    }
                    break;

                case Model.Enum.CommandType.ProgramUpgrade:
                    if (dal_ProgramUpgrade.GetList(string.Format(" id={0}", cmdModel.CommandId.Value)).Tables[0].Rows.Count > 0)
                    {
                        Model.ProgramUpgrade program = DataRowToAMS_ProgramUpgradeListModel(dal_ProgramUpgrade.GetList(string.Format(" id={0}", cmdModel.CommandId.Value)).Tables[0].Rows[0]);
                        cmd.ContentName     = ((AMS.Model.Enum.SeatManageSubsystem)program.Application).ToString();
                        cmd.ContentDescribe = program.Remark;
                        cmd.ContentID       = program.Id;
                    }
                    break;

                case Model.Enum.CommandType.SlipCustomer:
                    if (dal_SlipCustomer.GetList(string.Format(" id={0}", cmdModel.CommandId.Value)).Tables[0].Rows.Count > 0)
                    {
                        Model.AMS_SlipCustomer slipcustomer = DataRowToAMS_SlipCustomerModel(dal_SlipCustomerView.GetList(string.Format(" id={0}", cmdModel.CommandId.Value)).Tables[0].Rows[0]);
                        cmd.ContentName     = slipcustomer.SlipName;
                        cmd.ContentNumber   = slipcustomer.Number;
                        cmd.ContentDescribe = slipcustomer.Describe;
                        cmd.ContentID       = slipcustomer.Id;
                    }
                    break;

                case Model.Enum.CommandType.TitleAd:
                    if (Dal_TitleAd.GetList(string.Format(" id={0}", cmdModel.CommandId.Value)).Tables[0].Rows.Count > 0)
                    {
                        Model.AMS_TitleAd titleAd = DataRowToAMS_TitleAd(Dal_TitleAd.GetList(string.Format(" id={0}", cmdModel.CommandId.Value)).Tables[0].Rows[0]);
                        cmd.ContentName   = titleAd.Name;
                        cmd.ContentNumber = titleAd.Num;
                        cmd.ContentID     = titleAd.Id;
                    }
                    break;

                case Model.Enum.CommandType.RollTitles:
                    if (dal.GetModel(string.Format(" id={0}", cmdModel.CommandId.Value)).Tables[0].Rows.Count > 0)
                    {
                        Model.AMS_RollTitles titleAd = DataRowToAMS_RollTitles(dal.GetModel(string.Format(" id={0}", cmdModel.CommandId.Value)).Tables[0].Rows[0]);
                        cmd.ContentName   = titleAd.Name;
                        cmd.ContentNumber = titleAd.Num;
                        cmd.ContentID     = titleAd.ID;
                    }
                    break;
                }

                cmd.Command                = cmdModel.Command;
                cmd.FinishFlag             = cmdModel.FinishFlag;
                cmd.FinishTime             = cmdModel.FinishTime;
                cmd.ID                     = cmdModel.ID;
                cmd.OperatorBranchName     = cmdModel.OperatorBranchName;
                cmd.OperatorLoginId        = cmdModel.OperatorLoginId;
                cmd.OperatorPwd            = cmdModel.OperatorPwd;
                cmd.OperatorRemark         = cmdModel.OperatorRemark;
                cmd.OperatorName           = cmdModel.OperatorName;
                cmd.ReleaseTime            = cmdModel.ReleaseTime;
                cmd.SchoolAddress          = cmdModel.SchoolAddress;
                cmd.SchoolCardInfo         = cmdModel.SchoolCardInfo;
                cmd.SchoolConnectionString = cmdModel.SchoolConnectionString;
                cmd.SchoolDescribe         = cmdModel.SchoolDTUip;
                cmd.SchoolInterfaceInfo    = cmdModel.SchoolInterfaceInfo;
                cmd.SchoolLinkMan          = cmdModel.SchoolLinkMan;
                cmd.SchoolName             = cmdModel.SchoolName;
                cmd.SchoolNum              = cmdModel.SchoolNum;
                cmd.SchoolProvince         = cmdModel.SchoolProvince;
                commandDetailList.Add(cmd);
            }

            return(commandDetailList);
        }