// Token: 0x0600079F RID: 1951 RVA: 0x0001C338 File Offset: 0x0001A538
        internal static ResponseContent GetResponseInformation(string responseXml)
        {
            XmlDocument xmlDocument = new SafeXmlDocument();

            try
            {
                xmlDocument.LoadXml(responseXml);
            }
            catch (Exception innerException)
            {
                throw new PswsProxyException(Strings.PswsResponseIsnotXMLError(responseXml), innerException);
            }
            ResponseContent     responseContent        = new ResponseContent();
            XmlNamespaceManager pswsNamespaceManager   = ObjectTransfer.GetPswsNamespaceManager(xmlDocument);
            XmlElement          xmlElementMustExisting = ObjectTransfer.GetXmlElementMustExisting(xmlDocument, "/rt:entry/rt:content/m:properties", pswsNamespaceManager);

            responseContent.Id             = ObjectTransfer.GetChildXmlElementMustExisting(xmlElementMustExisting, "ID").InnerText;
            responseContent.Command        = ObjectTransfer.GetChildXmlElementMustExisting(xmlElementMustExisting, "Command").InnerText;
            responseContent.Status         = (ExecutionStatus)Enum.Parse(typeof(ExecutionStatus), ObjectTransfer.GetChildXmlElementMustExisting(xmlElementMustExisting, "Status").InnerText);
            responseContent.OutputXml      = ObjectTransfer.GetChildXmlElementMustExisting(xmlElementMustExisting, "Output").InnerText;
            responseContent.Error          = ObjectTransfer.GetErrorRecord(ObjectTransfer.GetChildXmlElementMustExisting(xmlElementMustExisting, "Errors"));
            responseContent.ExpirationTime = DateTime.Parse(ObjectTransfer.GetChildXmlElementMustExisting(xmlElementMustExisting, "ExpirationTime").InnerText);
            responseContent.WaitMsec       = int.Parse(ObjectTransfer.GetChildXmlElementMustExisting(xmlElementMustExisting, "WaitMsec").InnerText);
            return(responseContent);
        }
 // Token: 0x060007A3 RID: 1955 RVA: 0x0001C5B8 File Offset: 0x0001A7B8
 private static ResponseErrorDetail GetErrorDetails(XmlElement xmlElement)
 {
     return(new ResponseErrorDetail
     {
         Message = ObjectTransfer.GetChildXmlElementMustExisting(xmlElement, "Message").InnerText,
         RecommendedAction = ObjectTransfer.GetChildXmlElementMustExisting(xmlElement, "RecommendedAction").InnerText
     });
 }
        // Token: 0x060007A7 RID: 1959 RVA: 0x0001C694 File Offset: 0x0001A894
        private static XmlElement GetChildXmlElementMustExisting(XmlElement parentElement, string elementName)
        {
            XmlElement childXmlElement = ObjectTransfer.GetChildXmlElement(parentElement, elementName);

            if (childXmlElement == null)
            {
                throw new PswsProxyException(Strings.PswsResponseChildElementNotExisingError(parentElement.Name, elementName));
            }
            return(childXmlElement);
        }
 // Token: 0x060007A2 RID: 1954 RVA: 0x0001C534 File Offset: 0x0001A734
 private static ResponseCategoryInfo GetCategoryInfo(XmlElement xmlElement)
 {
     return(new ResponseCategoryInfo
     {
         Activity = ObjectTransfer.GetChildXmlElementMustExisting(xmlElement, "Activity").InnerText,
         Category = ObjectTransfer.GetChildXmlElementMustExisting(xmlElement, "Category").InnerText,
         Reason = ObjectTransfer.GetChildXmlElementMustExisting(xmlElement, "Reason").InnerText,
         TargetName = ObjectTransfer.GetChildXmlElementMustExisting(xmlElement, "TargetName").InnerText,
         TargetType = ObjectTransfer.GetChildXmlElementMustExisting(xmlElement, "TargetType").InnerText
     });
 }
        // Token: 0x060007A0 RID: 1952 RVA: 0x0001C450 File Offset: 0x0001A650
        internal static List <PSObject> GetResultObjects(string outputXml, TypeTable typeTable)
        {
            List <PSObject>    list = new List <PSObject>();
            PSObjectSerializer psobjectSerializer = new PSObjectSerializer(typeTable);

            foreach (string serializedData in ObjectTransfer.GetPSObjectSerializedData(outputXml))
            {
                list.Add(psobjectSerializer.Deserialize(serializedData));
            }
            return(list);
        }
