private async Task <List <int> > QualityCheckDataType(DbUtilities dbConn, RuleModel rule, ConnectParameters connector) { List <int> failedObjects = new List <int>(); QcRuleSetup qcSetup = new QcRuleSetup(); qcSetup.Database = connector.Catalog; qcSetup.DatabasePassword = connector.Password; qcSetup.DatabaseServer = connector.DatabaseServer; qcSetup.DatabaseUser = connector.User; qcSetup.DataConnector = connector.ConnectionString; string ruleFilter = rule.RuleFilter; string jsonRules = JsonConvert.SerializeObject(rule); qcSetup.RuleObject = jsonRules; bool externalQcMethod = rule.RuleFunction.StartsWith("http"); DataTable indexTable = manageQCFlags.GetIndexTable(); if (rule.RuleFunction == "Uniqueness") { CalculateKey(rule, indexTable); } if (rule.RuleFunction == "Consistency") { qcSetup.ConsistencyConnectorString = await GetConsistencySource(rule.RuleParameters); } foreach (DataRow idxRow in indexTable.Rows) { string jsonData = idxRow["JSONDATAOBJECT"].ToString(); if (!string.IsNullOrEmpty(jsonData)) { qcSetup.IndexId = Convert.ToInt32(idxRow["INDEXID"]); qcSetup.IndexNode = idxRow["TextIndexNode"].ToString(); qcSetup.DataObject = jsonData; string result = "Passed"; if (!Filter(jsonData, ruleFilter)) { if (externalQcMethod) { result = ProcessQcRule(qcSetup, rule); } else { Type type = typeof(QCMethods); MethodInfo info = type.GetMethod(rule.RuleFunction); result = (string)info.Invoke(null, new object[] { qcSetup, indexTable, _accessDefs, _indexData }); } if (result == "Failed") { failedObjects.Add(qcSetup.IndexId); } } } } return(failedObjects); }
private async Task MakePredictions(RuleModel rule, ConnectParameters connector) { QcRuleSetup qcSetup = new QcRuleSetup(); qcSetup.Database = connector.Catalog; qcSetup.DatabasePassword = connector.Password; qcSetup.DatabaseServer = connector.DatabaseServer; qcSetup.DatabaseUser = connector.User; string jsonRules = JsonConvert.SerializeObject(rule); qcSetup.RuleObject = jsonRules; string predictionURL = rule.RuleFunction; bool externalQcMethod = rule.RuleFunction.StartsWith("http"); indexTable = manageIndexTable.GetIndexTable(); foreach (DataRow idxRow in indexTable.Rows) { string jsonData = idxRow["JSONDATAOBJECT"].ToString(); if (!string.IsNullOrEmpty(jsonData)) { qcSetup.IndexId = Convert.ToInt32(idxRow["INDEXID"]); qcSetup.IndexNode = idxRow["TextIndexNode"].ToString(); qcSetup.DataObject = jsonData; PredictionResult result; if (externalQcMethod) { result = ProcessPrediction(qcSetup, predictionURL, rule); if (result.Status == "Server error") { break; } } else { Type type = typeof(PredictionMethods); MethodInfo info = type.GetMethod(rule.RuleFunction); result = (PredictionResult)info.Invoke(null, new object[] { qcSetup, _dbConn }); } await ProcessResult(result, rule); } } }