/// <summary> /// Executes the cancel. /// </summary> /// <param name="obj">The object.</param> private void ExecuteCancel(object obj) { _directoryComputerImporter = null; if (!PageNavigatorHelper.IsCurrent <EndPointListPage>()) { PageNavigatorHelper.Switch(new EndPointListPage()); } var viewModel = PageNavigatorHelper.GetMainContentViewModel <GroupViewModel>(); var selectedFolderIds = new List <int>(); var selectedEndpointIds = new List <int>(); selectedFolderIds.Add(CurrentDirectoryNode.NodeId); viewModel.SetParamsValueForDirectory(selectedFolderIds, selectedEndpointIds, ApplicationContext.SearchText, false, Guid.NewGuid(), ""); viewModel.GetData(); FilePath = string.Empty; }
private void OnTabSelected(Button btn) { if (btn == null) { return; } switch (btn.Content.ToString()) { case "Infos": if (!PageNavigatorHelper.IsCurrent <EndPointViewPage>()) { PageNavigatorHelper.Switch(new EndPointViewPage()); var viewModel = PageNavigatorHelper.GetMainContentViewModel <EndpointViewModel>(); viewModel.SetParams(ApplicationContext.NodesSelected[0].NodeId); viewModel.ReloadData(); } break; case UIConstant.GroupPolicies: if (!PageNavigatorHelper.IsCurrent <PolicyEnhancementPage>()) { PageNavigatorHelper.Switch(new PolicyEnhancementPage()); } break; case UIConstant.TaskListPage: if (!PageNavigatorHelper.IsCurrent <TaskListPage>()) { var taskListPage = new TaskListPage(); PageNavigatorHelper.Switch(taskListPage); } break; default: //Endpoint break; } }
/// <summary> /// event selected collection changed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DataTree_SelectedNodesCollectionChanged(object sender, NodeSelectionEventArgs e) { if (e.CurrentSelectedNodes.Count < 1) { if (DataTree.Equals(sender)) { ApplicationContext.IsError = true; ApplicationContext.NodesSelected = new List <DirectoryNode>(); } else { ApplicationContext.LabelNodesSelected = new List <DirectoryNode>(); } } else { if (SoftwareDataTree.Equals(sender)) { ApplicationContext.SoftwareSelectedNodeId = (e.CurrentSelectedNodes[0].Data as DirectoryNode).NodeId; if (PageNavigatorHelper.IsCurrent <SoftwarePage>()) { var viewModel = PageNavigatorHelper.GetMainContentViewModel <SoftwareViewModel>(); viewModel.SourceName = (e.CurrentSelectedNodes[0].Data as DirectoryNode).Title.ToUpper(); viewModel.BuidPage(); } return; } if (CheckScreenWithoutRefresh()) { return; } if (ApplicationContext.IsRebuildTree) { if (!LabelDataTree.Equals(sender) && e.CurrentSelectedNodes.Count == ApplicationContext.NodesSelected.Count) { ApplicationContext.IsRebuildTree = false; } if (LabelDataTree.Equals(sender) && e.CurrentSelectedNodes.Count == ApplicationContext.LabelNodesSelected.Count) { ApplicationContext.IsRebuildTree = false; } return; } var ln = new List <DirectoryNode>(); var fids = new List <DirectoryNode>(); var eids = new List <int>(); foreach (var cn in e.CurrentSelectedNodes) { var cnode = cn.Data as DirectoryNode; if (cnode != null) { ln.Add(cnode); if (cnode.IsFolder) { fids.Add(cnode); } else { eids.Add(cnode.NodeId); } } } var node = e.CurrentSelectedNodes[0].Data as DirectoryNode; if (node != null) { if (LabelDataTree.Equals(sender)) { if (Model.DirectoryPushed) { return; } ApplicationContext.LabelNodesSelected = ln; ApplicationContext.IsFromLabel = true; if (CheckEndpointNavigationClicked()) { if (e.CurrentSelectedNodes.Count == 1) { if (node.IsFolder) { var listResult = new List <ListLableEndpointResponse>(); foreach (var fid in fids) { var result = Model.GetEndpointByLabel(fid.NodeId, fid.Title); listResult.Add(result); } if (!PageNavigatorHelper.IsCurrent <EndPointListPage>()) { PageNavigatorHelper.Switch(new EndPointListPage()); } var viewModel = PageNavigatorHelper.GetMainContentViewModel <GroupViewModel>(); viewModel.SetParamsValueForLabel(listResult, eids); viewModel.GetLabelData(); } else { //dislay EndpointView page if (!PageNavigatorHelper.IsCurrent <EndPointViewPage>()) { PageNavigatorHelper.Switch(new EndPointViewPage()); } var viewModel = PageNavigatorHelper.GetMainContentViewModel <EndpointViewModel>(); viewModel.SetParams(node.NodeId); viewModel.ReloadData(); } } else { var listResult = new List <ListLableEndpointResponse>(); foreach (var fid in fids) { var result = Model.GetEndpointByLabel(fid.NodeId, fid.Title); listResult.Add(result); } if (!PageNavigatorHelper.IsCurrent <EndPointListPage>()) { PageNavigatorHelper.Switch(new EndPointListPage()); } var viewModel = PageNavigatorHelper.GetMainContentViewModel <GroupViewModel>(); viewModel.SetParamsValueForLabel(listResult, eids); viewModel.GetLabelData(); } } } else { if (!Model.DirectoryPushed) { return; } ApplicationContext.IsFromLabel = false; ApplicationContext.IsError = !node.IsFolder; ApplicationContext.NodeId = node.NodeId; //after add a note, select one node only if (ApplicationContext.IsAddNode) { var ns = new List <DirectoryNode>(); ns.Add(ln[0]); ln = ns; ApplicationContext.IsAddNode = false; if (CheckEndpointNavigationClicked()) { if (node.IsFolder) { //dislay GroupView page PageNavigatorHelper.Switch(new EndPointListPage()); var viewModel = PageNavigatorHelper.GetMainContentViewModel <GroupViewModel>(); var selectedFolderIds = new List <int>(); var selectedEndpointIds = new List <int>(); selectedFolderIds.Add(node.NodeId); viewModel.SetParamsValueForDirectory(selectedFolderIds, selectedEndpointIds, ApplicationContext.SearchText, true, node.Guid, node.Title); viewModel.EditOrAdd(); } else { //dislay EndpointView page PageNavigatorHelper.Switch(new EndPointViewPage()); var viewModel = PageNavigatorHelper.GetMainContentViewModel <EndpointViewModel>(); viewModel.SetParams(node.NodeId); viewModel.EditOrAdd(node.Title, true); } } } else if (ApplicationContext.IsEditNode) { var ns = new List <DirectoryNode>(); ns.Add(ln[0]); ln = ns; ApplicationContext.IsEditNode = false; if (CheckEndpointNavigationClicked()) { if (node.IsFolder) { //dislay GroupView page if (!PageNavigatorHelper.IsCurrent <EndPointListPage>()) { PageNavigatorHelper.Switch(new EndPointListPage()); } var viewModel = PageNavigatorHelper.GetMainContentViewModel <GroupViewModel>(); var selectedFolderIds = new List <int>(); var selectedEndpointIds = new List <int>(); selectedFolderIds.Add(node.NodeId); viewModel.SetParamsValueForDirectory(selectedFolderIds, selectedEndpointIds, ApplicationContext.SearchText, false, Guid.NewGuid(), ""); viewModel.EditOrAdd(); } else { //dislay EndpointView page if (!PageNavigatorHelper.IsCurrent <EndPointViewPage>()) { PageNavigatorHelper.Switch(new EndPointViewPage()); } var viewModel = PageNavigatorHelper.GetMainContentViewModel <EndpointViewModel>(); viewModel.SetParams(node.NodeId); viewModel.EditOrAdd(node.Title); } } } else { if (ApplicationContext.IsDeleteNode) { ApplicationContext.IsDeleteNode = false; } if (CheckEndpointNavigationClicked()) { if (e.CurrentSelectedNodes.Count == 1) { if (e.OriginalSelectedNodes.Count == 0) { if (node != null) { if (node.IsFolder) { ApplicationContext.NodesSelected = ln; var pageViewModel = PageNavigatorHelper.GetMainContentViewModel <PageViewModelBase>(); //if (pageViewModel != null && // pageViewModel.GetType() == typeof (ColorCodePageViewModel)) //{ // Model.GetBelowNode(node); // return; //} //if (pageViewModel != null && // pageViewModel.GetType() == typeof (AssignmentViewModel)) //{ // var assignmentVM = pageViewModel as AssignmentViewModel; // if (assignmentVM != null) // assignmentVM.GetRuleByFolder(); // Model.GetBelowNode(node); // return; //} if (pageViewModel != null && pageViewModel.GetType() == typeof(PolicyEnhancementPageViewModel)) { var assignmentVM = pageViewModel as PolicyEnhancementPageViewModel; if (assignmentVM != null) { assignmentVM.BuidPage(); } Model.GetBelowNode(node); return; } if (pageViewModel != null && pageViewModel.GetType() == typeof(TaskListViewModel)) { return; } //dislay GroupView page if (!PageNavigatorHelper.IsCurrent <EndPointListPage>()) { PageNavigatorHelper.Switch(new EndPointListPage()); } var viewModel = PageNavigatorHelper.GetMainContentViewModel <GroupViewModel>(); var selectedFolderIds = new List <int>(); var selectedEndpointIds = new List <int>(); selectedFolderIds.Add(node.NodeId); viewModel.SetParamsValueForDirectory(selectedFolderIds, selectedEndpointIds, ApplicationContext.SearchText, false, Guid.NewGuid(), ""); viewModel.GetData(); } else { if (PageNavigatorHelper.IsCurrent <PolicyEnhancementPage>()) { ApplicationContext.NodesSelected = ln; var pageVM = PageNavigatorHelper.GetMainContentViewModel <PolicyEnhancementPageViewModel>(); if (pageVM != null) { pageVM.BuidPage(); } Model.GetBelowNode(node); return; } else if (PageNavigatorHelper.IsCurrent <TaskListPage>()) { ApplicationContext.NodesSelected = ln; var pageVM = PageNavigatorHelper.GetMainContentViewModel <TaskListViewModel>(); if (pageVM != null) { pageVM.Refresh(); } return; } //dislay EndpointView page if (!PageNavigatorHelper.IsCurrent <EndPointViewPage>()) { PageNavigatorHelper.Switch(new EndPointViewPage()); } var viewModel = PageNavigatorHelper.GetMainContentViewModel <EndpointViewModel>(); viewModel.SetParams(node.NodeId); viewModel.ReloadData(); } } } else { var oriNote = e.OriginalSelectedNodes[0].Data as DirectoryNode; if (e.OriginalSelectedNodes.Count == 1 && oriNote.IsFolder == node.IsFolder && oriNote.NodeId == node.NodeId) { //doing nothing because re-selected itself } else { if (node != null) { if (node.IsFolder) { if (PageNavigatorHelper.IsCurrent <ColorCodePage>()) { var viewModel = PageNavigatorHelper .GetMainContentViewModel <ColorCodePageViewModel>(); viewModel.SetParams(node); viewModel.GetData(); } else if (PageNavigatorHelper.IsCurrent <DirectoryAssignmentPage>()) { ApplicationContext.NodesSelected = ln; var viewModel = PageNavigatorHelper .GetMainContentViewModel <AssignmentViewModel>(); viewModel.GetRuleByFolder(); } else if (PageNavigatorHelper.IsCurrent <PolicyEnhancementPage>()) { ApplicationContext.NodesSelected = ln; var viewModel = PageNavigatorHelper.GetMainContentViewModel <PolicyEnhancementPageViewModel>(); if (viewModel != null) { viewModel.BuidPage(); } } else if (PageNavigatorHelper.IsCurrent <TaskListPage>()) { ApplicationContext.NodesSelected = ln; var viewModel = PageNavigatorHelper.GetMainContentViewModel <TaskListViewModel>(); if (viewModel != null) { viewModel.Refresh(); } } //dislay GroupView page else { if (!PageNavigatorHelper.IsCurrent <EndPointListPage>()) { PageNavigatorHelper.Switch(new EndPointListPage()); } var viewModel = PageNavigatorHelper.GetMainContentViewModel <GroupViewModel>(); var selectedFolderIds = new List <int>(); var selectedEndpointIds = new List <int>(); selectedFolderIds.Add(node.NodeId); viewModel.SetParamsValueForDirectory(selectedFolderIds, selectedEndpointIds, ApplicationContext.SearchText, false, Guid.NewGuid(), ""); viewModel.GetData(); } } else { ApplicationContext.NodesSelected = ln; if (PageNavigatorHelper.IsCurrent <PolicyEnhancementPage>()) { var pageViewModel = PageNavigatorHelper.GetMainContentViewModel <PolicyEnhancementPageViewModel>(); if (pageViewModel != null) { pageViewModel.BuidPage(); } } else if (PageNavigatorHelper.IsCurrent <TaskListPage>()) { var taskListViewModel = PageNavigatorHelper.GetMainContentViewModel <PageViewModelBase>(); taskListViewModel.Refresh(); } else { //dislay EndpointView page if (!PageNavigatorHelper.IsCurrent <EndPointViewPage>()) { PageNavigatorHelper.Switch(new EndPointViewPage()); } var viewModel = PageNavigatorHelper.GetMainContentViewModel <EndpointViewModel>(); viewModel.SetParams(node.NodeId); viewModel.ReloadData(); } } } } } } else { if (PageNavigatorHelper.IsCurrent <PolicyEnhancementPage>()) { ApplicationContext.NodesSelected = ln; var pageViewModel = PageNavigatorHelper.GetMainContentViewModel <PolicyEnhancementPageViewModel>(); if (pageViewModel != null) { pageViewModel.BuidPage(); } return; } //dislay GroupView page if (!PageNavigatorHelper.IsCurrent <EndPointListPage>()) { PageNavigatorHelper.Switch(new EndPointListPage()); } var viewModel = PageNavigatorHelper.GetMainContentViewModel <GroupViewModel>(); viewModel.SetParamsValueForDirectory(fids.Select(r => r.NodeId).ToList(), eids, ApplicationContext.SearchText, false, Guid.NewGuid(), ""); viewModel.GetData(); } } else if (PageNavigatorHelper.IsCurrent <POCQuarantinePage>()) { var viewModel = PageNavigatorHelper.GetMainContentViewModel <POCQuarantineViewModel>(); if (e.CurrentSelectedNodes.Count == 1) { if (!node.IsFolder) { viewModel.RefreshQuarantineByComputerIds(new List <int> { node.NodeId }); } else { viewModel.RefreshQuarantineByFolder(node.NodeId); } } else { viewModel.RefreshByGroupEntities(fids.Select(r => r.NodeId).ToList(), eids); } } } ApplicationContext.NodesSelected = ln; Model.GetBelowNode(node); } } } }
public void ReloadData() { _view.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => { var basePage = PageNavigatorHelper.GetMainContentViewModel <PageViewModelBase>(); if (ApplicationContext.CanRefreshEndpoint) { switch (NavigationIndex) { case (int)NavigationIndexes.Endpoint: case (int)NavigationIndexes.Label: case (int)NavigationIndexes.Discovery: case (int)NavigationIndexes.NeighborhoodWatch: case (int)NavigationIndexes.LDAP: case (int)NavigationIndexes.Policy: case (int)NavigationIndexes.POCAgent: if (IsDirectory && ApplicationContext.NodesSelected == null) { //refresh tree data _view.RightTreeViewModel.UpdateTree(0, false, true); _view.RightTreeViewModel.LoadLabelView(true); } else if (IsDirectory && ApplicationContext.NodesSelected != null && ApplicationContext.NodesSelected.Count >= 0) { //refresh tree data _view.RightTreeViewModel.UpdateTree(ApplicationContext.NodesSelected, false, true); _view.RightTreeViewModel.LoadLabelView(true); } break; default: break; } //refresh neighborhood watch page if (basePage != null && (basePage.GetType() == typeof(NeighborhoodWatchViewModel) || basePage.GetType() == typeof(LDAPViewModel)) || PageNavigatorHelper.IsCurrent <EndPointListPage>()) { basePage.Refresh(); } } else if (ApplicationContext.CanRefreshDiscovery) { //refresh neighborhood watch page if (basePage != null && basePage.GetType() == typeof(NeighborhoodWatchViewModel)) { basePage.Refresh(); } } if (ApplicationContext.CanRefreshLDAP) { //refresh LDAP page if (basePage != null && basePage.GetType() == typeof(LDAPViewModel)) { basePage.Refresh(); } } if (ApplicationContext.CanRefreshSoftware) { if (basePage != null && basePage.GetType() == typeof(SoftwareViewModel)) { basePage.Refresh(); } else { Functions.GetAllSoftware(); Functions.GetAllUpdateSourceSoftware(); } } if (ApplicationContext.CanRefreshUpdateSource) { switch (NavigationIndex) { case (int)NavigationIndexes.Software: case (int)NavigationIndexes.Transfer: case (int)NavigationIndexes.Download: _view.RightTreeViewModel.BuilSoftwareTree(true); if (basePage != null && basePage.GetType() == typeof(TransferViewModel)) { basePage.Refresh(); } break; default: _view.RightTreeViewModel.RebuildUpdateSourceCache(); break; } } if (ApplicationContext.CanRefreshPolicyAgentDirectory) { Functions.LoadFolderPolicy(); Functions.LoadEndpointPolicy(); switch (NavigationIndex) { case (int)NavigationIndexes.POCAgent: _view.RightTreeViewModel.UpdateTree(ApplicationContext.NodesSelected, false, true); break; default: break; } } if (ApplicationContext.CanRefreshPolicyAgent) { if (basePage != null && basePage.GetType() == typeof(POCAgentViewModel)) { basePage.Refresh(); } else { Functions.GetAllPolicies(); } } if (ApplicationContext.CanRefreshTask) { if (basePage != null && basePage.GetType() == typeof(TaskListViewModel)) { basePage.Refresh(); } } })); }
/// <summary> /// Called when [tab selected]. /// </summary> /// <param name="btn">The BTN.</param> private void OnTabSelected(Button btn) { if (btn == null || ApplicationContext.NodesSelected == null || ApplicationContext.NodesSelected.Count == 0) { 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); } } switch (btn.Content.ToString()) { case UIConstant.ColorCodes: PageNavigatorHelper.Switch(new ColorCodePage(folders[0])); break; case UIConstant.Endpoints: var fids = folders.Select(e => e.NodeId).ToList(); var eids = endpoints.Select(e => e.NodeId).ToList(); if (!PageNavigatorHelper.IsCurrent <EndPointListPage>()) { PageNavigatorHelper.Switch(new EndPointListPage()); } var viewModel = PageNavigatorHelper.GetMainContentViewModel <GroupViewModel>(); viewModel.SetParamsValueForDirectory(fids, eids, ApplicationContext.SearchText, false, Guid.NewGuid(), ""); viewModel.GetData(); break; case UIConstant.DirectoryAssignment: if (!PageNavigatorHelper.IsCurrent <DirectoryAssignmentPage>()) { var assignmentPage = new DirectoryAssignmentPage(); PageNavigatorHelper.Switch(assignmentPage); } break; case UIConstant.TaskListPage: if (!PageNavigatorHelper.IsCurrent <TaskListPage>()) { var taskListPage = new TaskListPage(); PageNavigatorHelper.Switch(taskListPage); } break; case UIConstant.GroupPolicies: if (!PageNavigatorHelper.IsCurrent <PolicyEnhancementPage>()) { PageNavigatorHelper.Switch(new PolicyEnhancementPage()); } break; } }