示例#1
0
        private Geography ResolveLocation(string json)
        {
            if (string.IsNullOrWhiteSpace(json))
            {
                return(null);
            }
            string[] ary = json.Trim().Split(',');
            float    tmp1, tmp2;

            if ((ary.Length == 2 || ary.Length == 3) && float.TryParse(ary[0], out tmp1) && float.TryParse(ary[1], out tmp2))
            {
                if (ary.Length == 3 && ary[2] != null)
                {
                    var d = ary[2].Trim().ToLower();
                    if (d == "weixin")
                    {
                        return(LocationResolver.ConvertLocation((decimal)tmp2, (decimal)tmp1, GeographyType.QQ_Google_AmapMap, GeographyType.GPS));
                    }
                    else if (d == "baidu")
                    {
                        return(LocationResolver.ConvertLocation((decimal)tmp2, (decimal)tmp1, GeographyType.BaiduMap, GeographyType.GPS));
                    }
                }
                return(new Geography {
                    Longitude = tmp1, Latitude = tmp2
                });                                                         // GPS
            }
            return(null);
        }
示例#2
0
 public TokenWithSpan(TokenWithSpan currentToken, JSToken newToken)
 {
     _indexResolver = currentToken._indexResolver;
     _start         = currentToken._start;
     _end           = currentToken._end;
     _token         = newToken;
 }
示例#3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                var props = Properties.Settings.Default;
                _connector = new ExchangeConnector.ExchangeConnector(props.email);

                string currentSite = props.currentSite;
                _locations = new LocationResolver();
                _locations.Load("locationMap.csv");
                _connector.LocationFilter = _locations.OfSite(currentSite).ToArray();                 // filter locations by site
                _connector.Connect();

                _myLocation = new Location
                {
                    Site     = props.currentSite,
                    Building = props.currentBuilding,
                    Floor    = props.currentFloor
                };
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Application.Exit();
            }
        }
示例#4
0
 internal TokenWithSpan(LocationResolver indexResolver, int start, int end, JSToken token)
 {
     _token         = token;
     _start         = start;
     _end           = end;
     _indexResolver = indexResolver;
 }
示例#5
0
        LocationReference ILocationQuery.ResolvePostalSuburb(Country country, string location, ICollection <NamedLocation> suggestions, int maximumSuggestions)
        {
            var reference = new LocationReference();

            LocationResolver.ResolvePostalSuburb(reference, country, location, suggestions, maximumSuggestions);
            return(reference);
        }
示例#6
0
        LocationReference ILocationQuery.ResolvePostalSuburb(Country country, string location)
        {
            var reference = new LocationReference();

            LocationResolver.ResolvePostalSuburb(reference, country, location, null, 0);
            return(reference);
        }
示例#7
0
        public void InValidateGenBankLocationGetStart()
        {
            // Build a location.
            LocationResolver locResolver = new LocationResolver();

            // Validate GetStart method exception.
            try
            {
                locResolver.GetStart(null);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                LogExceptionMessage();
            }

            // Validate GetEnd method exception.
            try
            {
                locResolver.GetEnd(null);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                LogExceptionMessage();
            }
        }
示例#8
0
        private Result GetLocationResolver(out LocationResolver resolver, StorageId storageId)
        {
            UnsafeHelpers.SkipParamInit(out resolver);

            if (!IsValidStorageId(storageId))
            {
                return(ResultLr.LocationResolverNotFound.Log());
            }

            using ScopedLock <SdkMutexType> lk = ScopedLock.Lock(ref _mutex);

            int index = GetResolverIndexFromStorageId(storageId);
            ref LocationResolver lr = ref _resolvers[index];
示例#9
0
        public void InValidateGenBankLocationEndData()
        {
            // Get Values from XML node.
            string position = utilityObj.xmlUtil.GetTextValue(
                Constants.LocationWithEndDataNode, Constants.Position);

            // Build a location.
            LocationResolver locResolver = new LocationResolver();

            // Validate whether mentioned end data is present in the location
            // or not.
            try
            {
                locResolver.IsInEnd(null, Int32.Parse(position, (IFormatProvider)null));
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                       "GenBankFeatures P2 : Validate the exception successfully"));
                Console.WriteLine(string.Format((IFormatProvider)null,
                                                "GenBankFeatures P2 : Validate the exception successfully"));
            }

            // Validate IsInStart method exception.
            try
            {
                locResolver.IsInStart(null, Int32.Parse(position, (IFormatProvider)null));
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                LogExceptionMessage();
            }

            // Validate IsInRange method exception.
            try
            {
                locResolver.IsInRange(null, Int32.Parse(position, (IFormatProvider)null));
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                LogExceptionMessage();
            }
        }
