Ejemplo n.º 1
0
        public Predictions(string azureConnectionString)
        {
            _azureConnectionString = azureConnectionString;
            var            builder       = new ConfigurationBuilder();
            IConfiguration configuration = builder.Build();

            _fileStorage = new AzureFileStorageServiceCommon(configuration);
            _fileStorage.SetConnectionString(azureConnectionString);
            _dbConn    = new DbUtilities();
            _dp        = new DapperDataAccess();
            _indexData = new IndexDBAccess(_dp);
        }
        public ReportEditManagement(string azureConnectionString)
        {
            _dp = new DapperDataAccess();
            this.azureConnectionString = azureConnectionString;
            var            builder       = new ConfigurationBuilder();
            IConfiguration configuration = builder.Build();

            _fileStorage = new AzureFileStorageServiceCommon(configuration);
            _fileStorage.SetConnectionString(azureConnectionString);
            _dp        = new DapperDataAccess();
            _indexData = new IndexDBAccess(_dp);
        }
Ejemplo n.º 3
0
        public static string Consistency(QcRuleSetup qcSetup, DataTable dt, List <DataAccessDef> accessDefs, IIndexDBAccess indexData)
        {
            string    returnStatus = "Passed";
            RuleModel rule         = JsonConvert.DeserializeObject <RuleModel>(qcSetup.RuleObject);
            JObject   dataObject   = JObject.Parse(qcSetup.DataObject);
            JToken    value        = dataObject.GetValue(rule.DataAttribute);
            string    strValue     = value.ToString();

            if (Common.CompletenessCheck(strValue) == "Passed")
            {
                string     dataType = rule.DataType;
                IndexModel index    = Task.Run(() => indexData.GetIndex(qcSetup.IndexId, qcSetup.DataConnector)).GetAwaiter().GetResult();
                if (index != null)
                {
                    string         query           = " where " + index.DataKey;
                    DataAccessDef  dataAccessDef   = accessDefs.First(x => x.DataType == dataType);
                    string         sql             = dataAccessDef.Select + query;
                    IADODataAccess consistencyConn = new ADODataAccess();
                    DataTable      ct = consistencyConn.GetDataTable(sql, qcSetup.ConsistencyConnectorString);
                    Dictionary <string, string> columnTypes = ct.GetColumnTypes();
                    if (ct.Rows.Count > 0)
                    {
                        string strRefValue = ct.Rows[0][rule.DataAttribute].ToString();
                        string valueType   = columnTypes[rule.DataAttribute];
                        if (Common.CompletenessCheck(strRefValue) == "Passed")
                        {
                            returnStatus = RuleMethodUtilities.ConsistencyCheck(strValue, strRefValue, valueType);
                        }
                    }
                }
            }
            return(returnStatus);
        }
Ejemplo n.º 4
0
        public static string Uniqueness(QcRuleSetup qcSetup, DataTable dt, List <DataAccessDef> accessDefs, IIndexDBAccess indexData)
        {
            string returnStatus = "Passed";

            string query = $"INDEXID = '{qcSetup.IndexId}'";

            DataRow[] idxRows = dt.Select(query);
            if (idxRows.Length == 1)
            {
                string key = idxRows[0]["UNIQKEY"].ToString();
                if (!string.IsNullOrEmpty(key))
                {
                    query = $"UNIQKEY = '{key}'";
                    DataRow[] dtRows = dt.Select(query);
                    if (dtRows.Length > 1)
                    {
                        returnStatus = "Failed";
                    }
                }
            }

            return(returnStatus);
        }
Ejemplo n.º 5
0
        public static string Completeness(QcRuleSetup qcSetup, DataTable dt, List <DataAccessDef> accessDefs, IIndexDBAccess indexData)
        {
            string    returnStatus = "Passed";
            RuleModel rule         = JsonConvert.DeserializeObject <RuleModel>(qcSetup.RuleObject);
            JObject   dataObject   = JObject.Parse(qcSetup.DataObject);
            JToken    value        = dataObject.GetValue(rule.DataAttribute);

            if (value == null)
            {
                //log.Warning($"Attribute is Null");
            }
            else
            {
                string strValue = value.ToString();
                if (string.IsNullOrWhiteSpace(strValue))
                {
                    returnStatus = "Failed";
                }
                else
                {
                    double number;
                    bool   canConvert = double.TryParse(strValue, out number);
                    if (canConvert)
                    {
                        if (number == -99999)
                        {
                            returnStatus = "Failed";
                        }
                    }
                }
            }
            return(returnStatus);
        }
Ejemplo n.º 6
0
        public static string StringLength(QcRuleSetup qcSetup, DataTable dt, List <DataAccessDef> accessDefs, IIndexDBAccess indexData)
        {
            string    returnStatus = "Failed";
            string    error        = "";
            RuleModel rule         = JsonConvert.DeserializeObject <RuleModel>(qcSetup.RuleObject);
            JObject   dataObject   = JObject.Parse(qcSetup.DataObject);
            JToken    value        = dataObject.GetValue(rule.DataAttribute);
            StringLengthParameters stringParams = new StringLengthParameters()
            {
                Min = 20,
                Max = 20
            };

            if (!string.IsNullOrEmpty(rule.RuleParameters))
            {
                try
                {
                    stringParams = JsonConvert.DeserializeObject <StringLengthParameters>(rule.RuleParameters);
                    if (stringParams.Min == 0)
                    {
                        stringParams.Min = 20;
                    }
                    if (stringParams.Max == 0)
                    {
                        stringParams.Max = stringParams.Min;
                    }
                }
                catch (Exception ex)
                {
                    error = $"Bad parameter Json, {ex}";
                }
            }
            string strValue = value.ToString();

            strValue = strValue.Trim();
            int stringLength = strValue.Length;

            if (stringLength >= stringParams.Min & stringLength <= stringParams.Max)
            {
                returnStatus = "Passed";
            }
            else
            {
                returnStatus = "Failed";
            }
            return(returnStatus);
        }