Ejemplo n.º 6
0
        private static ResponseContent GetResponse(WebResponse response, out string responseXml)
        {
            ResponseContent responseInformation;

            using (StreamReader streamReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
            {
                responseXml         = streamReader.ReadToEnd();
                responseInformation = ObjectTransfer.GetResponseInformation(responseXml);
            }
            return(responseInformation);
        }
        // Token: 0x060007AA RID: 1962 RVA: 0x0001C97C File Offset: 0x0001AB7C
        private static IEnumerable <string> GetPSObjectSerializedData(string serializationData)
        {
            XmlDocument xmlDoc = new SafeXmlDocument();

            xmlDoc.LoadXml(serializationData);
            XmlNamespaceManager nsmgr          = ObjectTransfer.GetOutputNamespaceManager(xmlDoc);
            XmlElement          objectsElement = ObjectTransfer.GetXmlElementMustExisting(xmlDoc, "Objs", nsmgr);

            foreach (XmlElement objectElement in ObjectTransfer.GetChildXmlElements(objectsElement, "Obj"))
            {
                yield return(objectElement.OuterXml);
            }
            yield break;
        }
        // Token: 0x060007A1 RID: 1953 RVA: 0x0001C4B4 File Offset: 0x0001A6B4
        private static ResponseErrorRecord GetErrorRecord(XmlElement xmlElement)
        {
            XmlElement childXmlElement = ObjectTransfer.GetChildXmlElement(xmlElement, "element");

            if (childXmlElement == null)
            {
                return(null);
            }
            return(new ResponseErrorRecord
            {
                FullyQualifiedErrorId = ObjectTransfer.GetChildXmlElementMustExisting(childXmlElement, "FullyQualifiedErrorId").InnerText,
                CategoryInfo = ObjectTransfer.GetCategoryInfo(ObjectTransfer.GetChildXmlElementMustExisting(childXmlElement, "CategoryInfo")),
                ErrorDetail = ObjectTransfer.GetErrorDetails(ObjectTransfer.GetChildXmlElementMustExisting(childXmlElement, "ErrorDetails")),
                Exception = ObjectTransfer.GetChildXmlElementMustExisting(childXmlElement, "Exception").InnerText
            });
        }
Ejemplo n.º 9
0
        internal static IEnumerable <PSObject> Invoke(Guid cmdletUniqueId, string pswsServiceUri, string cmdletCommand, NetworkCredential credential, NameValueCollection headersTobeAdd, TypeTable typeTable)
        {
            CommandInvocation.CheckArgumentNull("pswsServiceUri", pswsServiceUri);
            CommandInvocation.CheckArgumentNull("cmdletCommand", cmdletCommand);
            CommandInvocation.CheckArgumentNull("credential", credential);
            int             tickCount = Environment.TickCount;
            string          value;
            string          value2;
            ResponseContent responseContent = CommandInvocation.CreateRequest(pswsServiceUri, cmdletCommand, credential, headersTobeAdd, out value, out value2);

            while (responseContent.Status == ExecutionStatus.Executing)
            {
                int num = Environment.TickCount - tickCount;
                if (num > 600000)
                {
                    throw new PswsProxyException(Strings.PswsInvocationTimout(600000));
                }
                Thread.Sleep(1000);
                responseContent = CommandInvocation.ResumeRequest(pswsServiceUri, responseContent.Id, credential, headersTobeAdd, out value2);
            }
            CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "TicksElapsed", (Environment.TickCount - tickCount).ToString());
            if (responseContent.Status == ExecutionStatus.Error)
            {
                CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "RequestXml", value);
                CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "ResponseXml", value2);
                StringBuilder stringBuilder = new StringBuilder();
                if (headersTobeAdd != null)
                {
                    foreach (string text in headersTobeAdd.AllKeys)
                    {
                        stringBuilder.Append(text);
                        stringBuilder.Append(':');
                        stringBuilder.Append(headersTobeAdd[text]);
                        stringBuilder.Append(' ');
                    }
                }
                CmdletLogger.SafeAppendGenericInfo(cmdletUniqueId, "RequestHeaders", stringBuilder.ToString());
                throw new PswsProxyCmdletException(responseContent.Error.Exception);
            }
            return(ObjectTransfer.GetResultObjects(responseContent.OutputXml, typeTable));
        }