Пример #1
0
        public void Execute()
        {
            var v1 = V1Connector
                     .WithInstanceUrl(instanceUrl)
                     .WithUserAgentHeader("Examples", "0.1")
                     .WithAccessToken(accessToken);

            dynamic results = v1
                              .Query("Epic")
                              .Where("Scope.Name", "Josh API Test")
                              .Select(
                "Name",
                From("Subs")
                .Select(
                    "Name",
                    From("Children")
                    .Select(
                        "Name", "AssetType"
                        )
                    )
                )
                              .Retrieve();

            foreach (var result in results)
            {
                WriteLine(result);
            }
        }
Пример #2
0
        private static void CheckMail(Object source, ElapsedEventArgs e)
        {
            List <Message> Messages     = new List <Message>();
            V1Logging      Logs         = new V1Logging();
            bool           V1TestResult = false;
            V1_Connector   V1Connection = new V1_Connector();
            V1Connector    V1Instance   = V1Connection.ConnectToV1();
            MailChecker    GetMail      = new MailChecker();

            //System.IO.File.Create(AppDomain.CurrentDomain.BaseDirectory + "MailChecker.txt");

            //Messages = GetMail.FetchAllMessages("pop.mail.yahoo.com", 995, true, "*****@*****.**", "altec123");
            Messages = GetMail.FetchAllMessagesWithMultipleAccounts();
            Console.Write(Messages.ToString());

            // write an entry to the log
            eventLog1.WriteEntry("Operation - Email Checked, " + Messages.Count.ToString() + " Found");

            if (Messages.Count != 0)
            {
                V1TestResult = V1Connection.V1TestConnection(V1Instance);
            }

            if (Messages.Count != 0 && V1TestResult == true)
            {
                //NewConnection = V1Connection.ConnectToV1();
                V1Connection.CreateRequest(V1Instance, Messages);
            }

            Logs.LogEvent("Operation - V1 Request Asset Creator Check Complete.");
        }
Пример #3
0
        public bool V1TestConnection(V1Connector CurrentV1Connection)
        {
            V1Logging Logs       = new V1Logging();
            bool      TestResult = false;
            IServices services   = new Services(CurrentV1Connection);

            try
            {
                Logs.LogEvent("Operation - Attempting Test Connection to VersionOne");

                Logs.LogEvent("Test - Testing URI - Pulling Meta");
                IAssetType defectType = services.Meta.GetAssetType("Scope");
                Logs.LogEvent("Test - Testing URI - SUCCESS");


                Logs.LogEvent("Test - Testing Token - Pulling Data");
                Oid        projectId = services.GetOid("Scope:0");
                IAssetType ScopeType = services.Meta.GetAssetType("Scope");
                Asset      NewScope  = services.New(defectType, projectId);

                Logs.LogEvent("Test - Testing Token - SUCCESS");

                TestResult = true;

                Logs.LogEvent("Operation - VersionOne Connection Test Complete - " + TestResult.ToString());
            }
            catch (Exception ex)
            {
                Logs.LogEvent("ERROR - Test Failure - " + ex.ToString());
                Logs.LogEvent("Operation - VersionOne Connection Test Complete - " + TestResult.ToString());
            }

            return(TestResult);
        }
Пример #4
0
 public static V1Connector CreateConnector()
 {
     return(V1Connector.WithInstanceUrl(BASE_URL)
            .WithUserAgentHeader("ServicesConstructorTester", "0.0")
            .WithUsernameAndPassword("admin", "admin")
            .Build());
 }
        public MetaModel(V1Connector v1Connector, bool hookup = false)
        {
            _v1Connector = v1Connector;

            if (hookup)
                Hookup();
        }
        private void Connect()
        {
            var settings = VersionOneSettings.FromXmlElement(configuration);

            var connector = V1Connector
                .WithInstanceUrl(settings.Url)
                .WithUserAgentHeader("VersionOne.Integration.Bugzilla", Assembly.GetEntryAssembly().GetName().Version.ToString());

            ICanSetProxyOrEndpointOrGetConnector connectorWithAuth;

            switch (settings.AuthenticationType)
            {
                case AuthenticationTypes.AccessToken:
                    connectorWithAuth = connector.WithAccessToken(settings.AccessToken);
                    break;
                default:
                    throw new Exception("Invalid authentication type");
            }

            if (settings.ProxySettings.Enabled)
            {
                connectorWithAuth.WithProxy(
                new ProxyProvider(new Uri(settings.ProxySettings.Url), settings.ProxySettings.Username, settings.ProxySettings.Password, settings.ProxySettings.Domain));

            }

            services = new Services(connectorWithAuth.UseOAuthEndpoints().Build());

            queryBuilder.Setup(services);
        }
        public void Execute()
        {
            var v1 = V1Connector
                     .WithInstanceUrl(instanceUrl)
                     .WithUserAgentHeader("Examples", "0.1")
                     .WithAccessToken(accessToken);

            dynamic result = v1.Create(
                Asset(
                    ("AssetType", "Story"),
                    ("Scope", "Scope:0"),
                    ("Name", "Story 1 from Tuple")
                    ),
                Asset(
                    ("AssetType", "Story"),
                    ("Scope", "Scope:0"),
                    ("Name", "Story 2 from Tuple")
                    ),
                Asset(
                    ("AssetType", "Story"),
                    ("Scope", "Scope:0"),
                    ("Name", "Story 3 from Tuple")
                    ),
                Asset(
                    ("AssetType", "Story"),
                    ("Scope", "Scope:0"),
                    ("Name", "Story 4 from Tuple")
                    )
                );

            WriteLine("Result returned from .Create with multiple assets:");
            WriteLine(result);
        }
