/// <summary>
 /// Initialize watcher service
 /// </summary>
 /// <param name="storageService">Storage instance</param>
 /// <param name="structureService">Structure service</param>
 public SyncStorageWatcherService(ISyncStorageService storageService, IFileStructureService structureService, ISyncStorageHashService storageHashService)
 {
     this.storageService     = storageService;
     this.structureService   = structureService;
     this.storageHashService = storageHashService;
     this.tempQueue          = new List <SyncQueueEntry>();
 }
Example #2
0
        /// <summary>
        /// Initialize file structure window
        /// </summary>
        public FileStructureWindow()
        {
            InitializeComponent();

            fileStructureService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFileStructureService>();
            stackService         = CommonServiceLocator.ServiceLocator.Current.GetInstance <IStackService>();
            reportService        = CommonServiceLocator.ServiceLocator.Current.GetInstance <IRenderingService>();

            var showReportButton = new RibbonButton
            {
                LargeIconName          = "filestructure_report_32x",
                SmallIconName          = "filestructure_report_32x",
                TextLocalizationKey    = "filestructure_show_report",
                TooltipLocalizationKey = "filestructure_show_report_tooltip",
                Size = Telerik.Windows.Controls.RibbonView.ButtonSize.Large
            };

            showReportButton.Click += (s, e) =>
            {
                var html = reportService.Render(ViewModel.GetStructure());

                var now          = DateTime.Now;
                var htmlFilePath = $"{Base.GlobalSettings.AppDataPath}\\Temp\\FileStructure_{now.Year}{now.Month}{now.Day}{now.Hour}{now.Minute}{now.Second}.html";

                System.IO.File.WriteAllText(htmlFilePath, html);
                System.Diagnostics.Process.Start(htmlFilePath);
            };

            RadRibbonDataGroup.Items.Add(showReportButton);

            AllowPaging = false;
        }
Example #3
0
 /// <summary>
 /// Initialize helper
 /// </summary>
 static WorkflowApplicationHelper()
 {
     fileStructureService             = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFileStructureService>();
     localizationService              = CommonServiceLocator.ServiceLocator.Current.GetInstance <ILocalizationService>();
     workflowOperationService         = CommonServiceLocator.ServiceLocator.Current.GetInstance <IWorkflowOperationService>();
     fileStructureDocumentPathService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFileStructureDocumentPathService>();
     sessionService = CommonServiceLocator.ServiceLocator.Current.GetInstance <ISessionService>();
     documentWorkflowOrganizationUnitAssignmentService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IDocumentWorkflowOrganizationUnitAssignmentService>();
     userService          = CommonServiceLocator.ServiceLocator.Current.GetInstance <IUserService>();
     configurationService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IConfigurationService>();
     forwardConfig        = configurationService.GetValue <int>("ForwardOption", "Filestructure", "");
 }
