Exemple #1
0
        void IInterceptor.Intercept(IInvocation invocation)
        {
            Contract.Assume(_State == InterceptorState.Active || _State == InterceptorState.Initialized);
            Contract.Assume(invocation != null);

            var txManagerC = _Kernel.Resolve <TransactionManager>();
            ITransactionManager txManager = txManagerC;

            var mTxMethod = _MetaInfo.Do(x => x.AsTransactional(invocation.MethodInvocationTarget ?? invocation.Method));

            var mTxData = mTxMethod.Do(x => txManager.CreateTransaction(x));

            _State = InterceptorState.Active;

            try
            {
                if (!mTxData.HasValue)
                {
                    if (mTxMethod.HasValue && mTxMethod.Value.Mode == TransactionScopeOption.Suppress)
                    {
                        _Logger.Info("supressing ambient transaction");
                        if (_Logger.IsInfoEnabled)
                        {
                            _Logger.Info("supressing ambient transaction");
                        }

                        using (new TxScope(null, _Logger.CreateChildLogger("TxScope")))
                            invocation.Proceed();
                    }
                    else
                    {
                        invocation.Proceed();
                    }

                    return;
                }

                var transaction = mTxData.Value.Transaction;
                Contract.Assume(transaction.State == TransactionState.Active,
                                "from post-condition of ITransactionManager CreateTransaction in the (HasValue -> ...)-case");

                if (mTxData.Value.ShouldFork)
                {
                    var task = ForkCase(invocation, mTxData.Value);
                    txManagerC.EnlistDependentTask(task);
                }
                else if (typeof(Task).IsAssignableFrom(invocation.MethodInvocationTarget.ReturnType))
                {
                    AsyncCase(invocation, transaction);
                }
                else
                {
                    SynchronizedCase(invocation, transaction);
                }
            }
            finally
            {
                _Kernel.ReleaseComponent(txManagerC);
            }
        }
        Maybe <ICreatedTransaction> ITransactionManager.CreateTransaction(ITransactionOptions transactionOptions)
        {
            var activity = _activityManager.GetCurrentActivity();

            if (transactionOptions.Mode == TransactionScopeOption.Suppress)
            {
                return(Maybe.None <ICreatedTransaction>());
            }

            var nextStackDepth = activity.Count + 1;
            var shouldFork     = transactionOptions.ShouldFork(nextStackDepth);

            ITransaction tx;

            if (activity.Count == 0)
            {
                tx = new Transaction(new CommittableTransaction(new TransactionOptions
                {
                    IsolationLevel = transactionOptions.IsolationLevel,
                    Timeout        = transactionOptions.Timeout
                }), nextStackDepth, transactionOptions, () => activity.Pop(),
                                     _logger.CreateChildLogger("Transaction"));
            }
            else
            {
                var clone = activity
                            .CurrentTransaction.Value
                            .Inner
                            .DependentClone(transactionOptions.DependentOption);
                Contract.Assume(clone != null);

                Action onDispose = () => activity.Pop();
                tx = new Transaction(clone, nextStackDepth, transactionOptions, shouldFork ? null : onDispose,
                                     _logger.CreateChildLogger("Transaction"));
            }

            if (!shouldFork)             // forked transactions should not be on the current context's activity stack
            {
                activity.Push(tx);
            }

            Contract.Assume(tx.State == TransactionState.Active, "by c'tor post condition for both cases of the if statement");

            // we should only fork if we have a different current top transaction than the current
            var m = Maybe.Some(new CreatedTransaction(tx, shouldFork, this.ForkScopeFactory(tx)) as ICreatedTransaction);

            // warn if fork and the top transaction was just created
            if (transactionOptions.Fork && nextStackDepth == 1)
            {
                _logger.WarnFormat("transaction {0} created with Fork=true option, but was top-most "
                                   + "transaction in invocation chain. running transaction sequentially",
                                   tx.LocalIdentifier);
            }

            Contract.Assume(m.HasValue && m.Value.Transaction.State == TransactionState.Active);

            return(m);
        }