Пример #8
0
        private static void CreateTestProject(bool useOAuthEndpoints)
        {
            V1Connector connector;

            if (useOAuthEndpoints)
            {
                connector = V1Connector.WithInstanceUrl(ConfigurationManager.AppSettings.Get("V1Url"))
                            .WithUserAgentHeader("IntegrationTests", "1.0")
                            .WithAccessToken(ConfigurationManager.AppSettings.Get("V1AccessToken"))
                            .UseOAuthEndpoints()
                            .Build();
            }
            else
            {
                connector = V1Connector.WithInstanceUrl(ConfigurationManager.AppSettings.Get("V1Url"))
                            .WithUserAgentHeader("IntegrationTests", "1.0")
                            .WithAccessToken(ConfigurationManager.AppSettings.Get("V1AccessToken"))
                            .Build();
            }
            var services      = new Services(connector);
            var assetType     = services.Meta.GetAssetType("Scope");
            var nameAttribute = assetType.GetAttributeDefinition("Name");
            var projectId     = services.GetOid("Scope:0");
            var newAsset      = services.New(assetType, projectId);

            newAsset.SetAttributeValue(nameAttribute, TestProjectName);
            services.Save(newAsset);
            _testProjectId = newAsset.Oid.Momentless;
        }
        public void Execute()
        {
            var assets = V1Connector
                         .WithInstanceUrl(instanceUrl)
                         .WithUserAgentHeader("Examples", "0.1")
                         .WithAccessToken(accessToken)
                         .Query("Scope")
                         .Select("Name", "Description", "Status", "Members", "Workitems:Defect")
                         .Retrieve();

            foreach (dynamic scope in assets)
            {
                WriteLine(scope.Oid);
                WriteLine(scope.Description);
                WriteLine(scope.Status);
                WriteLine($"Members count: {scope.Members.Count}");
                foreach (dynamic member in scope.Members)
                {
                    WriteLine(member);
                }
                WriteLine($"Defects count: {scope["Workitems:Defect"].Count}");
                foreach (dynamic defect in scope["Workitems:Defect"])
                {
                    WriteLine(defect);
                }
                WriteLine("---");
            }

            /* Expect to produce:
             *
             * If 3 Scopes available, then:
             *
             * Scope:00001
             * First scope
             * null // when there is no Status
             * Members count: 2
             * Member:20
             * Member:90
             * Defects count: 2
             * Defect:00010
             * Defect:00011
             * ---
             * Scope:00002
             * Second scope
             * ScopeStatus:1012
             * Members count: 2
             * Member:20
             * Member:400
             * Defects count: 1
             * Defect:00012
             * ----
             * Scope:00003
             * Third scope
             * null // when there is no Status
             * Members count: 1
             * Member:20 // Always one member in this particular Multi-Value relation
             * Defects count: 0
             */
        }
Пример #10
0
 public void NullPasswordException()
 {
     V1Connector connector = V1Connector
                             .WithInstanceUrl("http://localhost/VersionOne/")
                             .WithUserAgentHeader("MyApp", "1.0")
                             .WithUsernameAndPassword("username", null)
                             .Build();
 }
Пример #11
0
 public void NullUserAgentNameException()
 {
     V1Connector connector = V1Connector
                             .WithInstanceUrl("http://localhost/VersionOne/")
                             .WithUserAgentHeader(null, "1.0")
                             .WithAccessToken("accesstoken")
                             .Build();
 }
