void t_Elapsed(object sender, ElapsedEventArgs e)
 {
     t.Stop();
     try
     {
         DateTime nowDT = SeatManage.Bll.ServiceDateTime.Now;
         List <SeatManage.ClassModel.AMS_Advertisement> modelList = SeatManage.Bll.AdvertisementOperation.GetAdList(false, SeatManage.EnumType.AdType.SlipCustomerAd);
         foreach (AMS_Advertisement item in modelList)
         {
             CouponsInfo coupons = CouponsInfo.ToModel(item.AdContent);
             for (int i = 0; i < coupons.PopItemList.Count; i++)
             {
                 if (coupons.PopItemList[i].EffectDate > nowDT || coupons.PopItemList[i].EndDate < nowDT)
                 {
                     coupons.PopItemList.Remove(coupons.PopItemList[i]);
                     i--;
                 }
             }
             coupons.ID = item.ID;
             CouponsList[coupons.Station].Add(coupons);
         }
         SeatManage.Bll.FileOperate getImage = new SeatManage.Bll.FileOperate();
         foreach (KeyValuePair <int, ObservableCollection <CouponsInfo> > item in _CouponsList)
         {
             for (int i = 0; i < item.Value.Count; i++)
             {
                 for (int j = 0; j < item.Value[i].ImageFilePath.Count; j++)
                 {
                     string imageName = string.Format("{0}{1}", PlayerSetting.SysPath + "\\CouponsImage\\", item.Value[i].ImageFilePath[j]);
                     getImage.FileDownLoad(imageName, item.Value[i].ImageFilePath[j], SeatManage.EnumType.SeatManageSubsystem.SlipCustomerAd);
                 }
             }
             if (item.Value.Count == 0)
             {
                 CouponsInfo coupons = new CouponsInfo();
                 coupons.Num       = "";
                 coupons.LogoImage = PlayerSetting.DefaultVideosPath + PlayerSetting.DefaultVideo;
                 item.Value.Add(coupons);
             }
         }
         t1.Stop();
         if (ScrollStart != null)
         {
             ScrollStart(this, new EventArgs());
         }
     }
     catch (Exception ex)
     {
         if (looptime > 300)
         {
             t1.Stop();
         }
         else
         {
             t.Start();
         }
     }
 }
 /// <summary>
 /// 获取更新数据
 /// </summary>
 public void GetData()
 {
     foreach (SeatManage.ClassModel.PlaylistItemInfo item in PlaylistModel.MediaPlayList)
     {
         SeatManage.Bll.FileOperate fileDownload = new SeatManage.Bll.FileOperate();
         string filePath = string.Format(@"{0}temp\{1}", AppDomain.CurrentDomain.BaseDirectory, item.MediaFileName.Split('_')[1]);
         if (fileDownload.FileDownLoad(filePath, item.MediaFileName, SeatManage.EnumType.SeatManageSubsystem.PlaylistAd))
         {
             VideoItems.Add(GetNewItme(filePath));
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 下载优惠券图片
 /// </summary>
 /// <param name="list"></param>
 void DownSilpCustomer(List <SeatManage.ClassModel.AMS_SlipCustomer> list)
 {
     try
     {
         SeatManage.Bll.FileOperate getImage = new SeatManage.Bll.FileOperate();
         for (int i = 0; i < list.Count; i++)
         {
             SeatManage.ClassModel.AMS_SlipCustomer model = list[i];
             string printlogoName = GetLogoFileName(model.SlipTemplate);
             string printlogoPath = string.Format("{0}{1}", PlayerSetting.SysPath + "\\SlipImage\\", GetLogoFileName(model.SlipTemplate));
             string imageName     = string.Format("{0}{1}", PlayerSetting.SysPath + "\\SlipImage\\", model.ImageName);
             string logoName      = string.Format("{0}{1}", PlayerSetting.SysPath + "\\SlipImage\\", model.CustomerLogo);
             getImage.FileDownLoad(printlogoPath, printlogoName, SeatManage.EnumType.SeatManageSubsystem.SlipCustomer);
             getImage.FileDownLoad(imageName, model.ImageName, SeatManage.EnumType.SeatManageSubsystem.SlipCustomer);
             getImage.FileDownLoad(logoName, model.CustomerLogo, SeatManage.EnumType.SeatManageSubsystem.SlipCustomer);
         }
         string juneberryLogoPath = string.Format("{0}{1}", PlayerSetting.SysPath + "\\SlipImage\\", "南京智佰闻欣logo.png");
         getImage.FileDownLoad(juneberryLogoPath, "南京智佰闻欣logo.png", SeatManage.EnumType.SeatManageSubsystem.SlipCustomer);
     }
     catch (Exception ex)
     {
         SeatManage.SeatManageComm.WriteLog.Write(ex.Message);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 下载图片并且获取本地图片路径
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        private BitmapImage ImageSaveLocation(string imageName)
        {
            string filePath = string.Format(@"{0}temp\{1}", AppDomain.CurrentDomain.BaseDirectory, imageName.Split('_')[1]);

            if (!File.Exists(filePath))
            {//如果本地文件不存在,则下载
                SeatManage.Bll.FileOperate fileDownload = new SeatManage.Bll.FileOperate();
                if (!fileDownload.FileDownLoad(filePath, imageName, SeatManage.EnumType.SeatManageSubsystem.SchoolNotice))
                {
                    return
                        (null);
                }
            }
            BitmapImage img = new BitmapImage(new Uri(filePath, UriKind.RelativeOrAbsolute));

            return(img);
        }
 /// <summary>
 /// 下载视频文件
 /// </summary>
 /// <param name="vm">视频文件相对路径</param>
 public void DownloadFile(List <string> videoFilePaths)
 {
     SeatManage.Bll.FileOperate fi = new SeatManage.Bll.FileOperate();
     fi.DownloadError += new SeatManage.Bll.EventHandleFileOperateError(fi_DownloadError);
     //执行下载操作
     for (int i = 0; i < videoFilePaths.Count; i++)
     {
         string path     = videoFilePaths[i];
         string fullPath = string.Format("{0}{1}", PlayerSetting.DefaultVideosPath, path);
         try
         {
             PlayListHandleEvent(this, string.Format("正在下载{0}", path));
             fi.FileDownLoad(fullPath, path, SeatManage.EnumType.SeatManageSubsystem.PlaylistAd);
         }
         catch (Exception ex)
         {
             SeatManage.SeatManageComm.WriteLog.Write(ex.Message);
         }
     }
 }
 /// <summary>
 /// 获取通知
 /// </summary>
 private void GetAdvert()
 {
     try
     {
         string path = AppDomain.CurrentDomain.BaseDirectory;
         SeatManage.Bll.FileOperate fileoperator = new SeatManage.Bll.FileOperate();
         List <AMS_Advertisement>   advertList   = SeatManage.Bll.AdvertisementOperation.GetAdList(false, AdType.None);
         foreach (AMS_Advertisement advert in advertList)
         {
             switch (advert.Type)
             {
             case AdType.SchoolNotice:
             {
                 SchoolNoteInfo model = SchoolNoteInfo.ToModel(advert.AdContent);
                 model.ID = advert.ID;
                 model.InitializeUsage();
                 if (!Directory.Exists(path + "images\\AdImage\\NoteImage\\"))
                 {
                     Directory.CreateDirectory(path + "images\\AdImage\\NoteImage\\");
                 }
                 if (fileoperator.FileDownLoad(path + "images\\AdImage\\NoteImage\\" + model.NoteImagePath, model.NoteImagePath, SeatManageSubsystem.SchoolNotice))
                 {
                     _SchoolNote.Add(model);
                 }
                 else
                 {
                     SeatManage.SeatManageComm.WriteLog.Write(string.Format("校园通知初始化失败:{0}", advert.Num));
                 }
             }
             break;
             }
         }
     }
     catch (Exception ex)
     {
         SeatManage.SeatManageComm.WriteLog.Write(string.Format("校园通知初始化失败:{0}", ex.Message));
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// 上传设备截图
        /// </summary>
        /// <returns></returns>
        public static bool UpdateCaputre()
        {
            try
            {
                List <SeatManage.ClassModel.TerminalInfoV2> terminalList = SeatManage.Bll.TerminalOperatorService.GetAllTeminalInfo();
                SeatManage.Bll.FileOperate   seatfileTransport           = new SeatManage.Bll.FileOperate();
                AMS.ServiceProxy.FileOperate advertTransport             = new AMS.ServiceProxy.FileOperate();
                foreach (SeatManage.ClassModel.TerminalInfoV2 terminal in terminalList)
                {
                    if (!string.IsNullOrEmpty(terminal.ScreenshotPath))
                    {
                        AMS.Model.AMS_Device model = AMS.ServiceProxy.IDevice.GetDevicebyNo(terminal.ClientNo);
                        if (model == null)
                        {
                            return(true);//如果媒体服务器上获取不到信息,直接返回true,以便结束命令。
                        }

                        string fileFullName = string.Format("{0}{1}", ServiceSet.TempFilePath, terminal.ScreenshotPath);
                        if (seatfileTransport.FileDownLoad(fileFullName, terminal.ScreenshotPath, SeatManage.EnumType.SeatManageSubsystem.Caputre))
                        {
                            if (advertTransport.UpdateFile(fileFullName, terminal.ScreenshotPath, SeatManage.EnumType.SeatManageSubsystem.Caputre) == "")
                            {
                                File.Delete(fileFullName);
                                //上传完成,更新一下截图路径。
                                model.CaputrePath = terminal.ScreenshotPath;
                                AMS.ServiceProxy.IDevice.UpdateDeviceModel(model);
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 8
0
        ///// <summary>
        ///// 获取本地的文件更新信息
        ///// </summary>
        ///// <param name="system">系统名称</param>
        ///// <returns></returns>
        //private FileUpdateInfo GetLocalUpdateInfo(SeatManage.EnumType.SeatManageSubsystem system)
        //{
        //    string sysDirectory = string.Format(@"{0}{1}\updater.xml", baseDirectory, system.ToString());
        //    if (File.Exists(sysDirectory))
        //    {
        //        FileStream fs = new FileStream(sysDirectory, FileMode.Open);

        //        StreamReader streamReader = new StreamReader(fs);
        //        streamReader.BaseStream.Seek(0, SeekOrigin.Begin);
        //        string arry = "";
        //        string strLine = streamReader.ReadLine();
        //        strLine = streamReader.ReadToEnd();
        //        streamReader.Close();
        //        streamReader.Dispose();
        //        fs.Close();
        //        fs.Dispose();
        //        Console.Write(arry);
        //        Console.ReadLine();
        //        if (strLine != null)
        //        {
        //            FileUpdateInfo updateInfo = FileUpdateInfo.Convert(strLine);
        //            return updateInfo;
        //        }
        //        else
        //        {
        //            return null;
        //        }
        //    }
        //    else
        //    {
        //        return null;
        //    }
        //}

        public void DownloadUpdateFiles()
        {
            SeatManage.EnumType.SeatManageSubsystem mysystem = SeatManage.EnumType.SeatManageSubsystem.Mediaplayer;

            FileUpdateInfo        serviceUpateInfo = SeatManage.Bll.FileTransportBll.GetUpdateInfo(mysystem);
            List <FileSimpleInfo> isUpdateFiles    = null;

            if (serviceUpateInfo != null)
            {
                //下载所有Xml中包含的文件,不对比本地文件版本
                isUpdateFiles = serviceUpateInfo.BuildSystemFileSilmpleList();// GetNewVerFiles(serviceUpateInfo, mysystem);//下载播放器
                for (int i = 0; i < isUpdateFiles.Count; i++)
                {
                    //TODO:把文件先下载到临时文件夹中,下载无误,再移动到指定目录中。 (以后优化)

                    string sysDirectory = string.Format(@"{0}{1}\{2}", baseDirectory, mysystem.ToString(), isUpdateFiles[i].Name);
                    if (!downloadFile.FileDownLoad(sysDirectory, isUpdateFiles[i].Name, mysystem))
                    {
                        break;
                    }
                }
            }
            string StartProgram = "";

            if (serviceUpateInfo != null)
            {
                StartProgram = serviceUpateInfo.StartProgram;
            }
            else
            {
                StartProgram = ConfigurationManager.AppSettings["MediaPlayerProgram"];
            }
            if (string.IsNullOrEmpty(StartProgram))
            {
                HandlerError("播放器启动失败,没有配置媒体播放器启动程序。");
            }
            else
            {
                string mediaplayerStartPath = string.Format(@"{0}{1}\{2}", baseDirectory, mysystem.ToString(), StartProgram);
                if (File.Exists(mediaplayerStartPath))
                {
                    System.Diagnostics.Process.Start(mediaplayerStartPath);
                }
                else
                {
                    if (HandlerError != null)
                    {
                        HandlerError(string.Format("播放器启动失败,文件{0}不存在。", mediaplayerStartPath));
                    }
                }
            }
            StartProgram = "";


            mysystem         = SeatManage.EnumType.SeatManageSubsystem.SeatClient;
            serviceUpateInfo = SeatManage.Bll.FileTransportBll.GetUpdateInfo(mysystem);
            if (serviceUpateInfo != null)
            {
                //下载所有Xml中包含的文件,不对比本地文件版本
                isUpdateFiles = serviceUpateInfo.BuildSystemFileSilmpleList();// GetNewVerFiles(serviceUpateInfo, mysystem); //播放器下载完成下载选座终端。
                for (int i = 0; i < isUpdateFiles.Count; i++)
                {
                    string sysDirectory = string.Format(@"{0}{1}\{2}", baseDirectory, mysystem.ToString(), isUpdateFiles[i].Name);
                    if (!downloadFile.FileDownLoad(sysDirectory, isUpdateFiles[i].Name, mysystem))
                    {
                        break;
                    }
                }
                serviceUpateInfo.Save(string.Format(@"{0}{1}\updater.xml", baseDirectory, mysystem.ToString()));//下载完成,保存信息
            }

            if (serviceUpateInfo != null)
            {
                StartProgram = serviceUpateInfo.StartProgram;
            }
            else
            {
                StartProgram = ConfigurationManager.AppSettings["SeatClientProgram"];
            }
            if (string.IsNullOrEmpty(StartProgram))
            {
                HandlerError("选座终端启动失败,没有配置选座终端启动程序。");
            }
            else
            {
                string seatClient = string.Format(@"{0}{1}\{2}", baseDirectory, mysystem.ToString(), StartProgram);
                if (File.Exists(seatClient))
                {
                    System.Diagnostics.Process.Start(seatClient);
                }
                else
                {
                    HandlerError(string.Format("选座终端启动失败,文件{0}不存在。", seatClient));
                }
            }
            if (Downloaded != null)//通知终端下载已经完成
            {
                Downloaded(this, new EventArgs());
            }
        }
        /// <summary>
        /// 获取广告
        /// </summary>
        private void GetAdvert()
        {
            try
            {
                string path = AppDomain.CurrentDomain.BaseDirectory;
                SeatManage.Bll.FileOperate fileoperator = new SeatManage.Bll.FileOperate();
                List <AMS_Advertisement>   advertList   = SeatManage.Bll.AdvertisementOperation.GetAdList(false, AdType.None);
                foreach (AMS_Advertisement advert in advertList)
                {
                    switch (advert.Type)
                    {
                    case AdType.PopAd:
                    {
                        if (_popAdvert != null)
                        {
                            break;
                        }
                        _popAdvert    = PopAdvertInfo.ToModel(advert.AdContent);
                        _popAdvert.ID = advert.ID;
                        _popAdvert.InitializeUsage();
                        if (!Directory.Exists(path + "images\\AdImage\\PopImage\\"))
                        {
                            Directory.CreateDirectory(path + "images\\AdImage\\PopImage\\");
                        }
                        if (!fileoperator.FileDownLoad(path + "images\\AdImage\\PopImage\\" + _popAdvert.PopImagePath, _popAdvert.PopImagePath, SeatManageSubsystem.PopAd))
                        {
                            _popAdvert = null;
                            SeatManage.SeatManageComm.WriteLog.Write(string.Format("弹窗广告初始化失败:{0}", advert.Num));
                        }
                    }
                    break;

                    case AdType.PromotionAd:
                    {
                        PromotionAdvertInfo model = PromotionAdvertInfo.ToModel(advert.AdContent);
                        model.ID = advert.ID;
                        model.InitializeUsage();
                        if (!Directory.Exists(path + "images\\AdImage\\PromotionImage\\"))
                        {
                            Directory.CreateDirectory(path + "images\\AdImage\\PromotionImage\\");
                        }
                        if (fileoperator.FileDownLoad(path + "images\\AdImage\\PromotionImage\\" + model.AdImagePath, model.AdImagePath, SeatManageSubsystem.PromotionAd))
                        {
                            _promotionAdvert.Add(model);
                        }
                        else
                        {
                            SeatManage.SeatManageComm.WriteLog.Write(string.Format("推广广告初始化失败:{0}", advert.Num));
                        }
                    }
                    break;

                    case AdType.ReaderAd:
                    {
                        if (_readerAdvert != null)
                        {
                            break;
                        }
                        _readerAdvert    = ReaderAdvertInfo.ToModel(advert.AdContent);
                        _readerAdvert.ID = advert.ID;
                        _readerAdvert.InitializeUsage();
                        if (!Directory.Exists(path + "images\\AdImage\\ReaderImage\\"))
                        {
                            Directory.CreateDirectory(path + "images\\AdImage\\ReaderImage\\");
                        }
                        if (!fileoperator.FileDownLoad(path + "images\\AdImage\\ReaderImage\\" + _readerAdvert.ReaderAdImagePath, _readerAdvert.ReaderAdImagePath, SeatManageSubsystem.ReaderAd))
                        {
                            _readerAdvert = null;
                            SeatManage.SeatManageComm.WriteLog.Write(string.Format("读者广告初始化失败:{0}", advert.Num));
                        }
                    }
                    break;

                    case AdType.SchoolNotice:
                    {
                        SchoolNoteInfo model = SchoolNoteInfo.ToModel(advert.AdContent);
                        model.ID = advert.ID;
                        model.InitializeUsage();
                        if (!Directory.Exists(path + "images\\AdImage\\NoteImage\\"))
                        {
                            Directory.CreateDirectory(path + "images\\AdImage\\NoteImage\\");
                        }
                        if (fileoperator.FileDownLoad(path + "images\\AdImage\\NoteImage\\" + model.NoteImagePath, model.NoteImagePath, SeatManageSubsystem.SchoolNotice))
                        {
                            _schoolNote.Add(model);
                        }
                        else
                        {
                            SeatManage.SeatManageComm.WriteLog.Write(string.Format("推广广告初始化失败:{0}", advert.Num));
                        }
                    }
                    break;

                    case AdType.TitleAd:
                    {
                        _titleAdvert    = TitleAdvertInfoV2.ToModel(advert.AdContent);
                        _titleAdvert.ID = advert.ID;
                        _titleAdvert.InitializeUsage();
                    }
                    break;
                    }
                }
                _userGuide = SeatManage.Bll.T_SM_SystemSet.GetUserGuide();
                if (_userGuide != null)
                {
                    if (!Directory.Exists(path + "images\\AdImage\\UserGuide\\"))
                    {
                        Directory.CreateDirectory(path + "images\\AdImage\\UserGuide\\");
                    }
                    foreach (string file in _userGuide.ImageFilePath)
                    {
                        if (!fileoperator.FileDownLoad(path + "images\\AdImage\\UserGuide\\" + file, file, SeatManageSubsystem.UserGuide))
                        {
                            SeatManage.SeatManageComm.WriteLog.Write("使用手册初始化失败");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                SeatManage.SeatManageComm.WriteLog.Write(string.Format("广告初始化失败:{0}", ex.Message));
            }
        }