Exemple #3
0
        public object ExecuteJavaScript(string javaScript, ILogger log)
        {
            var jsExecutor = GetJavaScriptExecutor();

            log = log?.CreateChildLogger($"Execute JavaScript");
            log?.CreateChildLogger("Logged JavaScript")?.INFO(javaScript);

            return(jsExecutor.ExecuteScript(javaScript));
        }
Exemple #4
0
        public IWebElement FindElement(WebElementInfo elementInfo, ILogger log)
        {
            log = log?.CreateChildLogger($"Find {elementInfo}");
            log?.INFO($"Description: {elementInfo.Description}");

            var search      = elementInfo.GetWebSearch();
            var searchStack = new Stack <WebSearchInfo>();

            searchStack.Push(search);

            while (search.ParentSearch != null)
            {
                searchStack.Push(search.ParentSearch);
                search = search.ParentSearch;
            }

            var searchLog = log?.CreateChildLogger("Search element");

            searchLog?.INFO($"Search contains: {searchStack.Count} items");

            IWebElement foundElement = null;

            var counter = 0;

            while (searchStack.Count > 0)
            {
                var currentSearch = searchStack.Pop();
                searchLog?.INFO($"Search for {++counter} item");
                searchLog?.INFO($"Locator type: {currentSearch.LocatorType}");
                searchLog?.INFO($"Locator value: {currentSearch.LocatorValue}");

                var by = GetBy(currentSearch);

                try
                {
                    if (foundElement == null)
                    {
                        foundElement = FindElement(by);
                    }
                    else
                    {
                        foundElement = FindElementRelativeTo(foundElement, by);
                    }
                }
                catch (Exception ex)
                {
                    var err = new SaKiWebElementException(nameof(FindElement), "WebElement could't be found", elementInfo, ex);
                    log?.ERROR(err.Message, err);
                    throw err;
                }
            }

            log?.INFO("Element found successfully");

            return(foundElement);
        }
Exemple #5
0
        public object ExecuteJavaScript(WebElementInfo elementInfo, string javaScript, ILogger log)
        {
            var jsExecutor = GetJavaScriptExecutor();

            log = log?.CreateChildLogger($"Execute JavaScript on {elementInfo}");
            log?.CreateChildLogger("Logged JavaScript")?.INFO(javaScript);
            LogElementPath(elementInfo, log);

            var element = FindElement(elementInfo, log);

            return(jsExecutor.ExecuteScript(javaScript, element));
        }
Exemple #6
0
 public TimedEntryCache(IRuntime runtime, ILogger logger)
 {
     this.runtime       = runtime;
     this.logger        = logger.CreateChildLogger("workviewcache");
     userEntries        = new DataTree();
     userDataSemaphores = new Dictionary <string, SemaphoreSlim>();
 }
Exemple #7
0
        public TroToAXExport(
            ILogger logger,
            string filePathExport,
            string filePathCopy,
            MongoDatabase database,
            DataTree config)
        {
            if (!filePathExport.EndsWith(Path.DirectorySeparatorChar.ToString()))
            {
                filePathExport += Path.DirectorySeparatorChar;
            }

            if (!filePathCopy.EndsWith(Path.DirectorySeparatorChar.ToString()))
            {
                filePathCopy += Path.DirectorySeparatorChar;
            }

            this.logger         = logger.CreateChildLogger("TroToAXExport");
            this.filePathExport = filePathExport;
            this.filePathCopy   = filePathCopy;

            this.database = database;
            this.config   = config;

            if (!this.filePathExport.EndsWith(Convert.ToString(Path.DirectorySeparatorChar)))
            {
                this.filePathExport += Path.DirectorySeparatorChar;
            }

            Init();
        }
