Beispiel #1
0
        public void test_initialize()
        {
            Mock <IHelper> mockHelper = new Mock <IHelper>();

            mockHelper.Setup(p => p.GetDBContext(It.IsAny <int>()))
            .Returns <int>(workspaceID =>
            {
                if (workspaceID == 0)
                {
                    throw new ArgumentException();
                }
                return(new DBContext(new kCura.Data.RowDataGateway.Context(c_SQLServerName, string.Format("EDDS{0}", workspaceID == -1 ? string.Empty : workspaceID.ToString()), c_SQLUser, c_SQLPassword)));;
            });
            mockHelper.Setup(p => p.GetServicesManager())
            .Returns(() =>
            {
                Mock <IServicesMgr> svcMgr = new Mock <IServicesMgr>();
                svcMgr.Setup(p => p.CreateProxy <IRSAPIClient>(It.IsAny <ExecutionIdentity>()))
                .Returns <ExecutionIdentity>(eid =>
                {
                    var rc = new RSAPIClient(new Uri(c_ServerURL), new UsernamePasswordCredentials(c_RelativityUser, c_RelativityPassword));
                    rc.Login();
                    return(rc);
                });
                return(svcMgr.Object);
            });
            NSerio.Relativity.RepositoryHelper.ConfigureRepository(mockHelper.Object);
        }
        // TODO: Get the ident thing sorted out one day
        public T CreateProxy <T>(ExecutionIdentity ident) where T : IDisposable
        {
            var proxy = new RSAPIClient(
                new Uri(rsapiUrl),
                new UsernamePasswordCredentials(rsapiUsername, rsapiPassword)) as IRSAPIClient;

            return((T)proxy);
        }
Beispiel #3
0
        public IRSAPIClient getConection(int workspaceId)
        {
            IRSAPIClient client = new RSAPIClient(new Uri(String.Format($"{baseAddres}/relativity.services/")),
                                                  new UsernamePasswordCredentials(user, password));

            client.APIOptions.WorkspaceID = workspaceId;
            return(client);
        }
Beispiel #4
0
        public void Setup()
        {
            _helper = new Mock <IHelper>();
            var client = new RSAPIClient(new Uri($"http://{Config.RSAPIServer}/relativity.services"),
                                         new UsernamePasswordCredentials(Config.RSAPIUsername, Config.RSAPIPassword));

            _helper.Setup(h => h.GetServicesManager().CreateProxy <IRSAPIClient>(ExecutionIdentity.System))
            .Returns(client);
        }
        public static IRSAPIClient CreateRsapiClient()
        {
            Uri endpointUri = new Uri($"{protocol}://{serverAddress}/Relativity.Services");

            IRSAPIClient rsapiClient = new RSAPIClient(endpointUri, new UsernamePasswordCredentials(userName, password));

            System.Console.WriteLine($"Client created and logged in.");

            return(rsapiClient);
        }
        /// <summary>
        /// Gets the RSAPIClient with IntegratedAuth
        /// </summary>
        /// <param name="workspaceId"></param>
        /// <returns></returns>
        private IRSAPIClient GetRsapiIntegrated(int workspaceId = -1)
        {
            var          creds = new kCura.Relativity.Client.IntegratedAuthCredentials();
            IRSAPIClient proxy = new RSAPIClient(
                ServicesUri,
                creds);

            proxy.APIOptions.WorkspaceID = workspaceId;
            proxy.Login();
            return(proxy);
        }
 public IRSAPIClient GetRsapiClient()
 {
     try
     {
         IRSAPIClient proxy = new RSAPIClient
                                  (ServicesUri, new UsernamePasswordCredentials(_userName, _password));
         proxy.APIOptions.WorkspaceID = WorkspaceID;
         return(proxy);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Failed to connect to RSAPI. " + ex);
         throw;
     }
 }
        /// <summary>
        /// Returns the RSAPIClient with the given workspace
        /// </summary>
        /// <param name="workspaceId"></param>
        /// <returns></returns>
        public IRSAPIClient GetRsapiClient(int workspaceId = -1)
        {
            switch (_authType)
            {
            case Constants.Enums.AuthType.Integrated:
                return(GetRsapiIntegrated(workspaceId));

            case Constants.Enums.AuthType.UsernamePassword:
                IRSAPIClient proxy = new RSAPIClient(
                    ServicesUri,
                    new kCura.Relativity.Client.UsernamePasswordCredentials(_user, _password));
                //proxy.APIOptions.WorkspaceID = DefaultWorkspaceId;
                proxy.APIOptions.WorkspaceID = workspaceId;
                proxy.Login();
                return(proxy);

            default:
                return(GetRsapiIntegrated(workspaceId));
            }
        }
        private IRSAPIClient GetRsapiClient()
        {
            IRSAPIClient rsapiClient = new RSAPIClient(RsapiUri, new kCura.Relativity.Client.UsernamePasswordCredentials(RelativityUserName, RelativityPassword));

            return(rsapiClient);
        }