示例#1
0
 protected override async Task save(SynchronizationItemViewModel day, bool firstTime)
 {
     if (firstTime)
     {
         FirstSave = true;
     }
     else
     {
         SecondSave = true;
     }
     await base.save(day, firstTime);
 }
示例#2
0
        async protected override Task MergeTrainingDayFromDb(SynchronizationItemViewModel item)
        {
            Exception ex = ErrorDuringRetrieve ? new Exception() : null;

            Merged = true;
            //GetTrainingDayCompletedEventArgs e = new GetTrainingDayCompletedEventArgs(new object[] { FromServer }, ex, false, null);
            if (ex == null)
            {
                await MergeResult(FromServer, item);
            }
            else
            {
                throw ex;
            }
        }
示例#3
0
        async protected override Task saveTrainingDay(SynchronizationItemViewModel day)
        {
            SaveCount++;
            if (!IsInProgress)
            {
                IsInProgressGood = false;
            }

            Exception ex = NeedsMergeException && FirstSave && !SecondSave ? new OldDataException() : null;

            if (ErrorInSecondSave && SecondSave)
            {
                ex = new Exception("Test");
            }

            var newDay = day.DayInfo.TrainingDay.Copy();

            if (ex == null)
            {//imitate creating a new GlobalId on the server
                newDay.GlobalId = Guid.NewGuid();
                foreach (var entryObjectDto in newDay.Objects)
                {
                    entryObjectDto.GlobalId = Guid.NewGuid();
                }
            }
            if (RemoveFromServer != null)
            {
                if (RemoveFromServer == typeof(TrainingDayDTO))
                {
                    newDay = null;
                }
                var itemToDelete = newDay.Objects.Where(x => x.GetType() == RemoveFromServer).SingleOrDefault();
                if (itemToDelete != null)
                {
                    newDay.Objects.Remove(itemToDelete);
                }
            }

            SaveTrainingDayCompletedEventArgs res = new SaveTrainingDayCompletedEventArgs(new object[] { new SaveTrainingDayResult()
                                                                                                         {
                                                                                                             TrainingDay = newDay
                                                                                                         } }, ex, false, null);

            await applySave(res.Result, day);
        }
示例#4
0
        async protected override Task uploadGPSCoordinates(SynchronizationItemViewModel day, bool firstTime)
        {
            GPSUploadCount++;
            if (!IsInProgress)
            {
                IsInProgressGood = false;
            }

            if (UploadGPSError == null)
            {
                GPSCoordinatesOperationResult result = new GPSCoordinatesOperationResult(day.GPSEntry.Copy());
                uploadGPSResult(result, day, firstTime);
            }
            else if (UploadGPSError == ErrorCode.ObjectNotFound)
            {
                throw new ObjectNotFoundException();
            }
            else
            {
                throw new Exception();
            }
        }