コード例 #1
0
        internal override void ParseXml()
        {
            if (base.ResponseXml != null)
            {
                bool   suc    = true;
                string result = string.Empty;
                XmlParse.SelectSingleNode(base.ResponseXml, "/", (c) =>
                {
                    result = c.InnerText;
                });
                if (string.IsNullOrEmpty(result))
                {
                    suc = false;
                }
                if (suc)
                {
                    base.ResultXML = new System.Xml.XmlDataDocument();
                    result         = result.Replace("xmlns=\"http://www.opentravel.org/OTA/2003/05\"", "");
                    base.ResultXML.LoadXml(result);
                    //System.Xml.XmlNamespaceManager mgr = new System.Xml.XmlNamespaceManager(base.ResultXML.NameTable);
                    //mgr.AddNamespace("ns", "http://www.opentravel.org/OTA/2003/05");

                    XmlParse.SelectSingleNode(base.ResultXML, "/Response/Header", (c) =>
                    {
                        this.Header = new HeaderInfo();
                        this.Header.ShouldRecordPerformanceTime = XmlParse.GetAttribute(c, "ShouldRecordPerformanceTime").ToBoolean();
                        string t = XmlParse.GetAttribute(c, "Timestamp");
                        if (t.Count((ch) => ch == ':') == 3)
                        {
                            int i = t.LastIndexOf(':');
                            t     = t.Remove(i) + "." + t.Substring(i + 1);
                        }
                        this.Header.Timestamp    = t.ToDateTime();
                        this.Header.ReferenceID  = XmlParse.GetAttribute(c, "ReferenceID");
                        this.Header.RecentlyTime = XmlParse.GetAttribute(c, "RecentlyTime").ToDateTime();
                        this.Header.AccessCount  = XmlParse.GetAttribute(c, "AccessCount");
                        this.Header.CurrentCount = XmlParse.GetAttribute(c, "CurrentCount");
                        this.Header.ResetTime    = XmlParse.GetAttribute(c, "ResetTime").ToDateTime();
                        this.Header.ResultCode   = XmlParse.GetAttribute(c, "ResultCode");
                        if (this.Header.ResultCode == "Fail")
                        {
                            this.Error         = new Error();
                            this.Error.Code    = this.Header.ResultCode;
                            this.Error.Type    = XmlParse.GetAttribute(c, "ResultNo");
                            this.Error.Message = XmlParse.GetAttribute(c, "ResultMsg");
                        }
                    });
                    XmlParse.SelectSingleNode(base.ResultXML, "/Response/HotelResponse/OTA_PingRS/Errors/Error", (c) =>
                    {
                        suc                = false;
                        base.Error         = new Error();
                        base.Error.Type    = XmlParse.GetAttribute(c, "Type");
                        base.Error.Code    = XmlParse.GetAttribute(c, "Code");
                        base.Error.Message = c.InnerText;
                    });

                    if (suc)
                    {
                        XmlParse.SelectSingleNode(base.ResultXML, "/Response/DomesticGetCtripOrderIDResponse/CtripOrderIDList", node =>
                        {
                            this.OrderMapInfos = new List <DomestictCtripOrderIDInfo>();
                            XmlParse.SelectNodes(node, "CtripOrderIDDetail", ns =>
                            {
                                foreach (System.Xml.XmlNode n in ns)
                                {
                                    DomestictCtripOrderIDInfo info = new DomestictCtripOrderIDInfo();
                                    XmlParse.SelectSingleNode(n, "DistributorOrderID", c => { info.DistributorOrderID = c.InnerText; });
                                    XmlParse.SelectSingleNode(n, "CtriporderID", c => { info.CtriporderID = c.InnerText; });
                                    this.OrderMapInfos.Add(info);
                                }
                            });
                        });
                    }
                }
            }
        }
