Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigurationUnitStore"/> class.
        /// </summary>
        /// <param name="baseDirectoryPath">
        /// The base directory path.
        /// </param>
        /// <param name="fileName">
        /// Name of the file.
        /// </param>
        /// <param name="recreate">
        /// if set to <c>true</c> [recreate].
        /// </param>
        public ConfigurationUnitStore(string baseDirectoryPath, string fileName, bool recreate)
        {
            // this.Platform = SimpleIoc.Default.GetInstance<IPlatformService>();

            this.Platform            = SimpleIoc.Default.GetInstance <IPlatformService>();
            this.BaseDirectoryPath   = baseDirectoryPath;
            this.unitStoreDictionary = new Dictionary <string, IUnitTypeStore>();
            this.DatabaseFilename    = Path.Combine(baseDirectoryPath, fileName);

            this.DatabaseInstance = ConfigDatabase.Create(this.DatabaseFilename);

            // Changed WebConfigLayout, Query and Analysis preload to true. For an unknown reason, they don't work correctly after initialization.
            this.AddUnitStore("Menu", "menus", true, def => new Menu(def));
            this.AddUnitStore("FieldControl", "fieldcontrols", true, def => new FieldControl(def));
            this.AddUnitStore("WebConfigLayout", "webconfiglayouts", true, def => new WebConfigLayout(def));
            this.AddUnitStore("WebConfigValue", "webconfigvalues", true, def => new WebConfigValue(def));
            this.AddUnitStore("Form", "forms", true, def => new Form(def));
            this.AddUnitStore("QuickSearch", "quicksearch", true, def => new QuickSearch(def));
            this.AddUnitStore("Query", "queries", true, def => new UPConfigQuery(def));
            this.AddUnitStore("Analysis", "analyses", true, def => new UPConfigAnalysis(def));
            this.AddUnitStore("AnalysisCategory", "analysiscategories", false, def => new UPConfigAnalysisCategory(def));
            this.AddUnitStore("Details", "details", true, def => new UPConfigExpand(def));
            this.AddUnitStore("Search", "searches", true, def => new SearchAndList(def));
            this.AddUnitStore("Button", "buttons", true, def => new UPConfigButton(def));
            this.AddUnitStore("Header", "header", true, def => new UPConfigHeader(def));
            this.AddUnitStore("Image", "images", true, def => new UPConfigResource(def));
            this.AddUnitStore("Filter", "filter", true, def => new UPConfigFilter(def));
            this.AddUnitStore("InfoAreas", "infoareas", true, def => new InfoArea(def));
            this.AddUnitStore("Textgroups", "textgroups", true, def => new TextGroup(def));
            this.AddUnitStore("DataSets", "datasets", true, def => new UPConfigDataSet(def));
            this.AddUnitStore("TableCaptions", "tablecaptions", true, def => new UPConfigTableCaption(def));
            this.AddUnitStore("Timeline", "timeline", true, def => new ConfigTimeline(def));
            this.AddUnitStore("TreeView", "treeview", true, def => new UPConfigTreeView(def));

            if (recreate && this.UpdateDDL() != 0)
            {
                return;
            }

            this.Reset();
        }
Esempio n. 2
0
        /// <summary>
        /// Deletes the database.
        /// </summary>
        /// <param name="recreate">
        /// if set to <c>true</c> [recreate].
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool DeleteDatabase(bool recreate)
        {
            var fileManager = this.Platform.StorageProvider;

            if (!fileManager.FileExists(this.DatabaseFilename))
            {
                return(false);
            }

            this.DatabaseInstance.Close();

            //this.DatabaseInstance?.Dispose();

            Exception ex;

            fileManager.TryDelete(this.DatabaseFilename, out ex);

            if (recreate)
            {
                this.DatabaseInstance = ConfigDatabase.Create(this.DatabaseFilename);
            }

            return(true);
        }