/// <summary>
 /// 保存
 /// </summary>
 /// <returns></returns>
 public bool Save()
 {
     SeatManage.Bll.FileOperate          fileOperation = new SeatManage.Bll.FileOperate();
     SeatManage.ClassModel.UserGuideInfo model         = new SeatManage.ClassModel.UserGuideInfo();
     foreach (GuideImageItem item in _GuideImages)
     {
         if (!fileOperation.UpdateFile(item.ImageUrl, item.ImageNmae, SeatManage.EnumType.SeatManageSubsystem.UserGuide))
         {
             ErrorMessage = string.Format("文件{0}上传失败!", item.ImageNmae);
             return(false);
         }
         model.ImageFilePath.Add(item.ImageNmae);
     }
     model.XMLContent = model.ToXml();
     if (SeatManage.Bll.T_SM_SystemSet.UpdateUserGuide(model))
     {
         MessageBoxWindow mbw = new MessageBoxWindow();
         mbw.viewModel.Message = "保存成功!";
         mbw.viewModel.Type    = Code.MessageBoxType.Success;
         mbw.ShowDialog();
         return(true);
     }
     else
     {
         ErrorMessage = string.Format("保存失败!");
         return(false);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 获取更新程序
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static bool GetUpgrade(int id)
        {
            Model.ProgramUpgradeModel programModel = BLL.ProgramUpgradeBLL.GetProgramInfoById(id);
            if (programModel != null)
            {
                FileOperate advertfileOperate = new FileOperate();
                SeatManage.EnumType.SeatManageSubsystem systemType = (SeatManage.EnumType.SeatManageSubsystem)(int) programModel.Application;

                SeatManage.Bll.FileOperate           seatmanagefileOperate = new SeatManage.Bll.FileOperate();
                SeatManage.ClassModel.FileUpdateInfo programInfo           = SeatManage.ClassModel.FileUpdateInfo.Convert(programModel.AutoUpdaterXml);
                List <string> filePath = programInfo.BuildUpdateFilePaths();
                foreach (string path in filePath)
                {
                    string fullPath = string.Format("{0}{1}", ServiceSet.TempFilePath, path);
                    //文件下载
                    if (!advertfileOperate.FileDownLoad(fullPath, path, systemType))
                    {
                        return(false);
                    }
                    if (!seatmanagefileOperate.UpdateFile(fullPath, path, systemType))
                    {
                        return(false);
                    }
                }
                //执行完成,不需要更新数据库。
                //上传完毕删除本地的文件以及文件夹。
                SeatManage.ClassModel.FileUpdateInfo.DelDirectorys(ServiceSet.TempFilePath);
                return(true);
            }
            return(true);
        }
 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.º 5
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="sender"></param>
        /// <param name="e"></param>
        void t_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            t.Stop();

            //编辑文件名
            string imagefilepath = PlayerSetting.ImagelocadPath;

            if (imagefilepath.Length - 1 != imagefilepath.LastIndexOf("\\"))
            {
                imagefilepath += "\\" + PlayerSetting.SchoolNo + PlayerSetting.DeviceNo + ".jpg";
            }
            else
            {
                imagefilepath += PlayerSetting.SchoolNo + PlayerSetting.DeviceNo + ".jpg";
            }
            try
            {
                //获取截图
                AMS.Mediaplayer.Caputre.Caputre.Capture(imagefilepath);
                SeatManage.Bll.FileOperate fileOperate = new SeatManage.Bll.FileOperate();
                fileOperate.UpdateFile(imagefilepath, string.Format("{0}{1}.jpg", PlayerSetting.SchoolNo, PlayerSetting.DeviceNo), SeatManage.EnumType.SeatManageSubsystem.Caputre);
            }
            catch (Exception ex)
            {
                SeatManage.SeatManageComm.WriteLog.Write("设备截图失败:" + ex.Message);
            }
            try
            {
                //更新数据库状态
                SeatManage.ClassModel.TerminalInfoV2 terminal = SeatManage.Bll.TerminalOperatorService.GetTeminalSetting(PlayerSetting.DeviceNo); //AMS.AdvertisementManage_DAL.AMS_Device_DAL.UpdataDeviceStatus(_DeviceNo, "ScreenCaputre/" + _DeviceNo + ".jpg");
                terminal.ScreenshotPath   = string.Format("{0}{1}.jpg", PlayerSetting.SchoolNo, PlayerSetting.DeviceNo);
                terminal.StatusUpdateTime = SeatManage.Bll.ServiceDateTime.Now;
                SeatManage.Bll.TerminalOperatorService.UpdateTeminalSetting(terminal);
            }
            catch (Exception ex)
            {
                SeatManage.SeatManageComm.WriteLog.Write("上传设备运行状态失败:" + ex.Message);
            }
            finally
            {
                t.Start();
            }
        }
 /// <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.º 9
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.º 10
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);
     }
 }
 public bool Save()
 {
     try
     {
         if (string.IsNullOrEmpty(PlaylistModel.Num))
         {
             ErrorMessage = "播放列表的编号不能为空!";
             return(false);
         }
         if (string.IsNullOrEmpty(PlaylistModel.Name))
         {
             ErrorMessage = "播放列表的名称不能为空!";
             return(false);
         }
         if (PlaylistModel.EffectDate == null)
         {
             ErrorMessage = "播放列表的开始时间不能为空!";
             return(false);
         }
         if (PlaylistModel.EndDate == null)
         {
             ErrorMessage = "播放列表的结束时间不能为空!";
             return(false);
         }
         if (PlaylistModel.EndDate < PlaylistModel.EffectDate)
         {
             ErrorMessage = "播放列表的结束时间要大于开始时间!";
             return(false);
         }
         if (VideoItems.Count == 0)
         {
             ErrorMessage = "当前没有需要播放的文件!";
             return(false);
         }
         if (!IsEdit && SeatManage.Bll.AdvertisementOperation.GetAdModel(PlaylistModel.Num, SeatManage.EnumType.AdType.TitleAd) != null)
         {
             ErrorMessage = "已存在存在相同名称或编号的播放列表!";
             return(false);
         }
         PlaylistModel.ImageFilePath.Clear();
         PlaylistModel.MediaPlayList.Clear();
         foreach (ViewModel_VideoItem item in VideoItems)
         {
             SeatManage.ClassModel.PlaylistItemInfo newItem = new SeatManage.ClassModel.PlaylistItemInfo();
             newItem = item.VideoItemModel;
             newItem.MediaFileName = PlaylistModel.Num + "_" + newItem.MediaFileName.Substring(newItem.MediaFileName.LastIndexOf("\\") + 1);
             PlaylistModel.MediaPlayList.Add(newItem);
             bool isnew = true;
             foreach (string samefile in PlaylistModel.ImageFilePath)
             {
                 if (samefile == item.VideoFliePath)
                 {
                     isnew = false;
                     break;
                 }
             }
             if (isnew)
             {
                 PlaylistModel.ImageFilePath.Add(item.VideoFliePath);
             }
         }
         string resultstr = "";
         //TODO:保存&文件上传
         SeatManage.Bll.FileOperate fileUpload = new SeatManage.Bll.FileOperate();
         foreach (string upFileItem in PlaylistModel.ImageFilePath)
         {
             if (!fileUpload.UpdateFile(upFileItem, PlaylistModel.Num + "_" + upFileItem.Substring(upFileItem.LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.PlaylistAd))
             {
                 ErrorMessage = string.Format("文件{0}上传失败!{1}", upFileItem, resultstr);
                 return(false);
             }
         }
         //更换文件名
         for (int i = 0; i < PlaylistModel.ImageFilePath.Count; i++)
         {
             PlaylistModel.ImageFilePath[i] = PlaylistModel.Num + "_" + PlaylistModel.ImageFilePath[i].Substring(PlaylistModel.ImageFilePath[i].LastIndexOf("\\") + 1);
         }
         PlaylistModel.Type = SeatManage.EnumType.AdType.PlaylistAd;
         SeatManage.ClassModel.AMS_Advertisement model = new SeatManage.ClassModel.AMS_Advertisement();
         model.Type       = SeatManage.EnumType.AdType.PlaylistAd;
         model.ID         = PlaylistModel.ID;
         model.Name       = PlaylistModel.Name;
         model.Num        = PlaylistModel.Num;
         model.AdContent  = PlaylistModel.ToXml();
         model.EffectDate = PlaylistModel.EffectDate;
         model.EndDate    = PlaylistModel.EndDate;
         if (IsEdit)
         {
             //TODO:更新
             resultstr = SeatManage.Bll.AdvertisementOperation.UpdateAdModel(model);
         }
         else
         {
             //DOTO:添加
             resultstr = SeatManage.Bll.AdvertisementOperation.AddAdModel(model);
         }
         if (!string.IsNullOrEmpty(resultstr))
         {
             ErrorMessage = string.Format("保存失败!{0}", resultstr);
             return(false);
         }
         MessageBoxWindow mbw = new MessageBoxWindow();
         mbw.viewModel.Message = "保存成功!";
         mbw.viewModel.Type    = Code.MessageBoxType.Success;
         mbw.ShowDialog();
         return(true);
     }
     catch (Exception ex)
     {
         ErrorMessage = ex.Message;
         return(false);
     }
 }
 /// <summary>
 /// 获取和更新打印模板
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public static bool GetPrintTemplate(int id)
 {
     try
     {
         AMS.Model.AMS_PrintTemplate printTemplate = AMS.ServiceProxy.IPrintTemplateService.GetPrintTemplateByNum(id);
         if (printTemplate != null)
         {
             SeatManage.ClassModel.AMS_PrintTemplateModel model = new SeatManage.ClassModel.AMS_PrintTemplateModel();
             model.Describe   = printTemplate.Describe;
             model.EndDate    = Convert.ToDateTime(printTemplate.EndDate);
             model.EffectDate = Convert.ToDateTime(printTemplate.EffectDate);
             model.Template   = printTemplate.Template;
             model.Num        = printTemplate.Number;
             List <string> imagesName = GetImagesName(model.Template);
             //下载打印模版中的图片
             AMS.ServiceProxy.FileOperate fileOperate = new AMS.ServiceProxy.FileOperate();
             for (int i = 0; i < imagesName.Count; i++)
             {
                 string fileFullName = string.Format(@"{0}{1}", ServiceSet.TempFilePath, imagesName[i]);
                 if (!File.Exists(fileFullName))//文件不存在,则下载。
                 {
                     if (fileOperate.FileDownLoad(fileFullName, imagesName[i], SeatManage.EnumType.SeatManageSubsystem.SeatSlip) != "")
                     {
                         return(false);//下载失败,返回false;
                     }
                 }
             }
             //下载完成,执行上传操作。
             SeatManage.Bll.FileOperate seatFileOperate = new SeatManage.Bll.FileOperate();
             for (int i = 0; i < imagesName.Count; i++)
             {
                 string fileFullName = string.Format(@"{0}{1}", ServiceSet.TempFilePath, imagesName[i]);
                 if (File.Exists(fileFullName))//文件不存在,则下载。
                 {
                     if (!seatFileOperate.UpdateFile(fileFullName, imagesName[i], SeatManage.EnumType.SeatManageSubsystem.SeatSlip))
                     {
                         return(false);//下载失败,返回false;
                     }
                 }
             }
             if (SeatManage.Bll.T_SM_PrintTemplate.GetPrintTemplateByNum(printTemplate.Number) == null)
             {
                 if (SeatManage.Bll.T_SM_PrintTemplate.AddPrintTemplate(model) == SeatManage.EnumType.HandleResult.Successed)
                 {
                     //打印模板添加成功,上传文件
                     for (int i = 0; i < imagesName.Count; i++)
                     {
                         string fileFullName = string.Format(@"{0}{1}", ServiceSet.TempFilePath, imagesName[i]);
                         if (File.Exists(fileFullName))//文件存在则删除。
                         {
                             File.Delete(fileFullName);
                         }
                     }
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }
             else
             {
                 if (SeatManage.Bll.T_SM_PrintTemplate.UpdatePrintTemplate(model) == SeatManage.EnumType.HandleResult.Successed)
                 {
                     //打印模板添加成功,上传文件
                     for (int i = 0; i < imagesName.Count; i++)
                     {
                         string fileFullName = string.Format(@"{0}{1}", ServiceSet.TempFilePath, imagesName[i]);
                         if (File.Exists(fileFullName))//文件存在则删除。
                         {
                             File.Delete(fileFullName);
                         }
                     }
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }
         }
         else
         {
             //如果获取为空的,也作完成操作
             return(true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// 根据ID获取优惠券信息
        /// </summary>
        /// <returns></returns>
        public static bool GetSlipCustomer(int id)
        {
            //TODO:未测试
            try
            {
                Model.AMS_SlipCustomerModel  advertModel           = BLL.SlipReleaseCampusBLL.GetSlipReleaseListById(id);
                AdvertManage.BLL.FileOperate advertfileOperate     = new AdvertManage.BLL.FileOperate();
                SeatManage.Bll.FileOperate   seatmanagefileOperate = new SeatManage.Bll.FileOperate();
                if (advertModel != null)
                {
                    SeatManage.ClassModel.AMS_SlipCustomer seatModel = SeatManage.Bll.AMS_SlipCustomer.GetSlipCustomerByNum(advertModel.Number);
                    if (seatModel == null)
                    {
                        //优惠券在数据库中不存在:先执行下载操作,然后更新
                        string ImageUrlFullName = string.Format(@"{0}{1}", ServiceSet.TempFilePath, advertModel.ImageUrl);
                        try
                        {
                            advertfileOperate.FileDownLoad(ImageUrlFullName, advertModel.ImageUrl, SeatManage.EnumType.SeatManageSubsystem.SlipCustomer);
                        }
                        catch (Exception ex)
                        {
                            SeatManage.SeatManageComm.WriteLog.Write(string.Format("优惠券{0}下载失败:{1}", advertModel.Number, ex.Message));
                        }
                        try
                        {
                            if (seatmanagefileOperate.UpdateFile(ImageUrlFullName, advertModel.ImageUrl, SeatManage.EnumType.SeatManageSubsystem.SlipCustomer))
                            {
                                //上传完成,执行删除操作
                                File.Delete(ImageUrlFullName);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                        catch (Exception ex)
                        {
                            SeatManage.SeatManageComm.WriteLog.Write(string.Format("优惠券{0}上传失败:{1}", advertModel.Number, ex.Message));
                        }
                        string CustomerImagefullName = string.Format(@"{0}{1}", ServiceSet.TempFilePath, advertModel.CustomerImage);
                        advertfileOperate.FileDownLoad(CustomerImagefullName, advertModel.CustomerImage, SeatManage.EnumType.SeatManageSubsystem.SlipCustomer);
                        if (seatmanagefileOperate.UpdateFile(CustomerImagefullName, advertModel.CustomerImage, SeatManage.EnumType.SeatManageSubsystem.SlipCustomer))
                        {
                            File.Delete(CustomerImagefullName);
                        }
                        else
                        {
                            return(false);
                        }
                        if (advertModel.IsPrint)
                        {
                            XmlDocument Templatedoc = new XmlDocument();
                            Templatedoc.LoadXml(advertModel.SlipTemplate);
                            XmlElement  Templateroot   = Templatedoc.DocumentElement;
                            XmlNodeList Templatexnlist = ((XmlNode)Templateroot).ChildNodes;
                            for (int j = 0; j < Templatexnlist.Count; j++)
                            {
                                if (Templatexnlist[j].Name == "Pic")
                                {
                                    try
                                    {
                                        advertfileOperate.FileDownLoad((ServiceSet.TempFilePath + Templatexnlist[j].InnerText), Templatexnlist[j].InnerText, SeatManage.EnumType.SeatManageSubsystem.SlipCustomer);
                                    }
                                    catch (Exception ex)
                                    {
                                        SeatManage.SeatManageComm.WriteLog.Write(string.Format("优惠券{0}下载失败:{1}", advertModel.Number, ex.Message));
                                    }
                                    try
                                    {
                                        if (seatmanagefileOperate.UpdateFile((ServiceSet.TempFilePath + Templatexnlist[j].InnerText), Templatexnlist[j].InnerText, SeatManage.EnumType.SeatManageSubsystem.SlipCustomer))
                                        {
                                            //上传完成,执行删除操作
                                            File.Delete(ServiceSet.TempFilePath + Templatexnlist[j].InnerText);
                                        }
                                        else
                                        {
                                            return(false);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        SeatManage.SeatManageComm.WriteLog.Write(string.Format("优惠券{0}上传失败:{1}", advertModel.Number, ex.Message));
                                    }
                                }
                            }
                        }
                    }

                    if (seatModel != null && seatModel.CampusNum == advertModel.CampusNum)
                    {
                        //获取学校数据库中的优惠券。如果存在并且校区编号相同执行更新。
                        seatModel.CampusNum    = advertModel.CampusNum;
                        seatModel.CustomerLogo = advertModel.CustomerImage;
                        seatModel.EffectDate   = advertModel.EffectDate;
                        seatModel.EndDate      = advertModel.EndDate;
                        seatModel.ImageName    = advertModel.ImageUrl;
                        seatModel.No           = advertModel.Number;
                        seatModel.SlipTemplate = advertModel.SlipTemplate;
                        seatModel.IsPrint      = advertModel.IsPrint;
                        SeatManage.Bll.AMS_SlipCustomer.UpdateSlipCustomer(seatModel);
                    }
                    else
                    {
                        seatModel              = new SeatManage.ClassModel.AMS_SlipCustomer();
                        seatModel.CampusNum    = advertModel.CampusNum;
                        seatModel.CustomerLogo = advertModel.CustomerImage;
                        seatModel.EffectDate   = advertModel.EffectDate;
                        seatModel.EndDate      = advertModel.EndDate;
                        seatModel.ImageName    = advertModel.ImageUrl;
                        seatModel.No           = advertModel.Number;
                        seatModel.SlipTemplate = advertModel.SlipTemplate;
                        seatModel.IsPrint      = advertModel.IsPrint;
                        SeatManage.Bll.AMS_SlipCustomer.AddSlipCustomer(seatModel);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                SeatManage.SeatManageComm.WriteLog.Write(string.Format("获取优惠券客户失败:{0}", ex.Message));
                return(false);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <returns></returns>
        public bool Save()
        {
            try
            {
                if (string.IsNullOrEmpty(_NoteModel.Num))
                {
                    ErrorMessage = "编号不能为空!";
                    return(false);
                }
                if (string.IsNullOrEmpty(_NoteModel.Name))
                {
                    ErrorMessage = "名称不能为空!";
                    return(false);
                }
                if (_NoteImage == null)
                {
                    ErrorMessage = "图片不能为空!";
                    return(false);
                }
                if (_NoteModel.EffectDate == null)
                {
                    ErrorMessage = "开始时间不能为空!";
                    return(false);
                }
                if (_NoteModel.EndDate == null)
                {
                    ErrorMessage = "结束时间不能为空!";
                    return(false);
                }
                if (_NoteModel.EndDate < _NoteModel.EffectDate)
                {
                    ErrorMessage = "结束时间要大于开始时间!";
                    return(false);
                }

                if (!IsEdit && SeatManage.Bll.AdvertisementOperation.GetAdModel(_NoteModel.Num, SeatManage.EnumType.AdType.SchoolNotice) != null)
                {
                    ErrorMessage = "已存在存在相同名称或编号的通知!";
                    return(false);
                }

                string resultstr = "";                //TODO:保存&文件上传
                SeatManage.Bll.FileOperate fileOperation = new SeatManage.Bll.FileOperate();

                if (!fileOperation.UpdateFile(_NoteModel.NoteImagePath, _NoteModel.Num + "_" + _NoteModel.NoteImagePath.Substring(_NoteModel.NoteImagePath.LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.SchoolNotice))
                {
                    ErrorMessage = string.Format("文件{0}上传失败!", _NoteModel.NoteImagePath);
                    return(false);
                }
                //更换文件名
                _NoteModel.NoteImagePath = _NoteModel.Num + "_" + _NoteModel.NoteImagePath.Substring(_NoteModel.NoteImagePath.LastIndexOf("\\") + 1);
                _NoteModel.ImageFilePath.Clear();
                _NoteModel.ImageFilePath.Add(_NoteModel.NoteImagePath);
                _NoteModel.Type = SeatManage.EnumType.AdType.SchoolNotice;

                SeatManage.ClassModel.AMS_Advertisement model = new SeatManage.ClassModel.AMS_Advertisement();
                model.Type       = SeatManage.EnumType.AdType.SchoolNotice;
                model.ID         = _NoteModel.ID;
                model.Name       = _NoteModel.Name;
                model.Num        = _NoteModel.Num;
                model.AdContent  = _NoteModel.ToXml();
                model.EffectDate = _NoteModel.EffectDate;
                model.EndDate    = _NoteModel.EndDate;
                if (IsEdit)
                {
                    //TODO:更新
                    resultstr = SeatManage.Bll.AdvertisementOperation.UpdateAdModel(model);
                }
                else
                {
                    //DOTO:添加
                    resultstr = SeatManage.Bll.AdvertisementOperation.AddAdModel(model);
                }
                if (!string.IsNullOrEmpty(resultstr))
                {
                    ErrorMessage = string.Format("保存失败!{0}", resultstr);
                    return(false);
                }
                MessageBoxWindow mbw = new MessageBoxWindow();
                mbw.viewModel.Message = "保存成功!";
                mbw.viewModel.Type    = Code.MessageBoxType.Success;
                mbw.ShowDialog();
                return(true);
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
                return(false);
            }
        }
        /// <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));
            }
        }
Exemplo n.º 16
0
        /// <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_PlayListMd5Model model = AdvertManage.BLL.AMS_PlayListBLL.GetMd5PlaylistById(id);

                foreach (Model.AMS_VideoMd5Item video in model.VideoFiles)
                {
                    string fileFullName = string.Format(@"{0}{1}", ServiceSet.TempFilePath, video.RelativeUrl);
                    //开始下载文件
                    if (!File.Exists(fileFullName))
                    {
                        bool downloadResult = advertfileOperate.FileDownLoad(fileFullName, video.RelativeUrl, SeatManage.EnumType.SeatManageSubsystem.MediaFiles);
                        if (!downloadResult)
                        {
                            //下载失败,直接返回false
                            return(false);
                        }
                    }
                }

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

                //判断播放列表是否存在
                SeatManage.ClassModel.AMS_PlayListMd5 seatPlayList = SeatManage.Bll.AMS_PlayList.GetMd5PlayListByNum(model.PlayListNo);
                if (seatPlayList != null)
                {
                    //播放列表存在,执行更新操作
                    SeatManage.ClassModel.AMS_PlayListMd5 playlist = SeatManage.ClassModel.AMS_PlayListMd5.Parse(model.ToXml());
                    seatPlayList.PlayListNo = model.PlayListNo;
                    playlist.ReleaseDate    = model.ReleaseDate;
                    SeatManage.Bll.AMS_PlayList.UpdateMd5Playlist(playlist);
                    //执行完成通知终端更新播放列表
                    List <SeatManage.ClassModel.TerminalInfo> terminalList = SeatManage.Bll.ClientConfigOperate.GetTerminalsInfo();
                    foreach (SeatManage.ClassModel.TerminalInfo terminal in terminalList)
                    {
                        terminal.IsUpdatePlayList = true;
                        SeatManage.Bll.ClientConfigOperate.UpdateTerminal(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_VideoMd5Item video in model.VideoFiles)
                {
                    string fileFullName = string.Format(@"{0}{1}", ServiceSet.TempFilePath, video.RelativeUrl);
                    if (File.Exists(fileFullName))
                    {
                        File.Delete(fileFullName);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 保存
        /// </summary>
        public bool Save()
        {
            try
            {
                if (string.IsNullOrEmpty(PrintReceiptModel.Num))
                {
                    ErrorMessage = "编号不能为空!";
                    return(false);
                }
                if (string.IsNullOrEmpty(PrintReceiptModel.Name))
                {
                    ErrorMessage = "名称不能为空!";
                    return(false);
                }

                if (TemplateItem.PrintIiemList.Count < 1)
                {
                    ErrorMessage = "打印项目不能为空!";
                    return(false);
                }

                if (PrintReceiptModel.EffectDate == null)
                {
                    ErrorMessage = "请选择开始日期!";
                    return(false);
                }
                if (PrintReceiptModel.EndDate == null)
                {
                    ErrorMessage = "请选择结束日期!";
                    return(false);
                }
                if (PrintReceiptModel.EndDate < PrintReceiptModel.EffectDate)
                {
                    ErrorMessage = "结束日期不能小于开始日期!";
                    return(false);
                }



                if (!IsEdit && SeatManage.Bll.AdvertisementOperation.GetAdModel(PrintReceiptModel.Num, SeatManage.EnumType.AdType.PrintReceiptAd) != null)
                {
                    ErrorMessage = "存在相同的编号或名称!";
                    return(false);
                }
                //添加上传图片
                PrintReceiptModel.ImageFilePath.Clear();

                foreach (ViewModel.ViewModelPrintItem pitem in TemplateItem.PrintIiemList)
                {
                    if (pitem.IsImage)
                    {
                        bool isnew = true;
                        foreach (string samefile in PrintReceiptModel.ImageFilePath)
                        {
                            if (samefile == pitem.ImagePath)
                            {
                                isnew = false;
                                break;
                            }
                        }
                        if (isnew)
                        {
                            PrintReceiptModel.ImageFilePath.Add(pitem.ImagePath);
                        }
                    }
                }

                //TODO:图片上传,优惠券保存
                string result = "";
                SeatManage.Bll.FileOperate fileUpload = new SeatManage.Bll.FileOperate();
                for (int i = 0; i < PrintReceiptModel.ImageFilePath.Count; i++)
                {
                    if (!fileUpload.UpdateFile(PrintReceiptModel.ImageFilePath[i], PrintReceiptModel.Num + "_" + PrintReceiptModel.ImageFilePath[i].Substring(PrintReceiptModel.ImageFilePath[i].LastIndexOf("\\") + 1), SeatManage.EnumType.SeatManageSubsystem.PrintReceiptAd))
                    {
                        ErrorMessage = string.Format("上传图片失败!{0}", result);
                        return(false);
                    }
                    PrintReceiptModel.ImageFilePath[i] = PrintReceiptModel.Num + "_" + PrintReceiptModel.ImageFilePath[i].Substring(PrintReceiptModel.ImageFilePath[i].LastIndexOf("\\") + 1);
                }
                Getmodel();
                PrintReceiptModel.Type      = SeatManage.EnumType.AdType.PrintReceiptAd;
                PrintReceiptModel.AdContent = SeatManage.ClassModel.PrintReceiptInfo.ToXml(PrintReceiptModel);
                SeatManage.ClassModel.AMS_Advertisement model = new SeatManage.ClassModel.AMS_Advertisement();
                model.AdContent     = PrintReceiptModel.AdContent;
                model.EffectDate    = PrintReceiptModel.EffectDate;
                model.EndDate       = PrintReceiptModel.EndDate;
                model.ID            = PrintReceiptModel.ID;
                model.ImageFilePath = PrintReceiptModel.ImageFilePath;
                model.Name          = PrintReceiptModel.Name;
                model.Num           = PrintReceiptModel.Num;
                model.Type          = SeatManage.EnumType.AdType.PrintReceiptAd;
                string resultstr = "";
                if (IsEdit)
                {
                    //TODO:更新
                    resultstr = SeatManage.Bll.AdvertisementOperation.UpdateAdModel(model);
                }
                else
                {
                    //DOTO:添加
                    resultstr = SeatManage.Bll.AdvertisementOperation.AddAdModel(model);
                }
                if (!string.IsNullOrEmpty(resultstr))
                {
                    ErrorMessage = string.Format("保存失败!{0}", resultstr);
                    return(false);
                }
                MessageBoxWindow mbw = new MessageBoxWindow();
                mbw.viewModel.Message = "保存成功!";
                mbw.viewModel.Type    = Code.MessageBoxType.Success;
                mbw.ShowDialog();
                return(true);
            }

            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
                return(false);
            }
        }
 public static bool Get(int AdID)
 {
     try
     {
         AMS.Model.AMS_AdvertisementSchoolCopy adModel = AMS.ServiceProxy.AdvertisementOperationService.GetSchoolAdvert(AdID);
         if (adModel != null)
         {
             //上传下载类
             AMS.ServiceProxy.FileOperate advertfileOperate     = new AMS.ServiceProxy.FileOperate();
             SeatManage.Bll.FileOperate   seatmanagefileOperate = new SeatManage.Bll.FileOperate();
             seatmanagefileOperate.Downloaded += new SeatManage.Bll.EventHandleFileTransport(seatmanagefileOperate_Downloaded);
             advertfileOperate.DownloadError  += new AMS.ServiceProxy.EventHandleFileOperateError(fileOperate_DownloadError);
             //创建model
             SeatManage.ClassModel.AMS_Advertisement model = new SeatManage.ClassModel.AMS_Advertisement();
             model.AdContent     = adModel.AdContent;
             model.EffectDate    = adModel.EffectDate;
             model.EndDate       = adModel.EndDate;
             model.ImageFilePath = SeatManage.ClassModel.AMS_Advertisement.GetDownloadFile(adModel.AdContent);
             model.Name          = adModel.Name;
             model.Num           = adModel.Num;
             model.Type          = (SeatManage.EnumType.AdType)System.Enum.Parse(typeof(SeatManage.EnumType.AdType), adModel.Type.ToString());
             //图片下载
             foreach (string file in model.ImageFilePath)
             {
                 string fileFullName = string.Format(@"{0}{1}", ServiceSet.TempFilePath, file);
                 //开始下载文件
                 if (!File.Exists(fileFullName))
                 {
                     bool   downloadResult = false;
                     string error          = advertfileOperate.FileDownLoad(fileFullName, file, (SeatManage.EnumType.SeatManageSubsystem)System.Enum.Parse(typeof(SeatManage.EnumType.SeatManageSubsystem), model.Type.ToString()));
                     if (error == "")
                     {
                         downloadResult = true;
                     }
                     else
                     {
                         downloadResult = false;
                     }
                     if (!downloadResult)
                     {
                         //下载失败,直接返回false
                         return(false);
                     }
                 }
             }
             //图片上传
             foreach (string file in model.ImageFilePath)
             {
                 string fileFullName = string.Format(@"{0}{1}", ServiceSet.TempFilePath, file);
                 //文件下载完成,执行上传操作
                 bool uploadResult = seatmanagefileOperate.UpdateFile(fileFullName, file, (SeatManage.EnumType.SeatManageSubsystem)System.Enum.Parse(typeof(SeatManage.EnumType.SeatManageSubsystem), model.Type.ToString()));
                 if (!uploadResult)
                 {
                     //上传失败,直接返回false,不再尝试其他操作
                     return(false);
                 }
             }
             SeatManage.ClassModel.AMS_Advertisement sameModel = SeatManage.Bll.AdvertisementOperation.GetAdModel(model.Num, model.Type);
             string errorMessage = "";
             if (sameModel == null)
             {
                 errorMessage = SeatManage.Bll.AdvertisementOperation.AddAdModel(model);
             }
             else
             {
                 model.ID     = sameModel.ID;
                 errorMessage = SeatManage.Bll.AdvertisementOperation.UpdateAdModel(model);
             }
             if (errorMessage != "")
             {
                 SeatManage.SeatManageComm.WriteLog.Write(string.Format("更新广告遇到错误:{0}", errorMessage));
                 return(false);
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }