public VKNetworkAnalyzer() { vkRestApi = new VkRestApi(); // set up data handler vkRestApi.OnData += new VkRestApi.DataHandler(OnData); // set up error handler vkRestApi.OnError += new VkRestApi.ErrorHandler(OnError); }
// main error handler public void OnError(object vkRestApi, VkRestApi.OnErrorEventArgs onErrorArgs) { // TODO: notify user about the error Debug.WriteLine("Function " + onErrorArgs.Function + ", returned error: " + onErrorArgs.Error); // this.error = new Exception("Function " + onErrorArgs.function + ", returned error: " + onErrorArgs.error); this.requestStatistics.OnUnexpectedException(new Exception("Function " + onErrorArgs.Function + ", returned error: " + onErrorArgs.Error)); // indicate that we can continue readyEvent.Set(); }
public TestVKImpotrerForm() { InitializeComponent(); vkLoginDialog = new VKLoginDialog(); // subscribe for login events vkLoginDialog.OnUserLogin += new VKLoginDialog.UserLoginHandler(UserLogin); vkRestApi = new VkRestApi(); // set up data handler vkRestApi.OnData += new VkRestApi.DataHandler(OnData); // set up error handler vkRestApi.OnError += new VkRestApi.ErrorHandler(OnError); }
// main error handler private void OnError(object vkApi, VkRestApi.OnErrorEventArgs onErrorArgs) { Debug.WriteLine("Function " + onErrorArgs.Function + ", returned error: " + onErrorArgs.Details); if (errorLogWriter != null) { updateErrorLogFile(onErrorArgs, errorLogWriter); } if (onErrorArgs.Code == VkRestApi.CriticalErrorCode) { var result = MessageBox.Show( onErrorArgs.Details + "\n Please fix connection problem or just wait.\n Press \'Yes\' to continue with the current request" + "\nPress \'No\' to continue with the next request.", onErrorArgs.Error, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); if (result == DialogResult.Yes) { vkRestApi.CallVkFunction(onErrorArgs.Function, onErrorArgs.Context); return; } } else { switch (onErrorArgs.Code) { case 6: // this is too many requests error - repeat last API call Utils.sleepTime(0); vkRestApi.CallVkFunction(onErrorArgs.Function, onErrorArgs.Context); return; case 15: // user is not found - continue break; default: var result = MessageBox.Show( onErrorArgs.Details + "\n Please fix connection problem or just wait.\n Press \'Yes\' to continue with the current request" + "\nPress \'No\' to continue with the next request.", onErrorArgs.Error, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); if (result == DialogResult.Yes) { vkRestApi.CallVkFunction(onErrorArgs.Function, onErrorArgs.Context); return; } break; } } // indicate that data is ready and we can continue ReadyEvent.Set(); }
private void updateErrorLogFile(VkRestApi.OnErrorEventArgs error, StreamWriter writer) { writer.WriteLine("{0}\t{1}\t{2}\t{3}", error.Function, error.Code, error.Error, error.Details); }
// Constructor public VKGroupsForm() { InitializeComponent(); userIdTextBox.Text = @"Please authorize"; groupId = 0; isAuthorized = false; isWorkingFolderSet = false; vkLoginDialog = new VKLoginDialog(); // subscribe for login events vkLoginDialog.OnUserLogin += OnUserLogin; vkRestApi = new VkRestApi(); // set up data handler vkRestApi.OnData += OnData; // set up error handler vkRestApi.OnError += OnError; // setup background group posts worker handlers backgroundGroupsWorker.DoWork += GroupsWork; backgroundGroupsWorker.ProgressChanged += GroupsWorkProgressChanged; backgroundGroupsWorker.RunWorkerCompleted += GroupsWorkCompleted; // setup background group members worker handlers backgroundMembersWorker.DoWork += MembersWork; backgroundMembersWorker.ProgressChanged += MembersWorkProgressChanged; backgroundMembersWorker.RunWorkerCompleted += MembersWorkCompleted; // setup background group network worker handlers backgroundNetworkWorker.DoWork += NetworkWork; backgroundNetworkWorker.ProgressChanged += NetworkWorkProgressChanged; backgroundNetworkWorker.RunWorkerCompleted += NetworkWorkCompleted; // setup background Ego net worker handlers backgroundEgoNetWorker.DoWork += EgoNetWork; backgroundEgoNetWorker.ProgressChanged += EgoNetWorkProgressChanged; backgroundEgoNetWorker.RunWorkerCompleted += EgoNetWorkCompleted; // this.folderBrowserDialog1.ShowNewFolderButton = false; // Default to the My Documents folder. folderBrowserDialog1.RootFolder = Environment.SpecialFolder.Personal; // this.folderBrowserDialog1.RootFolder = Environment.SpecialFolder.MyComputer; WorkingFolderTextBox.Text = folderBrowserDialog1.SelectedPath; GroupsProgressBar.Minimum = 0; GroupsProgressBar.Maximum = 100 * POSTS_PER_REQUEST; GroupsProgressBar.Step = 1; ActivateControls(); }
public VKContentForm() { InitializeComponent(); this.userIdTextBox.Text = "Please authorize"; this.groupId = 0; this.isAuthorized = false; this.isWorkingFolderSet = false; folderBrowserDialog1.RootFolder = Environment.SpecialFolder.Personal; vkLoginDialog = new VKLoginDialog(); // subscribe for login events vkLoginDialog.OnUserLogin += new VKLoginDialog.UserLoginHandler(OnUserLogin); vkRestApi = new VkRestApi(); // set up data handler vkRestApi.OnData += new VkRestApi.DataHandler(OnData); // set up error handler vkRestApi.OnError += new VkRestApi.ErrorHandler(OnError); // setup background group posts worker handlers this.backgroundGroupsWorker.DoWork += new DoWorkEventHandler(GroupsWork); this.backgroundGroupsWorker.ProgressChanged += new ProgressChangedEventHandler(groupsWorkProgressChanged); this.backgroundGroupsWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(groupsWorkCompleted); // setup background communication network worker handlers this.backgroundNetWorker.DoWork += new DoWorkEventHandler(netWork); this.backgroundNetWorker.ProgressChanged += new ProgressChangedEventHandler(NetWorkProgressChanged); this.backgroundNetWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(NetWorkCompleted); ActivateControls(); }
// main error handler public void OnError(object vkRestApi, VkRestApi.OnErrorEventArgs onErrorArgs) { // TODO: notify user about the error Debug.WriteLine("Function " + onErrorArgs.Function + ", returned error: " + onErrorArgs.Error); }
public VKFinderForm() { InitializeComponent(); this.userIdTextBox.Text = "Please authorize"; this.FindProgressBar.Minimum = 0; this.FindProgressBar.Maximum = 10000; this.FindProgressBar.Step = 1; updateStatus(0, "Ready"); vkLoginDialog = new VKLoginDialog(); // subscribe for login events vkLoginDialog.OnUserLogin += new VKLoginDialog.UserLoginHandler(UserLogin); vkRestApi = new VkRestApi(); // set up data handler vkRestApi.OnData += new VkRestApi.DataHandler(OnData); // set up error handler vkRestApi.OnError += new VkRestApi.ErrorHandler(OnError); // folder for files this.folderBrowserDialog1.Description = "Select the directory that you want to use to store files."; // this.folderBrowserDialog1.ShowNewFolderButton = false; // Default to the My Documents folder. this.folderBrowserDialog1.RootFolder = Environment.SpecialFolder.Personal; // this.folderBrowserDialog1.RootFolder = Environment.SpecialFolder.MyComputer; this.WorkingFolderTextBox.Text = this.folderBrowserDialog1.SelectedPath; // set up background find worker handlers this.backgroundFinderWorker.DoWork += new DoWorkEventHandler(findWork); this.backgroundFinderWorker.ProgressChanged += new ProgressChangedEventHandler(findWorkProgressChanged); this.backgroundFinderWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(findWorkCompleted); // set up background load worker handlers this.backgroundLoaderWorker.DoWork += new DoWorkEventHandler(loadWork); }
// main error handler private void OnError(object vkRestApi, VkRestApi.OnErrorEventArgs onErrorArgs) { // notify user about the error Debug.WriteLine("Function " + onErrorArgs.Function + ", returned error: " + onErrorArgs.Error); // keep on going ... this.backgroundFinderWorker.CancelAsync(); // indicate that we can continue readyEvent.Set(); }