コード例 #1
0
ファイル: ProblemTraceForm.cs プロジェクト: posjaj/BugTrace
        private void UploadAttachment()
        {
            string fileServiceUrl = string.Empty;

            using (BugTraceEntities zentity = new BugTraceEntities(EntityContextHelper.GetEntityConnString()))
            {
                var currVersion = zentity.SYS_Version.Where(p => p.IsDefault == 1).FirstOrDefault();
                fileServiceUrl = currVersion.FileServiceUrlPort;
            }
            try
            {
                string          filepath = this.txtAttachment.Text;
                EndpointAddress address  = new EndpointAddress("http://" + fileServiceUrl + "/JAJ.WinServer/FileService");
                FileTransferSvc.FileServiceClient _client    = new FileTransferSvc.FileServiceClient("BasicHttpBinding_IFileService", address);
                FileTransferSvc.TransferFileData  uploadData = new FileTransferSvc.TransferFileData();
                uploadData.FileName     = Path.GetFileName(filepath);
                uploadData.FileData     = File.OpenRead(filepath);
                uploadData.FileSize     = (int)uploadData.FileData.Length;
                uploadData.FileUniqueID = this._attachmentUniqueID;
                uploadData.FileType     = "PPM_ProblemTrace";
                uploadData.oldFileName  = this._oldFileName;
                wait = new FrmWait("正 在 上 传 请 稍 候");
                wait.Show();
                _client.UploadFileAsync(uploadData.FileName, uploadData.FileSize, uploadData.FileType,
                                        uploadData.FileUniqueID, uploadData.oldFileName, uploadData.FileData);
                _client.UploadFileCompleted += _client_UploadFileCompleted;
            }
            catch (Exception ex)
            {
                MessageBox.Show("文件上传失败!");
                MyLog.LogError("保存问题跟踪时文件上传失败!", ex);
                return;
            }
        }
コード例 #2
0
ファイル: TestFrmUploadFile.cs プロジェクト: posjaj/BugTrace
        private void btnUpload_Click(object sender, EventArgs e)
        {
            var filepath = textBox1.Text;

            if (string.IsNullOrEmpty(filepath) || !File.Exists(filepath))
            {
                return;
            }
            _uploadCompleted = false;
            FileTransferSvc.TransferFileData uploadData = new FileTransferSvc.TransferFileData();
            uploadData.FileName     = Path.GetFileName(filepath);
            uploadData.FileData     = File.OpenRead(filepath);
            uploadData.FileSize     = uploadData.FileData.Length;
            uploadData.FileUniqueID = Guid.NewGuid().ToString();
            uploadData.FileType     = "test";
            uploadData.oldFileName  = "";
            _client.UploadFileAsync(uploadData.FileName, uploadData.FileSize, uploadData.FileType, uploadData.FileUniqueID, uploadData.oldFileName, uploadData.FileData);
            _client.UploadFileCompleted += _client_UploadFileCompleted;
            _uploadWatchThread           = new Thread(UpdateFileUploadInfo);
            _uploadWatchThread.Start(uploadData);
            btnBrowser.Enabled = false;
            btnUpload.Enabled  = false;
        }