예제 #1
0
        /// <summary>
        /// Deserializes a jobDetails creation result object from a payload string.
        /// </summary>
        /// <param name="payload">
        /// The payload.
        /// </param>
        /// <returns>
        /// A JobCreationResults object representing the payload.
        /// </returns>
        public JobCreationResults DeserializeJobCreationResults(string payload)
        {
            JobCreationResults results = new JobCreationResults();

            results.ErrorCode      = string.Empty;
            results.HttpStatusCode = HttpStatusCode.Accepted;
            XmlDocumentConverter documentConverter = new XmlDocumentConverter();
            var document = documentConverter.GetXmlDocument(payload);
            DynaXmlNamespaceTable nameTable = new DynaXmlNamespaceTable(document);
            var node = document.SelectSingleNode("//def:PassthroughResponse/def:Data", nameTable.NamespaceManager);

            results.JobId = node.InnerText;
            XmlElement error = (XmlElement)document.SelectSingleNode("//def:PassthroughResponse/def:Error", nameTable.NamespaceManager);

            if (error.IsNotNull())
            {
                var errorId = error.SelectSingleNode("//def:ErrorId", nameTable.NamespaceManager);
                if (errorId.IsNotNull())
                {
                    results.ErrorCode = errorId.InnerText;
                }
                var statusCode = error.SelectSingleNode("//def:StatusCode", nameTable.NamespaceManager);
                if (statusCode.IsNotNull())
                {
                    HttpStatusCode httpStatusCode = HttpStatusCode.Accepted;
                    if (HttpStatusCode.TryParse(statusCode.InnerText, out httpStatusCode))
                    {
                        results.HttpStatusCode = httpStatusCode;
                    }
                }
            }
            return(results);
        }
 /// <summary>
 /// Deserializes a jobDetails creation result object from a payload string.
 /// </summary>
 /// <param name="payload">
 /// The payload.
 /// </param>
 /// <returns>
 /// A JobCreationResults object representing the payload.
 /// </returns>
 public JobCreationResults DeserializeJobCreationResults(string payload)
 {
     JobCreationResults results = new JobCreationResults();
     results.ErrorCode = string.Empty;
     results.HttpStatusCode = HttpStatusCode.Accepted;
     XmlDocumentConverter documentConverter = new XmlDocumentConverter();
     var document = documentConverter.GetXmlDocument(payload);
     DynaXmlNamespaceTable nameTable = new DynaXmlNamespaceTable(document);
     var node = document.SelectSingleNode("//def:PassthroughResponse/def:Data", nameTable.NamespaceManager);
     results.JobId = node.InnerText;
     XmlElement error = (XmlElement)document.SelectSingleNode("//def:PassthroughResponse/def:Error", nameTable.NamespaceManager);
     if (error.IsNotNull())
     {
         var errorId = error.SelectSingleNode("//def:ErrorId", nameTable.NamespaceManager);
         if (errorId.IsNotNull())
         {
             results.ErrorCode = errorId.InnerText;
         }
         var statusCode = error.SelectSingleNode("//def:StatusCode", nameTable.NamespaceManager);
         if (statusCode.IsNotNull())
         {
             HttpStatusCode httpStatusCode = HttpStatusCode.Accepted;
             if (HttpStatusCode.TryParse(statusCode.InnerText, out httpStatusCode))
             {
                 results.HttpStatusCode = httpStatusCode;
             }
         }
     }
     return results;
 }
예제 #3
0
        /// <summary>
        /// Deserailzies a payload into a JobList.
        /// </summary>
        /// <param name="payload">
        /// The payload.
        /// </param>
        /// <returns>
        /// An JobList representing the payload.
        /// </returns>
        public JobList DeserializeJobList(string payload)
        {
            var     jobs    = new List <JobDetails>();
            JobList results = new JobList();
            XmlDocumentConverter documentConverter = new XmlDocumentConverter();
            var document = documentConverter.GetXmlDocument(payload);
            DynaXmlNamespaceTable nameTable = new DynaXmlNamespaceTable(document);
            var prefix = nameTable.GetPrefixesForNamespace("http://schemas.microsoft.com/2003/10/Serialization/Arrays").SingleOrDefault();

            if (prefix.IsNotNull())
            {
                var query = string.Format(CultureInfo.InvariantCulture, "//def:PassthroughResponse/def:Data/{0}:string", prefix);
                var nodes = document.SelectNodes(query, nameTable.NamespaceManager);
                foreach (XmlNode node in nodes)
                {
                    jobs.Add(new JobDetails()
                    {
                        JobId = node.InnerText
                    });
                }
            }
            results.ErrorCode      = string.Empty;
            results.HttpStatusCode = HttpStatusCode.Accepted;
            XmlElement error = (XmlElement)document.SelectSingleNode("//def:PassthroughResponse/def:Error", nameTable.NamespaceManager);

            if (error.IsNotNull())
            {
                var errorId = error.SelectSingleNode("//def:ErrorId", nameTable.NamespaceManager);
                if (errorId.IsNotNull())
                {
                    results.ErrorCode = errorId.InnerText;
                }
                var statusCode = error.SelectSingleNode("//def:StatusCode", nameTable.NamespaceManager);
                if (statusCode.IsNotNull())
                {
                    HttpStatusCode httpStatusCode = HttpStatusCode.Accepted;
                    if (HttpStatusCode.TryParse(statusCode.InnerText, out httpStatusCode))
                    {
                        results.HttpStatusCode = httpStatusCode;
                    }
                }
            }
            results.Jobs.AddRange(jobs);
            return(results);
        }
