Exemple #1
0
    private void processNodesAndConnections(List <DiagramNodeConnection> connections)
    {
        List <List <DiagramNodeConnection> > groups;
        List <byte[]>          images;
        List <List <HotSpot> > hotspotLists;

        groups       = DiagramGenerator.GetConnectionGroups(connections);
        images       = new List <byte[]>();
        hotspotLists = new List <List <HotSpot> >();

        foreach (var currConnectionGroup in groups)
        {
            DiagramGenerator gen;
            byte[]           bytes;
            Bitmap           b;
            int width;

            //Set a width that will generally fit the nodes
            if (currConnectionGroup.Count >= 15)
            {
                width = 750;
            }
            else if (currConnectionGroup.Count <= 5)
            {
                width = 300;
            }
            else
            {
                width = 500;
            }

            gen   = new DiagramGenerator(currConnectionGroup, width);
            b     = gen.Generate();
            bytes = ImageUtilities.BitmapToBytes(b, ImageFormat.Png);
            images.Add(bytes);
            hotspotLists.Add(gen.Hotspots);
        }

        pnlNoCorrelations.Visible = images.Count == 0;

        if (images.Count > 0)
        {
            displayDiagrams(images.ToArray(), hotspotLists);
        }
    }
Exemple #2
0
        public LiteDBContext(IConfiguration configuration)
        {
            var  databaseFilePath   = configuration["DatabaseFilePath"];
            bool databaseFileExists = File.Exists(databaseFilePath);
            var  databaseFile       = new LiteDatabase(databaseFilePath);

            CreateMappings(databaseFile);
            if (!databaseFileExists)
            {
                var generator = new DiagramGenerator();
                int count     = 10000;
                databaseFile.GetCollection <Diagram>().Insert(generator.GetDefaultDiagram(count).ToList());
                databaseFile.GetCollection <DiagramThumbnail>().Insert(generator.GetDefaultDiagramThumbnail(count).ToList());
                databaseFile.GetCollection <DiagramMeta>().Insert(generator.GetDefaultDiagramMeta(count).ToList());
                databaseFile.GetCollection <Diagram>().Insert(generator.GetBigDiagram100());
                databaseFile.GetCollection <DiagramMeta>().Insert(generator.GetBigDiagram100Meta());
            }
            RepositoryFactory = new LiteDBRepositoryFactory(databaseFile);
        }
        /// <summary>
        /// Event Handler for clicking "Save Settings"
        /// </summary>
        /// <param name="sender">The Button initiating the click</param>
        /// <param name="e">Event arguments</param>
        private void SaveSettingsButton_Click(object sender, RoutedEventArgs e)
        {
            if (AllDataEntered(diagramHandler.DiagramInformation))
            {
                diagramHandler.CreateDiagramInformationObject(DiaTitleTextBox.Text, int.Parse(DiaIntervalXAxisTextBox.Text), int.Parse(DiaIntervalYAxisTextBox.Text), int.Parse(DiaDivisionsXAxisTextBox.Text), int.Parse(DiaDivisionsYAxisTextBox.Text), DiagramGrid.RowDefinitions[0].ActualHeight, DiagramGrid.ColumnDefinitions[1].ActualWidth);
                diagramHandler.CreatePointsGenerator();
                diagramGenerator = new DiagramGenerator(DiagramGrid.ColumnDefinitions[0].ActualWidth, DiagramGrid.RowDefinitions[0].ActualHeight, diagramHandler.DiagramInformation, diagramHandler.IntervalPointsGenerator.YPointsUsedInDiagramGeneration, diagramHandler.IntervalPointsGenerator.XPointsUsedInDiagramGeneration);
                DiagramGrid.Children.Add(diagramGenerator);

                DiagramSettingsGroupBox.IsEnabled = false;
                PointsGroupBox.IsEnabled          = true;
                ClearDiagramButton.IsEnabled      = true;

                ClearDiagramSettingsInput();
            }
            else
            {
                MessageBoxes.ShowErrorMessageBox("You have not entered all data needed");
            }
        }
Exemple #4
0
        protected override DrawingElement DrawDiagram(IRenderContext context)
        {
            var dashboardName = context.OwinContext.Request.Query["name"];

            return(DiagramGenerator.GenerateDashboardDrawing(dashboardName));
        }
