예제 #1
0
파일: RunStrategy.cs 프로젝트: jutao023/Wes
        //加载
        private void RunStrategy_Load(object sender, EventArgs e)
        {
            output = new OutPut();
            output.Show(manSHJH.GetMainFrame().dockPanel1, DockState.DockBottomAutoHide);
            output.Text = "策略管理";
            //加载程序集
            ScanAssembly();

            //加载工程和用户信息
            ReadUserInfo();

            //设置默认选择项
            cboxSelectAccount.SelectedIndex  = 0;
            cboxSelectStrategy.SelectedIndex = 0;
        }
예제 #2
0
        public bool BeforeInit(Strategy _stag, StateNotify _sn = null, OutPut _outp = null)
        {
            if (_stag == null)
            {
                return(false);
            }
            runStrategy = _stag;
            runStrategy.SetContractID(this.contractID);
            runStrategy.SetUserInfo(this.username, this.password);
            runStrategy.SetValSign(this.valsign);
            runStrategy.SetTradeAddr(this.trade_addr, this.trade_port);
            runStrategy.SetMarketAddr(this.market_addr, this.market_port);
            runStrategy.SetHttpAddr(this.http_addr, this.http_port);

            showMessage = _outp;
            runStrategy.SetPrintMessage(_outp);

            runStrategy.SetStateNotify(_sn);
            return(true);
        }
예제 #3
0
파일: RunStrategy.cs 프로젝트: jutao023/Wes
        /**************************菜单事件***********************/
        //【启动】
        private void Start_MenuItem_Click(object sender, EventArgs e)
        {
            if (listStrategy.SelectedItems.Count <= 0)
            {
                return;
            }

            ListViewItem    lvi          = listStrategy.SelectedItems[0];
            string          filePath     = null;
            string          ClassName    = null;
            ProjectStrategy projectStrag = null;

            foreach (ProjectStrategy ps in listProjects)
            {
                if (lvi.Text == ps.username)
                {
                    filePath     = ps.fileName;
                    ClassName    = ps.strategyName;
                    projectStrag = ps;
                }
            }

            if (filePath == null || ClassName == null)
            {
                MessageBox.Show("此条记录已经失效!", "提示");
                return;
            }
            if (projectStrag == null)
            {
                return;
            }

            //运行中无法连续启动
            if (projectStrag.runFlag == EnumRunState.运行中 || projectStrag.runFlag == EnumRunState.异常 || projectStrag.runFlag == EnumRunState.超时)
            {
                return;
            }

            //判断是否存在此文件
            if (!System.IO.File.Exists(filePath))
            {
                MessageBox.Show("策略文件不存在或者被删除", "提示");
                return;
            }

            //启动
            Type typeStag = null;

            foreach (Type ty in listTypes)
            {
                if (ty.FullName == ClassName)
                {
                    typeStag = ty;
                    break;
                }
            }
            Strategy stt = null;

            try
            {
                stt = (Strategy)typeStag.Assembly.CreateInstance(typeStag.FullName);
            }catch (Exception es)
            {
                MessageBox.Show(es.Message, "提示");
                return;
            }
            OutPut op = new OutPut();

            op.Text = lvi.SubItems[1].Text;
            op.Show(manSHJH.GetMainFrame().dockPanel1, DockState.DockBottomAutoHide);
            if (!projectStrag.BeforeInit(stt, this, op))
            {
                MessageBox.Show("初始化交易模型失败!", "提示");
                return;
            }
            projectStrag.Init();
            projectStrag.runFlag = EnumRunState.运行中;
            lvi.SubItems[2].Text = EnumRunState.运行中.ToString();
        }