Exemplo n.º 1
0
        private static Mks CreateMks(string xml, IHistoryParser historyParser, ProcessExecutor executor)
        {
            Mks newMks = new Mks(historyParser, executor);

            NetReflector.Read(xml, newMks);
            return(newMks);
        }
Exemplo n.º 2
0
        public void GetModificationsCallsParseMemberInfo()
        {
            Modification addedModification = ModificationMother.CreateModification("myFile.file", "MyFolder");

            addedModification.Type = "Added";

            mksHistoryParserWrapper.ExpectAndReturn("Parse", new Modification[] { addedModification }, new IsTypeOf(typeof(TextReader)), FROM, TO);
            mksHistoryParserWrapper.ExpectAndReturn("ParseMemberInfoAndAddToModification", new Modification[] { addedModification }, new IsTypeOf(typeof(Modification)), new IsTypeOf(typeof(StringReader)));
            mockExecutorWrapper.ExpectAndReturn("Execute", new ProcessResult("", null, 0, false), new IsTypeOf(typeof(ProcessInfo)));

            string expectedCommand = string.Format(@"memberinfo --xmlapi --user=CCNetUser --password=CCNetPassword --quiet {0}",
                                                   GeneratePath(@"{0}\MyFolder\myFile.file", sandboxRoot));
            ProcessInfo expectedProcessInfo = ExpectedProcessInfo(expectedCommand);

            mockExecutorWrapper.ExpectAndReturn("Execute", new ProcessResult(null, null, 0, false), expectedProcessInfo);

            string      expectedDisconnectCommand     = string.Format(@"disconnect --user=CCNetUser --password=CCNetPassword --quiet --forceConfirm=yes");
            ProcessInfo expectedDisconnectProcessInfo = ExpectedProcessInfo(expectedDisconnectCommand);

            mockExecutorWrapper.ExpectAndReturn("Execute", new ProcessResult(null, null, 0, false), expectedDisconnectProcessInfo);

            mks = CreateMks(CreateSourceControlXml(), mksHistoryParser, mockProcessExecutor);
            Modification[] modifications = mks.GetModifications(IntegrationResultMother.CreateSuccessful(FROM), IntegrationResultMother.CreateSuccessful(TO));
            Assert.AreEqual(1, modifications.Length);
        }
Exemplo n.º 3
0
        public void GetModificationsForModificationInRootFolder()
        {
            sandboxRoot = TempFileUtil.GetTempPath("MksSandBox");

            Modification addedModification = ModificationMother.CreateModification("myFile.file", null);

            addedModification.Type = "Added";

            mksHistoryParserWrapper.Setup(parser => parser.Parse(It.IsAny <TextReader>(), FROM, TO)).Returns(new Modification[] { addedModification }).Verifiable();
            mksHistoryParserWrapper.Setup(parser => parser.ParseMemberInfoAndAddToModification(It.IsAny <Modification>(), It.IsAny <StringReader>())).Verifiable();
            mockExecutorWrapper.Setup(executor => executor.Execute(It.IsAny <ProcessInfo>())).Returns(new ProcessResult("", null, 0, false)).Verifiable();

            string expectedCommand = string.Format(@"memberinfo --xmlapi --user=CCNetUser --password=CCNetPassword --quiet {0}",
                                                   GeneratePath(@"{0}\myFile.file", sandboxRoot));
            ProcessInfo expectedProcessInfo = ExpectedProcessInfo(expectedCommand);

            mockExecutorWrapper.Setup(executor => executor.Execute(expectedProcessInfo)).Returns(new ProcessResult(null, null, 0, false)).Verifiable();

            string      expectedDisconnectCommand     = string.Format(@"disconnect --user=CCNetUser --password=CCNetPassword --quiet --forceConfirm=yes");
            ProcessInfo expectedDisconnectProcessInfo = ExpectedProcessInfo(expectedDisconnectCommand);

            mockExecutorWrapper.Setup(executor => executor.Execute(expectedDisconnectProcessInfo)).Returns(new ProcessResult(null, null, 0, false)).Verifiable();

            mks = CreateMks(CreateSourceControlXml(), mksHistoryParser, mockProcessExecutor);
            Modification[] modifications = mks.GetModifications(IntegrationResultMother.CreateSuccessful(FROM), IntegrationResultMother.CreateSuccessful(TO));
            Assert.AreEqual(1, modifications.Length);
        }
Exemplo n.º 4
0
        public void CheckDefaults()
        {
            Mks defalutMks = new Mks();

            Assert.AreEqual(@"si.exe", defalutMks.Executable);
            Assert.AreEqual(8722, defalutMks.Port);
            Assert.AreEqual(true, defalutMks.AutoGetSource);
            Assert.AreEqual(false, defalutMks.CheckpointOnSuccess);
            Assert.AreEqual(false, defalutMks.AutoDisconnect);
        }
