示例#1
0
        /// <summary>
        ///     Get all discovery endpoints that its subnet mark is subnetMark
        /// </summary>
        /// <param name="subnetMark"></param>
        private List <NeighborhoodWatch> GetNeighborhoods(string subnetMark)
        {
            var requestObj = new StringAuthenticateObject
            {
                StringAuth  = "OK",
                StringValue = subnetMark
            };
            var resultDeserialize = ServiceManager.Invoke(sc => RequestResponseUtils.GetData <List <NeighborhoodWatch> >(
                                                              sc.GetAllNeighborhoodWatch,
                                                              requestObj));

            if (resultDeserialize == null)
            {
                PageNavigatorHelper._MainWindow.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
                                                                       (Action)(() =>
                {
                    var messageDialog =
                        PageNavigatorHelper._MainWindow.MessageDialogContentControl.Content as MessageDialog;
                    messageDialog.ShowMessageDialog("Data is null", "Message");
                }));
                return(new List <NeighborhoodWatch>());
            }

            return(resultDeserialize);
        }
示例#2
0
 private void OnPieChartRefresh(object sender, EventArgs e)
 {
     try
     {
         _timer.Stop();
         var dataRequest  = new StringAuthenticateObject("OK");
         var dataResponse =
             ServiceManager.Invoke(sc => RequestResponseUtils.GetData <LastUpdated>(sc.GetLastUpdateTaskProgress, dataRequest));
         if (dataResponse != null && dataResponse.LastSync > _lastSync)
         {
             //First load
             if (_lastSync == DateTime.MinValue)
             {
                 _lastSync = dataResponse.LastSync;
             }
             else
             {
                 _lastSync = dataResponse.LastSync;
                 RefreshAllPieChart();
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Error("OnPieChartRefresh Error", ex);
     }
     finally
     {
         _timer.Start();
     }
 }
示例#3
0
 public static void DeleteLabelCriteria(int lcid)
 {
     using (var sc = new POCServiceClient("NetTcpBinding_IPOCService"))
     {
         var request = new StringAuthenticateObject {
             StringValue = lcid.ToString(), StringAuth = "OK"
         };
         var datareq = EncryptionHelper.EncryptString(JsonConvert.SerializeObject(request),
                                                      Key);
         sc.DeleteLabelCriteria(datareq);
         ApplicationContext.IsRebuildTree = true;
     }
 }
示例#4
0
        private void MoveDiscoveryBk_DoWork(object sender, DoWorkEventArgs e)
        {
            var strAuth        = new StringAuthenticateObject();
            var xmlDataBuilder = new StringBuilder();

            xmlDataBuilder.Append("<DataSet>");
            var indexName = GetFolderIndexAdd();

            foreach (var neighborhood in _selectedData)
            {
                var nname = neighborhood.Computer;
                if (string.IsNullOrWhiteSpace(neighborhood.Computer))
                {
                    nname = "New Computer";
                    if (indexName >= 2)
                    {
                        nname += " (" + indexName + ")";
                        indexName++;
                    }
                }
                xmlDataBuilder.Append("<Endpont>");
                xmlDataBuilder.Append("<SystemName>" + nname + "</SystemName>");
                xmlDataBuilder.Append("<FolderId>" + ApplicationContext.NodeTargetId + "</FolderId>");
                xmlDataBuilder.Append("<MacAddress>" + neighborhood.MAC + "</MacAddress>");
                xmlDataBuilder.Append("</Endpont>");
            }
            xmlDataBuilder.Append("</DataSet>");
            strAuth.StringAuth  = "OK";
            strAuth.StringValue = xmlDataBuilder.ToString();
            using (var sc = new POCServiceClient("NetTcpBinding_IPOCService"))
            {
                var data     = JsonConvert.SerializeObject(strAuth);
                var result   = sc.AddNewEndpointsFromDiscovery(EncryptionHelper.EncryptString(data, KeyEncryption));
                var rsDeser  = JsonConvert.DeserializeObject <List <EndPointData> >(EncryptionHelper.DecryptRijndael(result, KeyEncryption));
                var listData = new List <EndPoint>();
                foreach (var ed in rsDeser)
                {
                    var enp = new EndPoint(ed);
                    listData.Add(enp);
                }
                var ec = ApplicationContext.EndPointListAll.Count;
                ApplicationContext.EndPointListTree.RemoveAll(r => r.FolderId == ApplicationContext.NodeTargetId);
                ApplicationContext.EndPointListTree.AddRange(listData);
                if (ec == ApplicationContext.EndPointListAll.Count)
                {
                    ApplicationContext.EndPointListAll.RemoveAll(r => r.FolderId == ApplicationContext.NodeTargetId);
                    ApplicationContext.EndPointListAll.AddRange(listData);
                }
            }
        }
示例#5
0
        private void ClearUnmanagedNeighborhoodDb(List <int> nids)
        {
            var nidsJoin = string.Join(",", nids);
            var strAuth  = new StringAuthenticateObject
            {
                StringAuth  = "OK",
                StringValue = nidsJoin
            };

            using (var sc = new POCServiceClient("NetTcpBinding_IPOCService"))
            {
                var data = JsonConvert.SerializeObject(strAuth);
                sc.DeleteNeighborhoodWatch(EncryptionHelper.EncryptString(data, KeyEncryption));
            }
        }
示例#6
0
        private void DeletePolicy()
        {
            var confirmDlg = new ConfirmDialog("Are you sure you want to delete these informations?", "Delete policy");

            if (confirmDlg.ShowDialog() == true)
            {
                if (ApplicationContext.PoliciesList != null)
                {
                    var listId = ApplicationContext.PoliciesList.Select(r => r.Id).ToList();

                    var requestObj = new StringAuthenticateObject
                    {
                        StringAuth  = "OK",
                        StringValue = string.Join(",", listId)
                    };
                    using (var sc = new POCServiceClient("NetTcpBinding_IPOCService"))
                    {
                        var requestData = EncryptionHelper.EncryptString(JsonConvert.SerializeObject(requestObj),
                                                                         KeyEncryption);
                        sc.DeletePolicy(requestData);
                    }

                    foreach (var policyElementViewModel in ApplicationContext.PoliciesList)
                    {
                        //policyElementViewModel.IsActived = true;
                        _view.PnlPolicyContainer.Children.Remove(policyElementViewModel._view);
                    }
                    ApplicationContext.POCAgentList.RemoveAll(
                        r => ApplicationContext.PoliciesList.Select(r2 => r2.Id).Contains(r.Id));
                    ApplicationContext.PoliciesList.Clear();

                    if (_view.PnlPolicyContainer.Children.Count > 0 && ApplicationContext.POCAgentList.Count > 0)
                    {
                        var item = ApplicationContext.POCAgentList.FirstOrDefault(i => i.Id == Id);
                        if (item == null)
                        {
                            Id = ApplicationContext.POCAgentList.FirstOrDefault().Id;
                            BuildPage();
                        }
                    }
                    else
                    {
                        BtnSaveVisible = false;
                    }
                }
            }
        }
示例#7
0
        public static void GetAllUpdateSourceSoftware()
        {
            var requestObj = new StringAuthenticateObject
            {
                StringAuth = "OK"
            };
            var resultDeserialize = ServiceManager.Invoke(sc => RequestResponseUtils.GetData <List <UpdateSourceSoftware> >(
                                                              sc.GetAllUpdateSourceSoftware,
                                                              requestObj));

            if (resultDeserialize == null)
            {
                ApplicationContext.UpdateSourceSoftwareList = new List <UpdateSourceSoftware>();
            }
            else
            {
                ApplicationContext.UpdateSourceSoftwareList = resultDeserialize;
            }
        }
 private TransferSchedule GetTransferSchedule()
 {
     try
     {
         var requestObj = new StringAuthenticateObject
         {
             StringAuth = "OK"
         };
         var resultDeserialize = ServiceManager.Invoke(sc => RequestResponseUtils.GetData <TransferSchedule>(
                                                           sc.GetTransferScheduling,
                                                           requestObj));
         return(resultDeserialize);
     }
     catch (Exception ex)
     {
         Logger.Error(ex.Message, ex);
         return(null);
     }
 }
示例#9
0
        public static void GetAllPolicies()
        {
            var requestObj = new StringAuthenticateObject
            {
                StringAuth = "OK"
            };
            var resultDeserialize = ServiceManager.Invoke(sc => RequestResponseUtils.GetData <List <POCAgent> >(
                                                              sc.GetAllPolicies,
                                                              requestObj));

            if (resultDeserialize == null)
            {
                ApplicationContext.POCAgentList = new List <POCAgent>();
            }
            else
            {
                ApplicationContext.POCAgentList = resultDeserialize;
            }
        }
示例#10
0
        public static void LoadEndpointPolicy()
        {
            var requestObj = new StringAuthenticateObject
            {
                StringAuth = "OK"
            };
            var resultDeserialize = ServiceManager.Invoke(sc => RequestResponseUtils.GetData <List <PolicyAssign> >(
                                                              sc.GetEndpointPolicies,
                                                              requestObj));

            if (resultDeserialize == null)
            {
                ApplicationContext.EndpointPolicyList = new List <PolicyAssign>();
            }
            else
            {
                ApplicationContext.EndpointPolicyList = resultDeserialize;
            }
        }
        private void DeleteBg_DoWork(object sender, DoWorkEventArgs e)
        {
            var ldapId = (int)e.Argument;

            _view.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() =>
            {
                using (var sc = new POCServiceClient("NetTcpBinding_IPOCService"))
                {
                    var stringAuth = new StringAuthenticateObject
                    {
                        StringAuth = "OK",
                        StringValue = ldapId.ToString()
                    };
                    var request = EncryptionHelper.EncryptString(JsonConvert.SerializeObject(stringAuth),
                                                                 KeyEncryption);
                    sc.DeleteLDAP(request);
                    DomainName = string.Empty;
                }
            }));
        }
        private void DeleteContent()
        {
            var selectedIds   = ViewList.Where(r => r.IsSelected).Select(r => r.Id).ToList();
            var filesToDelete = ViewList.Where(r => r.IsSelected).Select(r => r.Name).ToList();
            var requestObj    = new StringAuthenticateObject
            {
                StringAuth  = "OK",
                StringValue = string.Join(",", selectedIds)
            };

            using (var sc = new POCServiceClient("NetTcpBinding_IPOCService"))
            {
                var requestData = EncryptionHelper.EncryptString(JsonConvert.SerializeObject(requestObj),
                                                                 KeyEncryption);
                sc.DeleteContent(requestData);
            }
            ServiceManager.DeleteSoftwareFile(filesToDelete);
            ApplicationContext.SoftwareList.RemoveAll(r => selectedIds.Contains(r.Id));
            ApplicationContext.UpdateSourceSoftwareList.RemoveAll(r => selectedIds.Contains(r.SoftwareId));
            BuidPage();
        }
