Exemplo n.º 1
0
        internal void WriteExecutionLog(AsyncTask asyncTask)
        {
            var name = asyncTask.GetType().Name;

            Results.Add(string.Format("{0}: {1}", name, serialNumber));
        }
Exemplo n.º 2
0
        public ListViewItem AddTask(AsyncTask newTask)
        {
            if (!newTask.Visible)
            {
                return null;
            }

            var taskItem = new ListViewItem { Tag = newTask };
            taskItem.SubItems.Add(Util.GetString(newTask.GetType().Name)).Name = "type";
            if (newTask is UploadFolderTask)
            {
                var task = (UploadFolderTask)newTask;
                taskItem.Text = Common.GetFileOrDirectoryName(task.Path);
                //taskItem.SubItems.Add(Util.GetString("UploadFolder")).Name = "type";
                taskItem.SubItems.Add("").Name = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is DownloadFileFromStorageTask)
            {
                var task = (DownloadFileFromStorageTask)newTask;
                taskItem.Text = task.File.Name;
                //taskItem.SubItems.Add(Util.GetString("DownloadFileFromStorage")).Name = "type";
                taskItem.SubItems.Add(Common.NumberOfBytesToString(task.File.OriginalSize)).Name = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is DownloadFileFromDriveTask)
            {
                var task = (DownloadFileFromDriveTask)newTask;
                taskItem.Text = task.File.Name;
                //taskItem.SubItems.Add(Util.GetString("DownloadFileFromDisk")).Name = "type";
                taskItem.SubItems.Add(Common.NumberOfBytesToString(task.File.OriginalSize)).Name = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is UploadFileTask)
            {
                var task = (UploadFileTask)newTask;
                taskItem.Text = Path.GetFileName(task.FileName);
                var fileInfo = new FileInfo(task.FileName);
                //taskItem.SubItems.Add(Util.GetString("UploadFile")).Name = "type";
                taskItem.SubItems.Add(Common.NumberOfBytesToString(fileInfo.Length)).Name = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is CreateFolderTask)
            {
                var task = (CreateFolderTask)newTask;
                taskItem.Text = Path.GetFileName(task.FolderName);
                //taskItem.SubItems.Add(Util.GetString("CreateFolder")).Name = "type";
                taskItem.SubItems.Add("").Name = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is DeleteFolderTaskBase)
            {
                var task = (DeleteFolderTaskBase)newTask;
                taskItem.Text = Path.GetFileName(task.Folder.Name);
                //if (task is DeleteEmptyFolderTask)
                //    taskItem.SubItems.Add(Util.GetString("DeleteEmptyFolder")).Name = "type";
                //else
                //    taskItem.SubItems.Add(Util.GetString("DeleteFolder")).Name = "type";
                taskItem.SubItems.Add("").Name = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is DeleteFileTask)
            {
                var task = (DeleteFileTask)newTask;
                taskItem.Text = Path.GetFileName(task.File.Name);
                //taskItem.SubItems.Add(Util.GetString("DeleteFile")).Name = "type";
                taskItem.SubItems.Add("").Name = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is DownloadFolderTask)
            {
                var task = (DownloadFolderTask)newTask;
                taskItem.Text = Path.GetFileName(task.Folder.Name);
                //taskItem.SubItems.Add(Util.GetString("DownloadFolder")).Name = "type";
                taskItem.SubItems.Add("").Name = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is SynchronizeFileTask)
            {
                var task = (SynchronizeFileTask)newTask;
                taskItem.Text = Path.GetFileName(task.SourceFile.Name);
                //taskItem.SubItems.Add(Util.GetString("SyncFile")).Name = "type";
                taskItem.SubItems.Add(Common.NumberOfBytesToString(task.SourceFile.Size)).Name = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is SynchronizeDriveFileTask)
            {
                var task = (SynchronizeDriveFileTask)newTask;
                taskItem.Text = Path.GetFileName(task.File?.Name);
                //taskItem.SubItems.Add(Util.GetString("SyncFileOnDrive")).Name = "type";
                taskItem.SubItems.Add(Common.NumberOfBytesToString(0)).Name = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is DownloadGlacierInventoryTask)
            {
                var task = (DownloadGlacierInventoryTask)newTask;
                //taskItem.SubItems.Add(Util.GetString("DownloadInventory")).Name = "type";
                taskItem.SubItems.Add(Common.NumberOfBytesToString(0)).Name = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }

            switch (newTask.State)
            {
                case AsyncTaskState.Cancelled:
                    taskItem.ImageKey = "cancel";
                    break;
                case AsyncTaskState.Completed:
                    taskItem.ImageKey = "ok";
                    break;
                case AsyncTaskState.Error:
                    taskItem.ImageKey = "error_red";
                    break;
                case AsyncTaskState.Running:
                    taskItem.ImageKey = "run";
                    break;
                case AsyncTaskState.Waiting:
                    taskItem.ImageKey = "queued";
                    break;
            }
            return taskListView.Items.Add(taskItem);
        }