Exemple #5
0
    private void loadCorrelations()
    {
        DataTable data;
        Dictionary <int, DiagramNode> nodes;
        List <DiagramNodeConnection>  connections;
        int?selectedSiteId;

        nodes       = new Dictionary <int, DiagramNode>();
        connections = new List <DiagramNodeConnection>();

        selectedSiteId = siteList.GetSelectedSiteId();
        if (selectedSiteId == null)
        {
            return;
        }

        data = _db.Report_DatasourceCorrelations(selectedSiteId.Value);
        //data = _db.Report_DatasourceCorrelations(8);

        for (int i = 0; i < data.Rows.Count; i++)
        {
            DiagramNode node;
            int         nodeId, otherNodeId;
            string      name, otherName;

            nodeId = (int)data.Rows[i]["ConfiguredDatasourceId"];
            name   = (string)data.Rows[i]["Name"];
            if (nodes.ContainsKey(nodeId))
            {
                node = nodes[nodeId];
            }
            else
            {
                nodes.Add(nodeId, new DiagramNode(DiagramGenerator.WrapText(name, 15), nodeId, null));
            }

            otherNodeId = (int)data.Rows[i]["OtherDatasourceId"];
            otherName   = (string)data.Rows[i]["OtherName"];
            if (nodes.ContainsKey(otherNodeId))
            {
                node = nodes[otherNodeId];
            }
            else
            {
                nodes.Add(otherNodeId, new DiagramNode(DiagramGenerator.WrapText(otherName, 15), otherNodeId, null));
            }

            string strength;

            strength = (string)data.Rows[i]["StrengthLabel"];

            if (strength != "None")
            {
                DiagramNodeConnection connection;
                connection = new DiagramNodeConnection();
                if (strength == "Large")
                {
                    connection.ConnectorWidth = 3;
                }
                else if (strength == "Medium")
                {
                    connection.ConnectorWidth = 2;
                }
                else
                {
                    connection.ConnectorWidth = 1;
                }

                connection.FirstNode  = nodes[nodeId];
                connection.SecondNode = nodes[otherNodeId];
                connections.Add(connection);
            }
        }

        processNodesAndConnections(connections);
    }
Exemple #6
0
        public async Task ExecuteAsync(string destinationDirectory, string solutionName, List <KSolutionGroup> solutionGroupList)
        {
            if (string.IsNullOrWhiteSpace(solutionName))
            {
                throw new ApplicationException("Solution name not specified");
            }
            var sw = Stopwatch.StartNew();

            ProgressChanged(this, new KickstartProgressChangedEventArgs()
            {
                ProgressPercentChange = 10, ProgressMessage = "Generation Started"
            });
            var connectionString = "Server=localhost;";
            var timeString       = DateTime.Now.ToString("yyyyMMddHHmmss");

            KickstartCoreService.SetCompanyNameOnProjects(solutionGroupList);
            KickstartCoreService.ConfigureMetaData(solutionGroupList, destinationDirectory);
            ProgressChanged(this, new KickstartProgressChangedEventArgs()
            {
                ProgressPercentChange = 5, ProgressMessage = ""
            });
            //deploy sql code to temp db, convert to K objects
            _kickstartCoreService.BuildSqlMeta(destinationDirectory, connectionString, solutionGroupList);
            ProgressChanged(this, new KickstartProgressChangedEventArgs()
            {
                ProgressPercentChange = 5, ProgressMessage = "Sql objects created on WorkDb"
            });


            AddProtoRefs(solutionGroupList);
            ProgressChanged(this, new KickstartProgressChangedEventArgs()
            {
                ProgressPercentChange = 5, ProgressMessage = ""
            });

            //pass 2
            //generate C objects from K objects
            _solutionGenerator.GenerateCSolutions(destinationDirectory, connectionString, solutionGroupList);
            ProgressChanged(this, new KickstartProgressChangedEventArgs()
            {
                ProgressPercentChange = 5, ProgressMessage = "Pass 2: K object transformed to C objects"
            });

            //save the K/C meta to Excel
            //Excel can be tweaked, and used as Meta source
            //_kSolutionGroupToExcelConverter.OutputPath = Path.Combine(destinationDirectory, $"{timeString}.xlsx");
            //_kSolutionGroupToExcelConverter.Convert(solutionGroupList);

            ProgressChanged(this, new KickstartProgressChangedEventArgs()
            {
                ProgressPercentChange = 5, ProgressMessage = ""
            });


            //Pass 3
            //generate Code from C objects
            _codeGenerator.GenerateCode(solutionGroupList, destinationDirectory);
            ProgressChanged(this, new KickstartProgressChangedEventArgs()
            {
                ProgressPercentChange = 5, ProgressMessage = "Pass 3: Code generated"
            });

            _solutionVisitor.AddProjectsToApplication(solutionGroupList, destinationDirectory);
            ProgressChanged(this, new KickstartProgressChangedEventArgs()
            {
                ProgressPercentChange = 5, ProgressMessage = "Pass 3: Projects added to solution"
            });

            if (solutionGroupList.Count > 1 || solutionGroupList.First().Solution.Count > 1)
            {
                //only do if there are multiple solutions
                _solutionVisitor.AddAllProjectsToMasterSln(solutionGroupList, destinationDirectory, solutionName);
            }
            ProgressChanged(this, new KickstartProgressChangedEventArgs()
            {
                ProgressPercentChange = 5, ProgressMessage = ""
            });

            BatchFileService.GenerateRestoreScript(solutionGroupList, destinationDirectory);
            BatchFileService.GenerateBuildScript(solutionGroupList, destinationDirectory);
            BatchFileService.GenerateDeployDbScript(solutionGroupList, destinationDirectory);
            BatchFileService.GenerateRunServicesScript(solutionGroupList, destinationDirectory);
            BatchFileService.GenerateRunTestClientScript(solutionGroupList, destinationDirectory);

            //Pass4
            //create diagrams

            DiagramGenerator.GenerateDiagram(destinationDirectory, solutionGroupList);
            ProgressChanged(this, new KickstartProgressChangedEventArgs()
            {
                ProgressPercentChange = 5, ProgressMessage = "Pass 4: Diagrams generated"
            });
            ProgressChanged(this, new KickstartProgressChangedEventArgs()
            {
                ProgressPercentChange = 100, ProgressMessage = $"Completed in {sw.Elapsed.TotalSeconds}.{sw.Elapsed.Milliseconds}s"
            });



            System.Console.WriteLine($"Completed in {sw.Elapsed.ToString()}");
        }
