private async void Login_Click(object sender, RoutedEventArgs e) { if (await ApiMethods.AuthenticateUser(txtUsername.Text, txtPassword.Password)) { Frame.Navigate(typeof(MainNavigation)); } }
/* Win32 API helper methods */ public static void CloseHandle(IntPtr handle) { if (handle != IntPtr.Zero) { ApiMethods.CloseHandle(handle); } }
public void Version40Test() { var sdk = new ApiMethods(Auth(), "4.0"); var agentTag = $"{Constants.AgentPrefix} {Constants.LookerVersion}.4.0"; Assert.Equal(agentTag, sdk.AuthSession.Settings.AgentTag); }
public async void GetCountryCovidData(CountryDto countryDto) { var results = await ApiMethods.GetCountryCovidData(countryDto); CountryCovidResults = new ObservableCollection <CountryCovidResult>(results); InitializeChart(); }
public async Task LoadNameInfo_Maks_NotEqual() { // Arrange string name = "Maks"; int expectedAge = 20; string[] expectedGender = { "female", "0,88" }; ConfigUtils.Initialize(); ApiHelper.Initialize(); // Act int actualAge = await ApiMethods.LoadNameAge(name). ConfigureAwait(false); string[] actualGender = await ApiMethods.LoadNameGender(name). ConfigureAwait(false); // Assert Assert.AreNotEqual(expectedAge, actualAge); for (int i = 0; i < actualGender.Length; i++) { Assert.AreNotEqual(expectedGender[i], actualGender[i]); } }
static void Main(string[] args) { ApiMethods apiMethods = new ApiMethods(); var distance = apiMethods.GetDrivingDistanceInKilometers("Kiev", "Moscow"); Console.WriteLine(distance); DateTime StartEventTime = new DateTime(2016, 01, 22, 12, 00, 00); DateTime EndEventTime = new DateTime(2016, 01, 22, 15, 01, 00); Events events = apiMethods.GetEventsFromCalendar(StartEventTime, EndEventTime); if (events.Items.Count == 0) { Console.WriteLine("No events found"); } else { Console.WriteLine("Events overlap. Event start: {0}", events.Items[0].Start.DateTime.Value.ToString()); TimeSpan a = EndEventTime - events.Items[0].Start.DateTime.Value; StartEventTime.Subtract(a); EndEventTime.Subtract(a); Events events2 = apiMethods.GetEventsFromCalendar(StartEventTime, EndEventTime); } Console.ReadKey(); }
public async Task <string> TryLogin(string login = "", string password = "") { LoginResponseBase baseauth = await ApiMethods.GetLoginBase(HttpContext.Session.GetString("Token")); if (!String.IsNullOrEmpty(baseauth.link)) { HttpContext.Session.SetString("BasePath", baseauth.link); LoginResponse auth = await ApiMethods.Login(HttpContext.Session.GetString("BasePath"), login, password); if (!String.IsNullOrEmpty(auth.SessionId)) { HttpContext.Session.SetString("SessionID", auth.SessionId); HttpContext.Session.SetString("ICN", auth.ICN); return("Success"); } else { CleanSessionParams(); return("BadLogin"); } } else { //return false; return("BadToken"); } }
public async void GetCountries() { var countries = await ApiMethods.GetAllCountries(); Countries = new ObservableCollection <CountryDto>(countries.OrderBy(c => c.Country)); GetCountryCovidData(countries.FirstOrDefault(c => c.Country == Trip.Country)); }
static void CompletionPortListener(Object o) { var hIOCP = (IntPtr)o; uint msgIdentifier; IntPtr pCompletionKey, lpOverlapped; while (ApiMethods.GetQueuedCompletionStatus(hIOCP, out msgIdentifier, out pCompletionKey, out lpOverlapped, ApiMethods.INFINITE)) { if (msgIdentifier == (uint)JobMsgInfoMessages.JOB_OBJECT_MSG_NEW_PROCESS) { Console.WriteLine("{0}: process {1} has started", msgIdentifier, (int)lpOverlapped); } else if (msgIdentifier == (uint)JobMsgInfoMessages.JOB_OBJECT_MSG_EXIT_PROCESS) { Console.WriteLine("{0}: process {1} exited", msgIdentifier, (int)lpOverlapped); } else if (msgIdentifier == (uint)JobMsgInfoMessages.JOB_OBJECT_MSG_ACTIVE_PROCESS_ZERO) { // nothing } else if (msgIdentifier == (uint)JobMsgInfoMessages.JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT) { Console.WriteLine("{0}: process {1} exceeded its memory limit", msgIdentifier, (int)lpOverlapped); } else { Console.WriteLine("Unknown message: {0}", msgIdentifier); } } }
private dynamic JsonPostRequest(ApiMethods methodName, JObject jsonPostData) { string error; var methodNameStr = Char.ToLowerInvariant(methodName.ToString()[0]) + methodName.ToString().Substring(1); dynamic data = HttpHelper.Post( new Uri(Scheme + "://" + Host + "/" + methodNameStr), JsonConvert.SerializeObject(jsonPostData, Formatting.Indented), out error ); if (String.IsNullOrEmpty(error)) { if (data == null) { error = "Got empty or invalid response from API"; } else { return(data); } } else { error = "HTTP or JSON error: " + error; } throw new Exception(error); }
public void GetAllCategoriesWithIdJSON() { if (ApiMethods.IsApiAuthRequest()) { var js = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue }; var category = new Category(); var allCategory = category.GetAllItems(); var allCategoryList = new List <AllCategoryWithIdResult>(); foreach (DataRow row in allCategory.Tables[0].Rows) { allCategoryList.Add(new AllCategoryWithIdResult() { id = row["ID"].ToString(), name = row["Name"].ToString().Trim() }); Context.Response.ContentType = "application/json; charset=UTF-8"; var responceBody = js.Serialize(allCategoryList); Context.Response.Write(responceBody); ApiMethods.LoggingRequest("GetAllCategoriesWithIdJSON", "GoodsAPI", "PublicAPI", null, responceBody.Length, Convert.ToInt32(HttpContext.Current.Request.Params["userid"]), HttpContext.Current.Request.Params["apikey"]); } } else { ApiMethods.ReturnNotAuth(); } }
public IActionResult CreateGame(CreateGameModel model) { // Create game model.GameId = ApiMethods.CreateGame(client); logger.LogInformation("User created a new game."); // Add all players that aren't null to the game. if (model.Player1Name != null) { ApiMethods.AddPlayer(model.GameId, model.Player1Name, "0", client); logger.LogInformation($"User added player: {model.Player1Name}"); } if (model.Player2Name != null) { ApiMethods.AddPlayer(model.GameId, model.Player2Name, "1", client); logger.LogInformation($"User added player: {model.Player2Name}"); } if (model.Player3Name != null) { ApiMethods.AddPlayer(model.GameId, model.Player3Name, "2", client); logger.LogInformation($"User added player: {model.Player3Name}"); } if (model.Player4Name != null) { ApiMethods.AddPlayer(model.GameId, model.Player4Name, "3", client); logger.LogInformation($"User added player: {model.Player4Name}"); } // Set cookies ApiMethods.AssignPlayerCookies(model, Response); return(RedirectToAction("Lobby")); }
public void UpdateItem(ItemDto item, Boolean increase) { var index = Items.IndexOf(item); var category = Categories.Where(i => i.Id == item.CategoryId).FirstOrDefault(); Items[index] = item; Items[index].Category = category; if (increase) { if (item.PackedCount < item.Count) { item.PackedCount++; total_packed++; item.Completed = item.PackedCount >= item.Count; if (item.Completed && CompletedFilter) { Items.Remove(item); } ApiMethods.UpdateItem(item); } } else { if (item.PackedCount > 0) { item.PackedCount--; total_packed--; item.Completed = item.PackedCount >= item.Count; ApiMethods.UpdateItem(item); } } }
public bool ContainsApiName(LolApiName name, LolApiMethodName method) { bool q1 = ApiMethods.Contains(method); bool q2 = Names.Contains(name); return(q1 && q2); }
public async void GetCountryCovidData(CountryDto countryDto) { ChartTitle = "Current Covid-19 situation in " + countryDto.Country; DateLabel = Trip.StartDate.ToString("M") + " " + Trip.StartDate.ToString("yyyy") + " - " + Trip.EndDate.ToString("M") + " " + Trip.EndDate.ToString("yyyy"); var results = await ApiMethods.GetCountryCovidData(countryDto); CountryCovidResults = new ObservableCollection <CountryCovidResult>(results); InitializeChart(); }
public List <AllProfileResult> GetProfilesXML(string email, string password) { if (ApiMethods.IsApiAuthRequest()) { var js = new JavaScriptSerializer { MaxJsonLength = Int32.MaxValue }; var allCityList = new List <AllProfileResult>(); var user = new Users { Email = email }; user.GetByEmail(); if (user.Password != OtherMethods.HashPassword(password)) { allCityList.Add(new AllProfileResult { Name = "Ошибка", ID = "Такой комбинации логина и пароля не найдено!" }); } else { var profiles = new UsersProfiles { UserID = user.ID }; var allProfilesDS = profiles.GetAllItems(); foreach (DataRow row in allProfilesDS.Tables[0].Rows) { string fioOrCompanyName; if (String.IsNullOrEmpty(row["CompanyName"].ToString())) { fioOrCompanyName = row["FirstName"] + " " + row["LastName"]; } else { fioOrCompanyName = row["CompanyName"].ToString(); } var iDPlusType = row["TypeID"].ToString() + row["ID"]; allCityList.Add(new AllProfileResult { Name = fioOrCompanyName, ID = iDPlusType }); } } var responceBody = js.Serialize(allCityList); ApiMethods.LoggingRequest("GetProfilesXML", "UserProileAPI", "UserAPI", null, responceBody.Length, Convert.ToInt32(HttpContext.Current.Request.Params["userid"]), HttpContext.Current.Request.Params["apikey"]); return(allCityList); } return(null); }
static PROCESS_INFORMATION StartSuspendedProcess(IList <String> procargs) { PROCESS_INFORMATION pi; STARTUPINFO si = new STARTUPINFO(); CheckResult(ApiMethods.CreateProcess(null, String.Join(" ", procargs), IntPtr.Zero, IntPtr.Zero, false, CreateProcessFlags.CREATE_SUSPENDED | CreateProcessFlags.CREATE_NEW_CONSOLE, IntPtr.Zero, null, ref si, out pi)); return(pi); }
public async Task GetHtmlUrlTest() { var sdk = new ApiMethods(Auth(), "4.0"); var actual = await sdk.Ok(sdk.AuthRequest <string, Exception>( HttpMethod.Get, _config.HtmlTestUrl )); Assert.Contains(_config.HtmlTestContent, actual); }
public async Task <string> PrintInvoices(string[] ExtNumbers) { GetInvoiceResponse GetInvoiceResponse = await ApiMethods.GetInvoice(HttpContext.Session.GetString("BasePath"), HttpContext.Session.GetString("SessionID"), HttpContext.Session.GetString("ICN"), ExtNumbers); return(GetInvoiceResponse.Invoice); }
private async void Register_Click(object sender, RoutedEventArgs e) { if (txtPassword.Password.Equals(txtPasswordConfirmation.Password)) { if (await ApiMethods.RegisterUser(txtUsername.Text, txtEmail.Text, txtPassword.Password)) { Frame.Navigate(typeof(Login)); } } }
/// <summary> /// 异步禁言当前 <see cref="Member"/> 实例 /// </summary> /// <param name="time">禁言时长</param> public async Task MuteAsync(TimeSpan time) { if (time.TotalSeconds <= 0 || time > TimeSpan.FromDays(30)) { throw new ArgumentOutOfRangeException(nameof(time)); } else { (await ApiMethods.MuteAsync(Session.Settings.HttpUri, Session.SessionKey, Group.Number, Number, (int)time.TotalSeconds)).CheckError(); } }
/// <summary> /// 异步获取当前 <see cref="CurrentUser"/> 实例的群额外信息 /// </summary> private async Task <List <Group> > GetGroupExtInfoAsync() { foreach (var group in GroupList) { var info = await ApiMethods.GetGroupConfigAsync(Session.Settings.HttpUri, Session.SessionKey, group.Number); group.GroupExtInfo = GetGroupExtInfoFromJson(info); } return(GroupList); }
public async void DeleteToDo(TodoDto todo) { if (todo.Completed) { total_finished--; } total_todos--; Todos.Remove(todo); await ApiMethods.DeleteToDo(todo); }
public IActionResult Index() { var viewModel = new TokenViewModel(); var apiMethods = new ApiMethods(); var token = apiMethods.RetornaToken(); viewModel.Token = token.Token; viewModel.User = token.User; return(View(viewModel)); }
public async Task <ActionResult> DetailsInfo(string number) { try { return(base.PartialView("/Views/Delans/Details.cshtml", await ApiMethods.GetStatusOfInvoice(HttpContext.Session.GetString("BasePath"), HttpContext.Session.GetString("SessionID"), HttpContext.Session.GetString("ICN"), number))); } catch { return(BadRequest()); } }
/// <summary> /// 异步获取 <see cref="Message"/> 实例 /// </summary> /// <param name="currentUser">指定获取 <see cref="Message"/> 实例的当前用户</param> /// <param name="id">指定获取 <see cref="Message"/> 实例的 ID</param> /// <returns>指定的当前用户和 ID 的 <see cref="Message"/> 实例</returns> public static async Task <Message> GetMessageAsync(CurrentUser currentUser, int id) { currentUser = currentUser ?? throw new ArgumentNullException(nameof(currentUser)); var session = currentUser.Session; var result = (await ApiMethods.GetMessageAsync(session.Settings.HttpUri, session.SessionKey, id)).CheckError(); var data = JObject.Parse(result)["data"].ToObject <MessageData>(); var parser = MessageParser.GetParser(currentUser, data); return(await ToMessageAsync(session, parser, data.MessageChain)); }
public async void GetTrips() { var trips = await ApiMethods.GetTrips(); trips.ForEach(t => { if ("".Equals(t.Country)) { t.Country = "Travel"; } }); Trips = new ObservableCollection <TripDto>(trips); }
/// <summary> /// 异步获取当前 <see cref="Group"/> 实例的成员信息 /// </summary> private async Task <List <Member> > GetMemberExtInfoAsync() { foreach (var member in MemberList) { var info = await ApiMethods.GetMemberInfoAsync(Session.Settings.HttpUri, Session.SessionKey, Number, member.Number); member.MemberExtInfo = GetMemberExtInfoFromJson(info); } return(MemberList); }
public IActionResult Index() { var apiMethods = new ApiMethods(); var devs = apiMethods.RetornaDevs(); var retorno = devs.Select(x => new DevsViewModel() { Id = x.Id, Nome = x.Nome }); return(View(retorno)); }
public IActionResult Index() { var apiMethods = new ApiMethods(); var projetos = apiMethods.RetornaProjetos(); var retorno = projetos.Select(x => new ProjetoViewModel() { Id = x.Id, Nome = x.Nome }); return(View(retorno)); }