public void AddHistoryItem(WorkerTask task)
        {
            if (Engine.ConfigOptions.HistorySave)
            {
                foreach (UploadResult ur in task.UploadResults)
                {
                    HistoryManager.AddHistoryItemAsync(Engine.HistoryPath, task.GenerateHistoryItem(ur));
                }
            }

            Adapter.AddRecentItem(task.Info.LocalFilePath);
        }
Пример #2
0
        private static void task_UploadCompleted(WorkerTask task)
        {
            try
            {
                if (ListViewControl != null && task != null && task.Result != null)
                {
                    ListViewItem lvi = ListViewControl.Items[task.Id];
                    lvi.Tag = task.Result;

                    if (task.Result.IsError)
                    {
                        string errors = string.Join("\r\n\r\n", task.Result.Errors.ToArray());

                        DebugHelper.WriteLine("Upload failed. ID: {0}, Filename: {1}, Errors:\r\n{2}", task.Id, task.Info.FileName, errors);

                        lvi.SubItems[1].Text = "Error";
                        lvi.SubItems[8].Text = string.Empty;
                        lvi.ImageIndex       = 1;

                        if (Engine.ConfigOptions.CompleteSound)
                        {
                            SystemSounds.Asterisk.Play();
                        }
                    }
                    else
                    {
                        DebugHelper.WriteLine("Upload completed. ID: {0}, Filename: {1}, URL: {2}, Duration: {3}ms", task.Id, task.Info.FileName,
                                              task.Result.URL, (int)task.UploadDuration);

                        lvi.SubItems[1].Text = task.Status.GetDescription();
                        lvi.ImageIndex       = 2;

                        if (!string.IsNullOrEmpty(task.Result.URL))
                        {
                            string url = string.IsNullOrEmpty(task.Result.ShortenedURL) ? task.Result.URL : task.Result.ShortenedURL;

                            lvi.SubItems[8].Text = url;

                            if (Engine.ConfigWorkflow.ClipboardOverwrite)
                            {
                                ZAppHelper.CopyTextSafely(url);
                            }

                            if (Engine.ConfigOptions.HistorySave)
                            {
                                HistoryManager.AddHistoryItemAsync(Engine.HistoryPath, task.GenerateHistoryItem());
                            }
                        }

                        if (Engine.ConfigOptions.CompleteSound)
                        {
                            SystemSounds.Exclamation.Play();
                        }
                    }

                    lvi.EnsureVisible();
                }
            }
            finally
            {
                StartTasks();
                //  UpdateTrayIcon();
            }
        }