Example #1
0
 private void SendEvent(Upload upload = null)
 {
     if (upload == null)
     {
         OnUpload?.Invoke(this, Upload);
     }
     else
     {
         OnUpload?.Invoke(this, upload);
     }
 }
Example #2
0
 public override void OnAcceptKeyPressed()
 {
     Close();
     OnUpload?.Invoke();
 }
 public void InvokeUpload()
 {
     //Console.WriteLine("InvokeUpload");
     OnUpload?.Invoke();
 }
 private void NotifyStateChanged() => OnUpload?.Invoke();
        private void Upload()
        {
            if (Uploading)
            {
                return;
            }
            Uploading = true;
            Task.Run(() =>
            {
                while (true)
                {
                    var uploadTask = _taskList.Where(item => item.IsUpload && !item.IsFail && !item.IsCompleted).FirstOrDefault();
                    if (uploadTask == null)
                    {
                        uploadTask = _taskList.Where(item => item.IsUpload && item.IsFail).OrderBy(item => item.FailedTime).FirstOrDefault();
                    }
                    if (uploadTask == null)
                    {
                        break;
                    }

                    OnUpload?.Invoke(uploadTask);

                    if (storages == null || !storages.Any())
                    {
                        var result = _storageProvider.GetStorages();
                        if (!result.Item1)
                        {
                            uploadTask.UploadStatus = "无可用存储";
                            break;
                        }
                        storages = result.Item2.Item1;
                    }
                    foreach (var storage in storages)
                    {
                        if (uploadTask.UploadedStorage.ContainsKey(storage.StorageInfo.ID))
                        {
                            if (uploadTask.UploadedStorage[storage.StorageInfo.ID])
                            {
                                continue;
                            }
                        }
                        else
                        {
                            uploadTask.UploadedStorage.Add(storage.StorageInfo.ID, false);
                        }
                        storage.UploadFile(uploadTask);
                    }
                    if (!uploadTask.UploadedStorage.Any(item => !item.Value))
                    {
                        var notifyVideoUploadCompletedForm = new NotifyVideoUploadCompletedForm()
                        {
                            RecordID   = uploadTask.RecordInfo.ScheduleId,
                            videoIndex = uploadTask.RecordInfo.Index,
                            Duration   = (int)uploadTask.RecordInfo.Duration,
                        };
                        foreach (var item in uploadTask.Results)
                        {
                            notifyVideoUploadCompletedForm.Storages.Add(item);
                        }

                        var result              = _serviceClient.GetResponse(_webPlatformApiFactory.CreateVideoUploadCompletedRequest(notifyVideoUploadCompletedForm));
                        uploadTask.IsCompleted  = result.Success;
                        uploadTask.UploadStatus = "上传完成";
                    }
                    Thread.Sleep(500);
                }

                Uploading = false;
            });
        }
Example #6
0
 private void FireUpload()
 {
     OnUpload?.Invoke();
 }