コード例 #2
0
        internal void ParseXML2()
        {
            bool suc = true;

            XmlParse.SelectSingleNode(base.ResponseXml, "/Response/Header", (c) =>
            {
                this.Header = new HeaderInfo();
                this.Header.ShouldRecordPerformanceTime = XmlParse.GetAttribute(c, "ShouldRecordPerformanceTime").ToBoolean();
                string t = XmlParse.GetAttribute(c, "Timestamp");
                if (t.Count((ch) => ch == ':') == 3)
                {
                    int i = t.LastIndexOf(':');
                    t     = t.Remove(i) + "." + t.Substring(i + 1);
                }
                this.Header.Timestamp    = t.ToDateTime();
                this.Header.ReferenceID  = XmlParse.GetAttribute(c, "ReferenceID");
                this.Header.RecentlyTime = XmlParse.GetAttribute(c, "RecentlyTime").ToDateTime();
                this.Header.AccessCount  = XmlParse.GetAttribute(c, "AccessCount");
                this.Header.CurrentCount = XmlParse.GetAttribute(c, "CurrentCount");
                this.Header.ResetTime    = XmlParse.GetAttribute(c, "ResetTime").ToDateTime();
                this.Header.ResultCode   = XmlParse.GetAttribute(c, "ResultCode");
                if (this.Header.ResultCode == "Fail")
                {
                    this.Error         = new Error();
                    this.Error.Code    = this.Header.ResultCode;
                    this.Error.Type    = XmlParse.GetAttribute(c, "ResultNo");
                    this.Error.Message = XmlParse.GetAttribute(c, "ResultMsg");
                }
            });
            XmlParse.SelectSingleNode(base.ResponseXml, "/Response/HotelResponse/OTA_HotelResSaveRS/Errors/Error", (c) =>
            {
                suc                = false;
                base.Error         = new Error();
                base.Error.Type    = XmlParse.GetAttribute(c, "Type");
                base.Error.Code    = XmlParse.GetAttribute(c, "Code");
                base.Error.Message = c.InnerText;
            });
            XmlParse.SelectSingleNode(base.ResponseXml, "/Response/HotelResponse/OTA_HotelResSaveRS/Warnings/Warning", (c) =>
            {
                string type  = XmlParse.GetAttribute(c, "Type");
                string code  = XmlParse.GetAttribute(c, "Code");
                string warn  = c.InnerText;
                this.Warning = string.Format("{0} {1} {2}", type, code, warn);
            });
            if (suc)
            {
                XmlParse.SelectSingleNode(base.ResponseXml, "/Response/HotelResponse/OTA_HotelResSaveRS/HotelReservations/HotelReservation/ResGlobalInfo/HotelReservationIDs", (c) =>
                {
                    this.Order = new Ctrip.Entities.HotelReservation()
                    {
                        HotelReservationIDs = new List <HotelReservationID>()
                    };
                    XmlParse.SelectNodes(c, "HotelReservationID", ns =>
                    {
                        foreach (System.Xml.XmlNode node in ns)
                        {
                            HotelReservationID idInfo = new HotelReservationID();
                            idInfo.ResID_Type         = XmlParse.GetAttribute(node, "ResID_Type");
                            idInfo.ResID_Value        = XmlParse.GetAttribute(node, "ResID_Value");
                            if (idInfo.ResID_Type == "501")
                            {
                                this.CtripOrderId = idInfo.ResID_Value;
                            }
                            this.Order.HotelReservationIDs.Add(idInfo);
                        }
                    });
                });
            }
        }
コード例 #3
0
        internal override void ParseXml()
        {
            if (base.ResponseXml != null)
            {
                bool   suc    = true;
                string result = string.Empty;
                XmlParse.SelectSingleNode(base.ResponseXml, "/", (c) =>
                {
                    result = c.InnerText;
                });
                if (string.IsNullOrEmpty(result))
                {
                    suc = false;
                }
                if (suc)
                {
                    base.ResultXML = new System.Xml.XmlDataDocument();
                    result         = result.Replace("xmlns=\"http://www.opentravel.org/OTA/2003/05\"", "");
                    base.ResultXML.LoadXml(result);
                    //System.Xml.XmlNamespaceManager mgr = new System.Xml.XmlNamespaceManager(base.ResultXML.NameTable);
                    //mgr.AddNamespace("ns", "http://www.opentravel.org/OTA/2003/05");

                    XmlParse.SelectSingleNode(base.ResultXML, "/Response/Header", (c) =>
                    {
                        this.Header = new HeaderInfo();
                        this.Header.ShouldRecordPerformanceTime = XmlParse.GetAttribute(c, "ShouldRecordPerformanceTime").ToBoolean();
                        string t = XmlParse.GetAttribute(c, "Timestamp");
                        if (t.Count((ch) => ch == ':') == 3)
                        {
                            int i = t.LastIndexOf(':');
                            t     = t.Remove(i) + "." + t.Substring(i + 1);
                        }
                        this.Header.Timestamp    = t.ToDateTime();
                        this.Header.ReferenceID  = XmlParse.GetAttribute(c, "ReferenceID");
                        this.Header.RecentlyTime = XmlParse.GetAttribute(c, "RecentlyTime").ToDateTime();
                        this.Header.AccessCount  = XmlParse.GetAttribute(c, "AccessCount");
                        this.Header.CurrentCount = XmlParse.GetAttribute(c, "CurrentCount");
                        this.Header.ResetTime    = XmlParse.GetAttribute(c, "ResetTime").ToDateTime();
                        this.Header.ResultCode   = XmlParse.GetAttribute(c, "ResultCode");
                        if (this.Header.ResultCode == "Fail")
                        {
                            this.Error         = new Error();
                            this.Error.Code    = this.Header.ResultCode;
                            this.Error.Type    = XmlParse.GetAttribute(c, "ResultNo");
                            this.Error.Message = XmlParse.GetAttribute(c, "ResultMsg");
                        }
                    });
                    XmlParse.SelectSingleNode(base.ResultXML, "/Response/HotelResponse/OTA_HotelResSaveRS/Errors/Error", (c) =>
                    {
                        suc                = false;
                        base.Error         = new Error();
                        base.Error.Type    = XmlParse.GetAttribute(c, "Type");
                        base.Error.Code    = XmlParse.GetAttribute(c, "Code");
                        base.Error.Message = c.InnerText;
                    });
                    XmlParse.SelectSingleNode(base.ResultXML, "/Response/HotelResponse/OTA_HotelResSaveRS/Warnings/Warning", (c) =>
                    {
                        string type  = XmlParse.GetAttribute(c, "Type");
                        string code  = XmlParse.GetAttribute(c, "Code");
                        string warn  = c.InnerText;
                        this.Warning = string.Format("{0} {1} {2}", type, code, warn);
                    });
                    if (suc)
                    {
                    }
                }
            }
        }
