Esempio n. 1
0
        public void CanConvert_checkForType_expectTrue()
        {
            LocationConverter <LocationImpl> locationConverter = new LocationConverter <LocationImpl>((x) => new LocationImpl(x));
            LocationImpl location = new LocationImpl(new Coordinate(1.2, 2.4));

            Assert.True(locationConverter.CanConvert(location.GetType()));
        }
Esempio n. 2
0
        public virtual IHttpActionResult SaveCurrentLocation([FromBody] LocationRequest locationRequest)
        {
            var response        = new InsertLocationResponse();
            var requestValidate = new ValidateRequestEngine(locationRequest);

            try
            {
                if (requestValidate.IsValid)
                {
                    LocationDa da = new LocationDa();
                    da.SaveChanges(LocationConverter.Convert(locationRequest));
                    response.Success = true;
                    response.Message = "Saved Location.";
                    da.Dispose();
                }
                else
                {
                    response.Success = false;
                    response.Message = requestValidate.Message;
                    return(new HttpActionResult(HttpStatusCode.BadRequest, response));
                }
            }
            catch (Exception ex)
            {
            }
            return(new HttpActionResult(HttpStatusCode.OK, response));
        }
Esempio n. 3
0
        public MainWindow()
        {
            InitializeComponent();
            CLocation.GetLocationEvent();
            CLocation.MainWin = this;
            LocationConverter locConverter = new LocationConverter();

            //set default parameters
            global.DomainName = "auth.hpicorp.net";
            string x = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName;

            geoIp2.Text = x;
            Visibility  = Visibility.Hidden;

            global.Locations = new LocationCollection()
            {
                new Location(29.991445, -95.585568),
                new Location(29.991389, -95.580096),
                new Location(29.988248, -95.579860),
                new Location(29.987988, -95.585375)
            };

            /// Immmediately start the Check window
            /// Don't show this window
            /// This window is unnecessary
        }
Esempio n. 4
0
        public IHttpActionResult RegisterDetailer(RegistrationModel registration)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = new User
            {
                UserName = registration.Username
            };

            var detailer = new Detailer
            {
                Address      = registration.Address,
                Cellphone    = registration.Cellphone,
                EmailAddress = registration.EmailAddress,
                FirstName    = registration.FirstName,
                LastName     = registration.LastName,
                Location     = LocationConverter.GeocodeAddress(registration.Address)
            };

            user.Detailer = detailer;

            var result = _userManager.Create(user, registration.Password);

            if (result.Succeeded)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest("Invalid user registration"));
            }
        }
Esempio n. 5
0
        private void mapClick(object sender, MouseButtonEventArgs e)
        {
            Popup             display           = new Popup();
            LocationConverter locationConverter = new LocationConverter();
            int      count         = this.Map.Children.Count;
            Point    clickPoint    = e.GetPosition(this);
            Location clickLocation = Map.ViewportPointToLocation(clickPoint);
            Pushpin  testPin;

            for (int i = 0; i < count; i++)
            {
                //check for if a pin is hit by this mouse click
                testPin = (Pushpin)Map.Children[i];
                double check_lat  = testPin.Location.Latitude - clickLocation.Latitude;
                double check_long = testPin.Location.Longitude - (clickLocation.Longitude + 40);
                if ((0 < check_lat && check_lat < 4) && (-2 < check_long && check_long < 2))
                {
                    //Process.Start(testPin.Content.ToString());
                    if (null != clicked)
                    {
                        clicked(testPin.Content, null);
                    }
                    return;
                }
            }
        }
        public void GivenInvalidLocationReturnsNotValid(string location)
        {
            var converter = new LocationConverter();

            (bool isValid, Point point) = converter.TryGetPoint(location, new Size(10, 10));

            isValid.Should().BeFalse();
        }
        public void EnsureLocationConverterConvertsToAGeoCoordinate()
        {
            Location location = new Location() { Latitude = TestLatitude, Longitude = TestLongitude };
            LocationConverter converter = new LocationConverter();
            GeoCoordinate coord = converter.Convert(location, typeof(GeoCoordinate), null, null) as GeoCoordinate;

            Assert.AreEqual(location.Latitude, coord.Latitude, "Expected same Latitude");
            Assert.AreEqual(location.Longitude, coord.Longitude, "Expected same Longitude");
        }
        public void GivenValidLocationReturnPoint(string location, int x, int y)
        {
            var converter = new LocationConverter();

            (bool isValid, Point point) = converter.TryGetPoint(location, new Size(10, 10));

            isValid.Should().BeTrue();

            point.Should().Be(new Point(x, y));
        }
