async protected virtual Task MergeTrainingDayFromDb(SynchronizationItemViewModel item)
        {
            WorkoutDayGetOperation data = new WorkoutDayGetOperation();

            data.WorkoutDateTime = item.DayInfo.TrainingDay.TrainingDate;
            data.CustomerId      = item.DayInfo.TrainingDay.CustomerId;
            data.Operation       = GetOperation.Current;
            var trainingDay = await BAService.GetTrainingDayAsync(data, new RetrievingInfo());

            await MergeResult(trainingDay, item);

            //var m = new ServiceManager<GetTrainingDayCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler<GetTrainingDayCompletedEventArgs> operationCompleted)
            //{
            //    client1.GetTrainingDayCompleted -= operationCompleted;
            //    client1.GetTrainingDayCompleted += operationCompleted;
            //    WorkoutDayGetOperation data = new WorkoutDayGetOperation();
            //    data.WorkoutDateTime = item.DayInfo.TrainingDay.TrainingDate;
            //    data.CustomerId = item.DayInfo.TrainingDay.CustomerId;
            //    data.Operation = GetOperation.Current;
            //    client1.GetTrainingDayAsync(ApplicationState.Current.SessionData.Token, data, new RetrievingInfo());

            //});


            //m.OperationCompleted += (s, a) =>
            //                            {
            //                                await MergeResult(a.Result, item);

            //                            };
            //if (!m.Run())
            //{
            //    IsBusy = false;
            //    item.State = MergeState.Error;
            //}
        }
Ejemplo n.º 2
0
        async Task downloadGpsCoordinates()
        {
            progressBar.ShowProgress(true, ApplicationStrings.MapPage_DownloadingGpsCoordinates);
            try
            {
                List <GPSPoint> points = await BAService.GetGPSCoordinatesAsync(SelectedItem.GlobalId);

                ApplicationState.Current.TrainingDay.SetGpsCoordinates(SelectedItem, points);
                if (
                    ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays.ContainsKey(
                        SelectedItem.TrainingDay.TrainingDate))
                {
                    ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays[
                        SelectedItem.TrainingDay.TrainingDate].SetGpsCoordinates(SelectedItem, points);
                }
                drawTrackOnMap(points);
                fillLaps(points);
            }
            catch (Exception)
            {
                BAMessageBox.ShowError(ApplicationStrings.MapPage_ErrDownloadingGpsCoordinates);
            }
            finally
            {
                progressBar.ShowProgress(false);
            }
        }
        async virtual protected Task saveTrainingDay(SynchronizationItemViewModel day)
        {
            var res = await BAService.SaveTrainingDayAsync(day.DayInfo.TrainingDay);

            await applySave(res, day);

            //var m = new ServiceManager<SaveTrainingDayCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler<SaveTrainingDayCompletedEventArgs> operationCompleted)
            //{
            //    client1.SaveTrainingDayCompleted -= operationCompleted;
            //    client1.SaveTrainingDayCompleted += operationCompleted;
            //    client1.SaveTrainingDayAsync(ApplicationState.Current.SessionData.Token, day.DayInfo.TrainingDay);

            //});


            //m.OperationCompleted += (s, a) =>
            //{
            //    saveResult(a.Result, day, firstTime);
            //};

            //if (!m.Run())
            //{
            //    IsBusy = false;
            //    day.State = MergeState.Error;
            //}
        }
Ejemplo n.º 4
0
        private async void btnCheckUserNameAvailability_Click(object sender, RoutedEventArgs e)
        {
            btnCheckUsername.IsEnabled = false;
            var result = await BAService.CheckProfileNameAvailabilityAsync(txtUserName.Text);

            if (result)
            {
                BAMessageBox.ShowInfo(ApplicationStrings.CreateProfilePage_InfoUsernameAvailable);
            }
            else
            {
                BAMessageBox.ShowWarning(ApplicationStrings.CreateProfilePage_InfoUsernameNotAvailable);
            }
            btnCheckUsername.IsEnabled = true;
        }
