Ejemplo n.º 1
0
        /// <summary>
        /// Edit file structure
        /// </summary>
        /// <param name="parameter">Grid parameter</param>
        /// <returns>Grid invoke result, to control grid refresh</returns>
        public static GridInvokeMethodResult EditFileStructure(GridFunctionParameter parameter)
        {
            foreach (var id in parameter.GetSelectedRowsAsDataRow().Select(x => (Guid)x["Id"]))
            {
                var fileStructureWindow = new FileStructureWindow();

                // Get and copy
                var fileStructure = fileStructureService.Get(id);

                fileStructureWindow.Initialize(fileStructure);
                fileStructureWindow.WindowMode = Framework.UI.WindowMode.Edit;
                fileStructureWindow.Show();

                // Refresh grid after closed
                fileStructureWindow.Closed += (s, e) =>
                {
                    parameter.GridView.RefreshData();
                };

                return(new GridInvokeMethodResult
                {
                    RefreshGrid = false,
                    Window = fileStructureWindow
                });
            }

            // Do not refresh grid if no data is passed
            return(new GridInvokeMethodResult {
                RefreshGrid = false
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Tries to checkout a document if required
        /// </summary>
        /// <param name="parameter">Grid parameter</param>
        private static void Checkout(GridFunctionParameter parameter)
        {
            foreach (var row in parameter.GetSelectedRowsAsDataRow())
            {
                if (Guid.TryParse(row["OrganizationId"]?.ToString(), out Guid organizationUnitId))
                {
                    var documentId = (Guid)row["Guid"];

                    // The grid needs a the column workflow id
                    var workflowId  = (Guid)row["WorkflowId"];
                    var directoryId = (Guid)row["DirectoryId"];

                    var workflowOperation = new WorkflowOperation
                    {
                        DocumentId             = documentId,
                        UserId                 = sessionService.CurrentSession.UserId,
                        TargetUserId           = sessionService.CurrentSession.UserId,
                        CreateDateTime         = DateTime.Now,
                        UpdateDateTime         = DateTime.Now,
                        ActionName             = "forward",
                        WorkflowId             = workflowId,
                        WorkflowOrganizationId = organizationUnitId,
                        DirectoryId            = directoryId,
                        Guid = Guid.NewGuid()
                    };

                    var documentPath = workflowOperationService.DocumentCheckout(workflowOperation);
                    row["DocumentPathId"] = documentPath;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets the state to complete
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static GridInvokeMethodResult Release(GridFunctionParameter parameter)
        {
            Checkout(parameter);

            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,
                    CreateDateTime = DateTime.Now,
                    UpdateDateTime = DateTime.Now,
                    WorkflowId     = workflowId,
                    ActionName     = "released",
                    Guid           = Guid.NewGuid()
                };

                workflowOperationService.Release(workflowOperation);
            }

            return(new GridInvokeMethodResult {
                RefreshGrid = true
            });
        }
Ejemplo n.º 4
0
        /// <summary>
        /// New file structure template
        /// </summary>
        /// <param name="parameter">Grid parameter</param>
        /// <returns>Grid invoke result, to control grid refresh</returns>
        public static GridInvokeMethodResult NewFileStructureTemplate(GridFunctionParameter parameter)
        {
            var fileStructureWindow = new FileStructureWindow();

            // Create new, maybe template
            var fileStructure = new FileStructure
            {
                IsTemplate  = true,
                Name        = "Template",
                Directories = new List <Directory>
                {
                    new Directory
                    {
                        Id   = Guid.NewGuid(),
                        Name = localizationService.Translate("filestructure_add_directory")
                    }
                }
            };

            fileStructureWindow.Initialize(fileStructure);
            fileStructureWindow.WindowMode = Framework.UI.WindowMode.Edit;
            fileStructureWindow.Show();

            // Refresh grid after closed
            fileStructureWindow.Closed += (s, e) =>
            {
                parameter.GridView.RefreshData();
            };

            return(new GridInvokeMethodResult
            {
                RefreshGrid = false,
                Window = fileStructureWindow
            });
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Checks the document out for the <see cref="WorkflowOrganizationUnit"/> and puts it in the user path
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static GridInvokeMethodResult DocumentCheckout(GridFunctionParameter parameter)
        {
            Checkout(parameter);

            return(new GridInvokeMethodResult {
                RefreshGrid = true
            });
        }
Ejemplo n.º 6
0
        /// <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
            });
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Forwards the document into the substitute folder
        /// </summary>
        /// <param name="gridFunctionParameter"></param>
        /// <returns></returns>
        public static GridInvokeMethodResult ForwardToSubstitute(GridFunctionParameter gridFunctionParameter)
        {
            var documentId  = Guid.Empty;
            var pathService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFileStructureDocumentPathService>();

            foreach (var documentRow in gridFunctionParameter.GetSelectedRowsAsDataRow())
            {
                documentId = (Guid)documentRow["Guid"];

                if (documentId.Equals(Guid.Empty))
                {
                    continue;
                }

                var workflowId     = (Guid)documentRow["WorkflowId"];
                var targetUserId   = (int)documentRow["UserId"];
                var sessionService = CommonServiceLocator.ServiceLocator.Current.GetInstance <ISessionService>();
                var currentUserId  = sessionService.CurrentSession.UserId;
                var paths          = pathService.GetByDocumentId(documentId);
                var pathId         = paths.FirstOrDefault(x => x.WorkflowState != DocumentWorkflowStateType.Completed).Id;
                if (pathId == null)
                {
                    continue;
                }

                //The User is authorized to take the document
                var workflowOperationService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IWorkflowOperationService>();

                workflowOperationService.ForwardTo(new WorkflowOperation
                {
                    DocumentId    = documentId,
                    UserId        = currentUserId,
                    TargetUserId  = currentUserId,
                    ActionName    = "Forward",
                    WorkflowId    = workflowId,
                    DocumentPath  = pathId,
                    OperationType = WorkflowOperationType.User,
                });
            }

            return(new GridInvokeMethodResult()
            {
                RefreshGrid = true,
            });
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Forwards a copy to the user that will be shown in the itembox or multicolumncombobox.
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static GridInvokeMethodResult ForwardCopyTo(GridFunctionParameter parameter)
        {
            IList <WorkflowOperation> workflowOperationList;

            if (forwardConfig == 1)
            {
                workflowOperationList = WorkflowOperationsItemBoxGet(parameter);
            }

            else
            {
                workflowOperationList = WorkflowOperationsGet(parameter);
            }

            if (workflowOperationList == null)
            {
                return(GridInvokeMethodResult.NoGridRefresh());
            }

            foreach (var workflowOperation in workflowOperationList)
            {
                try
                {
                    workflowOperationService.ForwardCopyTo(workflowOperation);
                }
                catch (DocumentWorkflowException ex)
                {
                    Log.LogManagerInstance.Instance.Error("Could not forward document in workflow", ex);

                    // TODO: Add localization
                    LocalizedMessageBox.Show("textkey", "captionKey", MessageBoxButton.OK, MessageBoxImage.Information);
                    MessageBox.Show("filestructure_forward_error", "filestructure_forward_error_head", MessageBoxButton.OK, MessageBoxImage.Information);
                    return(GridInvokeMethodResult.NoGridRefresh());
                }
            }
            return(new GridInvokeMethodResult {
                RefreshGrid = true
            });
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Edits the workflow organization unit
 /// </summary>
 /// <param name="parameter">the </param>
 /// <returns></returns>
 public static GridInvokeMethodResult EditWorkflowOrganizaitonUnit(GridFunctionParameter parameter)
 {
     return(new GridInvokeMethodResult {
         RefreshGrid = true
     });
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Opens a window to create a workflow and assign settings to it
 /// </summary>
 /// <param name="parameter"></param>
 /// <returns></returns>
 public static GridInvokeMethodResult NewWorkflow(GridFunctionParameter parameter)
 {
     return(new GridInvokeMethodResult {
         RefreshGrid = true
     });
 }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        private static IList <WorkflowOperation> WorkflowOperationsGet(GridFunctionParameter parameter)
        {
            IList <WorkflowOperation> workflowOperations = new List <WorkflowOperation>();

            Checkout(parameter);

            if (parameter.SelectedRows.Count == 0)
            {
                return(null);
            }

            Dictionary <string, string> dictParams = new Dictionary <string, string>();

            dictParams.Add("[WorkflowId]", parameter.GetSelectedRowsAsDataRow().FirstOrDefault()["WorkflowId"].ToString());

            var win = new ForwardWindow(dictParams);

            win.ShowDialog();

            var windowDataContext = win.DataContext;
            ObservableCollection <IMultiSelectionComboBoxItem> itemList = null;
            var commentText = "";

            if (windowDataContext is ForwardViewModel forwardViewModel)
            {
                itemList    = forwardViewModel.MultiItemboxItems;
                commentText = forwardViewModel.CommentText;
            }

            if (itemList == null)
            {
                return(null);
            }

            foreach (var item in itemList)
            {
                var user = userService.GetByGuid((Guid)item.Id);

                int  targetUserId            = 0;
                Guid?workflowOrganzisationId = null;

                if (user != null)
                {
                    targetUserId = user.Ident;
                }

                else
                {
                    workflowOrganzisationId = (Guid?)item.Id;
                }

                var comment = new Framework.Extension.InstanceDataCommentModel
                {
                    Comment             = commentText,
                    UserGroupVisibility = Visibility.Hidden,
                    UserId           = sessionService.CurrentSession.UserId,
                    InstanceDataGuid = Guid.NewGuid(),
                    StackGuid        = (Guid)parameter.GridView.Configuration.SelectedStackId
                };

                foreach (var row in parameter.GetSelectedRowsAsDataRow())
                {
                    var documentId     = (Guid)row["Guid"];
                    var documentPathId = (Guid)row["DocumentPathId"];
                    // The grid needs a the column workflow id
                    var workflowId = (Guid)fileStructureDocumentPathService.Get(documentPathId).WorkflowId;

                    if (workflowId == null)
                    {
                        continue;
                    }

                    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 (user == null)
                    {
                        workflowOperation.OperationType          = WorkflowOperationType.WorkflowOrganizationUnit;
                        workflowOperation.WorkflowOrganizationId = workflowOrganzisationId;
                    }

                    workflowOperations.Add(workflowOperation);

                    if (!string.IsNullOrWhiteSpace(comment.Comment))
                    {
                        comment.InstanceDataGuid = documentId;
                        comment.CommentId        = Guid.NewGuid();

                        Framework.Extension.InstanceDataComment.Singleton.Create(comment);
                    }
                }
            }
            return(workflowOperations);
        }
Ejemplo n.º 13
0
        /// <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
    }
}