private void PrintTemplate() { try { XmlDocument doc = new XmlDocument(); doc.Load(_FilesPath + "TemplateInfo.xml"); XmlNode nodes = doc.SelectSingleNode("//Root/PrintTemplate"); SeatManage.ClassModel.AMS_PrintTemplateModel priTem = new ClassModel.AMS_PrintTemplateModel(); priTem.Describe = nodes.Attributes["Describe"].Value; priTem.EffectDate = DateTime.Parse(nodes.Attributes["StartTime"].Value); priTem.EndDate = DateTime.Parse(nodes.Attributes["EndTime"].Value); priTem.Template = nodes.Attributes["Template"].Value; List <string> files = GetImagesName(priTem.Template); foreach (string file in files) { if (Progress != null) { Progress("验证打印模板图片" + file); } if (!File.Exists(_FilesPath + file)) { throw new Exception("打印模板图片" + file + "不存在!"); } } SeatManage.Bll.FileOperate upload = new Bll.FileOperate(); foreach (string file in files) { if (Progress != null) { Progress("正在上传打印模板图片" + file); } if (!upload.UpdateFile(_FilesPath + file, file, SeatManage.EnumType.SeatManageSubsystem.SeatSlip)) { throw new Exception("上传打印模板图片" + file + "失败!"); } } if (SeatManage.Bll.T_SM_PrintTemplate.AddPrintTemplate(priTem) == SeatManage.EnumType.HandleResult.Failed) { throw new Exception("添加打印模板失败!"); } else { if (Progress != null) { Progress("添加打印模板" + priTem.Describe + "成功!上传" + files.Count + "个文件!"); } } } catch { throw; } }
private void PlayListUpload() { try { XmlDocument doc = new XmlDocument(); doc.Load(_FilesPath + "playList.xml"); SeatManage.ClassModel.AMS_PlayList playerlist = SeatManage.ClassModel.AMS_PlayList.Parse(doc.OuterXml); playerlist.ReleaseDate = SeatManage.Bll.ServiceDateTime.Now; foreach (SeatManage.ClassModel.AMS_VideoItem itme in playerlist.VideoFiles) { if (Progress != null) { Progress("验证媒体文件" + itme.RelativeUrl); } if (!File.Exists(_FilesPath + itme.RelativeUrl)) { throw new Exception("验证媒体文件失败!" + itme.RelativeUrl + "不存在!"); } } SeatManage.Bll.FileOperate upload = new Bll.FileOperate(); foreach (SeatManage.ClassModel.AMS_VideoItem itme in playerlist.VideoFiles) { if (Progress != null) { Progress("正在上传媒体文件" + itme.RelativeUrl); } if (!upload.UpdateFile(_FilesPath + itme.RelativeUrl, itme.RelativeUrl, SeatManage.EnumType.SeatManageSubsystem.MediaFiles)) { throw new Exception("上传媒体文件" + itme.RelativeUrl + "失败!请检查WCF服务配置是否正确!"); } } if (SeatManage.Bll.AMS_PlayList.GetPlayListByNum(playerlist.PlayListNo) == null) { if (SeatManage.Bll.AMS_PlayList.AddPlaylist(playerlist) == SeatManage.EnumType.HandleResult.Failed) { throw new Exception("播放添加失败!"); } else { if (Progress != null) { Progress("播放列表发布成功:添加播放列表" + playerlist.PlayListNo + ",上传媒体文件" + playerlist.VideoFiles.Count + "个"); } } } else { if (SeatManage.Bll.AMS_PlayList.UpdatePlaylist(playerlist) == SeatManage.EnumType.HandleResult.Failed) { throw new Exception("播放更新失败!"); } else { if (Progress != null) { Progress("播放列表发布成功:更新播放列表" + playerlist.PlayListNo + ",上传媒体文件" + playerlist.VideoFiles.Count + "个"); } } } } catch { throw; } }
private void SlipCustomerUpload() { try { XmlDocument doc = new XmlDocument(); doc.Load(_FilesPath + "SlipCustomerList.xml"); List <SeatManage.ClassModel.AMS_SlipCustomer> list = FromXML(doc); SeatManage.Bll.FileOperate upload = new Bll.FileOperate(); foreach (SeatManage.ClassModel.AMS_SlipCustomer item in list) { if (item.IsPrint) { XmlDocument Templatedoc = new XmlDocument(); Templatedoc.LoadXml(item.SlipTemplate); XmlElement Templateroot = Templatedoc.DocumentElement; XmlNodeList Templatexnlist = ((XmlNode)Templateroot).ChildNodes; for (int j = 0; j < Templatexnlist.Count; j++) { if (Templatexnlist[j].Name == "Pic") { if (Progress != null) { Progress("正在验证媒体文件" + Templatexnlist[j].InnerText); } if (!File.Exists(_FilesPath + Templatexnlist[j].InnerText)) { throw new Exception("优惠券图片" + Templatexnlist[j].InnerText + "不存在!"); } } } } if (Progress != null) { Progress("正在验证媒体文件" + item.ImageName); } if (!File.Exists(_FilesPath + item.ImageName)) { throw new Exception("优惠券图片" + item.ImageName + "不存在!"); } if (Progress != null) { Progress("正在验证媒体文件" + item.CustomerLogo); } if (!File.Exists(_FilesPath + item.CustomerLogo)) { throw new Exception("优惠券图片" + item.CustomerLogo + "不存在!"); } } foreach (SeatManage.ClassModel.AMS_SlipCustomer item in list) { if (item.IsPrint) { XmlDocument Templatedoc = new XmlDocument(); Templatedoc.LoadXml(item.SlipTemplate); XmlElement Templateroot = Templatedoc.DocumentElement; XmlNodeList Templatexnlist = ((XmlNode)Templateroot).ChildNodes; for (int j = 0; j < Templatexnlist.Count; j++) { if (Templatexnlist[j].Name == "Pic") { if (Progress != null) { Progress("正在上传媒体文件" + Templatexnlist[j].InnerText); } if (!upload.UpdateFile((_FilesPath + Templatexnlist[j].InnerText), Templatexnlist[j].InnerText, SeatManage.EnumType.SeatManageSubsystem.SlipCustomer)) { throw new Exception("优惠券图片" + Templatexnlist[j].InnerText + "上传失败!"); } } } } if (Progress != null) { Progress("正在上传媒体文件" + item.CustomerLogo); } if (!upload.UpdateFile((_FilesPath + item.CustomerLogo), item.CustomerLogo, SeatManage.EnumType.SeatManageSubsystem.SlipCustomer)) { throw new Exception("优惠券图片" + item.CustomerLogo + "上传失败!"); } if (Progress != null) { Progress("正在上传媒体文件" + item.ImageName); } if (!upload.UpdateFile((_FilesPath + item.ImageName), item.ImageName, SeatManage.EnumType.SeatManageSubsystem.SlipCustomer)) { throw new Exception("优惠券图片" + item.ImageName + "上传失败!"); } List <SeatManage.ClassModel.AMS_SlipCustomer> oldslips = SeatManage.Bll.AMS_SlipCustomer.GetSlipCustomerList(item.CampusNum); bool isupdate = false; foreach (SeatManage.ClassModel.AMS_SlipCustomer sl in oldslips) { if (sl.No == item.No) { isupdate = true; item.Id = sl.Id; break; } } if (!isupdate) { if (SeatManage.Bll.AMS_SlipCustomer.AddSlipCustomer(item) == SeatManage.EnumType.HandleResult.Failed) { throw new Exception("优惠券" + item.No + "添加失败!"); } else { if (Progress != null) { Progress("优惠券" + item.No + "添加成功!"); } } } else { if (SeatManage.Bll.AMS_SlipCustomer.UpdateSlipCustomer(item) == SeatManage.EnumType.HandleResult.Failed) { throw new Exception("优惠券" + item.No + "更新失败"); } else { if (Progress != null) { Progress("优惠券" + item.No + "更新成功"); } } } } if (Progress != null) { Progress("发布成功,共计" + list.Count + "个优惠券"); } } catch { throw; } }
private void BackupProgram(SeatManage.EnumType.SeatManageSubsystem systemType) { try { string programDir = ""; //根据类型设置要上传的程序路径 if (systemType == EnumType.SeatManageSubsystem.Mediaplayer) { programDir = string.Format("{0}MediaPlayer", AppDomain.CurrentDomain.BaseDirectory); } else if (systemType == EnumType.SeatManageSubsystem.SeatClient) { programDir = string.Format("{0}SeatClient", AppDomain.CurrentDomain.BaseDirectory); } //判断路径是否存在 if (!Directory.Exists(programDir)) { if (BackupFiled != null) { string errorMessage = string.Format("路径{0}不存在,请检查终端配置是否有误", programDir); BackupFiled(new BackupProgressInfo() { Message = errorMessage }); } return; } //去除文件只读属性 SetReadOnly(programDir); //构造系统文件结构 FileUpdateInfo files = new FileUpdateInfo(programDir); files.SubsystemType = systemType; files.UpdateLog = "初始版本"; files.ReleaseDate = DateTime.Now; //设置文件启动程序 if (systemType == EnumType.SeatManageSubsystem.Mediaplayer) { files.StartProgram = "MediaPlayerClient.exe"; } else if (systemType == EnumType.SeatManageSubsystem.SeatClient) { files.StartProgram = "SeatClient.exe"; } //删除Log,Video和SlipImage for (int i = 0; i < files.Files.Directories.Count; i++) { if (files.Files.Directories[i].Name == "Caputre" || files.Files.Directories[i].Name == "Log" || files.Files.Directories[i].Name == "SlipImage") { files.Files.Directories.Remove(files.Files.Directories[i]); } } //删除配置文件 for (int i = 0; i < files.Files.Files.Count; i++) { string exName = files.Files.Files[i].Name.Substring(files.Files.Files[i].Name.LastIndexOf(".") + 1); if (exName == "config") { files.Files.Files.Remove(files.Files.Files[i]); } } SeatManage.Bll.FileOperate fileUpload = new Bll.FileOperate(); List <string> filesPathList = files.BuildUpdateFilePaths(); for (int i = 0; i < filesPathList.Count; i++) { string fileFullName = string.Format("{0}{1}", programDir, filesPathList[i]); if (Progress != null) {//注册上传的消息 BackupProgressInfo arge = new BackupProgressInfo(); arge.ProgramName = systemType.ToString(); arge.UpdateFileName = filesPathList[i]; arge.Progress = (int)(((double)i / (filesPathList.Count - 1)) * 100); Progress(arge); } if (!fileUpload.UpdateFile(fileFullName, filesPathList[i], systemType)) { if (BackupFiled != null) { BackupProgressInfo arge = new BackupProgressInfo(); arge.Message = string.Format("文件{0}上传失败", filesPathList[i]); BackupFiled(arge); } } } FileUpdateInfo oldFile = SeatManage.Bll.FileTransportBll.GetUpdateInfo(systemType); if (oldFile == null) { SeatManage.Bll.FileTransportBll.Add(files); } else { SeatManage.Bll.FileTransportBll.Update(files); } } catch (Exception ex) { if (BackupFiled != null) { BackupProgressInfo arge = new BackupProgressInfo(); arge.Message = string.Format("备份失败,请检查是否缺失了“座位管理系统终端设置程序.exe.config”文件"); BackupFiled(arge); } } }