Ejemplo n.º 1
0
        private FlowStepModel CreateObj(DataRow dataRow)
        {
            FlowStepModel info = new FlowStepModel();

            base.CreateModel(info, dataRow);
            return(info);
        }
Ejemplo n.º 2
0
        private Dictionary <string, object> CreateParamJms(DataRow dataPre, FlowStepModel step, Dictionary <string, object> dict, out string exceMsg)
        {
            Dictionary <string, object> keyValues = new Dictionary <string, object>();

            exceMsg = "";
            if (step.Params != null)
            {
                foreach (FlowStepParamModel param in step.Params)
                {
                    string str       = step.StepName + ">>参数" + param.ParamName;
                    object value     = null;
                    string paramName = param.ParamName.Trim();
                    if (param.IsPreStep) //如果从上一步取值
                    {
                        bool bParamName = dataPre.Table.Columns.Contains(paramName);
                        if (dataPre == null || !bParamName)
                        {
                            //如果有默认值
                            if (param.DefaultValue != "")
                            {
                                value = param.DefaultValue;
                            }
                            else
                            {
                                exceMsg = str + "无法从上一步取值值";
                                break;
                            }
                        }
                        else
                        {
                            value = dataPre[paramName];
                        }
                    }
                    else //从Request中取值
                    {
                        if (dict.ContainsKey(paramName))
                        {
                            value = dict[paramName];
                        }
                        else
                        {
                            //如果有默认值
                            if (param.DefaultValue != "")
                            {
                                value = param.DefaultValue;
                            }
                            else
                            {
                                exceMsg = str + "没有在Request中获取到值";
                                break;
                            }
                        }
                    }

                    keyValues.Add(paramName, value);
                }
            }
            return(keyValues);
        }
Ejemplo n.º 3
0
        public List <FlowStepModel> QueryOfParam(int fksn)
        {
            List <FlowStepModel> list = new List <FlowStepModel>();

            string    strSql = string.Format("select * from {0} where FKSN= {1} order by StepOrder", tableName, fksn);
            DataTable dt     = db.FillTable(strSql);

            foreach (DataRow dataRow in dt.Rows)
            {
                FlowStepModel info = this.CreateModel <FlowStepModel>(dataRow);

                //加载步骤参数
                string strSql1 = "select * from api_flow_step_param where fksn =" + info.SN.ToString();
                info.Params = new List <FlowStepParamModel>();

                string strFunParam     = "";
                string strFunTableParm = "";
                foreach (DataRow dataRow1 in db.FillTable(strSql1).Rows)
                {
                    FlowStepParamModel model1   = base.CreateModel <FlowStepParamModel>(dataRow1);
                    string             paraName = model1.ParamName;

                    if (strFunParam != "")
                    {
                        strFunParam += ",";
                    }

                    if (strFunTableParm != "")
                    {
                        strFunTableParm += ",";
                    }
                    info.Params.Add(model1);
                    strFunParam     += "@" + paraName;
                    strFunTableParm += paraName = "@" + paraName;
                }

                if (info.CommandType == "Fun") //标量函数
                {
                    info.CommandText = "select " + info.CommandText + "(" + strFunParam + ")";
                }
                else if (info.CommandType == "FunTable") //表函数
                {
                    info.CommandText = "select * from " + info.CommandText;
                    if (strFunTableParm != "")
                    {
                        info.CommandText += " where " + strFunParam;
                    }
                }

                list.Add(info);
            }

            return(list);
        }
Ejemplo n.º 4
0
        public IActionResult DeleteFlowStep(FlowStepModel model)
        {
            int resutl = this.flowStepDAL.Delete(model);

            List <FlowStepModel> list = new List <FlowStepModel>();

            if (resutl > 0)
            {
                list = this.flowStepDAL.Query(model.FKSN);
            }

            return(PartialView("/Views/Interface/FlowStepList.cshtml", list));
        }
Ejemplo n.º 5
0
        public List <FlowStepModel> Query(int fksn)
        {
            List <FlowStepModel> list = new List <FlowStepModel>();

            string    strSql = string.Format("select * from {0} where FKSN= {1} order by StepOrder", tableName, fksn);
            DataTable dt     = db.FillTable(strSql);

            foreach (DataRow dataRow in dt.Rows)
            {
                FlowStepModel info = this.CreateModel <FlowStepModel>(dataRow);
                list.Add(info);
            }
            return(list);
        }
Ejemplo n.º 6
0
        public IActionResult StepSave(FlowStepModel model)
        {
            if (model.SN > 0)
            {
                this.flowStepDAL.Update(model);
            }
            else
            {
                int SN = this.flowStepDAL.Insert(model);
                model.SN = SN;
            }

            List <FlowStepModel> list = this.flowStepDAL.Query(model.FKSN);

            return(PartialView("/Views/Interface/FlowStepList.cshtml", list));
        }
Ejemplo n.º 7
0
 public IActionResult StepSave(FlowStepModel model)
 {
     if (model.SN > 0)
     {
         FlowStepModel modelOld = this.flowStepDAL.Get <FlowStepModel>(model.SN);
         model.CommandText = modelOld.CommandText;
         model.CommandType = modelOld.CommandType;
         model.DataBase    = modelOld.DataBase;
         this.flowStepDAL.Update(model);
     }
     else
     {
         int SN = this.flowStepDAL.Insert(model);
         model.SN = SN;
     }
     return(Redist(model.FKSN));
 }
