Exemplo n.º 1
0
        public void RetrievePrinterProfileListWorking()
        {
            StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));

            string profilePath = Path.Combine(ApplicationDataStorage.ApplicationUserDataPath, "data", "temp", "cache", "profiles", "oemprofiles.json");

            if (File.Exists(profilePath))
            {
                File.Delete(profilePath);
            }
            //MatterControlUtilities.OverrideAppDataLocation();
            AutoResetEvent        requestCompleteWaiter = new AutoResetEvent(false);
            PublicProfilesRequest retrieveProfiles      = new PublicProfilesRequest();

            retrieveProfiles.URI = "https://mattercontrol-test.appspot.com/api/1/device/get-public-profile-list";


            retrieveProfiles.RequestComplete += (sender, eArgs) => { requestCompleteWaiter.Set(); };

            retrieveProfiles.Request();
            Assert.IsTrue(requestCompleteWaiter.WaitOne());

            Assert.IsTrue(File.Exists(profilePath));

            //Call Retrieve Profile next
            RetrievePrinterProfileWorking();
        }
Exemplo n.º 2
0
        private void Deserialized(StreamingContext context)
        {
            var oemProfiles = MatterControlApplication.LoadCacheable <Dictionary <string, Dictionary <string, string> > >(
                "oemprofiles.json",
                "profiles",
                () =>
            {
                string responseText = null;

                var autoResetEvent = new AutoResetEvent(false);

                var profileRequest = new PublicProfilesRequest();
                profileRequest.RequestSucceeded += (s, e) => responseText = profileRequest.ResponseValues["ProfileList"];
                profileRequest.RequestComplete  += (s, e) => autoResetEvent.Set();
                profileRequest.Request();

                // Block on the current thread until the response has completed
                autoResetEvent.WaitOne(30000);

                return(responseText);
            });

            OemProfiles = oemProfiles;
            SetManufacturers(oemProfiles.Select(m => new KeyValuePair <string, string>(m.Key, m.Key)).ToList());
        }