Exemplo n.º 1
0
        private List <MatchedAddress> ConvertToMatchedAddresses(Geocode geocode)
        {
            List <MatchedAddress> matchedAddresses = new List <MatchedAddress>();

            if (geocode.GcCount != null && geocode.GcCount.Count > 0)
            {
                foreach (Feature feature in geocode.Features)
                {
                    MatchedAddress matchedAddress = new MatchedAddress();

                    foreach (Field field in feature.Fields)
                    {
                        switch (field.Name)
                        {
                        case "ADDRESSFOUND":
                            matchedAddress.Address = field.FieldValue.ValueString;
                            break;

                        case "SCORE":
                            matchedAddress.Score = Convert.ToInt32(field.FieldValue.ValueString);
                            break;

                        case "SHAPEFIELD":
                            matchedAddress.Location = field.FieldValue.Point.Coordinate;
                            break;
                        }

                        matchedAddresses.Add(matchedAddress);
                    }
                }
            }

            return(matchedAddresses);
        }
Exemplo n.º 2
0
 public static string CreateUser(Geocode geocode, bool debugEnabled, Verbosity verbosity, List<string> fields)
 {
     var url = new Url(UserServiceBase);
     url.Append("create");
     HandleDefaults(url, geocode, debugEnabled, verbosity, fields);
     return url.ToString();
 }
        public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Address,City,StateId,ZipCode,PreferenceId,PaymentId,Gifting,Donating,AccountStatus,MemberSince,UserId")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                var userId = User.Identity.GetUserId();
                customer.UserId      = userId;
                customer.MemberSince = DateTime.Now;
                customer.Donating    = false;
                if (Geocode.CheckValidAddress(customer))
                {
                    if (Geocode.isValidLocation)
                    {
                        db.Customers.Add(customer);
                        db.SaveChanges();
                        return(RedirectToAction("Index", "Dashboard"));
                    }
                }
                return(RedirectToAction("Create", new { customer.PreferenceId, isValid = false, firstName = customer.FirstName, lastName = customer.LastName }));
            }

            //ViewBag.PaymentId = new SelectList(db.Payments, "Id", "Id", customer.PaymentId);
            ViewBag.PreferenceId = new SelectList(db.Preferences, "Id", "OptimalSize", customer.PreferenceId);
            ViewBag.StateId      = new SelectList(db.States, "Id", "Name", customer.StateId);
            return(View(customer));
        }
Exemplo n.º 4
0
        public void GetWeatherData(Geocode location)
        {
            // create a new proxy element from the NOAA WebReference
            var proxy = new ndfdXMLPortTypeClient();
            // get response data
            string data = proxy.NDFDgenByDay((decimal)location.Latitude, (decimal)location.Longitude, DateTime.Now.AddDays(-3).Date, "3",
                                             formatType.Item24hourly);

            StringReader reader = new StringReader(data);
            XDocument xmlDoc = XDocument.Load(reader);

            //using linq parse out the maximums and minimums
            var maximums = from tempvalue in xmlDoc.Descendants("temperature").Elements("value")
                           where tempvalue.Parent.Attribute("type").Value == "maximum"
                           select (string)tempvalue;

            var minimums = from tempvalue in xmlDoc.Descendants("temperature").Elements("value")
                           where tempvalue.Parent.Attribute("type").Value == "minimum"
                           select (string)tempvalue;

            // For now simply write out the lists to the console
            foreach (string max in maximums.ToList())
            {
                Console.WriteLine(max);
            }

            foreach (string min in minimums.ToList())
            {
                Console.WriteLine(min);
            }

            Console.WriteLine();
            Console.WriteLine(data);
        }
