Example #1
0
        protected virtual string GetUploadStatus(HttpContext context)
        {
            bool isId;
            Guid fileId = this.GetQueryStringID(context, Constants.Upload.Id, "Get Upload Status functionality failed. Upload File Id property is not defined or is in incorrect format", out isId);

            FileUploadStatus status = null;

            if (isId)
            {
                status = UploadManager.GetStatus(fileId);
            }

            if (status == null)
            {
                return(this.HandleNullStatus(context, fileId));
            }

            return(JsonConvert.SerializeObject(status));
        }
Example #2
0
        public override void Update(Guid mediaItemId, Guid fileId, Guid accountId, byte progress, string error = null, bool canceled = false)
        {
            progress = Math.Min(progress, (byte)100);

            var tmp = new FileUploadStatus
            {
                FileId = fileId,
            };

            tmp.ProgressList.Add(new AccountUploadStatus(mediaItemId, accountId, progress, error, canceled));

            this.StatusList.AddOrUpdate(
                fileId,
                tmp,
                (guid, status) =>
            {
                var accountData = status.ProgressList.FirstOrDefault(i => i.AccountId == accountId);

                if (accountData != null)
                {
                    if (accountData.Canceled)
                    {
                        return(status);
                    }

                    accountData.Progress    = progress;
                    accountData.MediaItemId = mediaItemId;
                    accountData.Error       = error;
                    accountData.Canceled    = canceled;
                }
                else
                {
                    status.ProgressList.Add(new AccountUploadStatus {
                        AccountId = accountId, Progress = progress, MediaItemId = mediaItemId, Error = error, Canceled = canceled
                    });
                }

                return(status);
            });
        }