コード例 #1
0
        internal void LoadDatabases(DirectoryInfo directoryInfo, Storage storage, FieldList fields, IndexList indexes)
        {
            var fileInfo = directoryInfo.GetFiles("*.inf");

            foreach (var file in fileInfo)
            {
                if (file.FullName.EndsWith(".inf", StringComparison.CurrentCultureIgnoreCase))
                {
                    var databaseInfo = new DatabaseInfo(new AdlibPath(file.FullName), storage);
                    var databaseNode = new DatabaseNode(databaseInfo);
                    databases[databaseNode.Path] = databaseNode;

                    foreach (var fieldInfo in databaseInfo.FieldInfoCollection.Values)
                    {
                        var fieldNode = new FieldNode(databaseInfo, fieldInfo);
                        fields.Add(fieldNode.Path, fieldNode);
                    }

                    foreach (var indexInfo in databaseInfo.IndexList)
                    {
                        if (indexInfo.FirstIndexTag != "%0" && indexInfo.IndexName != "wordlist")
                        {
                            var indexNode = new IndexNode(databaseInfo, indexInfo);
                            indexes.Add(indexNode.Path, indexNode);
                        }
                    }
                }
            }
        }
コード例 #2
0
        internal void LinkScreensToDataSourceNode(ApplicationInfo applicationInfo, DatabaseList databases, FieldList fields, IndexList indexes,
                                                  Adlib.Setup.ScreenList screenList, string databasePath)
        {
            foreach (var screen in screenList)
            {
                if (!string.IsNullOrWhiteSpace(screen))
                {
                    string path = ScreenPath(applicationInfo, screen);
                    if (screens.ContainsKey(path))
                    {
                        var screenNode = screens[path];
                        if (screenNode != null && screenNode.Screen != null)
                        {
                            // Link the fields that are used on the screen to the screen
                            foreach (var field in screenNode.Screen.FieldList)
                            {
                                if (field.Type == ScreenObjectType.Data || field.Type == ScreenObjectType.HtmlField || field.Type == ScreenObjectType.Image)
                                {
                                    var fieldNode = fields.FindFieldNode(databasePath + '\\' + field.Tag);
                                    if (fieldNode != null)
                                    {
                                        AddEdge(screenNode, AdlibEdgeType.ScreenUsesField, fieldNode);

                                        var databaseNode = databases[databasePath];
                                        AddEdge(fieldNode, AdlibEdgeType.FieldOf, databaseNode);

                                        foreach (var indexNode in indexes.FindIndexNodes(fieldNode.Field.DatabaseInfo, fieldNode.Field.Tag))
                                        {
                                            AddEdge(fieldNode, AdlibEdgeType.IndexedIn, indexNode);
                                            AddEdge(indexNode, AdlibEdgeType.IndexOf, databaseNode);
                                        }

                                        if (fieldNode.Field.IsLinked)
                                        {
                                            // this is a linked screen, add the linkref field and create an edge to the database
                                            var fieldInfo          = fieldNode.Field;
                                            var linkedDatabasePath = DatabaseNode.DatabasePath(fieldInfo.LinkedDatabaseInfo);
                                            var linkedDatabaseNode = databases[linkedDatabasePath];

                                            var linkRefTag = fieldInfo.LinkRefTag;
                                            if (!string.IsNullOrWhiteSpace(linkRefTag))
                                            {
                                                var linkRefFieldPath = FieldNode.FieldPath(fieldInfo.DatabaseInfo, linkRefTag);
                                                var linkRefFieldNode = fields.FindFieldNode(linkRefFieldPath);
                                                if (linkRefFieldNode == null)
                                                {
                                                    Console.WriteLine($"Application ERROR: link ref tag '{linkRefTag}' not defined in database '{fieldInfo.DatabaseInfo.BaseName}'");
                                                }
                                                else
                                                {
                                                    AddEdge(fieldNode, AdlibEdgeType.UsesLinkRef, linkRefFieldNode);
                                                    AddEdge(linkRefFieldNode, AdlibEdgeType.FieldOf, linkedDatabaseNode);

                                                    foreach (var indexNode in indexes.FindIndexNodes(linkRefFieldNode.Field.DatabaseInfo, linkRefFieldNode.Field.Tag))
                                                    {
                                                        AddEdge(linkRefFieldNode, AdlibEdgeType.IndexedIn, indexNode);
                                                        AddEdge(indexNode, AdlibEdgeType.IndexOf, linkedDatabaseNode);
                                                    }
                                                }
                                            }

                                            // we also need to add the term field for the linked database
                                            var linkIndexTag = fieldInfo.LinkIndexTag;
                                            if (!string.IsNullOrWhiteSpace(linkIndexTag))
                                            {
                                                var linkIndexFieldPath = fieldNode.FieldPath(applicationInfo, fieldInfo.LinkedDatabaseInfo, linkIndexTag);
                                                var linkIndexFieldNode = fields.FindFieldNode(linkIndexFieldPath);
                                                if (linkIndexFieldNode != null)
                                                {
                                                    AddEdge(fieldNode, AdlibEdgeType.UsesLinkField, linkIndexFieldNode);

                                                    // create an edge from the linkindexfield to the database node
                                                    AddEdge(linkIndexFieldNode, AdlibEdgeType.FieldOf, linkedDatabaseNode);

                                                    foreach (var indexNode in indexes.FindIndexNodes(linkIndexFieldNode.Field.DatabaseInfo, linkIndexFieldNode.Field.Tag))
                                                    {
                                                        AddEdge(linkIndexFieldNode, AdlibEdgeType.IndexedIn, indexNode);
                                                        AddEdge(indexNode, AdlibEdgeType.IndexOf, linkedDatabaseNode);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: ApplicationList.cs プロジェクト: bertdd/AdlibGraph
        void AddDataSourceEdgeToApplicationNode(ApplicationNode applicationNode, DataSourceInfo dataSourceInfo,
                                                DataSourceList datasources, MethodList methods, ScreenList screens, DatabaseList databases, FieldList fields, IndexList indexes)
        {
            var applicationInfo = applicationNode.Application;

            if (dataSourceInfo.DatabaseType == DatabaseType.NormalDatabase)
            {
                var dataSourceNode = datasources.FindDataSourceNode(applicationInfo, dataSourceInfo);

                AddEdge(applicationNode, AdlibEdgeType.HasDataSource, dataSourceNode);

                dataSourceInfo.ListScreenList.ForEach(screenName =>
                                                      screens.LinkScreenToNode(applicationInfo, dataSourceNode, screenName, AdlibEdgeType.UsesListScreen));
                dataSourceInfo.DetailScreenList.ForEach(screenName =>
                                                        screens.LinkScreenToNode(applicationInfo, dataSourceNode, screenName, AdlibEdgeType.UsesDetailScreen));
                dataSourceInfo.MethodList.ForEach(methodInfo =>
                                                  methods.LinkMethodToNode(applicationInfo, dataSourceNode, methodInfo, screens));

                var databasePath = DatabasePath(applicationInfo, dataSourceInfo);

                screens.LinkScreensToDataSourceNode(applicationInfo, databases, fields, indexes, dataSourceInfo.DetailScreenList, databasePath);
                screens.LinkScreensToDataSourceNode(applicationInfo, databases, fields, indexes, dataSourceInfo.ListScreenList, databasePath);
            }
        }
コード例 #4
0
ファイル: ApplicationList.cs プロジェクト: bertdd/AdlibGraph
        public void CreateEdges(DataSourceList datasources, MethodList methods, ScreenList screens, DatabaseList databases, FieldList fields, IndexList indexes)
        {
            foreach (var applicationNode in applications.Values)
            {
                applicationNode.Application.DataSourceList.ForEach((dataSourceInfo) =>
                                                                   AddDataSourceEdgeToApplicationNode(applicationNode, dataSourceInfo, datasources, methods, screens, databases, fields, indexes));
            }

            foreach (var applicationNode in applications.Values)
            {
                ColorEdges(applicationNode);
            }
        }
コード例 #5
0
 public IndexNode(DatabaseInfo databaseInfo, IIndexInfo indexInfo) :
     base(IndexList.Path(databaseInfo, indexInfo), $"{indexInfo.IndexName} ({databaseInfo.BaseName})")
 {
 }