Пример #1
0
        //
        // GET: /ConditionalFormatting/

        public ActionResult ConditionalFormatting()
        {
            var DataSource = new StockDataContext().GetStockData;

            ViewBag.dataSource = DataSource;
            return(View());
        }
        static void Main(string[] args)
        {
            var connectionString = "";

            using (var db = new StockDataContext(connectionString))
            {
                var products = ImportProducts();

                using (var bulkCopy = new ObjectBulkCopy <Product>((SqlConnection)db.Connection))
                {
                    bulkCopy.WriteToServer(products);
                }
            }
        }
 public CompanyDetailRepository()
 {
     data = new StockDataContext();
 }
 public AuthRepository( StockDataContext context)
 {
      _context = context;
 }
        private void bConsulterStockHtml_Click(object sender, RoutedEventArgs e)
        {
            DocumentCore doc = new DocumentCore();

            doc.Content.End.Insert("Page HTML Stock\n\n", new CharacterFormat()
            {
                FontName = "Verdana"
            });


            StockDataContext DCStock = new StockDataContext();
            var requete = from stock in DCStock.StockVoiture
                          select stock;

            foreach (var aa in requete)
            {
                C_Marque    marqueTmp = new G_Marque(sConnex).Lire_ID(aa.idMarque);
                C_Modele    modeleTmp = new G_Modele(sConnex).Lire_ID(aa.idModele);
                C_Categorie catTmp    = new G_Categorie(sConnex).Lire_ID(aa.idCategorie);
                C_Carburant carbuTmp  = new G_Carburant(sConnex).Lire_ID((int)aa.idCarburant); //cast car int?
                C_Couleur   coulTmp   = new G_Couleur(sConnex).Lire_ID((int)aa.idCouleur);

                doc.Content.End.Insert("ID Véhicule :" + aa.idVoiture + "\n", new CharacterFormat()
                {
                    FontName = "Verdana"
                });
                doc.Content.End.Insert("ID Marque :" + aa.idMarque + "\tNom Marque : " + marqueTmp.nomMarque + "\n", new CharacterFormat()
                {
                    FontName = "Verdana"
                });
                doc.Content.End.Insert("ID Modèle :" + aa.idModele + "\tNom Modele : " + modeleTmp.nomModele + "\n", new CharacterFormat()
                {
                    FontName = "Verdana"
                });
                doc.Content.End.Insert("ID Catégorie :" + aa.idCategorie + "\tNom Catégorie : " + catTmp.nomCat + "\n", new CharacterFormat()
                {
                    FontName = "Verdana"
                });
                doc.Content.End.Insert("Année de fabrication :" + aa.anneeFabrication + "\n", new CharacterFormat()
                {
                    FontName = "Verdana"
                });
                doc.Content.End.Insert("ID Carburant :" + aa.idCarburant + "\tNom Carburant : " + carbuTmp.nomCarburant + "\n", new CharacterFormat()
                {
                    FontName = "Verdana"
                });
                doc.Content.End.Insert("ID Couleur :" + aa.idCouleur + "\tNom Couleur : " + coulTmp.nomCouleur + "\n", new CharacterFormat()
                {
                    FontName = "Verdana"
                });
                doc.Content.End.Insert("ID Kilometrage :" + aa.kilometrage + "\n", new CharacterFormat()
                {
                    FontName = "Verdana"
                });
                doc.Content.End.Insert("----------------------------------------------------------------------\n", new CharacterFormat()
                {
                    FontName = "Verdana"
                });
            }

            doc.Save("Stock.html");

            //Lancement du navigateur

            View.Navigateur f = new View.Navigateur();
            f.ShowDialog();
        }
Пример #6
0
 protected DefaultDisposable()
 {
     _context = new StockDataContext();
 }
Пример #7
0
        static async Task Main()
        {
            string apiHost   = ConfigurationManager.AppSettings["apihost"];
            string apiKey    = ConfigurationManager.AppSettings["apiKey"];
            string baseUrl   = ConfigurationManager.AppSettings["baseurl"];
            string symbol    = ConfigurationManager.AppSettings["stocksymbol"];
            string pathParam = "";

            WatchlistJson watchlist         = new WatchlistJson();
            var           watchlistEquities = watchlist.GetWatchlistJson();

            if (watchlistEquities != null)
            {
                foreach (var item in watchlistEquities.Equities)
                {
                    pathParam = string.Format("stock/{0}/book", item.Equity);

                    string uri = helpers.UriHelper(baseUrl, pathParam);

                    var request = new HttpRequestMessage
                    {
                        Method     = HttpMethod.Get,
                        RequestUri = new Uri(uri),
                        Headers    =
                        {
                            { "x-rapidapi-key",  apiKey  },
                            { "x-rapidapi-host", apiHost }
                        }
                    };

                    string body;
                    using (var response = await client.SendAsync(request))
                    {
                        response.EnsureSuccessStatusCode();
                        body = await response.Content.ReadAsStringAsync();
                    }

                    var result = JsonSerializer.Deserialize <JsonRootResponse>(body);

                    using (var context = new StockDataContext())
                    {
                        //if Equity already exists in database, only add row to Quote table
                        var newEquityQuery = context.Equities.Where(e => e.CompanyName == result.Quote.CompanyName).FirstOrDefault <Equity>();

                        if (newEquityQuery == null)
                        {
                            Equity equity = new Equity()
                            {
                                CompanyName = result.Quote.CompanyName,
                                Industry    = result.Quote.Industry,
                                TickerId    = result.Quote.Symbol
                            };

                            context.Equities.Add(equity);
                        }

                        var newQuoteQuery = context.Quotes.Where(q => q.TickerId == result.Quote.Symbol && q.Date == result.Quote.Date).FirstOrDefault <Quote>();

                        if (newQuoteQuery == null)
                        {
                            Quote quote = new Quote()
                            {
                                TickerId       = result.Quote.Symbol,
                                OpenPrice      = result.Quote.OpenPrice,
                                ClosePrice     = result.Quote.ClosePrice,
                                HighPriceOfDay = result.Quote.HighPriceOfDay,
                                LowPriceOfDay  = result.Quote.LowPriceOfDay,
                                AvgTotalVol    = result.Quote.AvgTotalVol,
                                Week52High     = result.Quote.Week52High,
                                Week52Low      = result.Quote.Week52Low,
                                Date           = result.Quote.Date,
                                YTDChange      = result.Quote.YTDChange,
                                QuoteId        = Guid.NewGuid().ToString()
                            };

                            context.Quotes.Add(quote);
                        }

                        context.SaveChanges();
                    }
                }
            }
        }
Пример #8
0
 public StockPriceRepository()
 {
     data = new StockDataContext();
 }