Exemplo n.º 5
0
            public static string MultiGetArticle(string type, List <string> idList, Geocode location, bool enableDebug, Verbosity verbosity, List <string> fields)
            {
                var url = new Url(ArticleServiceBase).Append(type).Append("multiget").Append(idList.ToDelimitedList(","));

                HandleDefaults(url, location, enableDebug, verbosity, fields);
                return(url.ToString());
            }
        /// <summary>
        /// Retorna um objeto route para calculo de rota entre dois pontos.
        /// </summary>
        /// <param name="geocodeOrigin"></param>
        /// <param name="geocodeDestination"></param>
        /// <returns>Route</returns>
        protected static HereRouting GeocodeParaRouting(Geocode geocodeOrigin, Geocode geocodeDestination)
        {
            HereRouting routing         = null;
            double      latOrigin       = geocodeOrigin.items.First().position.lat;
            double      longOrigin      = geocodeOrigin.items.First().position.lng;
            double      latDestination  = geocodeDestination.items.First().position.lat;
            double      longDestination = geocodeDestination.items.First().position.lng;

            try
            {
                HttpClient          client   = new HttpClient();
                HttpResponseMessage response = client.GetAsync($"https://router.hereapi.com/v8/" +
                                                               $"routes?transportMode=car" +
                                                               $"&origin={latOrigin},{longOrigin}" +
                                                               $"&destination={latDestination},{longDestination}" +
                                                               $"&return=summary" +
                                                               $"&apiKey={HERE_APIKEY}").Result;

                if (response.IsSuccessStatusCode)
                {
                    string json = response.Content.ReadAsStringAsync().Result;
                    routing = JsonConvert.DeserializeObject <HereRouting>(json);
                }
            }

            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(routing);
        }
Exemplo n.º 7
0
 public static string CreateArticle(string type, Geocode geocode, bool debugEnabled, Verbosity verbosity, List<string> fields)
 {
     var url = new Url(ArticleServiceBase);
     url.Append(type);
     HandleDefaults(url, geocode, debugEnabled, verbosity, fields);
     return url.ToString();
 }
Exemplo n.º 8
0
 virtual protected void WriteToXmlElement(XmlElement iElement)
 {
     if (Geocode != 0)
     {
         iElement.SetAttribute("geocode", Geocode.ToString());
     }
     if (TambonGeocode != 0)
     {
         iElement.SetAttribute("tambon", TambonGeocode.ToString());
     }
     if (Owner != 0)
     {
         iElement.SetAttribute("owner", Owner.ToString());
     }
     if (!String.IsNullOrEmpty(Name))
     {
         iElement.SetAttribute("name", Name.ToString());
     }
     if (!String.IsNullOrEmpty(English))
     {
         iElement.SetAttribute("english", English.ToString());
     }
     foreach (RoyalGazetteContent lContent in mSubEntries)
     {
         lContent.ExportToXML(iElement);
     }
 }
Exemplo n.º 9
0
        public async Task <Geocode> Geocode(string location)
        {
            using (var client = new HttpClient())
            {
                var response = await client.GetAsync(geocodingApi + $"?address={location}&key={apiKey}");

                var content = await response.Content.ReadAsStringAsync();

                var json = JsonConvert.DeserializeObject <GeocodeResponse>(content);

                if (json.Status == "ZERO_RESULTS" || json.Status == "OVER_QUERY_LIMIT")
                {
                    return(null);
                }

                if (json.Status != "OK")
                {
                    throw new Exception($"Failed to query location. Status={json.Status}. Location={location}");
                }

                var geocode = new Geocode
                {
                    Latitude         = json.Results[0].Geometry.Location.Latitude,
                    Longitude        = json.Results[0].Geometry.Location.Longitude,
                    FormattedAddress = json.Results[0].FormattedAddress,
                };
                return(geocode);
            }
        }
 public RadialSearchQuery(Field field, Geocode center, decimal radius, DistanceUnit unit = Sdk.DistanceUnit.Miles)
 {
     this.Field = field;
     this.Center = center;
     this.DistanceUnit = unit;
     this.Radius = radius;
 }
Exemplo n.º 11
0
        private void WriteToKml(KmlHelper lKmlWriter, XmlNode iNode)
        {
            XmlNode lNode        = iNode;
            String  lDescription = "Geocode: " + Geocode.ToString();

            if ((Type == EntityType.Changwat) | (Type == EntityType.Bangkok))
            {
                lNode = lKmlWriter.AddFolder(lNode, English, false);
            }
            String lName = English;

            if (Type == EntityType.Muban)
            {
                lName = "Mu " + (Geocode % 100).ToString();
                if (!String.IsNullOrEmpty(English))
                {
                    lName = lName + ' ' + English;
                }
            }
            if (!String.IsNullOrEmpty(this.Comment))
            {
                lDescription = lDescription + Environment.NewLine + this.Comment;
            }
            foreach (EntityOffice lOffice in Offices)
            {
                lOffice.AddToKml(lKmlWriter, lNode, lName, lDescription);
            }
            foreach (PopulationDataEntry lEntity in SubEntities)
            {
                lEntity.WriteToKml(lKmlWriter, lNode);
            }
        }