Esempio n. 9
0
        private void doubleClick_offset(object sender, MouseButtonEventArgs e)
        {
            LocationConverter locationConverter = new LocationConverter();
            int      count         = this.Map.Children.Count;
            Point    clickPoint    = e.GetPosition(this);
            Location clickLocation = Map.ViewportPointToLocation(clickPoint);
            double   check_lat     = clickLocation.Latitude;
            double   check_long    = clickLocation.Longitude;

            return;
        }
Esempio n. 10
0
        public void EnsureLocationConverterConvertsToAGeoCoordinate()
        {
            Location location = new Location()
            {
                Latitude = TestLatitude, Longitude = TestLongitude
            };
            LocationConverter converter = new LocationConverter();
            GeoCoordinate     coord     = converter.Convert(location, typeof(GeoCoordinate), null, null) as GeoCoordinate;

            Assert.AreEqual(location.Latitude, coord.Latitude, "Expected same Latitude");
            Assert.AreEqual(location.Longitude, coord.Longitude, "Expected same Longitude");
        }
Esempio n. 11
0
        private static List <LocationPlaceholder> SetupList()
        {
            List <LocationPlaceholder> list = new List <LocationPlaceholder>
            {
                LocationConverter.CreateNewLocationPlaceholder(0, "Location1", 0.5m, 1.0m),
                LocationConverter.CreateNewLocationPlaceholder(1, "Location2", 1.0m, 1.1m),
                LocationConverter.CreateNewLocationPlaceholder(2, "Location3", 1.5m, 1.2m),
                LocationConverter.CreateNewLocationPlaceholder(3, "Location4", 2.0m, 1.3m),
                LocationConverter.CreateNewLocationPlaceholder(4, "Location5", 2.5m, 1.4m)
            };

            return(list);
        }
Esempio n. 12
0
        /// <summary>Creates an instance for the default language.</summary>
        /// <returns>A repository.</returns>
        public IEventRepository ForDefaultCulture()
        {
            var vector2DConverter                   = new Vector2DConverter();
            var vector3DConverter                   = new Vector3DConverter();
            var dynamicEventFlagConverter           = new DynamicEventFlagConverter();
            var dynamicEventFlagCollectionConverter = new DynamicEventFlagCollectionConverter(dynamicEventFlagConverter);
            var locationConverterFactory            = new LocationConverterFactory(vector2DConverter);
            var locationConverter                   = new LocationConverter(locationConverterFactory, vector3DConverter);
            var dynamicEventConverter               = new DynamicEventConverter(dynamicEventFlagCollectionConverter, locationConverter);
            var dynamicEventCollectionConverter     = new DynamicEventCollectionConverter(dynamicEventConverter);

            return(new EventRepository(this.serviceClient, dynamicEventCollectionConverter));
        }
Esempio n. 13
0
        public async Task AddLocation(DomainLocation newLocation, string travelIdentity)
        {
            var location = LocationConverter.ToDbLocation(newLocation);
            var tours    = await TriposoApiClient.GetTourInformation(location.Name);

            var toursDb = tours.Select(t => TourConverter.ToDbTour(t));

            foreach (var t in toursDb)
            {
                await TourRepository.AddTour(t, travelIdentity);
            }
            await LocationRepository.AddLocation(location, travelIdentity);
        }