Пример #12
0
 public void InvalidUrlException()
 {
     V1Connector connector = V1Connector
                             .WithInstanceUrl("InvalidUrl")
                             .WithUserAgentHeader("MyApp", "1.0")
                             .WithAccessToken("accesstoken")
                             .Build();
 }
Пример #13
0
 public void EmptyOAuth2TokenException()
 {
     V1Connector connector = V1Connector
                             .WithInstanceUrl("http://localhost/VersionOne/")
                             .WithUserAgentHeader("MyApp", "1.0")
                             .WithOAuth2Token("")
                             .Build();
 }
Пример #14
0
 public void NullAccessTokenException()
 {
     V1Connector connector = V1Connector
                             .WithInstanceUrl("http://localhost/VersionOne/")
                             .WithUserAgentHeader("MyApp", "1.0")
                             .WithAccessToken(null)
                             .Build();
 }
Пример #15
0
 public void EmptyWindowsIntegratedPasswordException()
 {
     V1Connector connector = V1Connector
                             .WithInstanceUrl("http://localhost/VersionOne/")
                             .WithUserAgentHeader("MyApp", "1.0")
                             .WithUsernameAndPassword("fqdn", "")
                             .Build();
 }
Пример #16
0
 public void NullWindowsIntegratedFQDNException()
 {
     V1Connector connector = V1Connector
                             .WithInstanceUrl("http://localhost/VersionOne/")
                             .WithUserAgentHeader("MyApp", "1.0")
                             .WithWindowsIntegrated(null, "password")
                             .Build();
 }
Пример #17
0
 public void NullUsernameException()
 {
     V1Connector connector = V1Connector
                             .WithInstanceUrl("http://localhost/VersionOne.Web")
                             .WithUserAgentHeader("MyApp", "1.0")
                             .WithUsernameAndPassword(null, "password")
                             .Build();
 }
Пример #18
0
 public void NullWindowsIntegratedPasswordException()
 {
     V1Connector connector = V1Connector
                             .WithInstanceUrl("http://localhost/VersionOne.Web")
                             .WithUserAgentHeader("MyApp", "1.0")
                             .WithWindowsIntegrated("fqdn", null)
                             .Build();
 }
Пример #19
0
 public void EmptyUserAgentVersionException()
 {
     V1Connector connector = V1Connector
                             .WithInstanceUrl("http://localhost/VersionOne/")
                             .WithUserAgentHeader("MyApp", "   ")
                             .WithAccessToken("accesstoken")
                             .Build();
 }
        public void Execute()
        {
            var v1 = V1Connector
                     .WithInstanceUrl(instanceUrl)
                     .WithUserAgentHeader("Examples", "0.1")
                     .WithAccessToken(accessToken);


            dynamic epic = v1.Create(Attributes(
                                         ("AssetType", "Epic"),
                                         ("Scope", "Scope:0"),
                                         ("Name", "Epic made from a Tuple"),
                                         ("Subs", Assets(
                                              Asset(
                                                  "Story",
                                                  ("Name", "Story 1 from a Tuple"),
                                                  ("Children", Assets(
                                                       Asset("Test", ("Name", "Test 1 from a Tuple")),
                                                       Asset("Task", ("Name", "Task 1 from a Tuple"))
                                                       ))
                                                  ),
                                              Asset(
                                                  "Story",
                                                  ("Name", "Story 2 from a Tuple"),
                                                  ("Children", Assets(
                                                       Asset("Test", ("Name", "Test 2 from a Tuple")),
                                                       Asset("Task", ("Name", "Task 2 from a Tuple"))
                                                       ))
                                                  )
                                              ))
                                         ));

            WriteLine("Epic returned from .Create (which does not requery the system, but fills in Oids linearly from server response):");
            PrintEpic(epic);

            epic = v1
                   .Query(epic.Oid)
                   .Select(
                "Name",
                "Scope",
                From("Subs")
                .Select(
                    "AssetType",
                    "Name",
                    From("Children")
                    .Select(
                        "AssetType",
                        "Name"
                        )
                    )
                )
                   .RetrieveFirst();

            WriteLine();
            WriteLine("Epic returned from .Query, requerying the system with subselect syntax to pull in nested relationships:");
            PrintEpic(epic);
        }
        static V1Connector BasicAuthentication()
        {
            V1Connector connector = V1Connector
                                    .WithInstanceUrl(Program.baseURL)
                                    .WithUserAgentHeader("AppName", "1.0")
                                    .WithUsernameAndPassword("admin", "admin")
                                    .Build();

            return(connector);
        }
        static V1Connector windowsIntegratedAuthentication()
        {
            // windows Integrated Authentication
            V1Connector connector = V1Connector
                                    .WithInstanceUrl(Program.baseURL)
                                    .WithUserAgentHeader("AppName", "1.0")
                                    .WithWindowsIntegrated()
                                    .Build();

            return(connector);
        }
