public void Work(Hangfire.Server.PerformContext performContext, IJobCancellationToken jobCancellationToken, int docnumber) { //Hangfire.BackgroundJobClient backgroundJobClient = new BackgroundJobClient(performContext.Storage); //Avvio il cronometro ChronoStart(performContext.BackgroundJob.CreatedAt, docnumber.ToString()); //Aggiungo un dettaglio al cronometro ChronoDetailAdd("start"); //Aggiungo un dettaglio al cronometro prendendomi l'ID del dettaglio var id = ChronoDetailAddStart("login action"); //Eseguo la call di login ArxivarService.Login(); //Aggiungo l'End al dettaglio del cronometro dato l'ID ChronoDetailAddEnd(id); //Eseguo la call di get user IO.Swagger.Api.UsersApi usersApi = new IO.Swagger.Api.UsersApi(ArxivarService.Configuration); usersApi.UsersGet(2); //Aggiungo un dettaglio al cronometro ChronoDetailAdd("after get users"); //Aggiungo un dettaglio al cronometro ChronoDetailAdd("End"); //Aggiungo l'End al cronometro iniziale ChronoEnd(); }
public async Task GetUserUserPrivileges() { var client = new AmbariRestClient($"https://{ClusterNetworkName}.azurehdinsight.net/api/v1/", UserName, Password); var api = new IO.Swagger.Api.UsersApi(client); var result = api.UserPrivilegeServiceGetPrivileges(UserName, "*", null, null, null, null); Trace.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented)); }
public async Task GetUsers() { var client = new AmbariRestClient($"https://{ClusterNetworkName}.azurehdinsight.net/api/v1/", UserName, Password); var api = new IO.Swagger.Api.UsersApi(client); var users = api.GetUsers("*", null, null, null, null); Assert.IsTrue(users.Count > 0); }
public async Task CreateUser() { var client = new AmbariRestClient($"https://{ClusterNetworkName}.azurehdinsight.net/api/v1/", UserName, Password); var api = new IO.Swagger.Api.UsersApi(client); var body = new UserRequestCreateUserSwagger() { Users = new CreateUserInfo() { Active = true, Admin = false, // DisplayName = "Three, User", LocalUserName = "******", Password = "******" } }; api.CreateUser(body.Users.LocalUserName, body); }
public ActionResult <EngineResult> Get(string id) { try { var arxivarRestConfiguration = new IO.Swagger.Client.Configuration() { BasePath = _appSettingsService.ARXivarNextWebApiUrl, ApiKey = new Dictionary <string, string>() { { "Authorization", Request.Headers["Authorization"] } }, ApiKeyPrefix = new Dictionary <string, string>() { { "Authorization", "" } } }; var usersApi = new IO.Swagger.Api.UsersApi(arxivarRestConfiguration); var userInfo = usersApi.UsersGetUserInfo(); var userInfo_CompleteDescription = userInfo.CompleteDescription; var userInfo_CompleteName = userInfo.CompleteName; var userInfo_UserId = userInfo.User; ClaimsIdentity claims = (this.User.Identity as ClaimsIdentity); string userIdString = claims.FindFirst("arx:user_id").Value; int userIdNumber = System.Convert.ToInt32(userIdString); IO.Swagger.Model.UserInfoDTO userInfoDTO = usersApi.UsersGet(userIdNumber); EngineResult model; if (_cache.TryGetValue(id, out model)) { return(model); } var engineCount = _engineInfoService.GetCountById(id); if (engineCount == null) { return(StatusCode(404)); } if (engineCount.C < 1) { return(StatusCode(404, string.Format("Id '{0}' not found.", id))); } if (engineCount.C > 1) { return(StatusCode(403, string.Format("Id '{0}' found too many times {1}", id, engineCount.C))); } var engineInfo = _engineInfoService.GetDataById(id); if (engineInfo == null) { return(StatusCode(404)); } model = _engineCalculator.Calculate(id, engineInfo); _cache.Set(id, model, new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromMinutes(_appSettingsService.CacheMin))); return(model); } catch (Exception ex) { return(StatusCode(500, ex)); } }