public List <string> GetWikiResults(int noOfResults = 1) { var wikiLinks = this.driver.FindElements(By.XPath($"//a[contains(@href, '.wikipedia.org/wiki/')]")); if (wikiLinks != null && wikiLinks.Any()) { List <Tuple <string, double> > filtered = new List <Tuple <string, double> >(); wikiLinks.ToList().ForEach(link => { var href = link.GetAttribute("href"); if (!string.IsNullOrEmpty(href)) { filtered.Add(new Tuple <string, double>(href, AutomationUtility.CalculateSimilarity(href, this.searchKeyword))); } }); if (filtered.Any()) { filtered = filtered.OrderByDescending(f => f.Item2).ToList(); return(filtered.Take(noOfResults).Select(f => f.Item1).ToList()); } } return(null); }
public static int SendAutomationAtachExcel(string _Subject, string _ContentMsg, string[] _MainPersonalId, string[] _CopyPersonalId, DataTable dt, string _FileName) { try { string filename = _FileName + "_" + DateTime.Now.Ticks; string fileExtention = ".xlsx"; string path = @"D:\tmpFiles\" + filename + fileExtention; bool SaveResult = GenerateExcel2(dt, path); if (SaveResult) { byte[] b = File.ReadAllBytes(path); File.Delete(path); return(AutomationUtility.SendAutomationMessageWithAttachment(_Subject, _ContentMsg, _MainPersonalId, _CopyPersonalId, filename, fileExtention, b)); } else { return(0); } } catch (Exception ex) { DBHelper.LogFile(ex); return(0); } finally { } }
static void Main(string[] args) { string _iFilePath, _bType, _nThreads, _nWLinks; //args[0] => Input filename if (!string.IsNullOrEmpty(args[0]) && args[0] != "null") { _iFilePath = args[0]; MovieNames = GetInputFromFile(_iFilePath); } //args[1] => Browser Type (gui, headless) if (!string.IsNullOrEmpty(args[1]) && args[1] != "null") { _bType = args[1]; browserType = GetBrowserType(_bType); } //args[2] => Max no of threads if (!string.IsNullOrEmpty(args[2]) && args[2] != "null") { _nThreads = args[2]; Int32.TryParse(_nThreads, out maxNoOfThreads); } //args[3] => Max no of wiki links if (!string.IsNullOrEmpty(args[3]) && args[3] != "null") { _nWLinks = args[3]; Int32.TryParse(_nWLinks, out noOfWikiLinks); } //args[4] => Output folder if (!string.IsNullOrEmpty(args[4]) && args[4] != "null") { outputDirectory = args[4]; } Console.WriteLine("Starting job"); Console.WriteLine(args); string reportDirectory = AutomationUtility.GetOutputDirectory(outputDirectory); AutomationHelper helper = new AutomationHelper(); helper.GetWikiLinks(MovieNames, browserType, reportDirectory, noOfWikiLinks); helper.Automate(MovieNames, browserType, reportDirectory, maxNoOfThreads); Console.WriteLine("Completed job"); }