Пример #23
0
        public void Execute()
        {
            var v1 = V1Connector
                     .WithInstanceUrl(instanceUrl)
                     .WithUserAgentHeader("Examples", "0.1")
                     .WithAccessToken(accessToken);

            dynamic newStory = v1.Create(new {
                AssetType = "Story",
                Scope     = "Scope:1015",
                Name      = $"Test Story Scope:1015 Create new Story with scalar attribute"
            });

            WriteLine("Created: " + newStory.Oid);
        }
        public void Execute()
        {
            var v1 = V1Connector
                     .WithInstanceUrl(instanceUrl)
                     .WithUserAgentHeader("Examples", "0.1")
                     .WithAccessToken(accessToken);

            dynamic story = new VersionOne.Assets.Asset("Story");

            story.Scope = "Scope:1015";
            story.Name  = "Story created from newed up Asset instance";

            dynamic createdStory = v1.Create(story);

            WriteLine("Created: " + createdStory.Oid);
        }
Пример #25
0
    private void Execute()
    {
        var connector = V1Connector
                        .WithInstanceUrl(instanceUrl)
                        .WithUserAgentHeader("Examples", "0.1")
                        .WithUsernameAndPassword(username, password)
                        .Build();

        var services = new Services(connector);

        var storyType = services.Meta.GetAssetType("Story");

        var query = new Query(storyType);

        var nameAttribute       = storyType.GetAttributeDefinition("Name");
        var idAttribute         = storyType.GetAttributeDefinition("ID");
        var taggedWithAttribute = storyType.GetAttributeDefinition("TaggedWith");

        query.Selection.Add(nameAttribute);
        query.Selection.Add(taggedWithAttribute);

        var term = new FilterTerm(idAttribute);

        term.Equal("Story:1004");
        query.Filter = term;

        var result = services.Retrieve(query);

        foreach (var story in result.Assets)
        {
            WriteLine(story.Oid.Token);
            WriteLine(story.GetAttribute(nameAttribute).Value);
            WriteLine(string.Join(",", story.GetAttribute(taggedWithAttribute).Values.Cast <string>()));

            // Itentional duplicate calls here, server will handle de-dedupe on query
            story.AddAttributeValue(taggedWithAttribute, "FIRST TAG");
            story.AddAttributeValue(taggedWithAttribute, "FIRST TAG");
            story.AddAttributeValue(taggedWithAttribute, "SECOND TAG");
            story.RemoveAttributeValue(taggedWithAttribute, "SECOND TAG");

            services.Save(story);
            story.AcceptChanges();

            WriteLine(string.Join(",", story.GetAttribute(taggedWithAttribute).Values.Cast <string>()));
        }
    }
Пример #26
0
        public void Execute()
        {
            var assets = V1Connector
                         .WithInstanceUrl(instanceUrl)
                         .WithUserAgentHeader("Examples", "0.1")
                         .WithAccessToken(accessToken)
                         .Query("Story")
                         .Where("Number", "S-01001")
                         .Select("Name", "Number")
                         .Retrieve();

            foreach (dynamic story in assets)
            {
                WriteLine(story.Oid);
                WriteLine(story.Name);
                WriteLine(story.Number);
            }
        }
Пример #27
0
        public V1ConnectionDto GetV1Connection()
        {
            V1ConnectionDto v1ConnectionDto = new V1ConnectionDto();

            try
            {
                if (!string.IsNullOrEmpty(_credentials.Username) && !string.IsNullOrEmpty(_credentials.Password))
                {
                    V1Connector connector = V1Connector
                                            .WithInstanceUrl(ConfigHelper.V1Url)
                                            .WithUserAgentHeader(ConfigHelper.V1Name, ConfigHelper.V1Version)
                                            .WithUsernameAndPassword(_credentials.Username, _credentials.Password)
                                            .Build();

                    IServices connection = new VersionOne.SDK.APIClient.Services(connector);

                    if (connection.LoggedIn != null)
                    {
                        v1ConnectionDto.IsValid      = true;
                        v1ConnectionDto.ErrorMessage = string.Empty;
                        v1ConnectionDto.Connection   = connection;
                    }
                }
                else
                {
                    v1ConnectionDto.IsValid      = false;
                    v1ConnectionDto.ErrorMessage = "Invalid Username/Password.";
                }
            }
            catch (Exception ex)
            {
                v1ConnectionDto.IsValid = false;
                if ((ex.InnerException != null) && (ex.InnerException.Message.Equals("Unauthorized")))
                {
                    v1ConnectionDto.ErrorMessage = "Unauthorized";
                }
                else
                {
                    v1ConnectionDto.ErrorMessage = "Exception Occured";
                }
            }

            return(v1ConnectionDto);
        }
