/// <summary>
 /// Initializes a new instance of the <see cref="TabsController"/> class.
 /// </summary>
 /// <param name="eventHelper">Event data provider instance</param>
 /// <param name="userManagementHelper">UserManagementHelper instance</param>
 /// <param name="configProvider">Configuration provider instance</param>
 /// <param name="logProvider">ILogProvider</param>
 public TabsController(IEventDataProvider eventHelper, IUserManagementHelper userManagementHelper, IConfigProvider configProvider, ILogProvider logProvider)
 {
     this.eventDataProvider    = eventHelper;
     this.userManagementHelper = userManagementHelper;
     this.configProvider       = configProvider;
     this.logProvider          = logProvider;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ShareEventDialog"/> class.
 /// </summary>
 /// <param name="connectorClient">Connector client</param>
 /// <param name="eventDataProvider">Event data provider instance</param>
 /// <param name="userManagementHelper">UserManagementHelper instance</param>
 /// <param name="logProvider">Logging component</param>
 public ShareEventDialog(IConnectorClient connectorClient, IEventDataProvider eventDataProvider, IUserManagementHelper userManagementHelper, ILogProvider logProvider)
 {
     this.eventDataProvider    = eventDataProvider;
     this.connectorClient      = connectorClient;
     this.logProvider          = logProvider;
     this.userManagementHelper = userManagementHelper;
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EventNotificationController"/> class.
 /// </summary>
 /// <param name="eventDataProvider">Event data provider instance</param>
 /// <param name="userManagementHelper">UserManagementHelper instance</param>
 /// <param name="connectorClientFactory">Connector client factory instance</param>
 /// <param name="logProvider">The instance of <see cref="ILogProvider"/></param>
 public EventNotificationController(IEventDataProvider eventDataProvider, IUserManagementHelper userManagementHelper, IConnectorClientFactory connectorClientFactory, ILogProvider logProvider)
 {
     this.eventDataProvider           = eventDataProvider;
     this.userManagementHelper        = userManagementHelper;
     this.connectorClientFactory      = connectorClientFactory;
     this.logProvider                 = logProvider;
     this.teamToEventNotificationsMap = new Dictionary <string, List <EventNotificationData> >();
 }
Beispiel #4
0
        public EventSourceReader(
            ILog logger,
            IEventDataProvider eventDataProvider)
        {
            Throw.IfNull(logger, nameof(logger));
            Throw.IfNull(eventDataProvider, nameof(eventDataProvider));

            _logger            = logger;
            _eventDataProvider = eventDataProvider;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PreviewController"/> class.
 /// </summary>
 /// <param name="eventDataProvider">Event data provider instance.</param>
 /// <param name="userManagementHelper">UserManagementHelper instance</param>
 /// <param name="logProvider">Log provider instance</param>
 /// <param name="connectorClientFactory">The connector client factory</param>
 /// <param name="configProvider">Configuration provider instance</param>
 public PreviewController(IEventDataProvider eventDataProvider, IUserManagementHelper userManagementHelper, ILogProvider logProvider, IConnectorClientFactory connectorClientFactory, IConfigProvider configProvider)
 {
     this.eventDataProvider               = eventDataProvider;
     this.userManagementHelper            = userManagementHelper;
     this.logProvider                     = logProvider;
     this.connectorClientFactory          = connectorClientFactory;
     this.timeToPostPreview               = TimeSpan.Parse(configProvider.GetSetting(ApplicationConfig.TimeToPostCelebration), CultureInfo.InvariantCulture);
     this.daysInAdvanceToSendEventPreview = Convert.ToInt32(configProvider.GetSetting(ApplicationConfig.DaysInAdvanceToSendEventPreview));
     this.minimumTimeToProcessEvent       = TimeSpan.FromHours(Convert.ToInt32(configProvider.GetSetting(ApplicationConfig.MinTimeToProcessEventInHours)));
 }
Beispiel #6
0
 /// <summary>
 /// Runs a named Pyphon script that uses the DSL
 /// </summary>
 /// <param name="scriptname">The python script file</param>
 /// <param name="IAzureDevOpsProvider">The Azure DevOps provider</param>
 /// <param name="iEmailProvider">The email provider</param>
 /// <param name="iEventdataProvider">The raw data provider</param>
 public void RunScript(
     string scriptname,
     IAzureDevOpsProvider iAzureDevOpsProvider,
     IEmailProvider iEmailProvider,
     IEventDataProvider iEventdataProvider)
 {
     this.RunScript(
         FolderHelper.GetRootedPath(@"dsl"),
         FolderHelper.GetRootedPath("~/"),
         scriptname,
         null,
         iAzureDevOpsProvider,
         iEmailProvider,
         iEventdataProvider);
 }
Beispiel #7
0
 /// <summary>
 /// Runs a named Pyphon script that uses the DSL
 /// </summary>
 /// <param name="scriptname">The python script file</param>
 /// <param name="args">The parameters to pass to the script</param>
 /// <param name="IAzureDevOpsProvider">The Azure DevOps provider</param>
 /// <param name="iEmailProvider">The email provider</param>
 /// <param name="iEventdataProvider">The raw data provider</param>
 public void RunScript(
     string scriptname,
     Dictionary <string, object> args,
     IAzureDevOpsProvider iAzureDevOpsProvider,
     IEmailProvider iEmailProvider,
     IEventDataProvider iEventdataProvider)
 {
     this.RunScript(
         FolderHelper.GetRootedPath(@"dsl"),
         FolderHelper.GetRootedPath("~/"),
         scriptname,
         args,
         iAzureDevOpsProvider,
         iEmailProvider,
         iEventdataProvider);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageDeliveryController"/> class.
 /// </summary>
 /// <param name="eventDataProvider">Event data provider instance</param>
 /// <param name="logProvider">The instance of <see cref="ILogProvider"/></param>
 /// <param name="connectorClientFactory">Connector client factory</param>
 public MessageDeliveryController(IEventDataProvider eventDataProvider, ILogProvider logProvider, IConnectorClientFactory connectorClientFactory)
 {
     this.eventDataProvider      = eventDataProvider;
     this.logProvider            = logProvider;
     this.connectorClientFactory = connectorClientFactory;
 }
 public KwasantNavigatorControl(IEventDataProvider provider)
 {
     _provider = provider;
 }
 public EventsController(IEventDataProvider _data)
 {
     data = _data;
 }
Beispiel #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessagesController"/> class.
 /// </summary>
 /// <param name="logProvider">The instance of <see cref="ILogProvider"/></param>
 /// <param name="userManagementHelper">UserManagementHelper instance</param>
 /// <param name="eventDataProvider">Event data provider instance</param>
 public MessagesController(ILogProvider logProvider, IUserManagementHelper userManagementHelper, IEventDataProvider eventDataProvider)
 {
     this.logProvider          = logProvider;
     this.userManagementHelper = userManagementHelper;
     this.eventDataProvider    = eventDataProvider;
 }
Beispiel #12
0
        public void RunScript(
            string dslFolder,
            string scriptFolder,
            string scriptname,
            Dictionary <string, object> args,
            IAzureDevOpsProvider iAzureDevOpsProvider,
            IEmailProvider iEmailProvider,
            IEventDataProvider iEventData)
        {
            if (scriptname == null)
            {
                throw new ArgumentNullException("scriptname");
            }
            else
            {
                if (string.IsNullOrEmpty(scriptFolder))
                {
                    scriptFolder = FolderHelper.GetRootedPath("~/");
                }
                else
                {
                    scriptFolder = FolderHelper.GetRootedPath(scriptFolder);
                }

                if (File.Exists(scriptname) == false)
                {
                    // we have not been given a resolvable file name, so try appending the base path
                    scriptname = Path.Combine(scriptFolder, scriptname);
                    if (File.Exists(scriptname) == false)
                    {
                        this.logger.Error(string.Format("DslProcessor: DslProcessor cannot find script:{0}", scriptname));
                        return;
                    }
                }
            }

            if (iEventData == null)
            {
                throw new ArgumentNullException("iEventData");
            }

            if (iAzureDevOpsProvider == null)
            {
                throw new ArgumentNullException("iAzureDevOpsProvider");
            }

            if (iEmailProvider == null)
            {
                throw new ArgumentNullException("iEmailProvider");
            }

            if (string.IsNullOrEmpty(dslFolder))
            {
                dslFolder = FolderHelper.GetRootedPath("~/");
            }
            else
            {
                dslFolder = FolderHelper.GetRootedPath(dslFolder);
            }

            // load the DSL wrapper class via MEF
            //An aggregate catalog that combines multiple catalogs
            var catalog = new AggregateCatalog();

            //Adds all the parts found in the same assembly as the Program class
            if (Directory.Exists(dslFolder))
            {
                this.logger.Info(
                    string.Format("DslProcessor: DslProcessor loading DSL from {0}", Path.GetFullPath(dslFolder)));
                catalog.Catalogs.Add(new DirectoryCatalog(dslFolder));
            }
            else
            {
                this.logger.Error(
                    string.Format("DslProcessor: DslProcessor cannot find DSL folder {0}", Path.GetFullPath(dslFolder)));
                return;
            }

            try
            {
                //Create the CompositionContainer with the parts in the catalog
                var container = new CompositionContainer(catalog);

                container.ComposeParts(this);
            }
            catch (CompositionException compositionException)
            {
                this.logger.Error(string.Format("DsLProcessor: {0}", compositionException.Message));
                return;
            }
            catch (ReflectionTypeLoadException ex)
            {
                this.logger.Error(string.Format("DsLProcessor: {0}", ex.Message));
                StringBuilder sb = new StringBuilder();
                foreach (Exception exSub in ex.LoaderExceptions)
                {
                    sb.AppendLine(exSub.Message);
                    FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
                    if (exFileNotFound != null)
                    {
                        if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
                        {
                            sb.AppendLine("Fusion Log:");
                            sb.AppendLine(exFileNotFound.FusionLog);
                        }
                    }
                    sb.AppendLine();
                }
                this.logger.Error(string.Format("DslProcessor: {0}", sb.ToString()));
                return;
            }

            this.logger.Info(
                string.Format("DslProcessor: DslProcessor found  {0} DSL libraries", this.dslLibraries.Count()));

            if (this.dslLibraries.Any())
            {
                // create the engine
                var engine = IronPython.Hosting.Python.CreateEngine(args);
                var objOps = engine.Operations;
                var scope  = engine.CreateScope();

                // inject the providers
                foreach (var item in this.dslLibraries)
                {
                    item.EmailProvider = iEmailProvider;
                    item.TfsProvider   = iAzureDevOpsProvider;
                    item.EventData     = iEventData;
                    item.ScriptFolder  = scriptFolder;

                    // Read in the methods
                    foreach (string memberName in objOps.GetMemberNames(item))
                    {
                        scope.SetVariable(memberName, objOps.GetMember(item, memberName));
                    }
                }

                if (this.redirectScriptEngineOutputtoLogging == true)
                {
                    // redirect the console out opf the script to the nLog
                    engine.Runtime.IO.SetOutput(
                        new ConsoleRedirectStreamToNlog(LogLevel.Info, "PythonScriptConsole"),
                        System.Text.Encoding.ASCII);
                    engine.Runtime.IO.SetErrorOutput(
                        new ConsoleRedirectStreamToNlog(LogLevel.Error, "PythonScriptError"),
                        System.Text.Encoding.ASCII);
                }
                else
                {
                    // this is only used in tests where the console is visible or being cpatured in another manner
                    engine.Runtime.IO.RedirectToConsole();
                }

                // run the script
                this.logger.Info(string.Format(
                                     "DslProcessor: DslProcessor running script:{0}",
                                     scriptname));
                var script = engine.CreateScriptSourceFromFile(scriptname);
                script.Execute(scope);
            }
            else
            {
                this.logger.Error(
                    string.Format("DslProcessor: DslProcessor cannot find DSL libraries in folder {0}", Path.GetFullPath(dslFolder)));
                return;
            }
        }
Beispiel #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SkipEventDialog"/> class.
 /// </summary>
 /// <param name="connectorClient">Connector client</param>
 /// <param name="eventDataProvider">Event data provider instance</param>
 /// <param name="logProvider">Logging component</param>
 public SkipEventDialog(IConnectorClient connectorClient, IEventDataProvider eventDataProvider, ILogProvider logProvider)
 {
     this.connectorClient   = connectorClient;
     this.eventDataProvider = eventDataProvider;
     this.logProvider       = logProvider;
 }
 public KwasantCalendarController(IEventDataProvider provider)
 {
     _provider = provider;
 }