コード例 #1
0
        private void SeedClients(SurveyAppContext context)
        {
            var mock = new ApplicationClient[] {
                new ApplicationClient()
                {
                    Name                = "angularjs",
                    PublicKey           = "El246n9cf1minYI0YGcBVQ8971fK8Gfp",
                    SecretKey           = "517DW0p493372N4s2753ply07p1tqe78",
                    IsActive            = true,
                    TokenExpirationTime = 30 // 30 minutes
                },
                new ApplicationClient()
                {
                    Name                = "androidmobile",
                    PublicKey           = "p35iw0R6RO1730BSK432qswrZldwY0jR",
                    SecretKey           = "PX5ie6aj22t7xi3J3u4xXR6r90RXPo88",
                    IsActive            = true,
                    TokenExpirationTime = 46800 // 30 days
                }
            };

            foreach (var entry in mock)
            {
                context.ApplicationClients.Add(entry);
            }
        }
        public async Task <string> GenerateRefreshToken(
            ApplicationUser user,
            ApplicationClient client)
        {
            var existingRefreshToken = await this.dataService
                                       .RefreshTokens
                                       .FindByCondition(r => r.ApplicationClientId == client.Id && r.UserId.ToString() == user.Id);

            if (existingRefreshToken != null)
            {
                dataService.RefreshTokens.Delete(existingRefreshToken);
            }

            RefreshToken refreshToken = new RefreshToken()
            {
                UserId = Guid.Parse(user.Id),
                ApplicationClientId = client.Id,
                ProtectedTicket     = GenerateRefreshToken(),
                ExpiresUtc          = DateTime.Now.AddMinutes(client.RefreshTokenLifeTime).ToUniversalTime()
            };

            dataService.RefreshTokens.Create(refreshToken);
            await dataService.CompleteAsync();

            return(refreshToken.ProtectedTicket);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            var log      = GetProductionLogger();
            var assembly = System.Reflection.Assembly.GetExecutingAssembly();
            var fvi      = FileVersionInfo.GetVersionInfo(assembly.Location);
            var c        = new RealClock();

            log.LogInformation($"Starting PBXConnector Console Runner {fvi.FileVersion}");

            RegistryConfigurationProvider config;

            try {
                config = new RegistryConfigurationProvider(log);
            }
            catch (Exception ex) {
                log.LogError("Error starting PBXConnector Console Runner", ex);
                throw;
            }
            var ac = new ApplicationClient(
                new PBXApplicationClientConfigurationProvider(config),
                log, "CJASDBYCOKYIWBWNFPQHOBGIQPEJUBSYNEOUEKJZTOSWWCPGCRWNYGBOOUZE");
            var connector = new PBXConnection(log, config, ac, c);

            connector.Start();
        }
コード例 #4
0
        public IdentityResult SignInClient(ExternalLoginInfo loginInfo, string clientKey, string userHostAddress, string sessionID)
        {
            if (string.IsNullOrEmpty(clientKey))
            {
                throw new ArgumentNullException(nameof(loginInfo));
            }
            if (loginInfo == null)
            {
                throw new ArgumentNullException(nameof(loginInfo));
            }
            var user   = Find(loginInfo);
            var client = user.User.Clients.SingleOrDefault(c => c.ClientKey == clientKey && c.SessionId == sessionID);

            if (client == null)
            {
                client = new ApplicationClient
                {
                    ClientKey   = clientKey,
                    IPAddress   = userHostAddress,
                    SessionId   = sessionID,
                    ConnectedOn = DateTime.UtcNow
                };
                user.User.AddClients(client);
            }
            else
            {
                client.ConnectedOn = DateTime.UtcNow;
            }
            var result = this.UpdateAsync(user).Result;

            user.CurrentClientId = client.Id.ToString();
            return(result);
        }