示例#13
0
        private LDAPDirectoriesEndpoints GetData()
        {
            var requestObj = new StringAuthenticateObject
            {
                StringAuth  = "OK",
                StringValue = Id.ToString()
            };
            var resultDeserialize = ServiceManager.Invoke(sc => RequestResponseUtils.GetData <LDAPDirectoriesEndpoints>(
                                                              sc.GetAllLDAPDirectoryEndpoint,
                                                              requestObj));

            if (resultDeserialize == null)
            {
                var messageDialog =
                    PageNavigatorHelper._MainWindow.MessageDialogContentControl.Content as MessageDialog;
                messageDialog.ShowMessageDialog("Data is null", "Message");

                return(new LDAPDirectoriesEndpoints());
            }

            return(resultDeserialize);
        }
 /// <summary>
 ///     Loads the label view.
 /// </summary>
 /// <param name="refresh">if set to <c>true</c> [refresh].</param>
 public void LoadLabelView(bool refresh = false)
 {
     if (refresh)
     {
         var authRequest = new StringAuthenticateObject {
             StringAuth = "OK", StringValue = "0"
         };
         var result =
             ServiceManager.Invoke(
                 sc =>
                 RequestResponseUtils.GetData <ListLableEndpointResponse>(sc.GetEndPointForLabel, authRequest));
         if (result != null)
         {
             ApplicationContext.LableEndpointDatas = result.Result.OrderBy(s => s.Name).ToList();
         }
         else
         {
             ApplicationContext.LableEndpointDatas = new List <LabelEndPointsData>();
         }
     }
     BuildLabelTree(ApplicationContext.LableEndpointDatas, ApplicationContext.LabelNodesSelected);
 }
