Exemple #1
0
        private void OnDeserialize()
        {
            movieDatabase = XmlProcessor.Deserialize <MovieDatabase>(txtXml.text);
            UpdateLog();

            btnSerialize.interactable = movieDatabase != null;
        }
        public WsMotorServiceResponse Validate(WsMotorRequest wsMotorRequest)
        {
            if (wsMotorRequest == null)
            {
                throw new ArgumentNullException(nameof(wsMotorRequest));
            }
            var mock = bool.Parse(ConfigurationManager.AppSettings.Get("Mock"));

            if (!mock)
            {
                try
                {
                    wsMotorRequest.Parameters.Parameter.Add(new Parameter
                    {
                        Name  = "STRAID",
                        Type  = "T",
                        Value = "2600"
                    });
                    wsMotorRequest.Parameters.Parameter.Add(new Parameter
                    {
                        Name  = "STRNAM",
                        Type  = "T",
                        Value = "SuperSymmetry"
                    });
                    var serialized   = _xmlProcessor.Serialize(wsMotorRequest);
                    var response     = executeStrategy(serialized);
                    var deserialized = _xmlProcessor.Deserialize <WsMotorServiceResponse>(response);
                    return(deserialized);
                }
                catch (Exception exception)
                {
                    var clientLog = new TelemetryClient();
                    clientLog.TrackException(exception);
                    return(new WsMotorServiceResponse
                    {
                        ScoresMotor = new ScoresMotor
                        {
                            ScoreMotor = new ScoreMotor
                            {
                                Type = "10",
                                Score = "0.0",
                                Classification = "N"
                            }
                        }
                    });
                }
            }
            return(new WsMotorServiceResponse
            {
                ScoresMotor = new ScoresMotor
                {
                    ScoreMotor = new ScoreMotor
                    {
                        Type = "10",
                        Score = "0.0",
                        Classification = "A"
                    }
                }
            });
        }
Exemple #3
0
        private void OnLoadAsset()
        {
            movieDatabase = XmlProcessor.Deserialize <MovieDatabase>(xmlAsset.text);
            UpdateLog();
            txtXml.text = xmlAsset.text;

            btnSerialize.interactable   = movieDatabase != null;
            btnDeserialize.interactable = !string.IsNullOrWhiteSpace(txtXml.text);
        }
Exemple #4
0
        public void TestDeserialize()
        {
            XmlProcessor processor = new XmlProcessor();

            PurchaseOrder po = processor.Deserialize <PurchaseOrder>(_purchaseOrderXml);

            po.Should().NotBeNull();
            po.ItemsOrders.Should().NotBeEmpty().And.HaveCount(3);
            po.OrderNumber.Should().Be("12345");
        }
        public void TestDeserialize()
        {
            XmlProcessor processor = new XmlProcessor();

            Invoice invoiceXml = processor.Deserialize <Invoice>(_invoiceXml);

            invoiceXml.Should().NotBeNull();
            invoiceXml.ItemsOrders.Should().NotBeEmpty().And.HaveCount(3);
            invoiceXml.InvoiceNumber.Should().Be("12345");
        }
Exemple #6
0
        public AnswerResponse AnswerQuestions(AnswerSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            try
            {
                settings.AnswerRequest.Identification = new Identification
                {
                    Number = settings.Identification,
                    Type   = settings.IdentificationType
                };

                var serialized = _xmlProcessor.Serialize(settings.AnswerRequest);

                var response = verificar(settings.Product, settings.ParamProduct, serialized);

                var deserialized = _xmlProcessor.Deserialize <AnswerResponse>(response);

                return(deserialized);
            }
            catch (Exception exception)
            {
                var clientLog = new TelemetryClient();
                clientLog.TrackException(exception);
                var consultationException =
                    _webSettingsConsultationSettingsBuilder.WithPayload(
                        JsonConvert.SerializeObject(new { Exception = exception }))
                    .WithExecutionId(settings.ExecutionId)
                    .WithTypeOfConsultation((int)TypeOfConsultation.CommunicationError)
                    .WithWebServiceName("Error consultando " + ServiceNameType.Answer.GetStringValue())
                    .Build();
                AddWebServiceConsultation(consultationException);

                return(new AnswerResponse {
                    Result = false
                });
            }
        }