Ejemplo n.º 7
0
        public static string IsNumber(QcRuleSetup qcSetup, DataTable dt, List <DataAccessDef> accessDefs, IIndexDBAccess indexData)
        {
            string    returnStatus = "Passed";
            RuleModel rule         = JsonConvert.DeserializeObject <RuleModel>(qcSetup.RuleObject);
            JObject   dataObject   = JObject.Parse(qcSetup.DataObject);
            JToken    value        = dataObject.GetValue(rule.DataAttribute);

            if (value == null)
            {
                //log.Warning($"Attribute is Null");
            }
            else
            {
                string strValue = value.ToString();
                bool   isValid  = false;
                isValid = isNumberTest.IsMatch(strValue);
                if (!isValid)
                {
                    returnStatus = "Failed";
                }
            }
            return(returnStatus);
        }
Ejemplo n.º 8
0
        public static string Entirety(QcRuleSetup qcSetup, DataTable dt, List <DataAccessDef> accessDefs, IIndexDBAccess indexData)
        {
            string    returnStatus = "Passed";
            RuleModel rule         = JsonConvert.DeserializeObject <RuleModel>(qcSetup.RuleObject);
            string    indexNode    = qcSetup.IndexNode;
            string    dataName     = rule.RuleParameters;
            IEnumerable <IndexModel> indexModels = Task.Run(() => indexData.GetChildrenWithName(qcSetup.DataConnector, indexNode, dataName)).GetAwaiter().GetResult();

            if (indexModels.Count() == 0)
            {
                returnStatus = "Failed";
            }
            return(returnStatus);
        }
Ejemplo n.º 9
0
        public static string CurveSpikes(QcRuleSetup qcSetup, DataTable dt, List <DataAccessDef> accessDefs, IIndexDBAccess indexData)
        {
            string               returnStatus = "Passed";
            string               error        = "";
            RuleModel            rule         = JsonConvert.DeserializeObject <RuleModel>(qcSetup.RuleObject);
            JObject              dataObject   = JObject.Parse(qcSetup.DataObject);
            double               nullValue    = Common.GetLogNullValue(dataObject.ToString());
            CurveSpikeParameters spikeParams  = new CurveSpikeParameters()
            {
                WindowSize   = 5,
                SeveritySize = 4
            };

            if (!string.IsNullOrEmpty(rule.RuleParameters))
            {
                try
                {
                    spikeParams = JsonConvert.DeserializeObject <CurveSpikeParameters>(rule.RuleParameters);
                    if (spikeParams.WindowSize == 0)
                    {
                        spikeParams.WindowSize = 5;
                    }
                    if (spikeParams.SeveritySize == 0)
                    {
                        spikeParams.SeveritySize = 4;
                    }
                }
                catch (Exception ex)
                {
                    error = $"Bad Json, {ex}";
                }
            }
            spikeParams.NullValue = nullValue;
            List <double> measuredValues = new List <double>();

            try
            {
                JToken value    = dataObject.GetValue("MEASURED_VALUE");
                string strValue = value.ToString();
                if (!string.IsNullOrEmpty(strValue))
                {
                    measuredValues = strValue.Split(',').Select(double.Parse).ToList();
                }
            }
            catch (Exception ex)
            {
                error = $"Problems with the log arrays, {ex}";
            }

            bool spike = RuleMethodUtilities.CurveHasSpikes(measuredValues, spikeParams);

            if (spike)
            {
                returnStatus = "Failed";
            }

            return(returnStatus);
        }
Ejemplo n.º 10
0
        public static string ValidityRange(QcRuleSetup qcSetup, DataTable dt, List <DataAccessDef> accessDefs, IIndexDBAccess indexData)
        {
            string returnStatus = "Passed";

            bool      canConvert;
            double    minRange;
            double    maxRange;
            RuleModel rule            = JsonConvert.DeserializeObject <RuleModel>(qcSetup.RuleObject);
            JObject   parameterObject = JObject.Parse(rule.RuleParameters);
            JToken    jMinRangeValue  = parameterObject.GetValue("MinRange");

            canConvert = double.TryParse(jMinRangeValue.ToString(), out minRange);
            if (!canConvert)
            {
                minRange = -99999.0;
            }
            JToken jMaxRangeValue = parameterObject.GetValue("MaxRange");

            canConvert = double.TryParse(jMaxRangeValue.ToString(), out maxRange);
            if (!canConvert)
            {
                maxRange = 99999.0;
            }

            JObject dataObject = JObject.Parse(qcSetup.DataObject);
            JToken  value      = dataObject.GetValue(rule.DataAttribute);
            double? number     = value.GetNumberFromJToken();

            if (number != null)
            {
                if (number >= minRange & number <= maxRange)
                {
                    returnStatus = "Passed";
                }
                else
                {
                    returnStatus = "Failed";
                }
            }

            return(returnStatus);
        }
Ejemplo n.º 11
0
 public ManageIndexTable(string connectionString)
 {
     _connectionString = connectionString;
     _dp        = new DapperDataAccess();
     _indexData = new IndexDBAccess(_dp);
 }
 public ReportEditManagement()
 {
     _dp        = new DapperDataAccess();
     _indexData = new IndexDBAccess(_dp);
 }