Exemplo n.º 5
0
        public void CheckpointSourceOnUnSuccessfulBuild()
        {
            string      expectedDisconnectCommand     = string.Format(@"disconnect --user=CCNetUser --password=CCNetPassword --quiet --forceConfirm=yes");
            ProcessInfo expectedDisconnectProcessInfo = ExpectedProcessInfo(expectedDisconnectCommand);

            mockExecutorWrapper.ExpectAndReturn("Execute", new ProcessResult(null, null, 0, false), expectedDisconnectProcessInfo);

            mockIntegrationResult.ExpectAndReturn("Succeeded", false);
            mockIntegrationResult.ExpectNoCall("Label", typeof(string));

            mks = CreateMks(CreateSourceControlXml(), mockHistoryParser, mockProcessExecutor);
            mks.LabelSourceControl(integrationResult);
        }
Exemplo n.º 6
0
        public void CheckpointSourceOnUnSuccessfulBuild()
        {
            string      expectedDisconnectCommand     = string.Format(@"disconnect --user=CCNetUser --password=CCNetPassword --quiet --forceConfirm=yes");
            ProcessInfo expectedDisconnectProcessInfo = ExpectedProcessInfo(expectedDisconnectCommand);

            mockExecutorWrapper.Setup(executor => executor.Execute(expectedDisconnectProcessInfo)).Returns(new ProcessResult(null, null, 0, false)).Verifiable();

            mockIntegrationResult.SetupGet(result => result.Succeeded).Returns(false).Verifiable();

            mks = CreateMks(CreateSourceControlXml(), mockHistoryParser, mockProcessExecutor);
            mks.LabelSourceControl(integrationResult);

            mockIntegrationResult.Verify();
            mockIntegrationResult.VerifyNoOtherCalls();
        }
Exemplo n.º 7
0
        public void ValuePopulation()
        {
            mks = CreateMks(CreateSourceControlXml(), null, null);

            Assert.AreEqual(@"..\bin\si.exe", mks.Executable);
            Assert.AreEqual(@"hostname", mks.Hostname);
            Assert.AreEqual(8722, mks.Port);
            Assert.AreEqual(@"CCNetUser", mks.User);
            Assert.AreEqual(@"CCNetPassword", mks.Password);
            Assert.AreEqual(sandboxRoot, mks.SandboxRoot);
            Assert.AreEqual(@"myproject.pj", mks.SandboxFile);
            Assert.AreEqual(true, mks.AutoGetSource);
            Assert.AreEqual(true, mks.CheckpointOnSuccess);
            Assert.AreEqual(true, mks.AutoDisconnect);
        }
Exemplo n.º 8
0
        public void GetModificationsFiltersByModifiedTimeIfCheckpointOnSuccessIsFalse()
        {
            Modification modificationBeforePreviousIntegration = ModificationMother.CreateModification("ccnet", FROM.AddMinutes(-2));
            Modification modificationInThisIntegration         = ModificationMother.CreateModification("ccnet", TO.AddMinutes(-1));
            Modification modificationAfterIntegrationStartTime = ModificationMother.CreateModification("myFile.file", TO.AddMinutes(1));

            Modification[] integrationModifications = new Modification[] { modificationBeforePreviousIntegration, modificationInThisIntegration, modificationAfterIntegrationStartTime };
            mksHistoryParserWrapper.Setup(parser => parser.Parse(It.IsAny <TextReader>(), FROM, TO)).Returns(integrationModifications).Verifiable();
            mksHistoryParserWrapper.Setup(parser => parser.ParseMemberInfoAndAddToModification(modificationBeforePreviousIntegration, It.IsAny <StringReader>())).Verifiable();
            mksHistoryParserWrapper.Setup(parser => parser.ParseMemberInfoAndAddToModification(modificationInThisIntegration, It.IsAny <StringReader>())).Verifiable();
            mksHistoryParserWrapper.Setup(parser => parser.ParseMemberInfoAndAddToModification(modificationAfterIntegrationStartTime, It.IsAny <StringReader>())).Verifiable();
            mockExecutorWrapper.Setup(executor => executor.Execute(It.IsAny <ProcessInfo>())).Returns(new ProcessResult("", null, 0, false)).Verifiable();

            mks = CreateMks(CreateSourceControlXml(), mksHistoryParser, mockProcessExecutor);
            mks.CheckpointOnSuccess = false;
            Modification[] modifications = mks.GetModifications(IntegrationResultMother.CreateSuccessful(FROM), IntegrationResultMother.CreateSuccessful(TO));
            Assert.AreEqual(1, modifications.Length);
        }
