public void TestMust_Get3RoutePointsWith2PhotosEach() { //AAA //Arrange var testPhotos = new Dictionary <(GpsCoordinates, DateTime), GalleryImage>(); //?? ????? ? ??? 6 ??????????, ??? ? ???????????? 1,1, ??? ? 2,2, ??? ? 3,3 - ?.?. ?? ????? ?????? ?????? ???????? ? ???????? 3 ?????? ????? //?? ????????, ??? ?????? ?????????? ?????? 6 ??????????, ??? ??????????? //???????, ???? ?? ???????? testPhotos.Add((new GpsCoordinates() { Latitude = 1, Longitude = 1 }, DateTime.Parse("2020/07/01")), new GalleryImage() { CreateDate = DateTime.Parse("2020/07/01"), ImagePath = "1" }); testPhotos.Add((new GpsCoordinates() { Latitude = 1, Longitude = 1 }, DateTime.Parse("2020/07/01")), new GalleryImage() { CreateDate = DateTime.Parse("2020/07/01"), ImagePath = "2" }); testPhotos.Add((new GpsCoordinates() { Latitude = 2, Longitude = 2 }, DateTime.Parse("2020/07/01")), new GalleryImage() { CreateDate = DateTime.Parse("2020/07/01"), ImagePath = "3" }); testPhotos.Add((new GpsCoordinates() { Latitude = 2, Longitude = 2 }, DateTime.Parse("2020/07/01")), new GalleryImage() { CreateDate = DateTime.Parse("2020/07/01"), ImagePath = "1" }); testPhotos.Add((new GpsCoordinates() { Latitude = 3, Longitude = 3 }, DateTime.Parse("2020/07/01")), new GalleryImage() { CreateDate = DateTime.Parse("2020/07/01"), ImagePath = "2" }); testPhotos.Add((new GpsCoordinates() { Latitude = 3, Longitude = 3 }, DateTime.Parse("2020/07/01")), new GalleryImage() { CreateDate = DateTime.Parse("2020/07/01"), ImagePath = "3" }); //Act AutoGeneratedRouted autoRoute = new AutoGeneratedRouted(new ImageManager()); autoRoute.Build(testPhotos); //Assert Assert.True(autoRoute.Points.Count == 3, "?????? ???? ?????? 3 ?????, ? ?????? ?? 2 ??????????"); }
public MakeNewRoutePage(AutoGeneratedRouted autoGeneratedRoute) { InitializeComponent(); _vm = new MakeNewRouteViewModel(autoGeneratedRoute); _vm.Navigation = this.Navigation; BindingContext = _vm; }
private async void generateNewRouteCommand(object obj) { _autoGeneratedRoute = null; if (obj != null) { int daysDepth = 0; try { daysDepth = Convert.ToInt32(obj); } catch (Exception) { } Analytics.TrackEvent("AutoRoute:Generate new started", new Dictionary <string, string> { { "daysDepth", daysDepth.ToString() } }); setPeriodByDepth(daysDepth); } bool maxCountOk = true; if (_selectedImagesCount > _maxCountForWarning) { maxCountOk = await askToMaxImageCountWarning(); } var startDate = DateTime.Now; if (maxCountOk) { GC.Collect(); IsRouteMaking = true; MaxCountProgressItems = _selectedImagesCount; attachReceiverMessagesForProgress(); await Task.Factory.StartNew(() => { ImagesCacheDbManager imagesCache = new ImagesCacheDbManager(new ImageManager(), PeriodRouteBegin, PeriodRouteEnd); imagesCache.UpdateMetadata(PathToImageDirectory); AutoRoutePreviewMakerManager routeMaker = new AutoRoutePreviewMakerManager(new LocalFileCacheManager()); _autoGeneratedRoute = routeMaker.Make(PeriodRouteBegin, PeriodRouteEnd, PathToImageDirectory); Device.BeginInvokeOnMainThread(() => { IsRouteMaking = false; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("PreviewRoutePoints")); UpdateRouteInfo(); var delay = DateTime.Now - startDate; Analytics.TrackEvent("AutoRoute:Route generate completed", new Dictionary <string, string> { { "delay", delay.ToString() }, { "Name", _autoGeneratedRoute.Name } }); }); }); detachReceiverMessagesForProgress(); } }
public MakeNewRouteViewModel(AutoGeneratedRouted autoGeneratedRoute) { _autoGeneratedRoute = autoGeneratedRoute; BackNavigationCommand = new Command(backNavigationCommand); ViewPhotoCommand = new Command(viewPhotoAsync); DeletePointCommand = new Command(deletePointCommand); DeleteImageFromPointCommand = new Command(deleteImageFromPointCommand); SelectPointCommand = new Command(selectPointCommand); SaveRouteCommand = new Command(saveRouteCommand); }
internal AutoGeneratedRouted Make(DateTimeOffset periodStart, DateTimeOffset periodEnd, string pathToImageDirectory) { AutoGeneratedRouted route = new AutoGeneratedRouted(new ImageManager()); var localCacheFiles = _cacheManager.GetImagesInfo(periodStart, periodEnd, pathToImageDirectory); if (localCacheFiles.Count > 0) { route.Name = $"{CommonResource.AutoRoutes_RouteName} { periodStart.DateTime.ToShortDateString() } - { periodEnd.DateTime.ToShortDateString() }"; route.BuildOld(localCacheFiles); } return(route); }
public bool Make(AutoGeneratedRouted autoRoute, string creatorId) { if (autoRoute.Points.Count > 0) { var vroute = new ViewRoute(string.Empty); vroute.CreatorId = creatorId; vroute.CreateDate = DateTime.Now; vroute.Name = autoRoute.Name; if (vroute.Save()) { foreach (var autoPoint in autoRoute.Points.Where(p => !p.IsDeleted)) { var vroutePoint = new ViewRoutePoint(vroute.RouteId, string.Empty); vroutePoint.Name = autoPoint.Name; vroutePoint.Longitude = autoPoint.Longitude; vroutePoint.Latitude = autoPoint.Latitude; vroutePoint.Version++; if (vroutePoint.Save()) { foreach (var autoMedia in autoPoint.Images.Where(i => !i.IsDeleted)) { string localImageId = autoMedia.Id; /*if (mediaObjectIsExists(mediaId)) * { * //в случае если мы используем одно и то же фото в нескольких альбомах, придется его дублировать * //связано с тем, что id media соответствует имени файла и если меняем свойства объекта в каком-то маршруте, меняется для всех * //media object в этом случае один, и это проблема * mediaId = makeNewMediaObject(mediaId); * }*/ string mediaId = makeNewMediaObject(localImageId); vroutePoint.AddMediaItem(mediaId, MediaObjectTypeEnum.Image); } vroutePoint.Save(); } } return(true); } } return(false); }
public void TestMust_Get3RoutePointsWith2PhotosEach_Old() { //AAA //Arrange var testPhotos = new List <ViewLocalFile>(); testPhotos.Add(new ViewLocalFile() { Processed = true, Latitude = 1, Longitude = 1, CreateDate = DateTime.Parse("2020/07/01"), FileNameDate = DateTime.Parse("2020/07/01") }); testPhotos.Add(new ViewLocalFile() { Processed = true, Latitude = 1, Longitude = 1, CreateDate = DateTime.Parse("2020/07/01"), FileNameDate = DateTime.Parse("2020/07/01") }); testPhotos.Add(new ViewLocalFile() { Processed = true, Latitude = 2, Longitude = 2, CreateDate = DateTime.Parse("2020/07/01"), FileNameDate = DateTime.Parse("2020/07/01") }); testPhotos.Add(new ViewLocalFile() { Processed = true, Latitude = 2, Longitude = 2, CreateDate = DateTime.Parse("2020/07/01"), FileNameDate = DateTime.Parse("2020/07/01") }); testPhotos.Add(new ViewLocalFile() { Processed = true, Latitude = 3, Longitude = 3, CreateDate = DateTime.Parse("2020/07/01"), FileNameDate = DateTime.Parse("2020/07/01") }); testPhotos.Add(new ViewLocalFile() { Processed = true, Latitude = 3, Longitude = 3, CreateDate = DateTime.Parse("2020/07/01"), FileNameDate = DateTime.Parse("2020/07/01") }); //Act AutoGeneratedRouted autoRoute = new AutoGeneratedRouted(new ImageManager()); autoRoute.BuildOld(testPhotos); //Assert Assert.True(autoRoute.Points.Count == 3, "?????? ???? ?????? 3 ?????, ? ?????? ?? 2 ??????????"); }