Exemple #8
0
        public JabraModule(IUnityContainer container,
                           IViewManager viewManager,
                           IViewEventManager viewEventManager,
                           ICommandManager commandManager,
                           IConfigManager configManager,
                           IInteractionManager interactionManager,
                           IEventAggregator eventAggregator,
                           IAgent agent,
                           ILogger log)
        {
            this.container          = container;
            this.viewManager        = viewManager;
            this.viewEventManager   = viewEventManager;
            this.commandManager     = commandManager;
            this.configManager      = configManager;
            this.interactionManager = interactionManager;
            this.eventAggregator    = eventAggregator;
            this.agent = agent;

            this.log = log.CreateChildLogger(moduleName);
            if (log.IsDebugEnabled)
            {
                this.log.Debug("Constructor");
            }
        }
Exemple #9
0
        public WebElementState GetElementState(WebElementInfo elementInfo, out IWebElement element, ILogger log, bool changeTimeouts = true)
        {
            log = log?.CreateChildLogger($"Get state for {elementInfo}");
            log?.INFO($"Description: {elementInfo.Description}");

            element = TryFindElementWithTimeFrame(elementInfo, DefaultTimeoutForTrySearchInMilisec, changeTimeouts);
            if (element == null)
            {
                log?.INFO($"State: {WebElementState.NotPresent}");
                return(WebElementState.NotPresent);
            }

            if (!element.Displayed)
            {
                log?.INFO($"State: {WebElementState.NotVisible}");
                return(WebElementState.NotVisible);
            }

            if (!element.Enabled)
            {
                log?.INFO($"State: {WebElementState.Disabled}");
                return(WebElementState.Disabled);
            }

            log?.INFO($"State: {WebElementState.Enabled}");
            return(WebElementState.Enabled);
        }
Exemple #10
0
        public TroToVismaExport(
            ILogger logger,
            string filePath,
            MongoDatabase database,
            DataTree config)
        {
            this.logger   = logger.CreateChildLogger("TroToAXExport");
            this.filePath = filePath;

            if (!filePath.EndsWith(Path.DirectorySeparatorChar.ToString()))
            {
                filePath += Path.DirectorySeparatorChar;
            }

            this.database = database;
            this.config   = config;

            if (!this.filePath.EndsWith(Convert.ToString(Path.DirectorySeparatorChar)))
            {
                this.filePath += Path.DirectorySeparatorChar;
            }

            // Make sure integration folder exists
            var di = new DirectoryInfo(filePath);

            di.Create();

            Init();
        }
Exemple #11
0
        public string GetCurrentUrl(ILogger log)
        {
            log = log?.CreateChildLogger("Getting current url");
            var url = GetDriver().Url;

            log?.INFO($"Current url: {url}");
            return(url);
        }
 /// <summary>
 /// Creates a new instance of this client
 /// </summary>
 /// <param name="testRailServer">Test-Rail server to create a client against</param>
 /// <param name="user">Test-Rail user name (account email)</param>
 /// <param name="password">Test-Rail password</param>
 /// <param name="logger">Logger implementation for this client</param>
 protected TestRailClient(Uri testRailServer, string user, string password, ILogger logger)
 {
     this.testRailServer = testRailServer;
     this.user           = user;
     this.password       = password;
     this.logger         = logger?.CreateChildLogger(nameof(TestRailClient));
     Projects            = GetProjects();
     JsonSettings        = Utilities.GetJsonSettings <SnakeCaseNamingStrategy>();
 }
Exemple #13
0
        public CiscoVoiceCommand(IObjectContainer container)
        {
            this.container = container;
            this.log       = container.Resolve <ILogger>();
            this.log       = log.CreateChildLogger("CustomWorkitemCommand");
            IEnterpriseServiceProvider enterpriseServiceProvider = container.Resolve <IEnterpriseServiceProvider>();

            this.openMediaService = enterpriseServiceProvider.Resolve <IOpenMediaService>("openmediaService");
        }
Exemple #14
0
        public static IServiceProvider GetServices(string name)
        {
            var services = new KernelServices();

            services.AddSingleton(logger.CreateChildLogger(name));
            services.AddSingleton <IObjectFactory>(new ObjectFactory(services));
            services.AddSingleton <IEventTrigger>(eventQueue);
            // TODO: Add more kernel services
            return(services);
        }