Exemplo n.º 9
0
        public void GetModificationsFiltersByModifiedTimeIfCheckpointOnSuccessIsFalse()
        {
            Modification modificationBeforePreviousIntegration = ModificationMother.CreateModification("ccnet", FROM.AddMinutes(-2));
            Modification modificationInThisIntegration         = ModificationMother.CreateModification("ccnet", TO.AddMinutes(-1));
            Modification modificationAfterIntegrationStartTime = ModificationMother.CreateModification("myFile.file", TO.AddMinutes(1));

            Modification[] integrationModifications = new Modification[] { modificationBeforePreviousIntegration, modificationInThisIntegration, modificationAfterIntegrationStartTime };
            mksHistoryParserWrapper.ExpectAndReturn("Parse", integrationModifications, new IsTypeOf(typeof(TextReader)), FROM, TO);
            mksHistoryParserWrapper.ExpectAndReturn("ParseMemberInfoAndAddToModification", null, modificationBeforePreviousIntegration, new IsTypeOf(typeof(StringReader)));
            mksHistoryParserWrapper.ExpectAndReturn("ParseMemberInfoAndAddToModification", null, modificationInThisIntegration, new IsTypeOf(typeof(StringReader)));
            mksHistoryParserWrapper.ExpectAndReturn("ParseMemberInfoAndAddToModification", null, modificationAfterIntegrationStartTime, new IsTypeOf(typeof(StringReader)));
            mockExecutorWrapper.SetupResult("Execute", new ProcessResult("", null, 0, false), new Type[] { typeof(ProcessInfo) });

            mks = CreateMks(CreateSourceControlXml(), mksHistoryParser, mockProcessExecutor);
            mks.CheckpointOnSuccess = false;
            Modification[] modifications = mks.GetModifications(IntegrationResultMother.CreateSuccessful(FROM), IntegrationResultMother.CreateSuccessful(TO));
            Assert.AreEqual(1, modifications.Length);
        }
Exemplo n.º 10
0
        public void GetSourceWithSpacesInSandbox()
        {
            sandboxRoot = TempFileUtil.GetTempPath("Mks Sand Box");
            string expectedResyncCommand = string.Format(@"resync --overwriteChanged --restoreTimestamp --forceConfirm=yes --includeDropped -R -S ""{0}\myproject.pj"" --user=CCNetUser --password=CCNetPassword --quiet", sandboxRoot);

            mockExecutorWrapper.Setup(executor => executor.Execute(ExpectedProcessInfo(expectedResyncCommand))).Returns(new ProcessResult(null, null, 0, false)).Verifiable();

            string expectedAttribCommand = string.Format(@"-R /s ""{0}\*""", sandboxRoot);

            mockExecutorWrapper.Setup(executor => executor.Execute(ExpectedProcessInfo("attrib", expectedAttribCommand))).Returns(new ProcessResult(null, null, 0, false)).Verifiable();

            string      expectedDisconnectCommand     = string.Format(@"disconnect --user=CCNetUser --password=CCNetPassword --quiet --forceConfirm=yes");
            ProcessInfo expectedDisconnectProcessInfo = ExpectedProcessInfo(expectedDisconnectCommand);

            mockExecutorWrapper.Setup(executor => executor.Execute(expectedDisconnectProcessInfo)).Returns(new ProcessResult(null, null, 0, false)).Verifiable();

            mks = CreateMks(CreateSourceControlXml(), mockHistoryParser, mockProcessExecutor);
            mks.GetSource(new IntegrationResult());
        }
Exemplo n.º 11
0
        public void GetModificationsCallsParseOnHistoryParser()
        {
            mksHistoryParserWrapper.ExpectAndReturn("Parse", new Modification[0], new IsTypeOf(typeof(TextReader)), FROM, TO);
            mksHistoryParserWrapper.ExpectNoCall("ParseMemberInfoAndAddToModification", new Type[] { (typeof(Modification)), typeof(StringReader) });

            ProcessInfo expectedProcessInfo = ExpectedProcessInfo(string.Format(@"viewsandbox --nopersist --filter=changed:all --xmlapi -R -S {0} --user=CCNetUser --password=CCNetPassword --quiet",
                                                                                GeneratePath(@"{0}\myproject.pj", sandboxRoot)));

            mockExecutorWrapper.ExpectAndReturn("Execute", new ProcessResult(null, null, 0, false), expectedProcessInfo);

            string      expectedDisconnectCommand     = string.Format(@"disconnect --user=CCNetUser --password=CCNetPassword --quiet --forceConfirm=yes");
            ProcessInfo expectedDisconnectProcessInfo = ExpectedProcessInfo(expectedDisconnectCommand);

            mockExecutorWrapper.ExpectAndReturn("Execute", new ProcessResult(null, null, 0, false), expectedDisconnectProcessInfo);

            mks = CreateMks(CreateSourceControlXml(), mksHistoryParser, mockProcessExecutor);
            Modification[] modifications = mks.GetModifications(IntegrationResultMother.CreateSuccessful(FROM), IntegrationResultMother.CreateSuccessful(TO));
            Assert.AreEqual(0, modifications.Length);
        }
