Ejemplo n.º 1
0
 public SimpleUploadTask(string filePath, string token, string uploadUrl)
 {
     FilePath         = filePath;
     Token            = token;
     Address          = uploadUrl;
     TotalBytes       = new FileInfo(filePath).Length;
     UploadTaskStatus = UploadTaskStatus.Active;
 }
Ejemplo n.º 2
0
        public bool TaskOperate(UploadTaskStatus todo)
        {
            //仅接受todo为active/pause/abort,其余指令将被丢弃
            lock (syncUploadTaskStatusObject)
            {
                if (uploadTaskStatus == todo)
                {
                    return(true);
                }
                switch (todo)
                {
                case UploadTaskStatus.Active:
                    if (uploadTaskStatus == UploadTaskStatus.Pause)
                    {
                        uploadTaskStatus = UploadTaskStatus.Active;
                        return(true);
                    }
                    else if (uploadTaskStatus == UploadTaskStatus.Error)
                    {
                        UploadBatch      = Guid.NewGuid().ToString();
                        TotalBytes       = new FileInfo(FilePath).Length;
                        TotalBlockCount  = (TotalBytes + SliceUploadWorker.BLOCKSIZE - 1) / SliceUploadWorker.BLOCKSIZE;
                        TotalContents    = new string[TotalBlockCount];
                        UploadTaskStatus = UploadTaskStatus.Active;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }

                case UploadTaskStatus.Pause:
                    if (uploadTaskStatus == UploadTaskStatus.Active)
                    {
                        uploadTaskStatus = UploadTaskStatus.Pause;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }

                case UploadTaskStatus.Abort:
                    if (uploadTaskStatus != UploadTaskStatus.Completed)
                    {
                        uploadTaskStatus = UploadTaskStatus.Abort;
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }

                default:
                    return(false);
                }
            }
        }
Ejemplo n.º 3
0
 public SliceUploadTask(string filePath, string token, string uploadUrl)
 {
     FilePath         = filePath;
     Token            = token;
     Address          = uploadUrl;
     UploadBatch      = Guid.NewGuid().ToString();
     TotalBytes       = new FileInfo(filePath).Length;
     TotalBlockCount  = (TotalBytes + SliceUploadWorker.BLOCKSIZE - 1) / SliceUploadWorker.BLOCKSIZE;
     TotalContents    = new string[TotalBlockCount];
     UploadTaskStatus = UploadTaskStatus.Active;
 }
Ejemplo n.º 4
0
 public bool TaskOperate(UploadTaskStatus todo)
 {
     return(false);
 }