Esempio n. 14
0
        public IHttpActionResult PutDetailer(int id, Detailer detailer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != detailer.DetailerId)
            {
                return(BadRequest());
            }

            var dbDetailer = db.Detailers.Find(id);

            dbDetailer.DetailerId   = detailer.DetailerId;
            dbDetailer.FirstName    = detailer.FirstName;
            dbDetailer.LastName     = detailer.LastName;
            dbDetailer.Address      = detailer.Address;
            dbDetailer.EmailAddress = detailer.EmailAddress;
            // Loops over the incoming availabilities
            foreach (var Availability in detailer.DetailerAvailabilities)
            {
                // For each on grab databases version of availability
                var dbAvailability = dbDetailer.DetailerAvailabilities.FirstOrDefault(avail => avail.DetailerId == Availability.DetailerId && avail.DayOfWeekId == Availability.DayOfWeekId);
                // Update databases version with new info
                dbAvailability.Start = Availability.Start;
                dbAvailability.End   = Availability.End;
            }
            dbDetailer.Cellphone = detailer.Cellphone;
            dbDetailer.Location  = LocationConverter.GeocodeAddress(dbDetailer.Address);

            db.Entry(dbDetailer).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DetailerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 15
0
        /// <summary>Creates an instance for the given language.</summary>
        /// <param name="culture">The culture.</param>
        /// <returns>A repository.</returns>
        public IEventRepository ForCulture(CultureInfo culture)
        {
            var vector2DConverter                   = new Vector2DConverter();
            var vector3DConverter                   = new Vector3DConverter();
            var dynamicEventFlagConverter           = new DynamicEventFlagConverter();
            var dynamicEventFlagCollectionConverter = new DynamicEventFlagCollectionConverter(dynamicEventFlagConverter);
            var locationConverterFactory            = new LocationConverterFactory(vector2DConverter);
            var locationConverter                   = new LocationConverter(locationConverterFactory, vector3DConverter);
            var dynamicEventConverter               = new DynamicEventConverter(dynamicEventFlagCollectionConverter, locationConverter);
            var dynamicEventCollectionConverter     = new DynamicEventCollectionConverter(dynamicEventConverter);
            IEventRepository repository             = new EventRepository(this.serviceClient, dynamicEventCollectionConverter);

            repository.Culture = culture;
            return(repository);
        }
        /// <summary>
        /// Creates a new location.
        /// </summary>
        /// <param name="locationViewModel"></param>
        /// <param name="ct"></param>
        /// <returns>LocationViewModel</returns>
        public async Task <LocationViewModel> AddLocationAsync(LocationRequestViewModel locationRequestViewModel, CancellationToken ct = default(CancellationToken))
        {
            var location = new Location
            {
                Longitude = (double)locationRequestViewModel.Longitude,
                Latitude  = (double)locationRequestViewModel.Latitude,
                VehicleId = (int)locationRequestViewModel.VehicleId,
                CreatedAt = DateTime.Now
            };

            location = await _repository.AddAsync(location, ct);

            var locationViewModel = LocationConverter.Convert(location);

            return(locationViewModel);
        }
Esempio n. 17
0
        public IHttpActionResult PutCustomer(int id, Customer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != customer.CustomerId)
            {
                return(BadRequest());
            }

            var dbCustomer = db.Customers.Find(id);

            dbCustomer.CustomerId   = customer.CustomerId;
            dbCustomer.FirstName    = customer.FirstName;
            dbCustomer.LastName     = customer.LastName;
            dbCustomer.Address      = customer.Address;
            dbCustomer.EmailAddress = customer.EmailAddress;
            dbCustomer.Cellphone    = customer.Cellphone;
            dbCustomer.Location     = LocationConverter.GeocodeAddress(dbCustomer.Address);
            dbCustomer.Appointments = customer.Appointments;

            db.Entry(dbCustomer).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public void ConvertValueTest()
        {
            //硬件坐标(84)转百度坐标(09) 结果:22.497601820474,113.922039598097
            Assert.NotNull(LocationConverter.Convert84To09(22.4948556106, 113.9106398730));

            //硬件坐标(84)转高德/腾讯坐标(02) 结果:22.4918022270248,113.915497680362
            Assert.NotNull(LocationConverter.Convert84To02(22.4948556106, 113.9106398730));

            //高德腾讯坐标(02)转百度坐标(09) 结果:22.4976512346523,113.922090103635
            Assert.NotNull(LocationConverter.Convert02To09(22.4918523806, 113.9155480930));

            //高德腾讯坐标(02)转硬件坐标(84) 结果:22.4949033119611,113.9106913112
            Assert.NotNull(LocationConverter.Convert02To84(22.4918523806, 113.9155480930));

            //百度坐标(09)转腾讯高德坐标(02) 结果:22.4918188289114,113.915495518286
            Assert.NotNull(LocationConverter.Convert09To02(22.4977230000, 113.9220230000));

            //百度坐标(09)转硬件坐标(84) 结果:22.4948697923719,113.910638735789
            Assert.NotNull(LocationConverter.Convert09To84(22.4977230000, 113.9220230000));
        }