Exemplo n.º 12
0
        public void GetSource()
        {
            string expectedResyncCommand = string.Format(@"resync --overwriteChanged --restoreTimestamp --forceConfirm=yes --includeDropped -R -S {0} --user=CCNetUser --password=CCNetPassword --quiet",
                                                         GeneratePath(@"{0}\myproject.pj", sandboxRoot));

            mockExecutorWrapper.ExpectAndReturn("Execute", new ProcessResult(null, null, 0, false), ExpectedProcessInfo(expectedResyncCommand));
            string expectedAttribCommand = string.Format(@"-R /s {0}",
                                                         GeneratePath(@"{0}\*", sandboxRoot));

            mockExecutorWrapper.ExpectAndReturn("Execute", new ProcessResult(null, null, 0, false), ExpectedProcessInfo("attrib", expectedAttribCommand));

            string      expectedDisconnectCommand     = string.Format(@"disconnect --user=CCNetUser --password=CCNetPassword --quiet --forceConfirm=yes");
            ProcessInfo expectedDisconnectProcessInfo = ExpectedProcessInfo(expectedDisconnectCommand);

            mockExecutorWrapper.ExpectAndReturn("Execute", new ProcessResult(null, null, 0, false), expectedDisconnectProcessInfo);

            mks = CreateMks(CreateSourceControlXml(), mockHistoryParser, mockProcessExecutor);
            mks.GetSource(new IntegrationResult());
        }
Exemplo n.º 13
0
        public void CheckpointSourceOnSuccessfulBuild()
        {
            string      path                = GeneratePath(@"{0}\myproject.pj", sandboxRoot);
            string      expectedCommand     = string.Format(@"checkpoint -d ""Cruise Control.Net Build - 20"" -L ""Build - 20"" -R -S {0} --user=CCNetUser --password=CCNetPassword --quiet", path);
            ProcessInfo expectedProcessInfo = ExpectedProcessInfo(expectedCommand);

            mockExecutorWrapper.Setup(executor => executor.Execute(expectedProcessInfo)).Returns(new ProcessResult(null, null, 0, false)).Verifiable();

            string      expectedDisconnectCommand     = string.Format(@"disconnect --user=CCNetUser --password=CCNetPassword --quiet --forceConfirm=yes");
            ProcessInfo expectedDisconnectProcessInfo = ExpectedProcessInfo(expectedDisconnectCommand);

            mockExecutorWrapper.Setup(executor => executor.Execute(expectedDisconnectProcessInfo)).Returns(new ProcessResult(null, null, 0, false)).Verifiable();

            mockIntegrationResult.SetupGet(result => result.Succeeded).Returns(true).Verifiable();
            mockIntegrationResult.SetupGet(result => result.Label).Returns("20").Verifiable();

            mks = CreateMks(CreateSourceControlXml(), mockHistoryParser, mockProcessExecutor);
            mks.LabelSourceControl(integrationResult);
        }
Exemplo n.º 14
0
        public void GetSource()
        {
            string expectedResyncCommand = string.Format(@"resync --overwriteChanged --restoreTimestamp --forceConfirm=yes --includeDropped -R -S {0} --user=CCNetUser --password=CCNetPassword --quiet",
                                                         GeneratePath(@"{0}\myproject.pj".Replace('\\', System.IO.Path.DirectorySeparatorChar), sandboxRoot));

            mockExecutorWrapper.Setup(executor => executor.Execute(ExpectedProcessInfo(expectedResyncCommand))).Returns(new ProcessResult(null, null, 0, false)).Verifiable();
            string expectedAttribCommand = string.Format(@"-R /s {0}",
                                                         GeneratePath(@"{0}\*".Replace('\\', System.IO.Path.DirectorySeparatorChar), sandboxRoot));

            mockExecutorWrapper.Setup(executor => executor.Execute(ExpectedProcessInfo("attrib", expectedAttribCommand))).Returns(new ProcessResult(null, null, 0, false)).Verifiable();

            string      expectedDisconnectCommand     = string.Format(@"disconnect --user=CCNetUser --password=CCNetPassword --quiet --forceConfirm=yes");
            ProcessInfo expectedDisconnectProcessInfo = ExpectedProcessInfo(expectedDisconnectCommand);

            mockExecutorWrapper.Setup(executor => executor.Execute(expectedDisconnectProcessInfo)).Returns(new ProcessResult(null, null, 0, false)).Verifiable();

            mks = CreateMks(CreateSourceControlXml(), mockHistoryParser, mockProcessExecutor);
            mks.GetSource(new IntegrationResult());
        }
Exemplo n.º 15
0
        public void GetModificationsCallsParseOnHistoryParser()
        {
            mksHistoryParserWrapper.Setup(parser => parser.Parse(It.IsAny <TextReader>(), FROM, TO)).Returns(new Modification[0]).Verifiable();

            ProcessInfo expectedProcessInfo = ExpectedProcessInfo(string.Format(@"viewsandbox --nopersist --filter=changed:all --xmlapi -R -S {0} --user=CCNetUser --password=CCNetPassword --quiet",
                                                                                GeneratePath(@"{0}\myproject.pj", sandboxRoot)));

            mockExecutorWrapper.Setup(executor => executor.Execute(expectedProcessInfo)).Returns(new ProcessResult(null, null, 0, false)).Verifiable();

            string      expectedDisconnectCommand     = string.Format(@"disconnect --user=CCNetUser --password=CCNetPassword --quiet --forceConfirm=yes");
            ProcessInfo expectedDisconnectProcessInfo = ExpectedProcessInfo(expectedDisconnectCommand);

            mockExecutorWrapper.Setup(executor => executor.Execute(expectedDisconnectProcessInfo)).Returns(new ProcessResult(null, null, 0, false)).Verifiable();

            mks = CreateMks(CreateSourceControlXml(), mksHistoryParser, mockProcessExecutor);
            Modification[] modifications = mks.GetModifications(IntegrationResultMother.CreateSuccessful(FROM), IntegrationResultMother.CreateSuccessful(TO));
            Assert.AreEqual(0, modifications.Length);

            mksHistoryParserWrapper.Verify();
            mksHistoryParserWrapper.VerifyNoOtherCalls();
        }