示例#15
0
        private void OnLoadTask_Dowork(object sender, DoWorkEventArgs e)
        {
            try
            {
                //_page.Dispatcher.Invoke(delegate { TaskItemElements.Clear(); }, DispatcherPriority.Render);
                if (ApplicationContext.TaskSoftwareList == null)
                {
                    var softwareRequest = new StringAuthenticateObject
                    {
                        StringAuth = "OK"
                    };
                    ApplicationContext.TaskSoftwareList = ServiceManager.Invoke(sc => RequestResponseUtils.GetData <List <SoftwareContent> >(
                                                                                    sc.GetAllSoftwareForTask, softwareRequest
                                                                                    ));
                }
                var softwareSelectedRequest = new SoftwarePackageDataRequest
                {
                    Id       = ApplicationContext.NodesSelected[0].NodeId,
                    IsFolder = ApplicationContext.NodesSelected[0].IsFolder
                };
                var taskDataResponse =
                    ServiceManager.Invoke(
                        sc => RequestResponseUtils.GetData <TaskDataResponse>(sc.GetTaskAndSoftware, softwareSelectedRequest));

                _pocTasks = taskDataResponse.Result.PocTasks;
                ApplicationContext.TaskSoftwareSelectedList = taskDataResponse.Result.SoftwareTasks;
                if (ApplicationContext.TaskProgressDictionary == null)
                {
                    RefreshTaskProgressDictionary(taskDataResponse.Result.TaskProgressList);
                }
            }
            catch (Exception ex)
            {
                Logger.Error("Load Task Error: " + ex.Message, ex);
            }
        }
        private List <LDAP> GetLDAPs()
        {
            var requestObj = new StringAuthenticateObject
            {
                StringAuth = "OK"
            };
            var resultDeserialize = ServiceManager.Invoke(sc => RequestResponseUtils.GetData <List <LDAP> >(
                                                              sc.GetAllLDAP,
                                                              requestObj));

            if (resultDeserialize == null)
            {
                _view.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
                                             (Action)(() =>
                {
                    var messageDialog =
                        PageNavigatorHelper._MainWindow.MessageDialogContentControl.Content as MessageDialog;
                    messageDialog.ShowMessageDialog("Data is null", "Message");
                }));
                return(new List <LDAP>());
            }

            return(resultDeserialize);
        }