コード例 #5
0
        private static void CreateClientSecret(ApplicationClient applicationClientEntity)
        {
            var key = new byte[32];

            RandomNumberGenerator.Create().GetBytes(key);
            applicationClientEntity.Base64Secret = WebEncoders.Base64UrlEncode(key);
        }
        public async Task <AuthenticationProviderResult <RefreshToken> > ValidateRefreshToken(
            ApplicationClient client,
            string refreshTokenTicket)
        {
            var response = new AuthenticationProviderResult <RefreshToken>()
            {
                IsSuccessful    = false,
                ResponseMessage = "",
                Result          = null
            };

            var existingRefreshToken = await this.dataService
                                       .RefreshTokens
                                       .FindByCondition(r => r.ApplicationClientId == client.Id &&
                                                        r.ProtectedTicket == refreshTokenTicket);

            if (existingRefreshToken == null)
            {
                response.ResponseMessage = "Invalid token";
                return(response);
            }

            if (existingRefreshToken.ExpiresUtc < DateTime.Now.ToUniversalTime())
            {
                response.ResponseMessage = "Token expired";
                return(response);
            }

            response.IsSuccessful = true;
            response.Result       = existingRefreshToken;
            return(response);
        }
コード例 #7
0
        /// <summary>
        /// Instantiates a new instance.
        /// </summary>
        /// <param name="apiKey">The API key to use to communicate with the Vultr
        /// API.</param>
        /// <param name="apiURL">The optional Vultr API URL to use. Set this if you want
        /// to override the default endpoint (e.g. for testing).</param>
        /// <exception cref="ArgumentNullException">If <paramref name="apiKey"/> is null
        /// or empty.</exception>
        public VultrClient(string apiKey, string apiURL = VultrApiURL)
        {
            if (string.IsNullOrEmpty(apiKey))
            {
                throw new ArgumentNullException("apiKey", "apiKey must not be null");
            }

            Account         = new AccountClient(apiKey, apiURL);
            Application     = new ApplicationClient(apiKey, apiURL);
            Auth            = new AuthClient(apiKey, apiURL);
            Backup          = new BackupClient(apiKey, apiURL);
            Block           = new BlockClient(apiKey, apiURL);
            DNS             = new DNSClient(apiKey, apiURL);
            Firewall        = new FirewallClient(apiKey, apiURL);
            ISOImage        = new ISOImageClient(apiKey, apiURL);
            Network         = new NetworkClient(apiKey, apiURL);
            OperatingSystem = new OperatingSystemClient(apiKey, apiURL);
            Plan            = new PlanClient(apiKey, apiURL);
            Region          = new RegionClient(apiKey, apiURL);
            ReservedIP      = new ReservedIPClient(apiKey, apiURL);
            Server          = new ServerClient(apiKey, apiURL);
            Snapshot        = new SnapshotClient(apiKey, apiURL);
            SSHKey          = new SSHKeyClient(apiKey, apiURL);
            StartupScript   = new StartupScriptClient(apiKey, apiURL);
            User            = new UserClient(apiKey, apiURL);
        }
コード例 #8
0
        public override int Execute(GenerateModelsOptions options)
        {
            try
            {
                if (!EnvironmentSettings.Uri.EndsWith('/'))
                {
                    EnvironmentSettings.Uri += "/";
                }

                Uri    metaData = new Uri($"{EnvironmentSettings.Uri}0/ServiceModel/EntityDataService.svc/$metadata");
                string response = ApplicationClient.ExecuteGetRequest(metaData.ToString(), -1);

                int count = CountXmlLines(response);

                ConsoleWriter.WriteMessage(ConsoleWriter.MessageType.OK, $"Obtained definition for {count} entities");
                Console.WriteLine();
                Console.WriteLine($"Would you like to create {count} models ? \nPress any key to continue, <Esc> to exit\n...\n");
                ConsoleKeyInfo keyInfo = Console.ReadKey();

                if (keyInfo.Key != ConsoleKey.Escape)
                {
                    Task t = Task.Run(async() => {
                        await BuildModelsAsync(response, options.DestinationPath);
                    });
                    t.Wait();
                }


                return(0);
            }
            catch (Exception)
            {
                return(1);
            }
        }
