public static void BrowseFileInfo(Document doc, BusyIndicator busyIndicator) { if (doc == null || doc.DocumentId < 1) { return; } if (Application.Current.IsRunningOutOfBrowser) { busyIndicator.IsBusy = true; busyIndicator.BusyContent = "正在下载文件..."; new DocumentDomainContext().DownloadFile(doc.UniqeName, doc.Revision, AuthenticateStatus.CurrentUser.UserId, obj => { busyIndicator.IsBusy = false; if (CheckInvokeOperation(obj)) { if (obj.Value == null) { CustomMessageBox.Alert("您要打开的文件不存在或者已经损坏,请与系统管理员联系!"); } else if (obj.Value.Content == null || obj.Value.Content.Length < 1) { CustomMessageBox.Alert("您要下载的文件内容为空!"); } else { Random rand = new Random(100); string strFile = string.Format("{0}{1}_{2}.{3}", GetTempLocalFolder(), obj.Value.UniqeName, rand.Next(), obj.Value.FileType.ToString().ToLower()); DocumentReader.Close(); using (var fs = new FileStream(strFile, FileMode.Create)) { fs.Write(obj.Value.Content, 0, obj.Value.Content.Length); } DocumentReader.Open(strFile); } } }, null); } else { var dialog = new SaveFileDialog { DefaultExt = Path.GetExtension(doc.OrignalName) }; dialog.Filter = string.Format("{0}|*.{1}", doc.FileType, dialog.DefaultExt); dialog.DefaultFileName = doc.FileName; var dResult = dialog.ShowDialog(); if (dResult != null && dResult.Value) { busyIndicator.IsBusy = true; busyIndicator.BusyContent = "正在下载文件..."; new DocumentDomainContext().DownloadFile(doc.UniqeName, doc.Revision, AuthenticateStatus.CurrentUser.UserId, obj => { busyIndicator.IsBusy = false; if (CheckInvokeOperation(obj)) { if (obj.Value == null) { CustomMessageBox.Alert("您要打开的文件不存在或者已经损坏,请与系统管理员联系!"); } else if (obj.Value.Content == null || obj.Value.Content.Length < 1) { CustomMessageBox.Alert("您要下载的文件内容为空!"); } else { using (var stream = dialog.OpenFile()) stream.Write(obj.Value.Content, 0, obj.Value.Content.Length); } } }, null); } } }