示例#17
0
        private void OnSyncNowCommand(object arg)
        {
            using (var sc = new POCServiceClient("NetTcpBinding_IPOCService"))
            {
                var fids    = new List <int>();
                var eids    = new List <int>();
                var endplst = new List <EndPoint>();
                var rightVm = PageNavigatorHelper.GetRightElementViewModel();
                if (rightVm.DirectoryPushed)
                {
                    //Select all endpoint in selected folders and selected endpoints
                    foreach (var cnode in ApplicationContext.NodesSelected)
                    {
                        if (cnode != null)
                        {
                            if (cnode.IsFolder)
                            {
                                fids.Add(cnode.NodeId);
                            }
                            else
                            {
                                eids.Add(cnode.NodeId);
                            }
                        }
                    }

                    foreach (var fid in fids)
                    {
                        GetAllEndpointOfFolder(endplst, fid);
                    }
                    foreach (var eid in eids)
                    {
                        var endpoint = ApplicationContext.EndPointListAll.Find(e => e.EndpointId == eid);
                        if (!endplst.Select(ep => ep.EndpointId).Contains(endpoint.EndpointId))
                        {
                            endplst.Add(endpoint);
                        }
                    }
                }
                else
                {
                    //Select all endpoint in selected labels and selected endpoints
                    foreach (var cnode in ApplicationContext.LabelNodesSelected)
                    {
                        if (cnode != null)
                        {
                            if (cnode.IsFolder)
                            {
                                fids.Add(cnode.NodeId);
                            }
                            else
                            {
                                eids.Add(cnode.NodeId);
                            }
                        }
                    }
                    var endpointDatas = new List <LabelEndPointsData>();
                    foreach (var id in fids)
                    {
                        var listEndpoints = ApplicationContext.LableEndpointDatas.Where(r => r.Id == id).ToList();
                        endpointDatas.AddRange(listEndpoints);
                    }
                    foreach (var le in endpointDatas)
                    {
                        foreach (var en in le.EndPointDatas)
                        {
                            if (!endplst.Select(r => r.EndpointId).Contains(en.EndpointId))
                            {
                                var endpoint = new EndPoint(en);
                                endplst.Add(endpoint);
                            }
                        }
                    }
                    foreach (var eid in eids)
                    {
                        var endpoint = ApplicationContext.EndPointListAll.Find(e => e.EndpointId == eid);
                        if (!endplst.Select(ep => ep.EndpointId).Contains(endpoint.EndpointId))
                        {
                            endplst.Add(endpoint);
                        }
                    }
                }
                if (endplst.Count == 0)
                {
                    var messageDialog =
                        PageNavigatorHelper._MainWindow.MessageDialogContentControl.Content as MessageDialog;
                    messageDialog.ShowMessageDialog("You must select at least one Endpoint to sync", "Sync Action");
                    return;
                }
                var requestObj = new StringAuthenticateObject
                {
                    StringAuth  = "OK",
                    StringValue = string.Join(",", endplst.Select(r => r.EndpointId).ToList())
                };
                var requestData = EncryptionHelper.EncryptString(JsonConvert.SerializeObject(requestObj), KeyEncryption);

                try
                {
                    sc.SyncNow(requestData);
                }
                catch (Exception ex)
                {
                }
            }
        }