Exemplo n.º 16
0
        public void GetModificationsCallsMemberInfoForNonDeletedModifications()
        {
            Modification addedModification = ModificationMother.CreateModification("myFile.file", "MyFolder");

            addedModification.Type = "Added";

            Modification modifiedModification = ModificationMother.CreateModification("myFile.file", "MyFolder");

            modifiedModification.Type = "Modified";

            Modification deletedModification = ModificationMother.CreateModification("myFile.file", "MyFolder");

            deletedModification.Type = "Deleted";

            mksHistoryParserWrapper.ExpectAndReturn("Parse", new Modification[] { addedModification, modifiedModification, deletedModification }, new IsTypeOf(typeof(TextReader)), FROM, TO);
            mksHistoryParserWrapper.ExpectAndReturn("ParseMemberInfoAndAddToModification", null, addedModification, new IsTypeOf(typeof(StringReader)));
            mksHistoryParserWrapper.ExpectAndReturn("ParseMemberInfoAndAddToModification", null, modifiedModification, new IsTypeOf(typeof(StringReader)));
            mksHistoryParserWrapper.ExpectAndReturn("ParseMemberInfoAndAddToModification", null, deletedModification, new IsTypeOf(typeof(StringReader)));
            mockExecutorWrapper.SetupResult("Execute", new ProcessResult("", null, 0, false), new Type[] { typeof(ProcessInfo) });

            mks = CreateMks(CreateSourceControlXml(), mksHistoryParser, mockProcessExecutor);
            Modification[] modifications = mks.GetModifications(IntegrationResultMother.CreateSuccessful(FROM), IntegrationResultMother.CreateSuccessful(TO));
            Assert.AreEqual(3, modifications.Length);
        }
