Example #1
0
        /// <summary>
        /// 触发新增数据function,add
        /// </summary>
        /// <param name="id"></param>
        /// <param name="strategyname"></param>
        /// <param name="strategynumber"></param>
        /// <param name="strategypath"></param>
        /// <param name="strategyinfo"></param>
        /// <param name="strategytype"></param>
        /// <param name="creattime"></param>
        /// <param name="states"></param>
        /// <param name="remark"></param>
        /// <param name="describe"></param>
        /// <param name="isrun"></param>
        /// <returns></returns>
        public bool Add(string strategyname, string strategynumber, string strategyinfo, string strategytype, string states, string remark, string describe, string isrun)
        {
            QTStrategyStru QTStrategy = new QTStrategyStru();

            QTStrategy.strategyname   = strategyname;
            QTStrategy.strategynumber = Guid.NewGuid().ToString();
            QTStrategy.strategypath   = Path.Combine(DateTime.Now.ToString("yyyyMMdd"), QTStrategy.strategynumber);
            QTStrategy.strategyinfo   = strategyinfo;
            QTStrategy.strategytype   = strategytype;
            QTStrategy.creattime      = DateTime.Now.ToString();
            QTStrategy.states         = states;
            QTStrategy.remark         = remark;
            QTStrategy.describe       = describe;
            QTStrategy.isrun          = isrun;
            QTStrategyViewModel dataInfo = new QTStrategyViewModel();

            if (dataInfo.AddData(_appConf, QTStrategy))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 创建脚本并执行
        /// </summary>
        /// <param name="options"></param>
        /// <param name="filepath"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public string RunScript(CommConf options, string wwwrootpath, string id)
        {
            try
            {
                string         errorMsg;
                SqliteAccess   conn   = new SqliteAccess(options.AttriList.FirstOrDefault(o => o.key == "DBLink").value);
                string         strsql = string.Format(@"select * from QTStrategy where id = {0}", id);
                DataTable      dt     = conn.QueryDt(strsql, out errorMsg);
                QTStrategyStru obj    = new QTStrategyStru();
                foreach (DataRow item in dt.Rows)
                {
                    obj.strategyname   = item["strategyname"].ToString();
                    obj.strategynumber = item["strategynumber"].ToString();
                    obj.strategypath   = item["strategypath"].ToString();
                    obj.strategyinfo   = item["strategyinfo"].ToString();
                }

                Dictionary <string, string> paralist = new Dictionary <string, string>();
                string context = Common.Verify.html_txt_n(obj.strategyinfo);
                //所在文件夹路径
                string scriptpath = Path.Combine(wwwrootpath, options.AttriList.FirstOrDefault(o => o.key == "ScriptPath").value, obj.strategypath);
                //脚本完整路径
                string path = Path.Combine(scriptpath, obj.strategyname) + ".py";
                lock (Lock)
                {
                    Common.FileHelper.TxtHelper.Write_txt(scriptpath, obj.strategyname + ".py", context);
                    return(Common.CallPython.RunFile(path, paralist));
                }
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
Example #3
0
        /// <summary>
        /// 触发修改数据function,Edit/Update
        /// </summary>
        /// <param name="id"></param>
        /// <param name="strategyname"></param>
        /// <param name="strategynumber"></param>
        /// <param name="strategypath"></param>
        /// <param name="strategytype"></param>
        /// <param name="strategyinfo"></param>
        /// <param name="creattime"></param>
        /// <param name="states"></param>
        /// <param name="remark"></param>
        /// <param name="describe"></param>
        /// <param name="isrun"></param>
        /// <returns></returns>
        public bool Update(string id, string strategyname, string strategynumber, string strategypath, string strategytype, string strategyinfo, string states, string remark, string describe, string isrun)
        {
            QTStrategyStru QTStrategy = new QTStrategyStru();

            QTStrategy.strategyname   = strategyname;
            QTStrategy.strategynumber = strategynumber;
            QTStrategy.strategypath   = strategypath;
            QTStrategy.strategytype   = strategytype;
            QTStrategy.states         = states;
            QTStrategy.remark         = remark;
            QTStrategy.describe       = describe;
            QTStrategy.isrun          = isrun;
            QTStrategy.states         = states;
            QTStrategy.strategyinfo   = strategyinfo;
            QTStrategyViewModel dataInfo = new QTStrategyViewModel();

            if (dataInfo.UpdateData(_appConf, QTStrategy))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// 查询数据
        /// </summary>
        /// <returns></returns>
        public List <QTStrategyStru> GetData(CommConf options, Dictionary <string, string> Para, ref string count)
        {
            string       errorMsg;
            SqliteAccess conn   = new SqliteAccess(options.AttriList.FirstOrDefault(o => o.key == "DBLink").value);
            bool         ispara = false;
            //拼接sql查询条件
            string strPara = " where 1=1 and ";

            foreach (var item in Para)
            {
                if (!string.IsNullOrEmpty(item.Value) && item.Key != "page" && item.Key != "limit")
                {
                    strPara += item.Key + "='" + item.Value + "' and ";
                    ispara   = true;
                }
            }
            strPara = strPara.Substring(0, strPara.Length - 4);
            string                strsql   = string.Format(@"select * from(select * from (select * from QTStrategy {0} order by id asc limit {1})
            order by id desc limit {2}) order by id asc", strPara, int.Parse(Para["page"]) * int.Parse(Para["limit"]), Para["limit"]);
            DataTable             dt       = conn.QueryDt(strsql, out errorMsg);
            QTStrategyStru        obj      = new QTStrategyStru();
            List <QTStrategyStru> DataList = new List <QTStrategyStru>();

            foreach (DataRow item in dt.Rows)
            {
                obj                = new QTStrategyStru();
                obj.id             = int.Parse(item["id"].ToString());
                obj.strategyname   = item["strategyname"].ToString();
                obj.strategynumber = item["strategynumber"].ToString();
                obj.strategypath   = item["strategypath"].ToString();
                obj.creattime      = item["creattime"].ToString();
                obj.describe       = item["describe"].ToString();
                obj.remark         = item["remark"].ToString();
                obj.states         = item["states"].ToString();
                obj.isrun          = item["isrun"].ToString();
                //obj.strategyinfo = Common.Verify.html_txt_n(item["strategyinfo"].ToString());
                obj.strategyinfo = item["strategyinfo"].ToString();
                obj.strategytype = item["strategytype"].ToString();
                DataList.Add(obj);
            }
            //是否是条件查询,统计条数
            if (ispara == false)
            {
                strsql = "select count(*) from QTStrategy";
            }
            else
            {
                strsql = string.Format(@"select count(*) from QTStrategy {0}", strPara);
            }
            DataTable dtcount = conn.QueryDt(strsql, out errorMsg);

            count = dtcount.Rows[0][0].ToString();
            return(DataList);
        }
Example #5
0
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <returns></returns>
        public bool DeleteData(CommConf options, QTStrategyStru objstru)
        {
            string       errorMsg;
            SqliteAccess conn  = new SqliteAccess(options.AttriList.FirstOrDefault(o => o.key == "DBLink").value);
            string       str   = string.Format("delete from QTStrategy where id='{0}'", objstru.id);
            int          count = conn.Execute(str, out errorMsg);

            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #6
0
        /// <summary>
        /// 新增数据
        /// 第一次新增时确定创建时间和路径,今后不可修改
        /// </summary>
        /// <returns></returns>
        public bool AddData(CommConf options, QTStrategyStru objstru)
        {
            string       errorMsg;
            SqliteAccess conn = new SqliteAccess(options.AttriList.FirstOrDefault(o => o.key == "DBLink").value);
            string       str  = string.Format("insert into QTStrategy (strategyname,strategynumber,strategyinfo,strategytype,strategypath,describe,states,remark,creattime,isrun) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')",
                                              objstru.strategyname, objstru.strategynumber, Common.Verify.txt_html_n(objstru.strategyinfo), objstru.strategytype, objstru.strategypath, objstru.describe, objstru.states, objstru.remark, objstru.creattime, objstru.isrun);
            int count = conn.Execute(str, out errorMsg);

            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #7
0
        /// <summary>
        /// 编辑数据
        /// 不允许编辑创建时间和路径
        /// </summary>
        /// <returns></returns>
        public bool UpdateData(CommConf options, QTStrategyStru objstru)
        {
            string       errorMsg;
            SqliteAccess conn = new SqliteAccess(options.AttriList.FirstOrDefault(o => o.key == "DBLink").value);
            string       str  = string.Format("update QTStrategy set strategyname = '{0}', describe = '{1}', states = '{2}', remark = '{3}', strategyinfo = '{4}', strategytype = '{5}', isrun = '{6}' where strategynumber='{7}'",
                                              objstru.strategyname, objstru.describe, objstru.states, objstru.remark, Common.Verify.txt_html_n(objstru.strategyinfo), objstru.strategytype, objstru.isrun, objstru.strategynumber);
            int count = conn.Execute(str, out errorMsg);

            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #8
0
        /// <summary>
        /// 触发删除数据function,delete
        /// </summary>
        /// <param name="id"></param>
        /// <param name="username"></param>
        /// <returns></returns>
        public bool Delete(string id, string strategyname)
        {
            QTStrategyStru QTStrategyStru = new QTStrategyStru();

            QTStrategyStru.id           = Convert.ToInt32(id);
            QTStrategyStru.strategyname = strategyname;
            QTStrategyViewModel dataInfo = new QTStrategyViewModel();

            if (dataInfo.DeleteData(_appConf, QTStrategyStru))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #9
0
        /// <summary>
        /// 接收前端传递来的,待修改页面数据,原样返回
        /// </summary>
        /// <param name="id"></param>
        /// <param name="strategyname"></param>
        /// <param name="strategynumber"></param>
        /// <param name="strategypath"></param>
        /// <param name="strategytype"></param>
        /// <param name="creattime"></param>
        /// <param name="states"></param>
        /// <param name="remark"></param>
        /// <param name="describe"></param>
        /// <param name="isrun"></param>
        /// <returns></returns>
        public IActionResult StrategyEdit(string id, string strategyname, string strategynumber, string strategypath, string strategyinfo, string strategytype, string states, string remark, string describe, string isrun)
        {
            QTStrategyStru QTStrategy = new QTStrategyStru();

            QTStrategy.strategyname   = strategyname;
            QTStrategy.strategynumber = strategynumber;
            QTStrategy.strategypath   = strategypath;
            QTStrategy.strategytype   = strategytype;
            QTStrategy.states         = states;
            QTStrategy.remark         = remark;
            QTStrategy.describe       = describe;
            QTStrategy.isrun          = isrun;
            QTStrategy.states         = states;
            QTStrategy.strategyinfo   = Models.Common.Verify.html_txt_n(strategyinfo);
            var resultModel = new QTStrategyViewModel
            {
                qtstrategy = QTStrategy
            };

            return(View(resultModel));
        }