public static WcfRepositoryClient GetRepositoryClient()
        {
            var Url          = ConfigurationManager.AppSettings["URL"].ToString();
            var UserName     = ConfigurationManager.AppSettings["UserName"].ToString();
            var UserPassword = System.Configuration.ConfigurationManager.AppSettings["Password"].ToString();

            RepositoryConnectionInfo info = new RepositoryConnectionInfo()
            {
                // TODO Update the hostname as appropriate.
                // Url = "localhost",
                //Url = "https://clsr-clrdp2w01p.ad.ucl.ac.uk",
                //AuthenticationMethod = RepositoryAuthenticationMethod.Windows,
                //TransportMethod = RepositoryTransportMethod.NetTcp

                Url = Url,
                AuthenticationMethod = RepositoryAuthenticationMethod.UserName,
                UserName             = UserName,
                Password             = UserPassword,
                TransportMethod      = RepositoryTransportMethod.NetTcp
            };

            var client = new WcfRepositoryClient(info);

            //var client1 = new RepositoryClientBase(info);
            // var test = new Algenta.Colectica.Model.Ddi.Utility.MetadataUpdateBuilder();
            // test.UpdateProperty
            return(client);
        }
Exemple #2
0
        public static WcfRepositoryClient GetClient()
        {
            var Url          = ConfigurationManager.AppSettings["URL"].ToString();
            var UserName     = ConfigurationManager.AppSettings["UserName"].ToString();
            var UserPassword = System.Configuration.ConfigurationManager.AppSettings["Password"].ToString();

            RepositoryConnectionInfo info = new RepositoryConnectionInfo()
            {
                // TODO Update the hostname as appropriate.
                // Url = "localhost",
                //Url = "https://clsr-clrdp2w01p.ad.ucl.ac.uk",
                //AuthenticationMethod = RepositoryAuthenticationMethod.Windows,
                //TransportMethod = RepositoryTransportMethod.NetTcp

                Url = Url,
                AuthenticationMethod = RepositoryAuthenticationMethod.UserName,
                UserName             = UserName,
                Password             = UserPassword,
                TransportMethod      = RepositoryTransportMethod.NetTcp
            };

            var client = new WcfRepositoryClient(info);

            return(client);
        }
        private static void TestUserIdSearch()
        {
            RepositoryConnectionInfo info = new RepositoryConnectionInfo();

            info.AuthenticationMethod = RepositoryAuthenticationMethod.Windows;
            info.Url             = "localhost:19893";
            info.TransportMethod = RepositoryTransportMethod.NetTcp;
            WcfRepositoryClient client = new WcfRepositoryClient(info);

            Category c = new Category()
            {
                AgencyId = "int.example"
            };

            c.ItemName.Current    = "Test Category";
            c.Label.Current       = "Test Category Label";
            c.Description.Current = "TestCategoryDesc";
            string userId = Guid.NewGuid().ToString();

            c.UserIds.Add(new UserId("sometype", userId));
            client.RegisterItem(c, new CommitOptions());

            var facet = new SearchFacet();

            facet.SearchTargets.Add(DdiStringType.UserId);
            //facet.SearchTerms.Add("TestCategoryDesc");
            facet.SearchTerms.Add(userId);

            var response = client.Search(facet);

            Console.WriteLine("Found " + response.Results.Count + " items");
        }
Exemple #4
0
 public void CloneRemoteToLocal(RepositoryConnectionInfo connectionInfo)
 {
     Git.CloneRepository()
     .SetURI(connectionInfo.LocalDirectory)
     .SetDirectory(new FilePath(connectionInfo.RemoteUrl))
     .SetBranch(connectionInfo.BranchName)
     .Call();
 }
Exemple #5
0
        public DateTime?GetLastRemoteCommitDate(RepositoryConnectionInfo repInfo)
        {
            var git = Git.Open(repInfo.LocalDirectory);

            var references = git.LsRemote()
                             .SetHeads(true)
                             .Call();

            var head = references.ElementAt(0);

            return(null);
        }
Exemple #6
0
        public void GetLastLocalCommitDateTest()
        {
            var target = new GitRepositoryService();

            var repositoryInfo = new RepositoryConnectionInfo
            {
                BranchName     = "master",
                LocalDirectory = @"D:\Projects\Sideline\Orchestra"
            };

            var date = target.GetLastLocalCommitDate(repositoryInfo);
        }
        // helpers
        public static WcfRepositoryClient GetRepositoryApiWindows()
        {
            var info = new RepositoryConnectionInfo()
            {
                AuthenticationMethod = RepositoryAuthenticationMethod.Windows,
                Url             = "localhost",
                TransportMethod = RepositoryTransportMethod.NetTcp,
            };

            var api = new WcfRepositoryClient(info);

            return(api);
        }