Ejemplo n.º 5
0
        async protected override Task SavingCompleted()
        {
            var entry = Entry;

            if (entry == null || viewModel.Points == null || viewModel.Points.Count == 0)
            {//todo:maybe we should delete coordinates from db?
                return;
            }
            //here GPSEntry should be saved so instead InstanceId we can use GlobalId
            ApplicationState.Current.TrainingDay.CleanUpGpsCoordinates();
            ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays[entry.TrainingDay.TrainingDate].CleanUpGpsCoordinates();

            try
            {
                var result = await BAService.GPSCoordinatesOperationAsync(entry.GlobalId, GPSCoordinatesOperationType.UpdateCoordinatesWithCorrection, viewModel.Points);

                result.GPSTrackerEntry.InstanceId = entry.InstanceId;
                var tdi    = ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays[entry.TrainingDay.TrainingDate];
                var gpsBag = tdi.GetGpsCoordinates(result.GPSTrackerEntry);
                gpsBag.IsSaved = true;
                tdi.Update(result.GPSTrackerEntry);
                ApplicationState.Current.TrainingDay    = tdi.Copy();
                ApplicationState.Current.CurrentEntryId = new LocalObjectKey(result.GPSTrackerEntry);
            }
            catch (NetworkException)
            {
                progressBar.ShowProgress(false);
                if (ApplicationState.Current.IsOffline)
                {
                    BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode);
                }
                else
                {
                    BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork);
                }
            }
            catch (Exception)
            {
                //mark this entry as still modified
                var tdi = ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays[entry.TrainingDay.TrainingDate];
                tdi.IsModified = true;
                tdi.GetGpsCoordinates(entry).IsSaved = false;
                progressBar.ShowProgress(false);
                ApplicationBar.EnableApplicationBar(true);
                BAMessageBox.ShowError(ApplicationStrings.GPSTrackerPage_ErrUploadGpsCoordinates);
            }
        }
Ejemplo n.º 6
0
        private void MainMap_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                _isMouseDown = true;
                var d      = MainMap.FromLocalToLatLng(e.X, e.Y);
                var diachi = BAService.GetAddressByGeo(float.Parse(d.Lat.ToString()), float.Parse(d.Lng.ToString()));
                if (_currentMarker == null)
                {
                    MainMap.addMarkerCustomer(d, diachi);
                    _MarkerA     = MainMap.MarkerCustomer;
                    _isMouseDown = false;
                }
                else
                {
                    _currentMarker.Position = d;
                }

                ToaDo  = d;
                DiaChi = diachi;
                _MarkerA.ToolTipText = diachi;
            }
        }
