private void update() { try { GCResourceAccess gcaccess = new GCResourceAccess(); FindIsUpdateAdvInfo findIsUpdateAdvInfo = null; FindDownAdvInfo findDownAdvInfo = new FindDownAdvInfo(); WebClient myclient = new WebClient(); while (true) { try { //Thread.Sleep(1); Thread.Sleep((1000 * 60) * 10); // 是否更新广告 findIsUpdateAdvInfo = null; //是否更新广告 findIsUpdateAdvInfo = gcaccess.findIsUpdateAdv(); if (!"0".Equals(findIsUpdateAdvInfo.code)) { continue; } log.Write("----开始更新广告"); // 广告详情获取 GCResourceAccess.adv_id = findIsUpdateAdvInfo.data.id; //将id记录到本地 if (SysBLL.IsTest.Equals("正式")) // GCResourceAccess.adv_id = SysConfigHelper.readerNode("GcAdv_id"); { GcManage.WriteGCID(findIsUpdateAdvInfo.data.id); } else { SysConfigHelper.writerNode("GcAdv_id", findIsUpdateAdvInfo.data.id); } string m_id = ""; string m_name = ""; for (int i = 1; i <= 5; i++) { findDownAdvInfo = null; if (i == 3) { } if (i == 2) { for (int j = 0; j < GcManage.paths.Length; j++) { findDownAdvInfo = gcaccess.findDownAdv(i.ToString(), GcManage.paths[j]); if (findDownAdvInfo == null) { continue; } if ("0".Equals(findDownAdvInfo.code)) { m_id = findDownAdvInfo.data.m_id; m_name = findDownAdvInfo.data.m_name; //下载资源 ResourceDownload(findDownAdvInfo.data.data, i, myclient, GcManage.paths[j]); } } continue; } else { findDownAdvInfo = gcaccess.findDownAdv(i.ToString(), "0"); if (findDownAdvInfo == null) { continue; } if ("0".Equals(findDownAdvInfo.code)) { m_id = findDownAdvInfo.data.m_id; m_name = findDownAdvInfo.data.m_name; //下载资源 ResourceDownload(findDownAdvInfo.data.data, i, myclient, ""); } } } // 更新结果通知参数 gcaccess.recordAdvUpdateLog(m_id, m_name); while (true) { if (!SysBLL.IsOpenIndexForm) { continue; } if ("1".Equals(GcManage.ReadGCStateID())) { log.Write("广告更新完毕,执行重启"); //ComputerBLL.Restart(); break; } break; } } catch (ThreadAbortException e) { log.Write("error:PictureChangeUserControl:01:update:" + e.Message + e.InnerException); continue; } catch (Exception e) { log.Write("error:PictureChangeUserControl:02:update:" + e.Message + e.InnerException); continue; } } } catch (ThreadAbortException e) { log.Write("error:PictureChangeUserControl:03:update:" + e.Message + e.InnerException); } catch (Exception e) { log.Write("error:PictureChangeUserControl:04:update:" + e.Message + e.InnerException); } }