private void OnUpdateFileCommand() { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == true) { String fileName = ofd.File.Name; foreach (PlanOutlineFileEntity entity in planOutLineFileList) { if (entity.fileName == fileName) { NotifyWindow notificationWindow = new NotifyWindow("错误", "已上传相同的文件!"); notificationWindow.Show(); return; } } App app = Application.Current as App; newEntity = new PlanOutlineFileEntity(); newEntity.UserID = app.UserInfo.UserID; newEntity.UserName = app.UserInfo.UserName; newEntity.FileName = fileName; UserFile = new FileUploader.UserFile(); UserFile.FileName = fileName; UserFile.FolderName = "PlanOutline"; UserFile.FileStream = ofd.File.OpenRead(); newEntity.FileBytes = UserFile.FileStream.Length; IsBusy = true; UserFile.FinishUpdate += UserFile_FinishUpdate; UserFile.Upload("", dependencyObject.Dispatcher); } }
private void LoadPlanOutLineEntitiesCompleted(LoadOperation<plan_outline_files> aLoadOperation) { planOutLineFileList.Clear(); foreach (plan_outline_files file in aLoadOperation.Entities) { PlanOutlineFileEntity entity = new PlanOutlineFileEntity(); entity.PlanFiles = file; entity.Update(); planOutLineFileList.Add(entity); } UpdateChanged("planOutLineFileList"); (OnDeleteFile as DelegateCommand).RaiseCanExecuteChanged(); }