private void OpenFile(WfAdjunctFile adjunctFile) { if (adjunctFile == null) { throw new ArgumentNullException("WfAdjunctFile cannot be null"); } if (adjunctFile.Data.Length > 0) { try { Process.Start(this.SaveFile(adjunctFile)); } catch (Exception exception) { MessageHelper.ShowInfo("你可能已经打开同名文件!\r打开文件时发生错误:" + exception.Message); } } else { MessageHelper.ShowInfo("附件大小等于0,无法打开文件!"); } }
protected string SaveFile(WfAdjunctFile adjunctFile) { string path = Path.GetTempFileName() + adjunctFile.Type; File.WriteAllBytes(path, adjunctFile.Data); return path; }
protected string SaveFile(WfAdjunctFile adjunctFile, string path) { string str = string.Concat(new object[] { path, Path.DirectorySeparatorChar, adjunctFile.Name, adjunctFile.Type }); File.WriteAllBytes(str, adjunctFile.Data); return str; }
protected WfAdjunctFile GetAdjunctFile(WfAdjunct adj) { if (adj.File != null) { return adj.File; } WfAdjunctFile file = new WfAdjunctFile(adj); IList<WfAdjunctFile> list = QueryHelper.List<WfAdjunctFile>(string.Empty, new string[] { "Id" }, new string[] { adj.Id }); if (list.Count == 0) { throw new NullReferenceException("Not find the adjunct file"); } file.Data = list[0].Data; return file; }