Example #4
0
        internal Control_DocumentWorkflow(DBInternPage DBInternPage)
        {
            InitializeComponent();

            documentWorkflowUserService        = CommonServiceLocator.ServiceLocator.Current.GetInstance <IDocumentWorkflowUserService>();
            documentWorkflowAppSettingsService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IDocumentWorkflowAppSettingsService>();
            fileStructureService        = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFileStructureService>();
            sessionService              = CommonServiceLocator.ServiceLocator.Current.GetInstance <ISessionService>();
            documentWorkflowAppSettings = documentWorkflowAppSettingsService.Get(DBInternPage.Guid);

            if (documentWorkflowAppSettings == null || string.IsNullOrWhiteSpace(documentWorkflowAppSettings.InternalName))
            {
                MessageBox.Show("Konfiguration nicht vorhanden", "...");
                return;
            }

            PageName = documentWorkflowAppSettings.PublicName;

            documentWorkflowUser = documentWorkflowUserService.Get(sessionService.CurrentSession.UserId);

            if (documentWorkflowUser == null)
            {
                documentWorkflowUser = new DocumentWorkflowUser
                {
                    UserId    = sessionService.CurrentSession.UserId,
                    IsDeleted = false
                                // TODO: Set current tenant
                };

                documentWorkflowUserService.Save(documentWorkflowUser);
            }

            fileStructureConfiguration = fileStructureService.GetByInstanceDataGuid(documentWorkflowUser.Guid);
            if (fileStructureConfiguration == null)
            {
                fileStructureConfiguration = new FileStructure
                {
                    IsTemplate       = false,
                    InstanceDataGuid = documentWorkflowUser.Guid,
                    Id        = Guid.NewGuid(),
                    Name      = documentWorkflowAppSettings.PublicName,
                    StackGuid = stackGuid
                };

                fileStructureService.Save(fileStructureConfiguration);
            }

            fileStructureConfiguration.Name = $"{documentWorkflowAppSettings.PublicName}({Framework.Base.UserManager.Singleton.GetFriendlyName(sessionService.CurrentSession.UserId)})";

            fileStructureControl.Initialize(fileStructureConfiguration);

            Loaded += ControlLoaded;
        }
        /// <summary>
        /// Initialize viewmodel
        /// </summary>
        /// <param name="path">Path instance</param>
        /// <param name="fileStructureService">File structure service</param>
        /// <param name="directoryTypeService">Directory type service</param>
        /// <param name="iconService">Icon service</param>
        /// <param name="stackService">Stack service</param>
        public DocumentPathViewModel(FileStructureDocumenPath path, IFileStructureService fileStructureService, IDirectoryTypeService directoryTypeService, IIconService iconService, IStackService stackService)
        {
            this.path = path;
            this.fileStructureService = fileStructureService;
            this.iconService          = iconService;
            this.directoryTypeService = directoryTypeService;
            this.stackService         = stackService;

            VisualPathElements = new ObservableCollection <FrameworkElement>();

            RefreshPath();
        }
Example #6
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public ViewFilePageViewModel(IFileStructureService fileStructureService)
        {
            // Init Services
            FileStructureService = fileStructureService;
            LocationsList        = DI.ApplicationViewModel.LocationList;

            // Create commands
            OrganizeCommand    = new ActionCommand(Organize);
            ShowSettingCommand = new ActionCommand(ShowSettingsForm);

            // Load the music files
            LoadMusicFiles();
        }
Example #7
0
        /// <summary>
        /// Create view model
        /// </summary>
        public DirectoryFieldViewModel()
        {
            directoryTypeClassificationService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IDirectoryTypeClassificationService>();
            directoryTypeFieldService          = CommonServiceLocator.ServiceLocator.Current.GetInstance <IDirectoryClassificationFieldService>();
            directoryClassificationService     = CommonServiceLocator.ServiceLocator.Current.GetInstance <IDirectoryClassificationService>();
            directoryFieldService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IDirectoryFieldService>();
            fileStructureService  = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFileStructureService>();
            fieldTypeService      = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFieldTypeService>();
            expanderMode          = Visibility.Collapsed;

            saveMetadataCommand = new RelayCommand((e) =>
            {
                Save();
            });
        }
Example #8
0
 /// <summary>
 /// Initialize service
 /// </summary>
 /// <param name="repository">Repository instance</param>
 /// <param name="structureService">File structure service</param>
 public FileStructureDocumentPathService(IFileStructureDocumentPathRepository repository
                                         , IFileStructureService structureService
                                         , IFileStructureDocumentPathTrackingRepository fileStructureDocumentPathTrackingRepository
                                         , ISessionService sessionService
                                         , IDocumentWorkflowAssignmentService documentWorkflowAssignmentService
                                         , IDocumentWorkflowConfigurationService documentWorkflowConfigurationService
                                         , IUnityContainer unityContainer)
 {
     this.repository       = repository;
     this.structureService = structureService;
     this.fileStructureDocumentPathTrackingRepository = fileStructureDocumentPathTrackingRepository;
     this.sessionService = sessionService;
     this.documentWorkflowAssignmentService    = documentWorkflowAssignmentService;
     this.documentWorkflowConfigurationService = documentWorkflowConfigurationService;
     this.unityContainer = unityContainer;
 }
