Example #1
0
        public bool SendCommandToUI(BeSafePipeCommand command)
        {
            try
            {
                _serverPipe.PushMessage(command);
                return(true);
            }
            catch (Exception ex)
            {
                ex.Log();
            }

            return(false);
        }
Example #2
0
        public bool SendCommandToService(BeSafePipeCommand command)
        {
            try
            {
                command.ConfigFilePath = PathUtils.ConfigFilePath;
                pipeClient.PushMessage(command);
                return(true);
            }
            catch (Exception ex)
            {
                ex.Log();
            }

            return(false);
        }
Example #3
0
        private void OnServerCommandReceived(NamedPipeConnection <BeSafePipeCommand, BeSafePipeCommand> connection, BeSafePipeCommand command)
        {
            switch (command.Command)
            {
            case PipeCommands.Notification:
                MessageBox.Show(command.Notification, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;

            case PipeCommands.PluginScanResult:
            {
                PluginResult pResult = command.PluginScanResult;

                notifyIcon.Tag = pResult;
                ToolTipIcon icon    = command.PluginScanResult.RiskRate == ThreatRiskRates.HighRisk ? ToolTipIcon.Error : ToolTipIcon.Warning;
                string      message = $"{pResult.PluginInfo.Name}{Environment.NewLine}{pResult.Message}";
                notifyIcon.ShowBalloonTip(3000, Resources.ApplicationName, message, icon);
            }
            break;
            }
        }
Example #4
0
        private void OnClientCommandReceived(NamedPipeConnection <BeSafePipeCommand, BeSafePipeCommand> connection, BeSafePipeCommand command)
        {
            try
            {
                switch (command.Command)
                {
                case PipeCommands.ComponentConfiguration:
                {
                    bool sotreSettingResult = new ServiceSetting().StoreConfigFilePath(command.ConfigFilePath);
                    if (sotreSettingResult)
                    {
                        ConfigApplier();
                    }
                }
                break;

                case PipeCommands.ReloadPlugins:
                {
                }
                break;

                case PipeCommands.Notification:
                {
                }
                break;
                }
            }
            catch (Exception ex)
            {
                ex.Log();
            }
        }