public ActionResult NippsRestore(Models.Nipps nipps, string restore)
        {
            ViewBag.Title = Resources.Global.RestoreTitle;

            string restoreServiceUrl    = NippsSiteHelper.BuildDeploymentServiceUrl(nipps.HostName, "BackupService/RestoreApplication");
            NippsPackageRequest request = new NippsPackageRequest
            {
                NippsPackages = new List <NippsPackage>
                {
                    new NippsPackage
                    {
                        HostName            = nipps.HostName,
                        SiteName            = nipps.SiteName,
                        ApplicationName     = nipps.ApplicationName,
                        ApplicationPoolName = nipps.ApplicationPoolName,
                        PackageZIP          = restore
                    }
                }
            };

            NippsPackageResponse response = RestHelper.RestPostObject <NippsPackageResponse, NippsPackageRequest>(restoreServiceUrl, request);

            ViewBag.Result             = response.Result;
            ViewBag.ResultMessages     = response.ResultMessages;
            ViewBag.ReturnToAction     = ReturnToAction;
            ViewBag.ReturnToController = ReturnToController;
            ViewBag.Title = Resources.Global.RestoreTitle;

            return(View(NippsSiteHelper.ResultMessageView));
        }
        public ActionResult NippsBackup(Models.Nipps nipps)
        {
            ViewBag.Title = Resources.Global.BackupTitle;

            string backupServiceUrl           = NippsSiteHelper.BuildDeploymentServiceUrl(nipps.HostName, "BackupService/BackupApplication");
            NippsPackageRequest backupRequest = new NippsPackageRequest
            {
                NippsPackages = new List <NippsPackage>
                {
                    new NippsPackage
                    {
                        ApplicationName = nipps.ApplicationName,
                        SiteName        = nipps.SiteName,
                        HostName        = nipps.HostName
                    }
                }
            };

            NippsPackageResponse backupResponse = RestHelper.RestPostObject <NippsPackageResponse, NippsPackageRequest>(backupServiceUrl, backupRequest);

            ViewBag.Result             = backupResponse.Result;
            ViewBag.ResultMessages     = backupResponse.ResultMessages;
            ViewBag.ReturnToAction     = ReturnToAction;
            ViewBag.ReturnToController = ReturnToController;
            ViewBag.Title = Resources.Global.BackupTitle;

            return(View(NippsSiteHelper.ResultMessageView));
        }
        public ActionResult NippsUpgradeList(Models.Nipps nipps)
        {
            string upgradeServiceUrl    = NippsSiteHelper.BuildDeploymentServiceUrl(nipps.HostName, "BackupService/UpgradeApplicationList");
            NippsPackageRequest request = new NippsPackageRequest
            {
                NippsPackages = new List <NippsPackage>()
            };

            if (!String.IsNullOrEmpty(nipps.HostName))
            {
                request.NippsPackages.Add(new NippsPackage
                {
                    HostName        = nipps.HostName,
                    SiteName        = nipps.SiteName,
                    ApplicationName = nipps.ApplicationName
                });
            }

            NippsPackageResponse response = RestHelper.RestPostObject <NippsPackageResponse, NippsPackageRequest>(upgradeServiceUrl, request);

            ViewBag.ResultList = response.ResultMessages;
            SetViewBagResult(response, ViewBag);

            return(View(nipps));
        }
Exemple #4
0
        public ActionResult NippsUndeploy(Models.Nipps nipps)
        {
            ViewBag.ReturnToAction     = ReturnToAction;
            ViewBag.ReturnToController = ReturnToController;
            ViewBag.Title = Resources.Global.UndeployTitle;
            ViewBag.Name  = Resources.Global.Undeploy;

            try
            {
                //first, get and remove nippsmodule, do not care weather exist or not
                RemoveNippsModule(GetNippsModule(nipps));

                //then remove application
                NippsSite nippsSite = new NippsSite
                {
                    Name = nipps.SiteName,
                    NippsApplications = new List <NippsApplication> {
                        new NippsApplication {
                            Path = nipps.ApplicationName, PhysicalPath = nipps.PhysicalPath
                        }
                    }
                };

                string           svcUrl           = NippsSiteHelper.BuildDeploymentServiceUrl(nipps.HostName) + "RemoveNippsSite";
                NippsSiteRequest nippsSiteRequest = new NippsSiteRequest {
                    NippsSites = new List <NippsSite> {
                        nippsSite
                    }
                };
                NippsSiteResponse response = RestHelper.RestPostObject <NippsSiteResponse, NippsSiteRequest>(svcUrl, nippsSiteRequest);

                if (response.Result == Result.OK)
                {
                    return(RedirectToAction("NippsServiceList"));
                }

                SetViewBagResult(response, ViewBag);
            }
            catch (Exception ex)
            {
                Logger.Error("{0}: {1}", nipps, ex.ToString());
                SetViewBagResult(new NippsSiteResponse {
                    Result = Result.FAIL, ResultMessages = new List <string> {
                        ex.ToString()
                    }
                }, ViewBag);
            }

            return(View(NippsSiteHelper.ResultMessageView));
        }
Exemple #5
0
        public ActionResult NippsDeploy(HttpPostedFileBase PackageZIP, Models.Nipps nipps)
        {
            string deploymentServiceUrl = NippsSiteHelper.BuildDeploymentServiceUrl(nipps.HostName) + "AddSite";

            byte[] packageZipBuffer = new byte[PackageZIP.ContentLength];
            PackageZIP.InputStream.Read(packageZipBuffer, 0, PackageZIP.ContentLength);

            string b64Package = Convert.ToBase64String(packageZipBuffer);

            NippsPackageRequest nippsPackageRequest = new NippsPackageRequest
            {
                NippsPackages = new List <NippsPackage>
                {
                    new NippsPackage {
                        PackageZIP          = b64Package,
                        SiteName            = nipps.SiteName,
                        HostName            = nipps.HostName,
                        ApplicationPoolName = nipps.ApplicationPoolName,
                        ApplicationName     = nipps.ApplicationName
                    }
                }
            };

            NippsPackageResponse response = RestHelper.RestPostObject <NippsPackageResponse, NippsPackageRequest>(deploymentServiceUrl, nippsPackageRequest);

            if (response.Result == Result.OK)
            {
                return(RedirectToAction("NippsServiceList"));
            }

            foreach (String em in response.ResultMessages)
            {
                Logger.Error(em);
            }

            ViewBag.Result             = response.Result;
            ViewBag.ResultMessages     = response.ResultMessages;
            ViewBag.ReturnToAction     = ReturnToAction;
            ViewBag.ReturnToController = ReturnToController;
            ViewBag.Title = Resources.Global.DeployTitle;

            return(View(NippsSiteHelper.ResultMessageView));
        }
Exemple #6
0
        public ActionResult NippsStop(Models.Nipps nipps)
        {
            string deploymentServiceUrl = NippsSiteHelper.BuildDeploymentServiceUrl(nipps.HostName) + "StopApplicationPool";
            NippsApplicationRequest nippsApplicationRequest = new NippsApplicationRequest
            {
                NippsApplications = new List <NippsApplication> {
                    new NippsApplication {
                        ApplicationPoolName = nipps.ApplicationPoolName
                    }
                }
            };

            NippsApplicationResponse response = RestHelper.RestPostObject <NippsApplicationResponse, NippsApplicationRequest>(deploymentServiceUrl, nippsApplicationRequest);

            if (response.Result == Result.FAIL)
            {
                foreach (string em in response.ResultMessages)
                {
                    Logger.Error(em);
                }
            }

            return(RedirectToAction("NippsServiceList"));
        }