Esempio n. 1
0
        public bool Fill(Order theOrder)
        {
            //Retrieve first address for order
            RteNode firstNode = (RteNode)theOrder._route._nodes[0];

            from_addr_street = firstNode.Street;
            from_addr_number = firstNode.StreetNbr;

            from_addr_city = firstNode.Locality;
            from_zone      = firstNode.Zone;
            from_addr_cmnt = theOrder._manualDescript;
            if (firstNode.StreetNbrLtr != null)
            {
                from_addr_apart = firstNode.StreetNbrLtr;
            }

            if (firstNode.Contents.Count > 0)
            {
                NdeContent firstContent = (NdeContent)firstNode.Contents[0];
                passenger = firstContent.Name;
                telephone = firstContent.ContactPhone;
            }
            else
            {
                passenger = String.Empty;
                telephone = String.Empty;
            }
            // if Description + ManualDescript exceeds 64 chars we can't process
            // this order.

            if (theOrder._manualDescript != null && firstNode.Description != null)
            {
                if ((theOrder.OrderID.Length + firstNode.Description.Length + theOrder._manualDescript.Length) < 64)
                {
                    call_comment = theOrder.OrderID + "/" + theOrder._manualDescript + " " + firstNode.Description;
                }
                else
                {
                    return(false);
                }
            }
            else if (theOrder._manualDescript != null)
            {
                if (theOrder.OrderID.Length + theOrder._manualDescript.Length < 64)
                {
                    call_comment = theOrder.OrderID + "/" + theOrder._manualDescript;
                }
                else
                {
                    return(false);
                }
            }
            else if (firstNode.Description != null)
            {
                if (theOrder.OrderID.Length + firstNode.Description.Length < 64)
                {
                    call_comment = theOrder.OrderID + "/" + firstNode.Description;
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                call_comment = theOrder.OrderID + "/";
            }


            //Destination address in second node if present
            if (theOrder._route._nodes.Count > 1)
            {
                RteNode secondNode = (RteNode)theOrder._route._nodes[1];
                if (secondNode != null)
                {
                    to_addr_street = secondNode.Street;
                    to_addr_number = secondNode.StreetNbr;
                    if (secondNode.StreetNbrLtr != null)
                    {
                        to_addr_apart = secondNode.StreetNbrLtr;
                    }
                    to_addr_city = secondNode.Locality;
                }
                if (secondNode.Contents.Count > 0)
                {
                    NdeContent secondContent = (NdeContent)secondNode.Contents[0];
                    passenger = secondContent.Name;
                    telephone = secondContent.ContactPhone;
                }
            }

            // vehicle attributes
            if (theOrder.VehAttributes.Count > 0)               // have vehicle attributes
            {
                this.veh_attributes = theOrder.VehAttributes;
            }

            return(true);
        }
Esempio n. 2
0
        public Route(string xmlFragment)
        {
            XmlTextReader xRdr = new XmlTextReader(xmlFragment, XmlNodeType.Element, null);
            XmlDocument   xDoc = new XmlDocument();

            xDoc.Load(xRdr);

            Int16 seqNbr = 0;

            foreach (XmlNode stopNode in xDoc.SelectNodes("/SUTI/msg/order/route/node"))
            {
                string        nodeXml  = stopNode.OuterXml;
                XmlTextReader rdrStop  = new XmlTextReader(nodeXml, XmlNodeType.Element, null);
                XmlDocument   xDocStop = new XmlDocument();
                xDocStop.Load(rdrStop);
                ++seqNbr;

                RteNode myRteNode = new RteNode();
                myRteNode.SeqNbr = seqNbr;
                XmlAttributeCollection stopAttr = stopNode.Attributes;
                if (stopAttr.GetNamedItem("nodeType").InnerXml.ToUpper().Equals("PICKUP"))
                {
                    myRteNode.NodeType = 'P';
                }
                else
                {
                    myRteNode.NodeType = 'D';
                }

                XmlNode addrNode = xDocStop.SelectSingleNode("/node/addressNode");
                XmlAttributeCollection addrAttr = addrNode.Attributes;
                myRteNode.Street    = addrAttr.GetNamedItem("street").InnerXml.ToUpper();
                myRteNode.StreetNbr = addrAttr.GetNamedItem("streetNo").InnerXml.ToUpper();
                if (addrAttr.GetNamedItem("streetNoLetter") != null)
                {
                    myRteNode.StreetNbrLtr = addrAttr.GetNamedItem("streetNoLetter").InnerXml.ToUpper();
                }
                if (addrAttr.GetNamedItem("community") != null)
                {
                    myRteNode.Locality = addrAttr.GetNamedItem("community").InnerXml.ToUpper();
                }
                else
                {
                    myRteNode.Locality = String.Empty;
                }


                XmlNode timesNode = xDocStop.SelectSingleNode("/node/timesNode/time");
                if (timesNode != null)
                {
                    XmlAttributeCollection timeAttr = timesNode.Attributes;

                    if (timeAttr.GetNamedItem("time") != null)
                    {
                        myRteNode.DueTime = timeAttr.GetNamedItem("time").InnerXml;
                    }
                }

                //Get Contents for the Node
                XmlNode passContent  = xDocStop.SelectSingleNode("//contactInfo[@contactType='traveller']");
                XmlNode phoneContent = xDocStop.SelectSingleNode("//contactInfo[@contactType='phone']");

                if (passContent != null)
                {
                    NdeContent             myContent   = new NdeContent();
                    XmlAttributeCollection contactAttr = passContent.Attributes;
                    myContent.Name = contactAttr.GetNamedItem("contactInfo").InnerXml;

                    if (phoneContent != null)
                    {
                        contactAttr            = phoneContent.Attributes;
                        myContent.ContactPhone = contactAttr.GetNamedItem("contactInfo").InnerXml;
                        myRteNode.Contents.Add(myContent);
                    }
                }



                XmlNode zoneNode = xDocStop.SelectSingleNode("/node/addressNode/geographicLocation");
                if (zoneNode != null)
                {
                    XmlAttributeCollection zoneDescriptAttr = zoneNode.Attributes;
                    myRteNode.Zone = zoneDescriptAttr.GetNamedItem("zone").InnerXml;
                }

                XmlNode manualDescriptNode = xDocStop.SelectSingleNode("/node/addressNode/manualDescriptionAddress");
                if (manualDescriptNode != null)
                {
                    XmlAttributeCollection manualDescriptAttr = manualDescriptNode.Attributes;
                    myRteNode.Description = manualDescriptAttr.GetNamedItem("manualText").InnerXml;
                }

                XmlNode contactNode = xDocStop.SelectSingleNode("/node/contents/content/contactInfosContent/contactInfo");
                if (contactNode != null)
                {
                    NdeContent             myContent   = new NdeContent();
                    XmlAttributeCollection contactAttr = contactNode.Attributes;
                    myContent.ContactPhone = contactAttr.GetNamedItem("contactInfo").InnerXml;
                    myRteNode.Contents.Add(myContent);
                }

                _nodes.Add(myRteNode);
            }
        }