/// <summary> /// Implementação concreta do site fundsexplorer.com.br /// </summary> /// <typeparam name="T"></typeparam> /// <param name="B3Code"></param> /// <returns></returns> public T Fill <T>(string B3Code) where T : DadosBase, new() { return(Usefull.GetCache <T>(() => { var fund = new FundsExplorerModel(); var HtmlDocument = this.LoadUrl("url.site.fundsexplorer", B3Code); var indices = HtmlDocument.GetElementbyId("simulation") .Descendants("div") .Where(Usefull.PredicateFindValueClass("section-body")); var cotacao = HtmlDocument.GetElementbyId("stock-price").Descendants("span"); fund.VariacaoCotacao = cotacao.First(p => p.GetAttributeValue("class", "").Contains("percentage ")).GetValueText(); fund.Cotacao = cotacao.First(Usefull.PredicateFindValueClass("price")).GetValueText(); fund.ComparacaoPoupanca = indices.First() .Descendants("div") .Where(Usefull.PredicateFindValueClass("col-md-6 col-xs-12")).ElementAt(1) .Descendants("li") .Last() .Descendants("span").ElementAt(1).InnerText.ClearText(); return fund as T; }, B3Code)); }
// <<<<<<<<<<<<<<<<< EDIT BUTTONS >>>>>>>>>>>>>>>>>>>>>> private void btnSave_Click(object sender, EventArgs e) { Airport local = MatchAirportList((Airport)listBoxAirports.CurrentRow.DataBoundItem); if (CheckCity() && CheckCountry() && CheckShort()) { Airport airportNew = new Airport(local.InternId, Usefull.UpperCase(textBoxCity.Text), Usefull.UpperCase(textBoxCountry.Text), tbShortName.Text.ToUpper(), Usefull.UpperCase(tbAirportName.Text)); if (AirportExists(airportNew)) { local.Name = Usefull.UpperCase(tbAirportName.Text); local.Country = Usefull.UpperCase(textBoxCountry.Text); local.City = Usefull.UpperCase(textBoxCity.Text); local.IATA = tbShortName.Text.ToUpper(); listBoxAirports.Enabled = true; gbEditor.Visible = false; RefreshList(); ClearFields(); } } }
public T Fill <T>(string B3Code) where T : DadosBase, new() { var lista = Usefull.GetCache <List <RankingModel> >(() => GetRanking(), "ranking.fundos").OrderBy(p => p.Codigo); T retorno = lista.FirstOrDefault(p => p.Codigo == B3Code) as T; return(retorno); }
public T Fill <T>(string B3Code) where T : DadosBase, new() { return(Usefull.GetCache <T>(() => { var fund = new SiteFIIModel(); var document = this.LoadUrl("url.site.fii", B3Code); var indices = document.GetElementbyId("informations--indexes") .Descendants("span") .Where(Usefull.PredicateFindValueClass("value")).ToList(); fund.PercentualUltimoYeld = indices[INDICES_PERCENTUAL_ULTIMOYELD].GetValueText(); fund.UltimoPagamento = indices[INDICES_VALOR_ULTIMOYELD].GetValueText(); fund.PatrimonioFundo = indices[INDICES_PATRIMONIO_FUNDO].GetValueText(); fund.PatrimonioPorCota = indices[INICES_PATRIMONIO_POR_COTA].GetValueText(); fund.Cotacao = document.DocumentNode.Descendants("div") .First(Usefull.PredicateFindValueClass("item quotation")) .Descendants("span") .Where(Usefull.PredicateFindValueClass("item")) .First().GetValueText(); var basicInformation = document.GetElementbyId("informations--basic") .Descendants("div") .Where(Usefull.PredicateFindValueClass("row")).ToList(); var foundsInformation = basicInformation.First() .Descendants("div") .Where(Usefull.PredicateFindValueClass("item")).ToList(); fund.Codigo = B3Code; fund.NomeFundo = foundsInformation[INFORMCOES_NOME].GetTextSpan(); fund.TipoFundoB3 = foundsInformation[INFORMCOES_TIPO_FUNDO].GetTextSpan(); fund.TipoFundoAnbima = foundsInformation[INFORMCOES_TIPO_FUNDO_ANBIMA].GetTextSpan(); fund.DataRegistroCVM = DateTime.Parse(foundsInformation[INFORMCOES_DATA_CRIACAO_FUNDO].GetTextSpan()); foundsInformation.Clear(); foundsInformation = basicInformation.Last() .Descendants("div") .Where(Usefull.PredicateFindValueClass("item")).ToList(); fund.TotalCotas = foundsInformation[INFORMCOES_TOTAL_COTAS].GetValueSpan(); fund.TotalCotistas = foundsInformation[INFORMCOES_TOTAL_COTISTAS].GetValueSpan(); fund.CNPJ = foundsInformation[INFORMCOES_CNPJ].GetTextSpan(); return fund as T; }, B3Code)); }
private bool AirportExists(Airport airportNew) { var result = Airports.Where(a => a.InternId == airportNew.InternId); if (result.ToList().Count == 1)//when in edition mode the result will return 1 { return(true); } else//the result will return 0 because it's a new airport { var checkName = Airports.Where(a => a.IATA == airportNew.IATA);//this will check for a repeated IATA code if (checkName.ToList().Count != 0) { MessageBox.Show($"You already have an Airport connection to {Usefull.UpperCase(textBoxCity.Text)}!", "Cannot add Airport!", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(true); } }
private void btnAdd_Click(object sender, EventArgs e) { if (CheckCity() && CheckCountry() && CheckShort())//checks for empty TBs and returns error if true! { Airport airportNew = new Airport(NextNumber(), Usefull.UpperCase(textBoxCity.Text), Usefull.UpperCase(textBoxCountry.Text), tbShortName.Text.ToUpper(), Usefull.UpperCase(tbAirportName.Text)); //checks if there is a airport with the same IATA code if (AirportExists(airportNew)) { Airports.Add(airportNew); RefreshList(); ClearFields(); //not sure if this is correct but cleans the search list BtnClean_Click(sender, e); } } }
//<<<<<<<<<<<<<<<<<<<<<<<<<<< BUTTONS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> private void btnCheckIn_Click(object sender, EventArgs e) { if (IsEmailValid(tbEmail.Text)) { //variables string name = Usefull.UpperCase(tbName.Text) + " " + Usefull.UpperCase(tbLastName.Text); string internId = MakeId(name); string id = tbIdentification.Text; string email = tbEmail.Text; string gender = GetGender(); string seat = cbSeats.Text; string seatClass = GetClass(); //creates a new passenger Passenger newPassenger = new Passenger(internId, name, id, email, gender, seat, seatClass); //adds the seat to the taken seats in the plane toBook.TakenSeats.Add(cbSeats.Text); //adds the passenger to the plane toBook.Tickets.Add(newPassenger); //creates the boarding pass FillPDF(newPassenger, toBook); MessageBox.Show($"The Boarding Pass for passenger {name} was created."); ShowPDF showPDF = new ShowPDF(this, toBook.FlightNumber, newPassenger); showPDF.ShowDialog(); BackToSearch(); } else { MessageBox.Show("The email provided is invalid."); } }
public static dynamic FII_RENTABILIDADE_PATRIMONIO_PERIODO([ExcelArgument(Name = "RENTABILIDADE_PATRIMONIO_PERIODO", Description = "RENTABILIDADE_PATRIMONIO_PERIODO")] string fundo) => Usefull.Run(() => crawlerRanking.Fill <RankingModel>(fundo).rentabilidade_patrimonio_Periodo, fundo);
public static dynamic FII_VARIACAO_PATRIMONIAL([ExcelArgument(Name = "VARIACAO_PATRIMONIAL", Description = "VARIACAO_PATRIMONIAL")] string fundo) => Usefull.Run(() => crawlerRanking.Fill <RankingModel>(fundo).Variacao_Patrimonial, fundo);
public static dynamic FII_P_VPA([ExcelArgument(Name = "P_VPA", Description = "P_VPA")] string fundo) => Usefull.Run(() => crawlerRanking.Fill <RankingModel>(fundo).P_VPA, fundo);
public static dynamic FII_PATRIMONIO_LIQUIDO([ExcelArgument(Name = "PATRIMONIO_LIQUIDO", Description = "PATRIMONIO_LIQUIDO")] string fundo) => Usefull.Run(() => crawlerRanking.Fill <RankingModel>(fundo).Patrimonio_Liquido, fundo);
public static dynamic FII_VARIACAO_PRECO([ExcelArgument(Name = "VARIACAO_PRECO", Description = "VARIACAO_PRECO")] string fundo) => Usefull.Run(() => crawlerRanking.Fill <RankingModel>(fundo).variacao_preco, fundo);
static void Main(string[] args) { #region Object creation Shop shop = new Shop(); shop.Id = 1; shop.Name = "My Grocerie"; shop.Finance = new Decimal(1200); shop.Credit = new Decimal(1500); Client client1 = new Client(); client1.Id = 1; client1.Money = new Decimal(100.20); client1.Name = "Eude"; client1.Surname = "Jean"; Address address1 = new Address(); address1.Id = 1; address1.City = "Rennes"; address1.Path = "Voie"; address1.Way = "La guenardiere"; address1.Number = "6"; client1.Address = address1; shop.Clients.Add(client1); Client client2 = new Client(); client2.Id = 2; client2.Money = new Decimal(50); client2.Name = "Marc"; client2.Surname = "Jack"; Address address2 = new Address(); address2.Id = 2; address2.City = "Rennes"; address2.Path = "Voie"; address2.Way = "La guenardiere"; address2.Number = "6"; client2.Address = address2; shop.Clients.Add(client2); Client client3 = new Client(); client3.Id = 3; client3.Money = new Decimal(30.80); client3.Name = "Ulé"; client3.Surname = "Ivon"; Address address3 = new Address(); address3.Id = 3; address3.City = "Rennes"; address3.Path = "Voie"; address3.Way = "La guenardiere"; address3.Number = "6"; client3.Address = address3; shop.Clients.Add(client3); Owner owner = new Owner(); owner.Id = 4; owner.Name = "Montant"; owner.Surname = "Ive"; Address address4 = new Address(); address4.Id = 4; address4.City = "Rennes"; address4.Path = "Voie"; address4.Way = "La guenardiere"; address4.Number = "6"; owner.Address = address4; shop.Owners.Add(owner); #region Products creation Product product1 = new Cold(); product1.Id = 1; product1.Name = "product 1"; product1.Price = new Decimal(10); shop.Products.Add(product1); Product product2 = new Consistant(); product2.Id = 2; product2.Name = "product 2"; product2.Price = new Decimal(20); shop.Products.Add(product2); Product product3 = new Fluid(); product3.Id = 3; product3.Name = "product 3"; product3.Price = new Decimal(30); shop.Products.Add(product3); Product product4 = new Hot(); product4.Id = 4; product4.Name = "product 4"; product4.Price = new Decimal(40); shop.Products.Add(product4); Product product5 = new Usefull(); product5.Id = 5; product5.Name = "product 5"; product5.Price = new Decimal(50); shop.Products.Add(product5); Product product6 = new Useless(); product6.Id = 6; product6.Name = "product 6"; product6.Price = new Decimal(60); shop.Products.Add(product6); Product product7 = new Usable(); product7.Id = 7; product7.Name = "product 7"; product7.Price = new Decimal(70); shop.Products.Add(product7); Product product8 = new Cold(); product8.Id = 8; product8.Name = "product 8"; product8.Price = new Decimal(80); shop.Products.Add(product8); Product product9 = new Cold(); product9.Id = 9; product9.Name = "product 9"; product9.Price = new Decimal(90); shop.Products.Add(product9); Product product10 = new Cold(); product10.Id = 10; product10.Name = "product 10"; product10.Price = new Decimal(100); shop.Products.Add(product10); #endregion #endregion #region Print object in console //Console.WriteLine(shop); shop.PrintItemCategories(); /*Console.WriteLine(owner); * Console.WriteLine(product1); * Console.WriteLine(product2); * Console.WriteLine(product3); * Console.WriteLine(product4); * Console.WriteLine(product5); * Console.WriteLine(product6); * Console.WriteLine(product7); * Console.WriteLine(product8); * Console.WriteLine(product9); * Console.WriteLine(product10); * Console.WriteLine(client1); * Console.WriteLine(client2); * Console.WriteLine(client3);*/ //shop.PrintItemCategories1(); Console.ReadKey(); #endregion }
public static dynamic FII_TIPO_FUNDO_B3([ExcelArgument(Name = "Código do Fundo", Description = "Código na B3 do Fundo Imobiliário")] string fundo) => Usefull.Run(() => crawlerFII.Fill <SiteFIIModel>(fundo).TipoFundoB3, fundo);
/// <summary> /// searches for airports in a list of all world airports with a user inputed city /// </summary> /// <returns></returns> private Task <List <Airport> > GetAirport() { var result = AllAirports.Where(a => a.City.StartsWith(Usefull.UpperCase(textBoxCity.Text))); return(Task.FromResult(result.ToList())); }
public static dynamic FII_QT_ATIVOS([ExcelArgument(Name = "QT_ATIVOS", Description = "QT_ATIVOS")] string fundo) => Usefull.Run(() => crawlerRanking.Fill <RankingModel>(fundo).qt_Ativos, fundo);
public static dynamic FII_SETOR([ExcelArgument(Name = "SETOR", Description = "SETOR")] string fundo) => Usefull.Run(() => crawlerRanking.Fill <RankingModel>(fundo).Setor, fundo);
public static dynamic FII_VACANCIA_FINANCERIA([ExcelArgument(Name = "VACANCIA_FINANCERIA", Description = "VACANCIA_FINANCERIA")] string fundo) => Usefull.Run(() => crawlerRanking.Fill <RankingModel>(fundo).Vacancia_financeria, fundo);
public static dynamic FII_TOTAL_COTISTAS([ExcelArgument(Name = "Código do Fundo", Description = "Código na B3 do Fundo Imobiliário")] string fundo) => Usefull.Run(() => crawlerFII.Fill <SiteFIIModel>(fundo).TotalCotistas, fundo);
public static dynamic FII_VALOR_COTA_PATRIMONIO([ExcelArgument(Name = "Código do Fundo", Description = "Código na B3 do Fundo Imobiliário")] string fundo) => Usefull.Run(() => crawlerFII.Fill <SiteFIIModel>(fundo).UltimoPagamento, fundo);
public static dynamic FII_RENTABILIDADE_PATRIMONIO_ACUMULADA([ExcelArgument(Name = "RENTABILIDADE_PATRIMONIO_ACUMULADA", Description = "RENTABILIDADE_PATRIMONIO_ACUMULADA")] string fundo) => Usefull.Run(() => crawlerRanking.Fill <RankingModel>(fundo).rentabilidade_patrimonio_Acumulada, fundo);
public static dynamic FII_PATRIMONIO_TOTAL([ExcelArgument(Name = "Código do Fundo", Description = "Código na B3 do Fundo Imobiliário")] string fundo) => Usefull.Run(() => crawlerFII.Fill <SiteFIIModel>(fundo).PatrimonioFundo, fundo);
public static dynamic FII_ULTIMO_YELD_PERCENTUAL([ExcelArgument(Name = "Código do Fundo", Description = "Código na B3 do Fundo Imobiliário")] string fundo) => Usefull.Run(() => crawlerFII.Fill <SiteFIIModel>(fundo).PercentualUltimoYeld, fundo);
public static dynamic FII_DY_ANO([ExcelArgument(Name = "DY_ANO", Description = "DY_ANO")] string fundo) => Usefull.Run(() => crawlerRanking.Fill <RankingModel>(fundo).DY_ano, fundo);
public static dynamic FII_LIQUIDEZDIARIA([ExcelArgument(Name = "LIQUIDEZDIARIA", Description = "LIQUIDEZDIARIA")] string fundo) => Usefull.Run(() => crawlerRanking.Fill <RankingModel>(fundo).LiquidezDiaria, fundo);
public static dynamic FII_COMPARAR_POUPANCA_12MESES([ExcelArgument(Name = "Código do Fundo", Description = "Código na B3 do Fundo Imobiliário")] string fundo) => Usefull.Run(() => crawlerFound.Fill <FundsExplorerModel>(fundo).ComparacaoPoupanca, fundo);
public static dynamic FII_DIVIDENDYELD([ExcelArgument(Name = "DIVIDENDYELD", Description = "DIVIDENDYELD")] string fundo) => Usefull.Run(() => crawlerRanking.Fill <RankingModel>(fundo).DividendYeld, fundo);
public static dynamic FII_DY_12M_MEDIA([ExcelArgument(Name = "DY_12M_MEDIA", Description = "DY_12M_MEDIA")] string fundo) => Usefull.Run(() => crawlerRanking.Fill <RankingModel>(fundo).DY_12M_Media, fundo);
private List <Product> SetupProductList() { List <Product> result = new List <Product>(); #region Products creation Product product1 = new Cold(); product1.Id = 1; product1.Name = "product 1"; product1.Price = new Decimal(10); result.Add(product1); Product product2 = new Consistant(); product2.Id = 2; product2.Name = "product 2"; product2.Price = new Decimal(20); result.Add(product2); Product product3 = new Fluid(); product3.Id = 3; product3.Name = "product 3"; product3.Price = new Decimal(30); result.Add(product3); Product product4 = new Hot(); product4.Id = 4; product4.Name = "product 4"; product4.Price = new Decimal(40); result.Add(product4); Product product5 = new Usefull(); product5.Id = 5; product5.Name = "product 5"; product5.Price = new Decimal(50); result.Add(product5); Product product6 = new Useless(); product6.Id = 6; product6.Name = "product 6"; product6.Price = new Decimal(60); result.Add(product6); Product product7 = new Usable(); product7.Id = 7; product7.Name = "product 7"; product7.Price = new Decimal(70); result.Add(product7); Product product8 = new Cold(); product8.Id = 8; product8.Name = "product 8"; product8.Price = new Decimal(80); result.Add(product8); Product product9 = new Cold(); product9.Id = 9; product9.Name = "product 9"; product9.Price = new Decimal(90); result.Add(product9); Product product10 = new Cold(); product10.Id = 10; product10.Name = "product 10"; product10.Price = new Decimal(100); result.Add(product10); #endregion return(result); }
public static dynamic FII_DATA_REGISTRO_CVM([ExcelArgument(Name = "Código do Fundo", Description = "Código na B3 do Fundo Imobiliário")] string fundo) => Usefull.Run(() => crawlerFII.Fill <SiteFIIModel>(fundo).DataRegistroCVM, fundo);