Ejemplo n.º 7
0
 private void MainMap_MouseMove(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right && _isMouseDown)
     {
         var d = MainMap.FromLocalToLatLng(e.X, e.Y);
         if (_currentMarker == null)
         {
             //  MainMap.AddMarkerCustomOne(d.Lat, d.Lng, "");
         }
         else
         {
             _currentMarker.Position = d;
         }
         if (_MarkerA != null)
         {
             var diachi = BAService.GetAddressByGeo(float.Parse(d.Lat.ToString()), float.Parse(d.Lng.ToString()));
             ToaDo  = d;
             DiaChi = diachi;
             _MarkerA.ToolTipText = diachi;
         }
     }
     MainMap.Refresh(); // force instant invalidation
 }
        async protected virtual Task uploadGPSCoordinates(SynchronizationItemViewModel day, bool firstTime)
        {
            var result = await BAService.GPSCoordinatesOperationAsync(day.GPSEntry.GlobalId, GPSCoordinatesOperationType.UpdateCoordinates, day.GPSBag.Points);

            if (result.GPSTrackerEntry != null)
            {
                result.GPSTrackerEntry.InstanceId = day.GPSEntry.InstanceId;
                day.GPSEntry.GlobalId             = result.GPSTrackerEntry.GlobalId;
            }
            uploadGPSResult(result, day, firstTime);


            //var m = new ServiceManager<AsyncCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler<AsyncCompletedEventArgs> operationCompleted)
            //{
            //    using (OperationContextScope ocs = new OperationContextScope(client1.InnerChannel))
            //    {
            //        var ggg = (IBodyArchitectAccessService)client1;
            //        GPSOperationParam dto = new GPSOperationParam();
            //        var json = JsonConvert.SerializeObject(day.GPSBag.Points);
            //        var bytes = UTF8Encoding.UTF8.GetBytes(json);
            //        dto.CoordinatesStream = bytes.ToZip();

            //        GPSOperationData param = new GPSOperationData();
            //        param.GPSTrackerEntryId = day.GPSEntry.GlobalId;
            //        param.Operation = GPSCoordinatesOperationType.UpdateCoordinates;

            //        OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("SessionId", "http://MYBASERVICE.TK/", ApplicationState.Current.SessionData.Token.SessionId));
            //        OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("Params", "http://MYBASERVICE.TK/", param));
            //        ApplicationState.AddCustomHeaders();

            //        ggg.BeginGPSCoordinatesOperation(dto, delegate(IAsyncResult aRes)
            //        {
            //            var proxy = (IBodyArchitectAccessService)aRes.AsyncState;
            //            //using (OperationContextScope o = new OperationContextScope(((BodyArchitectAccessServiceClient)proxy).InnerChannel))
            //            {

            //                try
            //                {
            //                    GPSCoordinatesOperationResult result = proxy.EndGPSCoordinatesOperation(aRes);
            //                    uploadGPSResult(result, day, firstTime);
            //                }
            //                catch (FaultException<BAServiceException> ex)
            //                {
            //                    if (ex.Detail.ErrorCode == ErrorCode.ObjectNotFound)
            //                    {
            //                        uploadGPSResult(new GPSCoordinatesOperationResult(null), day, firstTime);
            //                        return;
            //                    }
            //                    uploadGPSResult(null, day, firstTime);
            //                    day.State = MergeState.Error;
            //                }
            //                catch (Exception ex)
            //                {
            //                    uploadGPSResult(null, day, firstTime);
            //                    day.State = MergeState.Error;
            //                }
            //                finally
            //                {
            //                    IsBusy = false;
            //                }
            //            }
            //        }, client1);

            //    }


            //});
            //if (!m.Run())
            //{

            //}
        }