コード例 #9
0
    // Start is called before the first frame update
    void Start()
    {
        // enter your device details here
        orgId     = "";
        appId     = "";
        apiKey    = "";
        authToken = "";

        ApplicationClient applicationClient = new ApplicationClient(orgId, appId, apiKey, authToken);

        try{
            applicationClient.connect();
            Debug.Log("Connected");
        }
        catch (Exception ex) {
            Debug.Log(ex);
        }

        /* try{
         *  applicationClient.eventCallback += processEvent;
         *  applicationClient.subscribeToDeviceEvents("ChildApp", "123456");
         * }
         * catch(Exception ex){
         *  Debug.Log(ex);
         * }*/

        try{
            // change details here
            applicationClient.publishCommand("device type", "device ID", "event Name", "format", "data", 2);
        }
        catch (Exception ex) {
            Debug.Log(ex);
        }
    }
コード例 #10
0
 public override int Execute(PkgListOptions options)
 {
     try {
         var    scriptData         = "{}";
         string responseFormServer = ApplicationClient.ExecutePostRequest(ServiceUri, scriptData);
         var    json             = CorrectJson(responseFormServer);
         var    packages         = JsonConvert.DeserializeObject <List <Dictionary <string, string> > >(json);
         var    selectedPackages = packages.Where(p => p["Name"].ToLower().Contains(options.SearchPattern.ToLower())).OrderBy(p => p["Name"]);
         if (selectedPackages.Count() > 0)
         {
             var row = GetFormatedString("Name", "Maintainer");
             Console.WriteLine();
             Console.WriteLine(row);
             Console.WriteLine();
         }
         foreach (var p in selectedPackages)
         {
             var row = GetFormatedString(p["Name"], p["Maintainer"]);
             Console.WriteLine(row);
         }
         Console.WriteLine();
         Console.WriteLine($"Find {selectedPackages.Count()} packages in {EnvironmentSettings.Uri}");
         return(0);
     } catch (Exception e) {
         Console.WriteLine(e);
         return(1);
     }
 }
コード例 #11
0
        static void Main(string[] args)
        {
            try
            {
                string data       = "{\"name\":\"foo\",\"cpu\":60,\"mem\":50}";
                string deviceType = "";
                string deviceId   = "";
                string evt        = "test";
                string format     = "json";

                Console.Write("Enter your org id :");
                orgId = Console.ReadLine();

                Console.Write("Enter your app id :");
                appId = Console.ReadLine();

                Console.Write("Enter your api Key :");
                apiKey = Console.ReadLine();

                Console.Write("Enter your auth token :");
                authToken = Console.ReadLine();

                Console.Write("Please enter device details to which you want to subscribe event and send command...");

                Console.Write("Enter your device type :");
                deviceType = Console.ReadLine();

                Console.Write("Enter your device id :");
                deviceId = Console.ReadLine();



                ApplicationClient applicationClient = new ApplicationClient(orgId, appId, apiKey, authToken);
                applicationClient.connect();

                Console.WriteLine("Connected sucessfully to app id : " + appId);

                applicationClient.commandCallback      += processCommand;
                applicationClient.eventCallback        += processEvent;
                applicationClient.deviceStatusCallback += processDeviceStatus;
                applicationClient.appStatusCallback    += processAppStatus;

                applicationClient.subscribeToDeviceStatus();
                applicationClient.subscribeToApplicationStatus();



                applicationClient.subscribeToDeviceEvents(deviceType, deviceId, evt, format, 0);



                applicationClient.publishCommand(deviceType, deviceId, "testcmd", "json", data, 0);

                applicationClient.disconnect();
            }
            catch (Exception)
            {
                // ignore
            }
        }
