Пример #1
0
        public override void Execute()
        {
            string msg = "";

            if (AppContext.IsAppInitializing && AppContext.IsGetSignalList && AppContext.SignalDatas.Count > 0)
            {
                signals = new Signal[AppContext.SignalDatas.Count];
                AppContext.SignalDatas.CopyTo(signals);
                MethodInvoker mi = new MethodInvoker(InitPriceList);
                priceListView.Invoke(mi);
                mi = new MethodInvoker(InitSignalList);
                signalListView.Invoke(mi);
                mi = new MethodInvoker(InitStatList);
                statListView.Invoke(mi);
            }
            else if (AppContext.IsAppInitializing && AppContext.IsGetSymbolPrices && AppContext.SymbolPrices.Count > 0)
            {
                MethodInvoker mi = new MethodInvoker(InitPriceList);
                priceListView.Invoke(mi);
                AppContext.IsStatListInitialized   = true;
                AppContext.IsSignalListInitialized = true;
            }
            else
            {
                if (AppSetting.STATUS == AppSetting.TEST_ACCOUNT)  //  || AppSetting.STATUS == AppSetting.ADMIN_ACCOUNT
                {
                    msg = NetHelper.BuildMsg(Protocol.C0004_1, new string[] { "2" });
                }
                else
                {
                    msg = NetHelper.BuildMsg(Protocol.C0004_1, new string[] { "0" });
                }
                Send(msg);
            }
        }
Пример #2
0
        public override void Execute()
        {
            string request = NetHelper.BuildMsg(Protocol.C0002_2, new string[] { SUCCESS });

            //string request = NetHelper.BuildMsg(Protocol.C0011, new string[] { });
            Send(request);
        }
Пример #3
0
        private void Login()
        {
            bool isBusy   = false;
            bool finished = false;

            while (!finished)
            {
                Console.WriteLine(" request    ");
                if (AppClient.IsReady)
                {
                    AppSetting.RECONN_USER = txtusername.Text.Trim();
                    string  pwd    = txtuserpwd.Text.Trim();
                    ICrypta crypta = SecurityService.GetCrypta();
                    pwd = crypta.specialEncrypt(pwd);
                    AppSetting.RECONN_PWD = pwd;
                    string cpuSN       = SysUtil.GetSpecialStuffValueInfo(Win32Stuff.Win32_Processor.ToString(), "ProcessorId");
                    string hdID        = SysUtil.GetSpecialStuffValueInfo(Win32Stuff.Win32_DiskDrive.ToString(), "Model");
                    string machineInfo = cpuSN + "-" + hdID;
                    machineInfo = machineInfo ?? (LoginHandler.NULL);
                    machineInfo = string.IsNullOrEmpty(machineInfo.Trim()) ? LoginHandler.NULL : machineInfo.Trim();

                    AppSetting.MACHINE_INFO = machineInfo;
                    string request = NetHelper.BuildMsg(Protocol.C0001_1, new string[] { txtusername.Text.Trim(), pwd, machineInfo, AppSetting.VERSION, AppSetting.A_OR_C });
                    crypta = null;
                    Console.WriteLine(" request    " + count);
                    try
                    {
                        loginHandler.Send(request);
                        finished = true;
                    }
                    catch (Exception ex)
                    {
                        this.Invoke(new MethodInvoker(Noconnection));
                    }
                }

                count++;
                if (count >= MAX_LOGIN_TIME)
                {
                    AppClient.Close();
                    AppClient.IsStopAttempt = true;
                    isBusy = true;
                    break;
                }
                Thread.Sleep(500);
                if (isCancel)
                {
                    break;
                }
            }

            if (isBusy == true && !isCancel)
            {
                this.Invoke(new MethodInvoker(Noconnection));
            }
        }
