Exemplo n.º 1
0
        // the class parses through returned xml and gets values for lat and long
        public override KmlPrepData convertAddress(String xml)
        {
            KmlPrepData kmlPrepData = new KmlPrepData();

            StringBuilder output = new StringBuilder();
            using (XmlReader reader = XmlReader.Create(new StringReader(xml)))
            {
                XmlWriterSettings ws = new XmlWriterSettings();
                ws.Indent = true;
                using (XmlWriter writer = XmlWriter.Create(output, ws))
                {

                    reader.ReadToFollowing("latitude");
                    kmlPrepData.lat = reader.ReadElementContentAsDouble();

                    //reader.ReadToFollowing("offsetlon");
                    kmlPrepData.lng = reader.ReadElementContentAsDouble();

                    reader.ReadToFollowing("line1");
                    kmlPrepData.name = reader.ReadElementContentAsString();

                }
            }

            return kmlPrepData;
        }
Exemplo n.º 2
0
        // the class parses through returned xml and gets values for lat and long
        public override KmlPrepData convertAddress(String xml)
        {
            KmlPrepData kmlPrepData = new KmlPrepData();

            StringBuilder output = new StringBuilder();

            using (XmlReader reader = XmlReader.Create(new StringReader(xml)))
            {
                XmlWriterSettings ws = new XmlWriterSettings();
                ws.Indent = true;
                using (XmlWriter writer = XmlWriter.Create(output, ws))
                {
                    reader.ReadToFollowing("latitude");
                    kmlPrepData.lat = reader.ReadElementContentAsDouble();

                    //reader.ReadToFollowing("offsetlon");
                    kmlPrepData.lng = reader.ReadElementContentAsDouble();

                    reader.ReadToFollowing("line1");
                    kmlPrepData.name = reader.ReadElementContentAsString();
                }
            }

            return(kmlPrepData);
        }
Exemplo n.º 3
0
        public override void addAddresstoKmlDocument(KmlPrepData prepData, Document KmlDoc)
        {
            Point point = new Point();

            point.Coordinate = new Vector(prepData.lat, prepData.lng);

            Placemark placemark = new Placemark();
            placemark.Geometry = point;
            placemark.Name = prepData.name;

            KmlDoc.AddFeature(placemark);
        }
Exemplo n.º 4
0
        public override void addAddresstoKmlDocument(KmlPrepData prepData, Document KmlDoc)
        {
            Point point = new Point();

            point.Coordinate = new Vector(prepData.lat, prepData.lng);

            Placemark placemark = new Placemark();

            placemark.Geometry = point;
            placemark.Name     = prepData.name;

            KmlDoc.AddFeature(placemark);
        }
Exemplo n.º 5
0
 public virtual void addAddresstoKmlDocument(KmlPrepData prepData, Document KmlDoc)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 public virtual void addAddresstoKmlDocument(KmlPrepData prepData, Document KmlDoc)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 7
0
        public ActionResult Refresh()
        {
            IEnumerable<Prospect> prospectList = _prospectSerivce.getList();
            int counter = 0;
            Document document = new Document();

            // get lat and long for each prospect
            foreach (Prospect prospect in prospectList)
            {
                // some api's will only allow x calls per second this sleeper helps to space out the calls made to the web service
                counter = counter + 1;
                if (counter % 10 == 0)
                {
                    System.Diagnostics.Debug.WriteLine("Sleeping" + counter);
                    System.Threading.Thread.Sleep(5000);
                }

                String responseFromServer = _prospectSerivce.makePrepData(prospect);
                KmlPrepData kmlPrepData = new KmlPrepData();
                //System.Diagnostics.Debug.WriteLine(responseFromServer);
                kmlPrepData = _kmlPrepDataService.convertAddress(responseFromServer);

                // update lat long to the database
                _prospectSerivce.updateProspect(prospect);
            }

            //run stored procedure to update db
            IEnumerable<JoinedProspect> joinedPospects = _joinedProspectService.getList();

            // get results
            //create styles for placemarkers
            var doNotContactStyle = new Style();
            doNotContactStyle.Id = "doNoContact";
            doNotContactStyle.Icon = new IconStyle();
            doNotContactStyle.Icon.Color = new Color32(255, 0, 255, 0);
            doNotContactStyle.Icon.ColorMode = ColorMode.Normal;
            doNotContactStyle.Icon.Icon = new IconStyle.IconLink(new Uri("http://maps.google.com/mapfiles/kml/pal3/icon47.png"));
            doNotContactStyle.Icon.Scale = 1.1;

            var currentCustomerStyle = new Style();
            currentCustomerStyle.Id = "currentCustomer";
            currentCustomerStyle.Icon = new IconStyle();
            currentCustomerStyle.Icon.Color = new Color32(255, 0, 255, 0);
            currentCustomerStyle.Icon.ColorMode = ColorMode.Normal;
            currentCustomerStyle.Icon.Icon = new IconStyle.IconLink(new Uri("http://maps.google.com/mapfiles/kml/pal3/icon23.png"));
            currentCustomerStyle.Icon.Scale = 1.1;

            var cancelledCustomerStyle = new Style();
            cancelledCustomerStyle.Id = "cancelledCustomer";
            cancelledCustomerStyle.Icon = new IconStyle();
            cancelledCustomerStyle.Icon.Color = new Color32(255, 0, 255, 0);
            cancelledCustomerStyle.Icon.ColorMode = ColorMode.Normal;
            cancelledCustomerStyle.Icon.Icon = new IconStyle.IconLink(new Uri("http://maps.google.com/mapfiles/kml/pal3/icon51.png"));
            cancelledCustomerStyle.Icon.Scale = 1.1;
            //add results to document
            foreach (JoinedProspect jp in joinedPospects)
            {
                // loop through and add information to kmldocument
                KmlPrepData kmlPrepData = new KmlPrepData();
                _kmlDocumentService.addElementToKmlDocument(jp, document);

            }

            document.AddStyle(doNotContactStyle);
            document.AddStyle(currentCustomerStyle);
            document.AddStyle(cancelledCustomerStyle);

            //var serializer = new Serializer();
            //serializer.Serialize(document);
            //System.Diagnostics.Debug.WriteLine(serializer.Xml);

            _kmlDocumentService.saveKmlDocument(document);
            return View();
        }