示例#18
0
        private void TransferNow_OnDoWork(object sender, DoWorkEventArgs e)
        {
            var usvm = e.Argument as UpdateSourceElementViewModel;

            if (usvm != null)
            {
                usvm.CurrentSize = 0;
                var totalSize =
                    ServiceManager.TransferToServerAgent(new TransferToAgentDataRequest
                {
                    SourceUrl      = usvm.UpdateSourceUrl,
                    UpdateSourceId = usvm.Id
                });
                usvm.TotalSize       = (int)totalSize;
                usvm.ProgressVisible = true;
                var aTimer = new Timer();
                aTimer.Elapsed += delegate
                {
                    if (usvm.CurrentSize < usvm.TotalSize - CalculateSizeOnTenPercent(usvm.TotalSize))
                    {
                        usvm.CurrentSize += 1;
                    }
                };
                aTimer.Interval = 1000;
                aTimer.Enabled  = true;

                var timeOut = 60 * 10000; //10 minutes
                while (true)
                {
                    var dataRequest = new StringAuthenticateObject
                    {
                        StringAuth  = "OK",
                        StringValue = usvm.Id.ToString()
                    };
                    var dataResponse =
                        ServiceManager.Invoke(
                            sc => RequestResponseUtils.GetData <TransferDataResponse>(sc.GetTransferStatus, dataRequest));
                    //Break when unable execute transfer to Agent
                    if (dataResponse.FileSize < 0)
                    {
                        ErrorMessageList.AddRange(dataResponse.ErrorMessage.Select(c => string.Format("[{0}]: {1}", usvm.UpdateSourceName, c)));

                        usvm.CurrentSize     = 0;
                        usvm.ProgressVisible = false;
                        aTimer.Enabled       = false;
                        aTimer.Stop();
                        e.Result = null;
                        break;
                    }
                    if (timeOut == 0 || totalSize == dataResponse.FileSize)
                    {
                        //Timeout or transfer complete
                        aTimer.Enabled = false;
                        aTimer.Stop();
                        e.Result = usvm;
                        break;
                    }
                    Thread.Sleep(1000);
                    timeOut -= 1000;
                }
            }
        }
        /// <summary>
        ///     Searches the action.
        /// </summary>
        /// <param name="pars">The pars.</param>
        private void SearchAction(object pars)
        {
            _view.BackButton.Visibility = System.Windows.Visibility.Visible;
            if (DirectoryPushed)
            {
                if (!ApplicationContext.DirSearched)
                {
                    ApplicationContext.DirExpandedNodesBeforeSearch = new List <int>();
                    foreach (var id in ApplicationContext.ExpandedIds)
                    {
                        ApplicationContext.DirExpandedNodesBeforeSearch.Add(id);
                    }
                    ApplicationContext.DirNodesSelectedBeforeSearch = new List <DirectoryNode>();
                    foreach (var ns in ApplicationContext.NodesSelected)
                    {
                        ApplicationContext.DirNodesSelectedBeforeSearch.Add(ns);
                    }

                    ApplicationContext.DirectoryTreeSourceBeforeSearch = new ObservableCollection <DirectoryNode>();
                    foreach (var ds in _view.DataTree.ItemsSource as ObservableCollection <DirectoryNode> )
                    {
                        ApplicationContext.DirectoryTreeSourceBeforeSearch.Add(ds);
                    }
                }
                //search for directory
                _view.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
                                             (Action)(() => { MakeTree(0, true, SearchText); }));

                SetNodeExpandedState(_view.DataTree.Nodes, true);
                ApplicationContext.DirSearched = true;
            }
            else
            {
                if (!ApplicationContext.LabelSearched)
                {
                    ApplicationContext.LabelExpandedNodesBeforeSearch = new List <int>();
                    foreach (var ns in ApplicationContext.LabelExpandedIds)
                    {
                        ApplicationContext.LabelExpandedNodesBeforeSearch.Add(ns);
                    }
                    ApplicationContext.LabelNodesSelectedBeforeSearch = new List <DirectoryNode>();
                    foreach (var ns in ApplicationContext.LabelNodesSelected)
                    {
                        ApplicationContext.LabelNodesSelectedBeforeSearch.Add(ns);
                    }
                    ApplicationContext.LabelTreeSourceBeforeSearch = new List <DirectoryNode>();
                    foreach (var ns in _view.LabelDataTree.ItemsSource as List <DirectoryNode> )
                    {
                        ApplicationContext.LabelTreeSourceBeforeSearch.Add(ns);
                    }
                    ApplicationContext.LableEndpointDatasBeforeSearch = new List <LabelEndPointsData>();
                    foreach (var ns in ApplicationContext.LableEndpointDatas ?? new List <LabelEndPointsData>())
                    {
                        ApplicationContext.LableEndpointDatasBeforeSearch.Add(ns);
                    }
                }
                //search for label
                var authRequest = new StringAuthenticateObject
                {
                    StringAuth  = "OK",
                    StringValue = SearchText
                };

                var result =
                    ServiceManager.Invoke(
                        sc =>
                        RequestResponseUtils.GetData <ListLableEndpointResponse>(sc.SearchEndPointForLabel,
                                                                                 authRequest));
                result.Result = result.Result.OrderBy(s => s.Name).ToList();
                ApplicationContext.LableEndpointDatas = result.Result;
                ApplicationContext.LabelExpandedIds   = (result
                                                         .Result.Select(le => le.Id)).ToList();
                BuildLabelTree(result.Result);
                ApplicationContext.LabelSearched = true;
            }
        }