コード例 #12
0
 internal void AttachToState(ApplicationClient application, ApplicationState applicationState, ICommandQueue commandQueue, IViewStore viewStore)
 {
     _application      = application ?? throw new ArgumentNullException(nameof(application));
     _applicationState = applicationState ?? throw new ArgumentNullException(nameof(applicationState));
     _commandQueue     = commandQueue ?? throw new ArgumentNullException(nameof(commandQueue));
     _viewStore        = viewStore ?? throw new ArgumentNullException(nameof(viewStore));
 }
コード例 #13
0
        private void DeletePackage(string code)
        {
            Console.WriteLine("Deleting...");
            string deleteRequestData = "\"" + code + "\"";

            ApplicationClient.ExecutePostRequest(DeletePackageUrl, deleteRequestData, Timeout.Infinite);
            Console.WriteLine("Deleted.");
        }
コード例 #14
0
        private Application DeleteApplicationMetadata()
        {
            ApplicationClient appClient = new ApplicationClient(client);

            Application existingApp = appClient.DeleteApplication(testAppId);

            return(existingApp);
        }
コード例 #15
0
        private void DeleteApplicationMetadata()
        {
            ApplicationClient appClient = new ApplicationClient(client);

            foreach (string id in appIds)
            {
                appClient.DeleteApplication(id);
            }
        }
コード例 #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InstanceStorageTests"/> class.
        /// </summary>
        /// <param name="fixture">the fixture object which talks to the SUT (System Under Test)</param>
        public InstanceMultipartTests(PlatformStorageFixture fixture)
        {
            this.fixture           = fixture;
            this.client            = this.fixture.Client;
            this.storageClient     = new InstanceClient(this.client);
            this.applicationClient = new ApplicationClient(client);

            CreateTestApplication();
        }
コード例 #17
0
        public async Task UpdateAsync(ApplicationClient update, CancellationToken cancellationToken)
        {
            var entity = await _applicationManager.FindByIdAsync(update.ClientId ?? update.Id.ToString(), cancellationToken);

            if (entity != null)
            {
                UpdateProperties(update, entity);
                await _applicationManager.UpdateAsync(entity, update.ClientSecret ?? "", cancellationToken);
            }
        }
コード例 #18
0
        public void UpdateSysSetting(SysSettingsOptions opts, EnvironmentSettings settings = null)
        {
            string requestData = "{\"isPersonal\":false,\"sysSettingsValues\":{" + string.Format("\"{0}\":{1}", opts.Code, opts.Value) + "}}";

            try {
                ApplicationClient.ExecutePostRequest(PostSysSettingsValuesUrl, requestData);
                Console.WriteLine("SysSettings with code: {0} updated.", opts.Code);
            } catch {
                Console.WriteLine("SysSettings with code: {0} is not updated.", opts.Code);
            }
        }
コード例 #19
0
ファイル: ApplicationState.cs プロジェクト: sibearia/cleanic
    internal void AttachToApplication(ApplicationClient application, ICommandQueue commandQueue, IViewStore viewStore)
    {
        _application  = application ?? throw new ArgumentNullException(nameof(application));
        _commandQueue = commandQueue ?? throw new ArgumentNullException(nameof(commandQueue));
        _viewStore    = viewStore ?? throw new ArgumentNullException(nameof(viewStore));

        foreach (var action in Actions)
        {
            action.AttachToState(application, this, commandQueue, viewStore);
        }
    }
コード例 #20
0
 private static void UpdateProperties(
     ApplicationClient model,
     ApplicationClient entity
     )
 {
     entity.ConsentType            = model.ConsentType;
     entity.Permissions            = model.Permissions;
     entity.RedirectUris           = model.RedirectUris;
     entity.PostLogoutRedirectUris = model.PostLogoutRedirectUris;
     entity.Requirements           = model.Requirements;
 }