Exemple #15
0
        public IWebElement FindElementRelativeTo(WebElementInfo parentElementInfo, By by, ILogger log)
        {
            log = log?.CreateChildLogger($"Find element relativeTo: {parentElementInfo}");
            log?.INFO($"using locator: {by}");

            var parentElement = FindElement(parentElementInfo, log);
            var foundElement  = FindElementRelativeTo(parentElement, by);

            return(foundElement);
        }
Exemple #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BeforeReleaseCallCommand"/> class.
        /// </summary>
        /// <param name="container">The container.</param>
        public BeforeReleaseCallCommand(IObjectContainer container)
        {
            this.container = container;

            // Initialize the trace system
            this.log = container.Resolve <ILogger>();

            // Create a child trace section
            this.log = log.CreateChildLogger("BeforeReleaseCallCommand");
        }
Exemple #17
0
        /// <summary>
        /// Konfiguriert und initialisiert ein Plugin.
        /// </summary>
        /// <param name="plugin">Plugin das konfiguriert wird</param>
        /// <param name="config">Konfiguration die verwendet wird</param>
        public virtual void SetupPlugin(IPlugin plugin, PluginConfig config)
        {
            plugin.Name   = config.Name;
            plugin.Logger = logger.CreateChildLogger(config.Name);

            Configure(plugin, config.Settings);
            Bind(plugin, config.Bindings);
            plugin.Init();

            plugins.Register(plugin.Name, plugin);
        }
Exemple #18
0
 /// <summary>
 /// Creates a new instance of JiraClient.
 /// </summary>
 /// <param name="authentication">Authentication information by which to connect and fetch data from Jira.</param>
 /// <param name="logger">Logger implementation for this client.</param>
 public XpandClient(JiraAuthentication authentication, ILogger logger)
 {
     // setup
     this.logger    = logger?.CreateChildLogger(loggerName : nameof(XpandClient));
     jiraClient     = new JiraClient(authentication, this.logger);
     Authentication = jiraClient.Authentication;
     executor       = new JiraCommandsExecutor(authentication, this.logger);
     bucketSize     = authentication.GetCapability(ProviderCapability.BucketSize, 4);
     options        = new ParallelOptions {
         MaxDegreeOfParallelism = bucketSize
     };
 }
Exemple #19
0
        public void SelectInDropDown(WebElementInfo elementInfo, string value, ILogger log)
        {
            log = log?.CreateChildLogger($"Select option with value: {value} in: {elementInfo}");


            if (!(elementInfo is DropDownElementInfo dropDown))
            {
                throw new Exception($"Element: {elementInfo}" +
                                    $"Is not a DropDownElement");
            }

            LogElementPath(elementInfo, log, "DropDown");

            var input = dropDown.GetInputElement()
                        ?? throw new Exception($"{elementInfo} doesn't have specified Input child element");

            LogElementPath(elementInfo, log, "DropDown Input");

            var option = dropDown.GetOptionElement()
                         ?? throw new Exception($"{elementInfo} doesn't have specified Option child element");

            option = option.GetCopyWithResolvedDynamicLocator(value);

            LogElementPath(elementInfo, log, "DropDown Option to select");

            var selectLog = log?.CreateChildLogger("Select option");

            var optionState = GetElementState(option, out var optionElement, selectLog);

            if (!optionState.HasFlag(WebElementState.Visible))
            {
                selectLog?.INFO("As option is not visible. Try to expand DropDown");
                Click(input, selectLog);
            }

            Click(option, selectLog);
            log?.INFO($"Option with value: {value} is selected");
        }
