Esempio n. 1
0
        private void processDatePrices()
        {
            int processIndex = 0;

            foreach (var item in dayprices)
            {
                this.Dispatcher.BeginInvoke((Action) delegate()
                {
                    textCurrentProcess.Text = "处理符号: " + item.Key;
                    progressBar.Maximum     = dayprices.Count;
                    progressBar.Value       = processIndex;
                });
                processIndex++;


                int symbolIndex = symbols.IndexOf(item.Key);
                var items       = item.Value;

                foreach (var i in items)
                {
                    var dt = i.date;

                    if (datesImported.Contains(dt))
                    {
                        continue;//already in continue.
                    }

                    DatePrice[] prices = null;



                    if (!dateprices.ContainsKey(dt))
                    {
                        var cnt = symbols.Count;
                        prices = new DatePrice[cnt];
                        dateprices.Add(dt, prices);
                    }
                    else
                    {
                        prices = dateprices[dt];
                    }

                    prices[symbolIndex].open   = i.open;
                    prices[symbolIndex].close  = i.close;
                    prices[symbolIndex].high   = i.high;
                    prices[symbolIndex].low    = i.low;
                    prices[symbolIndex].volume = i.volume;
                    prices[symbolIndex].amount = i.amount;
                }
            }
        }
        public void AddOrUpdateDaypriceForCategory(int categoryId, double price,DateTime date)
        {
            Category category = context.Categories.Find(categoryId);
            context.Entry(category).Collection(p => p.PricePerDay).Load();
            if(category.PricePerDay.ToList().Exists(p=>p.CheckinDate==date))
            {
                category.PricePerDay.ToList().Find(p => p.CheckinDate == date).Price = price;

            }
            else
            {
                DatePrice dayPrice = new DatePrice(){CheckinDate=date,Price=price};
                context.Categories.Find(categoryId).PricePerDay.Add(dayPrice);
            }
            context.SaveChanges();
        }
        private void processDatePrices()
        {
            int processIndex = 0;
            foreach (var item in dayprices)
            {

                this.Dispatcher.BeginInvoke((Action)delegate()
                {
                    textCurrentProcess.Text = "处理符号: " + item.Key;
                    progressBar.Maximum = dayprices.Count;
                    progressBar.Value = processIndex;
                });
                processIndex++;


                int symbolIndex = symbols.IndexOf(item.Key);
                var items = item.Value;

                foreach (var i in items)
                {
                    var dt = i.date;

                    if (datesImported.Contains(dt))
                    {
                        continue;//already in continue.
                    }

                    DatePrice[] prices = null;

                 

                    if (!dateprices.ContainsKey(dt))
                    {
                        var cnt = symbols.Count;
                        prices = new DatePrice[cnt];
                        dateprices.Add(dt, prices);
                    }
                    else
                    {
                        prices = dateprices[dt];
                    }

                    prices[symbolIndex].open = i.open;
                    prices[symbolIndex].close = i.close;
                    prices[symbolIndex].high = i.high;
                    prices[symbolIndex].low = i.low;
                    prices[symbolIndex].volume = i.volume;
                    prices[symbolIndex].amount = i.amount;

                }
            }
        }