Exemplo n.º 12
0
            public static string GetArticle(string type, string id, Geocode location, bool enableDebug, Verbosity verbosity, List <string> fields)
            {
                var url = new Url(ArticleServiceBase).Append(type).Append(id);

                HandleDefaults(url, location, enableDebug, verbosity, fields);
                return(url.ToString());
            }
        public static Geocode BuscarGeocode(string lugar)
        {
            Geocode geocode = null;

            try
            {
                HttpClient          client   = new HttpClient();
                HttpResponseMessage response = client.GetAsync($"https://geocode.search.hereapi.com/v1/" +
                                                               $"geocode?q={lugar}" +
                                                               $"&apiKey={HERE_APIKEY}").Result;

                if (response.IsSuccessStatusCode)
                {
                    string json = response.Content.ReadAsStringAsync().Result;
                    geocode = JsonConvert.DeserializeObject <Geocode>(json);
                }
            }

            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(geocode);
        }
Exemplo n.º 14
0
            public static string GetDevice(string id, Geocode geocode, bool enableDebugging, Verbosity verbosity, List <string> fields)
            {
                var url = new Url(DeviceServiceBase).Append(id);

                HandleDefaults(url, geocode, enableDebugging, verbosity, fields);
                return(url.ToString());
            }
        private async Task SetVacancyGeocode(Guid vacancyId, Geocode geocode)
        {
            var vacancy = await _repository.GetVacancyAsync(vacancyId);

            if (vacancy.EmployerLocation == null)
            {
                _logger.LogInformation("Vacancy:{vacancyId} does not have employer location information. Cannot update vacancy", vacancy.Id);
                return;
            }

            if (vacancy.EmployerLocation?.Latitude != null && vacancy.EmployerLocation?.Longitude != null)
            {
                if (Math.Abs(vacancy.EmployerLocation.Latitude.Value - geocode.Latitude) < 0.0001 &&
                    Math.Abs(vacancy.EmployerLocation.Longitude.Value - geocode.Longitude) < 0.0001)
                {
                    _logger.LogInformation("Vacancy geocode:{geocode} has not changed for vacancy:{vacancyId}. Not updating vacancy", geocode, vacancy.Id);
                    return;
                }
            }

            vacancy.EmployerLocation.Latitude  = geocode.Latitude;
            vacancy.EmployerLocation.Longitude = geocode.Longitude;
            vacancy.GeoCodeMethod = geocode.GeoCodeMethod;

            await _repository.UpdateAsync(vacancy);

            _logger.LogInformation("Successfully geocoded vacancy:{vacancyId} with geocode Latitude:{latitude} Logtitude:{longitude}", vacancy.Id, vacancy.EmployerLocation.Latitude, vacancy.EmployerLocation.Longitude);
        }
Exemplo n.º 16
0
            public static string InitiateResetPassword(Geocode geocode, bool enableDebugging, Verbosity verbosity)
            {
                var url = new Url(UserServiceBase).Append("sendresetpasswordemail");

                HandleDefaults(url, geocode, enableDebugging, verbosity, null);
                return(url.ToString());
            }
Exemplo n.º 17
0
            public static string SendEmail(Geocode geocode, bool enableDebugging, Verbosity verbosity, List <string> fields)
            {
                var url = new Url(EmailServiceBase).Append("send");

                HandleDefaults(url, geocode, enableDebugging, verbosity, fields);
                return(url.ToString());
            }
Exemplo n.º 18
0
            public static string SendPushNotification(Geocode geocode, bool enableDebugging, Verbosity verbosity, List <string> fields)
            {
                var url = new Url(PushServiceBase);

                HandleDefaults(url, geocode, enableDebugging, verbosity, fields);
                return(url.ToString());
            }
Exemplo n.º 19
0
        public void UpdateLatitudeAndLongitude()
        {
            float[] latLng = Geocode.GetLatitudeAndLongitude(Address + " " + Zipcode, ApiKeys.geocodeKey);
            Latitude  = latLng[0];
            Longitude = latLng[1];

            return;
        }
Exemplo n.º 20
0
            public static string UpdateGroupMembersRequest(string group, Geocode geocode, bool enableDebugging, Verbosity verbosity, List <string> fields)
            {
                //{{hostname}}/v1.0/usergroup/g10/members
                var url = new Url(UserGroupServiceBase).Append(group).Append("members");

                HandleDefaults(url, geocode, enableDebugging, verbosity, fields);
                return(url.ToString());
            }
Exemplo n.º 21
0
            public static string GraphProject(string query, Geocode geocode, bool enableDebugging, Verbosity verbosity, List <string> fields)
            {
                var url = new Url(GraphServiceBase);

                url.Append(query).Append("project");
                HandleDefaults(url, geocode, enableDebugging, verbosity, fields);
                return(url.ToString());
            }