Exemple #8
0
 public void UpdateLocalFromRemote(RepositoryConnectionInfo repInfo)
 {
     try
     {
         Git.Open(repInfo.LocalDirectory)
         .Pull()
         .Call();
     }
     catch (RepositoryNotFoundException)
     {
         CloneRemoteToLocal(repInfo);
     }
 }
        public static WcfRepositoryClient GetClient()
        {
            RepositoryConnectionInfo info = new RepositoryConnectionInfo()
            {
                // TODO Update the hostname as appropriate.
                Url = "localhost",
                AuthenticationMethod = RepositoryAuthenticationMethod.Windows,
                TransportMethod = RepositoryTransportMethod.NetTcp
            };

            var client = new WcfRepositoryClient(info);
            return client;
        }
        public static RepositoryClientBase GetClient1()
        {
            // Get a client that can be used to interact with Colectica Repository.
            RepositoryConnectionInfo connectionInfo = new RepositoryConnectionInfo()
            {
                Url = "localhost",
                AuthenticationMethod = RepositoryAuthenticationMethod.Windows,
                TransportMethod      = RepositoryTransportMethod.NetTcp
            };

            WcfRepositoryClient client = new WcfRepositoryClient(connectionInfo);

            return(client);
        }
Exemple #11
0
        public static WcfRepositoryClient GetClient()
        {
            RepositoryConnectionInfo info = new RepositoryConnectionInfo()
            {
                // TODO Update the hostname as appropriate.
                Url = "localhost",
                AuthenticationMethod = RepositoryAuthenticationMethod.Windows,
                TransportMethod      = RepositoryTransportMethod.NetTcp
            };

            var client = new WcfRepositoryClient(info);

            return(client);
        }
        public static WcfRepositoryClient GetRepositoryApiUsername()
        {
            var info = new RepositoryConnectionInfo()
            {
                AuthenticationMethod = RepositoryAuthenticationMethod.UserName,
                Url             = "localhost:19893",
                TransportMethod = RepositoryTransportMethod.NetTcp,
                UserName        = "******",
                Password        = "******"
            };

            var api = new WcfRepositoryClient(info);

            return(api);
        }
        public static RepositoryClientBase GetClient(string url = "localhost")
        {
            // The WcfRepositoryClient takes a configation object
            // detailing how to connect to the Repository.
            var connectionInfo = new RepositoryConnectionInfo()
            {
                Url = url,
                AuthenticationMethod = RepositoryAuthenticationMethod.Windows,
                TransportMethod      = RepositoryTransportMethod.NetTcp,
            };

            var repo = new WcfRepositoryClient(connectionInfo);

            return(repo);
        }
        /// <summary>
        /// Configures and returns a client object that can be used to communicate
        /// with Colectica Repository via its Web Services.
        /// </summary>
        public static RepositoryClientBase GetClient()
        {
            // The WcfRepositoryClient takes a configation object
            // detailing how to connect to the Repository.
            var connectionInfo = new RepositoryConnectionInfo()
            {
                // TODO Replace this with the hostname of your Colectica Repository
                Url = "localhost",
                AuthenticationMethod = RepositoryAuthenticationMethod.Windows,
                TransportMethod = RepositoryTransportMethod.NetTcp,
            };

            // Create the client object, passing in the connection information.
            var client = new WcfRepositoryClient(connectionInfo);
            return client;
        }
Exemple #15
0
        public static RepositoryClientBase GetClient()
        {
            // The WcfRepositoryClient takes a configation object
            // detailing how to connect to the Repository.
            var connectionInfo = new RepositoryConnectionInfo()
            {
                // TODO Replace this with the hostname of your Colectica Repository
                Url = "localhost",
                AuthenticationMethod = RepositoryAuthenticationMethod.Windows,
                TransportMethod      = RepositoryTransportMethod.NetTcp,
            };

            // Create the client object, passing in the connection information.
            var client = new WcfRepositoryClient(connectionInfo);

            return(client);
        }