コード例 #21
0
        private string GenerateToken(ApplicationClient client, ApplicationUser user, DateTime expiration)
        {
            var payload = new Dictionary <string, object>()
            {
                { "Expiration", expiration },
                { "Client", client.Name },
                { "UserId", user.Id },
                { "Roles", user.Roles.Select(role => role.Name).ToArray() }
            };

            return(JWT.JsonWebToken.Encode(payload, client.SecretKey, JWT.JwtHashAlgorithm.HS256));
        }
        public override async Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context)
        {
            var clientId     = string.Empty;
            var clientSecret = string.Empty;

            if (!context.TryGetBasicCredentials(out clientId, out clientSecret))
            {
                context.TryGetFormCredentials(out clientId, out clientSecret);
            }

            if (context.ClientId == null)
            {
                context.Rejected();
                context.SetError("invalid_client", "Client credentials could not be retrieved through the Authorization header.");
                return;
            }

            try
            {
                if (clientId == "MyApp" && clientSecret == "MySecret")
                {
                    var client = new ApplicationClient
                    {
                        Id               = "MyApp",
                        AllowedGrant     = OAuthGrant.ResourceOwner,
                        ClientSecretHash = new PasswordHasher().HashPassword("MySecret"),
                        Name             = "My App",
                        CreatedOn        = DateTimeOffset.UtcNow
                    };

                    context.OwinContext.Set <ApplicationClient>("oauth:client", client);

                    string uid = context.Parameters.Where(f => f.Key == "uid").Select(f => f.Value).SingleOrDefault()[0];
                    context.OwinContext.Set <string>("SmartCard", uid);

                    context.Validated(clientId);
                }
                else
                {
                    // Client could not be validated.
                    context.SetError("invalid_client", "Client credentials are invalid.");
                    context.Rejected();
                }
            }
            catch (Exception)
            {
                context.SetError("server_error");
                context.Rejected();
            }

            return;
        }
コード例 #23
0
        public override async Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context)
        {
            //context.Validated();
            //return;

            string clientId = string.Empty;
            string clientSecret = string.Empty;

            if (!context.TryGetBasicCredentials(out clientId, out clientSecret))
            {
                context.TryGetFormCredentials(out clientId, out clientSecret);
            }

            if (context.ClientId == null)
            {
                context.SetError("invalid_client", "Client credentials could not be retrieved through the Authorization header.");
                context.Rejected();

                return;
            }

            try
            {
                if (clientId == "MyApp" && clientSecret == "MySecret")
                {
                    ApplicationClient client = new ApplicationClient();

                    client.Id = "MyApp";
                    client.AllowedGrant = OAuthGrant.ResourceOwner;
                    client.ClientSecretHash = new PasswordHasher().HashPassword("MySecret");
                    client.Name = "My App";
                    client.CreatedOn = DateTimeOffset.UtcNow;

                    context.OwinContext.Set<ApplicationClient>("oauth:client", client);
                    context.Validated(clientId);
                }
                else
                {
                    // Client could not be validated.
                    context.SetError("invalid_client", "Client credentials are invalid.");
                    context.Rejected();
                }
            }
            catch (Exception ex)
            {
                string errorMessage = ex.Message;
                context.SetError("server_error");
                context.Rejected();
            }

            return;
        }
コード例 #24
0
        public void Execute_ComplexObject_NoParamsTest()
        {
            ApplicationClient userSvc = new ApplicationClient(UserId, ApiKey, "UserService");

            User expected = new User(2, new FullName("Jane", "Doe"));
            User actual = userSvc.Execute<User>("CreateDefault");

            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Id, actual.Id);
            Assert.IsNotNull(actual.Name);
            Assert.AreEqual(expected.Name.FirstName, actual.Name.FirstName);
            Assert.AreEqual(expected.Name.LastName, actual.Name.LastName);
        }
