Пример #1
0
        private async void CreateProfile()
        {
            if (SyncProfileList.Count > 4)
            {
                MessageService.ShowMessageAsync("You have reached the maximum number of profiles.");
                return;
            }

            var result = await MessageService.ShowInput("Please enter profile name.");

            if (!string.IsNullOrEmpty(result))
            {
                if (SyncProfileList.Any(t => !string.IsNullOrEmpty(t.Name) && t.Name.Equals(result)))
                {
                    MessageService.ShowMessageAsync(
                        string.Format("A Profile with name '{0}' already exists. Please try again.", result));
                    return;
                }

                var syncProfile = CalendarSyncProfile.GetDefaultSyncProfile();
                syncProfile.Name      = result;
                syncProfile.IsDefault = false;
                var viewModel = new ProfileViewModel(syncProfile, GoogleCalendarService, OutlookCalendarService,
                                                     MessageService,
                                                     ExchangeWebCalendarService, ApplicationLogger, AccountAuthenticationService);
                PropertyChangedEventManager.AddHandler(viewModel, ProfilePropertyChangedHandler, "IsLoading");
                viewModel.Initialize(null);
                SyncProfileList.Add(viewModel);
            }
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        private async void CreateProfile(object parameter)
        {
            if (parameter == null)
            {
                return;
            }

            if (parameter.ToString().Equals("Calendars"))
            {
                await AddNewProfile(CalendarSyncProfiles, CalendarSyncProfile.GetDefaultSyncProfile());
            }
            else if (parameter.ToString().Equals("Tasks"))
            {
                await AddNewProfile(TaskSyncProfiles, TaskSyncProfile.GetDefaultSyncProfile());
            }
            else if (parameter.ToString().Equals("Contacts"))
            {
                await AddNewProfile(ContactsSyncProfiles, ContactSyncProfile.GetDefaultSyncProfile());
            }
        }
        private void ValidateSettings(Settings result)
        {
            if (result.SyncProfiles == null)
            {
                result.SyncProfiles = new ObservableCollection <CalendarSyncProfile>();
            }

            if (result.SyncProfiles.Count == 0)
            {
                result.SyncProfiles.Add(CalendarSyncProfile.GetDefaultSyncProfile());
            }

            foreach (var syncProfile in result.SyncProfiles)
            {
                syncProfile.SetCalendarTypes();
                if (syncProfile.SyncSettings == null || syncProfile.SyncSettings.SyncFrequency == null)
                {
                    syncProfile.SyncSettings = SyncSettings.GetDefault();
                }
                else if (syncProfile.SyncSettings.SyncRangeType == SyncRangeTypeEnum.SyncEntireCalendar)
                {
                    syncProfile.SyncSettings.SyncRangeType = SyncRangeTypeEnum.SyncRangeInDays;
                    syncProfile.SyncSettings.DaysInPast    = 120;
                    syncProfile.SyncSettings.DaysInFuture  = 120;
                }
            }

            if (result.AppSettings == null)
            {
                result.AppSettings = new AppSettings();
            }

            if (result.AppSettings.ProxySettings == null)
            {
                result.AppSettings.ProxySettings = new ProxySetting
                {
                    ProxyType = ProxyType.Auto
                };
            }
        }
Пример #4
0
        private void ValidateSettings(Settings result)
        {
            if (result.GoogleAccounts == null)
            {
                result.GoogleAccounts = new ObservableCollection <GoogleAccount>();
            }

            if (result.CalendarSyncProfiles == null || result.CalendarSyncProfiles.Count == 0)
            {
                result.CalendarSyncProfiles = new ObservableCollection <CalendarSyncProfile>()
                {
                    CalendarSyncProfile.GetDefaultSyncProfile()
                };
            }
            else
            {
                foreach (var syncProfile in result.CalendarSyncProfiles)
                {
                    syncProfile.SetSourceDestTypes();
                    if (syncProfile.SyncSettings == null)
                    {
                        syncProfile.SyncSettings = CalendarSyncSettings.GetDefault();
                    }
                    else if (syncProfile.SyncSettings.SyncRangeType == SyncRangeTypeEnum.SyncEntireCalendar)
                    {
                        syncProfile.SyncSettings.SyncRangeType = SyncRangeTypeEnum.SyncRangeInDays;
                        syncProfile.SyncSettings.DaysInPast    = 120;
                        syncProfile.SyncSettings.DaysInFuture  = 120;
                    }

                    if (syncProfile.SyncFrequency == null)
                    {
                        syncProfile.SyncFrequency = new IntervalSyncFrequency();
                    }
                }
            }

            if (result.TaskSyncProfiles == null || result.TaskSyncProfiles.Count == 0)
            {
                result.TaskSyncProfiles = new ObservableCollection <TaskSyncProfile>()
                {
                    TaskSyncProfile.GetDefaultSyncProfile()
                };
            }
            else
            {
                foreach (var syncProfile in result.TaskSyncProfiles)
                {
                    syncProfile.SetSourceDestTypes();
                    if (syncProfile.SyncSettings == null)
                    {
                        syncProfile.SyncSettings = TaskSyncSettings.GetDefault();
                    }

                    if (syncProfile.SyncFrequency == null)
                    {
                        syncProfile.SyncFrequency = new IntervalSyncFrequency();
                    }
                }
            }
            if (result.ContactSyncProfiles == null || result.ContactSyncProfiles.Count == 0)
            {
                result.ContactSyncProfiles = new ObservableCollection <ContactSyncProfile>()
                {
                    ContactSyncProfile.GetDefaultSyncProfile()
                };
            }

            if (result.AppSettings == null)
            {
                result.AppSettings = AppSettings.GetDefault();
            }
            else if (result.AppSettings.ProxySettings == null)
            {
                result.AppSettings.ProxySettings = new ProxySetting
                {
                    ProxyType = ProxyType.Auto
                };
            }
        }