Esempio n. 1
0
        private void tsmi_refreshPlans_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem menu = sender as ToolStripMenuItem;
            string            sort = null;

            try
            {
                // menu.Owner
                DataGridView dg = (menu.Owner as ContextMenuStrip).SourceControl as DataGridView;
                if (dg == null)
                {
                    return;
                }
                if (UseSetting == null)
                {
                    return;
                }
                DataTable dt = null;

                if (dg.Equals(this.dg_stragStatus))
                {
                    dt = StragRunPlanClass <TimeSerialData> .ToTable <StragRunPlanClass <TimeSerialData> >(UseSetting.AllRunPlannings.Values.ToList <StragRunPlanClass <TimeSerialData> >());
                }
                else if (dg.Equals(this.dg_NoCloseChances))
                {
                    //DbChanceList<T> dc = new PK10ExpectReader().getNoCloseChances<T>(null);
                    DbChanceList <T> dc = exread.getNoCloseChances <T>(null);
                    if (dc == null)
                    {
                        return;
                    }
                    dt = dc.Table;
                }
                else if (dg.Equals(this.dg_CloseChances))
                {
                    //DbChanceList<T> dc = new PK10ExpectReader().getNoCloseChances<T>(null);
                    DbChanceList <T> dc = exread.getClosedChances <T>(null, 2);
                    if (dc == null)
                    {
                        return;
                    }
                    dt   = dc.Table;
                    sort = "chanceindex desc";
                }
                else if (dg.Equals(this.dg_baseData))
                {
                    RefreshPK10Data();
                }
                else if (dg.Equals(this.dg_ExchangeList))
                {
                    RefrshStragAndPlan(true);
                }
                else if (dg.Equals(this.dg_LoginList))
                {
                    RefreshLogData(true);
                }
                else if (dg.Equals(this.dg_StragList))
                {
                    dt = BaseStragClass <TimeSerialData> .ToTable <BaseStragClass <TimeSerialData> >(UseSetting.AllStrags.Values.ToList <BaseStragClass <TimeSerialData> >());
                }
                if (dt == null)
                {
                    return;
                }
                SetDataGridDataTable(dg, dt, sort);
            }
            catch (Exception ce)
            {
                string msg = ce.Message;
            }
        }
Esempio n. 2
0
        void RefrshStragAndPlan(bool ForceRefresh = false)
        {
            try
            {
                if (UseSetting == null)
                {
                    return;
                }
                DataTable dt_strag = BaseStragClass <TimeSerialData> .ToTable <BaseStragClass <TimeSerialData> >(UseSetting.AllStrags.Values.ToList <BaseStragClass <TimeSerialData> >());

                if (dt_strag != null)
                {
                    SetDataGridDataTable(dg_StragList, dt_strag);
                }
                DataTable dt_plans = StragRunPlanClass <TimeSerialData> .ToTable <StragRunPlanClass <TimeSerialData> >(UseSetting.AllRunPlannings.Values.ToList <StragRunPlanClass <TimeSerialData> >());

                if (dt_plans != null)
                {
                    SetDataGridDataTable(dg_stragStatus, dt_plans);
                }
                DataTable dt_grps = CalcStragGroupClass <TimeSerialData> .ToTable <CalcStragGroupClass <TimeSerialData> >(UseSetting.AllRunningPlanGrps.Values.ToList <CalcStragGroupClass <TimeSerialData> >());

                if (dt_grps != null)
                {
                    SetDataGridDataTable(dg_PlanGrps, dt_grps);
                }
                DataTable dt_assetunit = AssetUnitClass.ToTable <AssetUnitClass>(UseSetting.AllAssetUnits.Values.ToList <AssetUnitClass>());
                if (dt_assetunit != null)
                {
                    SetDataGridDataTable(dg_AssetUnits, dt_assetunit);
                }
                DataTable dt_exchange = null;
                foreach (AssetUnitClass auc in UseSetting.AllAssetUnits.Values)
                {
                    ExchangeService ed = auc.getCurrExchangeServer();
                    if (ed == null)
                    {
                        //MessageBox.Show(string.Format("{0}资产单元交易服务为空!", auc.UnitName));

                        continue;
                    }
                    DataTable assetdt = ed.ExchangeDetail;
                    if (assetdt == null)
                    {
                        //MessageBox.Show(string.Format("{0}资产单元交易记录为空!", auc.UnitName));

                        continue;
                    }
                    //MessageBox.Show(string.Format("{0}有新交易记录{1}条!列数:{2}", auc.UnitName, assetdt.Rows.Count,assetdt.Columns.Count));

                    if (assetdt != null)
                    {
                        if (dt_exchange == null)
                        {
                            dt_exchange = assetdt.Clone();
                        }
                        for (int i = 0; i < assetdt.Rows.Count; i++)
                        {
                            dt_exchange.Rows.Add(assetdt.Rows[i].ItemArray);
                        }
                    }
                }
                //MessageBox.Show(dt_exchange.Rows.Count.ToString());
                if (dt_exchange != null)
                {
                    SetDataGridDataTable(dg_ExchangeList, dt_exchange, "createtime desc");
                }
                if (UseSetting.AllAssetUnits != null)
                {
                    lock (UseSetting.AllAssetUnits)
                    {
                        refresh_AssetChart();
                    }
                }
            }
            catch (Exception e)
            {
                string msg = string.Format("{0}:{1}", e.Message, e.StackTrace);
                if (ForceRefresh)
                {
                    MessageBox.Show(msg);
                }
            }
        }