示例#1
0
        public SalesAddViewModel(ISalesDatabase isd, ICustomerDatabase icd, ISalesLineDatabase isld, IDialogService ids, IGeoCoder geocoder)
        {
            salesDb       = isd;
            customerDb    = icd;
            salesLineDb   = isld;
            dialog        = ids;
            this.geocoder = geocoder;

            if (!GlobalVars.customerListIsLoaded)
            {
                loadCustomer();
            }
            RaisePropertyChanged(() => CustomerSelection);
            if (SelectedCustomer != null)
            {
                RaisePropertyChanged(() => SelectedCustomer);
            }
            if (InsertSalesItemsList != null)
            {
                if (InsertSalesItemsList.Count() > 0)
                {
                    RaisePropertyChanged(() => InsertSalesItemsList);
                    RaisePropertyChanged(() => TotalDiscountAmount);
                    RaisePropertyChanged(() => Total);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Geocodes the given address and returns the result.
        /// </summary>
        /// <param name="coderName"></param>
        /// <param name="country"></param>
        /// <param name="postalCode"></param>
        /// <param name="commune"></param>
        /// <param name="street"></param>
        /// <param name="houseNumber"></param>
        /// <returns></returns>
        public static IGeoCoderResult Code(
            string coderName,
            string country,
            string postalCode,
            string commune,
            string street,
            string houseNumber)
        {
            IGeoCoder coderInstance = null;

            // create and cache the coder class.
            if (_coders == null)
            {
                _coders = new Dictionary <string, IGeoCoder>();
            }
            if (!_coders.TryGetValue(coderName, out coderInstance))
            {
                throw new InvalidOperationException(string.Format(
                                                        "No geocoder registered with name: {0}", coderName));
            }

            return(coderInstance.Code(
                       country,
                       postalCode,
                       commune,
                       street,
                       houseNumber));
        }
        //----------------------------------------------------------------------
        private static IntSet <PartyId> SearchByCity(
            Timer t,
            AddressParserResult searchLocale,
            int desiredResultCount,
            int maxResultCount,
            double nonGeoMatchAbsDensity,
            out Location centroid,
            out double?maxRadiusMi)
        {
            maxRadiusMi = null;

            if (desiredResultCount == ExactMatchResultCount)
            {
                IntSet <PartyId> partiesInCity = null;
                t.Measure("Search by City", delegate() {
                    partiesInCity = Snap.Cache.Cache.City(searchLocale);
                });
                centroid = null;
                return(partiesInCity);
            }
            else
            {
                IGeoCoder geocoder = GeoCoderFactory.CreateGeoCoder();
                centroid = geocoder.GeoCode(
                    searchLocale.City,
                    searchLocale.StateCode);
                return(SearchNearLocation(
                           t,
                           desiredResultCount,
                           centroid,
                           nonGeoMatchAbsDensity,
                           out maxRadiusMi));
            }
        }
 public FormManualMatch(IGeoCoder geoCoder, DataGridView parentGrid)
 {
     InitializeComponent();
     this.geoCoder = geoCoder;
     this.parentGrid = parentGrid;
     suggestedMatch = geoCoder.SuggestedMatch();
 }
 public FormManualMatch(IGeoCoder geoCoder, DataGridView parentGrid)
 {
     InitializeComponent();
     this.geoCoder   = geoCoder;
     this.parentGrid = parentGrid;
     suggestedMatch  = geoCoder.SuggestedMatch();
 }
 public LocationService(ILocationDeterminator locationDeterminator, 
                     IRepository repository,
                     IGeoCoder geoCoder)
 {
     _locationDeterminator = locationDeterminator;
     _repository = repository;
     _geoCoder = geoCoder;
 }
 public AccountController(IUserService userservice, IDishService dishservice, IGeoCoder geocodeservice, IImageService imageservice, IReservationService reservationservice)
 {
     UserSvc = userservice;
     DishSvc = dishservice;
     GeocodeSvc = geocodeservice;
     ImageSvc = imageservice;
     ReservationSvc = reservationservice;
 }
 public FormLoadInput(IGeoCoder geoCoder)
 {
     if (geoCoder == null)
     {
         throw new ArgumentNullException("geoCoder");
     }
     InitializeComponent();
     this.geoCoder = geoCoder;
 }
示例#9
0
        /// <summary>
        /// Registers a geocoder under it's given name.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="code"></param>
        public static void RegisterGeoCoder(string name, IGeoCoder code)
        {
            // create and cache the coder class.
            if (_coders == null)
            {
                _coders = new Dictionary <string, IGeoCoder>();
            }

            _coders[name] = code;
        }
示例#10
0
        bool IJob.Initialize(IServiceProvider serviceProvider)
        {
            _settings = serviceProvider.GetService <ISettingsServiceInternal>();

            _provider = ExportedTypeLibrary.Import <IGeoCoder>(_settings.GetSetting("Geocoding", "Provider").GetValue <string>());
            if (_provider.ApiKeyRequired)
            {
                string apikey = _settings.GetSetting("Geocoding", "ApiKey").GetValue <string>();
                _provider.ApiKey = apikey;
            }
            return(true);
        }
示例#11
0
        bool IJob.Initialize(IServiceProvider serviceProvider)
        {
            _settings = serviceProvider.GetService<ISettingsServiceInternal>();

            _provider = ExportedTypeLibrary.Import<IGeoCoder>(_settings.GetSetting("Geocoding", "Provider").GetValue<string>());
            if (_provider.ApiKeyRequired)
            {
                string apikey = _settings.GetSetting("Geocoding", "ApiKey").GetValue<string>();
                _provider.ApiKey = apikey;
            }
            return true;
        }
示例#12
0
        bool IJob.Initialize(IServiceProvider serviceProvider)
        {
            _settings = serviceProvider.GetService<ISettingsServiceInternal>();

            _provider = ExportedTypeLibrary.Import<IGeoCoder>(_settings.GetSetting(SettingKeysJob.Provider).GetValue<string>());

            if (_provider.IsApiKeyRequired)
            {
                _provider.ApiKey = _settings.GetSetting(SettingKeysJob.ApiKey).GetValue<string>();
            }

            return true;
        }
示例#13
0
        bool IJob.Initialize(IServiceProvider serviceProvider)
        {
            _settings = serviceProvider.GetService <ISettingsServiceInternal>();

            _provider = ExportedTypeLibrary.Import <IGeoCoder>(_settings.GetSetting(SettingKeysJob.Provider).GetValue <string>());

            if (_provider.IsApiKeyRequired)
            {
                _provider.ApiKey = _settings.GetSetting(SettingKeysJob.ApiKey).GetValue <string>();
            }

            return(true);
        }
示例#14
0
        public FirstPageViewModel(INavigationService navigationService, IGeoCoder geoCoder)
        {
            Address.Value = "東京都渋谷区";
            NextCommand   = Address.Select(x => !string.IsNullOrEmpty(x)).ToReactiveCommand();

            NextCommand.Subscribe(async _ =>
            {
                var res = await geoCoder.Forward(Address.Value);
                if (res != null)
                {
                    await navigationService.NavigateAsync($"SecondPage?lat={res.Latitude}&lng={res.Longitude}&title={res.DisplayName}");
                }
            });
        }
 public TravelersAroundService(IRepository repository, 
                             IMembership membership,
                             IGeoCoder geoCoder,
                             ILocationDeterminator locationDeterminator,
                             ILog log,
                             ICache cache,
                             IAPIKeyGenerator apiKeyGen)
     : base(log)
 {
     _repository = repository;
     _membership = membership;
     _locationDeterminator = locationDeterminator;
     _geoCoder = geoCoder;
     _cache = cache;
     _apiKeyGen = apiKeyGen;
 }
示例#16
0
        private void InitializeProvider()
        {
            var providerName = _settings.GetSetting(SettingKeysJob.Provider).GetValue <string>();

            _provider = ExportedTypeLibrary.Import <IGeoCoder>(providerName);

            Logger.Instance.LogFormat(LogType.Debug, this, Properties.Resources.UsingProviderTrace, providerName);

            if (_provider.IsApiKeyRequired)
            {
                _provider.ApiKey = _settings.GetSetting(SettingKeysJob.ApiKey).GetValue <string>();

                if (string.IsNullOrEmpty(_provider.ApiKey))
                {
                    Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.NoKeyForGeocodingService, providerName);
                }
            }
        }
示例#17
0
        public SettingsViewModel(ISettings settings, Keys keys, IGeoCoder locator, ICongress congress, INavigationService2 navigationService)
            : base(navigationService)
        {
            _settings = settings;
            _congress = congress;
            _zipSearchVm = new ZipCodeSearchViewModel(navigationService);
            _geoVM = new GeoLocationViewModel(keys, navigationService);
            _locator = locator;

            _location = _settings.Location;
            if (_location != null)
            {
                _zipcode = _location.ZipCode;
            }

            _district = new RemoteResult<dynamic>(() => _congress.FindFirstDistrict(_location.Lat, _location.Long), 
                () => RaisePropertiesChanged("District"), new ExpandoObject());
        }
        //----------------------------------------------------------------------
        private static IntSet <PartyId> SearchNearStreetAddress(
            Timer t,
            AddressParserResult searchLocale,
            int desiredResultCount,
            int maxResultCount,
            double nonGeoMatchAbsDensity,
            out Location centroid,
            out double?maxRadiusMi)
        {
            if (null == searchLocale.Location)
            {
                IGeoCoder  geocoder = GeoCoderFactory.CreateGeoCoder();
                Location[] ls       = geocoder.GeoCode(
                    searchLocale.StreetAddress,
                    searchLocale.City,
                    searchLocale.StateCode,
                    searchLocale.PostalCode);

                if (ls.Length == 0)
                {
                    throw new ArgumentException("unknown address");
                }

                if (ls.Length > 1)
                {
                    throw new ArgumentException("ambiguous address");
                }

                centroid = ls[0];
            }
            else
            {
                centroid = searchLocale.Location;
            }

            maxRadiusMi = null;
            return(SearchNearLocation(
                       t,
                       desiredResultCount,
                       centroid,
                       nonGeoMatchAbsDensity,
                       out maxRadiusMi));
        }
示例#19
0
        public SearchService()
        {
            _dishes = new MongoHelper<Dish>("dishes");
            _users = new MongoHelper<User>("users");
            _geocode = new GoogleGeoCoder();

            //takes 2 parameters:
            //the current user given by the linq query ( selector )
            //the address given by the user performing the search, instanciated as a Geocoding.Address type.
            //returns true if the distance between the current user selector and the given address is less than the distance scope,
            // otherwise, false.
            dishinmiles = (user, addressrequested) =>
                {
                  return _geocode
                   .ReverseGeocode(user.Location.Coordinates[1], user.Location.Coordinates[0])
                   .FirstOrDefault()
                   .DistanceBetween(addressrequested, DistanceUnits.Miles).Value < Scope;
                };
        }
示例#20
0
        public MapViewModel(IGeoCoder geocoder)
        {
            this.geocoder = geocoder;

            SelectLocationCommand = new MvxCommand <LocationAutoCompleteResult>(selectedLocation =>
            {
                SetNewDestinationAddress(selectedLocation.LocalizedName);
            });

            ButtonSearch = new MvxCommand(() =>
            {
                if (SearchTerm.Length > 3 && MyLocation != null)
                {
                    SearchLocations(MyLocation, SearchTerm);
                }
            });

            ButtonMenu = new MvxCommand(() =>
            {
                ShowViewModel <ScanViewModel>();
            });
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FormLoadGazetteer"/> class.
        /// Reads the gazetteer file path from the args, used in testing. 
        /// </summary>
        /// <param name="args">The arguments containing the gazetteer filepath.</param>
        public FormLoadGazetteer(string[] args = null)
        {
            InitializeComponent();
            try
            {
                geoCoder = new GeoCoder();
                if (args != null && args.Length >= 1)
                {
                    string path = args[0];

                    if (!String.IsNullOrWhiteSpace(path))
                    {
                        LoadFile(path);
                        DisplayColumnNameLists();
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.Process("Form load error.", ex);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FormLoadGazetteer"/> class.
        /// Reads the gazetteer file path from the args, used in testing.
        /// </summary>
        /// <param name="args">The arguments containing the gazetteer filepath.</param>
        public FormLoadGazetteer(string[] args = null)
        {
            InitializeComponent();
            try
            {
                geoCoder = new GeoCoder();
                if (args != null && args.Length >= 1)
                {
                    string path = args[0];

                    if (!String.IsNullOrWhiteSpace(path))
                    {
                        LoadFile(path);
                        DisplayColumnNameLists();
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.Process("Form load error.", ex);
            }
        }
示例#23
0
        public MapViewModel(IGeoCoder geocoder)
        {
            this.geocoder = geocoder;
            locations = new ObservableCollection<LocationAutoCompleteResult>();

            SelectLocationCommand = new
                MvxCommand<LocationAutoCompleteResult>(selectedLocation =>
            {
                AddStopPin(selectedLocation.LocalizedName);
            });

            ButtonSearch = new MvxCommand(() =>
            {
                if (SearchTerm.Length > 3 && MyLocation != null)
                {
                    SearchLocations(MyLocation, SearchTerm);
                }
            });

            ButtonMenu = new MvxCommand(() =>
            {
                ShowViewModel<ScanViewModel>();
            });
        }
		public HomeController(IGeoCoder geoCoder)
		{
			this.geoCoder = geoCoder;
		}
示例#25
0
        public static Address ReadAddress(XmlReader addressReader, IGeoCoder geoCoder)
        {
            Address addr = new Address();

            addressReader.ReadToFollowing("Address");

            while (addressReader.Read())
            {
                if (addressReader.NodeType == XmlNodeType.Element)
                {
                    string elementName = addressReader.Name;

                    //Skip elements that have no text content. eg. <date/>
                    if (addressReader.IsEmptyElement)
                    {
                        continue;
                    }

                    //Reat to text content
                    addressReader.Read();

                    switch (elementName)
                    {
                        case "AddrLine":
                            {
                                addr.addrLine = addressReader.Value;

                                GeoCoding.Address[] addresses = geoCoder.GeoCode(addr.addrLine + "Toronto Canada");
                                if (addresses.Length != 0)
                                {
                                    addr.latCoord = addresses[0].Coordinates.Latitude;
                                    addr.longCoord = addresses[0].Coordinates.Longitude;
                                }

                                break;
                            }
                        case "House":
                            {
                                addr.houseNumber = addressReader.Value;
                                break;
                            }
                        case "Street":
                            {
                                addr.street = addressReader.Value;
                                break;
                            }
                        case "Type":
                            {
                                addr.streetType = addressReader.Value;
                                break;
                            }
                        case "Direction":
                            {
                                addr.streetDirection = addressReader.Value;
                                break;
                            }
                    }
                }
            }

            return addr;
        }
示例#26
0
        public static void ClassInitialize(TestContext context)
        {
            var handler = SimpleIoc.Default.GetInstance<HttpMessageHandler>();

            _service = new GeoCoder(handler, CredentialStore.RetrieveObject("bing.key.json").Key, "Portable-Bing-GeoCoder-UnitTests/1.0");
        }
示例#27
0
        public GeoCoderTest()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-us");

            geoCoder = CreateGeoCoder();
        }
示例#28
0
        public static void ClassInitialize(TestContext context)
        {
            var handler = SimpleIoc.Default.GetInstance <HttpMessageHandler>();

            _service = new GeoCoder(handler, CredentialStore.RetrieveObject("bing.key.json").Key, "Portable-Bing-GeoCoder-UnitTests/1.0");
        }
示例#29
0
 public FormLoadInput(IGeoCoder geoCoder)
 {
     if (geoCoder == null) throw new ArgumentNullException("geoCoder");
     InitializeComponent();
     this.geoCoder = geoCoder;
 }
示例#30
0
        /// <summary>
        /// Registers a geocoder under it's given name.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="code"></param>
        public static void RegisterGeoCoder(string name, IGeoCoder code)
        {
            // create and cache the coder class.
            if (_coders == null)
            {
                _coders = new Dictionary<string, IGeoCoder>();
            }

            _coders[name] = code;
        }
示例#31
0
 public HomeController(IGeoCoder geoCoder)
 {
     this.geoCoder = geoCoder;
 }
示例#32
0
        public MainViewModel(IGeoCoder geocoder)
        {
            _geocoder = geocoder;

            LookupAddress = new RelayCommand(() => Lookup(), () => !string.IsNullOrEmpty(Landmark));
        }
示例#33
0
        public static void ReadInvestigation(XmlReader investigationReader, SQLiteCommand cmd, IGeoCoder geoCoder)
        {
            string inNum = "";
            string inDate = "";
            string noticeDate = "";
            string nextInDate = "";
            string expiryDate = "";
            string issue = "";
            string status = "";
            Address addr = null;
            List<Deficiency> deficiencyList = null;

            //Read investigation element
            investigationReader.Read();

            while (investigationReader.Read())
            {
                if (investigationReader.NodeType == XmlNodeType.Element)
                {
                    string elementName = investigationReader.Name;

                    //Skip elements that have no text content. eg. <date/>
                    if(investigationReader.IsEmptyElement)
                    {
                        continue;
                    }

                    switch (elementName)
                    {
                        case "InNum":
                        {
                            break;
                        }
                        case "InType":
                        {
                            //Reat to text content
                            investigationReader.Read();

                            string inType = investigationReader.Value;
                            if (inType != "Order Issued Property Standards")
                            {
                                return;
                            }
                            break;
                        }
                        case "InDate":
                        {
                            //Reat to text content
                            investigationReader.Read();

                            inDate = investigationReader.Value;
                            break;
                        }
                        case "NoticeDate":
                        {
                            //Reat to text content
                            investigationReader.Read();

                            noticeDate = investigationReader.Value;
                            break;
                        }
                        case "NextInDate":
                        {
                            //Reat to text content
                            investigationReader.Read();

                            nextInDate = investigationReader.Value;
                            break;
                        }
                        case "ExpiryDate":
                        {
                            //Reat to text content
                            investigationReader.Read();

                            expiryDate = investigationReader.Value;
                            break;
                        }
                        case "Issue":
                        {
                            //Reat to text content
                            investigationReader.Read();

                            issue = investigationReader.Value;
                            break;
                        }
                        case "Status":
                        {
                            //Reat to text content
                            investigationReader.Read();

                            status = investigationReader.Value;
                            break;
                        }
                        case "Addresses":
                        {
                            addr = ReadAddress(investigationReader.ReadSubtree(), geoCoder);
                            break;
                        }
                        case "Deficiencies":
                        {
                            deficiencyList = ReadDeficiencies(investigationReader.ReadSubtree());
                            break;
                        }

                    }
                }
            }

            //Insert entry into sql

            long addrId = -1;

            cmd.CommandText = "SELECT ROWID FROM Address WHERE line = \"" + addr.addrLine + "\"";
            SQLiteDataReader dupAddrReader = cmd.ExecuteReader();
            if (dupAddrReader.Read())
            {
                addrId = (long)dupAddrReader["ROWID"];
            }
            dupAddrReader.Close();

            if (addrId == -1)
            {
                cmd.CommandText = "INSERT INTO Address VALUES(" +
                    "\"" + addr.addrLine + "\", " +
                    "\"" + addr.houseNumber + "\", " +
                    "\"" + addr.street + "\", " +
                    "\"" + addr.streetType + "\", " +
                    "\"" + addr.streetDirection + "\", " +
                    addr.latCoord.ToString() + ", " +
                    addr.longCoord.ToString() +
                    ")";
                cmd.ExecuteNonQuery();

                cmd.CommandText = "SELECT last_insert_rowid()";
                SQLiteDataReader addrIdReader = cmd.ExecuteReader();
                while (addrIdReader.Read())
                {
                    addrId = (long)addrIdReader[0];
                }
                addrIdReader.Close();
            }

            cmd.CommandText = "INSERT INTO Investigation VALUES(" +
                "\"" + inNum +"\", " +
                "\"" + inDate + "\", " +
                "\"" + noticeDate + "\", " +
                "\"" + nextInDate + "\", " +
                "\"" + expiryDate + "\", " +
                "\"" + issue + "\", " +
                "\"" + status +"\", " +
                addrId.ToString() +
                ")";
            cmd.ExecuteNonQuery();

            long investigationId = -1;
            cmd.CommandText = "SELECT last_insert_rowid()";
            SQLiteDataReader investigationIdReader = cmd.ExecuteReader();
            while (investigationIdReader.Read())
            {
                investigationId = (long)investigationIdReader[0];
            }
            investigationIdReader.Close();

            if (deficiencyList != null)
            {
                foreach(Deficiency curDeficiency in deficiencyList)
                {
                    cmd.CommandText = "INSERT INTO Deficiencies VALUES(" +
                        investigationId.ToString() + ", " +
                        "\"" + curDeficiency.location + "\", " +
                        "\"" + curDeficiency.description.Replace('"', '\'') + "\", " +
                        "\"" + curDeficiency.status + "\"" +
                        ")";
                    cmd.ExecuteNonQuery();
                }
            }
        }
示例#34
0
		public GeoCoderTest()
		{
			Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-us");

			geoCoder = CreateGeoCoder();
		}