Ejemplo n.º 1
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");
        }
Ejemplo n.º 2
0
        public NippsApplicationResponse StopApplicationPool(NippsApplicationRequest nippsApplicationRequest)
        {
            bool isSucceededOne = false;
            Logger logger = NLog.LogManager.GetCurrentClassLogger();
            NippsApplicationResponse response = new NippsApplicationResponse();
            response.ResultMessages = new List<string>();

            try
            {
                using (ServerManager serverManager = ServerManager.OpenRemote("localhost"))
                {
                    response.Result = Result.OK;

                    foreach (NippsApplication nippsApplication in nippsApplicationRequest.NippsApplications)
                    {
                        try
                        {
                            ApplicationPool appPool = serverManager.ApplicationPools[nippsApplication.ApplicationPoolName];
                            if (appPool.State == ObjectState.Started)
                                appPool.Stop();
                            isSucceededOne = true;
                        }
                        catch (Exception ex)
                        {
                            if (isSucceededOne)
                                response.Result = Result.SUCCESSWITHWARN;
                            logger.Error("{0} -> {1}", nippsApplication, ex.ToString());
                            response.ResultMessages.Add(string.Format("{0} -> {1}", nippsApplication, ex.ToString()));
                        }

                    }

                    serverManager.CommitChanges();

                }

            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
                response.Result = Result.FAIL;
                response.ResultMessages.Add(ex.ToString());
            }

            return response;
        }