예제 #4
0
        /// <summary>
        /// Desterilizes the jobDetails details payload data.
        /// </summary>
        /// <param name="payload">
        /// The payload data returned from a server.
        /// </param>
        /// <param name="jobId">
        /// The jobId for the jobDetails requested.
        /// </param>
        /// <returns>
        /// A new JobDetails object representing the jobDetails.
        /// </returns>
        public JobDetails DeserializeJobDetails(string payload, string jobId)
        {
            JobDetails           retval            = new JobDetails();
            XmlDocumentConverter documentConverter = new XmlDocumentConverter();
            var document = documentConverter.GetXmlDocument(payload);
            DynaXmlNamespaceTable nameTable = new DynaXmlNamespaceTable(document);
            var query = "//def:PassthroughResponse/def:Data";
            var node  = document.SelectSingleNode(query, nameTable.NamespaceManager);

            if (node.IsNotNull())
            {
                foreach (XmlNode child in node.ChildNodes)
                {
                    XmlElement element = child as XmlElement;
                    if (element.IsNotNull())
                    {
                        switch (element.LocalName)
                        {
                        case "ErrorOutputPath":
                            retval.ErrorOutputPath = element.InnerText;
                            break;

                        case "ExitCode":
                            var errorCode = element.InnerText;
                            if (errorCode.IsNotNullOrEmpty())
                            {
                                int outCode;
                                if (int.TryParse(errorCode, NumberStyles.Integer, CultureInfo.InvariantCulture, out outCode))
                                {
                                    retval.ExitCode = outCode;
                                }
                            }
                            break;

                        case "LogicalOutputPath":
                            retval.LogicalOutputPath = element.InnerText;
                            break;

                        case "Name":
                            retval.Name = element.InnerText;
                            break;

                        case "PhysicalOutputPath":
                            retval.PhysicalOutputPath = element.InnerText;
                            break;

                        case "Query":
                            retval.Query = element.InnerText;
                            break;

                        case "StatusCode":
                            var statusCode = JobStatusCode.Unknown;
                            Assert.IsTrue(Enum.TryParse(element.InnerText, true, out statusCode));
                            retval.StatusCode = statusCode;
                            break;

                        case "SubmissionTime":
                            var submissionTime = element.InnerText;
                            if (submissionTime.IsNotNullOrEmpty())
                            {
                                long timeInTicks;
                                if (long.TryParse(submissionTime, NumberStyles.Integer, CultureInfo.InvariantCulture, out timeInTicks))
                                {
                                    retval.SubmissionTime = new DateTime(timeInTicks);
                                }
                            }
                            break;
                        }
                    }
                }
            }
            retval.ErrorCode      = string.Empty;
            retval.HttpStatusCode = HttpStatusCode.Accepted;
            XmlElement error = (XmlElement)document.SelectSingleNode("//def:PassthroughResponse/def:Error", nameTable.NamespaceManager);

            if (error.IsNotNull())
            {
                var errorId = error.SelectSingleNode("//def:ErrorId", nameTable.NamespaceManager);
                if (errorId.IsNotNull())
                {
                    retval.ErrorCode = errorId.InnerText;
                }
                var statusCode = error.SelectSingleNode("//def:StatusCode", nameTable.NamespaceManager);
                if (statusCode.IsNotNull())
                {
                    HttpStatusCode httpStatusCode = HttpStatusCode.Accepted;
                    if (HttpStatusCode.TryParse(statusCode.InnerText, out httpStatusCode))
                    {
                        retval.HttpStatusCode = httpStatusCode;
                    }
                }
            }
            retval.JobId = jobId;
            return(retval);
        }
