private void createSession() { byte[] emptyBody = Serial.toBSON(new { }); StartCoroutine(HTTPHelpers.post(url + "/api/v1/sessions?bson=true", emptyBody, store.accessToken, (data) => { sessionInfo.gameObject.SetActive(true); sessionBackground.gameObject.SetActive(true); openingInfo.gameObject.SetActive(false); loadingCircle.gameObject.SetActive(false); nameTitle.gameObject.SetActive(true); nameInput.gameObject.SetActive(true); try { SessionData responce = Serial.fromBSON <SessionData>(data); sessionInfo.text = sessionInfoSave + responce.id; sessionID = responce.id; start.gameObject.SetActive(true); } catch (Exception e) { showError(e.ToString()); } }, (error) => { showError(error); }) ); }
public ActionResult AddShopCart(int id) { ProductsModel product = new ProductsModel(); if (Session["Cart"] == null) { var cust = (CustomersModel)Session["Login"]; List <ItemonCartModel> cart = new List <ItemonCartModel>(); cart.Add(new ItemonCartModel { Product = HTTPHelpers.GetMethod <ProductsModel>("http://localhost:37796/", "Products/GetProductDetail", RestSharp.Method.GET, id), Quantity = 1, CustomerID = cust.CustomerID }); Session["Cart"] = cart; } else { List <ItemonCartModel> cart = (List <ItemonCartModel>)Session["Cart"]; int index = cart.FindIndex(a => a.Product.ProductID == id); if (index != -1) { cart[index].Quantity++; } else { cart.Add(new ItemonCartModel { Product = HTTPHelpers.GetMethod <ProductsModel>("http://localhost:37796/", "Products/GetProductDetail", RestSharp.Method.GET, id), Quantity = 1 }); } Session["Cart"] = cart; } return(RedirectToRoute(new { controller = "Products", action = "GetProducts" })); }
public async Task <string> GetXivDB(string name, string world, bool api) { if (api == true) { var url = new Uri($"https://api.xivdb.com/search?one=characters&string={name}&pretty=1"); var client = HTTPHelpers.NewClient(); string responseBody = await client.GetStringAsync(url); var xivdbCharacters = JsonConvert.DeserializeObject <CharacterSearch>(responseBody); var results = from charResult in xivdbCharacters.characters.results where charResult.name.ToLower() == name.ToLower() && charResult.server == world select charResult; string playerLink = ""; if (results.Count() > 0) { playerLink = results.First().url_api; } else { return("!@invalid"); } return(playerLink); } else { var url = new Uri($"https://api.xivdb.com/search?one=characters&string={name}&pretty=1"); //https://api.xivdb.com/search?one=characters&string=knightin_Rustyarmour&pretty=1 var client = HTTPHelpers.NewClient(); //http://api.xivdb.com/character/6248857/knightin+rustyarmour/excalibur string responseBody = await client.GetStringAsync(url); var xivdbCharacters = JsonConvert.DeserializeObject <CharacterSearch>(responseBody); var results = from charResult in xivdbCharacters.characters.results where charResult.name.ToLower() == name.ToLower() && charResult.server == world select charResult; string playerLink = ""; if (results.Count() > 0) { playerLink = results.First().url_xivdb; } else { return("!@invalid"); } return(playerLink); } }
public ActionResult PutOrders() { var cart = (List <ItemonCartModel>)Session["Cart"]; HTTPHelpers.PostMethod("http://localhost:37776/", "Orders/PutOrder", RestSharp.Method.PUT, cart); Session.Remove("Cart"); return(RedirectToRoute(new { controller = "Orders", action = "GetCutomerOrder" })); }
public static int GetSecondsByCar(Coordinates origin, Coordinates dest, int secondsWithoutCar, string API_KEY) { string json = HTTPHelpers.SynchronizedRequest("GET", $"https://maps.googleapis.com/maps/api/directions/json" + $"?origin={origin.Lat},{origin.Lng}&destination={dest.Lat},{dest.Lng}&mode=driving&key={API_KEY}&language=en-US"); JObject jObj = JObject.Parse(json); int secondsByCar = Convert.ToInt32(jObj["routes"].First["legs"].First["duration"]["value"].ToString()); return(secondsByCar); }
public ActionResult GetCutomerOrder(string id) { if ((string)Session["UserType"] == "Customer") { var c = (CustomersModel)Session["Login"]; id = c.CustomerID; } var order = HTTPHelpers.GetMethod <List <OrdersModel> >("http://localhost:37776/", "Orders/GetCustomerOrders", RestSharp.Method.GET, id); return(View(order)); }
private IEnumerator deleteSession() { return(HTTPHelpers.delete(url + sessionPath + id, store.accessToken, () => { Debug.Log("Finished cleanup, exiting for you."); quit(); }, (error) => { Debug.Log(error); })); }
// GET: Logins public ActionResult CustomersLogin(CustomersModel customer) { var cust = HTTPHelpers.LoginMethod <CustomersModel>("http://localhost:37796/", "Login/CustomersLogin", RestSharp.Method.POST, customer); if (cust != null) { Session["Login"] = cust; Session["UserType"] = "Customer"; return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("LoginHata")); } }
public ActionResult EmployeesLogin(EmployeeModel employee) { var emp = HTTPHelpers.LoginMethod <EmployeeModel>("http://localhost:37796/", "Login/EmployeeLogin", RestSharp.Method.POST, employee); if (emp != null) { Session["Login"] = emp; Session["UserType"] = "Employee"; return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("LoginHata")); } }
private void serializeCaptures(object data) { if (sendToConsole && !isSilent) { if (pairs.Length != 0) { Debug.Log(JsonConvert.SerializeObject(data)); } else { Debug.Log(JsonConvert.SerializeObject(data, Formatting.Indented)); } return; } byte[] bson = Serial.toBSON(data); openRequests++; float start = Time.realtimeSinceStartup; string requestPath = url + sessionPath + id + "?bson=true"; StartCoroutine(HTTPHelpers.post(requestPath, bson, store.accessToken, (responceData) => { openRequests--; responceCount++; float responceTime = Time.realtimeSinceStartup - start; averageResponceTime = (averageResponceTime * responceCount + responceTime) / (responceCount + 1); averageOpenRequests = (averageOpenRequests * responceCount + openRequests) / (responceCount + 1); minOpenRequests.Include(openRequests); maxOpenRequests.Include(openRequests); minResponceTime.Include(responceTime); maxResponceTime.Include(responceTime); }, (error) => { openRequests--; Debug.Log(error); }) ); }
private void onLoginClick() { urlTitle.gameObject.SetActive(false); urlInput.gameObject.SetActive(false); warningInfo.gameObject.SetActive(false); newSession.gameObject.SetActive(false); connectionInfo.gameObject.SetActive(true); loadingCircle.gameObject.SetActive(true); // Content of the body is ignored byte[] emptyBody = Serial.toBSON(new { }); url = urlInput.text.Trim('/'); StartCoroutine(HTTPHelpers.post(url + "/api/v1/authentication/claims?bson=true", emptyBody, string.Empty, (data) => { openingInfo.gameObject.SetActive(true); connectionInfo.gameObject.SetActive(false); try { ClaimData responce = Serial.fromBSON <ClaimData>(data); StartCoroutine(WaitThenOpen(responce)); } catch (Exception e) { sessionInfo.text = "Error deserializing BSON response: " + e; Debug.Log(e); newSession.gameObject.SetActive(true); } }, (error) => { showError(error); }) ); }
private void pollClaim(string claimToken) { StartCoroutine(HTTPHelpers.pollGet(url + "/api/v1/authentication/claims?bson=true", claimToken, (data) => { try { AccessData responce = Serial.fromBSON <AccessData>(data); store = new SecretStorage(responce.accessToken); createSession(); } catch (Exception e) { sessionInfo.text = "Error deserializing BSON response: " + e; Debug.Log(e); newSession.gameObject.SetActive(true); } }, (error) => { showError(error); }) ); }
public ActionResult UpdateProduct(int id) { var product = HTTPHelpers.GetMethod <ProductsModel>("http://localhost:37796/", "Products/GetProductDetail", RestSharp.Method.GET, id); return(View(product)); }
public ActionResult DeleteProduct(int id) { HTTPHelpers.DeleteMethod("http://localhost:37786/", "Products/DeleteProduct", RestSharp.Method.DELETE, id); return(RedirectToAction("GetProducts")); }
public ActionResult PostProduct(ProductsModel product) { HTTPHelpers.PostMethod("http://localhost:37786/", "Products/PostProduct", RestSharp.Method.POST, product); return(RedirectToRoute(new { controller = "Products", action = "GetProduct", id = product.ProductID })); }
public ActionResult PutProduct(ProductsModel product) { HTTPHelpers.PostMethod("http://localhost:37786/", "Products/PutProduct", RestSharp.Method.PUT, product); return(RedirectToAction("GetProducts")); }
public ActionResult GetProductsByCategory(int id) { var products = HTTPHelpers.GetMethod <List <ProductsModel> >("http://localhost:37796/", "Products/GetProductsByCategoryID", RestSharp.Method.GET, id); return(View(products)); }
public ActionResult DeleteOrder(int id) { HTTPHelpers.DeleteMethod("http://localhost:37786/", "Orders/DeleteOrder", RestSharp.Method.DELETE, id); return(RedirectToAction("GetOrders")); }
public async Task ViewNonProfile(string server, [Remainder] string name) { var player = await GetParseNoID(server, name); if (player == null) { Console.WriteLine("Player not found"); await ReplyAsync("Sorry, the player you're looking for does not exist or has changed his name or is not on the specified server or datacenter."); } if (player.xivdbURL == "" || player.xivdbURL.Length == 0 || player.xivdbURL == null) { player.xivdbURL = GetXivDB(player.playerName, player.world, false).Result.ToString(); if (player.xivdbURL == "!@invalid") { await SendProfileNoXIVDB(0); return; } } if (player.xivdbURL_API == "" || player.xivdbURL_API.Length == 0 || player.xivdbURL_API == null) { player.xivdbURL_API = GetXivDB(player.playerName, player.world, true).Result.ToString(); if (player.xivdbURL_API == "!@invalid") { await Context.User.SendMessageAsync("Character API URL not found at XIVDB"); await SendProfileNoXIVDB(0); return; } } Console.WriteLine($"xivdb: {player.xivdbURL}\napi: {player.xivdbURL_API}"); player.GetClearedFights(); var client = HTTPHelpers.NewClient(); string responseBody = await client.GetStringAsync(player.xivdbURL_API); var xivdbCharacter = JsonConvert.DeserializeObject <XivDB.XIVDBCharacter>(responseBody); var raidJobs = ""; foreach (var job in player.jobs) { if (raidJobs.Contains(job.name) == false) { raidJobs += $" - **{job.name}**\n" + $" • Historical DPS: {job.historical_dps}\n" + $" • Historic Best : {Math.Round(job.historical_percent, 1)}%\n"; } } try { //foreach (var job in xivdbCharacter.data.classjobs.class_jobs) { //jobs += $"{job.name} - {job.level}"; //} } catch { Console.WriteLine($"classjobs is null: {xivdbCharacter.data.classjobs.class_jobs == null}"); } var clears = ""; foreach (var clear in player.GetClearedFights(Context)) { //if(clear.ToLower().Contains("byakko")){ clears += $" - {clear}\n"; //} } var reply = $"**Best DPS:** {player.bestDps}\n" + $"**Avg Best %:** {Math.Round(player.bestPercent, 1)}%\n\n" + $"__**Raid Jobs**__\n" + $"{raidJobs}\n" + $"__**Clears**__\n" + $"{clears}\n" + $""; //+ //$"__**Jobs**__\n" + //$"{jobs}"; //Console.WriteLine(reply); var embed = new EmbedBuilder() .WithTitle($"{xivdbCharacter.name} - {xivdbCharacter.data.title}") .WithUrl(player.xivdbURL) .WithThumbnailUrl(xivdbCharacter.avatar) .WithImageUrl(xivdbCharacter.portrait) .WithFooter(new EmbedFooterBuilder() .WithText($"{player.dc} - {player.world} | {xivdbCharacter.data.race}")) .WithColor(new Color(102, 255, 222)) .WithDescription(reply) .Build(); if (Context.Channel.GetType().Name == "SocketDMChannel") { await Context.User.SendMessageAsync("", embed : embed); } else { await ReplyAsync("", embed : embed); } }
public ActionResult GetCategories() { var categories = HTTPHelpers.GetListMethod <List <CategoriesModel> >("http://localhost:37796/", "Categories/GetCategories", RestSharp.Method.GET); return(View(categories)); }
public void Load() { string[] list = new string[] { }; var repoResponse = HTTPHelpers.GetHTTPResponseStreamAsync(RepositoryPackURL); repoResponse.Wait(); if (repoResponse.Result.Status == HttpStatusCode.OK) { // Start pack processing var tempDict = new Dictionary <string, Item>(); var trackableStream = new TrackableStream(repoResponse.Result.Stream); trackableStream.OnProgress += (long current, long total) => { RepositoryProgress?.Invoke(current, repoResponse.Result.Length); }; using (var reader = ReaderFactory.Open(trackableStream)) { while (reader.MoveToNextEntry()) { if (Regex.Match(reader.Entry.Key, @"^(?:\./)?list$", RegexOptions.IgnoreCase).Success) { list = Regex.Replace(StreamToString(reader.OpenEntryStream()), @"[\r\n]+", "\n").Split("\n"[0]); } if (Regex.Match(reader.Entry.Key, @"^(?:\./)?readme.md$", RegexOptions.IgnoreCase).Success) { Readme = StreamToString(reader.OpenEntryStream()); } var match = Regex.Match(reader.Entry.Key, @"^(?:\./)?([^/]+)/(extract|link|md5|sha1|readme(?:\.(?:md|txt)?)?)$", RegexOptions.IgnoreCase); if (match.Success) { var mod = match.Groups[1].ToString(); var fileName = match.Groups[2].ToString(); Item item; if (!tempDict.TryGetValue(mod, out item)) { item = new Item(mod); tempDict.Add(mod, item); } switch (fileName.ToLower()) { case "extract": item.setExtract(true); break; case "link": item.setURL(StreamToString(reader.OpenEntryStream()).Trim()); break; case "md5": item.setMD5(StreamToString(reader.OpenEntryStream()).Trim()); break; case "sha1": item.setSHA1(StreamToString(reader.OpenEntryStream()).Trim()); break; case "readme": case "readme.txt": case "readme.md": item.setReadme(StreamToString(reader.OpenEntryStream()).Trim(), fileName.EndsWith(".md")); break; } } } } if (list.Length == 0) { list = tempDict.Keys.ToArray(); } foreach (var key in tempDict.Keys.ToArray()) { var item = tempDict[key]; if (list.Contains(key)) { Items.Add(item); } tempDict.Remove(key); } tempDict.Clear(); tempDict = null; Items.Sort((x, y) => x.Name.CompareTo(y.Name)); RepositoryLoaded?.Invoke(Items.ToArray()); return; // End pack processing } var taskList = HTTPHelpers.GetHTTPResponseStringAsync(RepositoryListURL); taskList.Wait(); list = (taskList.Result ?? "").Split("\n"[0]); for (int i = 0; i < list.Length; i++) { var mod = list[i]; Item item = new Item(mod); var taskExtract = HTTPHelpers.GetHTTPStatusCodeAsync($"{RepositoryURL}{mod}/extract"); var taskURL = HTTPHelpers.GetHTTPResponseStringAsync($"{RepositoryURL}{mod}/link"); var taskMD5 = HTTPHelpers.GetHTTPResponseStringAsync($"{RepositoryURL}{mod}/md5"); var taskSHA1 = HTTPHelpers.GetHTTPResponseStringAsync($"{RepositoryURL}{mod}/sha1"); taskExtract.Wait(); taskURL.Wait(); taskMD5.Wait(); taskSHA1.Wait(); item.setExtract(taskExtract.Result == HttpStatusCode.OK); item.setURL(taskURL.Result); item.setMD5(taskMD5.Result); item.setSHA1(taskSHA1.Result); for (var x = 0; x < HmodReadme.readmeFiles.Length; x++) { var taskReadme = HTTPHelpers.GetHTTPResponseStringAsync($"{RepositoryURL}{mod}/{HmodReadme.readmeFiles[x]}"); taskReadme.Wait(); if (taskReadme.Result != null) { item.setReadme(taskReadme.Result, HmodReadme.readmeFiles[x].EndsWith(".md")); break; } } Items.Add(item); RepositoryProgress?.Invoke(i + 1, list.Length); } RepositoryLoaded?.Invoke(Items.ToArray()); return; }
public static List <Route> Calculate(ClientRouteCalculatorRequest rcr) { string API_KEY = Environment.ExpandEnvironmentVariables(ConfigurationManager.AppSettings["GOOGLE_API_KEY"]); List <Route> resultList = new List <Route>(); foreach (string company in rcr.CompaniesWithAddresses) { string companyNameWithStateEscaped = Uri.EscapeUriString(company); /* Extract exact address from company + state combination */ string json = HTTPHelpers.SynchronizedRequest("GET", $"https://maps.googleapis.com/maps/api/place/findplacefromtext/json?" + $"input={companyNameWithStateEscaped}&inputtype=textquery&language=en-US&fields=all&key={API_KEY}"); string exactAddress = RouteCalculatorHelpers.ExtractFormattedAddress(json); string exactAddressEscaped = Uri.EscapeUriString(exactAddress); /* Extract latitude, longitude from an address */ json = HTTPHelpers.SynchronizedRequest("GET", $"https://maps.googleapis.com/maps/api/geocode/json?" + $"address={exactAddressEscaped}&key={API_KEY}"); Coordinates destCoordinates = RouteCalculatorHelpers.ExtractLatLng(json); Coordinates originCoordinates = new Coordinates(rcr.Coordinates.Lat, rcr.Coordinates.Lng); // Get Route json = HTTPHelpers.SynchronizedRequest("GET", $"https://maps.googleapis.com/maps/api/directions/json" + $"?origin={originCoordinates.Lat},{originCoordinates.Lng}&destination={destCoordinates.Lat},{destCoordinates.Lng}&mode=transit&key={API_KEY}&language=en-US"); /* Calculate whether it is beneficial to use a car to drive to one of the stations */ // Loop over to get all station coordinates List <Coordinates> stationsInRoute = RouteCalculatorHelpers.GetStationsInRoute(json); // Calculate route to station via private vehicle int minLengthId = -1, minLengthRoute = int.MaxValue, differenceCarVsPublic = -1; for (int i = 0; i < stationsInRoute.Count; i++) { Coordinates c = stationsInRoute[i]; int secondsUntilStationNoCar = RouteCalculatorHelpers.CalculateSecondsUntilStation(json, c); if (RouteCalculatorHelpers.IsBeneficialToDriveByCar(originCoordinates, c, secondsUntilStationNoCar, API_KEY)) { int seconds = RouteCalculatorHelpers.GetLengthOfRouteByCar(originCoordinates, c, secondsUntilStationNoCar, API_KEY); if (seconds < minLengthRoute) { minLengthRoute = seconds; minLengthId = i; differenceCarVsPublic = secondsUntilStationNoCar - seconds; } } } bool isBeneficial; Coordinates prvVehicleCoords; string carDriveJustification = ""; try { prvVehicleCoords = new Coordinates(stationsInRoute[minLengthId].Lat, stationsInRoute[minLengthId].Lng); isBeneficial = true; TimeSpan time = TimeSpan.FromSeconds(differenceCarVsPublic); string timeStr = time.ToString(@"hh\:mm\:ss"); carDriveJustification = $"Driving with a private vehicle to 'PrivateVehicleCoordinates' " + $"and only then beginning the public transport journey will save {timeStr}"; } catch (ArgumentOutOfRangeException oorException) { prvVehicleCoords = new Coordinates(0, 0); isBeneficial = false; Console.WriteLine(oorException.ToString()); } Route route = new Route( exactAddress, originCoordinates, destCoordinates, prvVehicleCoords, isBeneficial, carDriveJustification); resultList.Add(route); } return(resultList); }
public ActionResult GetOrders() { var orders = HTTPHelpers.GetListMethod <List <OrdersModel> >("http://localhost:37786/", "Orders/GetOrders", RestSharp.Method.GET); return(View(orders)); }
public ActionResult PostOrder(OrdersModel order) { HTTPHelpers.PostMethod("http://localhost:37786/", "Orders/PostOrder", RestSharp.Method.POST, order); return(RedirectToRoute(new { controller = "Orders", action = "GetOrder", id = order.OrderID })); }
public ActionResult UpdateCustomer(string id) { var customer = HTTPHelpers.GetMethod <CustomersModel>("http://localhost:37776/", "Customers/GetCustomerDetail", RestSharp.Method.GET, id); return(View(customer)); }
// GET: OrderDetails public ActionResult GetOrderDetails(int id) { var orderdetail = HTTPHelpers.GetMethod <List <OrderDetailsModel> >("http://localhost:37776/", "OrderDetails/GetOrderDetails", RestSharp.Method.GET, id); return(View(orderdetail)); }
public async Task <Player> GetParseNoID(string server, [Remainder] string name) { Console.WriteLine("\n "); var roles = GetRoles(); var jobslist = new List <Nero.job>(); var worlds = Nero.Worlds.GetWorlds(); var worldResult = from wrld in worlds where wrld.Name.ToLower().Contains(server.ToLower()) select wrld; var world = worldResult.First(); var url = new Uri($"https://www.fflogs.com/v1/parses/character/{name}/{world.Name}/{world.Region}/?api_key={Configuration.Load().FFLogsKey}"); var trialUrl = new Uri($"https://www.fflogs.com/v1/parses/character/{name}/{world.Name}/{world.Region}/?api_key=7bd977bcb89a89934dc26a137b6d2b24&zone=15&zone=15"); var ultimateUrl = new Uri($"https://www.fflogs.com/v1/parses/character/{name}/{world.Name}/{world.Region}/?api_key=7bd977bcb89a89934dc26a137b6d2b24&zone=15&zone=19"); HttpClient client = HTTPHelpers.NewClient(); var player = new Player(0, name, world.DC, world.Name); try { Console.WriteLine($"FFlogs URl: {url}"); string responseBody = await client.GetStringAsync(url); string trialResponseBody = await client.GetStringAsync(trialUrl); string ultimateResponseBody = await client.GetStringAsync(ultimateUrl); var parses = JsonConvert.DeserializeObject <List <Nero.Parses> >(responseBody); var trialParses = JsonConvert.DeserializeObject <List <Nero.Parses> >(trialResponseBody); var ultimateParses = JsonConvert.DeserializeObject <List <Nero.Parses> >(ultimateResponseBody); parses.AddRange(trialParses); parses.AddRange(ultimateParses); // instantiate best% and bestdps double bestPercent = 0.0; double bestDps = 0.0; foreach (var parse in parses) { bool cleared = false; int specAmount = 0; if (parse.kill > 0) { cleared = true; } List <job> specs = new List <job>(); foreach (var spec in parse.specs) { if (parse.name != "Kefka") { Console.WriteLine($"parse fight: {parse.name}, spec name: {spec.spec}, spec hist %: {spec.best_historical_percent}, spec dps: {spec.best_persecondamount}"); specs.Add(new job(spec.spec, spec.best_historical_percent, spec.best_persecondamount)); if (spec.best_persecondamount >= bestDps) { bestDps = spec.best_persecondamount; } if (spec.best_historical_percent >= bestPercent) { bestPercent = spec.best_historical_percent; } specAmount++; } } player.AddFight(cleared, parse.kill, specAmount, specs, parse.name, bestDps, bestPercent); bestPercent = 0.0; bestDps = 0.0; } //ulong ffxivrecruiterID = 142476055482073089; //ulong testhouseID = 286211518691934210; //if (Context.Guild.Id == ffxivrecruiterID || Context.Guild.Id == testhouseID) { //await AssignRolesAsync(roles, user, player); //} return(player); } catch (HttpRequestException e) { Console.WriteLine("\nException caught"); Console.WriteLine($"Message: {e.Message}"); } client.Dispose(); return(null); }
// GET: Products public ActionResult GetProducts() { var products = HTTPHelpers.GetListMethod <List <ProductsModel> >("http://localhost:37796/", "Products/GetProducts", RestSharp.Method.GET); return(View(products)); }
public async Task SendProfileDM(ulong Id) { Console.WriteLine($"type: {Context.Channel.GetType().Name}"); var context = Context; Console.WriteLine($"does the players profile exist: {Player.DoesProfileExist(Id)}"); if (!Player.DoesProfileExist(Id)) { await Context.User.SendMessageAsync($"Profile for user <@{Id}> does not exist, please run the following command.\n!n assign `server` `character name`"); throw new Exception(""); } var player = Player.Load(Id); if (player.xivdbURL == "" || player.xivdbURL.Length == 0 || player.xivdbURL == null) { player.xivdbURL = GetXivDB(player.playerName, player.world, false).Result.ToString(); if (player.xivdbURL == "!@invalid") { //await SendProfileNoXIVDB(Id); throw new Exception("Invalid XIVDB api url"); } } if (player.xivdbURL_API == "" || player.xivdbURL_API.Length == 0 || player.xivdbURL_API == null) { player.xivdbURL_API = GetXivDB(player.playerName, player.world, true).Result.ToString(); if (player.xivdbURL_API == "!@invalid") { await ReplyAsync("Character API URL not found at XIVDB"); //await SendProfileNoXIVDB(Id); throw new Exception("Invalid XIVDB api url"); } } Console.WriteLine($"xivdb: {player.xivdbURL}\napi: {player.xivdbURL_API}"); var client = HTTPHelpers.NewClient(); string responseBody = await client.GetStringAsync(player.xivdbURL_API); var xivdbCharacter = JsonConvert.DeserializeObject <XivDB.XIVDBCharacter>(responseBody); var raidJobs = ""; foreach (var job in player.jobs) { if (raidJobs.Contains(job.name) == false) { raidJobs += $" - **{job.name}**\n" + $" • Historical DPS: {job.historical_dps}\n" + $" • Historic Best : {Math.Round(job.historical_percent, 1)}%\n"; } } try { //foreach (var job in xivdbCharacter.data.classjobs.class_jobs) { //jobs += $"{job.name} - {job.level}"; //} } catch { Console.WriteLine($"classjobs is null: {xivdbCharacter.data.classjobs.class_jobs == null}"); } var clears = ""; foreach (var clear in player.GetClearedFights(context)) { if (!clear.ToLower().Contains("byakko")) { clears += $" - {clear}\n"; } else { clears += $"\n{clear}\n"; } } var reply = $"**Best DPS:** {player.bestDps}\n" + $"**Avg Best %:** {Math.Round(player.bestPercent, 1)}%\n\n" + $"__**Raid Jobs**__\n" + $"{raidJobs}\n" + $"__**Clears**__\n" + $"{clears}\n" + $""; //+ //$"__**Jobs**__\n" + //$"{jobs}"; //Console.WriteLine(reply); var embed = new EmbedBuilder() .WithTitle($"{xivdbCharacter.name} - {xivdbCharacter.data.title}") .WithUrl(player.xivdbURL) .WithThumbnailUrl(xivdbCharacter.avatar) .WithImageUrl(xivdbCharacter.portrait) .WithFooter(new EmbedFooterBuilder() .WithText($"{player.dc} - {player.world} | {xivdbCharacter.data.race}")) .WithColor(new Color(102, 255, 222)) .WithDescription(reply) .Build(); await Context.User.SendMessageAsync("", embed : embed); }
public ActionResult UpdateOrder(int id) { var order = HTTPHelpers.GetMethod <OrdersModel>("http://localhost:37776/", "Orders/GetOrder", RestSharp.Method.GET, id); return(View(order)); }