Esempio n. 1
0
        private void ShowDeepSearchStatus()
        {
            if (this.IsDisposed)
            {
                return;
            }

            if (_InDeepSearch)
            {
                int total = LocalDatabase.problemList.Count;
                Interactivity.SetProgress(_DeepSearchProgress, total);
                string msg = "Searching for problems... [{0} of {1} problems completed.]";
                Interactivity.SetStatus(string.Format(msg, _DeepSearchProgress, total));

                _SetObjects(_deepSearchRes);
                problemListView.Sort(priorityProb, SortOrder.Descending);

                TaskQueue.AddTask(ShowDeepSearchStatus, 1000);
            }
            else
            {
                Interactivity.SetProgress(0);
                if (_CancelSearch)
                {
                    Interactivity.SetStatus("Deep search cancelled.");
                }
                else
                {
                    Interactivity.SetStatus("Deep search completed.");
                }
            }
        }
Esempio n. 2
0
        private static void __DownloadProblemDatabaseCompleted(DownloadTask task)
        {
            _DownloadingProblemDatabase = false;

            string msg = "Failed to update problem list.";

            if (task.Status == ProgressStatus.Completed)
            {
                LocalDatabase.LoadDatabase();
                msg = "Problem list is successfully updated.";
                Logger.Add("Downloaded problem database file", "__DownloadProblemDatabaseCompleted");
            }
            else if (task.Error != null)
            {
                if (task.Token == null)
                {
                    LocalDatabase.LoadDatabase();
                    Logger.Add(task.Error.Message, "__DownloadProblemDatabaseCompleted");
                }
                else
                {
                    DownloadFileAsync((string)task.Token, task.FileName, null, Priority.High,
                                      __DownloadProblemDatabaseProgress, __DownloadProblemDatabaseCompleted, 0);
                }
            }

            Interactivity.SetStatus(msg);
            Interactivity.SetProgress(0);
        }
Esempio n. 3
0
        void webClient1_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            try
            {
                string result = System.Text.Encoding.UTF8.GetString(e.Result);

                //update or add last submission id
                JudgeStatus[] statuslist = JsonConvert.DeserializeObject <JudgeStatus[]>(result);
                foreach (JudgeStatus status in statuslist)
                {
                    SetStatus(status);
                    if (status.id > LastSubID)
                    {
                        LastSubID = status.id;
                    }
                }

                Interactivity.SetProgress();
                Interactivity.SetStatus("Judge status update finished.");

                //set submission status
                submissionStatus.SetObjects(StatusList, false);
                submissionStatus.Sort(sidSUB, SortOrder.Descending);
                submissionStatus.EnsureVisible(0);
            }
            catch (Exception ex)
            {
                Interactivity.SetStatus("Judge status update failed.");
                Logger.Add(ex.Message, "Judge Status | webClient1_DownloadDataCompleted");
            }
            finally
            {
                LastUpdate = DateTime.Now;
            }
        }
Esempio n. 4
0
        private void dt_progressChanged(DownloadTask task)
        {
            string status = string.Format("Downloading submission data on problem... [{0} of {1} received]",
                                          Functions.FormatMemory(task.Received), Functions.FormatMemory(task.Total));

            Interactivity.SetStatus(status);
            Interactivity.SetProgress(task.ProgressPercentage);
        }
Esempio n. 5
0
        void webClient1_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
        {
            Interactivity.SetProgress(e.ProgressPercentage);
            string msg = "Downloading {0}'s submissions... [{1} out of {2}]";

            Interactivity.SetStatus(string.Format(msg, e.UserState,
                                                  Functions.FormatMemory(e.BytesReceived), Functions.FormatMemory(e.TotalBytesToReceive), true));
        }
Esempio n. 6
0
        private void ProgressChanged(Internet.DownloadTask task)
        {
            string file = Path.GetFileName(task.FileName);
            string text = string.Format("Downloading file : \"{0}\"... {1}% [{2} out of {3}] completed.",
                                        file, task.ProgressPercentage, Functions.FormatMemory(task.Received), Functions.FormatMemory(task.Total));

            Interactivity.SetStatus(text);
            Interactivity.SetProgress(task.Received, task.Total);
        }
Esempio n. 7
0
        void webClient1_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            if (this.IsDisposed)
            {
                return;
            }
            try
            {
                Interactivity.SetProgress();
                if (e.Cancelled)
                {
                    throw new OperationCanceledException();
                }
                if (e.Error != null)
                {
                    throw e.Error;
                }

                string result = System.Text.Encoding.UTF8.GetString(e.Result);

                if (currentUser != null)
                {
                    if (currentUser.uname != (string)e.UserState)
                    {
                        return;
                    }
                    currentUser.AddSubmissions(result);
                }
                else
                {
                    currentUser = JsonConvert.DeserializeObject <UserInfo>(result);
                    currentUser.Process();
                }

                string file = LocalDirectory.GetUserSubPath(currentUser.uname);
                string data = currentUser.GetJSONData();
                File.WriteAllText(file, data);

                ShowDataByTab();

                string msg = string.Format("Downloaded {0}'s submissions", e.UserState);
                Interactivity.SetStatus(msg);
                if (currentUser.LastSID == 0)
                {
                    Logger.Add(msg, "User Statistics");
                }
            }
            catch (Exception ex)
            {
                Interactivity.SetStatus(string.Format("Error while downloading {0}'s submissions.", e.UserState));
                Logger.Add(ex.Message, "UserStat | webClient1_DownloadDataCompleted");
            }
            finally
            {
                LastUpdate = DateTime.Now;
            }
        }