Example #9
0
        /// <summary>
        /// Initialize control
        /// </summary>
        public FileStructureControl()
        {
            InitializeComponent();

            stackService                     = CommonServiceLocator.ServiceLocator.Current.GetInstance <IStackService>();
            fielStructureService             = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFileStructureService>();
            fileStructureDocumentPathService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFileStructureDocumentPathService>();

            // Subscribe to preview drop event
            DragDropManager.AddPreviewDropHandler(directoryTreeView, new Telerik.Windows.DragDrop.DragEventHandler(OnPreviewDrop), true);
            DragDropManager.AddDragOverHandler(directoryTreeView, new Telerik.Windows.DragDrop.DragEventHandler(OnDragOver), true);
            DragDropManager.AddDropHandler(directoryTreeView, new Telerik.Windows.DragDrop.DragEventHandler(OnDrop), true);
            DragDropManager.AddDragInitializeHandler(directoryTreeView, new Telerik.Windows.DragDrop.DragInitializeEventHandler(OnDraginitialize), true);

            EventManager.RegisterClassHandler(typeof(RadTreeViewItem), Mouse.MouseDownEvent, new MouseButtonEventHandler(OnTreeViewItemMouseDown), false);

            if (localizationService == null)
            {
                localizationService = CommonServiceLocator.ServiceLocator.Current.GetInstance <ILocalizationService>();
            }
        }