Esempio n. 19
0
        public virtual IHttpActionResult GetCurrentLocation()
        {
            var response = new GetLocationResponse();

            try
            {
                LocationDa da        = new LocationDa();
                var        latestLoc = da.GetLatestLocation();
                var        location  = LocationConverter.ConvertToReponse(latestLoc);
                var        json      = JsonConvert.SerializeObject(location, new JsonSerializerSettings {
                    Formatting = Formatting.None
                });
                response = JsonConvert.DeserializeObject <GetLocationResponse>(json);

                da.Dispose();
            }
            catch (Exception ex)
            {
            }
            return(new HttpActionResult(HttpStatusCode.OK, response));
        }
        /// <summary>
        /// Get the historical location for a vehicle
        /// </summary>
        /// <param name="id"></param>
        /// <param name="ct"></param>
        /// <returns></returns>
        public async Task <List <LocationViewModel> > GetHistoricalLocationByVehicleIdAsync(int id, DateTime?startDate, DateTime?endDate, CancellationToken ct = default(CancellationToken))
        {
            var locations = await _repository.GetHistoricalByVehicleIdAsync(id, startDate, endDate, ct);

            return(LocationConverter.ConvertList(locations).ToList());
        }
Esempio n. 21
0
        public async Task <DomainLocation> GetLocation(string travelIdentity)
        {
            var response = await LocationRepository.GetLocation(travelIdentity);

            return(LocationConverter.ToDomainLocation(response));
        }
        public void DrawMapBinary(List <Point> pts)
        {
            var ln      = new List <Line>();
            var ellipse = new Ellipse();


            ellipse.Width  = 10;
            ellipse.Height = 10;
            ellipse.Fill   = Brushes.Blue;


            var x = new LocationConverter(false);
            var y = new LocationConverter(true);

            MapCanvas.Children.Add(ellipse);
            Canvas.SetLeft(ellipse, pts[1].X - 5);
            Canvas.SetTop(ellipse, pts[1].Y - 5);
            ellipse.PreviewMouseUp += (sender, args) => { };
            if (blackBoard.Count > 0)
            {
                var p = new Line();
                p.PreviewMouseDown += (sender, args) =>
                {
                    if (args.MiddleButton == MouseButtonState.Pressed)
                    {
                        var pt = new Point(args.MouseDevice.GetPosition(MapCanvas).X,
                                           args.MouseDevice.GetPosition(MapCanvas).Y);
                        var line = sender as Line;
                    }
                };


                p.Stroke = Brushes.Black;

                p.X1 = pts[1].X;
                p.Y1 = pts[1].Y;
                p.Y2 = pts[0].Y;
                p.X2 = pts[0].X;
                BindingOperations.SetBinding(p, Line.Y1Property,
                                             new Binding
                {
                    Source             = ellipse,
                    Path               = new PropertyPath(Canvas.TopProperty),
                    ConverterParameter = ellipse,
                    Converter          = y
                });

                BindingOperations.SetBinding(p, Line.X1Property,
                                             new Binding
                {
                    Source             = ellipse,
                    Path               = new PropertyPath(Canvas.LeftProperty),
                    Converter          = x,
                    ConverterParameter = ellipse
                });


                var lastEllipse = blackBoard.Last();
                BindingOperations.SetBinding(p, Line.Y2Property,
                                             new Binding
                {
                    Source             = lastEllipse,
                    Path               = new PropertyPath(Canvas.TopProperty),
                    ConverterParameter = lastEllipse,
                    Converter          = y
                });

                BindingOperations.SetBinding(p, Line.X2Property,
                                             new Binding
                {
                    Source             = lastEllipse,
                    Path               = new PropertyPath(Canvas.LeftProperty),
                    Converter          = x,
                    ConverterParameter = lastEllipse
                });
                p.SetValue(DraggableCanvas.CanBeDraggedProperty, false);
                MapCanvas.Children.Add(p);

                ln.Add(p);
            }


            Panel.SetZIndex(ellipse, 1000);
            blackBoard.Add(ellipse);
        }
