private void StatlListUpdate(object obj)
        {
            Dictionary <Protocol, Signal> protocolSignal = (Dictionary <Protocol, Signal>)obj;
            Protocol protocol = (Protocol)protocolSignal.Keys.First();
            Signal   signal   = (Signal)protocolSignal.Values.First();

            if (AppSetting.SYMBOLS.Contains(signal.Symbol))
            {
                if (signal.Arrow != 0 && protocol == Protocol.K0004_1)
                {
                    LogUtil.Info("StatlListUpdate signal.Arrow != 0 && protocol ==" + Protocol.K0004_1);
                    Signal[] signals = null;
                    lock (AppConst.SignalDatasLocker)
                    {
                        signals = new Signal[AppContext.SignalDatas.Count];
                        AppContext.SignalDatas.CopyTo(signals, 0);
                        Array.Sort(signals);
                    }

                    if (signals != null)
                    {
                        lock (AppConst.StatListLocker)
                        {
                            statListView.Items.Clear();
                            foreach (Signal sig in signals)
                            {
                                if (AppSetting.SYMBOLS.Contains(sig.Symbol))
                                {
                                    string       strSignal = AppUtil.GetSignalChinese(sig.Arrow);
                                    ListViewItem item      = new ListViewItem(
                                        new string[] { sig.Symbol.ToString(),
                                                       sig.ActPrice.ToString(), strSignal, sig.ActTime.ToString(), "", "", "" }, 25 + sig.Arrow);
                                    statListView.Items.Add(item);
                                }
                            }
                        }
                    }
                }
                else if (signal.ProfitPrice != 0 && protocol == Protocol.K0004_5)
                {
                    LogUtil.Info(" signal.Profit != 0  && protocol ==" + Protocol.K0004_5);
                    ListView.ListViewItemCollection items = statListView.Items;
                    for (int i = 0; i < items.Count; i++)
                    {
                        ListViewItem item = items[i];
                        if (item.SubItems.Count >= 5)
                        {
                            string   strDate = item.SubItems[3].Text ?? "";
                            DateTime actTime;
                            DateTime.TryParse(strDate, out actTime);
                            if (actTime.CompareTo(signal.ActTime) == 0)
                            {
                                lock (AppConst.StatListLocker)
                                {
                                    item.SubItems[4].Text = signal.ProfitTime.ToString();
                                    item.SubItems[5].Text = signal.ProfitPrice.ToString();
                                    item.SubItems[6].Text = signal.Profit.ToString();
                                    int count = item.SubItems.Count - 1;
                                    while (count >= 0)
                                    {
                                        item.SubItems[count].BackColor = Color.Azure;
                                        count--;
                                    }
                                    items[i] = item;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
        public override void Receive(object msg)
        {
            string[] msgs = (string[])msg;

            Protocol protocol    = AppUtil.ParseProtocol(msgs[1]);
            int      paramAmount = AppUtil.StringToInt(msgs[2]);

            if (protocol != Protocol.UNKNOWN)
            {
                if (msgs.Length >= 4)
                {
                    LogUtil.Info(" Signal content " + msgs[3]);
                    string[] info = msgs[3].Split(',');
                    if (info.Length >= 2)
                    {
                        Interval interval = AppUtil.StringToInterval(info[0]);
                        Symbol   symbol   = AppUtil.ParseSymbol(info[1]);
                        try
                        {
                            switch (protocol)
                            {
                            case Protocol.K0004_1:     // Arrow Signal
                                if (!AppContext.IsReconnecting && AppContext.IsPriceListInitialized &&
                                    AppContext.IsSignalListInitialized)
                                {
                                    if (!msgs.Contains(NULL))
                                    {
                                        Signal signal = new Signal();
                                        signal.Interval      = interval;
                                        signal.Symbol        = symbol;
                                        signal.ActPrice      = double.Parse(info[2]);
                                        signal.Arrow         = int.Parse(info[3]);
                                        signal.ActTime       = DateTime.Parse(info[4]);
                                        signal.StopLossPrice = double.Parse(info[5]);
                                        Console.WriteLine(Protocol.K0004_1 + "  " + signal);
                                        LogUtil.Info(Protocol.K0004_1 + "  " + signal);
                                        if (AppSetting.SYMBOLS.Contains(signal.Symbol) && AppSetting.INTEVALS.Contains(signal.Interval))
                                        {
                                            SignalProcess(signal, protocol);
                                        }
                                    }
                                }
                                break;

                            case Protocol.K0004_2:      // Stop Loss Signal
                                if (!AppContext.IsReconnecting && AppContext.IsPriceListInitialized &&
                                    AppContext.IsSignalListInitialized)
                                {
                                    if (!msgs.Contains(NULL))
                                    {
                                        Signal signal = new Signal();
                                        signal.Interval         = interval;
                                        signal.Symbol           = symbol;
                                        signal.StopLossBidPrice = double.Parse(info[2]);
                                        signal.StopLoss         = int.Parse(info[3]);
                                        signal.Arrow            = int.Parse(info[3]);
                                        signal.StopLossTime     = DateTime.Parse(info[4]);
                                        signal.ActTime          = DateTime.Parse(info[5]);
                                        Console.WriteLine(Protocol.K0004_2 + "  " + signal);
                                        LogUtil.Info(Protocol.K0004_2 + "  " + signal);
                                        if (signal.StopLossBidPrice > 0 && signal.StopLoss != 0)
                                        {
                                            SignalProcess(signal, protocol);
                                        }
                                    }
                                }
                                break;

                            case Protocol.K0004_3:      // Gain Tip Signal
                                if (!AppContext.IsReconnecting && AppContext.IsPriceListInitialized &&
                                    AppContext.IsSignalListInitialized)
                                {
                                    if (!msgs.Contains(NULL))
                                    {
                                        Signal signal = new Signal();
                                        signal.Interval     = interval;
                                        signal.Symbol       = symbol;
                                        signal.GainTip      = int.Parse(info[2]);
                                        signal.Arrow        = int.Parse(info[2]);
                                        signal.GainTipTime  = DateTime.Parse(info[3]);
                                        signal.ActTime      = DateTime.Parse(info[4]);
                                        signal.GainTipPrice = double.Parse(info[5]);
                                        Console.WriteLine(Protocol.K0004_3 + "  " + signal);
                                        LogUtil.Info(Protocol.K0004_3 + "  " + signal);
                                        if (signal.GainTipPrice > 0)
                                        {
                                            SignalProcess(signal, protocol);
                                        }
                                    }
                                }
                                break;

                            case Protocol.K0004_4:      // Stop Gain Signal
                                if (!AppContext.IsReconnecting && AppContext.IsPriceListInitialized &&
                                    AppContext.IsSignalListInitialized)
                                {
                                    if (!msgs.Contains(NULL))
                                    {
                                        Signal signal = new Signal();
                                        signal.Interval      = interval;
                                        signal.Symbol        = symbol;
                                        signal.StopGainPrice = double.Parse(info[2]);
                                        signal.StopGain      = int.Parse(info[3]);
                                        signal.Arrow         = int.Parse(info[3]);
                                        signal.StopGainTime  = DateTime.Parse(info[4]);
                                        signal.ActTime       = DateTime.Parse(info[5]);
                                        Console.WriteLine(Protocol.K0004_4 + "  " + signal);
                                        LogUtil.Info(Protocol.K0004_4 + "  " + signal);
                                        if (signal.StopGainPrice > 0)
                                        {
                                            SignalProcess(signal, protocol);
                                        }
                                    }
                                }
                                break;

                            case Protocol.K0004_5:      // Profit Signal
                                if (!AppContext.IsReconnecting && AppContext.IsPriceListInitialized &&
                                    AppContext.IsSignalListInitialized)
                                {
                                    if (!msgs.Contains(NULL))
                                    {
                                        Signal signal = new Signal();
                                        signal.Interval    = interval;
                                        signal.Symbol      = symbol;
                                        signal.Arrow       = int.Parse(info[2]);
                                        signal.ActTime     = DateTime.Parse(info[3]);
                                        signal.Profit      = int.Parse(info[4]);
                                        signal.ProfitTime  = DateTime.Parse(info[5]);
                                        signal.ProfitPrice = double.Parse(info[6]);
                                        Console.WriteLine(Protocol.K0004_5 + "  " + signal);
                                        LogUtil.Info(Protocol.K0004_5 + "  " + signal);
                                        if (signal.ProfitPrice > 0)
                                        {
                                            SignalProcess(signal, protocol);
                                        }
                                    }
                                }
                                break;
                            }
                        }
                        catch (Exception e)
                        {
                            LogUtil.Error(" Protocol " + protocol.ToString() + e.StackTrace);
                        }
                    }
                }
            }
        }
        private void SignalProcess(Signal signal, Protocol protocol)
        {
            Console.WriteLine(" Before Invoke control update ......   " + signal);
            bool dupli   = false;
            bool isValid = false;

            for (int i = 0; i < AppContext.SignalDatas.Count; i++)
            {
                Signal sig = AppContext.SignalDatas[i];
                if (signal.Equals(sig))
                {
                    if (signal.Arrow == sig.Arrow && protocol == Protocol.K0004_1)
                    {
                        dupli = true;
                    }
                    else if (signal.StopLoss == sig.StopLoss && protocol == Protocol.K0004_2)
                    {
                        dupli = true;
                    }
                    else if (signal.GainTip == sig.GainTip && protocol == Protocol.K0004_3)
                    {
                        dupli = true;
                    }
                    else if (signal.StopGain == sig.StopGain && protocol == Protocol.K0004_4)
                    {
                        dupli = true;
                    }
                    else if (signal.ProfitPrice == sig.ProfitPrice && protocol == Protocol.K0004_5)
                    {
                        dupli = true;
                    }
                    else
                    {
                        if (signal.StopLoss != 0)
                        {
                            sig.StopLoss = signal.StopLoss; sig.StopLossTime = signal.StopLossTime; sig.StopLossBidPrice = signal.StopLossBidPrice; isValid = true;
                        }
                        else if (signal.GainTip != 0)
                        {
                            sig.GainTip = signal.GainTip; sig.GainTipPrice = signal.GainTipPrice; sig.GainTipTime = signal.GainTipTime; isValid = true;
                        }
                        else if (signal.StopGain != 0)
                        {
                            sig.StopGain = signal.StopGain; sig.StopGainPrice = signal.StopGainPrice; sig.StopGainTime = signal.StopGainTime; isValid = true;
                        }
                        else if (signal.ProfitPrice > 0)
                        {
                            sig.Profit = signal.Profit; sig.ProfitPrice = signal.ProfitPrice; sig.ProfitTime = signal.ProfitTime; isValid = true;
                            DataProvider provider = DataService.GetProviderBySymbol(signal.Symbol);
                            if (provider != null && !provider.DataCache.SignalUnits[provider.CurrentTInterval].Contains(sig))
                            {
                                provider.DataCache.SignalUnits[provider.CurrentTInterval].Add(sig);
                            }
                        }
                        AppContext.SignalDatas[i] = sig;
                        LogUtil.Info(" AppContext.SignalDatas[i]  " + i + "  " + AppContext.SignalDatas[i]);
                    }
                    LogUtil.Info(" dupli ==============  " + dupli);
                    break;
                }
                if (i == AppContext.SignalDatas.Count - 1 && !dupli)
                {
                    isValid = true;
                }
            }

            if (!dupli)
            {
                if (protocol == Protocol.K0004_1)
                {
                    AppContext.SignalDatas.Add(signal);
                }

                if (isValid)
                {
                    Dictionary <Protocol, Signal> protocolSignal = new Dictionary <Protocol, Signal>();
                    protocolSignal.Add(protocol, signal);
                    MsgUpdatedDelegate d = null;
                    if (protocol != Protocol.K0004_5)
                    {
                        d = new MsgUpdatedDelegate(ProviderUpdate);
                        d.Invoke(protocolSignal);
                    }
                    if (protocol != Protocol.K0004_2 && protocol != Protocol.K0004_3)
                    {
                        d = new MsgUpdatedDelegate(SignalListUpdate);
                        signalListView.BeginInvoke(d, protocolSignal);
                    }
                    if (protocol == Protocol.K0004_5 || protocol == Protocol.K0004_1)
                    {
                        d = new MsgUpdatedDelegate(PriceListUpdate);
                        priceListView.BeginInvoke(d, protocolSignal);
                    }
                    if (protocol == Protocol.K0004_5 || protocol == Protocol.K0004_1)
                    {
                        d = new MsgUpdatedDelegate(StatlListUpdate);
                        statListView.BeginInvoke(d, protocolSignal);
                    }
                }
            }
        }
        private void PriceListUpdate(object obj)
        {
            Dictionary <Protocol, Signal> protocolSignal = (Dictionary <Protocol, Signal>)obj;
            Protocol protocol = (Protocol)protocolSignal.Keys.First();
            Signal   signal   = (Signal)protocolSignal.Values.First();

            if (AppSetting.SYMBOLS.Contains(signal.Symbol))
            {
                int signalCount = 0, profit = 0;
                if (signal.Arrow != 0 && protocol == Protocol.K0004_1)
                {
                    lock (AppConst.PriceListLocker)
                    {
                        //    if (priceListView.Items[iForexIndex].SubItems.Count > 0)
                        //    {
                        //        if (string.IsNullOrEmpty(priceListView.Items[iForexIndex].SubItems[2].Text))
                        //        {
                        //            dOldForexValue = 0;
                        //        }
                        //        else
                        //        {
                        //            dOldForexValue = Convert.ToInt16(priceListView.Items[iForexIndex].SubItems[2].Text);
                        //        }
                        //        priceListView.Items[iForexIndex].SubItems[2].Text = (dOldForexValue + 1).ToString();
                        //    }
                        //}

                        for (int i = 0; i < priceListView.Items.Count; i++)
                        {
                            string strSymbol = priceListView.Items[i].SubItems[0].Text;
                            Symbol symbol    = signal.Symbol;
                            string cnSymbol  = AppConst.AppCnSymbols[symbol];
                            if (cnSymbol != null && strSymbol != null && cnSymbol.Trim() == strSymbol.Trim())
                            {
                                string c = priceListView.Items[i].SubItems[2].Text;
                                signalCount = !string.IsNullOrEmpty(c) ? Convert.ToInt16(c) : 0;
                                priceListView.Items[i].SubItems[2].Text = (signalCount + 1).ToString();
                                break;
                            }
                        }
                    }
                }
                else if (signal.ProfitPrice != 0 && protocol == Protocol.K0004_5)
                {
                    LogUtil.Info(" Protocol :  " + Protocol.K0004_5);
                    lock (AppConst.PriceListLocker)
                    {
                        //if (priceListView.Items[iForexIndex].SubItems.Count > 0)
                        //{
                        //    if (string.IsNullOrEmpty(priceListView.Items[iForexIndex].SubItems[3].Text))
                        //    {
                        //        dOldForexValue = 0;
                        //    }
                        //    else
                        //    {
                        //        dOldForexValue = Convert.ToInt16(priceListView.Items[iForexIndex].SubItems[3].Text);
                        //    }
                        //    LogUtil.Info(" dOldForexValue :  " + dOldForexValue);
                        //    priceListView.Items[iForexIndex].SubItems[3].Text = (dOldForexValue + signal.Profit).ToString();
                        //}

                        for (int i = 0; i < priceListView.Items.Count; i++)
                        {
                            string strSymbol = priceListView.Items[i].SubItems[0].Text;
                            Symbol symbol    = signal.Symbol;
                            string cnSymbol  = AppConst.AppCnSymbols[symbol];
                            if (cnSymbol != null && strSymbol != null && cnSymbol.Trim() == strSymbol.Trim())
                            {
                                lock (AppConst.PriceListLocker)
                                {
                                    string p = priceListView.Items[i].SubItems[3].Text;
                                    profit = !string.IsNullOrEmpty(p) ? Convert.ToInt16(p) : 0;
                                    priceListView.Items[i].SubItems[3].Text = (profit + signal.Profit).ToString();
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
 public override void Send(object msg)
 {
     Console.WriteLine(" LogOutHandler  Send ~~~~~~~~~~~ ");
     LogUtil.Info(" LogOutHandler  Send ~~~~~~~~~~~ ");
     Client.Send(msg);
 }
示例#6
0
        public override void Receive(object msg)
        {
            Console.WriteLine(" ProviderHandler  Receive ~~~~~~~~~~~ " + provider.Symbol + "  Start  " + System.DateTime.Now.ToLongTimeString());

            if (provider != null)
            {
                string[] msgs = (string[])msg;

                Protocol protocol    = AppUtil.ParseProtocol(msgs[1]);
                int      paramAmount = AppUtil.StringToInt(msgs[2]);
                Console.WriteLine(" ProviderHandler  Receive ~~~~~~~~~~~ " + protocol);
                switch (protocol)
                {
                case Protocol.M0003_1:
                    Execute();
                    if (paramAmount > 0 && !msgs.Contains <string>(NULL))
                    {
                        List <BarData> rtdDatas = new List <BarData>();
                        AppUtil.ParseRtd(ref rtdDatas, 3, msgs, protocol);
                        if (rtdDatas.Count > 0)
                        {
                            provider.StartTime = rtdDatas[rtdDatas.Count - 1].DateTime.Add(AppConst.AppTimeSpans[provider.CurrentTInterval]);
                            provider.DataCache.InitDataUnits(rtdDatas);
                            provider.InitCdlStatus = DataInitStatus.Initialized;
                        }
                        LogUtil.Info(" C0003_1  ::::: URL count " + rtdDatas.Count);
                    }
                    else
                    {
                        provider.HisUri           = null;
                        provider.StartTime        = provider.LocalLastCdlTime;
                        provider.CdlLoadingStatus = DownloadStatus.Finished;
                        provider.InitCdlStatus    = DataInitStatus.Initialized;
                    }
                    IsGetHisInfo = true;
                    Execute();
                    //provider.DataCache.StartTime = provider.StartTime;
                    //provider.DataCache.Init();
                    Process(null);
                    break;

                case Protocol.C0003_2:
                    if (paramAmount != AppUtil.PARSE_ERROR && paramAmount > 0)
                    {
                        List <BarData> rtdDatas = new List <BarData>();
                        AppUtil.ParseRtd(ref rtdDatas, 3, msgs, protocol);
                        provider.LatesRtds        = rtdDatas;
                        provider.RtdLoadingStatus = DownloadStatus.Finished;
                        provider.InitRtdStatus    = DataInitStatus.Initialized;
                    }
                    else
                    {
                        provider.RtdLoadingStatus = DownloadStatus.Failed;
                        provider.InitRtdStatus    = DataInitStatus.Initialized;
                    }
                    IsGetRealTimeInfo = true;
                    break;

                case Protocol.C0004_2:
                    if (paramAmount > 0)
                    {
                        List <Signal> sigalList = new List <Signal>();
                        for (int i = 3; i < msgs.Length; i++)
                        {
                            string signalInfo = msgs[i];
                            if (!string.IsNullOrEmpty(signalInfo))
                            {
                                string[] info   = signalInfo.Split(',');
                                Signal   signal = new Signal();
                                signal.Interval      = AppUtil.StringToInterval(info[0]);
                                signal.Symbol        = AppUtil.ParseSymbol(info[1]);
                                signal.ActPrice      = double.Parse(info[2]);
                                signal.Arrow         = AppUtil.StringToInt(info[3]);
                                signal.ActTime       = DateTime.Parse(info[4]);
                                signal.StopLossPrice = double.Parse(info[5]);
                                if (NULL != info[6])
                                {
                                    signal.StopLossTime     = DateTime.Parse(info[6]);
                                    signal.StopLoss         = signal.Arrow;
                                    signal.StopLossBidPrice = double.Parse(info[13]);
                                }
                                signal.GainTipPrice = double.Parse(info[7]);
                                if (NULL != info[8])
                                {
                                    signal.GainTipTime = DateTime.Parse(info[8]);
                                    signal.GainTip     = signal.Arrow;
                                }
                                signal.StopGainPrice = double.Parse(info[9]);
                                if (NULL != info[10])
                                {
                                    signal.StopGainTime = DateTime.Parse(info[10]);
                                    signal.StopGain     = signal.Arrow;
                                }
                                signal.Profit = int.Parse(info[11]);
                                if (signal.Profit != 0 && NULL != info[12])
                                {
                                    signal.ProfitTime = DateTime.Parse(info[12]);
                                }
                                signal.ProfitPrice = double.Parse(info[13]);
                                sigalList.Add(signal);
                            }
                        }
                        //provider.SignalList = sigalList;
                        //AppContext.FirstDataProvider.DataCache.InitSignalUnits(sigalList);
                        provider.DataCache.InitSignalUnits(sigalList);
                    }
                    provider.InitSigStatus = DataInitStatus.Initialized;
                    IsGetSignalInfo        = true;
                    break;

                default:
                    IsGetHisInfo              = true;
                    provider.HisUri           = null;
                    provider.StartTime        = provider.LocalLastCdlTime;
                    provider.CdlLoadingStatus = DownloadStatus.Failed;
                    provider.InitCdlStatus    = DataInitStatus.Initialized;
                    IsGetRealTimeInfo         = true;
                    provider.RtdLoadingStatus = DownloadStatus.Failed;
                    provider.InitRtdStatus    = DataInitStatus.Initialized;
                    IsProcessing              = false;
                    break;
                }
                Console.WriteLine(" ProviderHandler  Receive ~~~~~~~~~~~ " + provider.Symbol + "  After operation  " + System.DateTime.Now.ToLongTimeString());
            }
        }
示例#7
0
        public override void Receive(object msg)
        {
            Console.WriteLine(" TimeCheckHandler  Receive ~~~~~~~~~~~ " + msg);
            string[] msgs = (string[])msg;

            Protocol protocol    = AppUtil.ParseProtocol(msgs[1]);
            int      paramAmount = AppUtil.StringToInt(msgs[2]);

            if (protocol != Protocol.UNKNOWN)
            {
                try
                {
                    switch (protocol)
                    {
                    case Protocol.S0002_1:
                        string   strServerTime = msgs[3];
                        DateTime serverTime;
                        serverTime = DateTime.Parse(strServerTime);

                        if (FXPA != null && !FXPA.IsDisposed)
                        {
                            if (!msgs.Contains(NULL))
                            {
                                if (serverTime.CompareTo(AppSetting.END_TIME) > 0)
                                {
                                    errCode = -1;
                                    MethodInvoker mi = new MethodInvoker(ShowErrorMsg);
                                    FXPA.BeginInvoke(mi);

                                    mi = new MethodInvoker(CloseApp);
                                    FXPA.BeginInvoke(mi);
                                }
                            }
                        }

                        int DAY = Convert.ToInt16(serverTime.Day);
                        AppContext.CURRENT_TIME = serverTime;

                        DateTime startTimeOfNormalDay = AppUtil.GetStartTimeOfNormalDay(AppContext.CURRENT_TIME);

                        if (DAY > LogUtil.DAY && serverTime.CompareTo(startTimeOfNormalDay) > 0)
                        {
                            MethodInvoker mi = new MethodInvoker(TimeLabelUpdate);
                            AppContext.TradeExpertControl.BeginInvoke(mi);
                            LogUtil.DAY = DAY;
                            LogUtil.Close();
                            LogUtil.init(true, true, true, true);
                        }
                        else if (DAY > AppContext.DAY)
                        {
                            AppContext.DAY = DAY;
                            DateTime      startTimeOfWeek   = AppUtil.GetStartTimeOfWeek(AppContext.CURRENT_TIME);
                            DateTime      startTimeOfBizDay = AppUtil.GetStartTimeOfBizToday(AppContext.CURRENT_TIME);
                            List <Signal> obsoletes         = new List <Signal>();
                            if (AppSetting.STATUS == AppSetting.TEST_ACCOUNT && serverTime.CompareTo(startTimeOfWeek) > 0)
                            {
                                if (AppContext.SignalDatas.Count > 0)
                                {
                                    lock (AppConst.SignalDatasLocker)
                                    {
                                        foreach (Signal signal in AppContext.SignalDatas)
                                        {
                                            if (signal.ProfitPrice != 0 && signal.ProfitTime.CompareTo(startTimeOfWeek) < 0)
                                            {
                                                obsoletes.Add(signal);
                                            }
                                        }
                                        foreach (Signal signal in obsoletes)
                                        {
                                            AppContext.SignalDatas.Remove(signal);
                                        }
                                    }
                                }
                            }
                            else if (serverTime.CompareTo(startTimeOfBizDay) > 0)
                            {
                                if (AppContext.SignalDatas.Count > 0)
                                {
                                    lock (AppConst.SignalDatasLocker)
                                    {
                                        foreach (Signal signal in AppContext.SignalDatas)
                                        {
                                            if (signal.ProfitPrice != 0 && signal.ProfitTime.CompareTo(startTimeOfBizDay) < 0)
                                            {
                                                obsoletes.Add(signal);
                                            }
                                        }
                                        foreach (Signal signal in obsoletes)
                                        {
                                            AppContext.SignalDatas.Remove(signal);
                                        }
                                    }
                                }
                            }

                            if (obsoletes != null && obsoletes.Count > 0)
                            {
                                MethodInvoker mi = new MethodInvoker(SignalListUpdate);
                                signalListView.BeginInvoke(mi);
                                mi = new MethodInvoker(StatListUpdate);
                                AppContext.StatListView.BeginInvoke(mi);
                                mi = new MethodInvoker(PriceListUpdate);
                                priceListView.BeginInvoke(mi);
                            }

                            obsoletes.Clear();
                            List <PublishInfo> obsoletes2 = new List <PublishInfo>();
                            if (AppContext.PublishInfos.Count > 0)
                            {
                                lock (AppContext.PublishInfos)
                                {
                                    foreach (PublishInfo info in AppContext.PublishInfos)
                                    {
                                        if (AppContext.CURRENT_TIME.Subtract(info.DateTime) > AppConst.AppTimeSpans[Interval.DAY1])
                                        {
                                            obsoletes2.Add(info);
                                        }
                                    }

                                    foreach (PublishInfo info in obsoletes2)
                                    {
                                        AppContext.PublishInfos.Remove(info);
                                    }
                                    if (obsoletes2 != null && obsoletes2.Count > 0)
                                    {
                                        MethodInvoker mi = new MethodInvoker(InfoListUpdate);
                                        infoListView.BeginInvoke(mi);
                                    }
                                }
                            }
                            obsoletes2.Clear();
                        }
                        break;
                    }
                }
                catch (Exception e)
                {
                    LogUtil.Info(" TimeCheckHandler  Receive  Exception~~~~~~~~~~~ " + e.StackTrace);
                }
            }
        }
        public bool LoadSigFile(string fileName, int startingRow, int rowsLimit, out List <Signal> datas, bool isDecrypt, bool isLocal)
        {
            datas = new List <Signal>();

            int i = 0;

            using (System.IO.TextReader tr = new System.IO.StreamReader(fileName))
            {
                try
                {
                    for (i = 0; i < startingRow + rowsLimit || rowsLimit == 0; i++)
                    {
                        string lineStr = tr.ReadLine();
                        if (lineStr == null)
                        {
                            break;
                        }

                        if (i >= startingRow)
                        {// Parse.
                         //if (isDecrypt)
                         //{
                         //    if (!isLocal)
                         //        lineStr = crypta.decrypt(lineStr);
                         //    else
                         //        lineStr = crypta.localDecrypt(lineStr);
                         //}

                            try
                            {
                                string[] lineSplit = Regex.Split(lineStr, ",");
                                Signal   signal    = new Signal();
                                signal.ActTime      = DateTime.Parse(lineSplit[0]);
                                signal.Arrow        = int.Parse(lineSplit[1]);
                                signal.ActPrice     = double.Parse(lineSplit[2]);
                                signal.GainTip      = int.Parse(lineSplit[3]);
                                signal.GainTipPrice = double.Parse(lineSplit[4]);
                                if (lineSplit[5] != NULL)
                                {
                                    signal.GainTipTime = DateTime.Parse(lineSplit[5]);
                                }
                                signal.StopGain      = int.Parse(lineSplit[6]);
                                signal.StopGainPrice = double.Parse(lineSplit[7]);
                                if (lineSplit[8] != NULL)
                                {
                                    signal.StopGainTime = DateTime.Parse(lineSplit[8]);
                                }
                                signal.StopLoss      = int.Parse(lineSplit[9]);
                                signal.StopLossPrice = double.Parse(lineSplit[10]);
                                if (lineSplit[11] != NULL)
                                {
                                    signal.StopLossTime     = DateTime.Parse(lineSplit[11]);
                                    signal.StopLossBidPrice = double.Parse(lineSplit[13]);
                                }
                                signal.Profit      = int.Parse(lineSplit[12]);
                                signal.ProfitPrice = double.Parse(lineSplit[13]);
                                if (lineSplit[14] != NULL)
                                {
                                    signal.ProfitTime = DateTime.Parse(lineSplit[14]);
                                }
                                LogUtil.Info(" Sig File Loading :::: " + signal);
                                datas.Add(signal);
                            }
                            catch (Exception e)
                            {
                                LogUtil.Info(" His File Loading :::: " + e.StackTrace);
                            }
                        }
                    }
                    Console.WriteLine("ccccccccccccccccccccccccccc  ");
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception.ToString());
                    datas.Clear();
                    return(false);
                }
            }
            return(true);
        }
        public bool LoadCdlFile(string fileName, int startingRow, int rowsLimit, out List <BarData> datas, bool isDecrypt, bool isLocal)
        {
            datas = new List <BarData>();

            int i = 0;

            using (System.IO.TextReader tr = new System.IO.StreamReader(fileName))
            {
                try
                {
                    for (i = 0; i < startingRow + rowsLimit || rowsLimit == 0; i++)
                    {
                        string lineStr = tr.ReadLine();
                        if (lineStr == null)
                        {
                            break;
                        }

                        if (i >= startingRow)
                        {// Parse.
                         //if (isDecrypt)
                         //{
                         //    if( !isLocal)
                         //        lineStr = crypta.decrypt(lineStr);
                         //    else
                         //        lineStr = crypta.localDecrypt(lineStr);
                         //}

                            try
                            {
                                string[] lineSplit = Regex.Split(lineStr, ",");
                                BarData  barData   = new BarData();
                                string   date      = lineSplit[0].Trim();
                                string   time      = lineSplit[1].Trim();
                                barData.DateTime = new DateTime(int.Parse(date.Substring(0, 4)), int.Parse(date.Substring(4, 2)), int.Parse(date.Substring(6, 2)),
                                                                int.Parse(time.Substring(0, 2)), int.Parse(time.Substring(2, 2)), int.Parse(time.Substring(4, 2))); //DateTime.Parse(lineSplit[0]);//  BarDataHelper.ParseCSVDateTime(lineSplit[0], lineSplit[1]);
                                barData.Open        = double.Parse(lineSplit[2], new System.Globalization.NumberFormatInfo());
                                barData.High        = double.Parse(lineSplit[3], new System.Globalization.NumberFormatInfo());
                                barData.Low         = double.Parse(lineSplit[4], new System.Globalization.NumberFormatInfo());
                                barData.Close       = double.Parse(lineSplit[5], new System.Globalization.NumberFormatInfo());
                                barData.ExLow       = barData.Low;
                                barData.ExHigh      = barData.ExHigh;
                                barData.IsCompleted = true;
                                LogUtil.Info(" His File Loading :::: " + barData);
                                datas.Add(barData);
                            }catch (Exception e) {
                                LogUtil.Info(" His File Loading :::: " + e.StackTrace);
                            }
                        }
                    }
                    Console.WriteLine("ccccccccccccccccccccccccccc  ");
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception.ToString());
                    datas.Clear();
                    return(false);
                }
            }

            return(true);
        }