인터넷에서 XML 파일을 가져 와서 전화로로드하고 있습니다. 모든 것이 올바르게 진행되고 있으며, 응용 프로그램의 초기로드시 업데이트되지 않는 목록 상자가 없습니다. 가 인터넷에 연결되어있는 경우Windows Phone 7 목록 상자가 업데이트되지 않습니다.
응용 프로그램의 부하에, 그것은 업데이트 연락처 메소드를 실행 다음과 같이
응용 프로그램에 대한 간단한 경로입니다. 그렇지 않으면 첫 번째로드인지 확인하고,로드 된 경우 응용 프로그램을 실행하기 전에 모바일 또는 무선 네트워크에 연결하도록 사용자에게 알립니다. 그렇지 않으면 이전 데이터가로드됩니다.
업데이트 방법에서 웹 서비스를 검사하여 마지막 업데이트 이후에 업데이트가 있는지 확인합니다. 첫 번째로드 인 경우 2000 개의 업데이트가 발생하여 업데이트해야합니다. 업데이트 번호가 0보다 크면 다운로드를 실행 한 다음 데이터를로드합니다 (여기가 문제입니다). 그렇지 않으면 이전 데이터 (현재 데이터)가로드됩니다.
문제는 다운로드 후 데이터를로드하지 않습니다. 다음은 해당 항목에 대한 코드입니다.
GetData의 기능 :
private void getData()
{
try
{
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
IsolatedStorageFileStream isoFileStream = myIsolatedStorage.OpenFile("contacts.xml", FileMode.Open);
using (StreamReader reader = new StreamReader(isoFileStream))
{
XElement xmlContact = XElement.Parse(reader.ReadToEnd());
lstContacts.ItemsSource = from contact in xmlContact.Descendants("contact")
select new ContactItem
{
ImageSource = contact.Element("Image").Value,
FName = contact.Element("FName").Value,
LName = contact.Element("LName").Value,
Extension = contact.Element("Extension").Value,
Email = contact.Element("Email").Value,
Cell = contact.Element("Cell").Value,
Title = contact.Element("TitleName").Value,
Dept = contact.Element("deptName").Value,
Office = contact.Element("officename").Value,
ID = contact.Element("ID").Value
};
}
}
}
catch
{
}
}
업데이트 기능 :
void contact_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
{
return;
}
XElement xmlContact = XElement.Parse(e.Result);
string updates = xmlContact.Element("updates").Element("number").Value;
if (firstrun)
{
updates = "2000";
settings["firstRun"] = (bool)false;
}
MessageBox.Show(updates);
if (Convert.ToInt32(updates) > 0)
{
MessageBox.Show("Updating Contacts");
ContactReader cr = new ContactReader("http://domain.tld/RLContactApp/getContactsWP7.php?sqlQueryType=C&lastUpdated=01%2F01%2F2000&format=xml", "contacts.xml");
bool downloaded = cr.Download();
if (downloaded)
{
getData();
}
}
else
{
MessageBox.Show("Not Updating Contacts");
getData();
}
}
내가 데이터를 만들 수있는 방법을 찾고 있어요이 응용 프로그램을 닫습니다 사용자를 말하지 않고 목록 상자에로드되는 다시로드하십시오.
도움을 주시면 대단히 감사하겠습니다.
아니요? ContactItem에는 .toList() 메서드가 포함되어 있지 않으며 itemessource에 IEnumerable. toList()를 전달하면 아무 것도 다릅니다. –
시도해보십시오 (검색어)). ToList(); –
JSJ
여전히 작동하지 않음 =/ –