Ejemplo n.º 1
0
        /// <summary>
        /// Creates and returns a <see cref="PageMap"/> from the specified <paramref name="dataModel"/>
        /// </summary>
        /// <param name="dataModel">The data model</param>
        /// <param name="parent">The parent page</param>
        /// <returns></returns>
        public static PageMap FromDataModel(PageMapDataModel dataModel, PageMap parent)
        {
            // Create the map
            var pageMap = new PageMap()
            {
                Id          = dataModel.Id,
                Color       = dataModel.Color,
                PathData    = dataModel.PathData,
                Name        = dataModel.Name,
                Description = dataModel.Description,
                Category    = dataModel.Category,
                Order       = dataModel.Order,
                Parent      = parent,
                Presenter   = CeidDiplomatikiDI.GetCeidDiplomatikiManager.Presenters.FirstOrDefault(x => x.Id == dataModel.PresenterId)
            };

            // If there are pages...
            if (!dataModel.Pages.IsNullOrEmpty())
            {
                // Set them
                pageMap.Pages = dataModel.Pages.Select(x => FromDataModel(x, pageMap)).ToList();
            }

            // Return the page map
            return(pageMap);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Traverses the pages root from the specified <paramref name="pageMap"/>
        /// to the end
        /// </summary>
        /// <param name="pageMap">The page map</param>
        /// <returns></returns>
        private IEnumerable <PageMap> GetPages(PageMap pageMap)
        {
            var result = new List <PageMap>()
            {
                pageMap
            };

            foreach (var page in pageMap.Pages)
            {
                result.AddRange(GetPages(page));
            }

            return(result);
        }
 /// <summary>
 /// Creates and returns a presenter page that represents the specified <paramref name="presenterMap"/>.
 /// </summary>
 /// <param name="presenterMap">The presenter map</param>
 /// <param name="pageMap">The page map</param>
 /// <returns></returns>
 public static FrameworkElement CreatePresenterPage(BasePresenterMap presenterMap, PageMap pageMap)
 {
     return(new DataGridPresenterPage(presenterMap as DataGridPresenterMap, pageMap));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Unregisters the specified <paramref name="pageMap"/>
 /// </summary>
 /// <param name="pageMap">The page map</param>
 public void Unregister(PageMap pageMap)
 {
     mPages.Remove(pageMap);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Registers the specified <paramref name="pageMap"/>
 /// </summary>
 /// <param name="pageMap">The page map</param>
 public void Register(PageMap pageMap)
 {
     mPages.Add(pageMap);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes the manager.
        /// NOTE: This method should be called before the usage of the manager,
        ///       usually at the entry point of the application!
        /// </summary>
        /// <returns></returns>
        public async Task InitializeAsync()
        {
            // If there isn't an options file...
            if (!File.Exists(OptionsFileName))
            {
                // There is nothing to initialize from, so return
                return;
            }

            // Get the options
            var options = XMLHelpers.FromXml <CeidDiplomatikiOptionsDataModel>(OptionsFileName);

            // For every database...
            foreach (var database in options.Databases)
            {
                // Add it
                Register(database);
            }

            // For every database options...
            foreach (var databaseOptions in Databases)
            {
                // Get the connection string
                databaseOptions.TryGetConnectionString(out var connectionString);

                // Get the analyzer
                var analyzer = CeidDiplomatikiDI.GetDatabaseAnalyzer(databaseOptions.Provider);

                // Get the database
                var database = analyzer.GetDatabases().First(x => x.DatabaseName == databaseOptions.DatabaseName);

                // Get the tables
                var tables = analyzer.GetTables(databaseOptions.DatabaseName);

                // Get the columns
                var columns = analyzer.GetColumns(database.DatabaseName, null);

                // For every query map related to that database...
                foreach (var queryMapDataModel in options.QueryMaps.Where(x => x.DatabaseId == databaseOptions.Id))
                {
                    // The joins collection
                    var joins = new List <JoinMap>();

                    // For every pair...
                    foreach (var joinDataModel in queryMapDataModel.Joins)
                    {
                        // Get the principle column
                        var principleColumn = columns.First(x => x.ColumnName == joinDataModel.PrincipleKeyColumnName);

                        // Get the foreign key column
                        var referencedColumn = columns.First(x => x.ColumnName == joinDataModel.ForeignKeyColumnName);

                        // Create the join map
                        var joinMap = new JoinMap(tables.First(x => x.TableName == joinDataModel.TableName), principleColumn, tables.First(x => x.TableName == joinDataModel.ReferencedTableName), referencedColumn, joinDataModel.Index, joinDataModel.IsInverted);

                        // Add it to the joins
                        joins.Add(joinMap);
                    }

                    // Create the map
                    var queryMap = QueryMap.FromDataModel(databaseOptions, database, tables.Where(x => queryMapDataModel.TableNames.Contains(x.TableName)).ToList(), columns.Where(x => queryMapDataModel.TableNames.Contains(x.TableName)).ToList(), joins, queryMapDataModel);

                    // Register it
                    await RegisterAsync(queryMap);
                }
            }

            // For every page...
            foreach (var page in options.PageMaps)
            {
                // Add it
                Register(PageMap.FromDataModel(page, null));
            }

            // Await a task
            await Task.CompletedTask;
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="pageMap">The page map</param>
 /// <param name="presenterMap">The presenter map</param>
 public BasePresenterPage(BasePresenterMap presenterMap, PageMap pageMap) : base()
 {
     PresenterMap = presenterMap ?? throw new ArgumentNullException(nameof(presenterMap));
     PageMap      = pageMap ?? throw new ArgumentNullException(nameof(pageMap));
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public PageMapPage(PageMap pageMap) : base()
        {
            PageMap = pageMap ?? throw new ArgumentNullException(nameof(pageMap));

            CreateGUI();
        }