Пример #4
0
        public override void Execute()
        {
            IsProcessing = true;

            if (AppContext.FirstDataProvider != null &&
                AppContext.TradeAnalyzerControl == null)
            {
                // TO DO
            }
            else
            {
                if (!IsGetHisInfo)
                {
                    IsGetHisInfo = true;
                    string request = "";

                    Console.WriteLine(" ProviderHandler  Send ~~~~~~~~~~~  " + Protocol.M0003_1);
                    if (provider.HasLocalLastCdlTime)
                    {
                        request = NetHelper.BuildMsg(Protocol.M0003_1, new string[] { provider.Symbol.ToString(), AppUtil.IntervalToString(provider.CurrentTInterval), provider.LocalLastCdlTime.Add(AppConst.AppTimeSpans[provider.CurrentTInterval]).ToString(FORMAT) });
                    }
                    else
                    {
                        request = NetHelper.BuildMsg(Protocol.M0003_1, new string[] { provider.Symbol.ToString(), AppUtil.IntervalToString(provider.CurrentTInterval), NULL });
                    }
                    Send(request);
                }
                else if (!IsGetSignalInfo)
                {
                    IsGetSignalInfo = true;
                    Console.WriteLine(" ProviderHandler  Send ~~~~~~~~~~~   " + Protocol.C0004_2);
                    string   request = "";
                    DateTime time    = DateTime.Now;
                    //time = time.AddMonths(-6);
                    time = DateTime.Parse("2009-09-01 00:00:00");
                    if (provider.HasLocalLastSigTime)
                    {
                        request = NetHelper.BuildMsg(Protocol.C0004_2, new string[] { provider.Symbol.ToString(), AppUtil.IntervalToString(AppContext.FirstDataProvider.CurrentTInterval), provider.LocalLastSigTime.ToString(FORMAT) });
                    }
                    else
                    {
                        request = NetHelper.BuildMsg(Protocol.C0004_2, new string[] { provider.Symbol.ToString(), AppUtil.IntervalToString(AppContext.FirstDataProvider.CurrentTInterval), time.ToString(FORMAT) });
                    }
                    Send(request);
                }
                else if (!IsGetRealTimeInfo)
                {
                    IsGetRealTimeInfo = true;
                    Console.WriteLine(" ProviderHandler  Send ~~~~~~~~~~~  " + Protocol.C0003_2);
                    string request = NetHelper.BuildMsg(Protocol.C0003_2, new string[] { provider.Symbol.ToString(), AppUtil.IntervalToString(provider.CurrentTInterval), provider.StartTime.ToString(FORMAT) });
                    Send(request);
                }
            }
        }
Пример #5
0
        public override void Execute()
        {
            DateTime now = DateTime.Now;

            count = count >= 9999 ? 0 : count;
            string token = AppSetting.USER + "_" + AppSetting.VERSION + "_" + now.Year + "." + now.Month + "." + now.Day + "." + now.Hour + "." + now.Minute + "." + now.Second + "." + count;

            count++;
            string request = NetHelper.BuildMsg(Protocol.C0002_3, new string[] { token });

            lock (AppContext.appTokenLock)
            {
                AppContext.ServToken.Add(token, MsgHandler.NULL);
            }
            Send(request);
        }
 private void btnReset_Click(object sender, EventArgs e)
 {
     if (AppClient.IsReady)
     {
         ICrypta crypta = SecurityService.GetCrypta();
         if (string.IsNullOrEmpty(textOldPwd.Text) && string.IsNullOrEmpty(textNewPwd.Text) && string.IsNullOrEmpty(textConfirmPwd.Text))
         {
             MessageBox.Show(this, "Passwords can not be empty!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else if (textNewPwd.Text.Trim() != textConfirmPwd.Text)
         {
             MessageBox.Show(this, "Re-type password is not the same as new password.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else if (crypta.specialEncrypt(textOldPwd.Text.Trim()) != AppSetting.PWD)
         {
             MessageBox.Show(this, "Old password is incorrect, please try again! ", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else if (textNewPwd.Text.Length < 6)
         {
             MessageBox.Show(this, "Password must be at least 8 characters, please try again. ", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else if (!AppUtil.PwdIsValid(textNewPwd.Text.Trim()))
         {
             MessageBox.Show(this, "Password cannot be any triple repeat characters, please try again. ", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             //string oldPwd = textOldPwd.Text.Trim();
             string newPwd = textNewPwd.Text.Trim();
             //oldPwd = crypta.specialEncrypt(oldPwd);
             newPwd = crypta.specialEncrypt(newPwd);
             string request = NetHelper.BuildMsg(Protocol.C0001_2, new string[] { AppSetting.PWD, newPwd });
             Console.WriteLine(" request    " + request);
             resetPwdHandler.Send(request);
         }
         crypta = null;
     }
     else
     {
         MessageBox.Show(this, "Network is disconnected!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        public override void Execute()
        {
            string request = NetHelper.BuildMsg(Protocol.C0001_5, new string[] {});

            Send(request);
        }
        //int errCode = 0;

        public override void Execute()
        {
            string request = NetHelper.BuildMsg(Protocol.C0001_4, new string[] { AppSetting.USER, "LOGOUT" });

            Send(request);
        }
Пример #9
0
        public override void Execute()
        {
            string request = NetHelper.BuildMsg(Protocol.C0002_4, new string[] { AppSetting.A_OR_C, AppSetting.VERSION });

            Send(request);
        }
Пример #10
0
        public void GetSignalsByTime(string time)
        {
            string request = NetHelper.BuildMsg(Protocol.C0004_1, new string[] { time });

            Send(request);
        }