コード例 #4
0
        internal override void ParseXml()
        {
            if (base.ResponseXml != null)
            {
                bool   suc    = true;
                string result = string.Empty;
                XmlParse.SelectSingleNode(base.ResponseXml, "/", (c) =>
                {
                    result = c.InnerText;
                });
                if (string.IsNullOrEmpty(result))
                {
                    suc = false;
                }
                if (suc)
                {
                    base.ResultXML = new System.Xml.XmlDataDocument();
                    result         = result.Replace("xmlns=\"http://www.opentravel.org/OTA/2003/05\"", "");
                    base.ResultXML.LoadXml(result);
                    //System.Xml.XmlNamespaceManager mgr = new System.Xml.XmlNamespaceManager(base.ResultXML.NameTable);
                    //mgr.AddNamespace("ns", "http://www.opentravel.org/OTA/2003/05");

                    XmlParse.SelectSingleNode(base.ResultXML, "/Response/Header", (c) =>
                    {
                        this.Header = new HeaderInfo();
                        this.Header.ShouldRecordPerformanceTime = XmlParse.GetAttribute(c, "ShouldRecordPerformanceTime").ToBoolean();
                        string t = XmlParse.GetAttribute(c, "Timestamp");
                        if (t.Count((ch) => ch == ':') == 3)
                        {
                            int i = t.LastIndexOf(':');
                            t     = t.Remove(i) + "." + t.Substring(i + 1);
                        }
                        this.Header.Timestamp    = t.ToDateTime();
                        this.Header.ReferenceID  = XmlParse.GetAttribute(c, "ReferenceID");
                        this.Header.RecentlyTime = XmlParse.GetAttribute(c, "RecentlyTime").ToDateTime();
                        this.Header.AccessCount  = XmlParse.GetAttribute(c, "AccessCount");
                        this.Header.CurrentCount = XmlParse.GetAttribute(c, "CurrentCount");
                        this.Header.ResetTime    = XmlParse.GetAttribute(c, "ResetTime").ToDateTime();
                        this.Header.ResultCode   = XmlParse.GetAttribute(c, "ResultCode");
                        if (this.Header.ResultCode == "Fail")
                        {
                            this.Error         = new Error();
                            this.Error.Code    = this.Header.ResultCode;
                            this.Error.Type    = XmlParse.GetAttribute(c, "ResultNo");
                            this.Error.Message = XmlParse.GetAttribute(c, "ResultMsg");
                        }
                    });
                    XmlParse.SelectSingleNode(base.ResultXML, "/Response/HotelResponse/OTA_HotelAvailRS/Errors/Error", (c) =>
                    {
                        suc                = false;
                        base.Error         = new Error();
                        base.Error.Type    = XmlParse.GetAttribute(c, "Type");
                        base.Error.Code    = XmlParse.GetAttribute(c, "Code");
                        base.Error.Message = c.InnerText;
                    });

                    //if (suc)
                    {
                        XmlParse.SelectSingleNode(base.ResultXML, "/Response/HotelResponse/OTA_HotelAvailRS/RoomStays/RoomStay", node =>
                        {
                            this.AvailabilityStatus = XmlParse.GetAttribute(node, "AvailabilityStatus");
                            RoomStay = new VxRoomStay();

                            XmlParse.SelectNodes(node, "RoomTypes/RoomType", (r_x) =>
                            {
                                if (RoomStay.RoomTypes == null)
                                {
                                    RoomStay.RoomTypes = new List <VxRoomType>();
                                }
                                foreach (System.Xml.XmlNode tpx in r_x)
                                {
                                    VxRoomType ve   = new VxRoomType();
                                    ve.RoomType     = XmlParse.GetAttribute(tpx, "RoomType");;
                                    ve.RoomTypeCode = XmlParse.GetAttribute(tpx, "RoomTypeCode");
                                    RoomStay.RoomTypes.Add(ve);
                                }
                            });

                            XmlParse.SelectNodes(node, "RatePlans/RatePlan", (r_x) =>
                            {
                                if (RoomStay.RatePlans == null)
                                {
                                    RoomStay.RatePlans = new List <VxRatePlan>();
                                }
                                foreach (System.Xml.XmlNode tpx in r_x)
                                {
                                    VxRatePlan ve        = new VxRatePlan();
                                    ve.RatePlanCode      = XmlParse.GetAttribute(tpx, "RatePlanCode");
                                    ve.RatePlanName      = XmlParse.GetAttribute(tpx, "RatePlanName");
                                    ve.AvailableQuantity = Convert.ToInt32(XmlParse.GetAttribute(tpx, "AvailableQuantity"));
                                    ve.PrepaidIndicator  = Convert.ToBoolean(XmlParse.GetAttribute(tpx, "PrepaidIndicator"));
                                    ve.IsInstantConfirm  = Convert.ToBoolean(XmlParse.GetAttribute(tpx, "IsInstantConfirm"));
                                    ve.InvoiceTargetType = Convert.ToInt32(XmlParse.GetAttribute(tpx, "InvoiceTargetType"));
                                    ve.SupplierID        = Convert.ToInt32(XmlParse.GetAttribute(tpx, "SupplierID"));
                                    XmlParse.SelectSingleNode(tpx, "MealsIncluded ", (bk) =>
                                    {
                                        ve.Breakfast = Convert.ToBoolean(XmlParse.GetAttribute(bk, "Breakfast"));
                                    });
                                    RoomStay.RatePlans.Add(ve);
                                }
                            });

                            XmlParse.SelectNodes(node, "RoomRates/RoomRate", (r_x) =>
                            {
                                if (RoomStay.RoomRates == null)
                                {
                                    RoomStay.RoomRates = new List <VxRoomRate>();
                                }
                                foreach (System.Xml.XmlNode tpx in r_x)
                                {
                                    VxRoomRate ve   = new VxRoomRate();
                                    ve.RoomTypeCode = XmlParse.GetAttribute(tpx, "RoomTypeCode");
                                    ve.RatePlanCode = XmlParse.GetAttribute(tpx, "RatePlanCode");
                                    XmlParse.SelectNodes(tpx, "Rates/Rate", (_prate) =>
                                    {
                                        if (ve.Rates == null)
                                        {
                                            ve.Rates = new List <VxRate>();
                                        }
                                        foreach (System.Xml.XmlNode xra in _prate)
                                        {
                                            VxRate _rm             = new VxRate();
                                            _rm.EffectiveDate      = XmlParse.GetAttribute(xra, "EffectiveDate");
                                            _rm.ExpireDate         = XmlParse.GetAttribute(xra, "ExpireDate");
                                            _rm.MaxGuestApplicable = Convert.ToInt32(XmlParse.GetAttribute(xra, "MaxGuestApplicable"));
                                            XmlParse.SelectSingleNode(xra, "MealsIncluded", (prx) =>
                                            {
                                                _rm.NumberOfBreakfast = Convert.ToInt32(XmlParse.GetAttribute(prx, "NumberOfBreakfast"));
                                            });
                                            XmlParse.SelectSingleNode(xra, "Base", (prx) =>
                                            {
                                                _rm.AmountBeforeTax = Convert.ToDecimal(XmlParse.GetAttribute(prx, "AmountBeforeTax"));
                                                _rm.CurrencyCode    = XmlParse.GetAttribute(prx, "CurrencyCode");
                                                if (_rm.CurrencyCode != "CNY")
                                                {
                                                    XmlParse.SelectSingleNode(prx, "TPA_Extensions/OtherCurrency/AmountPercentType", other =>
                                                    {
                                                        decimal price = XmlParse.GetAttribute(other, "Amount").ToDecimal();
                                                        string code   = XmlParse.GetAttribute(other, "CurrencyCode").ToString();
                                                        if (code == "CNY")
                                                        {
                                                            _rm.AmountBeforeTax = price;
                                                            _rm.CurrencyCode    = code;
                                                        }
                                                    });
                                                }
                                            });

                                            ///结算价节点
                                            XmlParse.SelectSingleNode(xra, "TPA_Extensions/Cost", (prx) =>
                                            {
                                                _rm.Cost             = Convert.ToDecimal(XmlParse.GetAttribute(prx, "Amount"));
                                                _rm.CostCurrencyCode = XmlParse.GetAttribute(prx, "CurrencyCode");
                                                if (_rm.CostCurrencyCode != "CNY")
                                                {
                                                    XmlParse.SelectSingleNode(prx, "OtherCurrency/AmountPercentType", other =>
                                                    {
                                                        decimal price = XmlParse.GetAttribute(other, "Amount").ToDecimal();
                                                        string code   = XmlParse.GetAttribute(other, "CurrencyCode").ToString();
                                                        if (code == "CNY")
                                                        {
                                                            _rm.Cost             = price;
                                                            _rm.CostCurrencyCode = code;
                                                        }
                                                    });
                                                }
                                            });


                                            XmlParse.SelectNodes(xra, "Fees/Fee", (prx) =>
                                            {
                                                if (_rm.Fees == null)
                                                {
                                                    _rm.Fees = new List <VxFee>();
                                                }
                                                foreach (System.Xml.XmlNode ftx in prx)
                                                {
                                                    VxFee fg        = new VxFee();
                                                    fg.Amount       = Convert.ToDecimal(XmlParse.GetAttribute(ftx, "Amount"));
                                                    fg.ChargeUnit   = Convert.ToDecimal(XmlParse.GetAttribute(ftx, "ChargeUnit"));
                                                    fg.Code         = XmlParse.GetAttribute(ftx, "Code");
                                                    fg.CurrencyCode = XmlParse.GetAttribute(ftx, "CurrencyCode");
                                                    XmlParse.SelectSingleNode(ftx, "Description/Text", (ttx) =>
                                                    {
                                                        fg.Description = ttx.Value;
                                                    });
                                                    _rm.Fees.Add(fg);
                                                }
                                            });

                                            ve.Rates.Add(_rm);
                                        }
                                    });
                                    RoomStay.RoomRates.Add(ve);
                                }
                            });

                            XmlParse.SelectNodes(node, "BasicPropertyInfo/VendorMessages/VendorMessage", (r_x) =>
                            {
                                try
                                {
                                    if (RoomStay.VendorMessages == null)
                                    {
                                        RoomStay.VendorMessages = new List <string>();
                                    }
                                    foreach (System.Xml.XmlNode tpx in r_x)
                                    {
                                        string tlt = XmlParse.GetAttribute(tpx, "Title");
                                        if (tlt == "酒店提示")
                                        {
                                            XmlParse.SelectNodes(tpx, "SubSection", (txs) =>
                                            {
                                                foreach (System.Xml.XmlNode tl in txs)
                                                {
                                                    var tst = tl.SelectSingleNode("Paragraph/Text");
                                                    if (tst != null && !string.IsNullOrEmpty(tst.InnerText))
                                                    {
                                                        RoomStay.VendorMessages.Add(tst.InnerText);
                                                    }
                                                }
                                            });
                                        }
                                    }
                                }
                                catch { }
                            });


                            XmlParse.SelectSingleNode(node, "CancelPenalties/CancelPenalty", can =>
                            {
                                this.CancelRule       = new CancelPenalty();
                                this.CancelRule.Start = XmlParse.GetAttribute(can, "Start").ToDateTime();
                                this.CancelRule.End   = XmlParse.GetAttribute(can, "End").ToDateTime();
                                XmlParse.SelectSingleNode(can, "AmountPercent", am =>
                                {
                                    this.CancelRule.Amount       = XmlParse.GetAttribute(am, "Amount").ToDecimal();
                                    this.CancelRule.CurrencyCode = XmlParse.GetAttribute(am, "CurrencyCode");
                                });
                            });
                            XmlParse.SelectSingleNode(node, "Total", tn =>
                            {
                                this.AmountBeforeTax = XmlParse.GetAttribute(tn, "AmountBeforeTax").ToDecimal();
                                this.CurrencyCode    = XmlParse.GetAttribute(tn, "CurrencyCode").ToString();
                                if (this.CurrencyCode != "CNY")
                                {
                                    XmlParse.SelectSingleNode(tn, "TPA_Extensions/OtherCurrency/AmountPercentType", other =>
                                    {
                                        decimal price = XmlParse.GetAttribute(other, "Amount").ToDecimal();
                                        string code   = XmlParse.GetAttribute(other, "CurrencyCode").ToString();
                                        if (code == "CNY")
                                        {
                                            this.AmountBeforeTax = price;
                                            this.CurrencyCode    = code;
                                        }
                                    });
                                }
                            });
                        });
                    }
                }
            }
        }
