Ejemplo n.º 1
0
        /// <summary>
        /// 上传设备截图
        /// </summary>
        /// <returns></returns>
        public static bool UpdateCaputre()
        {
            try
            {
                List <SeatManage.ClassModel.TerminalInfo> terminalList = SeatManage.Bll.ClientConfigOperate.GetTerminalsInfo();
                SeatManage.Bll.FileOperate seatfileTransport           = new SeatManage.Bll.FileOperate();
                BLL.FileOperate            advertTransport             = new BLL.FileOperate();
                foreach (SeatManage.ClassModel.TerminalInfo terminal in terminalList)
                {
                    if (!string.IsNullOrEmpty(terminal.ScreenshotPath))
                    {
                        AdvertManage.Model.AMS_DeviceModel model = AdvertManage.BLL.AMS_DeviceBLL.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;
                                AdvertManage.BLL.AMS_DeviceBLL.UpdateDeviceModel(model);
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取和更新打印模板
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static bool GetPrintTemplate(int id)
        {
            Model.AMS_PrintTemplateModel printTemplate = BLL.AMS_PrintTemplateBLL.GetPrintTemplateById(id);
            if (printTemplate != null)
            {
                SeatManage.ClassModel.AMS_PrintTemplateModel model = new SeatManage.ClassModel.AMS_PrintTemplateModel();
                model.Describe   = printTemplate.Describe;
                model.EndDate    = printTemplate.EndDate;
                model.EffectDate = printTemplate.EffectDate;
                model.Template   = printTemplate.Template;
                List <string> imagesName = GetImagesName(model.Template);
                //下载打印模版中的图片
                AdvertManage.BLL.FileOperate fileOperate = new 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 (!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.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
            {
                //如果获取为空的,也作完成操作
                return(true);
            }
        }