コード例 #25
0
        public void Execute_ComplexObject_withParamsTest()
        {
            ApplicationClient userSvc = new ApplicationClient(UserId, ApiKey, "UserService");

            User expected = new User(1, new FullName("Alex", "Espinoza"));
            User actual = userSvc.Execute<User>("Create", new MethodParameter("id", expected.Id), new MethodParameter("name", expected.Name));

            Assert.IsNotNull(actual);
            Assert.AreEqual(expected.Id, actual.Id);
            Assert.IsNotNull(actual.Name);
            Assert.AreEqual(expected.Name.FirstName, actual.Name.FirstName);
            Assert.AreEqual(expected.Name.LastName, actual.Name.LastName);
        }
コード例 #26
0
        private void CreateSysSetting(SysSettingsOptions opts)
        {
            Guid   id          = Guid.NewGuid();
            string requestData = "{" + string.Format("\"id\":\"{0}\",\"name\":\"{1}\",\"code\":\"{1}\",\"valueTypeName\":\"{2}\",\"isCacheable\":true",
                                                     id, opts.Code, opts.Type) + "}";

            try {
                ApplicationClient.ExecutePostRequest(InsertSysSettingsUrl, requestData);
                Console.WriteLine("SysSettings with code: {0} created.", opts.Code);
            } catch {
                Console.WriteLine("SysSettings with code: {0} already exists.", opts.Code);
            }
        }
コード例 #27
0
        public override async Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context)
        {
            string clientId     = string.Empty;
            string clientSecret = string.Empty;

            if (!context.TryGetBasicCredentials(out clientId, out clientSecret))
            {
                context.TryGetFormCredentials(out clientId, out clientSecret);
            }

            if (context.ClientId == null)
            {
                context.SetError("invalid_client", "Client credentials could not be retrieved through the Authorization header.");
                context.Rejected();

                return;
            }

            try
            {
                if (clientId == "MyApp" && clientSecret == "MySecret")
                {
                    ApplicationClient client = new ApplicationClient();

                    client.Id               = "MyApp";
                    client.AllowedGrant     = OAuthGrant.ResourceOwner;
                    client.ClientSecretHash = new PasswordHasher().HashPassword("MySecret");
                    client.Name             = "My App";
                    client.CreatedOn        = DateTimeOffset.UtcNow;

                    context.OwinContext.Set <ApplicationClient>("oauth:client", client);

                    context.Validated(clientId);
                }
                else
                {
                    // Client could not be validated.
                    context.SetError("invalid_client", "Client credentials are invalid.");
                    context.Rejected();
                }
            }
            catch (Exception ex)
            {
                string errorMessage = ex.Message;
                context.SetError("server_error");
                context.Rejected();
            }

            return;
        }
コード例 #28
0
        public async Task CreateAsync(ApplicationClient applicationClient, CancellationToken cancellationToken)
        {
            if (applicationClient == null)
            {
                throw new ArgumentNullException(nameof(applicationClient));
            }

            var entity = await _applicationManager.FindByIdAsync(applicationClient.Id.ToString(), cancellationToken);

            if (entity == null)
            {
                await _applicationManager.CreateAsync(applicationClient, applicationClient.ClientSecret,
                                                      cancellationToken);
            }
        }
コード例 #29
0
        public void ExecuteAsync_ComplexObject_withParamsTest()
        {
            ApplicationClient userSvc = new ApplicationClient(UserId, ApiKey, "UserService");

            User expected = new User(1, new FullName("Alex", "Espinoza"));
            Action<User> callback = actual => {
                Assert.IsNotNull(actual);
                Assert.AreEqual(expected.Id, actual.Id);
                Assert.IsNotNull(actual.Name);
                Assert.AreEqual(expected.Name.FirstName, actual.Name.FirstName);
                Assert.AreEqual(expected.Name.LastName, actual.Name.LastName);
            };

            Task<User> task = userSvc.ExecuteAsync(callback, "Create", new MethodParameter("id", expected.Id), new MethodParameter("name", expected.Name));
            task.Wait();
        }