コード例 #5
0
        internal override void ParseXml()
        {
            if (base.ResponseXml != null)
            {
                bool   suc    = true;
                string result = string.Empty;
                XmlParse.SelectSingleNode(base.ResponseXml, "/", (c) =>
                {
                    result = c.InnerText;
                });
                if (string.IsNullOrEmpty(result))
                {
                    suc = false;
                }
                if (suc)
                {
                    base.ResultXML = new System.Xml.XmlDataDocument();
                    result         = result.Replace("xmlns=\"http://www.opentravel.org/OTA/2003/05\"", "");
                    base.ResultXML.LoadXml(result);
                    //System.Xml.XmlNamespaceManager mgr = new System.Xml.XmlNamespaceManager(base.ResultXML.NameTable);
                    //mgr.AddNamespace("ns", "http://www.opentravel.org/OTA/2003/05");

                    XmlParse.SelectSingleNode(base.ResultXML, "/Response/Header", (c) =>
                    {
                        this.Header = new HeaderInfo();
                        this.Header.ShouldRecordPerformanceTime = XmlParse.GetAttribute(c, "ShouldRecordPerformanceTime").ToBoolean();
                        string t = XmlParse.GetAttribute(c, "Timestamp");
                        if (t.Count((ch) => ch == ':') == 3)
                        {
                            int i = t.LastIndexOf(':');
                            t     = t.Remove(i) + "." + t.Substring(i + 1);
                        }
                        this.Header.Timestamp    = t.ToDateTime();
                        this.Header.ReferenceID  = XmlParse.GetAttribute(c, "ReferenceID");
                        this.Header.RecentlyTime = XmlParse.GetAttribute(c, "RecentlyTime").ToDateTime();
                        this.Header.AccessCount  = XmlParse.GetAttribute(c, "AccessCount");
                        this.Header.CurrentCount = XmlParse.GetAttribute(c, "CurrentCount");
                        this.Header.ResetTime    = XmlParse.GetAttribute(c, "ResetTime").ToDateTime();
                        this.Header.ResultCode   = XmlParse.GetAttribute(c, "ResultCode");
                        if (this.Header.ResultCode == "Fail")
                        {
                            this.Error         = new Error();
                            this.Error.Code    = this.Header.ResultCode;
                            this.Error.Type    = XmlParse.GetAttribute(c, "ResultNo");
                            this.Error.Message = XmlParse.GetAttribute(c, "ResultMsg");
                        }
                    });
                    XmlParse.SelectSingleNode(base.ResultXML, "/Response/HotelResponse/OTA_PingRS/Errors/Error", (c) =>
                    {
                        suc                = false;
                        base.Error         = new Error();
                        base.Error.Type    = XmlParse.GetAttribute(c, "Type");
                        base.Error.Code    = XmlParse.GetAttribute(c, "Code");
                        base.Error.Message = c.InnerText;
                    });

                    if (suc)
                    {
                        XmlParse.SelectSingleNode(base.ResultXML, "/Response/HotelOrderMiniInfoResponse", node =>
                        {
                            this.MiniInfo = new HotelOrderMiniInfo();
                            XmlParse.SelectSingleNode(node, "AllianceId", n => { this.MiniInfo.AllianceId = n.InnerText; });
                            XmlParse.SelectSingleNode(node, "Sid", n => { this.MiniInfo.Sid = n.InnerText; });
                            XmlParse.SelectSingleNode(node, "Ouid", n => { this.MiniInfo.Ouid = n.InnerText; });
                            XmlParse.SelectSingleNode(node, "OrderId", n => { this.MiniInfo.OrderId = n.InnerText; });
                            XmlParse.SelectSingleNode(node, "HotelId", n => { this.MiniInfo.HotelId = n.InnerText; });
                            XmlParse.SelectSingleNode(node, "HotelName", n => { this.MiniInfo.HotelName = n.InnerText; });
                            XmlParse.SelectSingleNode(node, "FromOrderId", n => { this.MiniInfo.FromOrderId = n.InnerText; });
                            XmlParse.SelectSingleNode(node, "OrderStatus", n => { this.MiniInfo.OrderStatus = n.InnerText; });
                            XmlParse.SelectSingleNode(node, "Price", n => { this.MiniInfo.Price = n.InnerText.ToDecimal(); });
                            XmlParse.SelectSingleNode(node, "Quantity", n => { this.MiniInfo.Quantity = n.InnerText.ToInt32(); });
                            XmlParse.SelectSingleNode(node, "OrderDate", n => { this.MiniInfo.OrderDate = n.InnerText.ToDateTime(); });
                            XmlParse.SelectSingleNode(node, "CheckInDate", n => { this.MiniInfo.CheckInDate = n.InnerText.ToDateTime(); });
                            XmlParse.SelectSingleNode(node, "CheckOutDate", n => { this.MiniInfo.CheckOutDate = n.InnerText.ToDateTime(); });
                        });
                    }
                }
            }
        }
