示例#1
0
        public override void Execute(object parameter)
        {
            if (Current.ActiveDiagram != null && Current.ActiveDiagram.Schema is PSMSchema)
            {
                ModelVerifier verifier = new ModelVerifier();

                if (!verifier.TestSchemaNormalized((PSMSchema)Current.ActiveDiagram.Schema))
                {
                    #if SILVERLIGHT
                    ExolutioMessageBox.Show("Normalization", "Schema is not normalized", "Check command log window for details.");
                    #else
                    ExolutioMessageBox.Show("Normalization", "Schema is not normalized", "Check command log window for details.");
                    #endif
                    Current.MainWindow.DisplayLog(verifier.Log, true);
                }
                else
                {
                    #if SILVERLIGHT
                    ExolutioMessageBox.Show("Normalization", "Normalization passed", "Schema is normalized");
                    #else
                    ExolutioMessageBox.Show("Normalization", "Normalization passed", "Schema is normalized");
                    #endif
                    Current.MainWindow.DisplayReport(new CommandReport("Schema is normalized. "), true);
                }
            }
        }
示例#2
0
        public override void Execute(object parameter)
        {
            Updater.Updater      updater = new Updater.Updater();
            IEnumerable <string> files   = Directory.GetFiles(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "*.dll").Concat(Directory.GetFiles(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "*.exe"));

            Dictionary <string, Version> clientVersions = new Dictionary <string, Version>();

            foreach (string file in files)
            {
                Version clientVersion = AssemblyName.GetAssemblyName(file).Version;
                clientVersions[Path.GetFileName(file)] = clientVersion;
            }

            Dictionary <string, Version> newAvailableVersions;

            if (updater.AreNewVersionsAvailable(clientVersions, out newAvailableVersions) && ExolutioYesNoBox.ShowYesNoCancel("New version available", "New version is available. \r\nDo you wish to update?") == MessageBoxResult.Yes)
            {
                System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo("Exolutio.Updater.exe");
                info.UseShellExecute = true;
                (Current.MainWindow).Close();
                System.Diagnostics.Process.Start(info);
            }
            else
            {
                ExolutioMessageBox.Show("Exolutio Update", "Updates checked", "This is the latest version.");
            }
        }
示例#3
0
        public override void Execute(object parameter)
        {
            if (Current.ActiveDiagram != null && Current.ActiveDiagram.Schema is PSMSchema)
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter           = "XML files (*.xml)|*.xml|All files (*.*)|*.*";
                openFileDialog.FilterIndex      = 1;
                openFileDialog.RestoreDirectory = true;
                openFileDialog.Multiselect      = false;

                String fileToCheck = null;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    fileToCheck = openFileDialog.FileName;

                    PushDownAutomat  pda = new PushDownAutomat();
                    ValidationResult validationResult = null;
                    try
                    {
                        pda.inicialize((PSMSchema)Current.ActiveDiagram.Schema, fileToCheck);
                    }
                    catch (System.Xml.XmlException e)
                    {
                        validationResult = new ValidationResult(false, e.Message);
                    }
                    if (validationResult == null)
                    {
                        validationResult = pda.processTree();
                    }
                    ExolutioMessageBox.Show("Validation", "Validation Result", validationResult.Message);
                }
            }
        }
示例#4
0
 public override void Execute(object parameter)
 {
     Tests.ModelIntegrity.ModelConsistency.CheckProject(Current.Project);
     #if SILVERLIGHT
     ExolutioMessageBox.Show("Verified", "Test passed", "Model consistency checked successfuly.");
     #else
     ExolutioMessageBox.Show("Verified", "Test passed", "Model consistency checked successfuly.");
     #endif
 }
示例#5
0
        public override void Execute(object parameter)
        {
            String validationResults = "";

            System.Collections.Generic.IList <DiagramView> diagrams = Current.MainWindow.DiagramTabManager.GetOpenedDiagramViews();
            foreach (DiagramView diagram in diagrams)
            {
                if (diagram.Diagram.Schema is PSMSchema)
                {
                    string coreFileName = ((PSMSchema)diagram.Diagram.Schema).PSMSchemaClass.Name;

                    System.IO.DirectoryInfo dirInfo   = diagram.Diagram.Project.ProjectFile.Directory;
                    System.IO.FileInfo[]    fileNames = dirInfo.GetFiles("*.xml");
                    foreach (System.IO.FileInfo file in fileNames)
                    {
                        bool startsWith  = file.Name.StartsWith(coreFileName);
                        bool followedByO = coreFileName.Length < file.Name.Length && file.Name.Substring(coreFileName.Length).StartsWith("O");
                        bool followedByF = coreFileName.Length < file.Name.Length && file.Name.Substring(coreFileName.Length).StartsWith("F");
                        if (startsWith && (followedByO || followedByF))
                        {
                            PushDownAutomat  pda = new PushDownAutomat();
                            ValidationResult validationResult = null;
                            bool             validate         = true;
                            try
                            {
                                pda.inicialize((PSMSchema)diagram.Diagram.Schema, file.FullName);
                            }
                            catch (System.Xml.XmlException e)
                            {
                                validationResult = new ValidationResult(false, e.Message);
                            }
                            catch (Exception e) {
                                validationResults += "Soubor " + file.Name + " neodpovida modelu " + coreFileName + ". Nastala chyba: " + e.Message + System.Environment.NewLine;
                                validate           = false;
                            }
                            if (validate)
                            {
                                if (validationResult == null)
                                {
                                    validationResult = pda.processTree();
                                }
                                if ((!validationResult.Successful && file.Name.Substring(coreFileName.Length).StartsWith("O")) || validationResult.Successful && file.Name.Substring(coreFileName.Length).StartsWith("F"))
                                {
                                    validationResults += "Soubor " + file.Name + " neodpovida modelu " + coreFileName + "." + System.Environment.NewLine;
                                }
                            }
                        }
                    }
                }
            }

            ExolutioMessageBox.Show("Validation", "Validation Result", validationResults);
        }