Exemplo n.º 22
0
            public static string CreateArticle(string type, Geocode geocode, bool debugEnabled, Verbosity verbosity, List <string> fields)
            {
                var url = new Url(ArticleServiceBase);

                url.Append(type);
                HandleDefaults(url, geocode, debugEnabled, verbosity, fields);
                return(url.ToString());
            }
Exemplo n.º 23
0
 private void SetOneDirection()
 {
     if (this.isOneDirection)
     {
         this.End    = this.Start;
         this.EndPin = this.StartPin;
     }
 }
Exemplo n.º 24
0
            public static string GetFriends(string userId, string socialNetwork, Geocode location, bool enableDebug, Verbosity verbosity, List <string> fields)
            {
                //https://apis.appacitive.com/v1.0/user/{user id}/friends/facebook
                var url = new Url(UserServiceBase).Append(userId).Append("friends").Append(socialNetwork);

                HandleDefaults(url, location, enableDebug, verbosity, fields);
                return(url.ToString());
            }
Exemplo n.º 25
0
 public static string DeleteArticle(string type, string id, bool deleteConnections, Geocode location, bool enableDebug, Verbosity verbosity, List<string> fields)
 {
     var url = new Url(ArticleServiceBase).Append(type).Append(id);
     if (deleteConnections == true)
         url.QueryString["deleteconnections"] = "true";
     HandleDefaults(url, location, enableDebug, verbosity, fields);
     return url.ToString();
 }
Exemplo n.º 26
0
 public static string UpdateArticle(string type, string id, int revision, Geocode geocode, bool enableDebug, Verbosity verbosity, List<string> fields)
 {
     var url = new Url(ArticleServiceBase).Append(type).Append(id);
     if (revision > 0)
         url.QueryString["revision"] = revision.ToString();
     HandleDefaults(url, geocode, enableDebug, verbosity, fields);
     return url.ToString();
 }
Exemplo n.º 27
0
            public static string InvalidateUser(Geocode geocode, bool debugEnabled, Verbosity verbosity)
            {
                var url = new Url(UserServiceBase);

                url.Append("invalidate");
                HandleDefaults(url, geocode, debugEnabled, verbosity, null);
                return(url.ToString());
            }
Exemplo n.º 28
0
            public static string AuthenticateUser(Geocode geocode, bool debugEnabled, Verbosity verbosity, List <string> fields)
            {
                var url = new Url(UserServiceBase);

                url.Append("authenticate");
                HandleDefaults(url, geocode, debugEnabled, verbosity, fields);
                return(url.ToString());
            }
Exemplo n.º 29
0
            public static string CreateConnection(string connectionType, Geocode geocode, bool debugEnabled, Verbosity verbosity, List <string> fields)
            {
                var url = new Url(ConnectionServiceBase);

                url.Append(connectionType);
                HandleDefaults(url, geocode, debugEnabled, verbosity, fields);
                return(url.ToString());
            }
Exemplo n.º 30
0
        /// <summary>
        /// Returns true if Seller instances are equal
        /// </summary>
        /// <param name="other">Instance of Seller to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Seller other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Address == other.Address ||
                     Address != null &&
                     Address.Equals(other.Address)
                     ) &&
                 (
                     ChannelCode == other.ChannelCode ||
                     ChannelCode != null &&
                     ChannelCode.Equals(other.ChannelCode)
                 ) &&
                 (
                     Description == other.Description ||
                     Description != null &&
                     Description.Equals(other.Description)
                 ) &&
                 (
                     Geocode == other.Geocode ||
                     Geocode != null &&
                     Geocode.Equals(other.Geocode)
                 ) &&
                 (
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                 ) &&
                 (
                     InvoiceNumber == other.InvoiceNumber ||
                     InvoiceNumber != null &&
                     InvoiceNumber.Equals(other.InvoiceNumber)
                 ) &&
                 (
                     Mcc == other.Mcc ||
                     Mcc != null &&
                     Mcc.Equals(other.Mcc)
                 ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                 ));
        }
Exemplo n.º 31
0
        public Geocode Geolocate(int zipcode)
        {
            string  key        = "AIzaSyAjvSmZAIx5ytoXJmdVGlzqj8M76zlWKWs";
            var     requestUrl = $"https://maps.googleapis.com/maps/api/geocode/json?address={zipcode}&key={key}";
            var     result     = new WebClient().DownloadString(requestUrl);
            Geocode geocode    = JsonConvert.DeserializeObject <Geocode>(result);

            return(geocode);
        }
