Exemple #1
0
        private bool CheckMacAddress()
        {
            ShowMessage = "验证终端设置绑定的Mac地址";
            //TODO:验证Mac地址
            ShowMessage = "获取本地MAC地址";
            List <string> localMacAdd;

            try
            {
                localMacAdd = GetMacAddress.GetLocalAddress();
            }
            catch (Exception ex)
            {
                ShowMessage = "本地MAC获取失败:" + ex.Message;
                return(false);
            }
            ShowMessage = "本地MAC获取成功,获取SystemObject单例";
            SystemObject clientObject = SystemObject.GetInstance();

            if (clientObject.ClientSetting == null)
            {
                ShowMessage = "获取终端设置失败, 请检查终端编号是否正确。";
                return(false);
            }
            ShowMessage = "获取SystemObject单例获取成功";

            if (!string.IsNullOrEmpty(clientObject.ClientSetting.TerminalMacAddress))//mac地址不为空
            {
                foreach (string macAdd in localMacAdd)
                {
                    if (clientObject.ClientSetting.TerminalMacAddress == macAdd)
                    {
                        return(true);
                    }
                }
                ShowMessage = "Mac地址验证失败,重新设置终端编号,您也可以通过本地设置程序强行将Mac地址和终端编号锁定";
                return(false);
            }
            if (localMacAdd.Count > 0)
            {
                //TODO:更新终端设置
                clientObject.ClientSetting.TerminalMacAddress = localMacAdd[0];
            }
            try
            {
                if (!string.IsNullOrEmpty(TerminalOperatorService.UpdateTeminalSetting(clientObject.ClientSetting)))
                {
                    ShowMessage = "尝试锁定终端设置的时候出现错误。";
                    return(false);
                }
                return(true);
            }
            catch
            {
                ShowMessage = "尝试锁定终端设置的时候出现错误。";
                return(false);
            }
        }
        /// <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);
        }
Exemple #3
0
        /// <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 Empower()
 {
     try
     {
         //如果设置为服务器授权,则不管是否在线都要联网获取授权。
         if (ServiceSet.Empower == EmpowerMode.Server)
         {
             try
             {
                 //从Advert服务器上获取时间,以判断 是否能够连接到公司服务器上
                 DateTime?dt = DateTime.Now;
                 //如果有值说明能够连接到服务器上,进行授权。
                 if (dt.HasValue)
                 {
                     List <TerminalInfoV2> terminalList = TerminalOperatorService.GetAllTeminalInfo();
                     foreach (TerminalInfoV2 terminal in terminalList)
                     {
                         terminal.EmpowerLoseEfficacyTime = ServiceDateTime.Now.AddDays(7);
                         TerminalOperatorService.UpdateTeminalSetting(terminal);
                     }
                 }
             }
             catch { }
         }
         else if (ServiceSet.Empower == EmpowerMode.Local)
         {
             List <TerminalInfoV2> terminalList = TerminalOperatorService.GetAllTeminalInfo();
             foreach (TerminalInfoV2 terminal in terminalList)
             {
                 terminal.EmpowerLoseEfficacyTime = ServiceDateTime.Now.AddDays(7);
                 TerminalOperatorService.UpdateTeminalSetting(terminal);
             }
         }
     }
     catch (Exception ex)
     {
         WriteLog.Write(string.Format("终端使用授权失败:{0}", 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));
     }
 }