Exemple #7
0
        public SimpleDBContext(IConfiguration configuration)
        {
            var databaseFilePath = configuration["DatabaseFilePath"];
            var isNewDatabase    = !File.Exists(databaseFilePath);

            var builder = DBEngineBuilder.Make();

            builder.DatabaseFilePath(databaseFilePath);

            builder.Map <Diagram>()
            .PrimaryKey(x => x.Id)
            .Field(1, x => x.Title)
            .Field(2, x => x.Items, new FieldSettings {
                Compressed = true
            })
            .Field(3, x => x.Relations, new FieldSettings {
                Compressed = true
            })
            .Field(4, x => x.Width)
            .Field(5, x => x.Height)
            .MakeFunction(() => new Diagram())
            .PrimaryKeySetFunction((primaryKeyValue, entity) => entity.Id = (string)primaryKeyValue)
            .FieldSetFunction((fieldNumber, fieldValue, entity) =>
            {
                if (fieldNumber == 1)
                {
                    entity.Title = (string)fieldValue;
                }
                if (fieldNumber == 2)
                {
                    entity.Items = (List <DiagramItem>)fieldValue;
                }
                if (fieldNumber == 3)
                {
                    entity.Relations = (List <Relation>)fieldValue;
                }
                if (fieldNumber == 4)
                {
                    entity.Width = (float)fieldValue;
                }
                if (fieldNumber == 5)
                {
                    entity.Height = (float)fieldValue;
                }
            });

            builder.Map <DiagramThumbnail>()
            .PrimaryKey(x => x.DiagramId)
            .Field(1, x => x.Content, new FieldSettings {
                Compressed = true
            })
            .MakeFunction(() => new DiagramThumbnail())
            .PrimaryKeySetFunction((primaryKeyValue, entity) => entity.DiagramId = (string)primaryKeyValue)
            .FieldSetFunction((fieldNumber, fieldValue, entity) =>
            {
                if (fieldNumber == 1)
                {
                    entity.Content = (string)fieldValue;
                }
            });

            builder.Map <DiagramMeta>()
            .PrimaryKey(x => x.DiagramId)
            .Field(1, x => x.Title)
            .Field(2, x => x.TitleLetter)
            .Field(3, x => x.TitleNumber)
            .Field(4, x => x.CreateDate)
            .Field(5, x => x.UpdateDate)
            .MakeFunction(() => new DiagramMeta())
            .PrimaryKeySetFunction((primaryKeyValue, entity) => entity.DiagramId = (string)primaryKeyValue)
            .FieldSetFunction((fieldNumber, fieldValue, entity) =>
            {
                if (fieldNumber == 1)
                {
                    entity.Title = (string)fieldValue;
                }
                if (fieldNumber == 2)
                {
                    entity.TitleLetter = (string)fieldValue;
                }
                if (fieldNumber == 3)
                {
                    entity.TitleNumber = (int)fieldValue;
                }
                if (fieldNumber == 4)
                {
                    entity.CreateDate = (DateTime)fieldValue;
                }
                if (fieldNumber == 5)
                {
                    entity.UpdateDate = (DateTime)fieldValue;
                }
            });

            builder.Index <DiagramMeta>()
            .Name("title")
            .For(x => x.Title);

            builder.Index <DiagramMeta>()
            .Name("titleLetter")
            .For(x => x.TitleLetter);

            builder.Index <DiagramMeta>()
            .Name("titleNumber")
            .For(x => x.TitleNumber);

            builder.Index <DiagramMeta>()
            .Name("createDate")
            .For(x => x.CreateDate);

            builder.Index <DiagramMeta>()
            .Name("updateDate")
            .For(x => x.UpdateDate);

            builder.Index <DiagramThumbnail>()
            .Name("content")
            .For(x => x.DiagramId)
            .Include(x => x.Content);

            _engine = builder.BuildEngine();

            if (isNewDatabase)
            {
                var generator = new DiagramGenerator();
                int count     = 100000;
                _engine.GetCollection <Diagram>().Insert(generator.GetDefaultDiagram(count));
                _engine.GetCollection <DiagramThumbnail>().Insert(generator.GetDefaultDiagramThumbnail(count));
                _engine.GetCollection <DiagramMeta>().Insert(generator.GetDefaultDiagramMeta(count));
            }

            RepositoryFactory = new SimpleDBRepositoryFactory(_engine);
        }