/// <summary> /// 执行打印操作 /// </summary> /// <param name="_PrintType"></param> /// <param name="data"></param> public void Print(PrintStatus printType, PrintData data, string clientNo) { Printer printerStatus = PrintStatusHandle(); TerminalInfoV2 term = TerminalOperatorService.GetTeminalSetting(clientNo); if (printerStatus == Printer.NoPaper) { if (term.PrinterStatus) { term.PrinterStatus = false; term.LastPrintTimes = term.PrintedTimes; term.PrintedTimes = 0; TerminalOperatorService.UpdateTeminalSetting(term); } if (PrinterException != null) { PrinterException(Printer.NoPaper); } return; } if (printerStatus == Printer.Normal) { term.PrinterStatus = true; term.DeviceSetting.IsAnyPaper = true; } _PrintType = printType; printData = data; XmlDocument doc = new XmlDocument();//原模板 doc.LoadXml(GetPrintTemplate()); PrintDocument pd = new PrintDocument(); //打印操作的对象 pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); //设置边距 switch (PrintType) { //根据凭条的类型,在模板前增加【预约】或【等待】字样的节点 case PrintStatus.General: newDoc = doc; break; case PrintStatus.Book: newDoc = InsertXmlNode(PrintStatus.Book, doc); break; case PrintStatus.Wait: newDoc = InsertXmlNode(PrintStatus.Wait, doc); break; } pd.PrintPage += pd_PrintPage; pd.Print(); term.PrintedTimes++; TerminalOperatorService.UpdateTeminalSetting(term); }
/// <summary> /// 截图 /// </summary> public void ScreenShots() { if (!_screenShots) { return; } if (!Directory.Exists(imageSavePath)) { Directory.CreateDirectory(imageSavePath); } WPFMessage.MessageHelper.SendMessage(MediaCLient, SeatManage.EnumType.SendClentMessageType.ScreenShots, imageSavePath + "MeadiaClient.jpg"); WPFMessage.MessageHelper.SendMessage(SeatClient, SeatManage.EnumType.SendClentMessageType.ScreenShots, imageSavePath + "SeatClient.jpg"); Thread.Sleep(5000); if (!File.Exists(imageSavePath + "MeadiaClient.jpg") || !File.Exists(imageSavePath + "SeatClient.jpg")) { WriteLog.Write("获取截图失败!"); return; } try { Bitmap image = new Bitmap(1080, 1920); Graphics bg = Graphics.FromImage(image); Image bgmc = Bitmap.FromFile(imageSavePath + "MeadiaClient.jpg"); bg.DrawImage(bgmc, 0, 0, 1080, 920); Image scmc = Bitmap.FromFile(imageSavePath + "SeatClient.jpg"); bg.DrawImage(scmc, 0, 921, 1080, 1000); image.Save(imageSavePath + _schoolNo + _clientNo + ".jpg"); FileOperate fileOperate = new FileOperate(); fileOperate.UpdateFile(imageSavePath + _schoolNo + _clientNo + ".jpg", string.Format("{0}{1}.jpg", _schoolNo, _clientNo), SeatManage.EnumType.SeatManageSubsystem.Caputre); //更新数据库状态 TerminalInfoV2 terminal = TerminalOperatorService.GetTeminalSetting(_clientNo); terminal.ScreenshotPath = string.Format("{0}{1}.jpg", _schoolNo, _clientNo); terminal.StatusUpdateTime = ServiceDateTime.Now; TerminalOperatorService.UpdateTeminalSetting(terminal); } catch (Exception ex) { WriteLog.Write("发送设备状态失败:" + ex.Message); } }
/// <summary> /// 获取该学校的终端信息 /// </summary> public void GetDevice() { try { if (ServiceSet.IsOnline) { //媒体服务器的设备列表 List <AMS_Device> modelList = IDevice.GeDeviceModelBySchoolNum(ServiceSet.SchoolNums, false); Dictionary <string, AMS_Device> ModelDic = new Dictionary <string, AMS_Device>(); foreach (AMS_Device item in modelList) { ModelDic.Add(item.Number, item); } //学校的设备列表 List <TerminalInfoV2> oldModelList = TerminalOperatorService.GetAllTeminalInfo(); Dictionary <string, TerminalInfoV2> oldModelDic = new Dictionary <string, TerminalInfoV2>(); foreach (TerminalInfoV2 item in oldModelList) { oldModelDic.Add(item.ClientNo, item); } //判断是否存在num foreach (KeyValuePair <string, AMS_Device> item in ModelDic) { if (oldModelDic.Keys.Contains(item.Key)) { if (!item.Value.IsDel.Value) { TerminalInfoV2 terminal = TerminalOperatorService.GetTeminalSetting(item.Value.Number); //terminal.Describe = item.Value.Describe; terminal.EmpowerLoseEfficacyTime = ServiceDateTime.Now.AddDays(7); TerminalOperatorService.UpdateTeminalSetting(terminal); } else { AMS_Terminal.DeleteTerminal(item.Key); } } else { if (!item.Value.IsDel.Value) { TerminalInfoV2 terminal = new TerminalInfoV2(); //terminal.Describe = item.Value.Describe; terminal.EmpowerLoseEfficacyTime = ServiceDateTime.Now.AddDays(7); terminal.ClientNo = item.Value.Number; terminal.IsUpdatePlayList = false; TerminalOperatorService.AddTeminalInfo(terminal); } } if (item.Value.Flag.Value) { item.Value.Flag = false; IDevice.UpdateDeviceModel(item.Value); } } //判断是否存在非法No foreach (KeyValuePair <string, TerminalInfoV2> item in oldModelDic) { if (!ModelDic.Keys.Contains(item.Key)) { AMS_Terminal.DeleteTerminal(item.Key); } } } else { SystemAuthorization saModel = SeatManage.Bll.SystemAuthorizationOperation.GetSystemAuthorization(); if (saModel == null || saModel.SchoolNum != SeatManage.Bll.Registry.GetSchoolNum()) { WriteLog.Write("获取授权文件失败!"); return; } List <TerminalInfoV2> oldModelList = TerminalOperatorService.GetAllTeminalInfo(); Dictionary <string, TerminalInfoV2> oldModelDic = oldModelList.ToDictionary(item => item.ClientNo); foreach (var item in from item in oldModelDic from v in saModel.SeatClientList.Where(v => item.Key == v.Key) select item) { item.Value.EmpowerLoseEfficacyTime = ServiceDateTime.Now.AddDays(7); TerminalOperatorService.UpdateTeminalSetting(item.Value); } foreach (var item in from item in oldModelDic let isExist = saModel.SeatClientList.Any(v => item.Key == v.Key) where !isExist select item) { AMS_Terminal.DeleteTerminal(item.Key); } foreach (var item in from item in saModel.SeatClientList let isExist = oldModelDic.Any(v => item.Key == v.Key) where !isExist select item) { TerminalInfoV2 terminal = new TerminalInfoV2(); terminal.EmpowerLoseEfficacyTime = ServiceDateTime.Now.AddDays(7); terminal.ClientNo = item.Key; terminal.IsUpdatePlayList = false; TerminalOperatorService.AddTeminalInfo(terminal); } } } catch (Exception ex) { WriteLog.Write(string.Format("获取学校终端信息失败:{0}", ex.Message)); } }