private void DragSource_Drop(object sender, Infragistics.DragDrop.DropEventArgs e)
        {
            var data = e.Data as NeighborhoodWatch;
            var drca = e.DropTarget as XamDataTreeNodeControl;

            if (drca != null)
            {
                var node = drca.Node;
                if (node != null)
                {
                    if (ApplicationContext.EndPointListAll.Select(r => r.MACAddress).Contains(data.MAC))
                    {
                        var messageDialog = PageNavigatorHelper._MainWindow.MessageDialogContentControl.Content as MessageDialog;
                        messageDialog.ShowMessageDialog(
                            "Cannot move, this Endpoint is existed",
                            "Message");
                        return;
                    }
                    var ndata = node.Data as DirectoryNode;

                    ApplicationContext.AllNeighborhoodWatch.Find(r => r.Id == data.Id).Managed = true;

                    Model.OnTabSelected();

                    var mainVM = PageNavigatorHelper.GetMainModel();
                    mainVM.AddComputer(ndata, data.Computer, data.MAC);
                }
            }
        }
        public void OnDirectoryClick()
        {
            Model.SetInitState();
            BackButton.Visibility = Visibility.Collapsed;
            //btnDirectorySetFocus();
            btnLabel.BorderThickness     = new Thickness(0);
            Model.DirectoryPushed        = true;
            btnDirectory.BorderThickness = new Thickness(0, 0, 0, 2);
            btnDirectory.BorderBrush     = (Brush)(new BrushConverter().ConvertFrom("#1dabed"));
            btnDirectory.Foreground      = Brushes.White;
            var bc = new BrushConverter();

            btnLabel.Foreground = (Brush)bc.ConvertFrom("#8e8f98");

            btnLabel.Style                   = FindResource("PushedTabPageButton") as Style;
            btnDirectory.Style               = FindResource("PushedTabPageButton") as Style;
            LabelScrollViewer.Visibility     = Visibility.Collapsed;
            DirectoryScrollViewer.Visibility = Visibility.Visible;
            //reload tree when click on the directory
            var mainViewModel = PageNavigatorHelper.GetMainModel();

            if (Model.SearchCommand.CanExecute(null))
            {
                Model.SearchText = "";
                ApplicationContext.SearchText = "";
                Model.DirectoryLabelClicked(true);

                mainViewModel.AddDeleteButtonVisible = true;
            }
            ApplicationContext.DirSearched = false;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ColorCodeViewModel"/> class.
 /// </summary>
 /// <param name="view">The view.</param>
 /// <param name="colorModel">The color model.</param>
 public ColorCodeViewModel(ColorCodeControl view, ColorModel colorModel)
 {
     _view = view;
     UpdateModel(colorModel);
     _view.Model    = this;
     _mainViewModel = PageNavigatorHelper.GetMainModel();
 }
        /// <summary>
        /// Indicate that whether we can refresh screen or not
        /// </summary>
        /// <returns></returns>
        protected bool CanRefresh()
        {
            ApplicationContext.CanRefreshEndpoint     = false;
            ApplicationContext.CanRefreshDiscovery    = false;
            ApplicationContext.CanRefreshLDAP         = false;
            ApplicationContext.CanRefreshSoftware     = false;
            ApplicationContext.CanRefreshUpdateSource = false;
            var lastRefreshUpdate = ServiceManager.GetLastUpdateData();
            var canrefresh        = false;

            foreach (var lastupd in lastRefreshUpdate)
            {
                foreach (var inLastUpd in LastRefresh)
                {
                    if (inLastUpd.Name == lastupd.Name && inLastUpd.LastSync < lastupd.LastSync)
                    {
                        if (lastupd.Name == "DirectoryEndpoint")
                        {
                            ApplicationContext.CanRefreshEndpoint = true;
                        }
                        if (lastupd.Name == "Discovery")
                        {
                            ApplicationContext.CanRefreshDiscovery = true;
                        }
                        if (lastupd.Name == "LDAPDirectoryEndpoint")
                        {
                            ApplicationContext.CanRefreshLDAP = true;
                        }
                        if (lastupd.Name == "Software")
                        {
                            ApplicationContext.CanRefreshSoftware = true;
                        }
                        if (lastupd.Name == "UpdateSource")
                        {
                            ApplicationContext.CanRefreshUpdateSource = true;
                        }
                        if (lastupd.Name == "Task")
                        {
                            ApplicationContext.CanRefreshTask = true;
                        }
                        canrefresh = true;
                    }
                }
            }

            if (canrefresh)
            {
                var mainVm = PageNavigatorHelper.GetMainModel();
                if (mainVm != null)
                {
                    ApplicationContext.IsReload           = true;
                    ApplicationContext.IsReloadForRefresh = true;
                    mainVm.ReloadData();
                    LastRefresh = lastRefreshUpdate;
                }
            }

            return(canrefresh);
        }
 public ShowLDAPDirectoryViewModel(ShowLdapDirectoryDialog view, LDAPAssignmentViewModel ldapAssignmentViewModel)
 {
     _view = view;
     _ldapAssignmentViewModel = ldapAssignmentViewModel;
     _mainWindowViewModel     = PageNavigatorHelper.GetMainModel();
     SelectLdapCommand        = new RelayCommand(OnMoveCommand, CanExecuteCommand);
     _view.Loaded            += _view_Loaded;
 }
        private void UploadSoftware()
        {
            var mainVm = PageNavigatorHelper.GetMainModel();

            mainVm.ShowMessage("Uploading...");
            var uploadBg = new BackgroundWorkerHelper();

            uploadBg.AddDoWork(SaveBackgroundWorker_DoWork).AddRunWorkerCompleted(OnSaveData_RunWorkerCompleted).DoWork();
        }
Ejemplo n.º 7
0
        private void OnAssignmentNavExecute()
        {
            var mainViewModel = PageNavigatorHelper.GetMainModel();

            if (mainViewModel != null)
            {
                mainViewModel.NavigationIndex = (int)NavigationIndexes.Assignment;
            }
            PageNavigatorHelper.Switch(new DirectoryAssignmentPage());
        }
Ejemplo n.º 8
0
        private void OnDownloadNavExecute()
        {
            var mainViewModel = PageNavigatorHelper.GetMainModel();

            if (mainViewModel != null)
            {
                mainViewModel.NavigationIndex = (int)NavigationIndexes.Download;
            }
            //            PageNavigatorHelper.Switch(new NeighborhoodWatchPage());
        }
Ejemplo n.º 9
0
        private void OncolorNavExecute()
        {
            var mainViewModel = PageNavigatorHelper.GetMainModel();

            if (mainViewModel != null)
            {
                mainViewModel.NavigationIndex = (int)NavigationIndexes.Colors;
            }
            PageNavigatorHelper.Switch(new ColorCodePage());
        }
Ejemplo n.º 10
0
        private void OnQuarantineNavExecute()
        {
            var mainViewModel = PageNavigatorHelper.GetMainModel();

            if (mainViewModel != null)
            {
                mainViewModel.NavigationIndex = (int)NavigationIndexes.Transfer;
            }
            PageNavigatorHelper.Switch(new POCQuarantinePage());
        }
Ejemplo n.º 11
0
        private void OnLDAPNavExecute()
        {
            var mainViewModel = PageNavigatorHelper.GetMainModel();

            if (mainViewModel != null)
            {
                mainViewModel.NavigationIndex = (int)NavigationIndexes.LDAP;
            }
            PageNavigatorHelper.Switch(new LDAPPage());
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImportFilePageViewModel"/> class.
 /// </summary>
 /// <param name="view">The view.</param>
 /// <param name="folderId">The folder identifier.</param>
 public ImportFilePageViewModel(ImportFilePage view, int folderId)
 {
     _mainViewModel    = PageNavigatorHelper.GetMainModel();
     ImportCommand     = new RelayCommand(ExecuteImport, CanImport);
     CancelCommand     = new RelayCommand(ExecuteCancel);
     BrowseFileCommand = new RelayCommand(ExecuteBrowseFile, CanBrowseFile);
     _view             = view;
     ReloadData(folderId);
     VisibleSimulate       = Visibility.Collapsed;
     MenuImportButtonStyle = _view.FindResource("MenuButton") as Style;
 }
        /// <summary>
        ///     Make tree data
        /// </summary>
        /// <returns></returns>
        public void MakeTree(int nodeSelected, bool isSearch = false, string searchKey = "", bool isExpandAll = false, bool isReload = false)
        {
            if (isSearch)
            {
                GetSearchedData(searchKey);
            }
            else if (isReload)
            {
                ApplicationContext.FolderListAll    = GetAllFolders();
                ApplicationContext.EndPointListAll  = GetDirectoryEndpoints(1);
                ApplicationContext.FolderListTree   = ApplicationContext.FolderListAll;
                ApplicationContext.EndPointListTree = ApplicationContext.EndPointListAll;
            }
            var rootId     = ApplicationContext.FolderListTree == null || (ApplicationContext.FolderListTree != null && ApplicationContext.FolderListTree.Count == 0) ? ApplicationContext.FolderListAll.Find(r => r.FolderId == ApplicationContext.FolderListAll.Min(m => m.FolderId)).FolderId : ApplicationContext.FolderListTree.Min(r => r.FolderId);
            var rootName   = ApplicationContext.FolderListTree == null || (ApplicationContext.FolderListTree != null && ApplicationContext.FolderListTree.Count == 0) ? ApplicationContext.FolderListAll.Find(r => r.FolderId == ApplicationContext.FolderListAll.Min(m => m.FolderId)).FolderName : ApplicationContext.FolderListTree.Find(r => r.FolderId == rootId).FolderName;
            var guid       = ApplicationContext.FolderListTree == null || (ApplicationContext.FolderListTree != null && ApplicationContext.FolderListTree.Count == 0) ? ApplicationContext.FolderListAll.Find(r => r.FolderId == ApplicationContext.FolderListAll.Min(m => m.FolderId)).Guid : ApplicationContext.FolderListTree.Find(r => r.FolderId == rootId).Guid;
            var mainVm     = PageNavigatorHelper.GetMainModel();
            var isPocAgent = mainVm.NavigationIndex == (int)NavigationIndexes.POCAgent;
            var rootPolicy = isPocAgent ? ApplicationContext.FolderPolicyList.Find(r => r.ObjectId == rootId) : null;
            // create root, build subtree and return it
            var node = new DirectoryNode
            {
                NodeId              = rootId,
                Title               = rootName,
                IsFolder            = true,
                Guid                = guid,
                NodeWidth           = ApplicationContext.GridRightOriginalWidth,
                NodeHoverWidth      = isPocAgent ? 0 : ApplicationContext.GridRightOriginalWidth,
                NodeSelectedWidth   = isPocAgent ? ApplicationContext.GridRightOriginalWidth : 0,
                NodePolicyColor     = isPocAgent ? (rootPolicy != null ? rootPolicy.Color : UIConstant.PolicyDefaultColor) : "",
                ChildrenPolicyColor = isPocAgent ? GetChildPolicyAssign(new Directory {
                    FolderId = rootId
                }) : null,
                NodeColor = "#FFF"
            };

            MakeSubTree(node, isPocAgent);
            var listNode = new ObservableCollection <DirectoryNode>();

            listNode.Add(node);
            var rightViewModel = PageNavigatorHelper.GetRightElementViewModel();

            if (rightViewModel != null)
            {
                rightViewModel.EndEditingTree();
                rightViewModel.TreeDataSource = listNode;
                if (isExpandAll)
                {
                    ApplicationContext.ExpandedIds = new List <int>();
                    ApplicationContext.ExpandedIds.Add(ApplicationContext.FolderListAll.Select(c => c.FolderId).ToList().Min());
                }
                rightViewModel.RefreshTreeData(nodeSelected);
            }
        }
        private bool CheckEndpointNavigationClicked()
        {
            var mainVm = PageNavigatorHelper.GetMainModel();

            if (mainVm != null &&
                (mainVm.NavigationIndex == (int)NavigationIndexes.Endpoint ||
                 mainVm.NavigationIndex == (int)NavigationIndexes.Label))
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 15
0
        private void OnDiscoveryNavExecute()
        {
            var mainModel = PageNavigatorHelper.GetMainModel();

            SubEndpointVisibility  = 0.99;
            SubSoftwareVisibility  = 0.99;
            SubPolicyVisibility    = 0.99;
            SubReportingVisibility = 0.99;
            SubDiscoveryVisibility = SubDiscoveryVisibility == 1 ? 0.99 : 1;

            if (mainModel != null)
            {
                mainModel.NavigationIndex = (int)NavigationIndexes.Discovery;
            }
        }
Ejemplo n.º 16
0
        public void SelectedLDAPNavigation()
        {
            SubDiscoveryVisibility = 1;
            SubEndpointVisibility  = 0.99;
            SubPolicyVisibility    = 0.99;
            SubSoftwareVisibility  = 0.99;
            SubReportingVisibility = 0.99;
            var mainViewModel = PageNavigatorHelper.GetMainModel();

            if (mainViewModel != null)
            {
                mainViewModel.NavigationIndex = (int)NavigationIndexes.LDAP;
            }
            SetActiveButton("SubBtnLDAP");
        }
Ejemplo n.º 17
0
        public void ChangeEndpointNavigationState()
        {
            SubDiscoveryVisibility = 0.99;
            SubPolicyVisibility    = 0.99;
            SubSoftwareVisibility  = 0.99;
            SubReportingVisibility = 0.99;
            SubEndpointVisibility  = SubEndpointVisibility == 1 ? 0.99 : 1;
            var mainViewModel = PageNavigatorHelper.GetMainModel();

            if (mainViewModel != null)
            {
                mainViewModel.NavigationIndex = (int)NavigationIndexes.Endpoint;
            }
            SetActiveButton("BtnEndPoint");
        }
Ejemplo n.º 18
0
        private void OnMoveCommand(object args)
        {
            var data = new MoveFoldersAndEndpointsInputArgs();

            data.TargerFolderId = ApplicationContext.NodeTargetId;

            var selectNode    = FindChildSelectedNode();
            var dnlist        = new List <DirectoryNode>();
            var allChildNodes = new List <DirectoryNode>();

            foreach (var sn in ApplicationContext.NodesSelected)
            {
                if (sn.IsFolder)
                {
                    var childNodes = new List <DirectoryNode>();
                    FindAllChild(childNodes, sn);
                    allChildNodes.AddRange(childNodes);
                }
                dnlist.Add(sn);
                var node = selectNode.Find(e => e.NodeId == sn.NodeId);
                if (node != null)
                {
                    dnlist.Remove(sn);
                }
            }

            if (allChildNodes.Select(e => e.NodeId).ToList().Contains(data.TargerFolderId))
            {
                var messageDialog = PageNavigatorHelper._MainWindow.MessageDialogContentControl.Content as MessageDialog;
                messageDialog.ShowMessageDialog("Target folder is invalid", "Message");
                return;
            }

            data.FolderIds   = dnlist.Where(e => e.IsFolder).Select(e => e.NodeId).ToList();
            data.EndpointIds = dnlist.Where(e => !e.IsFolder).Select(e => e.NodeId).ToList();
            var mainViewModel = PageNavigatorHelper.GetMainModel();

            if (mainViewModel != null)
            {
                mainViewModel.MoveDirectoriesAndEndpointsAction(data);
            }
            _view.HideWindow();
            MakeTree(data.TargerFolderId);
        }
Ejemplo n.º 19
0
        public void EndPointNavigationClick()
        {
            SubDiscoveryVisibility = 0.99;
            SubSoftwareVisibility  = 0.99;
            SubPolicyVisibility    = 0.99;
            SubReportingVisibility = 0.99;
            SubEndpointVisibility  = SubEndpointVisibility == 1 ? 0.99 : 1;
            var mainViewModel = PageNavigatorHelper.GetMainModel();

            if (mainViewModel != null)
            {
                mainViewModel.NavigationIndex = (int)NavigationIndexes.Endpoint;
            }
            var righModel = PageNavigatorHelper.GetRightElementViewModel();

            if (righModel != null)
            {
                if (righModel.DirectoryPushed)
                {
                    var nodeSelected = ApplicationContext.NodesSelected != null &&
                                       ApplicationContext.NodesSelected.Count > 0
                        ? ApplicationContext.NodesSelected[0]
                        : null;
                    if (nodeSelected != null)
                    {
                        SelectCurrentTreeNode(nodeSelected);
                    }
                }
                else
                {
                    var nodeSelected = ApplicationContext.LabelNodesSelected != null &&
                                       ApplicationContext.LabelNodesSelected.Count > 0
                        ? ApplicationContext.LabelNodesSelected[0]
                        : null;
                    if (nodeSelected != null)
                    {
                        righModel.SelectLabelNodeFromGrid(nodeSelected);
                    }
                }
            }
        }
Ejemplo n.º 20
0
        private void OnPOCAgentNavExecute()
        {
            var mainViewModel = PageNavigatorHelper.GetMainModel();

            if (mainViewModel != null)
            {
                mainViewModel.NavigationIndex    = (int)NavigationIndexes.POCAgent;
                ApplicationContext.IsRebuildTree = true;
                if (ApplicationContext.FolderPolicyList == null)
                {
                    Functions.LoadFolderPolicy();
                }
                if (ApplicationContext.EndpointPolicyList == null)
                {
                    Functions.LoadEndpointPolicy();
                }
                var rightVM = PageNavigatorHelper.GetRightElementViewModel();
                rightVM.ReBuildTree(ApplicationContext.NodesSelected);
            }
            PageNavigatorHelper.Switch(new POCAgentPage());
        }
Ejemplo n.º 21
0
        //protected override void OnStartup(StartupEventArgs e)
        //{
        //    base.OnStartup(e);
        //    var form = new ConfigurationForm();
        //    form.Show();
        //}

        /// <summary>
        /// Handles the <see>
        ///     <cref>E:ApplicationUnhandledException</cref>
        /// </see>
        ///     event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="DispatcherUnhandledExceptionEventArgs"/> instance containing the event data.</param>
        void OnApplicationUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            string errorMessage = string.Format("An application error occurred.\nPlease check whether your data is correct and repeat the action. If this error occurs again there seems to be a more serious malfunction in the application, and you better close it.\n\nError:{0})",

                                                e.Exception.Message + (e.Exception.InnerException != null ? "\n" +
                                                                       e.Exception.InnerException.Message : null));
            var log = LogManager.GetLogger(typeof(App));

            log.Error(errorMessage, e.Exception.InnerException ?? e.Exception);
            var mainViewModel = PageNavigatorHelper.GetMainModel();

            if (mainViewModel != null)
            {
                mainViewModel.StartAppTimer();
            }
#if DEBUG
            e.Handled = false;
#else
            ShowUnhandeledException(e);
#endif
        }
        private void OnSaveData_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            var mainVm = PageNavigatorHelper.GetMainModel();

            if (e.Result != null && (bool)e.Result == false)
            {
                mainVm.HideMessage();
                return;
            }
            _view.Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)(() =>
            {
                var smv = PageNavigatorHelper.GetMainContentViewModel <SoftwareViewModel>();
                if (smv != null)
                {
                    smv.Refresh();
                }
                _view.Close();

                mainVm.HideMessage();
                //Auto transfer
                AutoTransferNewContent();
            }));
        }
        public void ReBuildTree(List <DirectoryNode> nodeSelected)
        {
            var mainVm     = PageNavigatorHelper.GetMainModel();
            var isPocAgent = mainVm.NavigationIndex == (int)NavigationIndexes.POCAgent;
            var rootId     = ApplicationContext.FolderListTree == null || (ApplicationContext.FolderListTree != null && ApplicationContext.FolderListTree.Count == 0) ? ApplicationContext.FolderListAll.Find(r => r.FolderId == ApplicationContext.FolderListAll.Min(m => m.FolderId)).FolderId : ApplicationContext.FolderListTree.Min(r => r.FolderId);
            var rootName   = ApplicationContext.FolderListTree == null || (ApplicationContext.FolderListTree != null && ApplicationContext.FolderListTree.Count == 0) ? ApplicationContext.FolderListAll.Find(r => r.FolderId == ApplicationContext.FolderListAll.Min(m => m.FolderId)).FolderName : ApplicationContext.FolderListTree.Find(r => r.FolderId == rootId).FolderName;
            var guid       = ApplicationContext.FolderListTree == null || (ApplicationContext.FolderListTree != null && ApplicationContext.FolderListTree.Count == 0) ? ApplicationContext.FolderListAll.Find(r => r.FolderId == ApplicationContext.FolderListAll.Min(m => m.FolderId)).Guid : ApplicationContext.FolderListTree.Find(r => r.FolderId == rootId).Guid;
            var rootPolicy = isPocAgent ? ApplicationContext.FolderPolicyList.Find(r => r.ObjectId == rootId) : null;
            // create root, build subtree and return it
            var node = new DirectoryNode
            {
                NodeId              = rootId,
                Title               = rootName,
                IsFolder            = true,
                NodeWidth           = ApplicationContext.GridRightOriginalWidth,
                Guid                = guid,
                NodeHoverWidth      = isPocAgent?0:ApplicationContext.GridRightOriginalWidth,
                NodeSelectedWidth   = isPocAgent? ApplicationContext.GridRightOriginalWidth : 0,
                NodePolicyColor     = isPocAgent? (rootPolicy != null?rootPolicy.Color: UIConstant.PolicyDefaultColor) : "",
                ChildrenPolicyColor = isPocAgent? GetChildPolicyAssign(new Directory {
                    FolderId = rootId
                }): null
            };

            MakeSubTree(node, isPocAgent);
            var listNode = new ObservableCollection <DirectoryNode>();

            listNode.Add(node);
            var rightViewModel = PageNavigatorHelper.GetRightElementViewModel();

            if (rightViewModel != null)
            {
                rightViewModel.EndEditingTree();
                rightViewModel.TreeDataSource = listNode;
                rightViewModel.RefreshTreeData(nodeSelected);
            }
        }