Exemplo n.º 32
0
            public static string CreateUser(Geocode geocode, bool debugEnabled, Verbosity verbosity, List <string> fields)
            {
                var url = new Url(UserServiceBase);

                url.Append("create");
                url.QueryString["returnacls"] = "true";
                HandleDefaults(url, geocode, debugEnabled, verbosity, fields);
                return(url.ToString());
            }
 protected ApiRequest(string sessionToken, Environment environment, string userToken = null, Geocode location = null, bool enableDebugging = false, Verbosity verbosity = Verbosity.Info)
 {
     this.SessionToken = sessionToken;
     this.CurrentLocation = location;
     this.Verbosity = verbosity;
     this.UserToken = userToken;
     this.Environment = environment;
     this.Fields = new List<string>();
 }
 public UpdateUserRequest(string sessionToken, Environment environment, string userToken = null, Geocode location = null, bool enableDebugging = false, Verbosity verbosity = Verbosity.Info) :
     base(sessionToken, environment, userToken, location, enableDebugging, verbosity)
 {
     this.PropertyUpdates = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
     this.AttributeUpdates = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
     this.AddedTags = new List<string>();
     this.RemovedTags = new List<string>();
     this.Revision = 0;
 }
Exemplo n.º 35
0
            public static string BulkDeleteArticle(string type, Geocode geocode, bool enableDebugging, Verbosity verbosity, List <string> fields)
            {
                //https://apis.appacitive.com/connection/userlist/bulkdelete
                var url = new Url(ArticleServiceBase);

                url.Append(type).Append("bulkdelete");
                HandleDefaults(url, geocode, enableDebugging, verbosity, fields);
                return(url.ToString());
            }
Exemplo n.º 36
0
            public static string RegisterDevice(Geocode geocode, bool enableDebugging, Verbosity verbosity, List <string> fields)
            {
                //https://apis.appacitive.com/connection/userlist/bulkdelete
                var url = new Url(DeviceServiceBase);

                url.Append("register");
                HandleDefaults(url, geocode, enableDebugging, verbosity, fields);
                return(url.ToString());
            }
        public static object Convert(object value, Type type)
        {
            if (value == null)
            {
                if (IsNullable(type) == false)
                {
                    throw new Exception("Given type " + type.Name + " cannot be null.");
                }
                else
                {
                    return(null);
                }
            }


            if (type.IsEnumeration() == true)
            {
                return(Enum.Parse(type, value.ToString(), true));
            }

            // Handle string to date time conversion
            if (type == typeof(DateTime))
            {
                DateTime result;
                // Return parsed date in local time zone
                if (DateTime.TryParseExact(value.ToString(), new[] { Formats.DateTime, Formats.Date }, null, System.Globalization.DateTimeStyles.AdjustToUniversal, out result) == true)
                {
                    return(result.ToLocalTime());
                }
                else
                {
                    throw new Exception("Unsupported date time format.");
                }
            }
            // Handle Datetime to string conversion.
            if (type == typeof(string) && value is DateTime)
            {
                return(((DateTime)value).ToString("o"));
            }
            // Handle geocode to string conversion
            if (type == typeof(Geocode) && value is string)
            {
                Geocode geo = null;
                if (Geocode.TryParse(value as string, out geo) == false)
                {
                    throw new Exception("Cannot convert " + value + " to a valid geocode.");
                }
                return(geo);
            }

            if (type.IsPrimitiveType() == true || type == typeof(string))
            {
                return(System.Convert.ChangeType(value, type, null));
            }
            throw new Exception("No automatic translation available for type " + type.Name + ".");
        }