Exemplo n.º 3
0
 internal void WriteExecutionLog(AsyncTask asyncTask)
 {
     var name = asyncTask.GetType().Name;
     Results.Add(string.Format("{0}: {1}", name, serialNumber));
 }
Exemplo n.º 4
0
        public ListViewItem AddTask(AsyncTask newTask)
        {
            if (!newTask.Visible)
            {
                return(null);
            }

            var taskItem = new ListViewItem {
                Tag = newTask
            };

            taskItem.SubItems.Add(Util.GetString(newTask.GetType().Name)).Name = "type";
            if (newTask is UploadFolderTask)
            {
                var task = (UploadFolderTask)newTask;
                taskItem.Text = Common.GetFileOrDirectoryName(task.Path);
                //taskItem.SubItems.Add(Util.GetString("UploadFolder")).Name = "type";
                taskItem.SubItems.Add("").Name  = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is DownloadFileFromStorageTask)
            {
                var task = (DownloadFileFromStorageTask)newTask;
                taskItem.Text = task.File.Name;
                //taskItem.SubItems.Add(Util.GetString("DownloadFileFromStorage")).Name = "type";
                taskItem.SubItems.Add(Common.NumberOfBytesToString(task.File.OriginalSize)).Name = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is DownloadFileFromDriveTask)
            {
                var task = (DownloadFileFromDriveTask)newTask;
                taskItem.Text = task.File.Name;
                //taskItem.SubItems.Add(Util.GetString("DownloadFileFromDisk")).Name = "type";
                taskItem.SubItems.Add(Common.NumberOfBytesToString(task.File.OriginalSize)).Name = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is UploadFileTask)
            {
                var task = (UploadFileTask)newTask;
                taskItem.Text = Path.GetFileName(task.FileName);
                var fileInfo = new FileInfo(task.FileName);
                //taskItem.SubItems.Add(Util.GetString("UploadFile")).Name = "type";
                taskItem.SubItems.Add(Common.NumberOfBytesToString(fileInfo.Length)).Name = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is CreateFolderTask)
            {
                var task = (CreateFolderTask)newTask;
                taskItem.Text = Path.GetFileName(task.FolderName);
                //taskItem.SubItems.Add(Util.GetString("CreateFolder")).Name = "type";
                taskItem.SubItems.Add("").Name  = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is DeleteFolderTaskBase)
            {
                var task = (DeleteFolderTaskBase)newTask;
                taskItem.Text = Path.GetFileName(task.Folder.Name);
                //if (task is DeleteEmptyFolderTask)
                //    taskItem.SubItems.Add(Util.GetString("DeleteEmptyFolder")).Name = "type";
                //else
                //    taskItem.SubItems.Add(Util.GetString("DeleteFolder")).Name = "type";
                taskItem.SubItems.Add("").Name  = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is DeleteFileTask)
            {
                var task = (DeleteFileTask)newTask;
                taskItem.Text = Path.GetFileName(task.File.Name);
                //taskItem.SubItems.Add(Util.GetString("DeleteFile")).Name = "type";
                taskItem.SubItems.Add("").Name  = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is DownloadFolderTask)
            {
                var task = (DownloadFolderTask)newTask;
                taskItem.Text = Path.GetFileName(task.Folder.Name);
                //taskItem.SubItems.Add(Util.GetString("DownloadFolder")).Name = "type";
                taskItem.SubItems.Add("").Name  = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is SynchronizeFileTask)
            {
                var task = (SynchronizeFileTask)newTask;
                taskItem.Text = Path.GetFileName(task.SourceFile.Name);
                //taskItem.SubItems.Add(Util.GetString("SyncFile")).Name = "type";
                taskItem.SubItems.Add(Common.NumberOfBytesToString(task.SourceFile.Size)).Name = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is SynchronizeDriveFileTask)
            {
                var task = (SynchronizeDriveFileTask)newTask;
                taskItem.Text = Path.GetFileName(task.File?.Name);
                //taskItem.SubItems.Add(Util.GetString("SyncFileOnDrive")).Name = "type";
                taskItem.SubItems.Add(Common.NumberOfBytesToString(0)).Name = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }
            else if (newTask is DownloadGlacierInventoryTask)
            {
                var task = (DownloadGlacierInventoryTask)newTask;
                //taskItem.SubItems.Add(Util.GetString("DownloadInventory")).Name = "type";
                taskItem.SubItems.Add(Common.NumberOfBytesToString(0)).Name = "size";
                taskItem.SubItems.Add("0").Name = "percent";
            }

            switch (newTask.State)
            {
            case AsyncTaskState.Cancelled:
                taskItem.ImageKey = "cancel";
                break;

            case AsyncTaskState.Completed:
                taskItem.ImageKey = "ok";
                break;

            case AsyncTaskState.Error:
                taskItem.ImageKey = "error_red";
                break;

            case AsyncTaskState.Running:
                taskItem.ImageKey = "run";
                break;

            case AsyncTaskState.Waiting:
                taskItem.ImageKey = "queued";
                break;
            }
            return(taskListView.Items.Add(taskItem));
        }