public void LoadData(List <BackgroundWorker> workers) { //Load data var loadDataBg = new BackgroundWorker(); loadDataBg.DoWork += LoadDataBg_DoWork; workers.Add(loadDataBg); loadDataBg.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args) { IsLoading = false; ReCountComputer(); BackgroundWorker wk = (BackgroundWorker)s; workers.Remove(wk); if (workers.Count == 0) { var ldapViewModel = PageNavigatorHelper.GetMainContentViewModel <LDAPViewModel>(); //Handle error when switch page, backgroundworker does not auto stop if (ApplicationContext.LDAPActived != null && ldapViewModel != null) { ldapViewModel.BuildLDAPTree(ApplicationContext.LDAPActived); } } }; loadDataBg.RunWorkerAsync(); }
public void OnActiveChanged() { var policyVm = PageNavigatorHelper.GetMainContentViewModel <POCAgentViewModel>(); if (policyVm != null) { policyVm.Id = Id; policyVm.Name = Name; policyVm.PolicyColor = ExpanderBackgroundColor; var pocAgent = ApplicationContext.POCAgentList.Find(r => r.Id == Id); if (pocAgent != null) { policyVm.POCServer = pocAgent.POCServer; policyVm.Key = pocAgent.Key; policyVm.Port = pocAgent.Port; policyVm.NeighborhoodWatch = pocAgent.NeighborhoodWatch; policyVm.TransferInterval = pocAgent.TransferInterval; policyVm.SynchronizationInterval = pocAgent.SyncInterval; policyVm.ActiveTransfer = pocAgent.ActiveTransfer; policyVm.UpdateSource = pocAgent.UpdateSource; policyVm.pocServerOrigin = pocAgent.POCServer; policyVm.keyOrigin = pocAgent.Key; policyVm.portOrigin = pocAgent.Port; } } }
private void FilterBk_DoWork(object sender, DoWorkEventArgs e) { _view.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => { if (IsActived) { var ldapViewModel = PageNavigatorHelper.GetMainContentViewModel <LDAPViewModel>(); if (ldapViewModel != null) { var ldap = new LDAP { Type = LDAPTypeStore, Domain = DomainName, Server = Server, User = User, Port = Port, IsSecureLDAP = IsSecure, Password = Password, SyncInterval = SyncInterval, ShowEndpoints = IsShowEndpoints, ShowFolders = IsShowFolders, Id = Id, HideManagedEndpoints = IsHideManagedEndPoints, HideEmptyFolders = IsHideEmptyFolders }; ReCountComputer(); ldapViewModel.BuildLDAPTree(ldap); } } })); }
private void OnMoveCommand(object args) { if (_selectedData.Any(neighborhood => ApplicationContext.EndPointListAll.Find(r => r.MACAddress == neighborhood.MAC) != null)) { _view.HideWindow(); var messageDialog = PageNavigatorHelper._MainWindow.MessageDialogContentControl.Content as MessageDialog; messageDialog.ShowMessageDialog( "Cannot move, have some Endpoints are existed", "Message"); return; } var moveDiscoveryBk = new BackgroundWorker(); moveDiscoveryBk.DoWork += MoveDiscoveryBk_DoWork; moveDiscoveryBk.RunWorkerCompleted += MoveDiscoveryBk_RunWorkerCompleted; moveDiscoveryBk.RunWorkerAsync(); foreach (var neighborhood in _selectedData) { ApplicationContext.AllNeighborhoodWatch.Find(r => r.Id == neighborhood.Id).Managed = true; } var neighborhoodVm = PageNavigatorHelper.GetMainContentViewModel <NeighborhoodWatchViewModel>(); if (neighborhoodVm != null) { neighborhoodVm.OnTabSelected(); } _view.HideWindow(); }
private void TxtModelCriteria_LostFocus(object sender, RoutedEventArgs e) { if (currentText != TxtModelCriteria.Text) { PageNavigatorHelper.GetMainContentViewModel <LabelViewModel>().OnSaveLabel(null); currentText = TxtModelCriteria.Text; } }
private void SaveBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { _view.Dispatcher.Invoke(DispatcherPriority.Render, (Action)(() => { var listPolicyAssign = e.Argument as List <PolicyAssign>; var pocAgentVm = PageNavigatorHelper.GetMainContentViewModel <POCAgentViewModel>(); pocAgentVm.AssignPolicy(listPolicyAssign); })); }
private void TxtIPv4Criteria2_LostFocus(object sender, RoutedEventArgs e) { if (currentText2 != TxtIPv4Criteria2.Text) { Model.TxtIPv4Criteria2 = TxtIPv4Criteria2.Text; PageNavigatorHelper.GetMainContentViewModel <LabelViewModel>().OnSaveLabel(null); currentText2 = TxtIPv4Criteria2.Text; } }
private void OnExecuteDeleteRule(object obj) { var directoryAssignment = PageNavigatorHelper.GetMainContentViewModel <AssignmentViewModel>(); if (directoryAssignment != null) { directoryAssignment.DeleteRuleCommand.Execute(null); } //_view.AssignmentCtxMenu.IsOpen = false; }
private void OnExecuteAddTask(object obj) { //Execute TaskListViewModel.AddTaskCommand var taskListViewModel = PageNavigatorHelper.GetMainContentViewModel <TaskListViewModel>(); if (taskListViewModel != null) { taskListViewModel.AddTaskCommand.Execute(null); } _view.TaskCtxMenu.IsOpen = false; }
private void OnShowLDAPCommand(object arg) { var ldapViewModel = PageNavigatorHelper.GetMainContentViewModel <LDAPViewModel>(); if (ldapViewModel != null) { ApplicationContext.LDAPActived = new LDAP { Id = Id, Domain = DomainName, ShowEndpoints = IsShowEndpoints, ShowFolders = IsShowFolders, HideEmptyFolders = IsHideEmptyFolders, HideManagedEndpoints = IsHideManagedEndPoints }; ldapViewModel.BuildLDAPTree(ApplicationContext.LDAPActived); } }
private void ActiveCurrentExpander() { var taskListViewModel = PageNavigatorHelper.GetMainContentViewModel <TaskListViewModel>(); if (taskListViewModel != null) { foreach (var taskItemElement in taskListViewModel.TaskItemElements) { taskItemElement.Model.IsActived = false; } } Model.IsActived = true; }
/// <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; } }
private void UpdateRule(string name) { if (name.Length > 200) { var messageDialog = PageNavigatorHelper._MainWindow.MessageDialogContentControl.Content as MessageDialog; messageDialog.ShowMessageDialog("Rule name cannot more than 200 letters", "Message"); return; } if (Model.IsActived) { var pocAgentVm = PageNavigatorHelper.GetMainContentViewModel <POCAgentViewModel>(); if (pocAgentVm != null) { pocAgentVm.Name = name; pocAgentVm.SavePolicyCommand.Execute(null); } } _headerExpanderOrg = name; }
private void ExecuteDelete(object obj) { try { if (DialogHelper.Confirm("Are you sure you want to delete selected task?", "Confirm Delete Task")) { var dataRequest = new DataRequest(Id); ServiceManager.Invoke(sc => sc.DeleteTask(RequestResponseUtils.SendData(dataRequest))); var taskListViewModel = PageNavigatorHelper.GetMainContentViewModel <TaskListViewModel>(); if (taskListViewModel != null) { taskListViewModel.RemoveTask(this); } } } catch (Exception ex) { Logger.Error("Delete Task Error: " + ex.Message, ex); } }
private bool CheckScreenWithoutRefresh() { var childViewModel = PageNavigatorHelper.GetMainContentViewModel <ViewModelBase>(); if (childViewModel != null && ApplicationContext.IsReloadForRefresh) { #region Screen without refresh function if (childViewModel.GetType() == typeof(LabelViewModel) || (childViewModel.GetType() == typeof(ImportFilePageViewModel)) || (childViewModel.GetType() == typeof(NeighborhoodWatchViewModel))) { //don't refresh labels screen ApplicationContext.IsReloadForRefresh = false; return(true); } #endregion } ApplicationContext.IsReloadForRefresh = false; return(false); }
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(); })); }
private void CbIPv4Opes_DropDownClosed(object sender, System.EventArgs e) { PageNavigatorHelper.GetMainContentViewModel <LabelViewModel>().OnSaveLabel(null); }
/// <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; } }
/// <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); } } } }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { PageNavigatorHelper.GetMainContentViewModel <LabelViewModel>().OnSaveLabel(null); }
//private bool CanExecuteCommand(object pars) //{ // return !IsBusy; //} //public bool IsBusy //{ // get { return _isBusy; } // set // { // _isBusy = value; // OnPropertyChanged("IsBusy"); // } //} //private void OnDeleteLabel(object pars) //{ // try // { // var labelCris = _view.PnlLabelContainer.Children; // var lbids = new List<int>(); // foreach (var ex in labelCris) // { // if (ex.GetType() == typeof(LabelCriteriaElement)) // { // var expander = (ex as LabelCriteriaElement).Expander; // var chbheader = expander.FindChild<CheckBox>("CbExpandHeader"); // if (chbheader != null && chbheader.IsChecked == true) // { // lbids.Add(((ex as LabelCriteriaElement).DataContext as LabelCriteriaViewModel).LabelId); // } // } // } // if (lbids.Count == 0) // { // var messageDialog = // PageNavigatorHelper._MainWindow.MessageDialogContentControl.Content as MessageDialog; // messageDialog.ShowMessageDialog("please select at least a label to delete", "Delete Label"); // } // else // { // var confirmdialog = new ConfirmDialog(); // confirmdialog.ConfirmText.Text = "Are you sure you want to delete selected labels?"; // confirmdialog.BtnOk.Focus(); // if (confirmdialog.ShowDialog() == true) // { // Logger.Info("Starting delete label"); // using (var sc = new POCServiceClient("NetTcpBinding_IPOCService")) // { // var request = EncryptionHelper.EncryptString(JsonConvert.SerializeObject(lbids), // KeyEncryption); // var result = sc.DeleteLabel(request); // var resultDeserialize = // JsonConvert.DeserializeObject<LabelCriteriaEndpointList>( // EncryptionHelper.DecryptRijndael(result, // KeyEncryption)); // if (resultDeserialize == null) // { // var messageDialog = // PageNavigatorHelper._MainWindow.MessageDialogContentControl.Content as MessageDialog; // messageDialog.ShowMessageDialog("Data is null", "Get label data"); // } // BuildLabelPage(resultDeserialize); // //Reload LabelFilterViewModel // foreach (var lid in lbids) // { // if (ApplicationContext.LabelNodesSelected.Select(l => l.NodeId).Contains(lid)) // { // ApplicationContext.LabelNodesSelected.Remove( // ApplicationContext.LabelNodesSelected.Find(r => r.NodeId == lid)); // } // } // ApplicationContext.IsRebuildTree = true; // RightTreeViewModel.LoadLabelView(true); // } // Logger.Info("Ended delete label"); // } // } // } // catch (Exception ex) // { // Logger.Error(ex); // var messageDialog = // PageNavigatorHelper._MainWindow.MessageDialogContentControl.Content as MessageDialog; // messageDialog.ShowMessageDialog( // "Cannot delete label due to exception occured, please see the log file under the Logs for more information", // "Delete label"); // } //} private void OnDeleteLabel(object arg) { var assignmentViewModel = PageNavigatorHelper.GetMainContentViewModel <LabelViewModel>(); assignmentViewModel.OnDeleteLabel(LabelId); }
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(); } } })); }
private void Worker_DoWork(object sender, DoWorkEventArgs e) { try { var dir = e.Argument as LDAPDirectory; if (dir != null) { var ldap = new LDAP { Type = LDAPTypeStore, Domain = DomainName, Server = Server, User = User, Port = Port, IsSecureLDAP = IsSecure, Password = Password, SyncInterval = SyncInterval, ShowEndpoints = IsShowEndpoints, ShowFolders = IsShowFolders, Id = Id, HideManagedEndpoints = IsHideManagedEndPoints, HideEmptyFolders = IsHideEmptyFolders, DistinguishedName = dir.DistinguishedName }; var resultDeserialize = ServiceManager.Invoke(sc => RequestResponseUtils.GetData <LDAPDirectoriesEndpoints>( sc.GetLDAPByDistinguishedName, ldap)); if (resultDeserialize != null) { if (!ApplicationContext.LdapDirectoriesEndpointsDictionary.ContainsKey(Id)) { var addValue = new LDAPDirectoriesEndpoints(); ApplicationContext.LdapDirectoriesEndpointsDictionary.AddOrUpdate(Id, addValue, (key, oldValue) => addValue); } ApplicationContext.LdapDirectoriesEndpointsDictionary[Id].Directories.AddRange(resultDeserialize.Directories); ApplicationContext.LdapDirectoriesEndpointsDictionary[Id].Endpoints.AddRange(resultDeserialize.Endpoints); _view.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => { if (IsActived) { var ldapViewModel = PageNavigatorHelper.GetMainContentViewModel <LDAPViewModel>(); if (ldapViewModel != null) { var ldapData = new LDAP { Type = LDAPTypeStore, Domain = DomainName, Server = Server, User = User, Port = Port, IsSecureLDAP = IsSecure, Password = Password, SyncInterval = SyncInterval, ShowEndpoints = IsShowEndpoints, ShowFolders = IsShowFolders, Id = Id, HideManagedEndpoints = IsHideManagedEndPoints, HideEmptyFolders = IsHideEmptyFolders }; ldapViewModel.BuildLDAPTree(ldapData); } } })); } } } catch (Exception) { ApplicationContext.IsBusy = false; } }
private void SyncDataBk_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (!ApplicationContext.LdapDirectoriesEndpointsDictionary.ContainsKey(Id)) { var addValue = new LDAPDirectoriesEndpoints(); ApplicationContext.LdapDirectoriesEndpointsDictionary.AddOrUpdate(Id, addValue, (key, oldValue) => addValue); } ApplicationContext.LdapDirectoriesEndpointsDictionary[Id].Directories = _ldapDirectories; ApplicationContext.LdapDirectoriesEndpointsDictionary[Id].Endpoints = new List <LDAPEndpoint>(); var ldapViewModel = PageNavigatorHelper.GetMainContentViewModel <LDAPViewModel>(); if (IsActived) { if (ldapViewModel != null) { var ldap = new LDAP { Type = LDAPTypeStore, Domain = DomainName, Server = Server, User = User, Port = Port, IsSecureLDAP = IsSecure, Password = Password, SyncInterval = SyncInterval, ShowEndpoints = IsShowEndpoints, ShowFolders = IsShowFolders, Id = Id, HideManagedEndpoints = IsHideManagedEndPoints, HideEmptyFolders = IsHideEmptyFolders }; ldapViewModel.BuildLDAPTree(ldap); } } if (_ldapDirectories == null || (_ldapDirectories != null && !_ldapDirectories.Any())) { IsLoading = false; ComputerCount = 0; ApplicationContext.IsBusy = false; } List <BackgroundWorker> workers = new List <BackgroundWorker>(); foreach (var dir in _ldapDirectories) { if (dir.FolderName != DomainName) { var worker = new BackgroundWorker(); worker.DoWork += Worker_DoWork; workers.Add(worker); worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args) { BackgroundWorker wk = (BackgroundWorker)s; workers.Remove(wk); if (workers.Count == 0) { IsLoading = false; ComputerCount = ApplicationContext.LdapDirectoriesEndpointsDictionary.ContainsKey(Id)? ApplicationContext.LdapDirectoriesEndpointsDictionary[Id].Endpoints.Count:0; ldapViewModel.Refresh(); ApplicationContext.IsBusy = false; } }; worker.RunWorkerAsync(dir); } } }