private void btnConnectRequest_Click(object sender, EventArgs e) { try { if (liUserProfiles == null || liUserProfiles.Count <= 0) { MessageBox.Show("No User Profiles found for this action", "No Profiles", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } var selectedUserProfiles = liUserProfiles.Where(s => s.IsSelected).ToList(); if (selectedUserProfiles == null || selectedUserProfiles.Count <= 0) { MessageBox.Show("No Profiles Selected for this action", "No Profiles", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } busyTab = 1; ShowBusyForm_Tab1(true); var data = Mapper.Map <List <LIUserData>, List <LIUserConnectRequestReport> >(selectedUserProfiles); settings = SraperSettingsManager.GetSettings(); var scraper = new LIScraper(settings); var done = scraper.StartConnectRequestFlow(data); ShowBusyForm_Tab1(false); scraper.ShutdownScraper(); UpdateStatus("Generating Report File"); string f = CSVFileManager.WriteConnectionRequestReport(settings.ConnReportPath, data); MessageBox.Show($"Successfully Sent Connection Requests to selected UserProfiles. A report has also been generated {f} ", "Connection Request", MessageBoxButtons.OK, MessageBoxIcon.Information); busyTab = 0; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error Creating Direct Message Schedule Data File", MessageBoxButtons.OK, MessageBoxIcon.Error); busyTab = 0; ShowBusyForm_Tab1(false); } }
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(); }