Пример #1
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.ThreadExit      += new EventHandler(Application_ThreadExit);
            //AppContext.AppConnect();

            Console.WriteLine(Application.CommonAppDataPath);
            Console.WriteLine(Application.LocalUserAppDataPath);
            Console.WriteLine(Application.ExecutablePath);
            Console.WriteLine(Application.StartupPath);
            Console.WriteLine(Application.UserAppDataPath);
            Console.WriteLine(Application.UserAppDataRegistry);

            LogUtil.init(true, true, true, true);
            LogUtil.Info("\n\n ####################################################### \n\n ");

            Console.WriteLine(" LoadingForm loadingForm = new LoadingForm(); ");
            AppConst.InitAppSettings();
            LoadingForm loadingForm = new LoadingForm();

            if (loadingForm.ShowDialog() == DialogResult.OK)
            {
                if (!AppContext.NoSubscription)
                {
                    ProviderService.Init();
                    Form mainForm = new FxpaForm();
                    Application.Run(mainForm);
                    AppContext.FxpaMain = mainForm;
                }
            }
        }
Пример #2
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);
                }
            }
        }