Пример #1
0
        public async Task<ActionResult> Index(string slug)
        {
            IApplication application = _applicationService.GetApplication(slug);

            if (application == null)
            {
                return HttpNotFound();
            }

            ICredentials credentials = _credentialProvider.GetCredentials();
            RemoteDeploymentManager deploymentManager = application.GetDeploymentManager(credentials);

            Task<IEnumerable<DeployResult>> deployResults = deploymentManager.GetResultsAsync();
            Task<RepositoryInfo> repositoryInfo = application.GetRepositoryInfo(credentials);

            await Task.WhenAll(deployResults, repositoryInfo);

            var appViewModel = new ApplicationViewModel(application, _settingsResolver)
            {
                RepositoryInfo = repositoryInfo.Result,
                Deployments = deployResults.Result.ToList()
            };

            ViewBag.slug = slug;
            ViewBag.appName = appViewModel.Name;

            return View(appViewModel);
        }
Пример #2
0
        public ActionResult Create(ApplicationViewModel appViewModel)
        {
            string slug = appViewModel.Name.GenerateSlug();
            if (db.Applications.Any(a => a.Name == appViewModel.Name || a.Slug == slug))
            {
                ModelState.AddModelError("Name", "Site already exists");
            }

            if (ModelState.IsValid)
            {
                Site site = null;

                try
                {
                    site = _siteManager.CreateSite(slug);

                    var app = new Application
                    {
                        Name = appViewModel.Name,
                        Slug = slug,
                        ServiceUrl = site.ServiceUrl,
                        SiteUrl = site.SiteUrl,
                        SiteName = slug,
                        Created = DateTime.Now,
                        UniqueId = Guid.NewGuid()
                    };

                    if (appViewModel.RepositoryType != RepositoryType.None)
                    {
                        IRepositoryManager repositoryManager = GetRepositoryManager(app);
                        repositoryManager.CreateRepository(appViewModel.RepositoryType);
                    }

                    db.Applications.Add(app);
                    db.SaveChanges();

                    return RedirectToAction("Details", new { slug = slug });
                }
                catch (Exception ex)
                {
                    if (site != null)
                    {
                        _siteManager.DeleteSite(slug);
                    }

                    ModelState.AddModelError("__FORM", ex.Message);
                }
            }

            PopulateRepositoryTypes();
            return View(appViewModel);
        }
Пример #3
0
        public Task<ActionResult> Details(string slug)
        {
            IApplication application = _applicationService.GetApplication(slug);

            if (application == null)
            {
                return HttpNotFoundAsync();
            }

            ICredentials credentials = _credentialProvider.GetCredentials();
            return application.GetRepositoryInfo(credentials).Then(repositoryInfo =>
            {
                var appViewModel = new ApplicationViewModel(application);
                appViewModel.RepositoryInfo = repositoryInfo;

                ViewBag.slug = slug;
                ViewBag.tab = "settings";
                ViewBag.appName = appViewModel.Name;

                return (ActionResult)View(appViewModel);
            });
        }
Пример #4
0
        private async Task<ActionResult> GetApplicationView(string tab, string viewName, string slug)
        {
            var application = _applicationService.GetApplication(slug);

            ICredentials credentials = _credentialProvider.GetCredentials();
            var repositoryInfo = await application.GetRepositoryInfo(credentials);
            var appViewModel = new ApplicationViewModel(application, _settingsResolver);
            appViewModel.RepositoryInfo = repositoryInfo;

            ViewBag.slug = slug;
            ViewBag.tab = tab;
            ViewBag.appName = appViewModel.Name;
            ViewBag.siteBinding = String.Empty;

            ModelState.Clear();

            return View(viewName, appViewModel);
        }
Пример #5
0
        public ActionResult ViewSourceControl(string slug)
        {
            Application application = db.Applications.SingleOrDefault(a => a.Slug == slug);
            if (application != null) {
                var appViewModel = new ApplicationViewModel(application);
                appViewModel.RepositoryType = GetRepositoryManager(application).GetRepositoryType();

                return View(appViewModel);
            }

            return HttpNotFound();
        }
Пример #6
0
        public ActionResult Editor(string slug)
        {
            Application application = db.Applications.SingleOrDefault(a => a.Slug == slug);
            if (application == null)
            {
                return HttpNotFound();
            }

            var appViewModel = new ApplicationViewModel(application);
            var repositoryManager = GetRepositoryManager(application);
            var siteState = (DeveloperSiteState)application.DeveloperSiteState;
            RepositoryType repositoryType = repositoryManager.GetRepositoryType();

            if (application.DeveloperSiteUrl == null)
            {
                if (repositoryType != RepositoryType.None &&
                    siteState == DeveloperSiteState.None)
                {
                    // Set this flag so we know that we're in the state where we can
                    // create the developer site.
                    ViewBag.Clone = true;
                }

                appViewModel.RepositoryType = RepositoryType.None;
            }
            else
            {
                appViewModel.RepositoryType = repositoryType;
            }

            return View(appViewModel);
        }
Пример #7
0
        public Task<ActionResult> Index(string slug)
        {
            IApplication application = _applicationService.GetApplication(slug);

            if (application == null)
            {
                return HttpNotFoundAsync();
            }

            ICredentials credentials = _credentialProvider.GetCredentials();
            RemoteDeploymentManager deploymentManager = application.GetDeploymentManager(credentials);

            // TODO: Do this in parallel
            return deploymentManager.GetResultsAsync().Then(results =>
            {
                return application.GetRepositoryInfo(credentials).Then(repositoryInfo =>
                {
                    var appViewModel = new ApplicationViewModel(application);
                    appViewModel.RepositoryInfo = repositoryInfo;
                    appViewModel.Deployments = results.ToList();

                    ViewBag.slug = slug;
                    ViewBag.appName = appViewModel.Name;

                    return (ActionResult)View(appViewModel);
                });
            });
        }