Ejemplo n.º 8
0
        public List <FlowStepModel> Query(int fksn)
        {
            List <FlowStepModel> list = new List <FlowStepModel>();

            try
            {
                string    tableName = base.GetTable(typeof(FlowStepModel));
                string    strSql    = string.Format("select * from {0} where FKSN= {1} order by StepOrder", tableName, fksn);
                DataTable dt        = db.FillTable(strSql);

                foreach (DataRow dataRow in dt.Rows)
                {
                    FlowStepModel info = this.CreateObj(dataRow);
                    list.Add(info);
                }
            }
            catch (Exception ex)
            {
                _logger.LogError("DbCommand->api_interface=>Insert(s) 出错\r\n" + ex.Message);
                throw ex;
            }
            return(list);
        }
Ejemplo n.º 9
0
        public IActionResult SmoExecute(int FKSN, List <int> ids)
        {
            foreach (int id in ids)
            {
                //步骤
                FlowStepModel flowModel = this.flowStepDAL.Get <FlowStepModel>(FKSN);

                //历史脚本
                foreach (FlowStepHisModel hisModel in this.flowStepHisDAL.Query(FKSN))
                {
                    if (hisModel.SN == id)
                    {
                        hisModel.IsEnable = true;
                        string script = hisModel.Text;
                        if (script != "")
                        {
                            if (flowModel.CommandType == "Text") //如果是纯文本,则更新步骤内容
                            {
                                flowModel.CommandText = hisModel.Text;
                                this.flowStepDAL.Update(flowModel);
                            }
                            else //如果是存储过程
                            {
                                string procName = hisModel.FileName.Split(".")[0].Split("-")[0];
                                this.flowStepHisDAL.SmoExecute(flowModel.DataBase, procName, script);
                            }
                        }
                    }
                    else
                    {
                        hisModel.IsEnable = false;
                    }
                    this.flowStepHisDAL.Update(hisModel);
                }
            }
            return(this.StepHisList(FKSN));
        }
Ejemplo n.º 10
0
        //创建参数
        private bool CreateParam(InterfaceModel response, IDbCommand cmd, DataRow dataPre, FlowStepModel step, Dictionary <string, object> dict, out string exceMsg)
        {
            exceMsg = "";
            if (step.Params != null)
            {
                foreach (FlowStepParamModel param in step.Params)
                {
                    string str       = step.StepName + ">>参数" + param.ParamName;
                    object value     = null;
                    string paramName = param.ParamName.Trim();
                    if (param.IsPreStep) //如果从上一步取值
                    {
                        bool bParamName = dataPre.Table.Columns.Contains(paramName);
                        if (dataPre == null || !bParamName)
                        {
                            //如果有默认值
                            if (param.DefaultValue != "")
                            {
                                value = param.DefaultValue;
                            }
                            else
                            {
                                exceMsg = str + "无法从上一步取值值";
                                return(false);
                            }
                        }
                        else
                        {
                            value = dataPre[paramName];
                        }
                    }
                    else //从Request中取值
                    {
                        if (dict.ContainsKey(paramName))
                        {
                            if (param.DataType == "Image")
                            {
                                string directory = Directory.GetCurrentDirectory() + "\\wwwroot\\Image\\";
                                if (!System.IO.Directory.Exists(directory))
                                {
                                    System.IO.Directory.CreateDirectory(directory);
                                }

                                string fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + Guid.NewGuid().ToString() + ".png";

                                var    segment         = new PathString("~".Substring(1));
                                var    applicationPath = context.Request.PathBase;
                                string virpath         = applicationPath.Add(segment).Value;

                                string vir = context.Request.PathBase.Add(new PathString("~".Substring(1))).Value;

                                string path      = directory + fileName;                                                                 //硬盘文件名称 
                                string imagePath = context.Request.Scheme + "://" + context.Request.Host + vir + "/Image/" + fileName;   //网络路径
                                       value     = imagePath;
                                object objFile   = dict[paramName];
                                if (objFile != null)
                                {
                                    IFormFile formFile = (IFormFile)dict[paramName];
                                    using (var stream = System.IO.File.Create(path))
                                    {
                                        formFile.CopyTo(stream);
                                    }
                                }
                            }
                            else
                            {
                                value = dict[paramName];
                            }
                        }
                        else
                        {
                            //如果有默认值
                            if (param.DefaultValue != "")
                            {
                                value = param.DefaultValue;
                            }
                            else
                            {
                                exceMsg = str + "没有在Request中获取到值";
                                return(false);
                            }
                        }
                    }

                    DbParameter dbParameter = this.componentContext.ResolveNamed <DbParameter>(response.DataType);
                    dbParameter.ParameterName = "@" + paramName;
                    dbParameter.Value         = value;
                    cmd.Parameters.Add(dbParameter);
                }
            }
            return(true);
        }
Ejemplo n.º 11
0
        public IActionResult DeleteFlowStep(FlowStepModel model)
        {
            int resutl = this.flowStepDAL.DeleteAll(model.SN);

            return(this.Redist(model.FKSN));
        }