public async Task ExecutePrediction(PredictionParameters parms) { string accessJson = await _fileStorage.ReadFile("connectdefinition", "PPDMDataAccess.json"); _accessDefs = JsonConvert.DeserializeObject <List <DataAccessDef> >(accessJson); ConnectParameters connector = await GetConnector(parms.DataConnector); databaseConnectionString = connector.ConnectionString; _dbConn.OpenConnection(connector); string sourceConnector = GetSource(); if (parms.DataConnector == sourceConnector) { syncPredictions = true; } else { syncPredictions = false; } RuleManagement rules = new RuleManagement(_azureConnectionString); RuleModel rule = await rules.GetRuleAndFunction(parms.DataConnector, parms.PredictionId); manageIndexTable = new ManageIndexTable(_accessDefs, connector.ConnectionString, rule.DataType, rule.FailRule); manageIndexTable.InitQCFlags(false); await MakePredictions(rule, connector); _dbConn.CloseConnection(); manageIndexTable.SaveQCFlags(); }
private async Task <RuleModel> GetRuleAndFunctionInfo(string dataConnector, int ruleId) { RuleManagement rules = new RuleManagement(_azureConnectionString); RuleModel rule = await rules.GetRuleAndFunction(dataConnector, ruleId); return(rule); }
public async Task CloseDataQC(string source, List <RuleFailures> ruleFailures) { try { ConnectParameters connector = await GetConnector(source); RuleManagement rm = new RuleManagement(_azureConnectionString); string jsonRules = await rm.GetRules(source); List <RuleModel> rules = JsonConvert.DeserializeObject <List <RuleModel> >(jsonRules); ManageIndexTable idxTable = new ManageIndexTable(connector.ConnectionString); await idxTable.GetIndexQCFlagData(); foreach (var ruleFailure in ruleFailures) { RuleModel rule = rules.FirstOrDefault(o => o.Id == ruleFailure.RuleId); foreach (var failure in ruleFailure.Failures) { string qcString = idxTable.GetQCFlag(failure); qcString = qcString + rule.RuleKey + ";"; idxTable.SetQCFlag(failure, qcString); } } idxTable.SaveQCFlagDapper(); } catch (Exception ex) { Exception error = new Exception($"DataQc: Could not close and save qc flags, {ex}"); throw error; } }
public async Task <List <DmsIndex> > GetResult(string source, int id) { ConnectParameters connector = await GetConnector(source); RuleManagement rules = new RuleManagement(_azureConnectionString); string jsonRule = await rules.GetRule(source, id); RuleModel rule = JsonConvert.DeserializeObject <RuleModel>(jsonRule); ManageIndexTable mit = new ManageIndexTable(connector.ConnectionString); List <DmsIndex> result = await mit.GetQcOrPredictionsFromIndex(rule.RuleKey); return(result); }
private async Task CreateDSMRules(ConnectParameters connector) { try { RuleManagement rules = new RuleManagement(azureConnectionString); List <DataAccessDef> accessDefs = await GetDataAccessDefinitions(); string ruleString = await ReadDatabaseFile("StandardRules.json"); await rules.SaveRulesToDatabase(ruleString, connector); } catch (Exception ex) { Exception error = new Exception("Load DMS Rule Error: ", ex); throw error; } }
public async Task <List <QcResult> > GetQCRules(DataQCParameters qcParms) { List <QcResult> qcResult = new List <QcResult>(); ConnectParameters connector = await GetConnector(qcParms.DataConnector); RuleManagement rules = new RuleManagement(_azureConnectionString); IndexAccess idxAccess = new IndexAccess(); string jsonString = await rules.GetActiveQCRules(connector.SourceName); qcResult = JsonConvert.DeserializeObject <List <QcResult> >(jsonString); foreach (QcResult qcItem in qcResult) { string query = $" where QC_STRING like '%{qcItem.RuleKey};%'"; qcItem.Failures = idxAccess.IndexCountByQuery(query, connector.ConnectionString); } return(qcResult); }
public async Task <List <PredictionCorrection> > GetPredictions(string source) { List <PredictionCorrection> predictionResults = new List <PredictionCorrection>(); ConnectParameters connector = await GetConnector(source); RuleManagement rules = new RuleManagement(_azureConnectionString); string jsonString = await rules.GetActivePredictionRules(source); predictionResults = JsonConvert.DeserializeObject <List <PredictionCorrection> >(jsonString); IndexAccess idxAccess = new IndexAccess(); foreach (PredictionCorrection predItem in predictionResults) { string query = $" where QC_STRING like '%{predItem.RuleKey};%'"; predItem.NumberOfCorrections = idxAccess.IndexCountByQuery(query, connector.ConnectionString); } return(predictionResults); }
private async Task CreateUpdateStoredProcedure(DbUtilities dbConn) { List <DataAccessDef> accessDefs = await GetDataAccessDefinitions(); var dataTypes = accessDefs.Select(s => s.DataType).Where(s => s != "Index").ToList(); foreach (string dataType in dataTypes) { DataAccessDef accessDef = accessDefs.First(x => x.DataType == dataType); BuildUpdateProcedure(dbConn, dataType, accessDef); } RuleManagement rm = new RuleManagement(); string type = "Rules"; DataAccessDef ruleDef = rm.GetDataAccessDefinition(type); BuildUpdateProcedure(dbConn, type, ruleDef); type = "Functions"; DataAccessDef functionDef = rm.GetDataAccessDefinition(type); BuildUpdateProcedure(dbConn, type, functionDef); }
private async Task CreateGetStoredProcedure(DbUtilities dbConn) { RuleManagement rm = new RuleManagement(); string type = "Rules"; DataAccessDef ruleDef = rm.GetDataAccessDefinition(type); BuildGetProcedure(dbConn, type, ruleDef); BuildGetProcedureWithId(dbConn, type, ruleDef); type = "Functions"; DataAccessDef functionDef = rm.GetDataAccessDefinition(type); BuildGetProcedure(dbConn, type, functionDef); BuildGetProcedureWithId(dbConn, type, functionDef); IndexAccess ia = new IndexAccess(); type = "Index"; DataAccessDef indexDef = ia.GetDataAccessDefinition(); BuildGetProcedure(dbConn, type, indexDef); BuildGetProcedureWithQcString(dbConn, indexDef); }