コード例 #6
0
        internal override void ParseXml()
        {
            if (base.ResponseXml != null)
            {
                bool   suc    = true;
                string result = string.Empty;
                XmlParse.SelectSingleNode(base.ResponseXml, "/", (c) =>
                {
                    result = c.InnerText;
                });
                if (string.IsNullOrEmpty(result))
                {
                    suc = false;
                }
                if (suc)
                {
                    base.ResultXML = new System.Xml.XmlDataDocument();
                    result         = result.Replace("xmlns=\"http://www.opentravel.org/OTA/2003/05\"", "");
                    base.ResultXML.LoadXml(result);
                    //System.Xml.XmlNamespaceManager mgr = new System.Xml.XmlNamespaceManager(base.ResultXML.NameTable);
                    //mgr.AddNamespace("ns", "http://www.opentravel.org/OTA/2003/05");

                    XmlParse.SelectSingleNode(base.ResultXML, "/Response/Header", (c) =>
                    {
                        this.Header = new HeaderInfo();
                        this.Header.ShouldRecordPerformanceTime = XmlParse.GetAttribute(c, "ShouldRecordPerformanceTime").ToBoolean();
                        string t = XmlParse.GetAttribute(c, "Timestamp");
                        if (t.Count((ch) => ch == ':') == 3)
                        {
                            int i = t.LastIndexOf(':');
                            t     = t.Remove(i) + "." + t.Substring(i + 1);
                        }
                        this.Header.Timestamp    = t.ToDateTime();
                        this.Header.ReferenceID  = XmlParse.GetAttribute(c, "ReferenceID");
                        this.Header.RecentlyTime = XmlParse.GetAttribute(c, "RecentlyTime").ToDateTime();
                        this.Header.AccessCount  = XmlParse.GetAttribute(c, "AccessCount");
                        this.Header.CurrentCount = XmlParse.GetAttribute(c, "CurrentCount");
                        this.Header.ResetTime    = XmlParse.GetAttribute(c, "ResetTime").ToDateTime();
                        this.Header.ResultCode   = XmlParse.GetAttribute(c, "ResultCode");
                        if (this.Header.ResultCode == "Fail")
                        {
                            base.Error         = new Error();
                            base.Error.Code    = this.Header.ResultCode;
                            base.Error.Type    = XmlParse.GetAttribute(c, "ResultNo");
                            base.Error.Message = XmlParse.GetAttribute(c, "ResultMsg");
                        }
                    });
                    XmlParse.SelectSingleNode(base.ResultXML, "/Response/HotelResponse/OTA_ResRetrieveRS/Errors/Error", (c) =>
                    {
                        suc                = false;
                        base.Error         = new Error();
                        base.Error.Type    = XmlParse.GetAttribute(c, "Type");
                        base.Error.Code    = XmlParse.GetAttribute(c, "Code");
                        base.Error.Message = c.InnerText;
                    });

                    if (suc)
                    {
                        XmlParse.SelectSingleNode(base.ResultXML, "/Response/HotelResponse/OTA_ResRetrieveRS/ReservationsList", node =>
                        {
                            XmlParse.SelectNodes(node, "HotelReservation", ons =>
                            {
                                foreach (System.Xml.XmlNode on in ons)
                                {
                                    HotelReservation order   = new HotelReservation();
                                    order.CreateDateTime     = XmlParse.GetAttribute(on, "CreateDateTime").ToDateTime();
                                    order.CreatorID          = XmlParse.GetAttribute(on, "CreatorID");
                                    order.LastModifyDateTime = XmlParse.GetAttribute(on, "LastModifyDateTime").ToDateTime();
                                    order.LastModifierID     = XmlParse.GetAttribute(on, "LastModifierID");
                                    order.ResStatus          = XmlParse.GetAttribute(on, "ResStatus");
                                    order.OrderStatus        = XmlParse.GetAttribute(on, "OrderStatus");
                                    XmlParse.SelectNodes(on, "UniqueID", uids =>
                                    {
                                        foreach (System.Xml.XmlNode uid in uids)
                                        {
                                            string type = XmlParse.GetAttribute(uid, "Type");
                                            string id   = XmlParse.GetAttribute(uid, "ID");
                                            if (type == "501")
                                            {
                                                order.CtripOrderId = id;
                                                continue;
                                            }
                                        }
                                    });
                                    XmlParse.SelectSingleNode(on, "RoomStays/RoomStay", room =>
                                    {
                                        XmlParse.SelectSingleNode(room, "RoomTypes/RoomType", rt =>
                                        {
                                            order.NumberOfUnits = XmlParse.GetAttribute(rt, "NumberOfUnits").ToInt32();
                                            order.RoomTypeCode  = XmlParse.GetAttribute(rt, "RoomTypeCode");
                                        });
                                        XmlParse.SelectSingleNode(room, "RatePlans/RatePlan", plan =>
                                        {
                                            order.RatePlanCode = XmlParse.GetAttribute(plan, "RatePlanCode");
                                            XmlParse.SelectNodes(plan, "AdditionalDetails/AdditionalDetail", adds =>
                                            {
                                                order.AdditionalDetails = new List <AdditionalDetail>();
                                                foreach (System.Xml.XmlNode add in adds)
                                                {
                                                    AdditionalDetail d = new AdditionalDetail();
                                                    d.Type             = XmlParse.GetAttribute(add, "Type");
                                                    d.Code             = XmlParse.GetAttribute(add, "Code");
                                                    XmlParse.SelectNodes(add, "DetailDescription/Text", tns =>
                                                    {
                                                        d.Texts = new List <string>();
                                                        foreach (System.Xml.XmlNode tn in tns)
                                                        {
                                                            d.Texts.Add(tn.InnerText);
                                                        }
                                                    });
                                                    order.AdditionalDetails.Add(d);
                                                }
                                            });
                                        });
                                        XmlParse.SelectSingleNode(room, "BasicPropertyInfo", info =>
                                        {
                                            XmlParse.SelectSingleNode(info, "Address", c =>
                                            {
                                                XmlParse.SelectSingleNode(c, "AddressLine", a => { order.Address = a.InnerText; });
                                                XmlParse.SelectSingleNode(c, "CityName", a => { order.CityName = a.InnerText; });
                                                XmlParse.SelectSingleNode(c, "PostalCode", a => { order.PostalCode = a.InnerText; });
                                            });
                                            XmlParse.SelectSingleNode(info, "ContactNumbers", con =>
                                            {
                                                XmlParse.SelectNodes(con, "ContactNumber", nums =>
                                                {
                                                    foreach (System.Xml.XmlNode num in nums)
                                                    {
                                                        string type = XmlParse.GetAttribute(num, "PhoneTechType");
                                                        string tel  = XmlParse.GetAttribute(num, "PhoneNumber");
                                                        if (type == "Data" || type == "Voice")
                                                        {
                                                            order.Tel = tel;
                                                        }
                                                        else if (type == "Fax")
                                                        {
                                                            order.Fax = tel;
                                                        }
                                                    }
                                                });
                                            });
                                        });
                                    });
                                    XmlParse.SelectSingleNode(on, "BillingInstructionCode", bill =>
                                    {
                                        order.BillingCode = XmlParse.GetAttribute(bill, "BillingCode");
                                    });
                                    XmlParse.SelectSingleNode(on, "ResGuests/ResGuest", guest =>
                                    {
                                        order.ArrivalTime = XmlParse.GetAttribute(guest, "ArrivalTime");
                                        XmlParse.SelectSingleNode(guest, "Profiles/ProfileInfo/Profile/Customer", cus =>
                                        {
                                            XmlParse.SelectNodes(cus, "PersonName", gns =>
                                            {
                                                order.CustomerNames = new List <string>();
                                                foreach (System.Xml.XmlNode gn in gns)
                                                {
                                                    XmlParse.SelectSingleNode(gn, "Surname", name => { order.CustomerNames.Add(name.InnerText); });
                                                }
                                            });
                                            XmlParse.SelectSingleNode(cus, "ContactPerson", con =>
                                            {
                                                order.ContactType = XmlParse.GetAttribute(con, "ContactType");
                                                XmlParse.SelectSingleNode(con, "PersonName/Surname", name => { order.ContactName = name.InnerText; });
                                                XmlParse.SelectSingleNode(con, "Telephone", tel =>
                                                {
                                                    string type         = XmlParse.GetAttribute(tel, "PhoneTechType");
                                                    order.ContactNumber = XmlParse.GetAttribute(tel, "PhoneNumber");
                                                    XmlParse.SelectSingleNode(tel, "Email", em => { order.Email = em.InnerText; });
                                                });
                                            });
                                        });
                                        XmlParse.SelectSingleNode(guest, "TPA_Extensions/LateArrivalTime", time => { order.LateArrivalTime = time.InnerText; });
                                    });
                                    XmlParse.SelectSingleNode(on, "ResGlobalInfo", info =>
                                    {
                                        XmlParse.SelectSingleNode(info, "GuestCounts", n =>
                                        {
                                            order.IsPerRoom = XmlParse.GetAttribute(n, "IsPerRoom").ToBoolean();
                                            XmlParse.SelectSingleNode(n, "GuestCount", count =>
                                            {
                                                order.GuestCount = XmlParse.GetAttribute(count, "Count").ToInt32();
                                            });
                                        });
                                        XmlParse.SelectSingleNode(info, "TimeSpan", tn =>
                                        {
                                            order.StartDate = XmlParse.GetAttribute(tn, "Start").ToDateTime();
                                            order.EndDate   = XmlParse.GetAttribute(tn, "End").ToDateTime();
                                        });
                                        XmlParse.SelectSingleNode(info, "SpecialRequests/SpecialRequest/Text", text => { order.SpecialRequest = text.InnerText; });
                                        XmlParse.SelectSingleNode(info, "Total", total =>
                                        {
                                            order.AmountBeforeTax = XmlParse.GetAttribute(total, "AmountBeforeTax").ToDecimal();
                                            order.CurrencyCode    = XmlParse.GetAttribute(total, "CurrencyCode");
                                            XmlParse.SelectSingleNode(total, "TPA_Extensions", cur =>
                                            {
                                                XmlParse.SelectSingleNode(cur, "OtherCurrency/AmountPercentType", c =>
                                                {
                                                    order.OtherAmount       = XmlParse.GetAttribute(c, "Amount").ToDecimal();
                                                    order.OtherCurrencyCode = XmlParse.GetAttribute(c, "CurrencyCode");
                                                });
                                                XmlParse.SelectSingleNode(cur, "NoShowPaid/AmountPercentType", c =>
                                                {
                                                    order.NoShowAmount       = XmlParse.GetAttribute(c, "Amount").ToDecimal();
                                                    order.NoShowCurrencyCode = XmlParse.GetAttribute(c, "CurrencyCode");
                                                });
                                            });
                                        });


                                        XmlParse.SelectNodes(info, "HotelReservationIDs/HotelReservationID", ids =>
                                        {
                                            order.HotelReservationIDs = new List <HotelReservationID>();
                                            foreach (System.Xml.XmlNode idn in ids)
                                            {
                                                HotelReservationID oid = new HotelReservationID();
                                                oid.ResID_Type         = XmlParse.GetAttribute(idn, "ResID_Type");
                                                oid.ResID_Value        = XmlParse.GetAttribute(idn, "ResID_Value");
                                                oid.CancelReason       = XmlParse.GetAttribute(idn, "CancelReason");
                                                oid.CancellationDate   = XmlParse.GetAttribute(idn, "CancellationDate").ToDateTime();
                                                order.HotelReservationIDs.Add(oid);
                                            }
                                        });
                                    });


                                    XmlParse.SelectSingleNode(on, "TPA_Extensions/DayNightAudit", c => { order.DayNightAudit = c.InnerText; });

                                    XmlParse.SelectSingleNode(on, "TPA_Extensions/OrderTags", info =>
                                    {
                                        order.OrderTags = new List <OrderTag>();

                                        XmlParse.SelectSingleNode(info, "OrderTag", n =>
                                        {
                                            OrderTag tag = new OrderTag();
                                            tag.Code     = XmlParse.GetAttribute(n, "Code").ToString();
                                            tag.Value    = XmlParse.GetAttribute(n, "Value").ToString();
                                            order.OrderTags.Add(tag);
                                        });
                                    });

                                    this.OrderList.Add(order);
                                }
                            });
                        });
                    }
                }
            }
        }