Exemple #16
0
        public DateTime?GetLastLocalCommitDate(RepositoryConnectionInfo repInfo)
        {
            var git        = Git.Open(repInfo.LocalDirectory);
            var repository = git.GetRepository();

            var reader  = new ReflogReader(repository, "HEAD");
            var lastRef = reader.GetLastEntry();

            if (lastRef == null)
            {
                return(null);
            }

            var authorIdent    = lastRef.GetWho();
            var authorDate     = authorIdent.GetWhen();
            var timeZoneOffset = TimeSpan.FromMinutes(authorIdent.GetTimeZoneOffset());

            return(authorDate + timeZoneOffset);
        }
Exemple #17
0
        public static RepositoryClientBase GetClient()
        {
            var connectionInfo = new RepositoryConnectionInfo()
            {
                Url             = RepositoryHostName,
                TransportMethod = RepositoryTransportMethod.REST
            };

            if (string.IsNullOrWhiteSpace(UserName) ||
                string.IsNullOrWhiteSpace(Password))
            {
                connectionInfo.AuthenticationMethod = RepositoryAuthenticationMethod.Windows;
            }
            else
            {
                connectionInfo.AuthenticationMethod = RepositoryAuthenticationMethod.UserName;
                connectionInfo.UserName             = UserName;
                connectionInfo.Password             = Password;
            }

            return(new RestRepositoryClient(connectionInfo));
        }
Exemple #18
0
        public SystemStatusModel GetSystemStatus()
        {
            var model = new SystemStatusModel();

            MefConfig.Container.SatisfyImportsOnce(model);

            // Database
            var dbStatus = new SystemComponent()
            {
                Name = "Colectica Curation Database"
            };

            model.Components.Add(dbStatus);

            try
            {
                using (var db = ApplicationDbContext.Create())
                {
                    var testUser = db.Users.FirstOrDefault();
                    dbStatus.IsWorking = true;
                }
            }
            catch (Exception ex)
            {
                dbStatus.IsWorking = false;
                dbStatus.Message   = string.Join(". ", ex.FlattenHierarchy().Select(x => x.Message));
            }

            // Curation service
            var serviceStatus = new SystemComponent()
            {
                Name = "Colectica Curation Service"
            };

            model.Components.Add(serviceStatus);

            try
            {
                var curatorService = new ServiceController("Colectica Curation Service");
                serviceStatus.IsWorking = curatorService.Status == ServiceControllerStatus.Running;
                serviceStatus.Message   = curatorService.Status.ToString();
            }
            catch (Exception ex)
            {
                serviceStatus.IsWorking = false;
                serviceStatus.Message   = ex.Message;
            }

#if ISPRO
            // Repository
            var repoStatus = new SystemComponent()
            {
                Name = "Colectica Repository"
            };
            model.Components.Add(repoStatus);

            try
            {
                var connectionInfo = new RepositoryConnectionInfo()
                {
                    Url = "localhost",
                    AuthenticationMethod = RepositoryAuthenticationMethod.Windows,
                    TransportMethod      = RepositoryTransportMethod.NetTcp
                };
                var client   = RepositoryHelper.GetClient();
                var testInfo = client.GetRepositoryInfo();
                repoStatus.IsWorking = true;
            }
            catch (Exception ex)
            {
                repoStatus.IsWorking = false;
                repoStatus.Message   = ex.Message;
            }
#endif

            // Clam Antivirus
            var clamStatus = new SystemComponent()
            {
                Name = "Clam Antivirus"
            };
            model.Components.Add(clamStatus);

            try
            {
                var clamService = new ServiceController("ClamD");
                clamStatus.IsWorking = clamService.Status == ServiceControllerStatus.Running;
                clamStatus.Message   = clamService.Status.ToString();
            }
            catch (Exception ex)
            {
                clamStatus.IsWorking = false;
                clamStatus.Message   = ex.Message;
            }

            // Stata
            //var stataStatus = new SystemComponent() { Name = "Stata" };
            //model.Components.Add(stataStatus);

            // R
            var rStatus = new SystemComponent()
            {
                Name = "R"
            };
            model.Components.Add(rStatus);

            try
            {
                //string rMessage = string.Empty;
                //var rImporter = new RDataImporter();
                //rStatus.IsWorking = rImporter.AreSystemRequirementsSatisfied(out rMessage);
            }
            catch (Exception ex)
            {
                rStatus.IsWorking = false;
                rStatus.Message   = ex.Message;
            }

            return(model);
        }