Esempio n. 23
0
        async public Task <DomainLocation[]> GetLocationInfoAsync(string cityName)
        {
            var result = await TriposoApiClient.GetLocationInfo(cityName);

            return(result.Select(r => LocationConverter.ToDomainLocation(r)).ToArray());
        }
Esempio n. 24
0
        public void CanWrite_callFunction_expectFalse()
        {
            LocationConverter <LocationImpl> locationConverter = new LocationConverter <LocationImpl>((x) => new LocationImpl(x));

            Assert.False(locationConverter.CanWrite);
        }
Esempio n. 25
0
        private void PtnCheck(object sender, EventArgs e)
        {
            bool PtnFlag = false, LocFlag = false;

            switch (ConvertAll(TBPtnName.Text, out Ptn))
            {
            case PatternError.AlreadyAutoUsed:
                PtnFlag           = true;
                TBPtnPreview.Text = "이미 자동 변수가 사용되었습니다.";
                break;

            case PatternError.CannotAccessString:
                PtnFlag           = false;
                TBPtnPreview.Text = "파일명에 사용하지 못하는 문자가 포함되어 있습니다.";
                break;

            case PatternError.UnknownVariable:
                PtnFlag           = false;
                TBPtnPreview.Text = "알 수 없는 변수가 사용되었습니다.";
                break;

            case PatternError.BlankString:
                PtnFlag           = false;
                TBPtnPreview.Text = "빈 이름은 사용할 수 없습니다.";
                break;

            case PatternError.NoError:
                PtnFlag           = true;
                TBPtnPreview.Text = Ptn;
                break;
            }

            if (PtnFlag)
            {
                TBPtnPreview.ToolTip = (new ToolTip().Content = Ptn);
            }
            else
            {
                TBPtnPreview.ToolTip = null;
            }

            switch (LocationConverter.ConvertAll(TBSaveLoc.Text, out Loc))
            {
            case PatternError.CannotAccessString:
                TBLocPreview.Text = "파일명에 사용하지 못하는 문자가 포함되어 있습니다.";
                LocFlag           = false;
                break;

            case PatternError.UnknownVariable:
                LocFlag = false;
                break;

            case PatternError.NoError:
                TBLocPreview.Text = Loc;
                LocFlag           = true;
                break;
            }

            if (LocFlag)
            {
                TBLocPreview.ToolTip = (new ToolTip().Content = Loc);
            }
            else
            {
                TBLocPreview.ToolTip = null;
            }

            if (PtnFlag && LocFlag)
            {
                ReturnFlag = true;
            }
            else
            {
                ReturnFlag = false;
            }
        }
 private static async Task <Location> UpdateLocation(List <string> claimsList, Guid userId)
 {
     return(await LocationConverter.UpdateLocationAsync(claimsList, userId));
 }
