/// <summary> /// 验证 /// </summary> /// <param name="file"></param> /// <returns></returns> private bool FileValidate(WorkFileInfo file) { bool result = true; StringBuilder errmsg = new StringBuilder(); if (string.IsNullOrEmpty(file.FileName)) { errmsg.Append("名称不能为空! \r"); result = false; } //if (string.IsNullOrEmpty(file.DrafTPerson)) //{ // errmsg.Append("起草人不能为空! \r"); // result = false; //} //if (string.IsNullOrEmpty(file.AuditPerson)) //{ // errmsg.Append("审核人不能为空! \r"); // result = false; //} if (string.IsNullOrEmpty(file.IssuePerson)) { errmsg.Append("发布人不能为空! \r"); result = false; } if (!string.IsNullOrEmpty(errmsg.ToString())) { MessageBox.Show(errmsg.ToString(), "验证失败"); } return(result); }
/// <summary> /// 保存操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, RoutedEventArgs e) { WorkFileInfo file = this.CurrentFile; if (file != null) { if (!FileValidate(file)) { return; } string error = string.Empty; bool result = FileManageHelper.SaveWorkFiles(file, out error); if (result) { this.Close(); if (file.Attachments != null || file.Attachments.Count > 0) { DeleteClientAtts(file.Attachments); } if (AfterSaveEvent != null) { AfterSaveEvent(CurrentFile); } } else { MessageBox.Show(error, "保存失败"); } } }
/// <summary> /// 修改文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgList_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (dgList.SelectedItem != null) { WorkFileInfo selectfile = dgList.SelectedItem as WorkFileInfo; if (!string.IsNullOrEmpty(selectfile.GUID)) { int selectindex = dgList.SelectedIndex; WorkFileManage modifyfile = new WorkFileManage(selectfile); modifyfile.WindowTitle = "修改工作文件"; modifyfile.AfterSaveEvent += (file) => { MessageBox.Show("保存成功"); GetWorkFiles(); dgList.SelectedIndex = selectindex; }; modifyfile.ShowDialog(); } else { MessageBox.Show(string.Format("{0}不包含文件,请先添加文件", SelectedCatalogItem.Value.Name)); } } }
public WorkFileManage(WorkFileInfo file) { InitializeComponent(); this.DataContext = this; CurrentFile = AT_BC.Data.Helpers.DataContractSerializeHelper.Clone <WorkFileInfo>(file); AttachmentSources = this.QueryAttachments(CurrentFile.GUID); UpdateAttSource(); this.Closed += WorkFileManage_Closed; }
/// <summary> /// 保存工作文件 /// </summary> /// <param name="file"></param> /// <param name="errormsg"></param> /// <returns></returns> public static bool SaveWorkFiles(WorkFileInfo file, out string errormsg) { errormsg = null; try { PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA_ActivityManage>(channel => { channel.SaveWorkFile(file); }); return(true); } catch (Exception ex) { errormsg = ex.GetExceptionMessage(); return(false); } }
/// <summary> /// 添加工作文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, RoutedEventArgs e) { if (SelectedCatalogItem != null) { WorkFileInfo file = new WorkFileInfo(); file.IssuePerson = CO_IA.Client.RiasPortal.Current.UserSetting.UserName; file.GUID = System.Guid.NewGuid().ToString(); file.Catalog.Guid = SelectedCatalogItem.Value.Guid; file.Catalog.Name = SelectedCatalogItem.Value.Name; file.SendState = SendStateEnum.草拟; WorkFileManage dialog = new WorkFileManage(file); dialog.WindowTitle = "添加工作文件"; dialog.AfterSaveEvent += (newfile) => { MessageBox.Show("保存成功"); GetWorkFiles(); }; dialog.ShowDialog(this); } else { MessageBox.Show("请先选择目录"); } }