private void Initialize() { Dispatcher.BeginInvoke((Action)(() => { FileStructure fileStructure = null; if (instanceDataChanged || Content == null) { fileStructureControl = new FileStructureControl(); Content = fileStructureControl; } fileStructure = fileStructureService.GetByInstanceDataGuid(InstanceDataGuid); if (fileStructure == null) { MessageBoxResult selectFromTemplateResult = MessageBoxResult.None; selectFromTemplateResult = MessageBox.Show(localizationService.Translate("filestructure_select_template_msg"), localizationService.Translate("filestructure_select_template_title"), MessageBoxButton.YesNo, MessageBoxImage.Question); if (selectFromTemplateResult == MessageBoxResult.No) { // Create new, maybe from template? fileStructure = new FileStructure { InstanceDataGuid = InstanceDataGuid, StackGuid = StackHelper.Singleton.GetStackGuidByName(StackName), IsTemplate = false }; } else { AsyncItemBox templateItemBox = null; templateItemBox = ItemBoxManager.GetItemBoxFromDB("IB_FileStructureTemplate"); templateItemBox.ShowDialog(); if (templateItemBox.SelectedItem != null) { var templateId = (Guid)templateItemBox.GetSelectedItemCell("Id"); var template = fileStructureService.Get(templateId); // Copy template and connect with instance data entry fileStructure = template.Copy(); fileStructure.IsTemplate = false; fileStructure.InstanceDataGuid = InstanceDataGuid; fileStructure.StackGuid = StackHelper.Singleton.GetStackGuidByName(StackName); } } } if (fileStructure == null) { return; } fileStructureService.Save(fileStructure); // Initialize data context and keep load order fileStructureControl.Initialize(fileStructure); instanceDataChanged = false; })); }
/// <summary> /// Shows the tracking for the parameter which is a document /// </summary> /// <param name="parameter"></param> /// <returns></returns> public static GridInvokeMethodResult ShowTracking(GridFunctionParameter parameter) { foreach (var row in parameter.GetSelectedRowsAsDataRow()) { var documentId = (Guid)row["Guid"]; var ib = (AsyncGridItemBox)ItemBoxManager.GetItemBoxFromDB($"IB_Document_Workflow_Tracking"); ib.SetPlaceholder("DocumentId", documentId.ToString()); ib.ShowDialog(); } return(new GridInvokeMethodResult { RefreshGrid = true }); }
/// <summary> /// Select document path /// </summary> /// <returns></returns> private FileStructureDocumenPath SelectPath() { // Show stack selection var selectStackItemBox = ItemBoxManager.GetItemBoxFromDB("IB_FileStructure_Stack"); selectStackItemBox.ShowDialog(); // Select instance-data if (selectStackItemBox.SelectedItem != null) { var selectDataItemBox = ItemBoxManager.GetItemBoxFromDB(selectStackItemBox.GetSelectedItemCell("StackDataItemBox").ToString()); selectDataItemBox.ShowDialog(); if (selectDataItemBox.SelectedItem != null) { var fileStructure = fileStructureService.GetByInstanceDataGuid((Guid)selectDataItemBox.GetSelectedItemCell("Guid")); if (fileStructure == null) { MessageBox.Show(localizationService.Translate("filestructure_path_no_selection"), localizationService.Translate("filestructure_path_no_selection_title"), MessageBoxButton.OK, MessageBoxImage.Information); } else { var selectPathWindow = new FileStructureWindow(); selectPathWindow.Initialize(fileStructure); selectPathWindow.IsInSelectMode = true; selectPathWindow.ShowDialog(); if (selectPathWindow.SelectedDirectory != null) { var newDocumentPath = new FileStructureDocumenPath { Id = Guid.NewGuid(), DirectoryGuid = selectPathWindow.SelectedDirectory.Id, DocumentGuid = documentId, FileStructureGuid = fileStructure.Id, WorkflowId = selectPathWindow.SelectedDirectory.WorkflowId }; return(newDocumentPath); } } } } return(null); }
private static IList <WorkflowOperation> WorkflowOperationsItemBoxGet(GridFunctionParameter parameter) { IList <WorkflowOperation> workflowOperations = new List <WorkflowOperation>(); Checkout(parameter); Guid?workflowOrganizationId = null; int targetUserId = 0; if (parameter.SelectedRows.Count == 0) { return(null); } var itemBox = (AsyncGridItemBox)ItemBoxManager.GetItemBoxFromDB("IB_Document_Workflow_User"); itemBox.SetPlaceholder("WorkflowId", parameter.GetSelectedRowsAsDataRow().FirstOrDefault()["WorkflowId"].ToString()); itemBox.ShowDialog(); if (itemBox.SelectedItem == null) { return(null); } var comment = new Framework.Extension.InstanceDataCommentModel { UserGroupVisibility = Visibility.Hidden, UserId = sessionService.CurrentSession.UserId, InstanceDataGuid = Guid.NewGuid(), StackGuid = (Guid)parameter.GridView.Configuration.SelectedStackId }; var commentWindow = new Framework.Extension.NewCommentWindow(comment); commentWindow.ShowDialog(); if (itemBox.GetSelectedItemCell("InternalType").ToString() == "User") { targetUserId = (int)itemBox.GetSelectedItemCell("Ident"); } else { workflowOrganizationId = (Guid)itemBox.GetSelectedItemCell("Guid"); } foreach (var row in parameter.GetSelectedRowsAsDataRow()) { var documentId = (Guid)row["Guid"]; var documentPathId = (Guid)row["DocumentPathId"]; var workflowId = (Guid)row["WorkflowId"]; var workflowOperation = new WorkflowOperation { DocumentId = documentId, DocumentPath = documentPathId, UserId = sessionService.CurrentSession.UserId, TargetUserId = targetUserId, CreateDateTime = DateTime.Now, UpdateDateTime = DateTime.Now, ActionName = "forward", WorkflowId = workflowId, Guid = Guid.NewGuid() }; if (itemBox.GetSelectedItemCell("InternalType").ToString() == "Group") { workflowOperation.OperationType = WorkflowOperationType.WorkflowOrganizationUnit; workflowOperation.WorkflowOrganizationId = workflowOrganizationId; } workflowOperations.Add(workflowOperation); if (!string.IsNullOrWhiteSpace(comment.Comment)) { comment.InstanceDataGuid = documentId; comment.CommentId = Guid.NewGuid(); Framework.Extension.InstanceDataComment.Singleton.Create(comment); } } return(workflowOperations); }
/// <summary> /// Create view model /// </summary> public FileStructureViewModel(RadTreeView directoryTreeView, Expander expander) { this.directoryTreeView = directoryTreeView; this.expander = expander; localizationService = CommonServiceLocator.ServiceLocator.Current.GetInstance <ILocalizationService>(); directoryTypeService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IDirectoryTypeService>(); iconService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IIconService>(); stackService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IStackService>(); fielStructureService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFileStructureService>(); documentWorkflowContextService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IDocumentWorkflowConfigurationService>(); documentWorkflowAssignmentService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IDocumentWorkflowAssignmentService>(); directoryFieldService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IDirectoryFieldService>(); directoryTypeFieldService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IDirectoryClassificationFieldService>(); rootPath = ""; VisualPathElements = new ObservableCollection <FrameworkElement>(); directoryCategoryMenuItems = new ObservableCollection <RadMenuItem>(); foreach (var category in directoryTypeService.GetAll().OrderBy(d => d.Category).GroupBy(d => d.Category)) { var categoryItem = new RadMenuItem { Header = category.Key, Tag = category.Key, Icon = new Image { Source = iconService.GetByNameAsImage("directory_add_x16"), Width = 16, Height = 16 } }; foreach (var type in category) { var menuItem = new RadMenuItem { Header = localizationService.Translate(type.Name), Icon = new Image { Source = iconService.GetByIdAsImage(type.IconId), Width = 16, Height = 16 }, Tag = type }; menuItem.Click += AddDirectoryItemClick; categoryItem.Items.Add(menuItem); } directoryCategoryMenuItems.Add(categoryItem); } // Create remove directory command removeDirectoryCommand = new RelayCommand((e) => { if (SelectedDirectory != null) { if (fielStructureService.GetDocuments(model, selectedDirectory.Model, true).Any()) { MessageBox.Show(localizationService.Translate("filestructure_delete_notallowed"), localizationService.Translate("filestructure_delete_notallowed_title"), MessageBoxButton.OK, MessageBoxImage.Information); return; } SelectedDirectory.RemoveDirectory(); SelectedDirectory = null; IsDirty = true; RefreshPath(); } }, (e) => { return(selectedDirectory != null); }); // Create edit metadata command editMetaDataCommand = new RelayCommand((e) => { if (SelectedDirectory != null) { var directoryFieldWindow = new DirectoryFieldWindow(); directoryFieldWindow.Initialize(SelectedDirectory.Model, GetStructure()); directoryFieldWindow.WindowMode = Framework.UI.WindowMode.Edit; directoryFieldWindow.ShowDialog(); return; } }, (e) => { return(selectedDirectory != null); }); renameDirectoryCommand = new RelayCommand((e) => { if (SelectedDirectory != null) { directoryTreeView.ContainerFromItemRecursive(directoryTreeView.SelectedItem).BeginEdit(); return; } }, (e) => { return(selectedDirectory != null); }); // Command to assign the workflow assignWorkflowCommand = new RelayCommand((e) => { if (selectedDirectory.Model.WorkflowId.HasValue) { MessageBox.Show(localizationService.Translate("filestructure_workflow_assign_already"), localizationService.Translate("filestructure_delete_notallowed_title"), MessageBoxButton.OK, MessageBoxImage.Information); return; } var box = ItemBoxManager.GetItemBoxFromDB("IB_Document_Workflow"); box.ShowDialog(); var result = box.GetSelectedItemCell("Guid"); if (result is Guid guid) { selectedDirectory.Model.WorkflowId = guid; //Assign all parents and children the workflow AssignedWorkflowToParentsAndChildren(guid); Save(); RaisePropertyChanged(nameof(AssignedWorkflow)); RaisePropertyChanged(nameof(AssignedWorkflowVisibility)); } }); // Archive from clipboard click archiveFromClipboard = new RelayCommand((e) => { // Save before archive if (IsDirty) { Save(); } if (IsWorkflowDirectory(selectedDirectory)) { return; } Helper.ArchiveHelper.ArchiveFromClipboard(model, selectedDirectory.Model); }, (e) => { return(selectedDirectory != null); }); // Archive from scanner archiveFromScanner = new RelayCommand((e) => { // Save before archive if (IsDirty) { Save(); } if (IsWorkflowDirectory(selectedDirectory)) { return; } Helper.ArchiveHelper.ArchiveFromScanClient(model, selectedDirectory.Model); }, (e) => { return(selectedDirectory != null); }); setReturnDirectory = new RelayCommand((e) => { var parentDirectory = selectedDirectory.StructureViewModel.Directories.FirstOrDefault(x => { return(x == selectedDirectory.Parent); }); foreach (var directory in parentDirectory.Directories) { directory.IsReturnDirectory = false; } selectedDirectory.IsReturnDirectory = true; }, (e) => { return(selectedDirectory != null); }); }
/// <summary> /// Open file structure editor for instance data /// </summary> /// <param name="parameter">Grid parameter</param> /// <returns>Grid invoke result, to control grid refresh</returns> public static GridInvokeMethodResult OpenFileStructureEditor(GridFunctionParameter parameter) { var fileStructureWindow = new FileStructureWindow(); // TODO: Maybe change to foreach.... var instanceDataGuid = parameter.GetSelectedRowsAsDataRow().Select(x => (Guid)x["Guid"]).FirstOrDefault(); var stackGuid = parameter.GetSelectedRowsAsDataRow().Select(x => (Guid)x["StackGuid"]).FirstOrDefault(); var fileStructure = fileStructureService.GetByInstanceDataGuid(instanceDataGuid); if (fileStructure == null) { var selectFromTemplateResult = MessageBox.Show(localizationService.Translate("filestructure_select_template_msg"), localizationService.Translate("filestructure_select_template_title"), MessageBoxButton.YesNoCancel, MessageBoxImage.Question); if (selectFromTemplateResult == MessageBoxResult.Cancel) { return new GridInvokeMethodResult { RefreshGrid = false } } ; if (selectFromTemplateResult == MessageBoxResult.No) { // Create new, maybe from template? fileStructure = new FileStructure { InstanceDataGuid = instanceDataGuid, StackGuid = stackGuid, IsTemplate = false }; } else { var templateItemBox = ItemBoxManager.GetItemBoxFromDB("IB_FileStructureTemplate"); templateItemBox.ShowDialog(); if (templateItemBox.SelectedItem != null) { var templateId = (Guid)templateItemBox.GetSelectedItemCell("Id"); var template = fileStructureService.Get(templateId); // Copy template and connect with instance data entry fileStructure = template.Copy(); fileStructure.IsTemplate = false; fileStructure.InstanceDataGuid = instanceDataGuid; fileStructure.StackGuid = stackGuid; } } // Exit if no file structure is created if (fileStructure == null) { return new GridInvokeMethodResult { RefreshGrid = false } } ; } // Initialize window fileStructureWindow.Initialize(fileStructure); fileStructureWindow.Show(); // Refresh grid after closed fileStructureWindow.Closed += (s, e) => { parameter.GridView.RefreshData(); }; return(new GridInvokeMethodResult { RefreshGrid = false, Window = fileStructureWindow }); } #endregion } }