/// <summary> /// 通用调用存储过程 /// </summary> /// <param name="model">存储过程Model</param> /// <param name="ParameterList">输出参数List</param> /// <returns>数据集</returns> public DataSet ExecStoredProcedures(StoredProcModel model, out List <ParameterModel> ParameterList) { try { //Database db = DatabaseFactory.CreateDatabase(); Database db = factory.CreateDefault(); DbCommand dbCommand = db.GetStoredProcCommand(model.ProcName); foreach (ParameterModel Param in model.ParameterList) { if (Param.ParamMode == ParamEnumMode.InMode)//输入参数 { db.AddInParameter(dbCommand, Param.ParamName, Param.ParamType, Param.ParamValue); } if (Param.ParamMode == ParamEnumMode.OutMode)//输出参数 { db.AddOutParameter(dbCommand, Param.ParamName, Param.ParamType, int.MaxValue); } } DataSet ds = db.ExecuteDataSet(dbCommand); ParameterList = new List <ParameterModel>(); foreach (ParameterModel Param in model.ParameterList) { if (Param.ParamMode == ParamEnumMode.OutMode)//输出参数 { Param.ParamResults = db.GetParameterValue(dbCommand, Param.ParamName); ParameterList.Add(Param); } } return(ds); } catch (Exception ex) { //throw new Exception(ex.Message); } ParameterList = new List <ParameterModel>(); return(new DataSet()); }
/// <summary> /// 根据条件得到网格化监督的分值 /// </summary> /// <param name="year">年,如2012</param> /// <param name="userId">用户id</param> /// <returns></returns> public decimal WghScore(string year, string userId) { decimal score = 0; string sTime = year + "-01-01"; string eTime = year + "-12-31"; DateTime dtStime = Convert.ToDateTime(sTime); DateTime dtEtime = Convert.ToDateTime(eTime); Common_BLL bllComm = new Common_BLL(); ParameterModel param = new ParameterModel(); param.ParamMode = ParamEnumMode.InMode; param.ParamName = "UserId"; param.ParamType = DbType.String; param.ParamValue = userId; ParameterModel paramStart = new ParameterModel(); paramStart.ParamMode = ParamEnumMode.InMode; paramStart.ParamName = "StartTime"; paramStart.ParamType = DbType.DateTime; paramStart.ParamValue = Convert.ToDateTime(sTime); ParameterModel paramEnd = new ParameterModel(); paramEnd.ParamMode = ParamEnumMode.InMode; paramEnd.ParamName = "EndTime"; paramEnd.ParamType = DbType.DateTime; paramEnd.ParamValue = Convert.ToDateTime(eTime); ParameterModel param1 = new ParameterModel(); param1.ParamMode = ParamEnumMode.OutMode; param1.ParamName = "SelfMonitor"; param1.ParamType = DbType.Double; ParameterModel param2 = new ParameterModel(); param2.ParamMode = ParamEnumMode.OutMode; param2.ParamName = "OrganEvalu"; param2.ParamType = DbType.Double; ParameterModel param3 = new ParameterModel(); param3.ParamMode = ParamEnumMode.OutMode; param3.ParamName = "Democracy"; param3.ParamType = DbType.Double; ParameterModel param4 = new ParameterModel(); param4.ParamMode = ParamEnumMode.OutMode; param4.ParamName = "NetworkRatingLim"; param4.ParamType = DbType.Double; ParameterModel param5 = new ParameterModel(); param5.ParamMode = ParamEnumMode.OutMode; param5.ParamName = "Report"; param5.ParamType = DbType.Double; ParameterModel param6 = new ParameterModel(); param6.ParamMode = ParamEnumMode.OutMode; param6.ParamName = "Mesher"; param6.ParamType = DbType.Double; ParameterModel param7 = new ParameterModel(); param7.ParamMode = ParamEnumMode.OutMode; param7.ParamName = "Score"; param7.ParamType = DbType.Double; StoredProcModel models = new StoredProcModel(); models.ProcName = "P_GetScoreByYearAndUserId"; models.ParameterList = new List <ParameterModel>(); models.ParameterList.Add(param); models.ParameterList.Add(paramStart); models.ParameterList.Add(paramEnd); models.ParameterList.Add(param1); models.ParameterList.Add(param2); models.ParameterList.Add(param3); models.ParameterList.Add(param4); models.ParameterList.Add(param5); models.ParameterList.Add(param6); models.ParameterList.Add(param7); List <ParameterModel> ParameterList = new List <ParameterModel>(); bllComm.ExecStoredProcedures(models, out ParameterList); score = Convert.ToDecimal(ParameterList[5].ParamResults); return(score); }
/// <summary> /// 通用调用存储过程 /// </summary> /// <param name="model">存储过程Model</param> /// <param name="ParameterList">输出参数List</param> /// <returns>数据集</returns> public DataSet ExecStoredProcedures(StoredProcModel model, out List <ParameterModel> ParameterList) { return(dal.ExecStoredProcedures(model, out ParameterList)); }