Exemplo n.º 17
0
        public void GetModificationsCallsMemberInfoForNonDeletedModifications()
        {
            Modification addedModification = ModificationMother.CreateModification("myFile.file", "MyFolder");

            addedModification.Type = "Added";

            Modification modifiedModification = ModificationMother.CreateModification("myFile.file", "MyFolder");

            modifiedModification.Type = "Modified";

            Modification deletedModification = ModificationMother.CreateModification("myFile.file", "MyFolder");

            deletedModification.Type = "Deleted";

            mksHistoryParserWrapper.Setup(parser => parser.Parse(It.IsAny <TextReader>(), FROM, TO)).Returns(new Modification[] { addedModification, modifiedModification, deletedModification }).Verifiable();
            mksHistoryParserWrapper.Setup(parser => parser.ParseMemberInfoAndAddToModification(addedModification, It.IsAny <StringReader>())).Verifiable();
            mksHistoryParserWrapper.Setup(parser => parser.ParseMemberInfoAndAddToModification(modifiedModification, It.IsAny <StringReader>())).Verifiable();
            mksHistoryParserWrapper.Setup(parser => parser.ParseMemberInfoAndAddToModification(deletedModification, It.IsAny <StringReader>())).Verifiable();
            mockExecutorWrapper.Setup(executor => executor.Execute(It.IsAny <ProcessInfo>())).Returns(new ProcessResult("", null, 0, false)).Verifiable();

            mks = CreateMks(CreateSourceControlXml(), mksHistoryParser, mockProcessExecutor);
            Modification[] modifications = mks.GetModifications(IntegrationResultMother.CreateSuccessful(FROM), IntegrationResultMother.CreateSuccessful(TO));
            Assert.AreEqual(3, modifications.Length);
        }
        /// <summary>
        /// Called when user makes a selection in the menu.
        /// This is your main exit point to the rest of your Add-in
        /// </summary>
        /// <param name="repository">the repository</param>
        /// <param name="location">the location of the menu</param>
        /// <param name="MenuName">the name of the menu</param>
        /// <param name="itemName">the name of the selected menu item</param>
        public override void EA_MenuClick(EA.Repository repository, string location, string MenuName, string itemName)
        {
            EA.Package    pkg        = null;
            EA.ObjectType oType      = repository.GetContextItemType();
            EA.Diagram    diaCurrent = repository.GetCurrentDiagram();
            EA.Connector  conCurrent = null;
            EA.Element    el         = null;


            if (diaCurrent != null)
            {
                conCurrent = diaCurrent.SelectedConnector;
            }
            switch (itemName)
            {
            case MenuAbout:
                About fAbout = new About();
                fAbout.setVersion(Release);     // set release / version
                fAbout.ShowDialog();

                break;


            case MenuMksGetNewest:
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Mks mks = new Mks(repository, pkg);
                    mks.GetNewest();
                }

                break;

            case MenuMksGetHistory:
                // if controlled package
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Mks mks = new Mks(repository, pkg);
                    MessageBox.Show(mks.ViewHistory(), "mks");
                }
                break;


            case MenuMksUndoCheckOut:
                // if controlled package
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Mks    mks = new Mks(repository, pkg);
                    string msg = mks.UndoCheckout();
                    if (msg != "")
                    {
                        MessageBox.Show(mks.UndoCheckout(), "mks");
                    }
                }
                break;

            // Change name to synomym
            // - Package, recursive
            // - Class
            case MenuChangeClassNameToSynonym:
                // Class recursive
                if (oType.Equals(EA.ObjectType.otElement))
                {
                    el = (EA.Element)repository.GetContextObject();
                    Util.ChangeClassNameToSynonyms(repository, el);
                }
                // Package recursiv
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Util.ChangePackageClassNameToSynonyms(repository, pkg);
                }

                break;



            //

            //   If package is controlled:
            //   - reset packageflags to "Recurse=0;VCCFG=unchanged";
            case MenuResetVcMode:
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Util.ResetVc(repository, pkg);
                }
                break;

            //   For all nested packages:
            //   If package is controlled:
            //   - reset packageflags to "Recurse=0;VCCFG=unchanged";
            case MenuResetVcModeRecursive:
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    Util.ResetVcRecursive(repository, pkg);
                }
                break;



            case MenuGetVcLatest:
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    // start preparation
                    int      count      = 0;
                    int      errorCount = 0;
                    DateTime startTime  = DateTime.Now;

                    repository.CreateOutputTab("Debug");
                    repository.EnsureOutputVisible("Debug");
                    repository.WriteOutput("Debug", "Start GetLatest", 0);
                    pkg = (EA.Package)repository.GetContextObject();
                    Util.GetLatest(repository, pkg, false, ref count, 0, ref errorCount);
                    string s = "";
                    if (errorCount > 0)
                    {
                        s = " with " + errorCount.ToString() + " errors";
                    }

                    // finished
                    TimeSpan span = DateTime.Now - startTime;
                    repository.WriteOutput("Debug", "End GetLatest " + span.Minutes + " minutes. " + s, 0);
                }

                break;

            case MenuGetVcLatestRecursive:
                if (oType.Equals(EA.ObjectType.otPackage) || oType.Equals(EA.ObjectType.otNone))
                {
                    // start preparation
                    int      count      = 0;
                    int      errorCount = 0;
                    DateTime startTime  = DateTime.Now;

                    repository.CreateOutputTab("Debug");
                    repository.EnsureOutputVisible("Debug");
                    repository.WriteOutput("Debug", "Start GetLatestRecursive", 0);
                    pkg = (EA.Package)repository.GetContextObject();
                    Util.GetLatest(repository, pkg, true, ref count, 0, ref errorCount);
                    string s = "";
                    if (errorCount > 0)
                    {
                        s = " with " + errorCount.ToString() + " errors";
                    }

                    // finished
                    TimeSpan span = DateTime.Now - startTime;

                    repository.WriteOutput("Debug", "End GetLatestRecursive in " + span.Hours + ":" + span.Minutes + " hh:mm. " + s, 0);
                }

                break;

            case MenuGetVcModeAll:
                //Repository.VersionControlResynchPkgStatuses(false);
                // over all packages
                foreach (EA.Package pkg1 in repository.Models)
                {
                    Util.UpdateVc(repository, pkg1);
                }

                break;

            case MenuGetVcMode:
                if (oType.Equals(EA.ObjectType.otPackage))
                {
                    pkg = (EA.Package)repository.GetContextObject();
                    // Get the revision
                    Regex  pattern  = new Regex(@"Revision:[^\$]+");
                    Match  regMatch = pattern.Match(pkg.Notes);
                    string revision = "";
                    if (regMatch.Success)
                    {
                        // get Revision
                        revision = regMatch.Value;
                        // add new string
                    }
                    // Get date
                    pattern  = new Regex(@"Date:[^\$]+");
                    regMatch = pattern.Match(pkg.Notes);
                    string date = "";
                    if (regMatch.Success)
                    {
                        // get Revision
                        date = regMatch.Value;
                        // add new string
                    }
                    string msg = revision + "  " +
                                 date + "\r\n" +
                                 "Path: " + Util.GetFilePath(repository, pkg) +
                                 "\r\n\r\n" + pkg.Flags + "\r\n" +
                                 Util.GetVCstate(pkg, true);

                    MessageBox.Show(msg, "State");
                }
                break;



            case MenuCopyGuidToClipboard:
                string str  = "";
                string str1 = "";
                string str2 = "";

                if (conCurrent != null)
                {    // Connector
                    EA.Connector con = conCurrent;
                    str = con.ConnectorGUID + " " + con.Name + ' ' + con.Type + "\r\n" +

                          "\r\n Connector: Select ea_guid As CLASSGUID, connector_type As CLASSTYPE,* from t_connector con where ea_guid = '" + con.ConnectorGUID + "'" +

                          "\r\n\r\nSelect o.ea_guid As CLASSGUID, o.object_type As CLASSTYPE,o.name As Name, o.object_type AS ObjectType, o.PDATA1, o.Stereotype, " +
                          "\r\n                       con.Name, con.connector_type, con.Stereotype, con.ea_guid As ConnectorGUID, dia.Name As DiagrammName, dia.ea_GUID As DiagramGUID," +
                          "\r\n                       o.ea_guid, o.Classifier_GUID,o.Classifier " +
                          "\r\nfrom (((t_connector con INNER JOIN t_object o              on con.start_object_id   = o.object_id) " +
                          "\r\nINNER JOIN t_diagramlinks diaLink  on con.connector_id      = diaLink.connectorid ) " +
                          "\r\nINNER JOIN t_diagram dia           on diaLink.DiagramId     = dia.Diagram_ID) " +
                          "\r\nINNER JOIN t_diagramobjects diaObj on diaObj.diagram_ID     = dia.Diagram_ID and o.object_id = diaObj.object_id " +
                          "\r\nwhere         con.ea_guid = '" + con.ConnectorGUID + "' " +
                          "\r\nAND dialink.Hidden  = 0 ";
                    Clipboard.SetText(str);
                    break;
                }
                if (oType.Equals(EA.ObjectType.otElement))
                {    // Element
                    el = (EA.Element)repository.GetContextObject();
                    string pdata1       = el.get_MiscData(0);
                    string pdata1String = "";
                    if (pdata1.EndsWith("}"))
                    {
                        pdata1String = "/" + pdata1;
                    }
                    else
                    {
                        pdata1       = "";
                        pdata1String = "";
                    }
                    string classifier = Util.GetClassifierGuid(repository, el.ElementGUID);
                    str = el.ElementGUID + ":" + classifier + pdata1String + " " + el.Name + ' ' + el.Type + "\r\n" +
                          "\r\nSelect ea_guid As CLASSGUID, object_type As CLASSTYPE,* from t_object o where ea_guid = '" + el.ElementGUID + "'";
                    if (classifier != "")
                    {
                        if (el.Type.Equals("ActionPin"))
                        {
                            str = str + "\r\n Typ:\r\nSelect ea_guid As CLASSGUID, 'Parameter' As CLASSTYPE,* from t_operationparams op where ea_guid = '" + classifier + "'";
                        }
                        else
                        {
                            str = str + "\r\n Typ:\r\nSelect ea_guid As CLASSGUID, object_type As CLASSTYPE,* from t_object o where ea_guid = '" + classifier + "'";
                        }
                    }
                    if (pdata1 != "")
                    {
                        str = str + "\r\n PDATA1:  Select ea_guid As CLASSGUID, object_type As CLASSTYPE,* from t_object o where ea_guid = '" + pdata1 + "'";
                    }

                    // Look for diagram object
                    EA.Diagram curDia = repository.GetCurrentDiagram();
                    if (curDia != null)
                    {
                        foreach (EA.DiagramObject diaObj in curDia.DiagramObjects)
                        {
                            if (diaObj.ElementID == el.ElementID)
                            {
                                str = str + "\r\n\r\n" +
                                      "select * from t_diagramobjects where object_id = " + diaObj.ElementID.ToString();
                                break;
                            }
                        }
                    }
                }

                if (oType.Equals(EA.ObjectType.otDiagram))
                {    // Element
                    EA.Diagram dia = (EA.Diagram)repository.GetContextObject();
                    str = dia.DiagramGUID + " " + dia.Name + ' ' + dia.Type + "\r\n" +
                          "\r\nSelect ea_guid As CLASSGUID, diagram_type As CLASSTYPE,* from t_diagram dia where ea_guid = '" + dia.DiagramGUID + "'";
                }
                if (oType.Equals(EA.ObjectType.otPackage))
                {    // Element
                    pkg = (EA.Package)repository.GetContextObject();
                    str = pkg.PackageGUID + " " + pkg.Name + ' ' + " Package " + "\r\n" +
                          "\r\nSelect ea_guid As CLASSGUID, 'Package' As CLASSTYPE,* from t_package pkg where ea_guid = '" + pkg.PackageGUID + "'";
                }
                if (oType.Equals(EA.ObjectType.otAttribute))
                {    // Element
                    str1 = "LEFT JOIN  t_object typAttr on (attr.Classifier = typAttr.object_id)";
                    if (repository.ConnectionString.Contains(".eap"))
                    {
                        str1 = "LEFT JOIN  t_object typAttr on (attr.Classifier = Format(typAttr.object_id))";
                    }
                    EA.Attribute attr = (EA.Attribute)repository.GetContextObject();
                    str = attr.AttributeID + " " + attr.Name + ' ' + " Attribute " + "\r\n" +
                          "\r\n " +
                          "\r\nSelect ea_guid As CLASSGUID, 'Attribute' As CLASSTYPE,* from t_attribute attr where ea_guid = '" + attr.AttributeGUID + "'" +
                          "\r\n Class has Attributes:" +
                          "\r\nSelect attr.ea_guid As CLASSGUID, 'Attribute' As CLASSTYPE, " +
                          "\r\n       o.Name As Class, o.object_type, " +
                          "\r\n       attr.Name As AttrName, attr.Type As Type, " +
                          "\r\n       typAttr.Name " +
                          "\r\n   from (t_object o INNER JOIN t_attribute attr on (o.object_id = attr.object_id)) " +
                          "\r\n                   " + str1 +
                          "\r\n   where attr.ea_guid = '" + attr.AttributeGUID + "'";
                }
                if (oType.Equals(EA.ObjectType.otMethod))
                {    // Element
                    str1 = "LEFT JOIN t_object parTyp on (par.classifier = parTyp.object_id))";
                    str2 = "LEFT JOIN t_object opTyp on (op.classifier = opTyp.object_id)";
                    if (repository.ConnectionString.Contains(".eap"))
                    {
                        str1 = " LEFT JOIN t_object parTyp on (par.classifier = Format(parTyp.object_id))) ";
                        str2 = " LEFT JOIN t_object opTyp  on (op.classifier  = Format(opTyp.object_id))";
                    }

                    EA.Method op = (EA.Method)repository.GetContextObject();
                    str = op.MethodGUID + " " + op.Name + ' ' + " Operation " +
                          "\r\nOperation may have type " +
                          "\r\nSelect op.ea_guid As CLASSGUID, 'Operation' As CLASSTYPE,opTyp As OperationType, op.Name As OperationName, typ.Name As TypName,*" +
                          "\r\n   from t_operation op LEFT JOIN t_object typ on (op.classifier = typ.object_id)" +
                          "\r\n   where op.ea_guid = '" + op.MethodGUID + "';" +
                          "\r\n\r\nClass has Operation " +
                          "\r\nSelect op.ea_guid As CLASSGUID, 'Operation' As CLASSTYPE,* " +
                          "\r\n    from t_operation op INNER JOIN t_object o on (o.object_id = op.object_id)" +
                          "\r\n    where op.ea_guid = '" + op.MethodGUID + "';" +
                          "\r\n\r\nClass has Operation has Parameters/Typ and may have operationtype" +
                          "\r\nSelect op.ea_guid As CLASSGUID, 'Operation' As CLASSTYPE,op.Name As ClassName, op.Name As OperationName, opTyp.Name As OperationTyp, par.Name As ParName,parTyp.name As ParTypeName " +
                          "\r\n   from ((t_operation op INNER JOIN t_operationparams par on (op.OperationID = par.OperationID) )" +
                          "\r\n                        " + str1 +
                          "\r\n                        " + str2 +
                          "\r\n   where op.ea_guid = '" + op.MethodGUID + "' " +
                          "\r\n  Order by par.Pos ";
                }
                Clipboard.SetText(str);
                break;

            // delete undefined referencee
            case MenuDeleteExternalReference:
                if (diaCurrent != null)
                {
                    foreach (EA.DiagramObject diaObj in diaCurrent.SelectedObjects)
                    {
                        EA.Element el1 = repository.GetElementByID(diaObj.ElementID);
                        string     s   = String.Format("External Reference of diagram '{0}', name:'{1}' ID={2} GUID='{3}' deleted", diaCurrent.Name, el1.Name, el1.ElementID, el1.ElementGUID);
                        repository.WriteOutput("System", s, 0);
                        DeleteUndefinedReference(repository, el1);
                    }
                }
                else
                {
                    foreach (EA.Element el1 in repository.GetTreeSelectedElements())
                    {
                        string s = String.Format("External Reference of tree, name:'{0}' ID={1} GUID='{2}' deleted", el1.Name, el1.ElementID, el1.ElementGUID);
                        repository.WriteOutput("System", s, 0);
                        DeleteUndefinedReference(repository, el1);
                    }
                }
                break;

            // Recursive delete undefined referencee
            case MenuDeleteExternalReferenceRecursive:
                pkg = null;
                if (oType.Equals(EA.ObjectType.otNone))
                {
                    oType = repository.GetTreeSelectedItemType();
                    if (oType.Equals(EA.ObjectType.otPackage))
                    {
                        pkg = (EA.Package)repository.GetTreeSelectedObject();
                    }
                    if (oType.Equals(EA.ObjectType.otElement))
                    {
                        el = (EA.Element)repository.GetTreeSelectedObject();
                    }
                }
                else
                {
                    if (oType.Equals(EA.ObjectType.otPackage))
                    {
                        pkg = (EA.Package)repository.GetContextObject();
                    }
                    if (oType.Equals(EA.ObjectType.otElement))
                    {
                        el = (EA.Element)repository.GetContextObject();
                    }
                }
                if (pkg != null)
                {
                    RecursivePackages.doRecursivePkg(repository,
                                                     pkg,
                                                     null,                        // Packages
                                                     SetDeleteUndefinedReference, // Elements
                                                     null,                        // Diagrams
                                                     null);
                }
                if (el != null)
                {
                    RecursivePackages.doRecursiveEl(repository,
                                                    el,
                                                    SetDeleteUndefinedReference, // Elements
                                                    null,                        // Diagrams
                                                    null);
                }

                break;
            }
        }