Exemplo n.º 1
0
        private void gvlHistory_MasterRowGetChildList(object sender, DevExpress.XtraGrid.Views.Grid.MasterRowGetChildListEventArgs e)
        {
            GridView view = sender as GridView;
            MTSymbol c    = (MTSymbol)view.GetRow(e.RowHandle);
            BindingList <MTHistoryM> bindingHistory = new BindingList <MTHistoryM>(c.MTHistoryMS.ToList());

            bindingSource.DataSource = bindingHistory;

            e.ChildList = bindingSource;

            MTProviderEntities db1         = new MTProviderEntities();
            IList <MTHistoryM> mtHistoryMS = db1.MTHistoryMS.Where(a => a.Symbol == c.Name).ToList();

            foreach (MTHistoryM mtHistory in mtHistoryMS)
            {
                MTHistoryM mtHistoryMSOld = c.MTHistoryMS.Where(a => a.ID == mtHistory.ID).FirstOrDefault();

                if (mtHistory.AllTicks != mtHistoryMSOld.AllTicks)
                {
                    mtHistoryMSOld.AllTicks = mtHistory.AllTicks;
                }
                if (mtHistory.MyTicks != mtHistoryMSOld.MyTicks)
                {
                    mtHistoryMSOld.MyTicks = mtHistory.MyTicks;
                }
            }

            //e.ChildList = bindingHistory;
        }
Exemplo n.º 2
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            MTProviderEntities db1         = new MTProviderEntities();
            IList <MTHistoryM> mtHistoryMS = db1.MTHistoryMS /*.Where(a => a.AllTicks != a.MyTicks || a.AllTicks == 0)*/.ToList();

            while (mtHistoryMS.Count != 0)
            {
                if (worker.CancellationPending == true)
                {
                    e.Cancel = true;
                    break;
                }
                else
                {
                    // Perform a time consuming operation and report progress.
                    System.Threading.Thread.Sleep(1000);
                    BindingList <MTHistoryM> mtHistoryMSOlds = this.bindingSource.DataSource as BindingList <MTHistoryM>;
                    if (mtHistoryMSOlds != null)
                    {
                        foreach (MTHistoryM mtHistory in mtHistoryMS)
                        {
                            foreach (GridView gridView in gvControlHistory.ViewCollection)
                            {
                                int rowHandle = gridView.LocateByValue("ID", mtHistory.ID);
                                if (rowHandle != DevExpress.XtraGrid.GridControl.InvalidRowHandle)
                                {
                                    MTHistoryM mtHistoryMSOld = mtHistoryMSOlds.Where(a => a.ID == mtHistory.ID).FirstOrDefault();
                                    if ((mtHistory.AllTicks != mtHistoryMSOld.AllTicks) || (mtHistory.MyTicks != mtHistoryMSOld.MyTicks))
                                    {
                                        worker.ReportProgress(rowHandle, mtHistory);
                                        selGV = gridView;
                                    }
                                }
                            }



                            //MTHistoryM mtHistoryMSOld = mtHistoryMSOlds.Where(a => a.ID == mtHistory.ID).FirstOrDefault();
                            ////MTHistoryM mtHistoryMSOld = db.MTHistoryMS.Where(a => a.ID == mtHistory.ID).FirstOrDefault();

                            //if (mtHistory.AllTicks != mtHistoryMSOld.AllTicks)
                            //    mtHistoryMSOlds[0].AllTicks = mtHistory.AllTicks;
                            //if (mtHistory.MyTicks != mtHistoryMSOld.MyTicks)
                            //    mtHistoryMSOlds[0].MyTicks = mtHistory.MyTicks;



                            //iterate through each expanded grid
                            //foreach (GridView gridView in gvControlHistory.ViewCollection)
                            //{
                            //    //find row handle within grid that contains the field value you are searching for
                            //    //int rowHandle = gridView.LocateByValue("theFieldName", someObjectVal);

                            //    int rowHandle = gridView.LocateByValue("ID", mtHistory.ID);
                            //    if (rowHandle != DevExpress.XtraGrid.GridControl.InvalidRowHandle)
                            //    {
                            //        MTHistoryM mtHistoryMSOld = db.MTHistoryMS.Where(a => a.ID == mtHistory.ID).FirstOrDefault();
                            //        if (mtHistory.AllTicks != 0)
                            //            gridView.SetRowCellValue(rowHandle, "AllTicks", mtHistory.AllTicks);
                            //        if (mtHistory.MyTicks != 0)
                            //        {
                            //            gridView.SetRowCellValue(rowHandle, "MyTicks", mtHistory.MyTicks);
                            //            //mtHistoryMSOld.MyTicks = mtHistory.MyTicks;
                            //        }
                            //    }
                            //}
                        }
                    }

                    db1         = new MTProviderEntities();
                    mtHistoryMS = db1.MTHistoryMS /*.Where(a => a.AllTicks != a.MyTicks || a.AllTicks == 0)*/.ToList();
                }
            }
        }