Beispiel #1
0
        private void buttonExportCsp_Click(object sender, EventArgs e)
        {
            checkForFunctions();
            if (activateExportImportCSPButton)
            {
                String cspXmlString = "";

                String pathToWrite = Path.GetDirectoryName(repository.ConnectionString);

                SaveFileDialog dialog = new SaveFileDialog();
                dialog.AddExtension     = true;
                dialog.DefaultExt       = "txt";
                dialog.InitialDirectory = pathToWrite;
                dialog.Filter           = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
                dialog.FileName         = "csptemp.txt";



                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    TGG tggPackage = new TGG(repository, repository.GetTreeSelectedPackage());
                    tggPackage.loadTreeFromTaggedValue();
                    MocaNode dummyNode = new MocaNode();

                    foreach (CSPConstraint constraint in tggPackage.Constraints)
                    {
                        if (constraint.UserDefined)
                        {
                            dummyNode.Children.Add(constraint.serializeToMocaTree(new MocaNode("CSPConstraint")));
                        }
                    }
                    cspXmlString = MocaTreeUtil.mocaNodeToString(dummyNode);

                    pathToWrite = dialog.FileName;
                    File.WriteAllText(pathToWrite, cspXmlString);
                    MessageBox.Show("User defined CSPs are exported to path: " + pathToWrite);
                }
            }
        }