コード例 #1
0
        public void Execute(object parameter)
        {
            if (_vm.NumberOfUploadedFiles == _vm.TotalNumberOfFiles)
            {
                _vm.IsBusy = true;
                var uriBuilder = new UriBuilder(App.ImageServiceURL);
                var r          = new Random();
                uriBuilder.Query = string.Format("Function=SaveImageUrl&r={0}&InventoryStatus={1}&ListingId={2}",
                                                 r.Next(), App.InventoryStatus,
                                                 App.ListingId);
                var client = new WebClient();
                client.UploadStringCompleted += client_UploadStringCompleted;
                CarImage data = GetPostData();
                using (var ms = new MemoryStream())
                {
                    var serializer = new DataContractJsonSerializer(data.GetType());
                    serializer.WriteObject(ms, data);
                    ms.Position = 0;

                    using (var reader = new StreamReader(ms))
                    {
                        client.UploadStringAsync(uriBuilder.Uri, reader.ReadToEnd());
                    }
                }
            }
            else
            {
                ErrorHandler.ShowWarning("Wait until your upload is finished.");
            }
        }