Exemplo n.º 38
0
        private async Task SetPlaceSelectedOnMap(GooglePlaceAutoCompletePrediction placeA)
        {
            var place = await googleMapsApi.GetPlaceDetails(placeA.PlaceId);

            if (place != null)
            {
                if (_isOriginFocused)
                {
                    Origin           = place.Name;
                    _originLatitud   = $"{place.Latitude}";
                    _originLongitud  = $"{place.Longitude}";
                    _isOriginFocused = false;
                    if (StartPin != null)
                    {
                        Map.Pins.Remove(StartPin);
                    }
                    StartPin = CreatePin(Constants.ORIGEN_LABEL, place.Latitude, place.Longitude);
                    Start    = new Geocode(place.Latitude, place.Longitude);
                    Map.Pins.Add(StartPin);
                    if (!_isOriginFocused && isOneDirection)
                    {
                        await App.Current.MainPage.Navigation.PopModalAsync(false);

                        _isOriginFocused = true;
                        CleanFields();
                        return;
                    }
                }
                else
                {
                    Destination          = place.Name;
                    _destinationLatitud  = $"{place.Latitude}";
                    _destinationLongitud = $"{place.Longitude}";
                    if (EndPin != null)
                    {
                        Map.Pins.Remove(EndPin);
                    }
                    EndPin = CreatePin(Constants.DESTINO_LABEL, place.Latitude, place.Longitude);
                    End    = new Geocode(place.Latitude, place.Longitude);
                    Map.Pins.Add(EndPin);

                    if (_originLatitud == _destinationLatitud && _originLongitud == _destinationLongitud)
                    {
                        await App.Current.MainPage.DisplayAlert("Ups", "El origen y el destino no pueden ser los mismos.", "Ok");
                    }
                    else
                    {
                        LoadRouteCommand.Execute(null);
                        await App.Current.MainPage.Navigation.PopModalAsync(false);

                        CleanFields();
                    }
                }
            }
        }
Exemplo n.º 39
0
 public void GetHashCodeTest()
 {
     var map = new Dictionary<Geocode, int>();
     var geoKey1 = new Geocode(10.5m, 10.6m);
     map[geoKey1] = 10;
     var geoKey2 = new Geocode(10.5m, 10.6m);
     int result;
     Assert.IsTrue(map.TryGetValue(geoKey2, out result));
     Assert.AreEqual<int>(10, result);
     
 }
Exemplo n.º 40
0
        public void GeocodeEqualityTest()
        {
            var geo1 = new Geocode(10m, 10.5m);
            var geo2 = new Geocode(20m / 2, 21m / 2);
            var geo3 = new Geocode(10m, 11m);       // different latitude
            var geo4 = new Geocode(12m, 10.5m);     // different longitude

            Assert.AreEqual<Geocode>(geo1, geo2);
            Assert.AreNotEqual<Geocode>(geo1, geo3);
            Assert.AreNotEqual<Geocode>(geo1, geo4);
        }
Exemplo n.º 41
0
 protected ApiRequest(string apiKey, string sessionToken, Environment environment, string userToken = null, Geocode location = null, bool enableDebugging = false, Verbosity verbosity = Verbosity.Info)
 {
     this.ApiKey = apiKey;
     this.UseApiSession = string.IsNullOrWhiteSpace(sessionToken) ? false : true;
     this.SessionToken = sessionToken;
     this.CurrentLocation = location;
     this.Verbosity = verbosity;
     this.UserToken = userToken;
     this.Environment = environment;
     this.Fields = new List<string>();
 }
Exemplo n.º 42
0
 private static Url HandleDefaults(Url url, Geocode location, bool enableDebug, Verbosity verbosity, List<string> fields)
 {
     if (enableDebug == true)
     {
         url.QueryString["debug"] = "true";
         if (verbosity == Verbosity.Verbose)
             url.QueryString["verbosity"] = "verbose";
     }
     if (location != null)
         url.QueryString["location"] = location.ToString();
     if (fields != null && fields.Count > 0)
         url.QueryString["fields"] = fields.Select(x => x.ToLower() ).ToDelimitedList(",");
     return url;
 }
Exemplo n.º 43
0
 private static void GeocodeExample()
 {
     var request = new Geocode(_api.Context, "61 Katherine str, Sandton");
     var result = _api.ExecuteRequest(request).Data[0];
     var output = string.Format("{0} {1}, {2}, {3}, {4}, {5}, {6}",
                                result.Number,
                                result.Line1,
                                result.Suburb,
                                result.City,
                                result.PostalCode,
                                result.Latitude,
                                result.Longitude);
     Console.WriteLine(output);
 }
Exemplo n.º 44
0
 public void GeocodeParsingTest()
 {
     var geo = new Geocode(10.0m, 10.0m);
     var valid = new[] 
     { 
         "10,10",        // without decimal points
         "10.0,10.0",    // normal
         " 10.0,10.0",   // with leading spaces
         "10.0,10.0",    // with trailing spaces
         "10.0 ,10.0 ",  // with leading space before comma
         "10.0, 10.0"    // with trailing space after comma
     };
     Array.ForEach(valid, value =>
         {
             Geocode geocode = null;
             Assert.IsTrue(Geocode.TryParse(value, out geocode), "Valid value {0} was not parsed correctly.", value);
             Assert.IsNotNull(geocode, "Geocode parsed for {0} was null.", value);
             Assert.IsTrue(geocode.Equals(geo), "Expected {0} but received {1}.", geo.ToString(), geocode.ToString());
         });
 }
