コード例 #1
0
        private static async void StartUpload()
        {
            if (Form.Uploading)
            {
                return;
            }
            if (UploadQueue.Count == 0)
            {
                return;
            }

            UploadContract contract = UploadQueue.Dequeue();

            try
            {
                contract.Uploader = await Client.UploadFile(contract.Path, contract.Filename);
            }
            catch (RetryException e)
            {
                if (e.LastException is IOException)
                {
                    MessageBox.Show($"Couldn´t upload file \"{contract.Filename}\":\n{e.Message}");
                    StartUpload();
                    return;
                }
                throw;
            }

            Form.StartUpload(contract);
        }
コード例 #2
0
 public void StartUpload(UploadContract contract)
 {
     StatusLabel.Invoke(new Action(() => StatusLabel.Text = "Uploading: " + contract.Filename));
     Uploading  = true;
     FileUpload = contract;
     UploadTimer.Start();
 }
コード例 #3
0
        public static void UploadFile(string filename)
        {
            if (!File.Exists(filename))
            {
                throw new FileNotFoundException();
            }

            UploadContract c = new UploadContract
            {
                Uploader = null,
                Path     = filename,
                Filename = Path.GetFileName(filename),

                Share            = true,
                FirstView        = false,
                Public           = true,
                PublicRegistered = true,
                Whitelisted      = false,
                Whitelist        = ""
            };

            Enqueue(c);
        }
コード例 #4
0
        private async void UploadButton_Click(object sender, EventArgs e)
        {
            if (File.Exists(PathText.Text) && !Uploading)
            {
                FileUploader u = await Client.UploadFile(PathText.Text, FilenameText.Text);

                var c = new UploadContract
                {
                    Uploader = u,
                    Path     = PathText.Text,
                    Filename = FilenameText.Text,

                    Share            = ShareBox.Checked,
                    FirstView        = FirstViewBox.Checked,
                    Public           = PublicBox.Checked,
                    PublicRegistered = PublicRegisteredBox.Checked,
                    Whitelisted      = WhitelistedBox.Checked,
                    Whitelist        = WhitelistText.Text
                };

                StartUpload(c);
            }
        }
コード例 #5
0
 public static void Enqueue(UploadContract contract)
 {
     UploadQueue.Enqueue(contract);
     StartUpload();
 }