Ejemplo n.º 1
0
        public JsonResult Status(string azure, string token)
        {
            string status = null;
            string xml    = "";

            try
            {
                dynamic az = (new JsonReader()).Read(azure);
                xml = AzureManagement.GetStatusUpdate(az.subscriptionId, CertificateBuilder.GetPrivateKey(az.key), token);
                XNamespace ns  = "http://schemas.microsoft.com/windowsazure";
                var        doc = XDocument.Parse(xml);
                var        op  = doc.Element(ns + "Operation");
                status = op.Element(ns + "Status").Value;
                if (status.ToLower().StartsWith("failed"))
                {
                    return(Json(new DeployStatusModel()
                    {
                        Status = DeployStatusModelStatus.Error,
                        Stage = ODPI.Resources.Controllers.DeployResource.Error,
                        LogMessage = xml
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new DeployStatusModel()
                {
                    Status = DeployStatusModelStatus.Error,
                    Stage = ODPI.Resources.Controllers.DeployResource.Error,
                    LogMessage = ex.Message,
                    StackTrace = ex.StackTrace,
                    Data = "xml: + " + xml + "\njson: " + azure
                }));
            }

            var ret = new DeployStatusModel()
            {
                Status     = status == "Succeeded" ? DeployStatusModelStatus.Ok : DeployStatusModelStatus.Inprogress,
                Stage      = ODPI.Resources.Controllers.DeployResource.DeployingApplication,
                LogMessage = StatusMessageConverter.Convert(status)
            };

            return(Json(ret));
        }
Ejemplo n.º 2
0
        public JsonResult DeployStatus(string azure, string token)
        {
            string status = null;

            try
            {
                dynamic    az  = (new JsonReader()).Read(azure);
                var        xml = AzureManagement.GetDeployStatusUpdate(az.subscriptionId, CertificateBuilder.GetPrivateKey(az.key), token);
                XDocument  doc = XDocument.Parse(xml);
                XNamespace ns  = "http://schemas.microsoft.com/windowsazure";
                status = doc.Descendants(ns + "RoleInstance").FirstOrDefault().Element(ns + "InstanceStatus").Value;
                if (status.ToLower().StartsWith("failed"))
                {
                    return(Json(new DeployStatusModel()
                    {
                        Status = DeployStatusModelStatus.Error,
                        Stage = ODPI.Resources.Controllers.DeployResource.Error,
                        LogMessage = xml
                    }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new DeployStatusModel()
                {
                    Status = DeployStatusModelStatus.Error,
                    Stage = ODPI.Resources.Controllers.DeployResource.Error,
                    LogMessage = ex.Message,
                    StackTrace = ex.StackTrace
                }));
            }

            var ret = new DeployStatusModel()
            {
                Status     = status == "ReadyRole" ? DeployStatusModelStatus.Ok : DeployStatusModelStatus.Inprogress,
                Stage      = ODPI.Resources.Controllers.DeployResource.DeployingApplication,
                LogMessage = StatusMessageConverter.Convert(status)
            };

            return(Json(ret));
        }