示例#6
0
        private void bValidateNew_Click(object sender, RoutedEventArgs e)
        {
            XsdValidator validator = new XsdValidator();
            bool         valid     = validator.ValidateDocument(schemaVersion2, tbNewDoc.Text);

            if (valid)
            {
                ExolutioMessageBox.Show("Validation", "Valid", "The new version is valid.");
            }
            else
            {
                ExolutioErrorMsgBox.Show("ERROR - The new version is not valid!", validator.ErrorMessage);
            }
        }
示例#7
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog
            {
                CheckFileExists = false,
                DefaultExt      = "xslt",
                Filter          = "XSLT Transformations|*.xslt"
            };

            string path = System.IO.Path.GetDirectoryName(schemaVersion2.Project.ProjectFile.FullName) +
                          //"\\" + System.IO.Path.GetFileNameWithoutExtension(schemaVersion2.Project.ProjectFile.FullName) + "-out" +
                          "\\SavedStylesheet.xslt";

            string xsdpath = System.IO.Path.GetDirectoryName(schemaVersion2.Project.ProjectFile.FullName) +
                             "\\LastSchema.xsd";

            XsdSchemaGenerator schemaGenerator = new XsdSchemaGenerator();

            schemaGenerator.Initialize(SchemaVersion1);
            schemaGenerator.GenerateXSDStructure();
            XDocument xmlSchemaDocument = schemaGenerator.GetXsd();

            if (path.Contains("Tests\\OCLAdaptation"))
            {
                if (!Directory.Exists(System.IO.Path.GetDirectoryName(path)))
                {
                    Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path));
                }
                XmlDocumentHelper.SaveInUtf8(tbXslt.Text, path);
                xmlSchemaDocument.SaveInUtf8(xsdpath);
                ExolutioMessageBox.Show("Saved", "Saved", string.Empty);
            }
            else if (saveFileDialog.ShowDialog() == true)
            {
                XmlDocumentHelper.SaveInUtf8(tbXslt.Text, saveFileDialog.FileName);
                xmlSchemaDocument.SaveInUtf8(xsdpath);
                ExolutioMessageBox.Show("Saved", "Saved", string.Empty);
            }
        }
示例#8
0
        private void ValidateDocumentAgainstSchema(XDocument schemaXSD)
        {
            XmlReader    xmlfile       = null;
            XmlReader    schemaReader  = null;
            MemoryStream _msSchemaText = null;

            isValidAgainstSchema         = true;
            abortValidationAgainstSchema = false;
            try
            {
                _msSchemaText = new MemoryStream();
                string tmp = System.IO.Path.GetTempFileName();
                schemaXSD.Save(tmp);
                schemaReader = new XmlTextReader(File.OpenRead(tmp));
                XmlSchema         schema         = XmlSchema.Read(schemaReader, schemaSettings_ValidationEventHandler);
                XmlReaderSettings schemaSettings = new XmlReaderSettings();
                schemaSettings.Schemas.Add(schema);
                foreach (XmlSchema s in schemaSettings.Schemas.Schemas())
                {
                    StringBuilder sb = new StringBuilder();
                    StringWriter  sw = new StringWriter(sb);
                    s.Write(sw);
                    sw.Flush();
                }

                schemaSettings.ValidationType          = ValidationType.Schema;
                schemaSettings.ValidationEventHandler += schemaSettings_ValidationEventHandler;

                try
                {
                    xmlfile = XmlReader.Create(new StringReader(fileView.FileContents), schemaSettings);
                }
                catch (XmlSchemaValidationException ex)
                {
                    isValidAgainstSchema = false;
                    ExolutioErrorMsgBox.Show("Invalid schema",
                                             string.Format("Validation can not continue - schema is invalid. \r\n\r\n{0}",
                                                           ex.Message));
                    return;
                }

                if (isValidAgainstSchema)
                {
                    while (xmlfile.Read() && !abortValidationAgainstSchema)
                    {
                    }
                }
            }
            catch (XmlSchemaValidationException ex)
            {
                isValidAgainstSchema = false;
                ExolutioErrorMsgBox.Show("Invalid document",
                                         string.Format("{0} \r\n\r\nValidation can not continue.", ex.Message));
            }
            catch (Exception ex)
            {
                isValidAgainstSchema = false;
                ExolutioErrorMsgBox.Show("Invalid document",
                                         string.Format("{0} \r\n\r\nValidation can not continue.", ex.Message));
            }
            finally
            {
                if (xmlfile != null)
                {
                    xmlfile.Close();
                }
                if (schemaReader != null)
                {
                    schemaReader.Close();
                }
                if (_msSchemaText != null)
                {
                    _msSchemaText.Dispose();
                }
            }

            if (isValidAgainstSchema)
            {
                ExolutioMessageBox.Show("Validation successful", "Document is valid",
                                        "Validation against the XML schema passed successfuly. ");
            }
        }