/// <summary> /// Initializes a new instance of the <see cref="BotInstance"/> class. /// </summary> /// <param name="settings">The settings.</param> public BotInstance(InstanceSettings settings) { Settings = settings; Connection = new TeamSpeakConnection(this); Repository = new DataRepository(Connection, Settings); ManagerFactory = new ManagerFactory(Repository); }
public async Task GetMaxUsersNumberAsync_NoWarmUp_Test() { #region Stubs var settings = new InstanceSettings { MaxUsersCapacity = 1000 }; #endregion #region Mocks var twitterUserDalMock = new Mock <ITwitterUserDal>(MockBehavior.Strict); twitterUserDalMock .Setup(x => x.GetTwitterUsersCountAsync()) .ReturnsAsync(249); #endregion var provider = new MaxUsersNumberProvider(settings, twitterUserDalMock.Object); var result = await provider.GetMaxUsersNumberAsync(); Assert.AreEqual(1000, result); #region Validations twitterUserDalMock.VerifyAll(); #endregion }
public WellKnownController(InstanceSettings settings, ITwitterUserService twitterUserService, ITwitterUserDal twitterUserDal, IModerationRepository moderationRepository) { _twitterUserService = twitterUserService; _twitterUserDal = twitterUserDal; _moderationRepository = moderationRepository; _settings = settings; }
public DebugingController(InstanceSettings instanceSettings, ICryptoService cryptoService, IActivityPubService activityPubService, IUserService userService) { _instanceSettings = instanceSettings; _cryptoService = cryptoService; _activityPubService = activityPubService; _userService = userService; }
public void WelcomeStep3Done_ConnectAdapter() { if (ApplicationSettings.GetInstance().EmulationMode == EmulationConstants.ONLY_VIGEM || ApplicationSettings.GetInstance().EmulationMode == EmulationConstants.VIGEM_AND_PROCESS_INJECTION) { VigemManager.Start(); } RefreshRemotePlayProcess(); ApplicationSettings.Save(); InstanceSettings.GetInstance().EnableMouseInput = true; simpleConfigPage = new SimpleConfigPage(); advancedMappingsPage = new AdvancedMappingsPage(); MouseAdvancedConfigPage mouseAdvancedConfigPage = new MouseAdvancedConfigPage(); MiscellaneousSettingsPage miscellaneousSettingsPage = new MiscellaneousSettingsPage(); AddTab("Simple Config", simpleConfigPage); AddTab("Advanced mappings", advancedMappingsPage); AddTab("Mouse Advanced Config", mouseAdvancedConfigPage); AddTab("Miscellaneous Settings", miscellaneousSettingsPage); // remove the welcome tab tabs.Items.RemoveAt(0); // Refresh to ensure advancedMappingsPage isnt blank advancedMappingsPage.RefreshButtonContents(); }
private void RefreshRemotePlayProcess() { if (InstanceSettings.GetInstance().GetRemotePlayProcess() != null) { InstanceSettings.GetInstance().GetRemotePlayProcess().Refresh(); } }
private void Handler_RemotePlayVolumeChange(object sender, EventArgs e) { if (InstanceSettings.GetInstance().GetRemotePlayProcess() != null) { AudioManager.SetApplicationVolume(InstanceSettings.GetInstance().GetRemotePlayProcess().Id, UserSettings.GetInstance().RemotePlayVolume); } }
/// <summary> /// Gets the <see cref="TS3_Bot.Core.BotInstance"/> with the specified id. /// </summary> /// <param name="setting">the settings</param> /// <value>The bot instance.</value> public BotInstance this[InstanceSettings setting] { get { return(bots.FirstOrDefault(bot => bot.Settings.Id == setting.Id)); } }
public ActivityPubService(ICryptoService cryptoService, InstanceSettings instanceSettings, IHttpClientFactory httpClientFactory, ILogger <ActivityPubService> logger) { _cryptoService = cryptoService; _instanceSettings = instanceSettings; _httpClientFactory = httpClientFactory; _logger = logger; }
private void Handle_LogLevelChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (Combo_LogLevel.SelectedValue != null) { ComboBoxItem selectedItem = (ComboBoxItem)Combo_LogLevel.SelectedItem; if (selectedItem.Tag != null) { string tag = selectedItem.Tag.ToString(); int value = Int32.Parse(tag); LogManager logManager = InstanceSettings.GetInstance().GetLogManager(); if (INDEX_LOG_DEFAULT == value) { logManager.SetLoggingLevel(LogEventLevel.Information); } else if (INDEX_LOG_DEBUG == value) { logManager.SetLoggingLevel(LogEventLevel.Debug); } else if (INDEX_LOG_VERBOSE == value) { logManager.SetLoggingLevel(LogEventLevel.Verbose); } } } }
protected override void OnStart(string[] args) { try { //System.Diagnostics.Debugger.Launch(); InstanceSettings InstanceInfo = new InstanceSettings(); InstanceInfo = InstanceInfo.GetInstanceSettings(); System.Timers.Timer ServiceTimer = new Timer((InstanceInfo.PollingInterval * 60000) /*1800000 300000*/); ServiceTimer.AutoReset = true; ServiceTimer.Elapsed += CheckMail; ServiceTimer.Enabled = true; //ServiceTimer.Start();//ServiceTimer.Enabled = true; ServiceTimer.Start(); GC.KeepAlive(ServiceTimer); // write an entry to the log eventLog1.WriteEntry("Operation - V1 Request Asset Creator Service Started"); } catch (Exception e) { eventLog1.WriteEntry("ERROR - OnStart - " + e.InnerException.Message); } }
public static void Start() { Log.Information("VigemManager.Start"); try { //TODO test that if we dont have vigem bus driver installed does the error still get propegated System.Threading.Thread.Sleep(1000); VigemInternals vig = new VigemInternals(); InstanceSettings.GetInstance().SetVigemInternals(vig); vig.StartAndListen(); } catch (Nefarius.ViGEm.Client.Exceptions.VigemBusNotFoundException e) { ExceptionLogger.LogException("VigemManager.Start error L55", e); System.Windows.MessageBox.Show("Vigembus not installed!", "Fatal Error", (MessageBoxButton)MessageBoxButtons.OK, (MessageBoxImage)MessageBoxIcon.Error); System.Windows.Forms.Application.Exit(); } catch (Exception e) { ExceptionLogger.LogException("VigemManager.Start error L65", e); System.Windows.MessageBox.Show("whoops! tell the developer he failed", "Fatal Error", (MessageBoxButton)MessageBoxButtons.OK, (MessageBoxImage)MessageBoxIcon.Error); System.Windows.Forms.Application.Exit(); } }
public StatusExtractorTests() { _settings = new InstanceSettings { Domain = "domain.name" }; }
public StatusServiceTests() { _settings = new InstanceSettings { Domain = "domain.name" }; }
/// <summary> /// Gets the <see cref="TS3_Bot.Core.BotInstance"/> with the specified id. /// </summary> /// <param name="setting">the settings</param> /// <value>The bot instance.</value> public BotInstance this[InstanceSettings setting] { get { return bots.FirstOrDefault(bot => bot.Settings.Id == setting.Id); } }
public static void Stop(InstanceSettings instanceSettings) { Log.Information("VigemManager.Stop"); try { if (instanceSettings != null) { VigemInternals vig = instanceSettings.GetVigemInternals(); if (vig != null) { vig.Stop(); } } } // You might be expecting the catches of this method to mirror, the Start() method // logically we are calling VigManager.Stop() is to end the application // so there it no point to call application exit catch (Nefarius.ViGEm.Client.Exceptions.VigemBusNotFoundException e) { ExceptionLogger.LogException("VigemManager.Stop error L96", e); } catch (Exception e) { ExceptionLogger.LogException("VigemManager.Stop error L100", e); } }
private async Task LockUserIfApplicable(AuthenticationUser user, InstanceSettings instanceSettings) { if (instanceSettings.MaximumInvalidLogonAttempts <= 0) { return; } if (user.InvalidLogonAttemptsNumber > 0 && user.LastInvalidLogonTimeStamp != null && DateTime.UtcNow > ((DateTime)user.LastInvalidLogonTimeStamp).AddHours(24)) { // We don't lock the user if she/he tries to login after 24 hours of the last failure attempt // after 24 hours we reset the counter and let the user to try invalid logon till reaches the limit user.InvalidLogonAttemptsNumber = 1; } else { user.InvalidLogonAttemptsNumber++; if (user.InvalidLogonAttemptsNumber >= instanceSettings.MaximumInvalidLogonAttempts) { user.IsEnabled = false; } } user.LastInvalidLogonTimeStamp = DateTime.UtcNow; await _userRepository.UpdateUserOnInvalidLoginAsync(user); }
/// <summary> /// Initializes a new instance of the <see cref="BotInstance"/> class. /// </summary> /// <param name="settings">The settings.</param> public BotInstance(InstanceSettings settings) { Settings = settings; Connection = new TeamSpeakConnection(this); Repository = new DataRepository(Connection, Settings); ManagerFactory = new ManagerFactory(Repository); }
public StatusService(InstanceSettings instanceSettings, IStatusExtractor statusExtractor, IExtractionStatisticsHandler statisticsHandler, IPublicationRepository publicationRepository) { _instanceSettings = instanceSettings; _statusExtractor = statusExtractor; _statisticsHandler = statisticsHandler; _publicationRepository = publicationRepository; }
public void Initialize() { _fakeEmailSettings = new EmailSettings { Id = "Fake", Authenticated = false, Domains = "Domain;MyDomain", EnableAllUsers = true, EnableDomains = true, EnableEmailDiscussion = false, EnableEmailReplies = false, EnableNotifications = false, EnableSSL = false, HostName = "FakeHostName", IncomingEnableSSL = false, IncomingHostName = "FakeIncomingHostName", IncomingPassword = "******", IncomingPort = 1234, IncomingServerType = 1, IncomingUserName = "******", Password = "******", Port = 1234, SenderEmailAddress = "FakeSenderAddress", UserName = "******" }; _instanceSettings = new InstanceSettings(); _cxn = new SqlConnectionWrapperMock(); _userRepository = new SqlUserRepositoryMock(); _instanceSettingsRepository = new SqlInstanceSettingsRepositoryMock(_fakeEmailSettings, _instanceSettings); _artifactPermissionsRepository = new SqlArtifactPermissionsRepository(_cxn.Object); _discussionsRepository = new SqlDiscussionsRepository(_cxn.Object, _userRepository, _instanceSettingsRepository, _artifactPermissionsRepository); }
public SendTweetsToInboxTask(IActivityPubService activityPubService, IStatusService statusService, IFollowersDal followersDal, InstanceSettings settings, ILogger <SendTweetsToInboxTask> logger) { _activityPubService = activityPubService; _statusService = statusService; _followersDal = followersDal; _settings = settings; _logger = logger; }
public UsersController(ITwitterUserService twitterUserService, IUserService userService, IStatusService statusService, InstanceSettings instanceSettings, ITwitterTweetsService twitterTweetService) { _twitterUserService = twitterUserService; _userService = userService; _statusService = statusService; _instanceSettings = instanceSettings; _twitterTweetService = twitterTweetService; }
public void Init() { _loginUser = new AuthenticationUser { Id = 1, Login = Login, UserSalt = UserSalt, Password = HashedPassword, IsEnabled = true }; _sqlUserRepositoryMock = new Mock <IUserRepository>(); _sqlUserRepositoryMock .Setup(m => m.GetUserByLoginAsync(Login)) .ReturnsAsync(_loginUser); _sqlUserRepositoryMock .Setup(m => m.ValidateUserPasswordForHistoryAsync(It.IsAny <int>(), It.Is <string>(p => p != NewPreviouslyUsedPassword))) .ReturnsAsync(true); _sqlUserRepositoryMock .Setup(m => m.ValidateUserPasswordForHistoryAsync(It.IsAny <int>(), It.Is <string>(p => p == NewPreviouslyUsedPassword))) .ReturnsAsync(false); _instanceSettings = new InstanceSettings { MaximumInvalidLogonAttempts = 5 }; _sqlSettingsRepositoryMock = new Mock <ISqlSettingsRepository>(); _sqlSettingsRepositoryMock .Setup(m => m.GetInstanceSettingsAsync()) .ReturnsAsync(_instanceSettings); _ldapRepositoryMock = new Mock <ILdapRepository>(); _samlRepositoryMock = new Mock <ISamlRepository>(); _logRepositoryMock = new Mock <IServiceLogRepository>(); _applicationSettings = new ApplicationSetting[] { new ApplicationSetting { Key = PasswordChangeCooldownInHoursKey, Value = DefaultPasswordChangeCooldownInHours } }; _applicationSettingsRepositoryMock = new Mock <IApplicationSettingsRepository>(); _applicationSettingsRepositoryMock .Setup(m => m.GetSettingsAsync(false)) .Returns(() => Task.Run(() => _applicationSettings)); _authenticationRepository = new AuthenticationRepository(_sqlUserRepositoryMock.Object, _sqlSettingsRepositoryMock.Object, _ldapRepositoryMock.Object, _samlRepositoryMock.Object, _logRepositoryMock.Object, _applicationSettingsRepositoryMock.Object); }
public UserService(InstanceSettings instanceSettings, ICryptoService cryptoService, IActivityPubService activityPubService, IProcessFollowUser processFollowUser, IProcessUndoFollowUser processUndoFollowUser, IStatusExtractor statusExtractor, IExtractionStatisticsHandler statisticsHandler, ITwitterUserService twitterUserService) { _instanceSettings = instanceSettings; _cryptoService = cryptoService; _activityPubService = activityPubService; _processFollowUser = processFollowUser; _processUndoFollowUser = processUndoFollowUser; _statusExtractor = statusExtractor; _statisticsHandler = statisticsHandler; _twitterUserService = twitterUserService; }
/// <summary> /// Initializes a new instance of the <see cref="DataRepository"/> class. /// </summary> public DataRepository(TeamSpeakConnection connection, InstanceSettings settings) { Connection = connection; Settings = settings; Container = new DataContainer(this.Settings.Name); Channel = new ChannelData(this); Client = new ClientData(this); Compliant = new CompliantData(this); File = new FileData(this); Server = new ServerData(this); Static = new StaticData(this); }
/// <summary> /// Initializes a new instance of the <see cref="DataRepository"/> class. /// </summary> public DataRepository(TeamSpeakConnection connection, InstanceSettings settings) { Connection = connection; Settings = settings; Container = new DataContainer(this.Settings.Name); Channel = new ChannelData(this); Client = new ClientData(this); Compliant = new CompliantData(this); File = new FileData(this); Server = new ServerData(this); Static = new StaticData(this); }
public InstanceSettings GetInstanceSettings(string instaneName) { if (InstanceSettings == null || instaneName == null) { return(null); } if (InstanceSettings.TryGetValue(instaneName, out var instanceSettings)) { return(instanceSettings); } return(null); }
private void OnAppExit(object sender, ExitEventArgs e) { Log.Debug("App OnAppExit"); InstanceSettings.GetInstance().EnableMouseInput = false; // cause not having a cursor is a pain in the ass Utility.ShowCursor(true); UserSettings.Save(UserSettings.PROFILE_PREVIOUS); ApplicationSettings.Save(); VigemManager.Stop(InstanceSettings.GetInstance()); //TODO: hardcoded, fix. //Injector.FindProcess("RemotePlay").Kill(); }
private void UpdateCost() { Cash.Text = Settings.InstanceSettings.InitalEmbarkment.Funds.ToString(); Cash.Invalidate(); EmployeeCost.Text = (new DwarfBux(Settings.InstanceSettings.InitalEmbarkment.Employees.Sum(e => e.SigningBonus))).ToString(); EmployeeCost.Invalidate(); TotalCost.Text = (Settings.InstanceSettings.InitalEmbarkment.Funds + Settings.InstanceSettings.InitalEmbarkment.Employees.Sum(e => e.SigningBonus)).ToString(); TotalCost.Invalidate(); var s = ""; InstanceSettings.ValidateEmbarkment(Settings, out s); ValidationLabel.Text = s; ValidationLabel.Invalidate(); }
private (DbSettings dbSettings, InstanceSettings instanceSettings) Convert(LocalSettingsData data) { var dbSettings = new DbSettings { Type = data.DbType, Host = data.DbHost, Name = data.DbName, User = data.DbUser, Password = data.DbPassword }; var instancesSettings = new InstanceSettings { Domain = data.InstanceDomain }; return(dbSettings, instancesSettings); }
public async Task ProcessAsync_Exception() { #region Stubs var follower = new Follower { Followings = new List <int> { 24 }, Host = "host" }; var settings = new InstanceSettings { Domain = "domain" }; #endregion #region Mocks var twitterUserDalMock = new Mock <ITwitterUserDal>(MockBehavior.Strict); twitterUserDalMock .Setup(x => x.GetTwitterUserAsync( It.Is <int>(y => y == 24))) .ReturnsAsync(new SyncTwitterUser { Id = 24, Acct = "acct" }); var userServiceMock = new Mock <IUserService>(MockBehavior.Strict); userServiceMock .Setup(x => x.SendRejectFollowAsync( It.Is <ActivityFollow>(y => y.type == "Follow"), It.IsNotNull <string>() )) .Throws(new Exception()); #endregion var action = new RejectAllFollowingsAction(twitterUserDalMock.Object, userServiceMock.Object, settings); await action.ProcessAsync(follower); #region Validations twitterUserDalMock.VerifyAll(); userServiceMock.VerifyAll(); #endregion }
public unsafe void AddInstance(char *iniFile, char *section, UInt32 id) { InstanceSettings new_instance = new InstanceSettings(); new_instance.Initialize(this, iniFile, section, id); this.Instances.Add(id, new_instance); bool bInSection = false; foreach (string line in System.IO.File.ReadAllLines(new_instance.INI_File)) { if (line.Trim().StartsWith(";")) { continue; // ignore comments } if (line.Trim().StartsWith("[")) { bInSection = false; // new section } // section test if (line.Trim().ToLower() == ("[" + new_instance.Section.ToLower() + "]")) { bInSection = true; } if (!bInSection) { continue; // abort this pass if not in section } if (!line.Contains("=")) { continue; // abort this pass if there's no INI setting here } string[] sLineParts = line.Trim().Split(new char[] { '=' }); SectionKey sk = new SectionKey(); sk.id = id; sk.INI_File = new_instance.INI_File; sk.Key = sLineParts[0].Trim(); sk.Section = new_instance.Section; sk.Value = ReadConfigString(new_instance.Section, sLineParts[0].Trim()); this.KeyValues.Add(sk); } }
public async Task GetInstanceSettingsAsync_QueryReturnsSettings_ReturnsFirst() { // Arrange var cxn = new SqlConnectionWrapperMock(); var repository = new SqlSettingsRepository(cxn.Object); InstanceSettings[] result = { new InstanceSettings { UseDefaultConnection = true } }; cxn.SetupQueryAsync("GetInstanceSettings", null, result); // Act InstanceSettings settings = await repository.GetInstanceSettingsAsync(); // Assert cxn.Verify(); Assert.AreEqual(result.First(), settings); }
/// <summary> /// Sets the specified settings. /// </summary> /// <param name="settings">The settings.</param> public void Set(InstanceSettings settings) { this.Settings = settings; SettingsSerializer.WriteSettings(this.Settings, fileStream); }
/// <summary> /// Initializes a new instance of the <see cref="TeamSpeakConnection"/> class. /// </summary> /// <param name="instanceSettings">The instance settings.</param> public TeamSpeakConnection(InstanceSettings instanceSettings) { Settings = instanceSettings; }
/// <summary> /// Changes the settings. /// </summary> /// <param name="settings">The settings.</param> public void ChangeSettings(InstanceSettings settings) { if (Repository.Connection.CredentialEntity != null && Repository.Connection.CredentialEntity.WorkerQueryRunner != null) Repository.Connection.CredentialEntity.WorkerQueryRunner.AddLogEntry(new LogEntryLight(LogLevel.Info, string.Format("TS3-Bot '{0}' Configuration refreshing.", Repository.Settings.Global.BotNickname))); var resetConnection = Settings.TeamSpeak.Hash != settings.TeamSpeak.Hash; Settings.ApplySettings(settings); if (resetConnection) { if (Repository.Connection.CredentialEntity != null && Repository.Connection.CredentialEntity.WorkerQueryRunner != null) { Repository.Connection.CredentialEntity.WorkerQueryRunner.AddLogEntry(new LogEntryLight(LogLevel.Info, "TS3-Bot with new Connection recognized.")); Repository.Connection.CredentialEntity.Dispose(); } } }
/// <summary> /// Initializes a new instance of the <see cref="AsyncTcpDispatcher"/> class. /// </summary> public AsyncTcpDispatcher(InstanceSettings settings) : base(settings.TeamSpeak.Host, settings.TeamSpeak.QueryPort) { }
public unsafe void AddInstance(char* iniFile, char* section, UInt32 id) { InstanceSettings new_instance = new InstanceSettings(); new_instance.Initialize(this, iniFile, section, id); this.Instances.Add(id, new_instance); bool bInSection = false; foreach (string line in System.IO.File.ReadAllLines(new_instance.INI_File)) { if (line.Trim().StartsWith(";")) continue; // ignore comments if (line.Trim().StartsWith("[")) bInSection = false; // new section // section test if (line.Trim().ToLower() == ("[" + new_instance.Section.ToLower() + "]")) bInSection = true; if (!bInSection) continue; // abort this pass if not in section if (!line.Contains("=")) continue; // abort this pass if there's no INI setting here string[] sLineParts = line.Trim().Split(new char[] { '=' }); SectionKey sk = new SectionKey(); sk.id = id; sk.INI_File = new_instance.INI_File; sk.Key = sLineParts[0].Trim(); sk.Section = new_instance.Section; sk.Value = ReadConfigString(new_instance.Section, sLineParts[0].Trim()); this.KeyValues.Add(sk); } }
/// <summary> /// Initializes a new instance of the <see cref="DataService"/> class. /// </summary> public DataService(InstanceSettings settings) { this.Settings = settings; this.QueryRunner = new QueryRunner(new SyncTcpDispatcher(settings)); }