private void btnUserProfileImport_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); settings = SraperSettingsManager.GetSettings(); if (settings != null && !string.IsNullOrWhiteSpace(settings.ConnReportPath)) { openFileDialog1.InitialDirectory = settings.ConnReportPath; } else { openFileDialog1.InitialDirectory = @"C:\"; } openFileDialog1.Title = "Import LinkedIn UserProfiles File"; openFileDialog1.CheckFileExists = true; openFileDialog1.CheckPathExists = true; openFileDialog1.DefaultExt = "csv"; openFileDialog1.Filter = "UserProfiles File (*.csv)|*.csv"; openFileDialog1.FilterIndex = 0; openFileDialog1.RestoreDirectory = true; openFileDialog1.ReadOnlyChecked = true; // openFileDialog1.ShowReadOnly = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { try { string impFilePath = openFileDialog1.FileName; this.txtUserProfileImport.Text = impFilePath; try { liImportUserProfiles = CSVFileManager.ReadUserProfilesImportFile(impFilePath); dgvImportUserProfilesSource = new BindingSource(); dgvImportUserProfilesSource.DataSource = liImportUserProfiles; this.dgvUserProfileImport.Rows.Clear(); this.dgvUserProfileImport.DataSource = dgvImportUserProfilesSource; } catch (Exception ex) { MessageBox.Show(ex.Message, "Invalid Import File", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } MessageBox.Show("Successfully Imported the UserProfiles", "File Import", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error Import File", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void SaveAppPrefrences() { try { settings = SraperSettingsManager.GetSettings(); settings.LIUserName = this.txtUserName.Text; settings.LIPassword = this.txtPassword.Text; if (string.IsNullOrWhiteSpace(settings.LIUserName) || string.IsNullOrWhiteSpace(settings.LIPassword)) { throw new Exception("LinkedIn UserName or Password cannot be blank"); } settings.ScraperMaxWait = (int)this.numScraperMaxWait.Value; settings.ScraperMinWait = (int)this.numScraperMinWait.Value; if (settings.ScraperMaxWait < settings.ScraperMinWait) { throw new Exception("ScraperMaxWait cannot be less than ScraperMinWait"); } settings.ScraperTimeout = (int)this.numScraperTimeout.Value; settings.ScraperBatchSize = (int)this.numBatchSize.Value; settings.ScrollMinWait = (int)this.numScraperScrollMinWait.Value; settings.ScrollMaxWait = (int)this.numScraperScrollMaxWait.Value; settings.ConnMinWait = (int)this.numMinConnMsgSec.Value; settings.ConnMaxWait = (int)this.numMaxConnMsgSec.Value; settings.ConnGreetings = this.txtConnMsgGreetings.Text; settings.ConnMessage = this.rtbConnMessage.Text; settings.ConnReportPath = this.txtConnMsgReportPath.Text; settings.DirMsgMinWait = (int)this.numMinDirecMsgSec.Value; settings.DirMsgMaxWait = (int)this.numMaxDirecMsgSec.Value; settings.DirMsgGreetings = this.txtDirecMsgGreetings.Text; settings.DirMessage = this.rtbDirecMessage.Text; settings.DirMsgReportPath = this.txtDirecMsgReportPath.Text; settings.DefaultKeyword = this.txtDefualtKeyword.Text; settings.UseOffScreenScraper = this.chkOffScreenScraping.Checked; SraperSettingsManager.SaveSettings(settings); MessageBox.Show("Successfully Updated Scraper Settings", "Settings Update", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error Save Settings", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnDirectMessageRequest_Click(object sender, EventArgs e) { try { if (liImportUserProfiles == null || liImportUserProfiles.Count <= 0) { MessageBox.Show("No User Profiles found for this action", "No Profiles", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } var selectedUserProfiles = liImportUserProfiles.Where(s => s.IsSelected).ToList(); if (selectedUserProfiles == null || selectedUserProfiles.Count <= 0) { MessageBox.Show("No User Profiles Selected for this action", "No Profiles", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } busyTab = 2; ShowBusyForm_Tab2(true); var data = Mapper.Map <List <LIUserData>, List <LIUserDirectMessageReport> >(selectedUserProfiles); settings = SraperSettingsManager.GetSettings(); var scraper = new LIScraper(settings); var done = scraper.StartDirectMessageFlow(data); scraper.ShutdownScraper(); busyTab = 0; ShowBusyForm_Tab2(false); UpdateStatus("Generating Report File"); string f = CSVFileManager.WriteDirectMessageReport(settings.DirMsgReportPath, data); MessageBox.Show($"Successfully Sent Direct Messages to selected UserProfiles. A report has also been generated {f} ", "Direct Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error Creating Direct Message Schedule Data File", MessageBoxButtons.OK, MessageBoxIcon.Error); busyTab = 0; ShowBusyForm_Tab2(false); } }
private async void btnSearchLinkedIn_Click(object sender, EventArgs e) { try { busyTab = 1; settings = SraperSettingsManager.GetSettings(); if (string.IsNullOrWhiteSpace(settings.LIUserName) || string.IsNullOrWhiteSpace(settings.LIPassword)) { throw new Exception("LinkedIn UserName or Password cannot be blank"); } searchCriteria = new SearchCriteria(); searchCriteria.Keyword = this.txtKeyword.Text; searchCriteria.City = this.txtCity.Text; searchCriteria.State = this.cmbState.Text; searchCriteria.Company = this.txtCompany.Text; this.dgvLinkedInResult.Rows.Clear(); this.rtbConnectLog.Clear(); liUserProfiles = new List <LIUserData>(); dgvLinkedInScrapingResultSource = new BindingSource(); dgvLinkedInScrapingResultSource.DataSource = liUserProfiles; dgvLinkedInResult.DataSource = dgvLinkedInScrapingResultSource; this.grpConnectNow.Enabled = false; this.grpConnectSchedule.Enabled = false; connScraper = new LIScraper(settings); pageNo = 1; ScrapeLinkedIn(connScraper, searchCriteria, pageNo); } catch (Exception ex) { MessageBox.Show(ex.Message, "Scraping Error", MessageBoxButtons.OK, MessageBoxIcon.Error); busyTab = 0; } }
private void ApplyPrefrences() { try { settings = SraperSettingsManager.GetSettings(); this.txtUserName.Text = settings.LIUserName; this.txtPassword.Text = settings.LIPassword; this.numScraperMaxWait.Value = settings.ScraperMaxWait; this.numScraperMinWait.Value = settings.ScraperMinWait; this.numScraperTimeout.Value = settings.ScraperTimeout; this.numBatchSize.Value = settings.ScraperBatchSize; this.numScraperScrollMinWait.Value = settings.ScrollMinWait; this.numScraperScrollMaxWait.Value = settings.ScrollMaxWait; this.numMinConnMsgSec.Value = settings.ConnMinWait; this.numMaxConnMsgSec.Value = settings.ConnMaxWait; this.txtConnMsgGreetings.Text = settings.ConnGreetings; this.rtbConnMessage.Text = settings.ConnMessage; this.txtConnMsgReportPath.Text = settings.ConnReportPath; this.numMinDirecMsgSec.Value = settings.DirMsgMinWait; this.numMaxDirecMsgSec.Value = settings.DirMsgMaxWait; this.txtDirecMsgGreetings.Text = settings.DirMsgGreetings; this.rtbDirecMessage.Text = settings.DirMessage; this.txtDirecMsgReportPath.Text = settings.DirMsgReportPath; this.txtDefualtKeyword.Text = settings.DefaultKeyword; this.chkOffScreenScraping.Checked = settings.UseOffScreenScraper; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error Applying Settings", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LinkedInForm_Shown(object sender, EventArgs e) { settings = SraperSettingsManager.GetSettings(); this.txtKeyword.Text = settings.DefaultKeyword; }
static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Console() .WriteTo.File("logs\\LIConnectScheduleAppLogs.txt", rollingInterval: RollingInterval.Day) .CreateLogger(); Logger.DebugMessaged += Logger_DebugMessaged; Logger.ErrorMessaged += Logger_ErrorMessaged; AutoMapper.Mapper.Initialize(cfg => { cfg.CreateMap <LIUserData, LIUserConnectRequestReport>().ReverseMap(); cfg.CreateMap <LIUserData, LIUserDirectMessageReport>().ReverseMap(); }); Log.Debug("Readig Command line arguments..."); int argNumber = 0; try { if (args.Length > 0) { //argNumber = 1;// argNumber = Convert.ToInt32(args[0]); Log.Debug($"Command is {argNumber}"); string err = ""; switch (argNumber) { case 1: { Log.Debug("Performing Connection Request Workflow..."); var data = CSVFileManager.ReadConnectionRequestSchedulerData(out err); if (data.Count > 0) { var settings = SraperSettingsManager.GetSettings(); var scraper = new LIScraper(settings); var done = scraper.StartConnectRequestFlow(data); scraper.ShutdownScraper(); Log.Debug("Generating Report File"); string f = CSVFileManager.WriteConnectionRequestReport(settings.ConnReportPath, data); Log.Debug($"Report File Generated {f}"); } else { Log.Debug("No Connection Request Scheduling data..."); if (!string.IsNullOrWhiteSpace(err)) { Log.Error(err); } } } break; case 2: { Log.Debug("Performing Direct Message Workflow..."); var data = CSVFileManager.ReadDirectMessageSchedulerData(out err); if (data.Count > 0) { var settings = SraperSettingsManager.GetSettings(); var scraper = new LIScraper(settings); var done = scraper.StartDirectMessageFlow(data); scraper.ShutdownScraper(); Log.Debug("Generating Report File"); string f = CSVFileManager.WriteDirectMessageReport(settings.DirMsgReportPath, data); Log.Debug($"Report File Generated {f}"); } else { Log.Debug("No Direct Message Scheduling data..."); if (!string.IsNullOrWhiteSpace(err)) { Log.Error(err); } } } break; } } } catch (Exception ex) { Log.Error(ex, $"Error while running scheduler Task - {argNumber}"); } Log.Debug("All Done , Exiting..."); return; //TestLinkedinScraping(); }