Esempio n. 8
0
        private static void __DownloadCategoryIndexProgress(DownloadTask task)
        {
            string msg = msg = "Downloading category index... [{0}/{1} completed]";

            msg = string.Format(msg, Functions.FormatMemory(task.Received), Functions.FormatMemory(task.Total));
            Interactivity.SetStatus(msg);

            int percent = task.ProgressPercentage;

            Interactivity.SetProgress(task.ProgressPercentage);
        }
Esempio n. 9
0
        private static void __DownloadProblemDatabaseProgress(DownloadTask task)
        {
            string msg = "Downloading problem list... [{0}/{1} completed]";

            msg = string.Format(msg, Functions.FormatMemory(task.Received), Functions.FormatMemory(task.Total));
            Interactivity.SetStatus(msg);

            int percent = task.ProgressPercentage;

            Interactivity.SetProgress(task.ProgressPercentage);
        }
Esempio n. 10
0
        private static void __DownloadUserInfoProgress(DownloadTask task)
        {
            string msg = "Downloading {0}'s submissions... [{1}/{2} completed]";

            msg = string.Format(msg, task.Token,
                                Functions.FormatMemory(task.Received), Functions.FormatMemory(task.Total));
            Interactivity.SetStatus(msg);

            int percent = task.ProgressPercentage;

            Interactivity.SetProgress(task.ProgressPercentage);
        }
Esempio n. 11
0
        private static void __DownloadUserInfoCompleted(DownloadTask task)
        {
            string msg = "Failed to downloaded user submissions.";

            if (task.Status == ProgressStatus.Completed)
            {
                LocalDatabase.LoadDefaultUser();
                msg = "Downloaded user submissions.";
            }
            else if (task.Error != null)
            {
                Logger.Add(task.Error.Message, "__DownloadUserInfoCompleted");
            }

            Interactivity.SetStatus(msg);
            Interactivity.SetProgress(0);
        }
Esempio n. 12
0
        private static void __DownloadProblemCategoryCompleted(DownloadTask task)
        {
            string msg = "Failed to downloaded category list.";

            if (task.Status == ProgressStatus.Completed)
            {
                LocalDatabase.LoadCategories();
                msg = "Downloaded category list.";
                Logger.Add("Downloaded problem's categories.", "Downloader");
            }
            else if (task.Error != null)
            {
                Logger.Add(task.Error.Message, "Downloader");
            }

            Interactivity.SetStatus(msg);
            Interactivity.SetProgress(0);
        }
Esempio n. 13
0
        private static void __DownloadCategoryFileCompleted(DownloadTask task)
        {
            string msg = "Failed to downloaded category list.";

            if (task.Status == ProgressStatus.Completed)
            {
                LocalDatabase.LoadCategoryData((string)task.Token);
                Interactivity.CategoryDataUpdated();

                msg = "Downloaded Category file: " + (string)task.Token;
                Logger.Add(msg, "__DownloadCategoryFileCompleted");
            }
            else if (task.Error != null)
            {
                Logger.Add(task.Error.Message, "__DownloadCategoryFileCompleted");
            }

            Interactivity.SetStatus(msg);
            Interactivity.SetProgress(0);
        }
Esempio n. 14
0
        private static void __DownloadProblemDatabaseCompleted(DownloadTask task)
        {
            _DownloadingProblemDatabase = false;

            string msg = "Failed to update problem list.";

            if (task.Status == ProgressStatus.Completed)
            {
                LocalDatabase.LoadDatabase();
                msg = "Problem list is successfully updated.";
                Logger.Add("Downloaded problem database file", "Downloader");
            }
            else if (task.Error != null)
            {
                Logger.Add(task.Error.Message, "Downloader");
            }

            Interactivity.SetStatus(msg);
            Interactivity.SetProgress(0);
        }
Esempio n. 15
0
 private void customWebBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
 {
     Interactivity.SetProgress(e.CurrentProgress, e.MaximumProgress);
 }
Esempio n. 16
0
 void webClient1_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
 {
     Interactivity.SetStatus("Judge status updating...");
     Interactivity.SetProgress(e.ProgressPercentage);
 }
Esempio n. 17
0
 void webClient2_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
 {
     Interactivity.SetProgress(e.ProgressPercentage);
     Interactivity.SetStatus(string.Format("Downloading rank-list... [{0} out of {1}]",
                                           Functions.FormatMemory(e.BytesReceived), Functions.FormatMemory(e.TotalBytesToReceive)));
 }