コード例 #1
0
        public ActionResult Status(string hostedServiceName, string id, bool isStarted)
        {
            InitializeDeploymentTenant(hostedServiceName);
            var cloudServices = new CloudServices(Storage.BlobStorage);

            if (isStarted)
            {
                cloudServices.EnableService(id);
            }
            else
            {
                cloudServices.DisableService(id);
            }

            return Json(new
                {
                    serviceName = id,
                    isStarted,
                });
        }
コード例 #2
0
        public ServicesModel QueryServices()
        {
            var serviceManager = new CloudServices(_runtimeProviders);
            var services = serviceManager.GetServices();

            var inspector = new CloudApplicationInspector(_runtimeProviders);
            var applicationDefinition = inspector.Inspect();

            if (!applicationDefinition.HasValue)
            {
                return new ServicesModel
                    {
                        QueueServices = new QueueServiceModel[0],
                        ScheduledServices = new CloudServiceInfo[0],
                        CloudServices = new CloudServiceInfo[0],
                        UnavailableServices = new CloudServiceInfo[0]
                    };
            }

            var appDefinition = applicationDefinition.Value;

            var queueServices = services.Join(
                appDefinition.QueueServices,
                s => s.ServiceName,
                d => d.TypeName,
                (s, d) => new QueueServiceModel { ServiceName = s.ServiceName, IsStarted = s.IsStarted, Definition = d }).ToArray();

            var scheduledServices = services.Where(s => appDefinition.ScheduledServices.Any(ads => ads.TypeName.StartsWith(s.ServiceName))).ToArray();
            var otherServices = services.Where(s => appDefinition.CloudServices.Any(ads => ads.TypeName.StartsWith(s.ServiceName))).ToArray();
            var unavailableServices = services
                .Where(s => !queueServices.Any(d => d.ServiceName == s.ServiceName))
                .Except(scheduledServices).Except(otherServices).ToArray();

            return new ServicesModel
                {
                    QueueServices = queueServices,
                    ScheduledServices = scheduledServices,
                    CloudServices = otherServices,
                    UnavailableServices = unavailableServices
                };
        }