Ejemplo n.º 9
0
        async private Task getProfileInformation()
        {
            currentOperation = new OperationToken();
            var profileInfo = await BAService.GetProfileInformationAsync(new GetProfileInformationCriteria());

            if (currentOperation != null && currentOperation.Cancelled)
            {
                showProgress(false);
                IsLogining = false;
                return;
            }

            ApplicationState.Current.ProfileInfo = profileInfo;

            ApplicationState.Current.Cache.Reminders.EnsureReminders();

            ApplicationState.Current.ProfileInfo.FavoriteUsers.Sort
                (delegate(UserSearchDTO u1, UserSearchDTO u2)
            {
                return(u1.UserName.CompareTo(u2.UserName));
            });
            ApplicationState.Current.ProfileInfo.Friends.Sort(
                delegate(UserSearchDTO u1, UserSearchDTO u2)
            {
                return(u1.UserName.CompareTo(u2.UserName));
            });
            if (ApplicationState.Current.MyDays == null)
            {
                ApplicationState.Current.MyDays = new Dictionary <CacheKey, TrainingDaysHolder>();
            }
            ApplicationState.Current.Cache.ClearAfterLogin();
            ApplicationState.Current.CurrentBrowsingTrainingDays =
                null;
            ApplicationState.Current.ClearTrainingDays();
            showProgress(false, false);
            IsLogining = false;
            onLoggingChanged();

            //var m = new ServiceManager<GetProfileInformationCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler<GetProfileInformationCompletedEventArgs> operationCompleted)
            //{

            //    currentOperation = new OperationToken();
            //    client1.GetProfileInformationAsync(ApplicationState.Current.SessionData.Token, new GetProfileInformationCriteria());

            //    client1.GetProfileInformationCompleted -= operationCompleted;
            //    client1.GetProfileInformationCompleted += operationCompleted;

            //});
            //m.OperationCompleted += (s, a1) =>
            //{
            //    if (a1.Error !=null)
            //          {
            //              showProgress(false);
            //              IsLogining=false;
            //              BAMessageBox.ShowError(ApplicationStrings.ErrCantRetrieveProfileInfo);
            //              return;
            //          }
            //          OperationToken op1 =(OperationToken)a.UserState;
            //          if (op1 !=null && op1.Cancelled)
            //          {
            //              showProgress(false);
            //              IsLogining=false;
            //              return;
            //          }

            //          else if (a1.Result != null)
            //          {
            //              //if (Settings.RefreshFrequencyDays == 0)
            //              //{
            //              //    //in trial/free mode we retrieve exercises and the rest stuff in every login
            //              //    ApplicationState.Current.Cache.Clear();
            //              //}

            //              ApplicationState.Current.ProfileInfo = a1.Result.Result;

            //              ApplicationState.Current.Cache.Reminders.EnsureReminders();

            //              ApplicationState.Current.ProfileInfo.FavoriteUsers.Sort
            //                  (delegate(UserSearchDTO u1, UserSearchDTO u2)
            //                       {
            //                           return u1.UserName.CompareTo(u2.UserName);
            //                       });
            //              ApplicationState.Current.ProfileInfo.Friends.Sort(
            //                  delegate(UserSearchDTO u1, UserSearchDTO u2)
            //                      {
            //                          return u1.UserName.CompareTo(u2.UserName);
            //                      });
            //              if (ApplicationState.Current.MyDays == null)
            //              {
            //                  //ApplicationState.Current.MyDays=new TrainingDaysHolder(ApplicationState.Current.SessionData.Profile);
            //                  ApplicationState.Current.MyDays =new Dictionary<CacheKey, TrainingDaysHolder>();
            //              }
            //              ApplicationState.Current.Cache.ClearAfterLogin();
            //              ApplicationState.Current.CurrentBrowsingTrainingDays =
            //                  null;
            //              ApplicationState.Current.ClearTrainingDays();
            //              showProgress(false, false);
            //              IsLogining = false;
            //              onLoggingChanged();
            //          }
            //};

            //if (!m.Run(true))
            //{
            //    IsLogining = false;
            //    showProgress(false);
            //    if (ApplicationState.Current.IsOffline)
            //    {
            //        BAMessageBox.ShowError(ApplicationStrings.ErrOfflineMode);
            //    }
            //    else
            //    {
            //        BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork);
            //    }
            //}
        }