Ejemplo n.º 24
0
        private void CanTabSelected(Button btn)
        {
            if (btn == null || ApplicationContext.NodesSelected == null || ApplicationContext.NodesSelected.Count == 0 || ApplicationContext.IsFromLabel)
            {
                return;
            }
            List <DirectoryNode> folders   = new List <DirectoryNode>();
            List <DirectoryNode> endpoints = new List <DirectoryNode>();

            foreach (var n in ApplicationContext.NodesSelected)
            {
                if (n.IsFolder)
                {
                    folders.Add(n);
                }
                else
                {
                    endpoints.Add(n);
                }
            }
            var mainViewModel = PageNavigatorHelper.GetMainModel();

            if (mainViewModel != null)
            {
                mainViewModel.NavigationIndex = (int)NavigationIndexes.Colors;
            }
            //PageNavigatorHelper.Switch(new ColorCodePage(folders[0]));
            if (folders.Count == 0)
            {
                PageNavigatorHelper.Switch(new ColorCodePage(endpoints[0]));
            }
            else
            {
                PageNavigatorHelper.Switch(new ColorCodePage(folders[0]));
            }
        }
        /// <summary>
        ///     Save the node name edited
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataTree_NodeExitedEditMode(object sender, NodeEventArgs e)
        {
            var mainViewModel = PageNavigatorHelper.GetMainModel();
            var nodedata      = e.Node.Data as DirectoryNode;

            if (DataTree.Equals(sender))
            {
                if (nodedata != null && !string.IsNullOrWhiteSpace(nodedata.Title.Trim()))
                {
                    if (nodedata != null && nodedata.IsFolder)
                    {
                        if (nodedata.Title.Length > 200)
                        {
                            var mdialog = PageNavigatorHelper._MainWindow.MessageDialogView;
                            mdialog.ShowMessageDialog("Name's length must be less than 200 letters", "Message");

                            nodedata.Title = _originalTitle;
                        }
                        else
                        {
                            DataTree.SelectionSettings.NodeSelection = TreeSelectionType.None;
                            var ed = new DirectoryEndpoint
                            {
                                Name     = nodedata.Title,
                                FolderId = nodedata.NodeId
                            };

                            if (mainViewModel != null)
                            {
                                mainViewModel.EditDirectoryAction(ed);
                            }
                        }
                    }
                    if (nodedata != null && !nodedata.IsFolder)
                    {
                        if (nodedata.Title.Length > 250)
                        {
                            var mdialog = PageNavigatorHelper._MainWindow.MessageDialogView;
                            mdialog.ShowMessageDialog("Name's length must be less than 250 letters", "Message");

                            nodedata.Title = _originalTitle;
                        }
                        else
                        {
                            DataTree.SelectionSettings.NodeSelection = TreeSelectionType.None;
                            var ed = new DirectoryEndpoint
                            {
                                Name     = nodedata.Title,
                                FolderId = nodedata.NodeId
                            };

                            if (mainViewModel != null)
                            {
                                mainViewModel.EditEndpointAction(ed);
                            }
                        }
                    }
                }
                else
                {
                    if (nodedata != null)
                    {
                        nodedata.Title = _originalTitle;
                    }
                }
            }
            else if (SoftwareDataTree.Equals(sender))
            {
                if (nodedata != null && !string.IsNullOrWhiteSpace(nodedata.SourceName.Trim()))
                {
                    if (nodedata.SourceName.Length > 200)
                    {
                        var mdialog = PageNavigatorHelper._MainWindow.MessageDialogView;
                        mdialog.ShowMessageDialog("the length of SourceName must be less than 200 letters", "Message");

                        nodedata.Title      = _originalTitle;
                        nodedata.SourceName = _originalSourceName;
                        return;
                    }
                    var updSource = ApplicationContext.UpdateSourceList.Find(r => r.Id == nodedata.NodeId);
                    if (updSource != null)
                    {
                        updSource.SourceName = nodedata.Title;
                    }
                    Model.BuilSoftwareTree();
                    var editSoftwareBg = new BackgroundWorkerHelper();
                    editSoftwareBg.AddDoWork(SaveBackgroundWorker_DoWork).DoWork(updSource);
                }
                else
                {
                    if (nodedata != null)
                    {
                        nodedata.Title      = _originalTitle;
                        nodedata.SourceName = _originalSourceName;
                    }
                }
            }
            ApplicationContext.IsBusy = false;
        }
 public EndpointDirectoryDialogViewModel(EndpointDirectoryDialog view)
 {
     _view = view;
     _mainWindowViewModel = PageNavigatorHelper.GetMainModel();
     OkCommand            = new RelayCommand(OnMoveCommand, CanExecuteCommand);
 }
