- Add prototype for loading cacheable content - Make RetrievePrinterProfile test use public server - Expose JsonResponseDictionary on PublicProfilesRequest
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using MatterHackers.MatterControl.DataStorage;
|
|
using MatterHackers.MatterControl.SettingsManagement;
|
|
using System.IO;
|
|
using System.Net;
|
|
|
|
namespace MatterHackers.MatterControl.VersionManagement
|
|
{
|
|
public class RetrievePublicProfileRequest
|
|
{
|
|
#if DEBUG
|
|
internal static string DownloadBaseUrl { get; } = "https://mattercontrol-test.appspot.com/api/1/device/get-public-profile";
|
|
#else
|
|
internal static string DownloadBaseUrl { get; } = "https://mattercontrol.appspot.com/api/1/device/get-public-profile";
|
|
#endif
|
|
|
|
public string GetPrinterProfileByMakeModel(string make, string model)
|
|
{
|
|
string deviceToken = OemSettings.Instance.OemProfiles[make][model];
|
|
string profiletext = DownloadPrinterProfile(deviceToken);
|
|
return profiletext;
|
|
}
|
|
|
|
internal static string DownloadPrinterProfile(string deviceToken)
|
|
{
|
|
// Keep track of version. When retrieving check version
|
|
string url = DownloadBaseUrl + string.Format("/{0}",deviceToken);
|
|
|
|
string profilePath = Path.Combine(ApplicationDataStorage.ApplicationUserDataPath,"Profiles",string.Format("{0}.json",deviceToken));
|
|
|
|
WebClient client = new WebClient();
|
|
|
|
string profileText = client.DownloadString(url);
|
|
//File.WriteAllText(profileText, profilePath);
|
|
return profileText;
|
|
}
|
|
}
|
|
}
|