Пример #28
0
        public void Execute()
        {
            var v1 = V1Connector
                     .WithInstanceUrl(instanceUrl)
                     .WithUserAgentHeader("Examples", "0.1")
                     .WithAccessToken(accessToken);

            dynamic epic = v1.Create(
                ("AssetType", "Epic"),
                ("Scope", "Scope:0"),
                ("Name", "Epic with four Stories"),
                ("Subs", Assets(
                     Asset(
                         ("AssetType", "Story"),
                         ("Name", "Story in Epic")
                         ),
                     Asset(
                         ("AssetType", "Story"),
                         ("Name", "Another Story in Epic")
                         ),
                     Asset(
                         ("AssetType", "Story"),
                         ("Name", "Story in Epic")
                         ),
                     Asset(
                         ("AssetType", "Story"),
                         ("Name", "Another Story in Epic")
                         )
                     ))
                );

            IEnumerable <string> updated = v1.Update(
                From("Story")
                .Where(
                    Equal("Name", "Story in Epic", "Another Story in Epic"),
                    Equal("Scope", "Scope:0"),
                    Equal("Super", epic.Oid)
                    ), new
            {
                Description = "Updated via bulk API"
            });

            WriteLine("Updated the following Assets: " + string.Join(", ", updated));
        }
Пример #29
0
        public void Execute()
        {
            //Set up a connection to VersionOne using simple authentication
            var assets = V1Connector
                         .WithInstanceUrl(instanceUrl)
                         .WithUserAgentHeader("Examples", "0.1")
                         .WithAccessToken(accessToken)
                         .Query("Story")
                         .Where("Name", "Hello, Lifecycle!")
                         .Select("Name", "Number")
                         .Retrieve();

            foreach (dynamic story in assets)
            {
                WriteLine(story.Oid);
                WriteLine(story.Name);
                WriteLine(story.Number);
            }
        }
Пример #30
0
        public void Execute()
        {
            //Set up a connection to VersionOne using simple authentication
            V1Connector connector = V1Connector
                                    .WithInstanceUrl(instanceUrl)
                                    .WithUserAgentHeader("Examples", "0.1")
                                    .WithAccessToken(accessToken)
                                    .Build();

            IServices services = new Services(connector);

            //Determine which VersionOne Asset you would like to look for
            IAssetType storyType = services.Meta.GetAssetType("Story");

            //Prepare this query object.  I am saying "Hey, I want to query a story
            Query query = new Query(storyType);

            //Define the attributes that you would like to access from that Story
            IAttributeDefinition nameAttribute   = storyType.GetAttributeDefinition("Name");
            IAttributeDefinition numberAttribute = storyType.GetAttributeDefinition("Number");

            //Add them to the query object since we need to get these specific attributes
            query.Selection.Add(nameAttribute);
            query.Selection.Add(numberAttribute);

            //Since we need to get a specific Story or Stories that meet some criteria, we set up a filter
            FilterTerm term = new FilterTerm(numberAttribute);

            term.Equal("S-01001");
            query.Filter = term;

            // We do the actually query on the server here and get our results to be processed soon after
            QueryResult result = services.Retrieve(query);


            foreach (Asset story in result.Assets)
            {
                //This first line grabs and prints the system identifier OID of the current Story
                Console.WriteLine(story.Oid.Token);
                Console.WriteLine(story.GetAttribute(nameAttribute).Value);
                Console.WriteLine(story.GetAttribute(numberAttribute).Value);
            }
        }
Пример #31
0
        public void Execute()
        {
            const string scopeOid = "Scope:1015";

            var v1 = V1Connector
                     .WithInstanceUrl(instanceUrl)
                     .WithUserAgentHeader("Examples", "0.1")
                     .WithAccessToken(accessToken);

            dynamic scope = v1
                            .Query(scopeOid)
                            .Select("Workitems:Story")
                            .RetrieveFirst();

            WriteLine($"Story count: {scope["Workitems:Story"].Count}");
            foreach (var story in scope["Workitems:Story"])
            {
                WriteLine(story);
            }
        }
 public V1Configuration(V1Connector v1Connector)
 {
     if (v1Connector == null)
         throw new ArgumentNullException("v1Connector");
     _v1Connector = v1Connector;
 }
 public Attachments(V1Connector v1Connector)
 {
     _v1Connector = v1Connector;
 }