commit
bfd0d86f6f
5 changed files with 40 additions and 42 deletions
|
|
@ -2566,12 +2566,8 @@ namespace MatterHackers.MatterControl
|
|||
// Create archive point for printing attempt
|
||||
if (Path.GetExtension(sourcePath).ToUpper() == ".MCX")
|
||||
{
|
||||
// TODO: We should zip mcx and settings when starting a print
|
||||
string platingDirectory = Path.Combine(ApplicationDataStorage.Instance.ApplicationLibraryDataPath, "PrintHistory");
|
||||
Directory.CreateDirectory(platingDirectory);
|
||||
|
||||
string now = "Workspace " + DateTime.Now.ToString("yyyy-MM-dd HH_mm_ss");
|
||||
string archivePath = Path.Combine(platingDirectory, now + ".zip");
|
||||
string archivePath = Path.Combine(ApplicationDataStorage.Instance.PrintHistoryPath, now + ".zip");
|
||||
|
||||
string settingsFilePath = ProfileManager.Instance.ProfilePath(printer.Settings.ID);
|
||||
|
||||
|
|
|
|||
|
|
@ -28,19 +28,25 @@ either expressed or implied, of the FreeBSD Project.
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
|
||||
namespace MatterHackers.MatterControl.DataStorage
|
||||
{
|
||||
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Private getters used to enforce presence of directories")]
|
||||
public class ApplicationDataStorage
|
||||
{
|
||||
public bool FirstRun = false;
|
||||
// Required by Android
|
||||
public bool FirstRun { get; set; } = false;
|
||||
|
||||
//Describes the location for storing all local application data
|
||||
// Describes the location for storing all local application data
|
||||
private static ApplicationDataStorage globalInstance;
|
||||
|
||||
private const string applicationDataFolderName = "MatterControl";
|
||||
private const string datastoreName = "MatterControl.db";
|
||||
private const string ApplicationDataFolderName = "MatterControl";
|
||||
|
||||
private const string DatastoreName = "MatterControl.db";
|
||||
|
||||
private string _applicationPath;
|
||||
|
||||
public static ApplicationDataStorage Instance
|
||||
{
|
||||
|
|
@ -50,11 +56,11 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
{
|
||||
globalInstance = new ApplicationDataStorage();
|
||||
}
|
||||
|
||||
return globalInstance;
|
||||
}
|
||||
}
|
||||
|
||||
private string _applicationPath;
|
||||
public string ApplicationPath
|
||||
{
|
||||
get
|
||||
|
|
@ -68,15 +74,22 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
}
|
||||
}
|
||||
|
||||
private static string _applicationUserDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), applicationDataFolderName);
|
||||
private static string _applicationUserDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ApplicationDataFolderName);
|
||||
|
||||
private static string _applicationLibraryDataPath => Path.Combine(_applicationUserDataPath, "Library");
|
||||
|
||||
private static string _libraryAssetPath => Path.Combine(_applicationLibraryDataPath, "Assets");
|
||||
|
||||
private static string _platingDirectory => Path.Combine(_applicationLibraryDataPath, "Plating");
|
||||
private static string _partHistoryDirectory => Path.Combine(_applicationLibraryDataPath, "PartHistory");
|
||||
|
||||
private static string _applicationTempDataPath => Path.Combine(_applicationUserDataPath, "data", "temp");
|
||||
|
||||
private static string _gcodeOutputPath => Path.Combine(_applicationTempDataPath, "gcode");
|
||||
|
||||
private static string _cacheDirectory => Path.Combine(_applicationTempDataPath, "cache");
|
||||
|
||||
private static string _printHistoryPath => Path.Combine(_applicationLibraryDataPath, "PrintHistory");
|
||||
|
||||
private static string _webCacheDirectory => Path.Combine(_applicationTempDataPath, "WebCache");
|
||||
|
||||
public static string ApplicationUserDataPath => EnsurePath(_applicationUserDataPath);
|
||||
|
|
@ -89,12 +102,12 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
|
||||
public string PlatingDirectory => EnsurePath(_platingDirectory);
|
||||
|
||||
public string PartHistoryDirectory => EnsurePath(_partHistoryDirectory);
|
||||
|
||||
public string GCodeOutputPath => EnsurePath(_gcodeOutputPath);
|
||||
|
||||
public string CacheDirectory => EnsurePath(_cacheDirectory);
|
||||
|
||||
public string PrintHistoryPath => EnsurePath(_printHistoryPath);
|
||||
|
||||
public string WebCacheDirectory => EnsurePath(_webCacheDirectory);
|
||||
|
||||
public string DownloadsDirectory { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads");
|
||||
|
|
@ -102,20 +115,20 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
public string CustomLibraryFoldersPath => Path.Combine(_applicationUserDataPath, "LibraryFolders.conf");
|
||||
|
||||
/// <summary>
|
||||
/// Returns the path to the sqlite database
|
||||
/// Gets the path to the Sqlite database
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string DatastorePath => Path.Combine(EnsurePath(_applicationUserDataPath), datastoreName);
|
||||
/// <returns>The path toe Sqlite database</returns>
|
||||
public string DatastorePath => Path.Combine(EnsurePath(_applicationUserDataPath), DatastoreName);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the public storage folder (ex. download folder on Android)
|
||||
/// Gets or sets the public storage folder (ex. download folder on Android)
|
||||
/// </summary>
|
||||
public string PublicDataStoragePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Invokes CreateDirectory on all paths, creating if missing, before returning
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns>Returns the path to the given directory</returns>
|
||||
private static string EnsurePath(string fullPath)
|
||||
{
|
||||
Directory.CreateDirectory(fullPath);
|
||||
|
|
@ -126,6 +139,7 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
/// Overrides the AppData location. Used by tests to set a non-standard AppData location
|
||||
/// </summary>
|
||||
/// <param name="path">The new AppData path.</param>
|
||||
/// <param name="sqliteBuilder">The Sqlite generator with platform specific bindings</param>
|
||||
internal void OverrideAppDataLocation(string path, Func<ISQLite> sqliteBuilder)
|
||||
{
|
||||
Console.WriteLine(" Overriding ApplicationUserDataPath: " + path);
|
||||
|
|
|
|||
|
|
@ -31,21 +31,19 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
|
||||
namespace MatterHackers.MatterControl.DataStorage
|
||||
{
|
||||
public class Datastore
|
||||
{
|
||||
bool wasExited = false;
|
||||
public bool ConnectionError = false;
|
||||
private bool wasExited = false;
|
||||
public ISQLite dbSQLite;
|
||||
private string datastoreLocation = ApplicationDataStorage.Instance.DatastorePath;
|
||||
private static Datastore globalInstance;
|
||||
private ApplicationSession activeSession;
|
||||
|
||||
private List<Type> dataStoreTables = new List<Type>
|
||||
private readonly List<Type> dataStoreTables = new List<Type>
|
||||
{
|
||||
typeof(PrintItemCollection),
|
||||
typeof(PrinterSetting),
|
||||
|
|
@ -76,6 +74,7 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
{
|
||||
globalInstance = new Datastore();
|
||||
}
|
||||
|
||||
return globalInstance;
|
||||
}
|
||||
|
||||
|
|
@ -85,6 +84,7 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
globalInstance = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void Exit()
|
||||
{
|
||||
if (wasExited)
|
||||
|
|
@ -94,10 +94,10 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
|
||||
wasExited = true;
|
||||
|
||||
if (this.activeSession != null)
|
||||
if (activeSession != null)
|
||||
{
|
||||
this.activeSession.SessionEnd = DateTime.Now;
|
||||
this.activeSession.Commit();
|
||||
activeSession.SessionEnd = DateTime.Now;
|
||||
activeSession.Commit();
|
||||
}
|
||||
|
||||
// lets wait a bit to make sure the commit has resolved.
|
||||
|
|
@ -122,7 +122,7 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
}
|
||||
}
|
||||
|
||||
//Run initial checks and operations on sqlite datastore
|
||||
// Run initial checks and operations on sqlite datastore
|
||||
public void Initialize(ISQLite dbSQLite)
|
||||
{
|
||||
this.dbSQLite = dbSQLite;
|
||||
|
|
@ -148,25 +148,13 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
return Convert.ToInt32(result);
|
||||
}
|
||||
|
||||
//Begins new application session record
|
||||
// Begins new application session record
|
||||
private void StartSession()
|
||||
{
|
||||
activeSession = new ApplicationSession();
|
||||
dbSQLite.Insert(activeSession);
|
||||
}
|
||||
|
||||
private void GenerateSampleData()
|
||||
{
|
||||
for (int index = 1; index <= 5; index++)
|
||||
{
|
||||
Printer printer = new Printer();
|
||||
printer.ComPort = string.Format("COM{0}", index);
|
||||
printer.BaudRate = "250000";
|
||||
printer.Name = string.Format("Printer {0}", index);
|
||||
Datastore.Instance.dbSQLite.Insert(printer);
|
||||
}
|
||||
}
|
||||
|
||||
// Checks if the datastore contains the appropriate tables - adds them if necessary
|
||||
private void ValidateSchema()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
graphics2D.Clear(Color.White);
|
||||
graphics2D.FillRectangle(0, 0, ViewOnlyTexture.Width / 2, ViewOnlyTexture.Height, Color.LightGray);
|
||||
// request the texture so we can set it to repeat
|
||||
var plugin = ImageGlPlugin.GetImageGlPlugin(ViewOnlyTexture, true, true, false);
|
||||
ImageGlPlugin.GetImageGlPlugin(ViewOnlyTexture, true, true, false);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 14a7b70331b8001ff55e46363d973ee95e4cac5c
|
||||
Subproject commit f78e55d7e1f027eafd9c6808bbb3587f3b0abda4
|
||||
Loading…
Add table
Add a link
Reference in a new issue