Ejemplo n.º 1
0
        /// <summary>
        ///     Gets the tenants.
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <string> GetTenants( )
        {
            using (new GlobalAdministratorContext( ))
            {
                IEnumerable <ETenant> instancesOfType = TenantHelper.GetAll( );

                if (instancesOfType != null)
                {
                    return(instancesOfType.Select(t => t.Name).ToList( ));
                }

                return(Enumerable.Empty <string>( ));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets information about the tenants that exists.
        /// </summary>
        /// <returns>List of remote tenant info objects.</returns>
        public IList <RemoteTenantInfo> GetTenants()
        {
            using (Profiler.Measure("TenantService.GetTenants"))
            {
                using (new GlobalAdministratorContext())
                {
                    var tenants = TenantHelper.GetAll();

                    if (tenants == null)
                    {
                        return(new List <RemoteTenantInfo>());
                    }

                    return(tenants.Select(GetTenantInfo).ToList());
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Populate the tenants combo box.
        /// </summary>
        private void LoadTenants()
        {
            using (new AdministratorContext())
            {
                var tenants = TenantHelper.GetAll();

                var items = from instance in tenants
                            let item = new TenantEntry()
                {
                    Name = instance.Name, Id = instance.Id
                }
                orderby item.ToString()
                select item;

                cmbTenant.Items.Clear();
                cmbTenant.Items.Add("[Global]");
                cmbTenant.Items.AddRange(items.ToArray());
            }
            cmbTenant.SelectedIndex = 1;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Make sure a queue exusts for every tenant and have the correct concurrency
        /// </summary>
        private Dictionary <long, QueueActioner <BackgroundTask> > CreateActioners()
        {
            var result = new Dictionary <long, QueueActioner <BackgroundTask> >();

            List <long> tenantIds;

            using (new GlobalAdministratorContext())
            {
                tenantIds = TenantHelper.GetAll().Select(t => t.Id).ToList();
            }

            foreach (var tenantId in tenantIds)
            {
                var queue = _tenantQueueFactory.Create(tenantId);

                result.Add(tenantId, new QueueActioner <BackgroundTask>(queue, ProcessTask, _perTenantConcurrency));
            }

            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Gets the tenants.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        public static IEnumerable <string> GetTenants(IProcessingContext context)
        {
            if (context == null)
            {
                context = new ProcessingContext( );
            }

            context.Report.StartTime = DateTime.Now;

            List <string> tenantNames;

            using (new GlobalAdministratorContext( ))
            {
                IEnumerable <Tenant> tenants = TenantHelper.GetAll();

                tenantNames = tenants.Select(tenant => tenant.Name).ToList( );
            }

            context.Report.EndTime = DateTime.Now;

            return(tenantNames);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Suspend all queued tasks
        /// </summary>
        public void RestoreAllTasks()
        {
            int restoredCount = 0;

            foreach (var tenant in TenantHelper.GetAll())
            {
                using (new TenantAdministratorContext(tenant.Id))
                {
                    foreach (var handler in TaskHandlers.Values)
                    {
                        var tasks = handler.RestoreSuspendedTasks();

                        foreach (var task in tasks)
                        {
                            EnqueueTask(task);
                            restoredCount++;
                        }
                    }
                }
            }

            EventLog.Application.WriteInformation($"Restoring {restoredCount} suspended tasks.");
        }