Exemplo n.º 45
0
 public static string GetDevice(string id, Geocode geocode, bool enableDebugging, Verbosity verbosity, List<string> fields)
 {
     var url = new Url(DeviceServiceBase).Append(id);
     HandleDefaults(url, geocode, enableDebugging, verbosity, fields);
     return url.ToString();
 }
 public FindAllUsersRequest(string sessionToken, Environment environment, string userToken = null, Geocode location = null, bool enableDebugging = false, Verbosity verbosity = Verbosity.Info) :
     base(sessionToken, environment, userToken, location, enableDebugging, verbosity)
 {
     this.Type = "user";
 }
 private DeleteArticleRequest(string sessionToken, Environment environment, string userToken = null, Geocode location = null, bool enableDebugging = false, Verbosity verbosity = Verbosity.Info) :
     base(sessionToken, environment, userToken, location, enableDebugging, verbosity)
 {
 }
 public GetDownloadUrlRequest(string sessionToken, Environment environment, string userToken = null, Geocode location = null, bool enableDebugging = false, Verbosity verbosity = Verbosity.Info) :
     base(sessionToken, environment, userToken, location, enableDebugging, verbosity)
 {
 }
 public GetUserRequest(string sessionToken, Environment environment, string userToken = null, Geocode location = null, bool enableDebugging = false, Verbosity verbosity = Verbosity.Info) :
     base(sessionToken, environment, userToken, location, enableDebugging, verbosity)
 {
     this.UserIdType = string.Empty; // Nikhil: String.empty indicates default type is id. This should probably be changed.
 }
 public MultiGetArticleRequest(string sessionToken, Environment environment, string userToken = null, Geocode location = null, bool enableDebugging = false, Verbosity verbosity = Verbosity.Info) :
     base(sessionToken, environment, userToken, location, enableDebugging, verbosity)
 {
     this.IdList = new List<string>();
 }
Exemplo n.º 51
0
        public IconLabelView(Opdracht opdracht, FileImageSource source, String text)
        {
            adressen = DataController.Instance.GetAddresses();
            presatielijst = DataController.Instance.GetAchievements();
            gemeentes = DataController.Instance.GetCitys();
            adrestText = adressen[opdracht.Adres].Straat + " " + adressen[opdracht.Adres].Nummer + ", " + gemeentes[adressen[opdracht.Adres].Gemeente].Postcode + " " + gemeentes[adressen[opdracht.Adres].Gemeente].Plaats;
            BackgroundColor = StyleKit.CardFooterBackgroundColor;

            img = new Image()
            {
                Source = source,
                HeightRequest = 10,
                WidthRequest = 10
            };

            var label = new Label()
            {
                Text = text,
                FontSize = 9,
                FontAttributes = FontAttributes.Bold,
                TextColor = StyleKit.LightTextColor
            };

            var tapGestureRecognizer = new TapGestureRecognizer();
            tapGestureRecognizer.Tapped += (sender, e) => {

                if (label.Text == "Navigeer")
                {
                    label.Text = "geklikt";
                    Geocode geo = new Geocode();
                    geo.Latitude = opdracht.Latitude;
                    geo.Longitude = opdracht.Longitude;

                    Place place = new Place();

                    if (Device.OS == TargetPlatform.iOS)
                    {
                        place.Name = adrestText;
                        place.Vicinity = "Brugge";
                    }
                    else
                    {
                        place.Name = "Brugge";
                        place.Vicinity = adrestText;
                    }
                    place.Location = geo;

                    LaunchMapApp(place);

                }
                else if (label.Text == "Start")
                {
                    label.Text = "Stop";
                    opdracht.Statuslabel = "Stop";
                    img.Source = StyleKit.Icons.Stop;
                    opdracht.starttijd = DateTime.Now;
                    DataController.Instance.Update(opdracht);
                    SyncController.Instance.SyncNeeded();

                    bool found = false;
                    foreach (Prestatie pres in presatielijst)
                    {
                        if (pres.OpdrachtID == opdracht.ID)
                        {
                            found = true;
                        }
                    }

                    if (!found)
                    {
                        Prestatie presatie = new Prestatie();
                        presatie.Aanvang = DateTime.Now;
                        presatie.Duur = 0;
                        presatie.OpdrachtID = opdracht.ID;
                        DataController.Instance.Insert(presatie);
                        SyncController.Instance.SyncNeeded();
                    }

                }
                else if (label.Text == "Stop")
                {
                    label.Text = "Start";
                    opdracht.Statuslabel = "Start";
                    img.Source = StyleKit.Icons.Resume;
                    Debug.WriteLine("gevonden tijd: " + opdracht.starttijd);
                    start = opdracht.starttijd.Value.TimeOfDay;
                    DataController.Instance.Update(opdracht);
                    SyncController.Instance.SyncNeeded();
                    einde = DateTime.Now.TimeOfDay;
                    TimeSpan tijd = CalculateTime();

                    foreach (Prestatie pres in presatielijst)
                    {
                        if (pres.OpdrachtID == opdracht.ID)
                        {
                            pres.Duur = pres.Duur + Convert.ToDecimal(tijd.TotalMinutes);
                            DataController.Instance.Update(pres);
                            SyncController.Instance.SyncNeeded();
                        }
                    }
                }
            };

            label.GestureRecognizers.Add(tapGestureRecognizer);

            //TO-DO: latitude & longitude in een navigeerknop.
            //opdracht.Latitude, opdracht.Longitude

            var stack = new StackLayout()
            {
                Padding = new Thickness(5),
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions = LayoutOptions.Center,
                Children = {
                    img,label
                }
            };

            Content = stack;
        }