Ejemplo n.º 27
0
 public MoveLDAPViewModel(MoveLdapDialog view)
 {
     _view = view;
     _mainWindowViewModel = PageNavigatorHelper.GetMainModel();
     MoveLdapCommand      = new RelayCommand(OnMoveCommand, CanExecuteCommand);
 }
Ejemplo n.º 28
0
        /// <summary>
        ///     Called when [navigator selected].
        /// </summary>
        /// <param name="btn">The BTN.</param>
        private void OnNavigatorCommand(Button btn)
        {
            var rightVM = PageNavigatorHelper.GetRightElementViewModel();

            _view.StSubDiscovery.Visibility = Visibility.Visible;
            _view.StSubEndpoint.Visibility  = Visibility.Visible;
            _view.StSubSoftware.Visibility  = Visibility.Visible;
            _view.StSubPolicies.Visibility  = Visibility.Visible;
            _view.StSubReporting.Visibility = Visibility.Visible;
            var mainViewModel = PageNavigatorHelper.GetMainModel();
            var previousIndex = mainViewModel.NavigationIndex;

            switch (btn.Name)
            {
            case "BtnEndPoint":
                EndPointNavigationClick();
                if (rightVM != null)
                {
                    rightVM.DirectoryTreeVisible = true;
                    rightVM.SoftwareTreeVisible  = false;
                    if (rightVM.DirectoryPushed)
                    {
                        mainViewModel.AddDeleteButtonVisible = true;
                    }
                }
                break;

            case "SubBtnLabel":
                OnLabelNavExecute();
                if (rightVM != null)
                {
                    rightVM.DirectoryTreeVisible = true;
                    rightVM.SoftwareTreeVisible  = false;
                    if (rightVM.DirectoryPushed)
                    {
                        mainViewModel.AddDeleteButtonVisible = true;
                    }
                }
                break;

            case "SubBtnColor":
                CanTabSelected(btn);
                if (rightVM != null)
                {
                    rightVM.DirectoryTreeVisible = true;
                    rightVM.SoftwareTreeVisible  = false;
                    if (rightVM.DirectoryPushed)
                    {
                        mainViewModel.AddDeleteButtonVisible = true;
                    }
                }
                break;

            case "SubBtnAssignments":
                OnAssignmentNavExecute();
                if (rightVM != null)
                {
                    rightVM.DirectoryTreeVisible = true;
                    rightVM.SoftwareTreeVisible  = false;
                    if (rightVM.DirectoryPushed)
                    {
                        mainViewModel.AddDeleteButtonVisible = true;
                    }
                }
                break;

            case "BtnDiscovery":
                OnDiscoveryNavExecute();
                if (rightVM != null)
                {
                    rightVM.DirectoryTreeVisible = true;
                    rightVM.SoftwareTreeVisible  = false;
                    if (rightVM.DirectoryPushed)
                    {
                        mainViewModel.AddDeleteButtonVisible = true;
                    }
                }
                break;

            case "SubBtnNeighborhood":
                OnNeighborhoodNavExecute();
                if (rightVM != null)
                {
                    rightVM.DirectoryTreeVisible = true;
                    rightVM.SoftwareTreeVisible  = false;
                    if (rightVM.DirectoryPushed)
                    {
                        mainViewModel.AddDeleteButtonVisible = true;
                    }
                }
                break;

            case "SubBtnLDAP":
                OnLDAPNavExecute();
                if (rightVM != null)
                {
                    rightVM.DirectoryTreeVisible = true;
                    rightVM.SoftwareTreeVisible  = false;
                    if (rightVM.DirectoryPushed)
                    {
                        mainViewModel.AddDeleteButtonVisible = true;
                    }
                }
                break;

            case "BtnSoftware":
                OnSoftwareNavExecute();
                if (rightVM != null)
                {
                    rightVM.BuilSoftwareTree();
                    rightVM.DirectoryTreeVisible         = false;
                    rightVM.SoftwareTreeVisible          = true;
                    mainViewModel.AddDeleteButtonVisible = false;
                }
                break;

            case "SubBtnDownload":
                OnDownloadNavExecute();
                if (rightVM != null)
                {
                    rightVM.DirectoryTreeVisible         = false;
                    rightVM.SoftwareTreeVisible          = true;
                    mainViewModel.AddDeleteButtonVisible = false;
                }
                break;

            case "SubBtnTransfer":
                OnTransferNavExecute();
                if (rightVM != null)
                {
                    rightVM.DirectoryTreeVisible         = false;
                    rightVM.SoftwareTreeVisible          = true;
                    mainViewModel.AddDeleteButtonVisible = false;
                }
                break;

            case "BtnLicense":
                OnLicenseNavExecute();
                break;

            case "BtnPolicy":
                OnPolicyNavExecute();
                break;

            case "SubBtnPOCAgent":
                OnPOCAgentNavExecute();
                if (rightVM != null)
                {
                    rightVM.DirectoryTreeVisible         = true;
                    rightVM.SoftwareTreeVisible          = false;
                    mainViewModel.AddDeleteButtonVisible = false;
                }
                break;

            case "SubBtnEndpointPatron":
                break;

            case "BtnReporting":
                OnReportingNavExecute();
                break;

            case "SubBtnQuarantine":
                OnQuarantineNavExecute();
                break;

            case "BtnNotification":
                OnNotificationNavExecute();
                break;

            case "BtnSetting":
                OnSettingNavExecute();
                break;
            }
            if (btn.Name != "SubBtnPOCAgent" && previousIndex == (int)NavigationIndexes.POCAgent)
            {
                ApplicationContext.IsRebuildTree = true;
                rightVM.ReBuildTree(ApplicationContext.NodesSelected);
            }
        }
        /// <summary>
        ///     Event of dropping a note
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataTree_OnNodeDragEnd(object sender, DragDropEventArgs e)
        {
            if (e.OperationType == OperationType.DropNotAllowed)
            {
                return;
            }
            var data          = new MoveFoldersAndEndpointsInputArgs();
            var dragNode      = e.Data as XamDataTreeNode;
            var mainViewModel = PageNavigatorHelper.GetMainModel();

            if (dragNode != null)
            {
                var dragData = dragNode.Data as DirectoryNode;
                if (dragData != null)
                {
                    var dropTarget = e.DropTarget as XamDataTreeNodeControl;
                    if (dropTarget != null)
                    {
                        var dropData = dropTarget.Node.Data as DirectoryNode;
                        if (dropData != null)
                        {
                            if (DataTree.Equals(sender))
                            {
                                ApplicationContext.NodeId = dragData.NodeId;
                                if (!(dropData.NodeId == dragData.NodeId && dropData.IsFolder == dragData.IsFolder))
                                {
                                    data.TargerFolderId = dropData.NodeId;
                                    var lstfi = new List <int>();
                                    var lstei = new List <int>();
                                    if (dragData.IsFolder)
                                    {
                                        lstfi.Add(dragData.NodeId);
                                    }
                                    else
                                    {
                                        lstei.Add(dragData.NodeId);
                                    }
                                    data.FolderIds   = lstfi;
                                    data.EndpointIds = lstei;

                                    if (mainViewModel != null)
                                    {
                                        mainViewModel.MoveDirectoriesAndEndpointsAction(data);
                                    }
                                }
                            }
                            else if (SoftwareDataTree.Equals(sender))
                            {
                                var updSource = ApplicationContext.UpdateSourceList.Find(r => r.Id == dragData.NodeId);
                                if (updSource != null)
                                {
                                    updSource.ParentId = dropData.NodeId;
                                    var editUpdSourceBg = new BackgroundWorkerHelper();
                                    editUpdSourceBg.AddDoWork(SaveBackgroundWorker_DoWork).DoWork(updSource);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 30
0
        public void MoveNotes(ObservableCollection <DirectoryNode> listMoves, string guid, int parentId, bool isUseMoveButton = false)
        {
            var workers = new List <BackgroundWorker>();

            foreach (var dn in listMoves)
            {
                var listMove = new ObservableCollection <DirectoryNode>();
                listMove.Add(dn);
                var dirs = new List <DirectoryNode>();
                DataFromNode(dirs, listMove, guid, parentId);
                foreach (var dir in dirs)
                {
                    if (!dir.IsFolder)
                    {
                        var isExisted = ApplicationContext.EndPointListAll.Select(r => r.SystemName).Contains(dir.Title);
                        if (isExisted)
                        {
                            var messageDialog =
                                PageNavigatorHelper._MainWindow.MessageDialogContentControl.Content as MessageDialog;
                            messageDialog.ShowMessageDialog("Endpoint can not be moved because it is already Existed", "Message");
                            if (!isUseMoveButton)
                            {
                                ApplicationContext.IsReloadForRefresh = true;
                                var rootId = ApplicationContext.FolderListAll.Select(r => r.FolderId).Min();
                                Model.MakeTree(rootId);
                                var domains = PnlDomainContainer.Children;
                                foreach (var domain in domains)
                                {
                                    if (domain.GetType() == typeof(LDAPDomainExpanderElement))
                                    {
                                        var expander = domain as LDAPDomainExpanderElement;
                                        if (expander.Model.IsActived)
                                        {
                                            var ldap = new LDAP {
                                                Id = expander.Model.Id, Domain = expander.Model.DomainName, ShowEndpoints = expander.Model.IsShowEndpoints, ShowFolders = expander.Model.IsShowFolders, HideEmptyFolders = expander.Model.IsHideEmptyFolders, HideManagedEndpoints = expander.Model.IsHideManagedEndPoints
                                            };
                                            Model.BuildLDAPTree(ldap);
                                            break;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                PageNavigatorHelper.GetMainModel().HideMessage();
                            }

                            return;
                        }
                    }
                }
            }
            foreach (var dn in listMoves)
            {
                var listMove = new ObservableCollection <DirectoryNode>();
                listMove.Add(dn);
                var dirs = new List <DirectoryNode>();
                DataFromNode(dirs, listMove, guid, parentId);
                foreach (var dir in dirs)
                {
                    if (!dir.IsFolder)
                    {
                        if (
                            ApplicationContext.LdapDirectoriesEndpointsDictionary.ContainsKey(
                                ApplicationContext.LDAPActived.Id))
                        {
                            var ldapDirEnd = ApplicationContext.LdapDirectoriesEndpointsDictionary[ApplicationContext.LDAPActived.Id];
                            var endLDAP    = ldapDirEnd.Endpoints.FindAll(r => r.SystemName == dir.Title);
                            foreach (var end in endLDAP)
                            {
                                end.Managed = true;
                            }
                        }
                    }
                }
                var addBkg = new BackgroundWorker();
                addBkg.DoWork += AddBkg_DoWork;
                workers.Add(addBkg);
                addBkg.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs arg)
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() =>
                    {
                        var worker = s as BackgroundWorker;
                        workers.Remove(worker);
                        if (workers.Count == 0)
                        {
                            var cdomains = PnlDomainContainer.Children;
                            foreach (var domain in cdomains)
                            {
                                if (domain.GetType() == typeof(LDAPDomainExpanderElement))
                                {
                                    var expander = domain as LDAPDomainExpanderElement;
                                    if (expander.Model.IsActived)
                                    {
                                        var ldap = new LDAP {
                                            Id = expander.Model.Id, Domain = expander.Model.DomainName, ShowEndpoints = expander.Model.IsShowEndpoints, ShowFolders = expander.Model.IsShowFolders, HideEmptyFolders = expander.Model.IsHideEmptyFolders, HideManagedEndpoints = expander.Model.IsHideManagedEndPoints
                                        };
                                        Model.BuildLDAPTree(ldap);
                                        break;
                                    }
                                }
                            }
                            var rootId = ApplicationContext.FolderListAll.Select(r => r.FolderId).Min();
                            ApplicationContext.IsReloadForRefresh = true;
                            Model.MakeTree(rootId, false, "", false, true);
                            PageNavigatorHelper.GetMainModel().HideMessage();
                        }
                    }));
                };
                addBkg.RunWorkerAsync(dirs);
            }
        }