internal bool SelectFileToAdjuct(WfAdjunct adjunct) { if (adjunct == null) { throw new NullReferenceException("WfAdjunct cannot be null"); } OpenFileDialog dialog = new OpenFileDialog(); dialog.Title = "请选择附件"; dialog.Filter = "Word 文件 (*.doc)|*.txt|All files (*.*)|*.*"; dialog.FilterIndex = 2; if (dialog.ShowDialog() == DialogResult.OK) { Stream stream = dialog.OpenFile(); if (stream != null) { if (adjunct.File == null) { adjunct.File = new WfAdjunctFile(adjunct); } adjunct.File.Data = Read2Buffer(stream, -1); stream.Close(); adjunct.Type = Path.GetExtension(dialog.FileName); if (StringHelper.IsNull(adjunct.Name)) { adjunct.Name = Path.GetFileNameWithoutExtension(dialog.FileName); } return true; } } return false; }
public override void Run() { WfAdjunct adjunct = new WfAdjunct(); if (base.SelectFileToAdjuct(adjunct)) { adjunct.Id = StringHelper.GetNewGuid(); adjunct.ProinstId = base.ae.ProinstId; adjunct.CreateDate = new DateTime?(DateTimeHelper.GetNow()); SmIdentity smIdentity = SecurityUtil.GetSmIdentity(); adjunct.CreateStaffId = smIdentity.UserId; adjunct.CreateStaffName = smIdentity.UserName; base.ae.CurrentUnitOfWork.RegisterNew(adjunct); base.ae.CurrentUnitOfWork.RegisterDirty(adjunct.File); base.ae.AddAdjunct(adjunct); } }
internal bool IsHaveEditAdjuctPermission(WfAdjunct adj) { SmIdentity smIdentity = SecurityUtil.GetSmIdentity(); return (adj.CreateStaffId == smIdentity.UserId); }
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; }
public void AddAdjunct(WfAdjunct adj) { this.currentAdjuncts.Add(adj); this.view.RefreshData(); this.view.FocusedRowHandle = this.view.GetRowHandle(adj); }
public void RemoveAdjunct(WfAdjunct adj) { this.currentAdjuncts.Remove(adj); this.view.RefreshData(); }