public async Task <ActionResult <string> > Get([FromBody] GetParams prms) { var result = await _signInManager.PasswordSignInAsync(prms.login, prms.password, true, lockoutOnFailure : true); if (result.Succeeded) { var Claims = new [] { new Claim(JwtRegisteredClaimNames.Sub, prms.login), new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()) }; var signedKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(ApplicationData.Key)); var token = new JwtSecurityToken( issuer: "http://oec.com", audience: "http://oec.com", expires: DateTime.UtcNow.AddHours(1), claims: Claims, signingCredentials: new SigningCredentials(signedKey, SecurityAlgorithms.HmacSha256) ); return(Ok(new { token = new JwtSecurityTokenHandler().WriteToken(token), expiration = token.ValidTo })); } return(Unauthorized()); }
public async Task <ActionResult <string> > Get([FromBody] GetParams prms) { var user = new User { UserName = prms.login, Email = prms.login }; var result = await _userManager.CreateAsync(user, prms.password); if (result.Succeeded) { var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { userId = user.Id, code = code }, protocol: Request.Scheme); return(new OkResult()); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } // If we got this far, something failed, redisplay form return(new BadRequestResult()); }
/// <summary> /// Конструктор сам задает функцию по указанной точке Лагранжа. /// </summary> /// /// <param name="lagrangianPoint"> Точка Лагранжа.</param> /// <param name="basis"> Базис.</param> /// <param name="julianDate"> Юлианская дата.</param> /// <param name="connectorVector"> Вектор средства связи в системе координат этого ретрранслятора.</param> /// <param name="connectorBasis"> Базис средства связи в системе координат этого ретрранслятора.</param> /// <param name="view"> Область видимости средства связи.</param> /// <param name="id"> Идентификатор.</param> /// /// <exception cref="ArgumentNullException"> /// Вызывается при передаче null. /// </exception> public LagrangianRepeater(double julianDate, LagrangianPoint lagrangianPoint, string id, Basis basis, Vector connectorVector, Basis connectorBasis, View view) : base(UnitVector.UnitVectorX, basis, UnitVector.UnitVectorX) { switch (lagrangianPoint) { case LagrangianPoint.EM1: getParamsMethod += LagrangianPoints.GetEarthMoon1; referenceSystem = Planets.Earth; break; case LagrangianPoint.EM2: getParamsMethod += LagrangianPoints.GetEarthMoon2; referenceSystem = Planets.Earth; break; case LagrangianPoint.EM3: getParamsMethod += LagrangianPoints.GetEarthMoon3; referenceSystem = Planets.Earth; break; case LagrangianPoint.EM4: getParamsMethod += LagrangianPoints.GetEarthMoon4; referenceSystem = Planets.Earth; break; case LagrangianPoint.EM5: getParamsMethod += LagrangianPoints.GetEarthMoon5; referenceSystem = Planets.Earth; break; case LagrangianPoint.SE1: getParamsMethod += LagrangianPoints.GetSunEarth1; referenceSystem = Planets.Sun; break; case LagrangianPoint.SE2: getParamsMethod += LagrangianPoints.GetSunEarth2; referenceSystem = Planets.Sun; break; case LagrangianPoint.SE3: getParamsMethod += LagrangianPoints.GetSunEarth3; referenceSystem = Planets.Sun; break; case LagrangianPoint.SE4: getParamsMethod += LagrangianPoints.GetSunEarth4; referenceSystem = Planets.Sun; break; case LagrangianPoint.SE5: getParamsMethod += LagrangianPoints.GetSunEarth5; referenceSystem = Planets.Sun; break; } connector = new RepeaterConnector(id, connectorVector, connectorBasis, view, this); UpdateParams(julianDate); }
/// <summary> /// Конструктор сам задает функцию по указанной точке Лагранжа. /// </summary> /// /// <param name="lagrangianPoint"> Точка Лагранжа.</param> /// <param name="connector"> Средство связи.</param> /// <param name="basis"> Базис.</param> /// <param name="vector"> Координаты.</param> /// <param name="velocity"> Скорость.</param> /// /// <exception cref="ArgumentNullException"> /// Вызывается при передаче null. /// </exception> public LagrangianRepeater(LagrangianPoint lagrangianPoint, RepeaterConnector connector, Basis basis, Vector vector, Vector velocity) : base(connector, vector, basis, velocity, Planets.Sun) { switch (lagrangianPoint) { case LagrangianPoint.EM1: getParamsMethod += LagrangianPoints.GetEarthMoon1; referenceSystem = Planets.Earth; break; case LagrangianPoint.EM2: getParamsMethod += LagrangianPoints.GetEarthMoon2; referenceSystem = Planets.Earth; break; case LagrangianPoint.EM3: getParamsMethod += LagrangianPoints.GetEarthMoon3; referenceSystem = Planets.Earth; break; case LagrangianPoint.EM4: getParamsMethod += LagrangianPoints.GetEarthMoon4; referenceSystem = Planets.Earth; break; case LagrangianPoint.EM5: getParamsMethod += LagrangianPoints.GetEarthMoon5; referenceSystem = Planets.Earth; break; case LagrangianPoint.SE1: getParamsMethod += LagrangianPoints.GetSunEarth1; referenceSystem = Planets.Sun; break; case LagrangianPoint.SE2: getParamsMethod += LagrangianPoints.GetSunEarth2; referenceSystem = Planets.Sun; break; case LagrangianPoint.SE3: getParamsMethod += LagrangianPoints.GetSunEarth3; referenceSystem = Planets.Sun; break; case LagrangianPoint.SE4: getParamsMethod += LagrangianPoints.GetSunEarth4; referenceSystem = Planets.Sun; break; case LagrangianPoint.SE5: getParamsMethod += LagrangianPoints.GetSunEarth5; referenceSystem = Planets.Sun; break; } }
public NewsFeed Get(GetParams @params) { var parameters = new VkParameters { { "filters", @params.Filters }, { "return_banned", @params.ReturnBanned }, { "start_time", @params.StartTime }, { "end_time", @params.EndTime }, { "max_photos", @params.MaxPhotos }, { "source_ids", @params.SourceIds }, { "start_from", @params.StartFrom }, { "count", @params.Count }, { "fields", @params.Fields } }; var response = _vk.Call("newsfeed.get", parameters); var result = new NewsFeed { Items = response["items"].ToReadOnlyCollectionOf <NewsItem>(x => x), Profiles = response["profiles"].ToReadOnlyCollectionOf <User>(x => x), Groups = response["groups"].ToReadOnlyCollectionOf <Group>(x => x), NewOffset = response["new_offset"], NextFrom = response["next_from"] }; return(result); }
/// <summary> /// Конструктор. /// </summary> /// /// <param name="function"> Функция, определяющая координаты и скорость точки.</param> /// <param name="connector"> Средство связи.</param> /// <param name="basis"> Базис.</param> /// <param name="vector"> Координаты.</param> /// <param name="velocity"> Скорость.</param> /// <param name="centralBody"> Тело, в системе отсчета которого заданы координаты.</param> /// /// <exception cref="ArgumentNullException"> /// Вызывается при передаче null. /// </exception> public LagrangianRepeater(GetParams function, RepeaterConnector connector, Basis basis, Vector vector, Vector velocity, Body centralBody) : base(connector, vector, basis, velocity, centralBody) { if (function == null) { throw new ArgumentNullException("function mustn't be null"); } getParamsMethod += function; }
public IRestResponse Get(GetParams getParams) { if (getParams.Security) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; } var client = new RestClient(getParams.Url ?? _baseUrl); var request = new RestRequest(getParams.Resource, Method.GET); if (getParams.SimpleAuthentication != null) { client.Authenticator = new HttpBasicAuthenticator(getParams.SimpleAuthentication["username"], getParams.SimpleAuthentication["password"]); } else if (getParams.UseAuthentication && _authenticationModel != null) { if (_authenticationModel is BasicAuthentication basicAuth) { client.Authenticator = new HttpBasicAuthenticator(basicAuth.Username, basicAuth.Password); } else { throw new NotImplementedException(); } } if (getParams.Headers != null) { foreach (var(key, value) in getParams.Headers) { request.AddHeader(key, value); } } if (getParams.Cookies != null) { foreach (var(key, value) in getParams.Cookies) { request.AddCookie(key, value); } } if (getParams.Parameters != null) { foreach (var(key, value) in getParams.Parameters) { request.AddParameter(key, value, getParams.ParameterType); } } var response = client.Execute(request); return(response); }
/// <summary> /// Конструктор. /// </summary> /// /// <param name="function"> Функция, определяющая координаты и скорость точки.</param> /// <param name="basis"> Базис.</param> /// <param name="vector"> Координаты.</param> /// <param name="velocity"> Скорость.</param> /// <param name="referenceSystem"> Система координат, в которой задан ретранслятор.</param> /// <param name="connectorVector"> Вектор средства связи в системе координат этого ретрранслятора.</param> /// <param name="connectorBasis"> Базис средства связи в системе координат этого ретрранслятора.</param> /// <param name="view"> Область видимости средства связи.</param> /// <param name="id"> Идентификатор.</param> /// /// <exception cref="ArgumentNullException"> /// Вызывается при передаче null. /// </exception> public LagrangianRepeater(GetParams function, string id, Vector vector, Basis basis, Vector velocity, CoordinateSystem referenceSystem, Vector connectorVector, Basis connectorBasis, View view) : base(vector, basis, velocity, referenceSystem) { if (function == null) { throw new ArgumentNullException("function mustn't be null"); } getParamsMethod += function; connector = new RepeaterConnector(id, connectorVector, connectorBasis, view, this); }
protected async Task <HttpResponseMessage> Get(string endpoint, GetParams getParams = null, QueryParams queryParams = null, CancellationToken?token = null) { var response = await HttpClient.Get(endpoint, getParams, queryParams, token); if (NeedTokenRefresh(response)) { await RefreshToken(); response = await HttpClient.Get(endpoint, getParams, queryParams, token); } await CheckError(response); return(response); }
public ReadOnlyCollection <App> Get(out int totalCount, GetParams @params) { var parameters = new VkParameters { { "app_ids", @params.AppIds }, { "platform", @params.Platform }, { "extended", @params.Extended }, { "return_friends", @params.ReturnFriends }, { "fields", @params.Fields }, { "name_case", @params.NameCase } }; var result = _vk.Call("apps.get", parameters); totalCount = result["count"]; return(result["items"].ToReadOnlyCollectionOf <App>(x => x)); }
public object GetController(string controllerName) { Type type = _controllers.FirstOrDefault(m => m.Name.Equals(controllerName)); if (type == null) { throw new InvalidOperationException("未找到对应控制器"); } ConstructorInfo[] constructors = type.GetConstructors(); if (constructors.Length == 0) { throw new InvalidOperationException("控制器无法构建"); } ConstructorInfo constructor = null; var constructorParametersLength = 0; foreach (ConstructorInfo constructorInfo in constructors) { int length = constructorInfo.GetParameters().Length; if (length < constructorParametersLength) { continue; } constructor = constructorInfo; constructorParametersLength = length; } if (constructor == null) { throw new InvalidOperationException("控制器无法构建"); } ParameterInfo[] parameterInfos = constructor.GetParameters(); var parameters = new object[parameterInfos.Length]; for (var i = 0; i < parameterInfos.Length; i++) { parameters[i] = GetParams?.Invoke(parameterInfos[i].ParameterType); } object controller = Activator.CreateInstance(type, parameters); return(controller); }
public async Task <HttpResponseMessage> Get(string endpoint, GetParams getParams, QueryParams queryParams, CancellationToken?token = null) { try { bool paramExists; var url = new StringBuilder(GetUrl(endpoint, out paramExists)); SetParamString(url, paramExists, (getParams?.Parameters ?? new NameValuePair[0]).Concat(queryParams?.Parameters ?? new NameValuePair[0])); using (var request = CreateRequestMessage(HttpMethod.Get, url.ToString())) using (var tokenHelper = new CancellationTokenHelper(token, Timeout)) { return(await HttpClient.SendAsync(request, HttpCompletionOption.ResponseContentRead, tokenHelper.Token)); } } catch (BacklogException) { throw; } catch (Exception ex) { throw new BacklogApiException("backlog api request failed.", ex); } }
protected override void onLoad() { var productTxt = Document.GetElementById <InputElement>("productTxt"); productTxt.Focus(); var quantityTxt = Document.GetElementById <InputElement>("quantityTxt"); quantityTxt.Value = "0"; quantityTxt.OnChange = (ev) => { Quantity = int.Parse(quantityTxt.Value); }; var toDownBtn = Document.GetElementById <ButtonElement>("toDownBtn"); toDownBtn.OnClick = (ev) => { if (Quantity > 0) { Quantity--; quantityTxt.Value = Quantity.ToString(); } }; var toUpBtn = Document.GetElementById <ButtonElement>("toUpBtn"); toUpBtn.OnClick = (ev) => { Quantity++; quantityTxt.Value = Quantity.ToString(); }; var backBtn = Document.GetElementById <ButtonElement>("backBtn"); backBtn.OnClick = (ev) => { Navigation <Main> .Go(); }; var saveBtn = Document.GetElementById <ButtonElement>("saveBtn"); saveBtn.OnClick = (ev) => { var dynamodb = new DynamoDB(); var paramGet = new GetParams { TableName = "stock", Key = new { product = new DynamoItem { S = productTxt.Value } } }; dynamodb.getItem(paramGet, (errGet, dataGet) => { if (dataGet.Item == null) { var paramPut = new ItemParams { TableName = "stock", Item = new { product = new DynamoItem { S = productTxt.Value }, quantity = new DynamoItem { N = Quantity.ToString() } } }; dynamodb.putItem(paramPut, (errPut, dataPut) => { if (errPut != null) { Toast.Error("A Error ocorred on include the product!"); } else { productTxt.Value = String.Empty; quantityTxt.Value = "0"; Quantity = 0; productTxt.Focus(); Toast.Success("Sucess included product!"); } }); } else { Toast.Error("Product alredy exist!"); } }); }; }
public async Task <IActionResult> Get(GetParams getParams) { return(Ok( await mediator.Send( new FindProductPagedQuery(getParams.PageParams)))); }
public void getItem(GetParams param, Action <DynamoError, GetData> callback) { return; }
public void SendRequestSql(string rep, string fichier) { try { Dictionary <string, string> Natif = new Dictionary <string, string> (); FileInfo file = new FileInfo(rep); if (!file.Exists) { if (fichier.Contains("EXP_REPOS_DUS__AN_")) { string yearfile = getBetString(fichier, "__").Replace("AN", "").Replace("_", ""); Natif.Add("%yearfile%", yearfile); if (!File.Exists(rep)) { query = "FICHIER SQL GESTIME MANQUANT OU MAUVAIS CHEMIN !"; return; } } else { query = "FICHIER SQL MANQUANT OU MAUVAIS CHEMIN !"; return; } } string strscript = getrequete(rep); //Les natifs de l'automate Natif.Add("%pathfile%", automateDRH.Properties.Settings.Default.traitementPath + @"\\" + fichier); Natif.Add("%yearnow%", DateTime.Now.Year.ToString()); foreach (KeyValuePair <string, string> item in Natif) { strscript = strscript.Replace(item.Key, item.Value); } string[] stringSeparators = new string[] { "\r\n" }; foreach (string GetParams in strscript.Split(stringSeparators, StringSplitOptions.None)) { if (GetParams.Contains("%")) { string getFichier = ""; bool checkgetfichier = false; string key = getBetString(GetParams, "%"); string value = getBetString(GetParams, "(", ")").Replace(" ", ""); if (value != "") { foreach (string getParamsInFile in value.Split(',')) { string[] splitparams = getParamsInFile.Split(':'); if (splitparams.Length == 3) { splitparams[1] = getBetString(getParamsInFile, "\""); } if (splitparams[0] == "file") { if (File.Exists(splitparams[1])) { getFichier = getrequete(splitparams[1]); checkgetfichier = true; } else { query = "Le fichier du parametre 'file' n'est pas correcte !"; return; } } else { if (!checkgetfichier) { query = "Il manque le parametre 'file' !"; return; } getFichier = getFichier.Replace(splitparams[0], splitparams[1].Replace("\"", "")); } } getFichier = getFichier.Replace("%", ""); } strscript = strscript.Replace(GetParams, getFichier); } } MySqlCommand cmd = new MySqlCommand(strscript, conn); cmd.CommandType = CommandType.Text; cmd.CommandTimeout = 0; cmd.ExecuteNonQuery(); query = "OK"; } catch (MySqlException ex) { query = ex.Message; } catch (Exception e) { query = e.Message; } }
public void ListenForConnections() { MonitorThread.Start(); Console.WriteLine("Listening"); while (RunServer) { HttpListenerContext ctx = Listener.GetContext(); HttpListenerRequest req = ctx.Request; HttpListenerResponse rsp = ctx.Response; if (req.HttpMethod == "GET") { string DictionaryKey = UrlParseUtils.ParseUntil(req.Url.ToString(), '?').Replace(ServerLocationNoPort, "").Replace(ReplacingUrl, ""); string GetString = ""; try { GetString = req.Url.ToString().Replace(UrlParseUtils.ParseUntil(req.Url.ToString(), '?'), "").Remove(0, 1); }catch { //No Get Params Given } byte[] Response = new byte[0]; try { Func <Params, MySqlCtx, byte[]> HandleFunction = Routes.RouteList[DictionaryKey].Handle; Response = HandleFunction(new Params(GetParams.GetGetParamsFromString(GetString)), MySqlConnectionData); } catch { //No Route Response = Encoding.UTF8.GetBytes("404"); } rsp.OutputStream.Write(Response, 0, Response.Length); rsp.Close(); } else if (req.HttpMethod == "POST") { string DictionaryKey = UrlParseUtils.ParseUntil(req.Url.ToString(), '?').Replace(ServerLocationNoPort, "").Replace(ReplacingUrl, ""); string GetString = ""; try { GetString = req.Url.ToString().Replace(UrlParseUtils.ParseUntil(req.Url.ToString(), '?'), "").Remove(0, 1); } catch { //No Get Params Given } byte[] Response = new byte[0]; try { Func <Params, MySqlCtx, byte[]> HandleFunction = Routes.RouteList[DictionaryKey].Handle; byte[] BinaryPostData; using (MemoryStream ms = new MemoryStream()) { req.InputStream.CopyTo(ms); BinaryPostData = ms.ToArray(); } Response = HandleFunction(new Params(GetParams.GetGetParamsFromString(GetString), BinaryPostData), MySqlConnectionData); } catch (Exception e) { Console.WriteLine(e.Message); Response = Encoding.UTF8.GetBytes("404"); } rsp.OutputStream.Write(Response, 0, Response.Length); rsp.Close(); } } MonitorThread.Join(); }
public async Task <IActionResult> Get(GetParams getParams) { return(Ok(await mediator.Send( new FindStoresByChainIdQuery(getParams.ChainId, getParams.PageParams)))); }