public virtual async Task IsBlogOnlineAsync() { try { await RequestDataAsync(Blog.Url); Blog.Online = true; } catch (WebException webException) { if (webException.Status == WebExceptionStatus.RequestCanceled) { return; } Logger.Error("AbstractCrawler:IsBlogOnlineAsync:WebException {0}", webException); ShellService.ShowError(webException, Resources.BlogIsOffline, Blog.Name); Blog.Online = false; } catch (TimeoutException timeoutException) { HandleTimeoutException(timeoutException, Resources.OnlineChecking); Blog.Online = false; } }
protected override void OnInitialize() { base.OnInitialize(); musicFileContext = Container.GetExportedValue <MockMusicFileContext>(); musicFiles = new ObservableCollection <MusicFile>() { musicFileContext.Create(@"C:\Users\Public\Music\Dancefloor\Culture Beat - Serenity.wav"), musicFileContext.Create(@"C:\Culture Beat - Serenity - Epilog.wma"), }; selectionService = Container.GetExportedValue <SelectionService>(); selectionService.Initialize(musicFiles); playlistManager = new PlaylistManager(); controller = Container.GetExportedValue <PlaylistController>(); controller.PlaylistSettings = new PlaylistSettings(); controller.PlaylistManager = playlistManager; controller.Initialize(); controller.Run(); shellService = Container.GetExportedValue <ShellService>(); var view = shellService.PlaylistView; viewModel = ViewHelper.GetViewModel <PlaylistViewModel>((IView)view); }
public Startup(IConfiguration configuration) { Configuration = configuration; IShellService shellService = new ShellService(); shellService.ConfigureDependancyInjection(); }
protected override void OnInitialize() { base.OnInitialize(); controller = Container.GetExportedValue <ModuleController>(); shellService = Container.GetExportedValue <ShellService>(); controller.Initialize(); controller.Run(); }
public void VerifyAssembly(string filePath) { bool isMono = Type.GetType("Mono.Runtime") != null; var shellOutput = isMono ? ShellService.PEDump(filePath) : ShellService.PEVerify(filePath); if (shellOutput.ExitCode != 0) { throw new Exception(shellOutput.ToString()); } }
public Output Command(String cmd, String root, String rsc, String site, String provider) { if (!CheckUser()) { return(null); } ShellService svc = new ShellService(cmd, root, rsc, site, provider); return(svc.Process_Commands()); }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; var bufferSize = 1024 * 67 + 128; Stream inputStream = Console.OpenStandardInput(bufferSize); Console.SetIn(new StreamReader(inputStream, Console.InputEncoding, false, bufferSize)); var shellService = new ShellService(); shellService.Run(args); }
public ModuleController(IMessageService messageService, IEntityController entityController, BookController bookController, PersonController personController, ShellService shellService, Lazy <ShellViewModel> shellViewModel) { this.messageService = messageService; this.entityController = entityController; this.bookController = bookController; this.personController = personController; this.shellService = shellService; this.shellViewModel = shellViewModel; exitCommand = new DelegateCommand(Close); }
protected bool HandleServiceUnavailableWebException(WebException webException) { var resp = (HttpWebResponse)webException.Response; if (!(resp.StatusCode == HttpStatusCode.ServiceUnavailable || resp.StatusCode == HttpStatusCode.Unauthorized)) { return(false); } Logger.Error("{0}, {1}", string.Format(CultureInfo.CurrentCulture, Resources.NotLoggedIn, Blog.Name), webException); ShellService.ShowError(webException, Resources.NotLoggedIn, Blog.Name); return(true); }
public void ShellService_RunFilesListCommand() { //Arrange string command = "FILES_LIST"; ShellService service = new ShellService(); GingerAction gingerAction = new GingerAction(); //Act service.RunShell(gingerAction, command); //Assert Assert.IsNull(gingerAction.Errors); }
public void ShellService_RunIPConfigCommand() { //Arrange string command = "IPCONFIG"; ShellService service = new ShellService(); GingerAction gingerAction = new GingerAction(); //Act service.RunShell(gingerAction, command); //Assert Assert.IsNull(gingerAction.Errors); }
public void ShellService_RunNetstatCommand() { //Arrange string command = "NETSTAT"; ShellService service = new ShellService(); GingerAction gingerAction = new GingerAction(); //Act service.RunShell(gingerAction, command); //Assert Assert.IsNull(gingerAction.Errors); }
protected bool HandleNotFoundWebException(WebException webException) { var resp = (HttpWebResponse)webException.Response; if (resp.StatusCode != HttpStatusCode.NotFound) { return(false); } Logger.Error("{0}, {1}", string.Format(CultureInfo.CurrentCulture, Resources.BlogIsOffline, Blog.Name), webException); ShellService.ShowError(webException, Resources.BlogIsOffline, Blog.Name); return(true); }
protected bool HandleLimitExceededWebException(WebException webException) { var resp = (HttpWebResponse)webException.Response; if (resp == null || (int)resp.StatusCode != 429) { return(false); } Logger.Error("{0}, {1}", string.Format(CultureInfo.CurrentCulture, Resources.LimitExceeded, Blog.Name), webException); ShellService.ShowError(webException, Resources.LimitExceeded, Blog.Name); return(true); }
protected bool HandleUnauthorizedWebException(WebException webException) { var resp = (HttpWebResponse)webException?.Response; if (resp == null || resp.StatusCode != HttpStatusCode.Unauthorized) { return(false); } Logger.Error("{0}, {1}", string.Format(CultureInfo.CurrentCulture, Resources.PasswordProtected, Blog.Name), webException.Message); ShellService.ShowError(webException, Resources.PasswordProtected, Blog.Name); return(true); }
protected override void OnInitialize() { base.OnInitialize(); controller = Container.GetExportedValue <ManagerController>(); controller.Initialize(); shellService = Container.GetExportedValue <ShellService>(); selectionService = Container.GetExportedValue <SelectionService>(); managerStatusService = Container.GetExportedValue <IManagerStatusService>(); var view = (MockManagerView)shellService.ContentView; viewModel = ViewHelper.GetViewModel <ManagerViewModel>(view); }
public ModuleController(ISystemService systemService, ShellService shellService, Lazy <FileController> fileController, Lazy <RichTextDocumentController> richTextDocumentController, Lazy <PrintController> printController, Lazy <ShellViewModel> shellViewModel, Lazy <MainViewModel> mainViewModel, Lazy <StartViewModel> startViewModel) { this.systemService = systemService; this.fileController = fileController.Value; _ = richTextDocumentController.Value; this.printController = printController.Value; this.shellViewModel = shellViewModel.Value; this.mainViewModel = mainViewModel.Value; this.startViewModel = startViewModel.Value; shellService.ShellView = this.shellViewModel.View; this.shellViewModel.Closing += ShellViewModelClosing; exitCommand = new DelegateCommand(Close); }
public ScanWorker(ILogger <ScanWorker> logger, SecSoulService secSoulService, ShellService shellService, IOptionsMonitor <PossibleScansOptions> scanOptions, VirusTotalScan virusTotalScan, NmapScan nmapScan, DirbScan dirbScan, WebCrawlerService webCrawlerService, HashCheckScan hashCheckScan) { _logger = logger; _secSoulService = secSoulService; _shellService = shellService; _possibleScans = scanOptions.CurrentValue; _virusTotalScan = virusTotalScan; _nmapScan = nmapScan; _dirbScan = dirbScan; _webCrawlerService = webCrawlerService; _hashCheckScan = hashCheckScan; }
public void ShellService_ValidateOS() { //Arrange string command = "CLEAR_SCREEN"; ShellService service = new ShellService(); GingerAction gingerAction = new GingerAction(); string targetOS = OperatingSystem.GetCurrentOS(); //Act service.RunShell(gingerAction, command); //Assert Assert.AreEqual(targetOS, gingerAction.Output["curr_os"]); }
public ModuleController(IMessageService messageService, IPresentationService presentationService, IEntityController entityController, BookController bookController, PersonController personController, ShellService shellService, Lazy <ShellViewModel> shellViewModel) { presentationService.InitializeCultures(); this.messageService = messageService; this.entityController = entityController; this.bookController = bookController; this.personController = personController; this.shellService = shellService; this.shellViewModel = shellViewModel; this.exitCommand = new DelegateCommand(Close); }
public override async Task IsBlogOnlineAsync() { if (!await CheckIfLoggedInAsync()) { Logger.Error("TumblrHiddenCrawler:GetUrlsAsync: {0}", "User not logged in"); ShellService.ShowError(new Exception("User not logged in"), Resources.NotLoggedIn, Blog.Name); PostQueue.CompleteAdding(); } try { tumblrKey = await UpdateTumblrKeyAsync("https://www.tumblr.com/dashboard/blog/" + Blog.Name); string document = await GetSvcPageAsync("1", "0"); Blog.Online = true; } catch (WebException webException) { if (webException.Status == WebExceptionStatus.RequestCanceled) { return; } if (HandleServiceUnavailableWebException(webException)) { Blog.Online = true; } if (HandleNotFoundWebException(webException)) { Blog.Online = false; } if (HandleLimitExceededWebException(webException)) { Blog.Online = true; } } catch (TimeoutException timeoutException) { HandleTimeoutException(timeoutException, Resources.OnlineChecking); Blog.Online = false; } catch (Exception ex) when(ex.Message == "Acceptance of privacy consent needed!") { Blog.Online = false; } }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void Execute(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); if (_dte.SelectedItems.Count > 0) { SelectedItem selectedItem = _dte.SelectedItems.Item(1); ProjectItem selectProjectItem = selectedItem.ProjectItem; if (selectProjectItem != null) { IShellService shell = new ShellService(); //shell.ShowDialog("生成配置", new MainWindow(_dte)); shell.ShowDialog("生成配置", new Welcome(_dte)); } } }
public void DataGridColumnRestore() { try { if (ShellService.Settings.ColumnSettings.Count != 0) { ViewCore.DataGridColumnRestore = ShellService.Settings.ColumnSettings; } } catch (Exception ex) { Logger.Error("ManagerViewModel:ManagerViewModel {0}", ex); ShellService.ShowError(ex, Resources.CouldNotRestoreUISettings); return; } }
public void SetViewTest() { ShellService shellService = new ShellService(); object mockView = new object(); AssertHelper.PropertyChangedEvent(shellService, x => x.ShellView, () => shellService.ShellView = mockView); Assert.AreEqual(mockView, shellService.ShellView); AssertHelper.PropertyChangedEvent(shellService, x => x.ItemListView, () => shellService.ItemListView = mockView); Assert.AreEqual(mockView, shellService.ItemListView); AssertHelper.PropertyChangedEvent(shellService, x => x.NewItemsView, () => shellService.NewItemsView = mockView); Assert.AreEqual(mockView, shellService.NewItemsView); }
public void PropertiesTest() { var lazyShellViewModel = new Lazy <IShellViewModel>(() => new MockShellViewModel()); var shellService = new ShellService(lazyShellViewModel); var mockShellViewModel = (MockShellViewModel)lazyShellViewModel.Value; object shellView = new object(); mockShellViewModel.View = shellView; Assert.AreEqual(shellView, shellService.ShellView); Assert.IsNull(shellService.ContentView); object contentView = new object(); AssertHelper.PropertyChangedEvent(shellService, x => x.ContentView, () => shellService.ContentView = contentView); Assert.AreEqual(contentView, shellService.ContentView); }
public virtual T ConvertJsonToClass <T>(string json) where T : new() { try { using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(json))) { var serializer = new DataContractJsonSerializer(typeof(T)); return((T)serializer.ReadObject(ms)); } } catch (SerializationException serializationException) { Logger.Error("AbstractCrawler:ConvertJsonToClass<T>: {0}", "Could not parse data"); ShellService.ShowError(serializationException, Resources.PostNotParsable, Blog.Name); return(new T()); } }
public void SetViewTest() { ShellService shellService = new ShellService(); object mockView = new object(); AssertHelper.PropertyChangedEvent(shellService, x => x.MainView, () => shellService.MainView = mockView); Assert.AreEqual(mockView, shellService.MainView); AssertHelper.PropertyChangedEvent(shellService, x => x.UserBugsView, () => shellService.UserBugsView = mockView); Assert.AreEqual(mockView, shellService.UserBugsView); AssertHelper.PropertyChangedEvent(shellService, x => x.TeamBugsView, () => shellService.TeamBugsView = mockView); Assert.AreEqual(mockView, shellService.TeamBugsView); }
public override async Task IsBlogOnlineAsync() { try { twUser = await GetTwUser(); if (!string.IsNullOrEmpty(twUser.Errors?[0]?.Message)) { Logger.Warning("TwitterCrawler.IsBlogOnlineAsync: {0}: {1}", Blog.Name, twUser.Errors?[0]?.Message); ShellService.ShowError(null, (twUser.Errors?[0]?.Code == 63 ? Blog.Name + ": " : "") + twUser.Errors?[0]?.Message); Blog.Online = false; } else { Blog.Online = true; } } catch (WebException webException) { if (webException.Status == WebExceptionStatus.RequestCanceled) { return; } if (HandleUnauthorizedWebException(webException)) { Blog.Online = true; } else if (HandleLimitExceededWebException(webException)) { Blog.Online = true; } else { Logger.Error("TwitterCrawler:IsBlogOnlineAsync:WebException {0}", webException); ShellService.ShowError(webException, Resources.BlogIsOffline, Blog.Name); Blog.Online = false; } } catch (TimeoutException timeoutException) { HandleTimeoutException(timeoutException, Resources.OnlineChecking); Blog.Online = false; } }
private void Authenticate() { try { var url = @"https://www.tumblr.com/login"; ShellService.Settings.OAuthCallbackUrl = "https://www.tumblr.com/dashboard"; AuthenticateViewModel authenticateViewModel = authenticateViewModelFactory.CreateExport().Value; authenticateViewModel.AddUrl(url); authenticateViewModel.ShowDialog(ShellService.ShellView); } catch (System.Net.WebException ex) { Logger.Error("SettingsViewModel:Authenticate: {0}", ex); ShellService.ShowError(ex, Resources.AuthenticationFailure, ex.Message); return; } }
public override async Task IsBlogOnlineAsync() { try { await GetApiPageWithRetryAsync(0); Blog.Online = true; } catch (WebException webException) { if (webException.Status == WebExceptionStatus.RequestCanceled) { return; } if (HandleUnauthorizedWebException(webException)) { Blog.Online = true; } else if (HandleLimitExceededWebException(webException)) { Blog.Online = true; } else if (HandleNotFoundWebException(webException)) { Blog.Online = false; } else { Logger.Error("TumblrBlogCrawler:IsBlogOnlineAsync: {0}, {1}", Blog.Name, webException); ShellService.ShowError(webException, "{0}, {1}", Blog.Name, webException.Message); Blog.Online = false; } } catch (TimeoutException timeoutException) { HandleTimeoutException(timeoutException, Resources.OnlineChecking); Blog.Online = false; } catch (Exception ex) when(ex.Message == "Acceptance of privacy consent needed!") { Blog.Online = false; } }