Esempio n. 27
0
 public void EnsureLocationConverterReturnsNullForConvertBack()
 {
     LocationConverter converter = new LocationConverter();
     Assert.IsNull(converter.ConvertBack(string.Empty, null, null, null), "Expected null result");
 }
        private void AddEllipse(List <Point> pts, int i, List <Line> lines)
        {
            var ee = new Ellipse();

            ee.Width  = 10;
            ee.Height = 10;
            ee.Fill   = Brushes.Blue;
            ee.Tag    = pts[i];


            ee.PreviewMouseUp += (sender, args) =>
            {
                if (args.ChangedButton == MouseButton.Middle)
                {
                    for (var index1 = 0; index1 < Points.Count; index1++)
                    {
                        var pointList     = Points[index1];
                        var ellipseSender = sender as Ellipse;
                        var initialPoints = ellipseSender.Tag is Point ? (Point)ellipseSender.Tag : new Point();

                        if (pointList.Contains(initialPoints))
                        {
                            var index = pointList.IndexOf(initialPoints);
                            pointList.RemoveAt(index);
                            RefreshMap();
                            return;
                        }
                    }
                }
                for (var index1 = 0; index1 < Points.Count; index1++)
                {
                    var pointList     = Points[index1];
                    var ellipseSender = sender as Ellipse;
                    var initialPoints = ellipseSender.Tag is Point ? (Point)ellipseSender.Tag : new Point();
                    var pointOnCanvas = new Point(Canvas.GetLeft(ellipseSender) + 5,
                                                  Canvas.GetTop(ellipseSender) + 5);
                    if (pointList.Contains(initialPoints))
                    {
                        var index = pointList.IndexOf(initialPoints);
                        pointList[index] = pointOnCanvas;

                        return;
                    }
                }
            };

            var x = new LocationConverter(false);
            var y = new LocationConverter(true);

            MapCanvas.Children.Add(ee);
            Canvas.SetLeft(ee, pts[i].X - 5);
            Canvas.SetTop(ee, pts[i].Y - 5);
            if (lines.Count > i)
            {
                BindingOperations.SetBinding(lines[i], Line.Y1Property,
                                             new Binding
                {
                    Source             = ee,
                    Path               = new PropertyPath(Canvas.TopProperty),
                    ConverterParameter = ee,
                    Converter          = y
                });

                BindingOperations.SetBinding(lines[i], Line.X1Property,
                                             new Binding
                {
                    Source             = ee,
                    Path               = new PropertyPath(Canvas.LeftProperty),
                    Converter          = x,
                    ConverterParameter = ee
                });
            }
            if (i > 0)
            {
                BindingOperations.SetBinding(lines[i - 1], Line.Y2Property,
                                             new Binding
                {
                    Source             = ee,
                    Path               = new PropertyPath(Canvas.TopProperty),
                    ConverterParameter = ee,
                    Converter          = y
                });

                BindingOperations.SetBinding(lines[i - 1], Line.X2Property,
                                             new Binding
                {
                    Source             = ee,
                    Path               = new PropertyPath(Canvas.LeftProperty),
                    Converter          = x,
                    ConverterParameter = ee
                });
            }
            Panel.SetZIndex(ee, 1000);
        }
        /// <summary>
        /// Get the current location for a vehicle.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="ct"></param>
        /// <returns></returns>
        public async Task <LocationViewModel> GetLocationByVehicleIdAsync(int id, CancellationToken ct = default(CancellationToken))
        {
            var location = await _repository.GetCurrentByVehicleIdAsync(id, ct);

            return(LocationConverter.Convert(location));
        }
