Esempio n. 1
0
        public void TestEnumInRoot()
        {
            FileStream file = new FileStream("data.dat", FileMode.Create);
            IndexedFileStorage storage = new IndexedFileStorage(file, 256, true);
            Context ctx = new Context(typeof(IDataEnumModel), null, storage);

            using (var ws = ctx.OpenWorkspace<IDataEnumModel>(IsolationLevel.Exclusive))
            {
                IDataEnumModel database = ws.Data;
                ws.Data.firstEnum = EnumsEnglish.FirstValue;
                ws.Data.secondEnum = EnumsSrpski.DrugaVrednost;
                ws.Data.intNumber = 100;
                ws.Commit();
            }

            ctx.Dispose();
            storage.Dispose();
            file.Close();

            file = new FileStream("data.dat", FileMode.Open);
            storage = new IndexedFileStorage(file, 256, true);
            TypesVisualisationService service = new TypesVisualisationService(storage);
            string content = service.GetGraphVizContentFromStorage(storage);
            System.IO.File.WriteAllText("TestEnumInRoot.gv", content);

            storage.Dispose();
            file.Close();
        }
Esempio n. 2
0
        public void TestTextTemplateGenerationRemotely()
        {
            CreateDatFile();
            FileStream file = new FileStream("data.dat", FileMode.Open);
            IndexedFileStorage storage = new IndexedFileStorage(file, 256, true);
            TypesVisualisationService service = new TypesVisualisationService(storage);
            string content = service.GetGraphVizContentFromStorage(storage);
            System.IO.File.WriteAllText("templateOutputRemote.gv", content);
            Assert.IsTrue(true);

            storage.Dispose();
            file.Close();
        }
Esempio n. 3
0
        private void btnCreateGVFile_Click(object sender, EventArgs e)
        {
            disableControls();
            this.Cursor = Cursors.WaitCursor;
            Application.DoEvents();

            try
            {
                string gvContent = null;
                string chosenTypeName = null;
                //Opening the storage
                using (FileStream file = new FileStream(filePath, FileMode.Open))
                using (var storage = new IndexedFileStorage(file, clusterSize, safeWrite, header))
                {
                    TypesVisualisationService typesVisualisationService = new TypesVisualisationService(storage);
                    string rootTypeName = typesVisualisationService.getRootTypeName();
                    if (rbRootType.Checked)
                    {
                        chosenTypeName = rootTypeName;
                        gvContent = typesVisualisationService.GetGraphVizContentFromStorage(storage);

                    }
                    else
                    {
                        //Opening the dialog for choosing a type.
                        ChooseTypeForm chooseTypeForm = new ChooseTypeForm(typesVisualisationService.GetTypeVisualUnits(typesVisualisationService.GetRootTypeId()), rootTypeName);
                        if (chooseTypeForm.ShowDialog() == DialogResult.OK)
                        {
                            chosenTypeName = chooseTypeForm.CurrentType.Name;
                            gvContent = typesVisualisationService.GetGraphVizContentFromStorage(chosenTypeName, storage);
                        }
                    }
                }
                if (gvContent != null)
                {
                    this.Cursor = Cursors.WaitCursor;
                    Application.DoEvents();

                    //creating the filename for the image.
                    string fileLocation = filePath.Substring(0, filePath.LastIndexOf("\\") + 1);
                    string fileName = Path.GetFileNameWithoutExtension(filePath) + "_" + chosenTypeName;
                    string pngExtension = ".png";
                    string newFilePathPng = fileLocation + fileName + pngExtension;
                    int occurance = 0;
                    while (File.Exists(newFilePathPng))
                    {
                        occurance++;
                        newFilePathPng = fileLocation + fileName + occurance + pngExtension;
                    }

                    //Calling dot.exe to generate the image.
                    var getStartProcessQuery = new GetStartProcessQuery();
                    var getProcessStartInfoQuery = new GetProcessStartInfoQuery();
                    var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery,getStartProcessQuery);
                    var wrapper = new GraphVizWrapper.GraphVizWrapper(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand);

                    byte[] output = wrapper.GenerateGraph(gvContent, Enums.GraphReturnType.Png);
                    File.WriteAllBytes(newFilePathPng, output);

                    panStatus.Visible = true;
                    tbStatus.Text = newFilePathPng;

                }

            }
            catch (FileNotFoundException ex)
            {
                String message = "File Path is invalid! The file has probably been moved or removed since opening it.\n Please check the file location.";
                ExceptionDialog exDialog = new ExceptionDialog(message, ex);
                exDialog.ShowDialog();
            }
            catch (Exception ex)
            {
                String message = "An exception has occured. Please consult the exception log below.";
                ExceptionDialog exDialog = new ExceptionDialog(message, ex);
                exDialog.ShowDialog();
            }
            enableControls();
            this.Cursor = Cursors.Default;
            Application.DoEvents();
        }