public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { if (!callback.IsDisposed) { using (callback) { // 직접 다운받아야 하는 파일의 경우 (ex: ActiveX) if (this.agrees != null && this.agrees.IndexOf(downloadItem.SuggestedFileName) > -1) { callback.Continue(downloadItem.SuggestedFileName, showDialog: true); } // 자동으로 받아지는 경우 else if (this.ignores == null || this.ignores.IndexOf(downloadItem.SuggestedFileName) == -1) { OnBeforeDownloadFired?.Invoke(this, downloadItem); // 다운로드할 경로를 설정했다면 별도 창 띄우지 않고 진행 if (downloadSrc != String.Empty) { callback.Continue(this.downloadSrc, showDialog: false); } else { callback.Continue(downloadItem.SuggestedFileName, showDialog: true); } } } } }
public void OnBeforeDownload(IWebBrowser webBrowser, IBrowser browser, DownloadItem item, IBeforeDownloadCallback callback) { if (!callback.IsDisposed) { using (callback) { myForm.UpdateDownloadItem(item); // ask browser what path it wants to save the file into string path = myForm.CalcDownloadPath(item); // if file should not be saved, path will be null, so skip file if (path == null) { // skip file callback.Continue(path, false); } else { // open the downloads tab myForm.OpenDownloadsTab(); callback.Continue(path, true); } } } }
public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem item, IBeforeDownloadCallback callback) { if (!callback.IsDisposed) { using (callback) { myForm.Idm.Add(item); if (myForm.X.downloadpath != null) { callback.Continue(myForm.X.downloadpath, true); } else { callback.Continue(item.SuggestedFileName, true); } /* * // ask browser what path it wants to save the file into * string path = myForm.CalcDownloadPath(item); * * // if file should not be saved, path will be null, so skip file * if (path != null) { * // skip file * //callback.Continue(item.SuggestedFileName, true); * callback.Continue(path, false); * } else { * // download file * callback.Dispose(); * //open the downloads tab * myForm.OpenDownloadsTab(); * } */ } } }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { try { if (!callback.IsDisposed) { using (callback) { if (browser.IsPopup) { Application.Current.Dispatcher.Invoke(new Action(() => { try { ChromiumWebBrowser chromiumWebBrowser = null; webBrowserManager.CacheWebBrowsers.TryTake(out chromiumWebBrowser); hideWindow = Window.GetWindow(chromiumWebBrowser); hideWindow.Hide(); } catch (Exception ex) { Logger.Error(ex); } })); } callback.Continue(downloadItem.SuggestedFileName, showDialog: true); } } } catch (Exception ex) { Logger.Error(ex); } }
private void RequestConfigurationFileDownload(DownloadItem downloadItem, IBeforeDownloadCallback callback) { var args = new DownloadEventArgs(); logger.Debug($"Handling download of configuration file '{downloadItem.SuggestedFileName}'."); ConfigurationDownloadRequested?.Invoke(downloadItem.SuggestedFileName, args); if (args.AllowDownload) { if (args.Callback != null) { callbacks[downloadItem.Id] = args.Callback; } logger.Debug($"Starting download of configuration file '{downloadItem.SuggestedFileName}'..."); using (callback) { callback.Continue(args.DownloadPath, false); } } else { logger.Debug($"Download of configuration file '{downloadItem.SuggestedFileName}' was cancelled."); } }
private void HandleFileDownload(DownloadItem downloadItem, IBeforeDownloadCallback callback) { var filePath = default(string); var showDialog = settings.AllowCustomDownloadLocation; logger.Debug($"Handling download of file '{downloadItem.SuggestedFileName}'."); if (!string.IsNullOrEmpty(settings.DownloadDirectory)) { filePath = Path.Combine(Environment.ExpandEnvironmentVariables(settings.DownloadDirectory), downloadItem.SuggestedFileName); } else { filePath = Path.Combine(KnownFolders.Downloads.ExpandedPath, downloadItem.SuggestedFileName); } if (showDialog) { logger.Debug($"Allowing user to select custom download location, with '{filePath}' as suggestion."); } else { logger.Debug($"Automatically downloading file as '{filePath}'."); } downloads[downloadItem.Id] = Guid.NewGuid(); using (callback) { callback.Continue(filePath, showDialog); } }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { Console.WriteLine("[{0}] File:{1}", downloadItem.Id, downloadItem.SuggestedFileName); SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.OverwritePrompt = true; saveFileDialog.SupportMultiDottedExtensions = false; saveFileDialog.Filter = "All|*.*"; //saveFileDialog.FileName = System.IO.Path.GetFileName(""); saveFileDialog.FileName = downloadItem.SuggestedFileName; DialogResult result = saveFileDialog.ShowDialog(); if (result == DialogResult.OK) { callback.Continue(saveFileDialog.FileName, false); } //FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); //if (folderBrowserDialog.ShowDialog() == DialogResult.OK) //{ // string path = folderBrowserDialog.SelectedPath; // callback.Continue(path+ "\\" + downloadItem.SuggestedFileName, false); //} }
public void OnBeforeDownload(IWebBrowser webBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { var uri = new Uri(downloadItem.Url); var extension = Path.GetExtension(uri.AbsolutePath); var isConfigFile = String.Equals(extension, appConfig.ConfigurationFileExtension, StringComparison.OrdinalIgnoreCase); logger.Debug($"Handling download request for '{uri}'."); if (isConfigFile) { Task.Run(() => RequestConfigurationFileDownload(downloadItem, callback)); } else if (settings.AllowDownloads) { logger.Debug($"Starting download of '{uri}'..."); using (callback) { callback.Continue(null, true); } } else { logger.Info($"Aborted download request for '{uri}', as downloading is not allowed."); } }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { var fileInfo = new FileInfo(downloadItem.SuggestedFileName); string fileName = fileName = $"{_prefix}{_newName ?? fileInfo.Name.Replace(fileInfo.Extension, "")}{_suffix}{fileInfo.Extension}"; fileName = fileName.Replace("/", "").Replace("\\", ""); string filePath = $"{_path}\\{fileName}"; if (!callback.IsDisposed) { using (callback) { OnDownloadStart(browser, downloadItem); if (File.Exists(filePath)) { downloadItem.IsCancelled = true; OnDownloadComplete(downloadItem, filePath); } else { callback.Continue(filePath, false); } } } }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { DialogResult dialogResult = MessageBox.Show("Kids Portal is strictly for browsing only.\n\nDownloading is prohibited.", "Kids Portal - Protection", MessageBoxButtons.OK, MessageBoxIcon.Stop); if (dialogResult == DialogResult.Yes) { // parent login if (true) { var handler = OnBeforeDownloadFired; if (handler != null) { handler(this, downloadItem); } if (!callback.IsDisposed) { using (callback) { callback.Continue(downloadItem.SuggestedFileName, showDialog: true); } } } } else if (dialogResult == DialogResult.No) { //do something else } }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { var handler = OnBeforeDownloadFired; if (handler != null) { handler(this, downloadItem); } if (!callback.IsDisposed) { using (callback) { Uri originalUri = new Uri(downloadItem.OriginalUrl); // Parse the query string variables into a NameValueCollection. NameValueCollection qscoll = HttpUtility.ParseQueryString(originalUri.Query); var dr = new DownloadRecord() { FileName = downloadItem.SuggestedFileName, Url = downloadItem.Url, IsCancelled = false }; var fDr = Global.DownloadRepository.InitDownload(dr); Global.DownloadRepository.UpdateDownload(downloadItem.Url, downloadItem); callback.Continue(fDr.FullPath, showDialog: false); } } }
public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { callback.Continue(@"C:\Users\" + System.Security.Principal.WindowsIdentity.GetCurrent().Name + @"\Downloads\" + downloadItem.SuggestedFileName, true); LogHelper.Debug("Download File " + downloadItem.FullPath); }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { if (!callback.IsDisposed) { using (callback) { string directory = Properties.Settings.Default.StorageLocation + (GlobalVariables.CurrentUnitCode != "" ? GlobalVariables.CurrentUnitCode + "/" : ""); Directory.CreateDirectory(directory); string filename = directory + downloadItem.SuggestedFileName; if (!File.Exists(filename)) { callback.Continue(filename, showDialog: false); ++GlobalVariables.FilesDownloaded; BlackboardFile f = new BlackboardFile(downloadItem.SuggestedFileName, downloadItem.Url); f.RawURL = GlobalVariables.CurrentUrl; f.FirstDownloaded = DateTime.Now; f.LastDownloaded = DateTime.Now; f.TimesDownloaded = 1; f.LocalPath = filename; //We know the unit we want exists in GlobalVariables.Units because it was created before the download started, back in Crawler.cs GlobalVariables.Units.First(u => u.Name == GlobalVariables.CurrentUnitCode).Files.Add(f); } else { //FUTURE FEATURE: Allow files to be marked for redownloading. ++GlobalVariables.FilesSkipped; } if (DownloadHandled != null) DownloadHandled(new object(), new EventArgs()); } } }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { if (!callback.IsDisposed) { callback.Continue(downloadItem.SuggestedFileName, showDialog: true); callback.Dispose(); } }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { string filename = Path.Combine(KnownFolders.GetPath(KnownFolder.Downloads), downloadItem.SuggestedFileName); callback.Continue(filename, !downloadItem.SuggestedFileName.ToLower().EndsWith(".zip")); }
void IDownloadHandler.OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { if (!callback.IsDisposed) { using (callback) { callback.Continue(downloadItem.SuggestedFileName, showDialog: true); } } }
//public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { // if (!callback.IsDisposed) { // using (callback) { // callback.Continue(downloadItem.SuggestedFileName, true); // } // } //} public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { if (!callback.IsDisposed) { using (callback) { callback.Continue(downloadItem.SuggestedFileName, true); } } }
public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, CefSharp.IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { if (!string.IsNullOrWhiteSpace(downloadItem.SuggestedFileName)) { var path = Path.Combine(Directory.GetCurrentDirectory(), downloadItem.SuggestedFileName); callback.Continue(path, false); return; } var match = _nameRegex.Match(downloadItem.ContentDisposition); if (match.Success) { var name = match.Groups[1].ToString(); var path = Path.Combine(Directory.GetCurrentDirectory(), name); callback.Continue(path, false); } }
public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { if (_quickMode) { return; } callback.Continue(_path.ToString(), false); }
public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { if (!callback.IsDisposed) { using (callback) { callback.Continue("SolutionTemplate.pbix", showDialog: true); } } }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { if (!callback.IsDisposed) { using (callback) { myForm.UpdateDownloadItem(downloadItem); callback.Continue(downloadItem.SuggestedFileName, showDialog: true); } } }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { if (!callback.IsDisposed) { using (callback) { callback.Continue(@"D:\dps下载文件\" + downloadItem.SuggestedFileName, showDialog: false); } } }
public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { OnBeforeDownloadFired?.Invoke(this, downloadItem); if (!callback.IsDisposed) { using (callback) { callback.Continue(downloadItem.SuggestedFileName, showDialog: true); } } }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { if (!callback.IsDisposed) { using (callback) { string filePath = System.IO.Path.Combine(this.downloadDirectory, downloadItem.SuggestedFileName); callback.Continue(filePath, showDialog: true); } } }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { var save_dialog = new SaveFileDialog(); save_dialog.FileName = downloadItem.SuggestedFileName; if (save_dialog.ShowDialog() ?? false) { callback.Continue(save_dialog.FileName, false); } }
public void ContinueDownload(string path, IBeforeDownloadCallback callback) { SaveFileDialog sf = new SaveFileDialog(); sf.FileName = path; sf.Title = path; sf.InitialDirectory = "./"; if (sf.ShowDialog() == DialogResult.OK) { callback.Continue(path, false); } }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { var handler = OnBeforeDownloadFired; handler?.Invoke(this, downloadItem); if (!callback.IsDisposed) { using (callback) { callback.Continue(downloadItem.SuggestedFileName, true); } } }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { if (!callback.IsDisposed) { using (callback) { callback.Continue(@"C:\Users\" + System.Security.Principal.WindowsIdentity.GetCurrent().Name + @"\Downloads\" + downloadItem.SuggestedFileName, showDialog: true); } } }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { if (!callback.IsDisposed) { using (callback) { destination = Path.Combine(MyPath.PathLocalAppData, downloadItem.SuggestedFileName); callback.Continue(destination, showDialog: false); Globals.log.Debug("DownloadHandler:> CefsharpDummy start download file to " + destination); Configuration.myState = Configuration.State.downloading; } } }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { //System.Diagnostics.Debug.WriteLine(System.Security.Principal.WindowsIdentity.GetCurrent().Name); if (!callback.IsDisposed) { using (callback) { callback.Continue(@"c:\Users\" + System.Security.Principal.WindowsIdentity.GetCurrent().Name + @"\download\" + downloadItem.SuggestedFileName, true); } } }
void IDownloadHandler.OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { if (callback.IsDisposed) { return; } using (callback) { drm.DownloadFileName = downloadItem.SuggestedFileName; callback.Continue(ConfigurationManager.AppSettings["TempFolderPath"] + downloadItem.SuggestedFileName, showDialog: false); } }
public void OnBeforeDownload(IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback) { var handler = OnBeforeDownloadFired; if (handler != null) { handler(this, downloadItem); } if (!callback.IsDisposed) { using (callback) { callback.Continue(downloadItem.SuggestedFileName, showDialog: true); } } }