public static ValidationRuleApplied Map(this RuleValidationsPOCO valRulePoco) { var ret = new ValidationRuleApplied { //AppId = valRulePoco.ConvertedCode.Contains("clp.") ? 14 : valRulePoco.ConvertedCode.Contains("cli.") ? 1 : 0, //ApplyOrder = valRulePoco.RuleValId, }; return(ret); }
internal static List <RuleValidationsPOCO> GetRuleValiations(int toTake) { string sqlGetRuleValidationsForConversion = string.Format("SELECT * FROM rules.dbo.RuleValidations WITH(NOLOCK) left JOIN rules.dbo.XPathTargetFields ON XPathTargetFields.XPathTargetFieldsID = RuleValidations.XPathTargetFieldsID left JOIN rules.dbo.ErrMsg ON ErrMsg.ErrMsgID = RuleValidations.ErrMsgID where RuleValid > {0} ORDER BY RuleValID", lastValIdRead); List <RuleValidationsPOCO> ret = new List <RuleValidationsPOCO>(); using (SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["DSN"])) using (SqlCommand cmd = new SqlCommand(sqlGetRuleValidationsForConversion, conn)) { conn.Open(); var reader = cmd.ExecuteReader(); int i = 0; while (reader.Read() && i++ < toTake) { RuleValidationsPOCO r = new RuleValidationsPOCO { ActionTypeVal = (ActionTypeValidations)int.Parse(reader["ActionTypeValID"].ToString()), description = reader["Description"].ToString(), dtadded = DateTime.Parse(reader["DtAdded"].ToString()), dtupdated = DateTime.Parse(reader["DtUpdated"].ToString()), errMsg = reader["Msg"].ToString(), extraData = reader["ExtraData"].ToString(), RuleValId = int.Parse(reader["RuleValId"].ToString()), userId = int.Parse(reader["UsrID"].ToString()), xmlSchema = reader["xmlSchemaID"].ToString() == "1" ? "CLP" : reader["xmlSchemaID"].ToString() == "2" ? "CLI" : null, xpath = reader["xpath"].ToString(), xpathCondAlt = reader["xpathCondAlt"].ToString() }; ret.Add(r); } } lastValIdRead = ret.Max(c => c.RuleValId); return(ret); }