Ejemplo n.º 10
0
        async public Task LoginImplementation(string username, string password)
        {
            if (!progressBar.IsOperationStarted)
            {//we should perform login
                showProgress(true);
                IsLogining = true;
                var btnLogin = (ApplicationBarIconButton)ApplicationBar.Buttons[0];
                btnLogin.IsEnabled       = true;
                ApplicationState.Current = null;

                progressBar.ShowProgress(true, ApplicationStrings.Login_ProgressAuthentication);

                try
                {
                    currentOperation = new OperationToken();
                    var sessionData = await BAService.LoginAsync(txtUserName.Text, password.ToSHA1Hash());

                    if (sessionData == null)
                    {
                        Settings.UserName = null;
                        Settings.Password = null;
                        IsLogining        = false;
                        showProgress(false);
                        BAMessageBox.ShowError(ApplicationStrings.ErrUserOrPasswordNotValid);
                        return;
                    }
                    if (currentOperation != null && currentOperation.Cancelled)
                    {
                        IsLogining = false;
                        return;
                    }


                    progressBar.ShowProgress(true, ApplicationStrings.Login_ProgressRetrieveProfile);
                    btnLogin.IsEnabled = true;

                    if (Settings.LiveTileEnabled && Settings.InitialAsk)
                    {
                        try
                        {
                            pushNotification.RegisterDevice(sessionData.Profile.GlobalId);
                        }
                        catch
                        {
                        }
                    }

                    var state = ApplicationState.LoadState();
                    if (state == null)
                    {
                        state = new ApplicationState();
                    }
                    else if (state.TempUserName != username)
                    {
                        //if we log as a different user, we should't use cache
                        ApplicationState.ClearOffline();
                        state = new ApplicationState();
                    }

                    state.IsOffline                       = false;
                    ApplicationState.Current              = state;
                    ApplicationState.Current.SessionData  = sessionData;
                    ApplicationState.Current.TempUserName = username;
                    ApplicationState.Current.TempPassword = password.ToSHA1Hash();
                    ApplicationState.Current.SessionData.Token.Language = ApplicationState.CurrentServiceLanguage;

                    Settings.UserName = username;
                    Settings.Password = password;

                    try
                    {
                        await getProfileInformation();
                    }
                    catch (Exception)
                    {
                        showProgress(false);
                        IsLogining = false;
                        BAMessageBox.ShowError(ApplicationStrings.ErrCantRetrieveProfileInfo);
                    }
                }
                //catch (NetworkException)
                //{
                //    IsLogining = false;
                //    showProgress(false);
                //    BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork);
                //}
                catch (DatabaseVersionException)
                {
                    IsLogining = false;
                    showProgress(false);
                    BAMessageBox.ShowError(ApplicationStrings.ErrOldApplicationVersion);
                }
                catch (Exception ex)
                {
                    showProgress(false);
                    IsLogining = false;
                    goToOffline(true);
                }
            }
            else
            {
                if (currentOperation != null)
                {
                    currentOperation.Cancel();
                    currentOperation = null;
                }
                showProgress(false);
            }
        }