示例#10
0
        /// <summary>
        /// InValidate GenBank location with invalid Start location data.
        /// <param name="endData">Start data used for different test cases.</param>
        /// </summary>
        private static void InValidateLocationStartData(string startData)
        {
            // Build a location.
            LocationResolver locResolver = new LocationResolver();
            string           location    = "123.125";
            ILocationBuilder locBuilder  = new LocationBuilder();
            ILocation        loc         = locBuilder.GetLocation(location);

            // Set Invalid end data Validate GetStart method exception.
            loc.StartData = startData;
            try
            {
                locResolver.IsInStart(loc, 124);
                Assert.Fail();
            }
            catch (Exception)
            {
                LogExceptionMessage();
            }
        }
示例#11
0
 private async void bnSearch_Click(object sender, RoutedEventArgs e)
 {
     //Use the static method ResolveWeatherCode to get the WOEID code of a city, poi or weather station
     tbLocation.Text = await LocationResolver.ResolveLocationToWoeid(tbSearch.Text);
 }
示例#12
0
 public TokenWithSpan(TokenWithSpan currentToken, JSToken newToken) {
     _indexResolver = currentToken._indexResolver;
     _start = currentToken._start;
     _end = currentToken._end;
     _token = newToken;
 }
示例#13
0
 internal TokenWithSpan(LocationResolver indexResolver, int start, int end, JSToken token) {
     _token = token;
     _start = start;
     _end = end;
     _indexResolver = indexResolver;
 }
示例#14
0
 void ILocationQuery.ResolveLocation(LocationReference reference, Country country, string location)
 {
     LocationResolver.ResolveLocation(reference, country, location, null, 0);
 }
示例#15
0
 void ILocationQuery.ResolvePostalSuburb(LocationReference reference, Country country, string location)
 {
     LocationResolver.ResolvePostalSuburb(reference, country, location, null, 0);
 }
示例#16
0
        public void InValidateSubSequenceWithComplimentOperator()
        {
            // Get Values from XML node.
            string sequence = utilityObj.xmlUtil.GetTextValue(
                Constants.InvalidLocationWithComplementOperatorNode,
                Constants.ExpectedSequence);
            string location = utilityObj.xmlUtil.GetTextValue(
                Constants.InvalidLocationWithComplementOperatorNode,
                Constants.Location);
            string alphabet = utilityObj.xmlUtil.GetTextValue(
                Constants.InvalidLocationWithComplementOperatorNode,
                Constants.AlphabetNameNode);

            // Create a sequence object.
            ISequence seqObj = new Sequence(Utility.GetAlphabet(alphabet),
                                            sequence);

            // Build a location.
            ILocationBuilder locBuilder  = new LocationBuilder();
            ILocation        loc         = locBuilder.GetLocation(location);
            LocationResolver locResolver = new LocationResolver();

            // Get sequence using location of the sequence with operator.
            try
            {
                loc.GetSubSequence(seqObj);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
                LogExceptionMessage();
            }

            // Validate sub sequence exception for an invalid sequence.
            try
            {
                locResolver.GetSubSequence(loc, null);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                LogExceptionMessage();
            }

            // Validate GetSubSequence method with null location.
            try
            {
                locResolver.GetSubSequence(null, seqObj);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                LogExceptionMessage();
            }

            // Validate sub sequence exception for an invalid sequence.
            try
            {
                locResolver.GetSubSequence(loc, null, null);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                LogExceptionMessage();
            }

            // Validate GetSubSequence method with null location.
            try
            {
                locResolver.GetSubSequence(null, seqObj, null);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                LogExceptionMessage();
            }

            // Validate GetSubSequence method with null location.
            try
            {
                loc.GetSubSequence(null);
                Assert.Fail();
            }
            catch (ArgumentNullException)
            {
                ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                       "GenBankFeatures P2 : Validate the exception successfully"));
            }
        }
示例#17
0
 void ILocationQuery.ResolveLocation(LocationReference reference, Country country)
 {
     LocationResolver.ResolveLocation(reference, country, string.Empty, null, 0);
 }