private void OnDeleteContextMenuClick(object sender, RoutedEventArgs e) { var fse = mouseElement.DataContext as FileSystemEntity; if (fse == null) { return; } if (!CustomMessageBox.Ask(string.Format("您确定要删除{0}[{1}]吗?该操作不可恢复,请谨慎操作!", EnumHelper.GetName(fse.Type.GetType(), fse.Type), fse.Name))) { return; } BusyIndicator1.IsBusy = true; BusyIndicator1.BusyContent = "正在执行..."; if (fse.Type == FileSystemEntityType.Folder) { docContext.DeleteFolder(fse.FolderId, AuthenticateStatus.CurrentUser.UserId, obj => { BusyIndicator1.IsBusy = false; if (Utility.Utility.CheckInvokeOperation(obj)) { if (obj.Value == -2) { CustomMessageBox.Show("当前文件夹不为空,不能删除!"); } else if (obj.Value > 0) { OpenFolder(FolderId); } else { CustomMessageBox.Alert("删除文件夹失败,错误码:" + obj.Value); } } }, null); } else { docContext.DeleteFile(fse.FileId, fse.FileRevision, obj => { BusyIndicator1.IsBusy = false; if (Utility.Utility.CheckInvokeOperation(obj)) { if (obj.Value == -2) { CustomMessageBox.Show("没有找到要删除的文件信息!"); } else if (obj.Value > 0) { OpenFolder(FolderId); } else { CustomMessageBox.Alert("删除文件失败,错误码:" + obj.Value); } } }, null); } }
private void DoSaveArchiveWorkflow(AuditStatus status, ArchiveWorkflow flow) { archiveFlowSaved = true; BusyIndicator1.IsBusy = true; BusyIndicator1.BusyContent = "正在保存流程..."; flow.SubmitUserId = AuthenticateStatus.CurrentUser.UserId; flow.Status = status; flowContext.SaveWorkflow(flow, obj => { BusyIndicator1.IsBusy = false; if (Utility.Utility.CheckInvokeOperation(obj)) { if (obj.Value == null) { CustomMessageBox.Show("流程保存失败,请您检查输入是否正确!"); } else { ArchiveFlow = obj.Value; if (ArchiveFlow.Status == AuditStatus.Draft) { LayoutRoot.DataContext = ArchiveFlow; } else if (ArchiveFlow.Status == AuditStatus.Auditing) { CustomMessageBox.Alert("流程提交成功!"); OnBackToBrowseButtonClick(this, null); } } } }, null); }
private bool ValidateWorkflowInfo() { var flow = LayoutRoot.DataContext as ArchiveWorkflow; if (flow == null) { CustomMessageBox.Alert("获取工作流实例失败,请重试!"); return(false); } if (string.IsNullOrEmpty(flow.FlowTitle)) { CustomMessageBox.Alert("请输入工作流标题!"); txtFlowTitle.Focus(); return(false); } if (flow.Files == null || flow.Files.Count < 1) { CustomMessageBox.Alert("请选择您要提交的文件!"); return(false); } //foreach (var file in flow.Files) //{ // var sb = new StringBuilder(); // sb.AppendFormat("FileName:{0}{1}Length:{2}", file.DocumentInfo.FileName, Environment.NewLine, // file.DocumentInfo.Content.Length); // if (file.DocumentInfo.Descriptions != null) // foreach (var desc in file.DocumentInfo.Descriptions) // { // sb.AppendFormat("{0}{1}={2}", Environment.NewLine, desc.Header, desc.Description); // } // MessageBox.Show(sb.ToString()); //} return(true); }
//检查工作流信息是否有效 private bool ValidateWorkflowInfo() { var flow = LayoutRoot.DataContext as ArchiveWorkflow; if (flow == null) { CustomMessageBox.Alert("获取工作流实例失败,请重试!"); return(false); } if (string.IsNullOrEmpty(flow.FlowTitle)) { CustomMessageBox.Alert("请输入工作流标题!"); txtFlowTitle.Focus(); return(false); } if (flow.Files == null || flow.Files.Count < 1) { CustomMessageBox.Alert("请选择您要提交的文件!"); return(false); } if (ArchiveFlowCombBox.SelectedIndex == -1) { CustomMessageBox.Alert("请选择归档流程!"); ArchiveFlowCombBox.Focus(); return(false); } if (flow.FlowType < 1) { flow.FlowType = Convert.ToInt32(ArchiveFlowCombBox.SelectedValue); } var doc = flow.Files[0].DocumentInfo; if (IsRevise && doc.Identity < 1) { doc.Revision = ReviseFile.Revision + 1; doc.CreatedBy = AuthenticateStatus.CurrentUser.UserId; doc.CreateTime = DateTime.Now; doc.FilePath = string.Empty; doc.Status = DocumentStatus.Draft; if (doc.Descriptions != null) { foreach (var desc in doc.Descriptions) { desc.Identity = 0; } } } return(true); }
private void OnRenameContextMenuClick(object sender, RoutedEventArgs e) { var fse = mouseElement.DataContext as FileSystemEntity; if (fse == null) { return; } var dlg = new PromptWindow(); dlg.SetTitle("请输入新的文件夹名称"); dlg.OnOk += (oo, ee) => { string strName = dlg.InputText; if (string.IsNullOrEmpty(strName) || strName.Equals(fse.Name, StringComparison.CurrentCultureIgnoreCase)) { return; } var source = FileBrowseListBox.ItemsSource as List <FileSystemEntity>; if (source != null && source.Any(o => o.Type == FileSystemEntityType.Folder && o.Name.Equals(strName, StringComparison.CurrentCultureIgnoreCase) && o.FolderId != fse.FolderId)) { CustomMessageBox.Alert("新的文件夹名称与其他文件夹名重复!"); return; } BusyIndicator1.IsBusy = true; BusyIndicator1.BusyContent = "正在执行..."; docContext.RenameFolder(fse.FolderId, strName, obj => { BusyIndicator1.IsBusy = false; if (Utility.Utility.CheckInvokeOperation(obj)) { if (obj.Value > 0) { fse.Name = strName; } else { CustomMessageBox.Show("重命名失败!错误码:" + obj.Value); } } }, null); }; dlg.Show(); }
//当用户导航到此页面时执行。 protected override void OnNavigatedTo(NavigationEventArgs e) { if (NavigationService != null) { int flowId = NavigationContext.QueryString.ContainsKey("FlowId") ? Convert.ToInt32(NavigationContext.QueryString["FlowId"]) : 0; Guid fileId = Guid.Empty; if (flowId > 0) { BusyIndicator1.IsBusy = true; BusyIndicator1.BusyContent = "正在加载数据..."; flowContext.GetArchiveWorkflow(flowId, obj => { BusyIndicator1.IsBusy = false; if (Utility.Utility.CheckInvokeOperation(obj)) { ArchiveFlow = obj.Value; var doc = ArchiveFlow.Files == null || ArchiveFlow.Files.Count < 1 ? null : ArchiveFlow.Files[0]; if (doc != null) { FolderId = NavigationContext.QueryString.ContainsKey("FolderId") ? Convert.ToInt32(NavigationContext.QueryString["FolderId"]) : ArchiveFlow.FolderId; OrgId = NavigationContext.QueryString.ContainsKey("OrgId") ? NavigationContext.QueryString["OrgId"] : doc.DocumentInfo.OrganizationId; } BindWorkflowInfo(); } }, null); } else if (NavigationContext.QueryString.ContainsKey("ReviseFile") && Guid.TryParse(NavigationContext.QueryString["ReviseFile"], out fileId)) { ArchiveFlow = new ArchiveWorkflow { IsRevise = true }; IsRevise = true; docContext.DownloadLatestFile(fileId, obj => { if (Utility.Utility.CheckInvokeOperation(obj)) { var doc = obj.Value; if (doc == null) { CustomMessageBox.Alert("您要修订的文件不存在,请您确认已经正确操作!"); NavigationService.Navigate(new Uri(string.Empty, UriKind.Relative)); } else { if (ArchiveFlow.Files == null) { ArchiveFlow.Files = new List <WorkflowFileInfo>(); } ArchiveFlow.Files.Clear(); doc.Identity = 0; ArchiveFlow.Files.Add(new WorkflowFileInfo { DocumentId = 0, DocumentInfo = doc }); ArchiveFlow.FlowTitle = string.Format("修订文档-{0}", doc.FileName); OrgId = doc.OrganizationId; FolderId = doc.FolderId; BindWorkflowInfo(); } } }, null); } else { FolderId = NavigationContext.QueryString.ContainsKey("FolderId") ? Convert.ToInt32(NavigationContext.QueryString["FolderId"]) : 0; OrgId = NavigationContext.QueryString.ContainsKey("OrgId") ? NavigationContext.QueryString["OrgId"] : AuthenticateStatus.DefaultOrganization; BindWorkflowInfo(); } } }