示例#1
0
        private void UploadExecute(object obj)
        {
            var team = obj as WrapTeam;

            if (team == null || team.Team.ID <= 0)
            {
                return;
            }
            OpenFileDialog dialog = new OpenFileDialog();

            if (dialog.ShowDialog() == true)
            {
                var attach = new attach()
                {
                    Type     = "Team",
                    TypeID   = team.Team.ID,
                    FileName = dialog.File.Name,
                    Path     = string.Format("ClientBin/Attach/Teams/{0}/{1}", team.Team.ID, dialog.File.Name)
                };
                var client = Utils.ServicesFactory.CreateMatchService();
                client.AddAttachesAsync(new ObservableCollection <attach>()
                {
                    attach
                });
                var item = new UploadItemInfo(dialog.File.Name, dialog.File.OpenRead());
                StartUpload(team.Team.ID, item);
            }
        }
示例#2
0
        private void StartUpload(int teamID, UploadItemInfo item)
        {
            WebClient client = new WebClient();

            client.OpenWriteCompleted += Client_OpenWriteCompleted;
            client.WriteStreamClosed  += Client_WriteStreamClosed;
            string queryString = string.Format("filePath={0}&fileName={1}", "ClientBin/Attach/Teams/" + teamID, item.Name);

            client.OpenWriteAsync(new Uri(App.Root + "UploadFileHandler.ashx?" + queryString), "post", item.Stream);
        }