protected JsonBenchmarkBase() { JsonSampleString = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, TestFilesFolder, "chucknorris.json")); RootSample = JsonConvert.DeserializeObject <Root>(JsonSampleString); JsonSampleString2 = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, TestFilesFolder, "testingJson.json")); JsonSample = JsonConvert.DeserializeObject <Root2>(JsonSampleString2); ZeroFormatterSampleString2 = ZeroFormatterSerializer.Serialize <Root2>(JsonSample); }
public Item2 SelctOneRecordRandomly(string uid) { using (var con = new NpgsqlConnection(cs)) { con.Open(); Root2 root = new Root2(); root.items = (con.Query <Item2>("SELECT * FROM item where uid = @uid", new { uid }).ToList()); return(root.items[0]); } }
public List <string> Isinterected(string linkIteraction) { WebClient webC = new WebClient(); string XML = webC.DownloadString(linkIteraction); XmlDocument document = new XmlDocument(); document.LoadXml(XML); string jsonText = JsonConvert.SerializeXmlNode(document); string Comment = ""; List <InteractionPair> Pair = null; List <string> Severity = new List <string>(); try { Root2 jsonClass = JsonConvert.DeserializeObject <Root2>(jsonText); //Comment = Comment + jsonClass.interactiondata.fullInteractionTypeGroup.fullInteractionType.comment; Pair = jsonClass.interactiondata.fullInteractionTypeGroup.fullInteractionType.interactionPair; foreach (var pair in Pair) { Comment += pair.description; Severity.Add(pair.severity); } } catch (Exception) { return(new List <string>() { "", "false" }); } List <string> strings = new List <string>(); strings.Add(Comment); bool flag = false; for (int i = 0; i < Severity.Count(); i++) { if (Severity[i] == "high" || Severity[i] == "N/A") { flag = true; //there's dangerous in the interaction between them } } strings.Add(flag.ToString()); return(strings); }
public Task Execute(IJobExecutionContext context) { return(Task.Run(() => { Console.WriteLine(DateTime.Now); string codes = string.Empty; MyfundParm parm = new MyfundParm() { page = 1, rows = 1000, sort = "id", order = "asc" }; var data = _repo.GetPageList(parm).Result; //foreach (var d in data.rows) //{ // codes += d.Code + ","; //} //string url = "https://api.doctorxiong.club/v1/fund?code=" + codes; //FundRetComm response = HttpClientHelper.GetResponse<FundRetComm>(url); foreach (var d in data.rows) { try { //string url = "https://api.doctorxiong.club/v1/fund?code=" + d.Code; //FundRetComm response = HttpClientHelper.GetResponse<FundRetComm>(url); string url = $@"https://fundmobapi.eastmoney.com/FundMApi/FundValuationDetail.ashx?FCODE=" + d.Code + "&deviceid=Wap&plat=Wap&product=EFund&version=2.0.0&Uid=9572315881384690&_=" + MathHelper.GetTimeStamp(); Root2 response = HttpClientHelper.GetResponse <Root2>(url); if (response.ErrCode == 0) { var cur = response.Datas[0]; if (cur != null) { if (!string.IsNullOrEmpty(cur.gszzl)) { _repo.UpdateExpectGrowth(new Myfund() { Id = d.Id, ExpectGrowth = decimal.Parse(cur.gszzl) }); } } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } })); }
public void MainTest() { using (var session = Domain.OpenSession()) { using (session.OpenTransaction()) { var a1 = new A(); var b1 = new B(); var r1 = new Root2() { Number = 123, Child1 = a1, Child2 = b1 }; Session.Current.SaveChanges(); var result = session.Query.All <Root2>().Select(r => r.Number == 123 ? r.Child1 : r.Child2); QueryDumper.Dump(result); // Rollback } } }
public Root2 GetFromDB() { using (var con = new NpgsqlConnection(cs)) { con.Open(); Root2 root = new Root2(); root.items = con.Query <Item2>($"SELECT * FROM item").ToList(); root.items.OrderBy(attribute => attribute.custom == true); foreach (var item in root.items) { if (item.caution.Contains("SHOULD BE CONSIDERED ")) { item.caution = item.caution.Remove(0, 21); } } return(root); } }
static void Main(string[] args) { //var listtable = new List<object>(20); var Root = new Root() { Table = new List <table>(20) }; //for(int i = 0; i < 20; i++) //{ // Root.Table[i].name = $"{i}"; // Root.Table[i].Status = true; //} var selectc = new List <int>(); while (true) { Console.WriteLine("1. Add table :"); Console.WriteLine("2. Pay :"); string chon = Console.ReadLine(); if (chon == "1") { selectc = new List <int>(); var newtable = new table(); Console.WriteLine("Please enter number of table :"); var index = Int32.Parse(Console.ReadLine()); bool check = true; foreach (var item in Root.Table) { if (item.name == $"{index}") { item.Status = false; check = false; break; } } if (check) { var doituong = new table(); doituong.name = $"{index}"; doituong.Status = true; Root.Table.Add(doituong); } int i = 0; int posision = 0; for (i = 0; i < Root.Table.Count; i++) { if ($"{index}" == Root.Table[i].name) { posision = i; break; } } while (Root.Table[posision].Status) { Root.Table[posision].selects = new select(); Console.WriteLine("1. cola:"); Console.WriteLine("2. pepsi"); Console.WriteLine("3. coffe"); Console.WriteLine("4. water"); Console.WriteLine("5. beer"); Console.WriteLine("6. Exit"); Console.Write("select drink:"); int tam = Int32.Parse(Console.ReadLine()); if (tam == 6) { break; } if (tam > 0 && tam < 6) { selectc.Add(tam); } } while (!Root.Table[posision].Status) { Console.WriteLine("Table has been choose"); Console.WriteLine("1. add order "); Console.WriteLine("2. exit"); string tam3 = Console.ReadLine(); int tam2 = 0; if (tam3 == "1") { while (tam2 != 6) { Console.WriteLine("1. cola:"); Console.WriteLine("2. pepsi"); Console.WriteLine("3. coffe"); Console.WriteLine("4. water"); Console.WriteLine("5. beer"); Console.WriteLine("6. Exit"); Console.Write("select drink:"); tam2 = Int32.Parse(Console.ReadLine()); selectc.Add(tam2); } //Root = new Root() //{ // Table = new List<table>() //} } else if (tam3 == "2") { break; } } //Root.Table[posision].selects //select aa = new select(); foreach (var item in selectc) { if (item == 1) { Root.Table[posision].selects.Pricecoca++; } else if (item == 2) { Root.Table[posision].selects.Pricepepsi++; } else if (item == 3) { Root.Table[posision].selects.Pricecoffe++; } else if (item == 4) { Root.Table[posision].selects.Pricewater++; } else if (item == 5) { Root.Table[posision].selects.Pricebeer++; } } //Root.Table.Add(new table() //{ // name = newtable.name, // selects = aa1, // Status = false //}); Root.Table[posision].Status = false; using (StreamWriter sw = File.CreateText(@"C:\Users\Hoang\Documents\module2\FileIO\ConsoleApp1\additional_2.3\order.json")) { var data = JsonConvert.SerializeObject(Root); sw.Write(data); } } else if (chon == "2") { Console.WriteLine("Please enter number of table :"); var index = Int32.Parse(Console.ReadLine()); int i; int posision = -1; for (i = 0; i < Root.Table.Count; i++) { if ($"{index}" == Root.Table[i].name) { posision = i; break; } } if (posision == -1) { Console.WriteLine("Invalid table."); } else { var Root2 = new Root2() { Table = new List <table1>(20) }; foreach (var std in Root.Table) { Root2.Table.Add(new table1() { name = std.name, selects = std.selects, tinhtien = std.selects.tinhtien(), giotinhtien = DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss") }); } Console.WriteLine("complete pay."); using (StreamWriter sw = File.CreateText(@"C:\Users\Hoang\Documents\module2\FileIO\ConsoleApp1\additional_2.3\Bill.json")) { var data = JsonConvert.SerializeObject(Root2); sw.Write(data); } Root.Table.RemoveAt(posision); } } } }
public async Task <IActionResult> IndexAsync(DateTime datum) { if (!_db.StorageDB.Any()) { // await geListTickersAsync(); var comp = ProcessCSV("constituents.csv"); foreach (var item in comp) { //Dohvatanje detaljnih podataka za iste var client2 = new HttpClient(); var request2 = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri(@"https://apidojo-yahoo-finance-v1.p.rapidapi.com/stock/v2/get-summary?symbol=" + item.Symbol + "®ion=US"), Headers = { { "x-rapidapi-key", "59cd2485cemshf72578d1ef3ac2ap106076jsncc6280cf1332" }, { "x-rapidapi-host", "apidojo-yahoo-finance-v1.p.rapidapi.com" }, }, }; System.Threading.Thread.Sleep(1000); using (var response2 = await client2.SendAsync(request2)) { response2.EnsureSuccessStatusCode(); var details = await response2.Content.ReadAsStringAsync(); Root2 financije2 = JSONSerializerWrapper.Deserialize <Root2>(details); //Pohrana u bazu podataka if (financije2.summaryProfile != null && financije2.price != null) { StorageDB s = new StorageDB() { symbol = item.Symbol, CompanyName = item.Name, numberOfEmployees = financije2.summaryProfile.fullTimeEmployees, City = financije2.summaryProfile.city, State = financije2.summaryProfile.country, MarketCap = financije2.price.marketCap.longFmt }; _db.StorageDB.Add(s); _db.SaveChanges(); } } } } List <Storage> podaci = new List <Storage>(); if (!_db.FinanceStorageDB.Any(x => x.Datum.Year == datum.Year && x.Datum.Month == datum.Month && x.Datum.Day == datum.Day)) { foreach (var item in _db.StorageDB) { try { //Uzimanje samo onih kompanija, koje imaju "historical finanace" na odabrani datum var h = await YahooFinanceApi.Yahoo.GetHistoricalAsync(item.symbol, new DateTime(datum.Year, datum.Month, datum.Day), new DateTime(datum.Year, datum.Month, datum.Day).AddDays(1), Period.Daily); foreach (var candle in h) { podaci.Add(new Storage { OpenPrice = candle.Open, ClosePrice = candle.Close, Datum = candle.DateTime, ID = item.ID }); } } catch (Exception) { } } for (int i = 0; i < podaci.Count; i++) { FinanceStorageDB f = new FinanceStorageDB { OpenPrice = podaci[i].OpenPrice, ClosePrice = podaci[i].ClosePrice, Datum = podaci[i].Datum, StorageDBId = podaci[i].ID }; _db.FinanceStorageDB.Add(f); _db.SaveChanges(); } } //Dohvatanje podataka iz baze podataka StorageVM model = new StorageVM(); model.podaci = _db.FinanceStorageDB .Include(i => i.StorageDB) .Where(i => i.Datum.Year == datum.Year && i.Datum.Month == datum.Month && i.Datum.Day == datum.Day) .Select(n => new StorageVM.Rows { symbol = n.StorageDB.symbol, CompanyName = n.StorageDB.CompanyName, numberOfEmployees = n.StorageDB.numberOfEmployees, City = n.StorageDB.City, State = n.StorageDB.State, MarketCap = n.StorageDB.MarketCap, ClosePrice = n.ClosePrice, OpenPrice = n.OpenPrice, Datum = n.Datum }) .ToList(); return(View(model)); }
private async Task geListTickersAsync() { //Dohvatanje liste symbola i kompanija u EU regiji var client = new HttpClient(); var request = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri("https://apidojo-yahoo-finance-v1.p.rapidapi.com/market/get-trending-tickers?region=US"), Headers = { { "x-rapidapi-key", "59cd2485cemshf72578d1ef3ac2ap106076jsncc6280cf1332" }, { "x-rapidapi-host", "apidojo-yahoo-finance-v1.p.rapidapi.com" }, }, }; using (var response = await client.SendAsync(request)) { response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Root financije = JSONSerializerWrapper.Deserialize <Root>(body); //Convertovanje JSona u C# foreach (var item in financije.finance.result) { foreach (var x in item.quotes) { //Dohvatanje detaljnih podataka za iste var client2 = new HttpClient(); var request2 = new HttpRequestMessage { Method = HttpMethod.Get, RequestUri = new Uri(@"https://apidojo-yahoo-finance-v1.p.rapidapi.com/stock/v2/get-summary?symbol=" + x.symbol + "®ion=US"), Headers = { { "x-rapidapi-key", "59cd2485cemshf72578d1ef3ac2ap106076jsncc6280cf1332" }, { "x-rapidapi-host", "apidojo-yahoo-finance-v1.p.rapidapi.com" }, }, }; System.Threading.Thread.Sleep(1000); using (var response2 = await client2.SendAsync(request2)) { response2.EnsureSuccessStatusCode(); var details = await response2.Content.ReadAsStringAsync(); Root2 financije2 = JSONSerializerWrapper.Deserialize <Root2>(details); //Pohrana u bazu podataka if (financije2.summaryProfile != null && financije2.price != null) { StorageDB s = new StorageDB() { symbol = x.symbol, CompanyName = x.shortName, numberOfEmployees = financije2.summaryProfile.fullTimeEmployees, City = financije2.summaryProfile.city, State = financije2.summaryProfile.country, MarketCap = financije2.price.marketCap.longFmt }; _db.StorageDB.Add(s); _db.SaveChanges(); } } } } throw new NotImplementedException(); } }
private NeuronNet AcceptJson(Root2 root2) { NeuronNet net = new NeuronNet(); for (int i = 0; i < root2.inputss.Count; i++) { PointF pointF = new PointF(); pointF.X = (float)root2.inputss[i].Position.X; pointF.Y = (float)root2.inputss[i].Position.Y; NeuronInput neuron = new NeuronInput((float)root2.inputss[i].value, root2.inputss[i].Name, pointF); neuron.positionChanged = root2.inputss[i].positionChanged; neuron.wasPainted = root2.inputss[i].wasPainted; net.inputss.Add(neuron); } for (int i = 0; i < root2.NeuronGroups.Count; i++) { NeuronGroup neurongroup = new NeuronGroup(); neurongroup.Neurons = root2.NeuronGroups[i].Neurons; neurongroup.SecondActivate = root2.NeuronGroups[i].SecondActivate; neurongroup.SumForSoftMax = (float)root2.NeuronGroups[i].SumForSoftMax; neurongroup.allNeuronsWasPainted = root2.NeuronGroups[i].allNeuronsWasPainted; net.NeuronGroups.Add(neurongroup); } for (int i = 0; i < root2.studyPairss.Count; i++) { StudyPair studyPair = new StudyPair(); for (int j = 0; j < root2.studyPairss[i].inputs.Count; j++) { studyPair.inputs.Add((float)root2.studyPairss[i].inputs[j]); } for (int j = 0; j < root2.studyPairss[i].quits.Count; j++) { studyPair.quits.Add((float)root2.studyPairss[i].quits[j]); } for (int j = 0; j < root2.studyPairss[i].realQuits.Count; j++) { studyPair.realQuits.Add((float)root2.studyPairss[i].realQuits[j]); } net.studyPairss.Add(studyPair); } net.E = (float)root2.E; net.moment = (float)root2.moment; for (int i = 0; i < root2.errors.Count; i++) { PointF pointF = new PointF(); pointF.X = (float)root2.errors[i].X; pointF.Y = (float)root2.errors[i].Y; net.errors.Add(pointF); } for (int i = 0; i < root2.normalizedErrors.Count; i++) { PointF pointF = new PointF(); pointF.X = (float)root2.normalizedErrors[i].X; pointF.Y = (float)root2.normalizedErrors[i].Y; net.normalizedErrors.Add(pointF); } net.EraCount = root2.EraCount; net.currentSelection = new NeuronGroup(0); net.recognitionResults = new List <RecognitionResult>(); net.StudyPairsLoaded = root2.StudyPairsLoaded; net.InputsSum = (float)root2.InputsSum; net.allInputsWasPainted = root2.allInputsWasPainted; net.minError = (float)root2.minError; net.NormalizeOutputValue = (float)root2.NormalizeOutputValue; net.biasX = (float[])root2.biasX; net.biasY = (float[])root2.biasY; net.scaleX = (float[])root2.scaleX; net.scaleY = (float[])root2.scaleY; net.StudyLimit = (float)root2.StudyLimit; net.AccessChangeNet = root2.AccessChangeNet; return(net); }