2013-07-29 2 views
0

안녕하세요. 매분 내 타일 이미지를 업데이트해야하지만 해결 방법을 찾을 수 없습니다. 나는 this을 보았지만 제대로 작동시키지 못했습니다.매분마다 타일 이미지 업데이트 8 개 앱

타일의 이미지는 웹에서 두 번로드되지만 이후에는 다시로드되지 않습니다. 매분 내 타일에서 이미지를 업데이트하려면 어떻게해야합니까?

예 : Here, 내 타일 및 숫자는 웹 서버의 이미지이므로 새 이미지가있을 때마다이 이미지를 새로 고침해야합니다.

public static void CreateSchedule() 
    { 




     var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); 
     var plannedUpdated = tileUpdater.GetScheduledTileNotifications(); 


     DateTime now = DateTime.Now; 
     DateTime planTill = now.AddHours(4); 

     string src1 = "http://mysite/squareLogo128.png"; 

     DateTime updateTime = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0).AddMinutes(1); 
     if (plannedUpdated.Count > 0) 
      updateTime = plannedUpdated.Select(x => x.DeliveryTime.DateTime).Union(new [] { updateTime }).Max(); 



     string xml = "<tile>" 
         + "<visual>" 
         + "<binding template='TileWideImageAndText01'>" 
         + "<text id='1'>This tile notification uses web images</text>" 
         + "<image id='1' src='" + src1 + "' alt='Web image'/>" 
         + "</binding>" 
         + "<binding template='TileSquareImage'>" 
         + "<image id='1' src='" + src1 + "' alt='Web image'/>" 
         + "</binding>" 
         + "</visual>" 
         + "</tile>"; 

     XmlDocument documentNow = new XmlDocument(); 
     documentNow.LoadXml(xml); 

     tileUpdater.Update(new TileNotification(documentNow) { ExpirationTime = now.AddMinutes(1) }); 
     for (var startPlanning = updateTime; startPlanning < planTill; startPlanning = startPlanning.AddMinutes(1)) 
     { 
      Debug.WriteLine(startPlanning); 
      Debug.WriteLine(planTill); 

      try 
      { 
       string src2 = "http://mysite/squareLogo128.png"; 
       string xml2 = "<tile>" 
         + "<visual>" 
         + "<binding template='TileWideImageAndText01'>" 
         + "<text id='1'>This tile notification uses web images</text>" 
         + "<image id='1' src='" + src2 + "' alt='Web image'/>" 
         + "</binding>" 
         + "<binding template='TileSquareImage'>" 
         + "<image id='1' src='" + src2 + "' alt='Web image'/>" 
         + "</binding>" 
         + "</visual>" 
         + "</tile>"; 

       XmlDocument document = new XmlDocument(); 
       document.LoadXml(xml2); 

       ScheduledTileNotification scheduledNotification = new ScheduledTileNotification(document, new DateTimeOffset(startPlanning)) { ExpirationTime = startPlanning.AddMinutes(1) }; 
       tileUpdater.AddToSchedule(scheduledNotification); 


      } 
      catch (Exception e) 
      { 
      } 
     } 
    } 
+0

'try {} catch {}'블록에서 빠져 나오지 않는다고 확신합니까? – Izzy

답변

1

난 당신이 Debug.WriteLine 출력을보고있는 것을 여기에서 추정하고있어, 당신은 당신이 당신의 빈 catch에 예외를 삼키는하지 않을 확인했습니다.

Fiddler을 실행 해 보셨습니까? 같은 이미지를 반복해서 요청하고 있기 때문에 로컬 캐시에서 제공되는지 궁금합니다. (왜 두번이 약간 의문의 대상이 될 수 있습니다.) 당신이 임의의 쿼리 문자열에 압정 경우

은 (즉, 문제가 될 수 있는지 확인하기 위해 간단한 테스트를하고 일) 캐시를 속일 수

string src2 = "http://mysite/squareLogo128.png" + "?" + Guid.NewGuid().ToString(); 

을 말한다. 그래도 문제가되지 않는다면 (그리고 AFAIK가 제어 할 수있는 것이 아님) 적절한 no-cache 헤더를 설정할 이미지 검색 (서비스를 통해)에 응답 헤더를 설정하는 것이 더 좋습니다. 그렇지 않으면 재사용 할 수없는 이미지로 캐시를 채 웁니다.

좀 더 자세한 내용을 보려면 my blog post on image handling with notifications의 "이미지가 클라우드에 있음"섹션을 살펴보십시오.