Exemple #20
0
        public IWebElement WaitForElementState(WebElementInfo elementInfo, WebElementState elementState, ILogger log, int timeoutInSec = 0, int pollingInMiliSec = 0)
        {
            if (timeoutInSec == 0)
            {
                timeoutInSec = DefaultTimeoutForSearchInSec;
            }
            if (pollingInMiliSec == 0)
            {
                pollingInMiliSec = DefaultTimeoutForPollingInSec;
            }

            log = log?.CreateChildLogger($"Wait for state: {elementState} for {elementInfo}");
            log?.INFO($"With timeout in {timeoutInSec} seconds and with polling interval in {pollingInMiliSec} seconds");


            var flags         = Enum.GetValues(typeof(WebElementState)).Cast <WebElementState>();
            var expectedFlags = flags.Where(f => elementState.HasFlag(f)).ToList();

            try
            {
                GetDriver().Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(DefaultTimeoutForTrySearchInMilisec);

                var  sw       = Stopwatch.StartNew();
                long mseconds = 0;
                while (sw.Elapsed.TotalSeconds <= timeoutInSec)
                {
                    mseconds = sw.ElapsedMilliseconds;
                    var state = GetElementState(elementInfo, out var element, null, false);

                    if (expectedFlags.All(f => state.HasFlag(f)))
                    {
                        return(element);
                    }

                    var toSleep = pollingInMiliSec * 1000 - (sw.ElapsedMilliseconds - mseconds);
                    if (toSleep > 0)
                    {
                        Thread.Sleep((int)toSleep);
                    }
                }

                var err = SaKiWebElementException.TimeoutDuring($"waiting for element state: {elementState}", timeoutInSec, elementInfo);
                log?.ERROR(err.Message, err);
                throw err;
            }
            finally
            {
                GetDriver().Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(DefaultTimeoutForSearchInSec);
            }
        }
		public FileTransaction(string name, DependentTransaction inner, uint stackDepth, ITransactionOptions creationOptions,
								Action onDispose, ILogger logger)
		{
			Contract.Requires(inner != null);
			Contract.Requires(creationOptions != null);
			Contract.Requires(!string.IsNullOrEmpty(name));
			Contract.Requires(logger != null);
			Contract.Ensures(_Name != null);

			_Inner = new Transaction(inner, stackDepth, creationOptions, onDispose, logger.CreateChildLogger("Transaction"));

			_Name = name;
			InnerBegin();
		}
Exemple #22
0
 public void Click(WebElementInfo elementInfo, ILogger log)
 {
     try
     {
         log = log?.CreateChildLogger($"Click on {elementInfo}");
         LogElementPath(elementInfo, log);
         var element = WaitForElementState(elementInfo, WebElementState.ReadyForAction, log);
         element.Click();
     }
     catch (Exception ex)
     {
         if (IsScreenshotOnErrorEnabled)
         {
             TryLogScreenShot($"Failed to Click on {elementInfo}", log);
         }
         throw SaKiWebElementException.ErrorDuring("Click on element", elementInfo, ex);
     }
 }
