Ejemplo n.º 1
0
        private void btnChonFile_Click(object sender, EventArgs e)
        {
            //Chọn files
            OpenFileDialog x = new OpenFileDialog();

            x.Multiselect = true;
            x.ShowDialog();
            string[] file_names = x.FileNames;
            if (file_names.Count() > 0)
            {
                //Tạo chứng từ mới
                //ct = new ChungTu();
                //ct.ngay = ServerTimeHelper.getNow();
                //ct.sohieu = "mã chứng từ";
                //Gán attchment
                foreach (string file_name in file_names)
                {
                    Attachment tmp = new Attachment();
                    tmp.LOCAL_FILE_PATH = file_name;
                    ct.attachments.Add(tmp);
                }
                //register event
                ct.onUploadProgress += new SHARED.Libraries.FTPHelper.UploadProgress(this.onChungTu_Uploading);
                // do in background
                //var taskA = new Task(() => ct.upload());
                //taskA.ContinueWith(new Action<Task>(this.onUploadFinish));
                //taskA.Start();
                Task.Factory.StartNew(() => ct.upload().Wait())
                .ContinueWith(new Action <Task>(this.onUploadFinish));
            }
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Chọn files
            OpenFileDialog x = new OpenFileDialog();

            x.Multiselect = true;
            x.ShowDialog();
            string[] file_names = x.FileNames;
            //Tạo chứng từ mới
            ct        = new ChungTu();
            ct.ngay   = ServerTimeHelper.getNow();
            ct.sohieu = "mã chứng từ";
            //Gán attchment
            foreach (string file_name in file_names)
            {
                Attachment tmp = new Attachment();
                tmp.LOCAL_FILE_PATH = file_name;
                ct.attachments.Add(tmp);
            }
            //register event
            ct.onUploadProgress += new SHARED.Libraries.FTPHelper.UploadProgress(this.onChungTu_Uploading);
            // do in background
            cancel = new CancellationTokenSource();
            var re = ct.upload(cancel.Token).ContinueWith(new Action <Task>(this.onUploadFinish));
        }
Ejemplo n.º 3
0
 private void button1_Click(object sender, EventArgs e)
 {
     //Chọn files
     OpenFileDialog x = new OpenFileDialog();
     x.Multiselect = true;
     x.ShowDialog();
     string[] file_names = x.FileNames;
     //Tạo chứng từ mới
     ct = new ChungTu();
     ct.ngay = ServerTimeHelper.getNow();
     ct.sohieu = "mã chứng từ";
     //Gán attchment
     foreach (string file_name in file_names)
     {
         Attachment tmp = new Attachment();
         tmp.LOCAL_FILE_PATH = file_name;
         ct.attachments.Add(tmp);
     }
     //register event
     ct.onUploadProgress += new SHARED.Libraries.FTPHelper.UploadProgress(this.onChungTu_Uploading);
     // do in background
     cancel = new CancellationTokenSource();
     var re = ct.upload(cancel.Token).ContinueWith(new Action<Task>(this.onUploadFinish));
 }