Example #1
0
        private async Task DownloadMissingProfiles(IProgress <SyncReportType> syncReport)
        {
            SyncReportType reportValue = new SyncReportType();
            int            index       = 0;

            foreach (string oem in OemProfiles.Keys)
            {
                string cacheScope = Path.Combine("public-profiles", oem);

                index++;
                foreach (var model in OemProfiles[oem].Keys)
                {
                    var    publicDevice = OemProfiles[oem][model];
                    string cachePath    = ApplicationController.CacheablePath(cacheScope, publicDevice.CacheKey);
                    if (!File.Exists(cachePath))
                    {
                        await Task.Delay(20000);

                        await ProfileManager.LoadOemProfileAsync(publicDevice, oem, model);

                        if (syncReport != null)
                        {
                            reportValue.actionLabel  = string.Format("Downloading public profiles for {0}...", oem);
                            reportValue.percComplete = (double)index / OemProfiles.Count;
                            syncReport.Report(reportValue);
                        }
                    }
                }
            }
        }
        private async Task DownloadMissingProfiles(IProgress <SyncReportType> syncReport)
        {
            string         cacheDirectory = Path.Combine(ApplicationDataStorage.ApplicationUserDataPath, "data", "temp", "cache", "profiles");
            SyncReportType reportValue    = new SyncReportType();
            int            index          = 0;

            foreach (string oem in OemProfiles.Keys)
            {
                index++;
                foreach (string profileKey in OemProfiles[oem].Values)
                {
                    string cacheKey  = profileKey + ProfileManager.ProfileExtension;
                    string cachePath = Path.Combine(cacheDirectory, cacheKey);

                    if (!File.Exists(cachePath))
                    {
                        var profile = await ApplicationController.DownloadPublicProfileAsync(profileKey);

                        string profileJson = JsonConvert.SerializeObject(profile);
                        if (!string.IsNullOrEmpty(profileJson))
                        {
                            File.WriteAllText(cachePath, profileJson);
                        }
                        if (syncReport != null)
                        {
                            reportValue.actionLabel  = String.Format("Downloading public profiles for {0}...", oem);
                            reportValue.percComplete = (double)index / OemProfiles.Count;
                            syncReport.Report(reportValue);
                        }
                    }
                }
            }
        }
		private void ReportProgress(SyncReportType report)
		{
			syncingDetails.Text = report.actionLabel;
		}
 private void ReportProgress(SyncReportType report)
 {
     syncingDetails.Text = report.actionLabel;
 }
		private async Task DownloadMissingProfiles(IProgress<SyncReportType> syncReport)
		{
			SyncReportType reportValue = new SyncReportType();
			int index = 0;
			foreach (string oem in OemProfiles.Keys)
			{
				string cacheScope = Path.Combine("public-profiles", oem);

				index++;
				foreach (var model in OemProfiles[oem].Keys)
				{
					var publicDevice = OemProfiles[oem][model];
					string cachePath = ApplicationController.CacheablePath(cacheScope, publicDevice.CacheKey);
					if (!File.Exists(cachePath))
					{
						await Task.Delay(20000);
						await ProfileManager.LoadOemProfileAsync(publicDevice, oem, model);

						if (syncReport != null)
						{
							reportValue.actionLabel = string.Format("Downloading public profiles for {0}...", oem);
							reportValue.percComplete = (double)index / OemProfiles.Count;
							syncReport.Report(reportValue);
						}
					}
				}
			}
		}