public void Unregister(List <Instance> instances) { try { Preconditions.CheckArgument(!Conditions.IsNullOrEmpty(instances), "instances"); UnregisterRequest request = new UnregisterRequest() { Instances = instances }; UnregisterRespnse response = this.Request <UnregisterRespnse>(RestPaths.REGISTRY_UNREGISTER_FULL_PATH, request); if (response.ResponseStatus.IsFail()) { _log.Error("unregister instances failed. Response:" + response.ToJson()); } else if (response.ResponseStatus.isPartialFail()) { _log.Warn("unregister instances patial failed. Response:" + response.ToJson()); } LogEvent(response.ResponseStatus, "registry", "unregister"); } catch (Exception e) { _log.Warn("unregister instances failed", e); LogEvent("registry", "unregister"); } }
public UnregisterResponse Unregister(UnregisterRequest request) { lock (_lock) { var registrationKey = $"{request.PodAddress}:{request.PodPort}"; var currentRoutes = _registrations.GetValueOrDefault(registrationKey, null)?.Routes; if (currentRoutes?.Any() == true) { _snapshot = _snapshot.With(request.PodAddress, request.PodPort, new List <string>(), currentRoutes); _cache.SetSnapshot(_snapshot); _registrations.Remove(registrationKey); return(new UnregisterResponse { Unregistered = true }); } return(new UnregisterResponse { Unregistered = false }); } }
public async Task <IActionResult> Unregister(UnregisterRequest request) { // 1) Faz o login para garantir que a senha está correta var email = GetCurrentEmail(); var signResult = await _signInManager.PasswordSignInAsync(email, request.Password, false, lockoutOnFailure : false); if (!signResult.Succeeded) { new ModelStateBuilder <UnregisterRequest>(this) .SetFieldError(f => f.Password, ProblemDetailsFieldType.PasswordMismatch); return(this.BadRequest()); } // 2) Recupera o usuário logado var user = await this.GetCurrentUser(); if (user == null) { this.SetUserNotFound(); return(this.NotFound()); } // 3) Deleta o usuário var identityResult = await _userManager.DeleteAsync(user); if (!identityResult.Succeeded) { new ModelStateBuilder <UnregisterRequest>(this); return(this.BadRequest()); } return(Ok()); }
public IHttpActionResult Unregister([FromBody] UnregisterRequest obj) { try { ClienteController clientCore = new ClienteController(); // Verify at least object arrives with data if (obj == null) { throw new NotEnoughAttributesException("No se ha recibido ningún parámetro"); } // Verify for parameters needed // password is optional if (obj.idChannel == null || obj.idProduct == null || obj.value == null) { throw new NotEnoughAttributesException("No se han recibido todos los parámetros requeridos"); } // Check params's integrity if (obj.idChannel.GetType() != typeof(int) || obj.idProduct.GetType() != typeof(int) || obj.value.GetType() != typeof(string)) { throw new NotValidDataException("Los tipos de datos no coinciden"); } // Call core ActionResponse action = clientCore.UnregisterAction(obj); if (action.code == (int)CodeStatusEnum.OK) { return(ResponseOk(action.data)); } // OK else { return(ResponseError(action.code, action.message)); } // NOK } catch (NotValidDataException e) { logger.Error(e.Message); return(ResponseError((int)CodeStatusEnum.BAD_REQUEST, e.Message)); } catch (NotEnoughAttributesException e) { logger.Error(e.Message); return(ResponseError((int)CodeStatusEnum.BAD_REQUEST, e.Message)); } catch (Exception ex) { logger.Fatal(ex.Message); return(ResponseError((int)CodeStatusEnum.INTERNAL_ERROR, "Error desconocido en el sistema")); } }
public async ValueTask ExecuteAsync(UnregisterSessionCommand command) { var loginInfo = new UnregisterRequest { SessionId = command.SessionId }; await m_MessageQueueService.RequestAsync( "session.unregister", loginInfo.ToByteArray()).ConfigureAwait(false); }
private Task Unregister(long registrationId) { UnregisterRequest unregisterRequest = new UnregisterRequest(mFormatter); long requestId = mPendingUnregistrations.Add(unregisterRequest); unregisterRequest.RequestId = requestId; mProxy.Unregister(requestId, registrationId); return(unregisterRequest.Task); }
/// <summary> /// Unsubscribe from pushes at pushwoosh server /// </summary> public void UnsubscribeFromPushes(EventHandler <string> success, EventHandler <string> failure) { if (_notificationChannel != null) { _notificationChannel.Close(); _notificationChannel = null; } PushToken = ""; UnregisterRequest request = new UnregisterRequest { AppId = AppID }; PushwooshAPIServiceBase.InternalSendRequestAsync(request, (obj, arg) => { if (success != null) { success(this, null); } }, failure); }
public override Task <Null> Unregister(UnregisterRequest request, ServerCallContext context) { Server removed; lock (servers) { var i = servers.FindIndex((s) => (request.ServerId == s.ServerId)); if (i < 0) { logger.LogWarning($"the server is not registered. serverId: {request.ServerId}"); return(Task.FromResult(new Null())); } removed = servers[i]; servers.RemoveAt(i); } OnServerRemove(removed); return(Task.FromResult(new Null())); }
/// <summary> /// Will desactive user credential (user identify + product) /// </summary> /// <param name="obj">Unregister request object (idProduct, idChannel, value)</param> /// <returns></returns> public ActionResponse UnregisterAction(UnregisterRequest obj) { try { int idProduct = obj.idProduct.Value; int idChannel = obj.idChannel.Value; string value = obj.value; // effective value for user identify string password = obj.password; // STEP 0: Need to verify if product and channel exist or not ProductData prodData = new ProductData(); Product oProduct = prodData.GetProductById(obj.idProduct.Value); if (oProduct == null) { return(functions.Response((int)CodeStatusEnum.NO_CONTENT, "El producto no existe en el sistema", null)); } ChannelData channelData = new ChannelData(); Channel oChannel = channelData.GetChannelById(obj.idChannel.Value); if (oChannel == null) { return(functions.Response((int)CodeStatusEnum.NO_CONTENT, "El canal no existe en el sistema", null)); } // STEP 1: Check if user identify already exists by id_cliente + channel + value UserIdentifyData uiData = new UserIdentifyData(); UserIdentify ui = uiData.FindByIdChannelAndValue(idChannel, value); if (ui.idUserIdentify == null) { return(functions.Response((int)CodeStatusEnum.NO_CONTENT, "La identidad del usuario no existe en el sistema", null)); } // STEP 2: Check credentials string passwordAsMD5 = null; if (password != null) { using (MD5 md5Hash = MD5.Create()) { passwordAsMD5 = functions.GetMd5Hash(md5Hash, password.Trim()); } } CredentialData credData = new CredentialData(); Credential oCredential = credData.FindByProductAndUserIdentifyAndPass(idProduct, ui.idUserIdentify.Value, passwordAsMD5); if (oCredential.idCredential == null) { return(functions.Response((int)CodeStatusEnum.NO_CONTENT, "No existe ninguna credencial con los datos proporcionados", null)); } // STEP 3: If Credential is OK, will use same method passing actual password, the idea is use it for updating // the state to INACTIVE, it's not neccesary to make another method int idCredential = oCredential.idCredential.Value; bool updCredential = credData.UpdatePassword(idCredential, passwordAsMD5, (int)StateEnum.INACTIVE); if (!updCredential) { return(functions.Response((int)CodeStatusEnum.INTERNAL_ERROR, "No se pudo actualizar el estado de la credencial", null)); } // OK, return true/false UnregisterResponse response = new UnregisterResponse(); response.updated = DateTime.Now; return(functions.Response((int)CodeStatusEnum.OK, "OK", response)); } catch (Exception e) { logger.Fatal(e.Message); return(functions.Response((int)CodeStatusEnum.INTERNAL_ERROR, e.Message, null)); } }
public IActionResult Unregister(Guid id, UnregisterRequest unregisterRequest) { var result = _dispatcher.Dispatch(new UnregisterUserCommand(id, unregisterRequest.By, unregisterRequest.Reason)); return(FromResult(result)); }
public Task <UnregisterResponse> Unregister(UnregisterRequest request) { return(Task.FromResult(_service.Unregister(request))); }