コード例 #30
0
 protected int Login()
 {
     try {
         Console.WriteLine($"Try login to {EnvironmentSettings.Uri} with {EnvironmentSettings.Login} credentials...");
         ApplicationClient.Login();
         Console.WriteLine("Login done");
         return(0);
     } catch (WebException we) {
         HttpWebResponse errorResponse = we.Response as HttpWebResponse;
         if (errorResponse.StatusCode == HttpStatusCode.NotFound)
         {
             Console.WriteLine($"Application {EnvironmentSettings.Uri} not found");
         }
         return(1);
     }
 }
コード例 #31
0
        private Application CreateTestApplication(string appId)
        {
            ApplicationClient appClient = new ApplicationClient(client);

            try
            {
                Application existingApp = appClient.GetApplication(appId);
                return(existingApp);
            }
            catch (Exception)
            {
                // do nothing.
            }

            return(appClient.CreateApplication(appId, null));
        }
コード例 #32
0
        public async Task <IActionResult> RegisterClient([FromBody] AuthorizedQS ajaxModel)
        {
            if (ajaxModel.value.Length == 0)
            {
                return(Content("false"));
            }

            var client = new ApplicationClient()
            {
                ClientDescription = ajaxModel.value
            };

            db.ApplicationClients.Add(client);
            await db.SaveChangesAsync();

            return(Content("true:" + client.applicationClientId));
        }
コード例 #33
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageBoxInstancesControllerTest"/> class.
        /// </summary>
        /// <param name="fixture">the fixture object which talks to the SUT (System Under Test)</param>
        public MessageBoxInstancesControllerTest(PlatformStorageFixture fixture)
        {
            this.fixture        = fixture;
            this.client         = this.fixture.Client;
            this.instanceClient = new InstanceClient(this.client);
            this.appClient      = new ApplicationClient(this.client);

            _client = new DocumentClient(new Uri(_cosmosSettings.EndpointUri), _cosmosSettings.PrimaryKey, new ConnectionPolicy
            {
                ConnectionMode     = ConnectionMode.Gateway,
                ConnectionProtocol = Protocol.Https,
            });

            testdata = new TestData();
            appIds   = testdata.GetAppIds();
            CreateTestApplications();
        }
コード例 #34
0
        public async Task <GenericResponse> UpdateApplicationClient(ApplicationClient applicationClient, ApplicationClientForUpdateDto applicationClientForUpdate)
        {
            try
            {
                this.mapper.Map(applicationClientForUpdate, applicationClient);

                this.dataService.ApplicationClients.Update(applicationClient);
                await this.dataService.CompleteAsync();

                return(GenericResponseBuilder.Success());
            }
            catch (Exception ex)
            {
                logger.LogError(string.Format("Error in BLL - UpdateApplicationClient. {0}", ex.Message));
                return(GenericResponseBuilder.NoSuccess(ex.Message.ToString()));
            }
        }
コード例 #35
0
        private async void connectClientAPI()
        {
            var infos = await m_env.GetApplicationInfos();

            m_clientAPI = ApplicationClient.ForApi(infos.AccountId, infos.ApplicationName, infos.PrimaryKey);
            m_clientAPI.Endpoint = infos.ApiEndpoint;
        }
コード例 #36
0
        public void Execute_withParamsTest()
        {
            ApplicationClient userSvc = new ApplicationClient(UserId, ApiKey, "UserService");

            string result = userSvc.Execute<string>("GetFirstNameById", new MethodParameter("id", 1));

            Assert.AreEqual("Robert", result);
        }
コード例 #37
0
        public void Execute_NoParamsTest()
        {
            ApplicationClient userSvc = new ApplicationClient(UserId, ApiKey, "UserService");

            string result = userSvc.Execute<string>("GetMostCommonFirstName");

            Assert.AreEqual("John", result);
        }