Ejemplo n.º 11
0
        async protected Task saveToTheDb(bool goBack = false)
        {
            if (ApplicationState.Current == null)
            {
                return;
            }

            if (ReadOnly)
            {
                //Translation i huj wie co
                BAMessageBox.ShowError("Cannot modify entry for another user");
                return;
            }
            ExtensionMethods.BindFocusedTextBox();
            if (!ValidateBeforeSave())
            {
                return;
            }

            progressBar.ShowProgress(true, ApplicationStrings.EntryObjectPageBase_ProgressUpdating);
            BeforeSaving();
            DateTime date = ApplicationState.Current.TrainingDay.TrainingDay.TrainingDate;

            //first save a copy to the local storage
            ThreadPool.QueueUserWorkItem(delegate
            {
                var copy        = ApplicationState.Current.TrainingDay.Copy();
                copy.IsModified = true;
                ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays[copy.TrainingDay.TrainingDate] = copy;
            });

            try
            {
                var entryBeforeSave = Entry;//see the comment where this is used belove
                var result          = await BAService.SaveTrainingDayAsync(ApplicationState.Current.TrainingDay.TrainingDay);

                if (result.TrainingDay != null)
                {
                    var savedDay = result.TrainingDay;
                    savedDay.FillInstaneId(ApplicationState.Current.TrainingDay.TrainingDay);
                    savedDay.TrainingDate = date;//bug fixing: web service converts date to local or something like this. but this is only in SaveTrainingDay method
                    var tdi = ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays[savedDay.TrainingDate];
                    tdi.TrainingDay = savedDay;
                    tdi.IsModified  = false;
                    ApplicationState.Current.TrainingDay = tdi.Copy();

                    //if we use instance id for determining current entry then after save we should always use globalid
                    if (Entry != null)
                    {
                        ApplicationState.Current.CurrentEntryId = new LocalObjectKey(Entry);
                    }

                    await SavingCompleted();

                    progressBar.ShowProgress(false);
                    if (result.NewRecords.Count > 0)
                    {
                        BAMessageBox.ShowInfo(ApplicationStrings.MessageNewRecords, new Uri("/Images/Records32.png", UriKind.RelativeOrAbsolute));
                    }
                }
                else
                {
                    progressBar.ShowProgress(false);
                    //if (ApplicationState.Current.TrainingDay != null && ApplicationState.Current.TrainingDay.TrainingDay.TrainingDate == date)
                    //{
                    //    ApplicationState.Current.TrainingDay = null;
                    //}
                    if (!goBack)
                    {//user remove all data from the trainig day so on the server this day is removed. so on the client we "mark" this item as a new item
                        ApplicationState.Current.TrainingDay.TrainingDay.GlobalId = Guid.Empty;
                        var tmpEntry = Entry;
                        tmpEntry.GlobalId = Guid.Empty;
                        tmpEntry.Version  = 0;
                        ApplicationState.Current.CurrentEntryId = new LocalObjectKey(tmpEntry);
                    }
                    ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays.Remove(date);
                }
                if (ApplicationState.Current.TrainingDay != null && !IsClosing && !goBack)
                {
                    if (Entry == null && !ApplicationState.Current.TrainingDay.TrainingDay.Objects.Contains(entryBeforeSave))
                    {//this is invoked when for example user saved empty supplements entry so on the server this entry is removed and therefore after save Entry returns null. so we must restore the entry before saving operation (this is a special case)
                        ApplicationState.Current.TrainingDay.TrainingDay.Objects.Add(entryBeforeSave);
                        entryBeforeSave.TrainingDay = ApplicationState.Current.TrainingDay.TrainingDay;
                        entryBeforeSave.GlobalId    = Guid.Empty;
                        entryBeforeSave.Version     = 0;
                    }
                    show(true);
                }

                if (goBack)
                {
                    ApplicationState.Current.TrainingDay = null;
                    if (NavigationService.CanGoBack && !IsClosing)
                    {
                        NavigationService.GoBack();
                    }
                }
            }
            catch (NetworkException)
            {
                progressBar.ShowProgress(false);
                if (ApplicationState.Current.IsOffline)
                {
                    BAMessageBox.ShowWarning(ApplicationStrings.EntryObjectPageBase_SavedLocallyOnly);
                }
                else
                {
                    BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork);
                }
            }
            catch (ValidationException validEx)
            {
                progressBar.ShowProgress(false);
                if (IsClosing)
                {
                    return;
                }
                BAMessageBox.ShowError(validEx.Results.First().Key + ":" + validEx.Results.First().Message);
            }
            catch (OldDataException oldData)
            {
                progressBar.ShowProgress(false);
                if (IsClosing)
                {
                    return;
                }
                BAMessageBox.ShowError(ApplicationStrings.ErrOldData);
            }
            catch (LicenceException licence)
            {
                progressBar.ShowProgress(false);
                if (IsClosing)
                {
                    return;
                }
                BAMessageBox.ShowError(ApplicationStrings.ErrLicence);
            }
            catch (Exception ex)
            {
                progressBar.ShowProgress(false);
                BugSenseHandler.Instance.SendExceptionAsync(ex);
                if (IsClosing)
                {
                    return;
                }

                BAMessageBox.ShowWarning(ApplicationStrings.EntryObjectPageBase_SavedLocallyOnly);
            }



            //var m = new ServiceManager<SaveTrainingDayCompletedEventArgs>(delegate(BodyArchitectAccessServiceClient client1, EventHandler<SaveTrainingDayCompletedEventArgs> operationCompleted)
            //{
            //    client1.SaveTrainingDayCompleted -= operationCompleted;
            //    client1.SaveTrainingDayCompleted += operationCompleted;
            //    client1.SaveTrainingDayAsync(ApplicationState.Current.SessionData.Token, ApplicationState.Current.TrainingDay.TrainingDay);

            //});


            //m.OperationCompleted += async (s, a) =>
            //{
            //    if (a.Error != null)
            //    {
            //        progressBar.ShowProgress(false);
            //        if(IsClosing)
            //        {
            //            return;
            //        }
            //        FaultException<ValidationFault> faultEx = a.Error as FaultException<ValidationFault>;
            //        FaultException<BAServiceException> serviceEx = a.Error as FaultException<BAServiceException>;
            //        if (faultEx != null)
            //        {
            //            BAMessageBox.ShowError(faultEx.Detail.Details[0].Key + ":" + faultEx.Detail.Details[0].Message);
            //            return;
            //        }
            //        if (serviceEx!=null)
            //        {
            //            if(serviceEx.Detail.ErrorCode==ErrorCode.OldDataException)
            //            {
            //                BAMessageBox.ShowError(ApplicationStrings.ErrOldData);
            //                return;
            //            }
            //            else if(serviceEx.Detail.ErrorCode==ErrorCode.LicenceException)
            //            {
            //                BAMessageBox.ShowError(ApplicationStrings.ErrLicence);
            //                return;
            //            }
            //        }

            //        BAMessageBox.ShowWarning(ApplicationStrings.EntryObjectPageBase_SavedLocallyOnly);
            //        return;
            //    }
            //    else
            //    {
            //        if (a.Result.Result.TrainingDay != null)
            //        {
            //            var savedDay = a.Result.Result.TrainingDay;
            //            //savedDay.InstanceId = dayInstanceId;
            //            //var savedEntry=savedDay.GetEntry(EntryType);
            //            //if (savedEntry != null)
            //            //{
            //            //    savedEntry.InstanceId = entryInstanceId;
            //            //}
            //            savedDay.FillInstaneId(ApplicationState.Current.TrainingDay.TrainingDay);
            //            savedDay.TrainingDate = date;//bug fixing: web service converts date to local or something like this. but this is only in SaveTrainingDay method
            //            var tdi=ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays[savedDay.TrainingDate];
            //            tdi.TrainingDay = savedDay;
            //            tdi.IsModified = false;
            //            ApplicationState.Current.TrainingDay = tdi.Copy();
            //            await SavingCompleted();

            //            progressBar.ShowProgress(false);
            //            if(a.Result.Result.NewRecords.Count>0)
            //            {
            //                BAMessageBox.ShowInfo(ApplicationStrings.MessageNewRecords, new Uri("/Images/Records32.png", UriKind.RelativeOrAbsolute));
            //            }
            //        }
            //        else
            //        {
            //            progressBar.ShowProgress(false);
            //            if (ApplicationState.Current.TrainingDay != null && ApplicationState.Current.TrainingDay.TrainingDay.TrainingDate == date)
            //            {
            //                ApplicationState.Current.TrainingDay = null;
            //            }
            //            ApplicationState.Current.CurrentBrowsingTrainingDays.TrainingDays.Remove(date);
            //        }
            //        if (ApplicationState.Current.TrainingDay != null && !IsClosing)
            //        {
            //            show(ApplicationState.Current.TrainingDay.TrainingDay, true);
            //        }

            //        if (goBack)
            //        {
            //            ApplicationState.Current.TrainingDay = null;
            //            if (NavigationService.CanGoBack && !IsClosing)
            //            {
            //                NavigationService.GoBack();
            //            }
            //        }
            //    }

            //};

            //if(!m.Run())
            //{
            //    progressBar.ShowProgress(false);
            //    if (ApplicationState.Current.IsOffline)
            //    {
            //        BAMessageBox.ShowWarning(ApplicationStrings.EntryObjectPageBase_SavedLocallyOnly);
            //    }
            //    else
            //    {
            //        BAMessageBox.ShowError(ApplicationStrings.ErrNoNetwork);
            //    }
            //}
        }