Exemplo n.º 52
0
 public static string GetArticle(string type, string id, Geocode location, bool enableDebug, Verbosity verbosity, List<string> fields)
 {   
     var url = new Url(ArticleServiceBase).Append(type).Append(id);
     HandleDefaults(url, location, enableDebug, verbosity, fields);
     return url.ToString();
 }
Exemplo n.º 53
0
 public static string GetListContent(string name, int pageNumber, int pageSize, Geocode geocode, bool enableDebugging, Verbosity verbosity, List<string> fields)
 {
     //https://apis.appacitive.com/list/<listname>/contents
     var url = new Url(ListServiceBase);
     url.Append(name).Append("contents");
     if (pageNumber != 1)
         url.QueryString["pnum"] = pageNumber.ToString();
     if (pageSize > 0)
         url.QueryString["psize"] = pageSize.ToString();
     HandleDefaults(url, geocode, enableDebugging, verbosity, fields);
     return url.ToString();
 }
Exemplo n.º 54
0
 public static string GraphProject(string query, Geocode geocode, bool enableDebugging, Verbosity verbosity, List<string> fields)
 {
     var url = new Url(GraphServiceBase);
     url.Append(query).Append("project");
     HandleDefaults(url, geocode, enableDebugging, verbosity, fields);
     return url.ToString();
 }
 public AuthenticateUserRequest(string sessionToken, Environment environment, string userToken = null, Geocode location = null, bool enableDebugging = false, Verbosity verbosity = Verbosity.Info) :
     base(sessionToken, environment, userToken, location, enableDebugging, verbosity)
 {
     this.Attributes = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
 }
Exemplo n.º 56
0
 public static string SendPushNotification(Geocode geocode, bool enableDebugging, Verbosity verbosity, List<string> fields)
 {
     var url = new Url(PushServiceBase);
     HandleDefaults(url, geocode, enableDebugging, verbosity, fields);
     return url.ToString();
 }
Exemplo n.º 57
0
 public static string SendEmail(Geocode geocode, bool enableDebugging, Verbosity verbosity, List<string> fields)
 {
     var url = new Url(EmailServiceBase).Append("send");
     HandleDefaults(url, geocode, enableDebugging, verbosity, fields);
     return url.ToString();
 }
Exemplo n.º 58
0
 public static string InitiateResetPassword(Geocode geocode, bool enableDebugging, Verbosity verbosity)
 {
     var url = new Url(UserServiceBase).Append("sendresetpasswordemail");
     HandleDefaults(url, geocode, enableDebugging, verbosity, null);
     return url.ToString();
     
 }
Exemplo n.º 59
0
 public static string ValidateUserSession(Geocode geocode, bool debugEnabled, Verbosity verbosity)
 {
     var url = new Url(UserServiceBase);
     url.Append("validate");
     HandleDefaults(url, geocode, debugEnabled, verbosity, null);
     return url.ToString();
 }
Exemplo n.º 60
0
 public static string UpdateArticleUrl(string type, string id, Geocode userLocation, List<string> fields)
 {
     return string.Format("{0}/{1}/{2}", ArticleServiceBase, type, id);
 }