public List <RuleCodeIOType> GetAvailabileRuleCodeTypes() { List <RuleCodeIOType> ret = new List <RuleCodeIOType>(); using (var conn = new SqlConnection(_connString)) using (var cmd = new SqlCommand("RulesEngine.spa_GetCodeIOTypes", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 360; conn.Open(); using (SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { while (reader.Read()) { var tempCat = new RuleCodeIOType { RuleCodeIOTypeId = int.Parse(reader["RuleCodeIOTypeId"].ToString()), TypeName = reader["TypeName"].ToString(), }; ret.Add(tempCat); } } conn.Close(); } return(ret); }
private void WriteRuleCodeToStream(TextWriter tw, RuleCodeCache codeCache, int?ruleAppliedId) { var methodName = string.Format("Z_{0}_{1}_{2}", codeCache.CodeHash, codeCache.RuleCodeId, ruleAppliedId); ////public static outputtype methodName(inputtype input){ //// ruleCode } //// tw.Write("public static "); RuleCodeIOType outputType = _rulesDAL.DALCache.RuleCodeIOTypes.FirstOrDefault(c => c.RuleCodeIOTypeId == codeCache.OutputTypeId); if (outputType == null) { throw new KeyNotFoundException("Output type not found in the cache"); } tw.Write(outputType.TypeName); tw.Write(" "); tw.Write(methodName); tw.Write("( "); RuleCodeIOType inputType = _rulesDAL.DALCache.RuleCodeIOTypes.FirstOrDefault(c => c.RuleCodeIOTypeId == codeCache.InputTypeId); if (inputType == null) { throw new KeyNotFoundException("Input Type not found in the cache"); } tw.Write(inputType.TypeName); tw.Write(" obj)"); tw.WriteLine("{"); if (codeCache.CodeText == null) { throw new NullReferenceException("can't have null code in CompileRules"); } tw.WriteLine(codeCache.CodeText); tw.WriteLine("}"); }