예제 #5
0
 public void GivenIHaveTheXmlContentWith(string xml)
 {
     XmlDocumentConverter documentConverter = new XmlDocumentConverter();
     this.document = documentConverter.GetXmlDocument(xml);
 }
 /// <summary>
 /// Deserailzies a payload into a JobList.
 /// </summary>
 /// <param name="payload">
 /// The payload.
 /// </param>
 /// <returns>
 /// An JobList representing the payload.
 /// </returns>
 public JobList DeserializeJobList(string payload)
 {
     var jobs = new List<JobDetails>();
     JobList results = new JobList();
     XmlDocumentConverter documentConverter = new XmlDocumentConverter();
     var document = documentConverter.GetXmlDocument(payload);
     DynaXmlNamespaceTable nameTable = new DynaXmlNamespaceTable(document);
     var prefix = nameTable.GetPrefixesForNamespace("http://schemas.microsoft.com/2003/10/Serialization/Arrays").SingleOrDefault();
     if (prefix.IsNotNull())
     {
         var query = string.Format(CultureInfo.InvariantCulture, "//def:PassthroughResponse/def:Data/{0}:string", prefix);
         var nodes = document.SelectNodes(query, nameTable.NamespaceManager);
         foreach (XmlNode node in nodes)
         {
             jobs.Add(new JobDetails() { JobId = node.InnerText });
         }
     }
     results.ErrorCode = string.Empty;
     results.HttpStatusCode = HttpStatusCode.Accepted;
     XmlElement error = (XmlElement)document.SelectSingleNode("//def:PassthroughResponse/def:Error", nameTable.NamespaceManager);
     if (error.IsNotNull())
     {
         var errorId = error.SelectSingleNode("//def:ErrorId", nameTable.NamespaceManager);
         if (errorId.IsNotNull())
         {
             results.ErrorCode = errorId.InnerText;
         }
         var statusCode = error.SelectSingleNode("//def:StatusCode", nameTable.NamespaceManager);
         if (statusCode.IsNotNull())
         {
             HttpStatusCode httpStatusCode = HttpStatusCode.Accepted;
             if (HttpStatusCode.TryParse(statusCode.InnerText, out httpStatusCode))
             {
                 results.HttpStatusCode = httpStatusCode;
             }
         }
     }
     results.Jobs.AddRange(jobs);
     return results;
 }
 /// <summary>
 /// Desterilizes the jobDetails details payload data.
 /// </summary>
 /// <param name="payload">
 /// The payload data returned from a server.
 /// </param>
 /// <param name="jobId">
 /// The jobId for the jobDetails requested.
 /// </param>
 /// <returns>
 /// A new JobDetails object representing the jobDetails.
 /// </returns>
 public JobDetails DeserializeJobDetails(string payload, string jobId)
 {
     JobDetails retval = new JobDetails();
     XmlDocumentConverter documentConverter = new XmlDocumentConverter();
     var document = documentConverter.GetXmlDocument(payload);
     DynaXmlNamespaceTable nameTable = new DynaXmlNamespaceTable(document);
     var query = "//def:PassthroughResponse/def:Data";
     var node = document.SelectSingleNode(query, nameTable.NamespaceManager);
     if (node.IsNotNull())
     {
         foreach (XmlNode child in node.ChildNodes)
         {
             XmlElement element = child as XmlElement;
             if (element.IsNotNull())
             {
                 switch (element.LocalName)
                 {
                     case "ErrorOutputPath":
                         retval.ErrorOutputPath = element.InnerText;
                         break;
                     case "ExitCode":
                         var errorCode = element.InnerText;
                         if (errorCode.IsNotNullOrEmpty())
                         {
                             int outCode;
                             if (int.TryParse(errorCode, NumberStyles.Integer, CultureInfo.InvariantCulture, out outCode))
                             {
                                 retval.ExitCode = outCode;
                             }
                         }
                         break;
                     case "LogicalOutputPath":
                         retval.LogicalOutputPath = element.InnerText;
                         break;
                     case "Name":
                         retval.Name = element.InnerText;
                         break;
                     case "PhysicalOutputPath":
                         retval.PhysicalOutputPath = element.InnerText;
                         break;
                     case "Query":
                         retval.Query = element.InnerText;
                         break;
                     case "StatusCode":
                         JobStatusCode statusCode;
                         retval.StatusCode = Enum.TryParse(element.InnerText, true, out statusCode) ? statusCode : JobStatusCode.Unknown;
                         break;
                     case "SubmissionTime":
                         var submissionTime = element.InnerText;
                         if (submissionTime.IsNotNullOrEmpty())
                         {
                             long timeInTicks;
                             if (long.TryParse(submissionTime, NumberStyles.Integer, CultureInfo.InvariantCulture, out timeInTicks))
                             {
                                 retval.SubmissionTime = new DateTime(timeInTicks);
                             }
                         }
                         break;
                 }
             }
         }
     }
     retval.ErrorCode = string.Empty;
     retval.HttpStatusCode = HttpStatusCode.Accepted;
     XmlElement error = (XmlElement)document.SelectSingleNode("//def:PassthroughResponse/def:Error", nameTable.NamespaceManager);
     if (error.IsNotNull())
     {
         var errorId = error.SelectSingleNode("//def:ErrorId", nameTable.NamespaceManager);
         if (errorId.IsNotNull())
         {
             retval.ErrorCode = errorId.InnerText;
         }
         var statusCode = error.SelectSingleNode("//def:StatusCode", nameTable.NamespaceManager);
         if (statusCode.IsNotNull())
         {
             HttpStatusCode httpStatusCode = HttpStatusCode.Accepted;
             if (HttpStatusCode.TryParse(statusCode.InnerText, out httpStatusCode))
             {
                 retval.HttpStatusCode = httpStatusCode;
             }
         }
     }
     retval.JobId = jobId;
     return retval;
 }