Exemple #23
0
 public void Type(string text, WebElementInfo elementInfo, ILogger log)
 {
     try
     {
         log = log?.CreateChildLogger($"Type text '{text}' to {elementInfo}");
         LogElementPath(elementInfo, log);
         var element = WaitForElementState(elementInfo, WebElementState.ReadyForAction, log);
         element.SendKeys(text);
     }
     catch (Exception ex)
     {
         if (IsScreenshotOnErrorEnabled)
         {
             TryLogScreenShot($"Failed to Type text '{text}' to {elementInfo}", log);
         }
         throw SaKiWebElementException.ErrorDuring("Type to element", elementInfo, ex);
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="BeforeReleaseCallCommand"/> class.
        /// </summary>
        /// <param name="container">The container.</param>
        public MarkDoneCommand(IObjectContainer container)
        {
            this.container = container;

            // Initialize the trace system
            this.log = container.Resolve <ILogger>();

            // Create a child trace section
            this.log = log.CreateChildLogger("MarkDoneLog");


            var contextDictionary = Context as IDictionary <string, object>;

            object caseObject;

            if (contextDictionary != null && contextDictionary.TryGetValue("Case", out caseObject))
            {
                var theCase = caseObject as ICase;
                _caseIdentifier = theCase;
            }
        }
Exemple #25
0
        private void LogElementPath(WebElementInfo elementInfo, ILogger log, string elementType = "Element")
        {
            log = log?.CreateChildLogger($"{elementType} location");
            var search = elementInfo.GetWebSearch();
            var stack  = new Stack <WebSearchInfo>();

            while (search != null)
            {
                stack.Push(search);
                search = search.ParentSearch;
            }

            var isFirst = true;

            while (stack.Count != 0)
            {
                search = stack.Pop();
                log?.INFO($"{(isFirst ? "Locator" : "Followed by")}: {search.LocatorType} | {search.LocatorValue}");
                isFirst = false;
            }
        }
Exemple #26
0
        public void SelectInRadioGroup(WebElementInfo elementInfo, string value, ILogger log)
        {
            log = log?.CreateChildLogger($"Select option with value: {value} in: {elementInfo}");

            if (!(elementInfo is RadioGroupElementInfo radioGroup))
            {
                throw new Exception($"Element: {elementInfo}" +
                                    $"Is not a RadioGroupElement");
            }

            LogElementPath(elementInfo, log, "RadioGroup");

            var option = radioGroup.GetOptionElement()
                         ?? throw new Exception($"{elementInfo} doesn't have specified Option child element");

            option = option.GetCopyWithResolvedDynamicLocator(value);

            LogElementPath(elementInfo, log, "RadioGroup Option to select");

            Click(option, log);

            log?.INFO($"Option with value: {value} is selected");
        }
Exemple #27
0
 /// <summary>
 /// Creates a new instance JiraBugsManager.
 /// </summary>
 /// <param name="client">JiraClient by which to utilize Jira requests.</param>
 /// <param name="logger">Logger implementation for this JiraClient</param>
 public JiraBugsManager(JiraClient client, ILogger logger)
 {
     this.client = client;
     this.logger = logger != default ? logger.CreateChildLogger(nameof(JiraBugsManager)) : logger;
 }
Exemple #28
0
        public Launch(
            ILogger logger,
            IIrcClient freenodeClient,
            IIrcClient wikimediaClient,
            IAppConfiguration appConfig,
            ITemplateConfiguration templateConfiguration,
            IBotUserConfiguration userConfiguration,
            IChannelConfiguration channelConfiguration,
            IStalkFactory stalkFactory,
            IFileService fileService)
        {
            this.logger               = logger;
            this.freenodeClient       = freenodeClient;
            this.wikimediaClient      = wikimediaClient;
            this.appConfig            = appConfig;
            this.channelConfiguration = channelConfiguration;

            if (!this.channelConfiguration.Items.Any())
            {
                this.logger.InfoFormat("Migrating to channel configuration file...");

                var defaultChannel = new IrcChannel(this.appConfig.FreenodeChannel);
                this.channelConfiguration.Add(defaultChannel);

                if (appConfig.StalkConfigFile != null)
                {
                    var stalkConfig = new StalkConfiguration(
                        appConfig,
                        logger.CreateChildLogger("LegacyStalkConfig"),
                        stalkFactory,
                        fileService
                        );
                    stalkConfig.Initialize();

                    foreach (var stalk in stalkConfig.Items)
                    {
                        stalk.Channel = this.appConfig.FreenodeChannel;
                        defaultChannel.Stalks.Add(stalk.Identifier, stalk);
                        stalkConfig.Remove(stalk.Identifier);
                    }

                    stalkConfig.Save();
                }

                this.channelConfiguration.Save();
            }

            this.logger.InfoFormat(
                "Tracking {0} stalks, {1} templates, {2} users, and {3} channels.",
                this.channelConfiguration.Items.Aggregate(0, (i, channel) => i + channel.Stalks.Count),
                templateConfiguration.Items.Count,
                userConfiguration.Items.Count,
                channelConfiguration.Items.Count
                );

            if (appConfig.MetricsPort != 0)
            {
                this.logger.DebugFormat("Setting up metrics server on port {0}", appConfig.MetricsPort);
                this.metricsServer = new MetricServer(appConfig.MetricsPort);
                this.metricsServer.Start();

                VersionInfo.WithLabels(
                    FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion,
                    FileVersionInfo.GetVersionInfo(Assembly.GetAssembly(typeof(IrcClient)).Location)
                    .FileVersion,
                    FileVersionInfo.GetVersionInfo(Assembly.GetAssembly(typeof(CommandBase)).Location)
                    .FileVersion,
                    FileVersionInfo.GetVersionInfo(Assembly.GetAssembly(typeof(MediaWikiApi)).Location)
                    .FileVersion,
                    FileVersionInfo.GetVersionInfo(Assembly.GetAssembly(typeof(ConduitClient)).Location)
                    .FileVersion,
                    Environment.Version.ToString(),
                    Environment.OSVersion.ToString(),
                    ((TargetFrameworkAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(TargetFrameworkAttribute), false).FirstOrDefault())?.FrameworkDisplayName ?? "Unknown"
                    )
                .Set(1);

                this.logger.DebugFormat("Metrics server configured.");
            }
            else
            {
                this.logger.Warn("Prometheus metrics server disabled.");
            }

            this.freenodeClient.DisconnectedEvent  += this.OnDisconnect;
            this.wikimediaClient.DisconnectedEvent += this.OnDisconnect;
        }
Exemple #29
0
 /// <summary>
 /// Initialises a new instance of the <see cref="LegacyDatabase"/> class.
 /// </summary>
 /// <param name="logger">
 /// The logger.
 /// </param>
 /// <param name="configurationHelper">
 /// The configuration Helper.
 /// </param>
 public LegacyDatabase(ILogger logger, IConfigurationHelper configurationHelper)
 {
     this.configurationHelper = configurationHelper;
     this.Log = logger.CreateChildLogger("Helpmebot.Legacy.Database.LegacyDatabase");
 }
Exemple #30
0
 public Log CreateLogger(ISFDCListener listener, ILogger genLoggger)
 {
     this._sFDCListener = listener;
     this._genlogger    = genLoggger.CreateChildLogger("SFDCAdapter");
     return(_thisLogger);
 }
Exemple #31
0
        /// <summary>
        /// Initialises a new instance of the <see cref="NetworkClient"/> class.
        /// </summary>
        /// <param name="hostname">
        /// The hostname.
        /// </param>
        /// <param name="port">
        /// The port.
        /// </param>
        /// <param name="logger">
        /// The logger.
        /// </param>
        /// <param name="startThreads">
        /// The start threads.
        /// </param>
        protected NetworkClient(string hostname, int port, ILogger logger, bool startThreads)
        {
            this.hostname = hostname;
            this.port = port;
            this.logger = logger;
            this.inboundLogger = logger.CreateChildLogger("Inbound");
            this.outboundLogger = logger.CreateChildLogger("Outbound");

            this.logger.InfoFormat("Connecting to socket tcp://{0}:{1}/ ...", hostname, port);

            this.client = new TcpClient(this.hostname, this.port);

            this.Reader = new StreamReader(this.client.GetStream());
            this.Writer = new StreamWriter(this.client.GetStream());
            this.sendQueue = new Queue<string>();

            this.writerThreadResetEvent = new AutoResetEvent(true);

            if (startThreads)
            {
                this.StartThreads();
            }
        }
Exemple #32
0
 /// <summary>
 /// Creates a new instance of JiraCommandExecutor.
 /// </summary>
 /// <param name="authentication">JiraAuthentication instance to use with this JiraCommandExecutor.</param>
 /// <param name="logger">Logger implementation for this JiraCommandExecutor.</param>
 public JiraCommandsExecutor(JiraAuthentication authentication, ILogger logger)
 {
     this.authentication = authentication;
     this.logger         = logger != default ? logger.CreateChildLogger(nameof(JiraCommandsExecutor)) : logger;
     bucketSize          = authentication.GetCapability(ProviderCapability.BucketSize, 4);
 }
Exemple #33
0
 public ILogger CreateChildLogger(string loggerName)
 {
     return(_logger.CreateChildLogger(loggerName));
 }
        /// <summary>
        /// Initialises a new instance of the <see cref="WatcherController"/> class.
        /// </summary>
        /// <param name="messageService">
        /// The message Service.
        /// </param>
        /// <param name="urlShorteningService">
        /// The url Shortening Service.
        /// </param>
        /// <param name="watchedCategoryRepository">
        /// The watched Category Repository.
        /// </param>
        /// <param name="mediaWikiSiteRepository">
        /// The media Wiki Site Repository.
        /// </param>
        /// <param name="ignoredPagesRepository">
        /// The ignored Pages Repository.
        /// </param>
        /// <param name="logger">
        /// The logger.
        /// </param>
        /// <param name="ircClient">
        /// The IRC Client.
        /// </param>
        /// <param name="legacyDatabase">
        /// The legacy Database.
        /// </param>
        protected WatcherController(
            IMessageService messageService, 
            IUrlShorteningService urlShorteningService, 
            IWatchedCategoryRepository watchedCategoryRepository, 
            IMediaWikiSiteRepository mediaWikiSiteRepository,
            IIgnoredPagesRepository ignoredPagesRepository,
            ILogger logger,
            IIrcClient ircClient,
            ILegacyDatabase legacyDatabase)
        {
            this.messageService = messageService;
            this.urlShorteningService = urlShorteningService;
            this.watchers = new Dictionary<string, CategoryWatcher>();
            this.logger = logger;
            this.ircClient = ircClient;

            foreach (WatchedCategory item in watchedCategoryRepository.Get())
            {
                var categoryWatcher = new CategoryWatcher(
                    item,
                    mediaWikiSiteRepository,
                    ignoredPagesRepository,
                    logger.CreateChildLogger("CategoryWatcher[" + item.Keyword + "]"));
                this.watchers.Add(item.Keyword, categoryWatcher);
                categoryWatcher.CategoryHasItemsEvent += this.CategoryHasItemsEvent;
            }

            this.legacyDatabase = legacyDatabase;
        }
Exemple #35
0
        /// <summary>
        /// Initialises a new instance of the <see cref="IrcClient"/> class.
        /// </summary>
        /// <param name="client">
        /// The client.
        /// </param>
        /// <param name="logger">
        /// The logger.
        /// </param>
        /// <param name="ircConfiguration">
        /// The configuration Helper.
        /// </param>
        /// <param name="password">
        /// The password.
        /// </param>
        public IrcClient(INetworkClient client, ILogger logger, IIrcConfiguration ircConfiguration, string password)
        {
            this.nickname = ircConfiguration.Nickname;
            this.networkClient = client;
            this.logger = logger;
            this.syncLogger = logger.CreateChildLogger("Sync");
            this.username = ircConfiguration.Username;
            this.realName = ircConfiguration.RealName;
            this.password = password;
            this.networkClient.DataReceived += this.NetworkClientOnDataReceived;
            this.ReceivedMessage += this.OnMessageReceivedEvent;

            this.clientCapabilities = new List<string> { "sasl", "account-notify", "extended-join", "multi-prefix" };

            this.authToServices = ircConfiguration.AuthToServices;

            if (!this.authToServices)
            {
                this.logger.Warn("Services authentication is disabled!");

                this.clientCapabilities.Remove("sasl");
                this.clientCapabilities.Remove("account-notify");
                this.clientCapabilities.Remove("extended-join");
            }

            this.userCache = new Dictionary<string, IrcUser>();
            this.channels = new Dictionary<string, IrcChannel>();

            this.connectionRegistrationSemaphore = new Semaphore(0, 1);
            this.syncLogger.Debug("ctor() acquired connectionRegistration semaphore.");

            this.RegisterConnection(null);
        }