Example #1
0
        private static async Task <OutputData> GetOutputData(string expected, string actual, string postcode, string property_code_Url)
        {
            // Fetches the rating using Fuzzy Logic
            var    matchedCode           = FuzzyProcessor.GetTopMatchedPostCode(expected, actual);
            var    postCodeAddressConent = matchedCode.Item1;
            string property_code         = postCodeAddressConent.Substring(postCodeAddressConent.IndexOf("Property Code") + "Property Code ".Length);

            // Fetches the property code
            var propertyCodeData = await Task.Run(() => GetPropertyCodeContent(property_code_Url, property_code));

            return(new OutputData
            {
                InstructionAddress = expected,
                Postcode = postcode,
                Airbus_Fetched_Address = actual,
                Confidence_Ratio = matchedCode.Item2,
                Matched_PropetyCode_Address = matchedCode.Item1,
                Matched_UPRN_Address = propertyCodeData
            });
        }
        public static async Task Execute()
        {
            try
            {
                //  foreach (Tuple<string, string> row in StaticDataRepository.TestData)

                foreach (DataRow row in ExcelDataRepository.GetDataTableFromExcel().Rows)
                {
                    var result = await Task.Run(() => GetPostCodeContent(post_code_Url, row[1].ToString()));

                    // Fetches the rating using Fuzzy Logic
                    var    matchedCode           = FuzzyProcessor.GetTopMatchedPostCode(row[0].ToString(), result);
                    var    postCodeAddressConent = matchedCode.Item1;
                    string property_code         = postCodeAddressConent.Substring(postCodeAddressConent.IndexOf("Property Code") + "Property Code ".Length);

                    // Fetches the property code
                    var propertyCodeData = await Task.Run(() => GetPropertyCodeContent(property_code_Url, property_code));

                    outputDatas.Add(new OutputData
                    {
                        InstructionAddress          = row[0].ToString(),
                        Postcode                    = row[1].ToString(),
                        Airbus_Fetched_Address      = result,
                        Confidence_Ratio            = matchedCode.Item2,
                        Matched_PropetyCode_Address = matchedCode.Item1,
                        Matched_UPRN_Address        = propertyCodeData
                    });
                }

                FileLogWriter.WritelineMessage($"Total item count {outputDatas.Count}");
                //foreach (var item in outputDatas)
                //{
                //    FileLogWriter.WritelineMessage(item.ToString());
                //}
                ExcelDataRepository.WriteToExcel(outputDatas);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error while processing excel... {ex}");
            }
        }