public static void ImportPrinters(ProfileData profileData, string profilePath) { foreach (Printer printer in Datastore.Instance.dbSQLite.Query<Printer>("SELECT * FROM Printer;")) { ImportPrinter(printer, profileData, profilePath); } }
public static void ImportPrinter(Printer printer, ProfileData profileData, string profilePath) { var printerInfo = new PrinterInfo() { Name = printer.Name, Id = printer.Id.ToString() }; profileData.Profiles.Add(printerInfo); var layeredProfile = ActiveSliceSettings.LoadEmptyProfile(); //Load printer settings from database as second layer layeredProfile.OemProfile = new OemProfile(LoadOemLayer(printer)); //Ordering matters - Material presets trump Quality LoadQualitySettings(layeredProfile, printer); LoadMaterialSettings(layeredProfile, printer); string fullProfilePath = Path.Combine(profilePath, printer.Id + ".json"); File.WriteAllText(fullProfilePath, JsonConvert.SerializeObject(layeredProfile, Formatting.Indented)); //GET LEVELING DATA from DB //PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(printer); /* PrintLevelingPlane.Instance.SetPrintLevelingEquation( levelingData.SampledPosition0, levelingData.SampledPosition1, levelingData.SampledPosition2, ActiveSliceSettings.Instance.PrintCenter); */ }
static ActiveSliceSettings() { // Ensure the profiles directory exists Directory.CreateDirectory(profilesPath); // Load or import the profiles.json document if (File.Exists(profilesDBPath)) { ProfileData = JsonConvert.DeserializeObject<ProfileData>(File.ReadAllText(profilesDBPath)); } else { ProfileData = new ProfileData(); // Import class profiles from the db into local json files DataStorage.ClassicDB.ClassicSqlitePrinterProfiles.ImportPrinters(ProfileData, profilesPath); File.WriteAllText(profilesDBPath, JsonConvert.SerializeObject(ProfileData, Formatting.Indented)); // TODO: Upload new profiles to webservice } if (!string.IsNullOrEmpty(ProfileData.ActiveProfileID)) { Instance = LoadProfile(ProfileData.ActiveProfileID); } else { // Load an empty profile with just the MatterHackers base settings from config.json Instance = new SettingsProfile(LoadEmptyProfile()); } }