Example #10
0
 /// <summary>
 /// Constructor for dependency injection.
 /// </summary>
 /// <param name="fileStructureService"></param>
 /// <param name="documentWorkflowAppSettingsService"></param>
 /// <param name="documentWorkflowUserService"></param>
 /// <param name="fileStructureDocumentPathService"></param>
 /// <param name="documentWorkflowTrackerService"></param>
 /// <param name="documentWorkflowOrganizationUnitAssignmentService"></param>
 public WorkflowOperationService(IFileStructureService fileStructureService,
                                 IDocumentWorkflowAppSettingsService documentWorkflowAppSettingsService,
                                 IDocumentWorkflowUserService documentWorkflowUserService,
                                 IFileStructureDocumentPathService fileStructureDocumentPathService,
                                 IDocumentWorkflowTrackerService documentWorkflowTrackerService,
                                 IDocumentWorkflowOrganizationUnitAssignmentService documentWorkflowOrganizationUnitAssignmentService,
                                 IDocumentWorkflowConfigurationService documentWorkflowConfigurationService,
                                 IUnityContainer unityContainer,
                                 IDocumentWorkflowAssignmentService documentWorkflowAssignmentService,
                                 Flow.Event.IFlowEventService flowEventService)
 {
     this.fileStructureService = fileStructureService;
     this.documentWorkflowAppSettingsService = documentWorkflowAppSettingsService;
     this.documentWorkflowUserService        = documentWorkflowUserService;
     this.fileStructureDocumentPathService   = fileStructureDocumentPathService;
     this.documentWorkflowTrackerService     = documentWorkflowTrackerService;
     this.documentWorkflowOrganizationUnitAssignmentService = documentWorkflowOrganizationUnitAssignmentService;
     this.unityContainer = unityContainer;
     this.documentWorkflowConfigurationService = documentWorkflowConfigurationService;
     this.documentWorkflowAssignmentService    = documentWorkflowAssignmentService;
     this.flowEventService = flowEventService;
 }
        /// <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>
        /// Initialize viewmodel
        /// </summary>
        /// <param name="documentId">Document id</param>
        public DocumentPathOverViewViewModel(Guid documentId)
        {
            this.documentId = documentId;

            documentPathService  = ServiceLocator.Current.GetInstance <IFileStructureDocumentPathService>();
            fileStructureService = ServiceLocator.Current.GetInstance <IFileStructureService>();
            directoryTypeService = ServiceLocator.Current.GetInstance <IDirectoryTypeService>();
            iconService          = ServiceLocator.Current.GetInstance <IIconService>();
            localizationService  = ServiceLocator.Current.GetInstance <ILocalizationService>();
            stackService         = ServiceLocator.Current.GetInstance <IStackService>();
            documentWorkflowAssignmentService = ServiceLocator.Current.GetInstance <IDocumentWorkflowAssignmentService>();

            removedPaths = new List <DocumentPathViewModel>();

            paths = new ObservableCollection <DocumentPathViewModel>();
            foreach (var path in documentPathService.GetByDocumentId(documentId))
            {
                var pathVM = new DocumentPathViewModel(path, fileStructureService, directoryTypeService, iconService, stackService)
                {
                    Parent = this
                };

                paths.Add(pathVM);
            }

            // Add new document path
            addDocumentPathCommand = new RelayCommand((p) =>
            {
                var newDocumentPath = SelectPath();

                if (newDocumentPath != null)
                {
                    if (CheckPathExists(newDocumentPath.Id, newDocumentPath.DirectoryGuid, newDocumentPath.FileStructureGuid))
                    {
                        MessageBox.Show(localizationService.Translate("filestructure_path_exists"), localizationService.Translate("filestructure_path_exists_title"), MessageBoxButton.OK, MessageBoxImage.Information);
                        return;
                    }

                    var newDocumentPathVM = new DocumentPathViewModel(newDocumentPath, fileStructureService, directoryTypeService, iconService, stackService)
                    {
                        Parent = this
                    };

                    Paths.Add(newDocumentPathVM);
                }
            });

            // Change document path
            changeDocumentPathCommand = new RelayCommand((p) =>
            {
                var selectedPath = p as DocumentPathViewModel;

                if (selectedPath.IsProtectedPath)
                {
                    MessageBox.Show(localizationService.Translate("filestructure_path_protected"), localizationService.Translate("filestructure_path_protected_title"), MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }

                var fileStructure = fileStructureService.Get(selectedPath.Model.FileStructureGuid);


                var selectPathWindow = new FileStructureWindow();
                selectPathWindow.Initialize(fileStructure);
                selectPathWindow.IsInSelectMode = true;

                selectPathWindow.Loaded += (s, e) =>
                {
                    selectPathWindow.ViewModel.SelectedDirectory = selectPathWindow.ViewModel.RawDirectories.FirstOrDefault(x => x.Model.Id == selectedPath.Model.DirectoryGuid);
                };

                selectPathWindow.ShowDialog();

                if (selectPathWindow.SelectedDirectory != null)
                {
                    if (CheckPathExists(selectedPath.Model.Id, selectPathWindow.SelectedDirectory.Id, fileStructure.Id))
                    {
                        MessageBox.Show(localizationService.Translate("filestructure_path_exists"), localizationService.Translate("filestructure_path_exists_title"), MessageBoxButton.OK, MessageBoxImage.Information);
                        return;
                    }

                    selectedPath.Model.DirectoryGuid = selectPathWindow.SelectedDirectory.Id;
                    selectedPath.Model.WorkflowId    = selectPathWindow.SelectedDirectory.WorkflowId;
                    selectedPath.RefreshPath();
                }
            });

            // Remove document path
            removeDocumentPathCommand = new RelayCommand((p) =>
            {
                var selectedPath = p as DocumentPathViewModel;

                if (selectedPath.IsProtectedPath)
                {
                    MessageBox.Show(localizationService.Translate("filestructure_path_protected"), localizationService.Translate("filestructure_path_protected_title"), MessageBoxButton.OK, MessageBoxImage.Information);
                    return;
                }

                var messageBoxResult = MessageBox.Show(localizationService.Translate("filestructure_remove_path"), localizationService.Translate("filestructure_remove_path_title"), MessageBoxButton.YesNo, MessageBoxImage.Question);

                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    removedPaths.Add(selectedPath);
                    paths.Remove(selectedPath);
                }
            });
        }
 public FileStructureTabItem()
 {
     this.fileStructureService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFileStructureService>();
     this.localizationService  = CommonServiceLocator.ServiceLocator.Current.GetInstance <ILocalizationService>();
 }
Example #14
0
 /// <summary>
 /// Initialize helper
 /// </summary>
 static ApplicationHelper()
 {
     fileStructureService = CommonServiceLocator.ServiceLocator.Current.GetInstance <IFileStructureService>();
     localizationService  = CommonServiceLocator.ServiceLocator.Current.GetInstance <ILocalizationService>();
 }