Esempio n. 30
0
    private static async Task <IEnumerable <ML.Location> > QueryDataAsync(OwntracksSettings owntracksSettings, CancellationToken cancellationToken = default)
    {
        using var messageHandler = new HttpClientHandler { Credentials = new NetworkCredential(owntracksSettings.HttpUserName, owntracksSettings.HttpPassword) };
        using var httpClient     = new HttpClient(messageHandler)
              {
                  BaseAddress = owntracksSettings.Uri
              };

        var            apiClient = new OwntracksApiClient(httpClient);
        GetUsersResult?users     = await apiClient.GetUsersAsync(cancellationToken).ConfigureAwait(false);

        var result = new List <ML.Location>();

        if (users == null)
        {
            return(result);
        }

        foreach (string?user in users.Results)
        {
            GetDevicesResult?devices = await apiClient.GetDevicesAsync(user, cancellationToken).ConfigureAwait(false);

            if (devices == null)
            {
                continue;
            }

            foreach (string?device in devices.Results)
            {
                GetLocationsResult?locationsResult = await apiClient.GetLocationsAsync(user, device, DateTimeOffset.UtcNow.AddYears(-42), cancellationToken : cancellationToken).ConfigureAwait(false);

                if (locationsResult == null)
                {
                    continue;
                }

                IEnumerable <ML.Location>?convertedLocationResults = locationsResult.Data.Select(l => LocationConverter.Convert(user, device, l));
                result.AddRange(convertedLocationResults);
            }
        }

        return(result);
    }
Esempio n. 31
0
        public void EnsureLocationConverterReturnsNullForConvertBack()
        {
            LocationConverter converter = new LocationConverter();

            Assert.IsNull(converter.ConvertBack(string.Empty, null, null, null), "Expected null result");
        }
        private void buttonOK_Click(object sender, System.EventArgs e)
        {
            PropertyDescriptorCollection properties =
                TypeDescriptor.GetProperties(titledThumbnail);

            PropertyDescriptor Title = properties["Title"];

            if (Title != null)
            {
                try
                {
                    Title.SetValue(titledThumbnail, textImageTitle.Text);
                }
                catch (Exception err)
                {
                    MessageBox.Show(this,
                                    "Problem setting title property: Source:" +
                                    err.Source + " Message: " + err.Message, "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            PropertyDescriptor alignment = properties["Align"];

            if (alignment != null)
            {
                try
                {
                    alignment.SetValue(titledThumbnail, Enum.Parse(typeof(TitleAlignment), cboAlignment.Text));
                }
                catch (Exception err)
                {
                    MessageBox.Show(this, "Problem setting align property: Source:" +
                                    err.Source + " Message: " + err.Message, "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            PropertyDescriptorCollection imageInfoProps =
                TypeDescriptor.GetProperties(titledThumbnail.ImageInfo);

            PropertyDescriptor imageDescription = imageInfoProps["ImageLongDescription"];

            if (imageDescription != null)
            {
                try
                {
                    imageDescription.SetValue(titledThumbnail.ImageInfo, textLongImageDesc.Text);
                }
                catch (Exception err)
                {
                    MessageBox.Show(this,
                                    "Problem setting image Long Description property: Source:" +
                                    err.Source + " Message: " + err.Message, "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            PropertyDescriptor imageDate = imageInfoProps["ImageDate"];

            if (imageDate != null)
            {
                try
                {
                    imageDate.SetValue(titledThumbnail.ImageInfo, dtpImageTaken.Value);
                }
                catch (Exception err)
                {
                    MessageBox.Show(this,
                                    "Problem setting image date property: Source:" + err.Source + " Message: "
                                    + err.Message, "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            PropertyDescriptor photographerFullName = imageInfoProps["PhotographerFullName"];

            if (photographerFullName != null)
            {
                try
                {
                    photographerFullName.SetValue(titledThumbnail.ImageInfo, textPhotographerFullName.Text);
                }
                catch (Exception err)
                {
                    MessageBox.Show(this,
                                    "Problem setting photographer's full name property: Source:" +
                                    err.Source + " Message: " + err.Message, "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            PropertyDescriptor imageLocation = imageInfoProps["ImageLocation"];

            if (imageLocation != null)
            {
                try
                {
                    LocationConverter converter = new LocationConverter();
                    imageLocation.SetValue(titledThumbnail.ImageInfo, converter.ConvertFrom(null, Application.CurrentCulture, textLocation.Text));
                }
                catch (Exception err)
                {
                    MessageBox.Show(this,
                                    "Problem setting image location property: Source:" +
                                    err.Source + " Message: " + err.Message, "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }