Пример #1
0
        public static async Task AddOnlineFilesToTile(Guid _accountID)
        {
            string name = Resource.Localization.AppResources.Tile_RemoteFileTitle;

            try
            {
                using (var context = new OwnCloudDataContext())
                {
                    var account = await App.AccountService.GetAccountByID(_accountID);
                    // TODO: this will edit the account in the list
                    await App.AccountService.RestoreCredentials(account);
                    name = account.Username + " " + name;
                }
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch
            // ReSharper restore EmptyGeneralCatchClause
            {
                //Do nothing
            }

            var invokeUrl = new Uri("/View/Page/RemoteFiles.xaml?account=" + _accountID, UriKind.Relative);

            PinUrlToStart(invokeUrl, name, "Resource/Image/RemoteFolderLogo.png");
        }
Пример #2
0
        /// <summary>
        /// Callback for LoadServerCalendars
        /// </summary>
        void LoadCalendarInfoComplete(object sender, Net.LoadCalendarInfoCompleteArgs e)
        {
            if (!e.Success)
            {
                return;
            }

            //Run things in main thread
            System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                using (Data.OwnCloudDataContext context = new OwnCloudDataContext())
                {
                    //Get the account, to get the Url, where we can get all calendars
                    var account = context.Accounts.Where(o => o.GUID == _accountId).Single();

                    //enumerate all calendars and add it to list
                    foreach (var calendar in e.CalendarInfo)
                    {
                        ServerCalendars.Add(
                            new ServerCalendarDisplayInfo
                        {
                            CalendarInfo = calendar,
                            //If the calendar is in the database, the calendar is "enabled"
                            IsClientEnabled = account.Calendars.Count(o => o.Url == calendar.Url) > 0
                        });
                    }
                }
            });
        }
        void EventClick(object sender, RoutedEventArgs e)
        {
            var dbEvent = (sender as FrameworkElement).DataContext as TableEvent;

            int accountID = 0;
            using (var context = new OwnCloudDataContext())
            {
                accountID = context.Calendars.Where(o => o.Id == dbEvent.CalendarId).Single()._accountId ?? 0;
            }

            //TODO: Import Edit Page..
            App.Current.RootFrame.Navigate(new Uri("/View/Page/AppointmentPage.xaml?url=" + dbEvent.Url + "&uid=" + accountID.ToString(), UriKind.Relative));
        }
Пример #4
0
        public void DisableCalendar(CalendarCalDavInfo calendar) {
            using (var context = new OwnCloudDataContext()) {
                var entity = (from o in context.Calendars where o.Url == calendar.Url select o).SingleOrDefault();

                if (entity != null)
                    context.Calendars.DeleteOnSubmit(entity);

                var eventsToDelete = context.Events.Where(o => o.CalendarId == entity.Id).ToArray();

                context.Events.DeleteAllOnSubmit(eventsToDelete);

                context.SubmitChanges();
            }
        }
Пример #5
0
        public void EnableCalendar(CalendarCalDavInfo calendar) {
            using (var context = new OwnCloudDataContext()) {
                var existingEntity =
                    (from o in context.Calendars where o.Url == calendar.Url select o).SingleOrDefault();

                if (existingEntity != null)
                    return;

                var entity = TableCalendar.FromCalDavCalendarInfo(calendar);
                entity.GetCTag = "";

                entity._accountId = this._accountId;

                context.Calendars.InsertOnSubmit(entity);
                context.SubmitChanges();
            }
        }
        public void DisableCalendar(CalendarCalDavInfo calendar)
        {
            using (var context = new OwnCloudDataContext())
            {
                var entity = (from o in context.Calendars where o.Url == calendar.Url select o).SingleOrDefault();

                if (entity != null)
                {
                    context.Calendars.DeleteOnSubmit(entity);
                }

                var eventsToDelete = context.Events.Where(o => o.CalendarId == entity.Id).ToArray();

                context.Events.DeleteAllOnSubmit(eventsToDelete);

                context.SubmitChanges();
            }
        }
        private void ContextMenu_OnOpened(object sender, RoutedEventArgs e)
        {
            var context = new OwnCloudDataContext();

            var events = context.Events.Where(o => o.To > _targetDate && o.From < _targetDate.AddDays(1)).ToArray();
            context.Dispose();

            if (events.Length == 0) return;

            CmMenu.Items.Clear();

            foreach (var tableEvent in events)
            {
                var item = new MenuItem {Header = tableEvent.Title, DataContext = tableEvent};
                item.Click += EventClick;

                CmMenu.Items.Add(item);
            }
            if (CmMenu.Items.Count == 0)
                CmMenu.IsEnabled = false;
        }
        public void EnableCalendar(CalendarCalDavInfo calendar)
        {
            using (var context = new OwnCloudDataContext())
            {
                var existingEntity =
                    (from o in context.Calendars where o.Url == calendar.Url select o).SingleOrDefault();

                if (existingEntity != null)
                {
                    return;
                }

                var entity = TableCalendar.FromCalDavCalendarInfo(calendar);
                entity.GetCTag = "";

                entity._accountId = this._accountId;

                context.Calendars.InsertOnSubmit(entity);
                context.SubmitChanges();
            }
        }
        public CalendarOverviewDataContext()
        {
            //First, all local stored calendars should be loaded. Then we can load the calendars,
            //that exists online
            CalendarGroups = new ObservableCollection<CalendarAccountGroup>();

            var context = new OwnCloudDataContext();

            foreach (var account in context.Accounts)
            {
                var currentAccountGroup = new CalendarAccountGroup { Key = account.DisplayUserName };

                //Copy to a local var. That fix an issue, that occures with some
                //different versions of comilers
                var currentAccount = account;

                foreach (var calendar in context.Calendars.Where(o => o.AcountID == currentAccount.GUID))
                {
                    currentAccountGroup.Add(calendar);
                }
            }

        }
Пример #10
0
        /// <summary>
        /// Loads all server calendars for the account into ServerCalendars
        /// </summary>
        private void LoadServerCalendars()
        {
            using (Data.OwnCloudDataContext context = new OwnCloudDataContext())
            {
                //Get the account, to get the Url, where we can get all calendars
                var account = context.Accounts.Where(o => o.GUID == _accountId).Single();

                //Get clear credentials
                if (account.IsEncrypted)
                {
                    account.RestoreCredentials();
                }

                //Create caldav client to get all calendars
                Net.OcCalendarClient ocClient = new Net.OcCalendarClient(account.GetUri().AbsoluteUri,
                                                                         new Net.OwncloudCredentials {
                    Username = account.Username, Password = account.Password
                }, account.CalDAVPath);

                //Load calendars
                ocClient.LoadCalendarInfoComplete += LoadCalendarInfoComplete;
                ocClient.LoadCalendarInfo();
            }
        }
Пример #11
0
        public static void AddOnlineFilesToTile(int _accountID)
        {
            string name = Resource.Localization.AppResources.Tile_RemoteFileTitle;

            try
            {
                using (var context = new OwnCloudDataContext())
                {
                    var account = context.Accounts.Single(o => o.GUID == _accountID);
                    account.RestoreCredentials();
                    name = account.Username + " " + name;
                }
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch
            // ReSharper restore EmptyGeneralCatchClause
            {
                //Do nothing
            }

            var invokeUrl = new Uri("/View/Page/RemoteFiles.xaml?account=" + _accountID, UriKind.Relative);

            PinUrlToStart(invokeUrl, name, "Resource/Image/RemoteFolderLogo.png");
        }
Пример #12
0
        public CalendarOverviewDataContext()
        {
            //First, all local stored calendars should be loaded. Then we can load the calendars,
            //that exists online
            CalendarGroups = new ObservableCollection <CalendarAccountGroup>();

            var context = new OwnCloudDataContext();

            foreach (var account in context.Accounts)
            {
                var currentAccountGroup = new CalendarAccountGroup {
                    Key = account.DisplayUserName
                };

                //Copy to a local var. That fix an issue, that occures with some
                //different versions of comilers
                var currentAccount = account;

                foreach (var calendar in context.Calendars.Where(o => o.AcountID == currentAccount.GUID))
                {
                    currentAccountGroup.Add(calendar);
                }
            }
        }
Пример #13
0
        /// <summary>
        /// Loads all server calendars for the account into ServerCalendars
        /// </summary>
        private async Task LoadServerCalendars() {

            using (var context = new OwnCloudDataContext()) {
                //Get the account, to get the Url, where we can get all calendars
                var account = await App.AccountService.GetAccountByID(_accountId.Value);

                //Get clear credentials
                await App.AccountService.RestoreCredentials(account);

                //Create caldav client to get all calendars
                var ocClient = new Net.OcCalendarClient(account.GetUri().AbsoluteUri,
                    new Net.OwncloudCredentials { Username = account.Username, Password = account.Password }, account.CalDAVPath);

                //Load calendars
                ocClient.LoadCalendarInfoComplete += LoadCalendarInfoComplete;
                ocClient.LoadCalendarInfo();

            }
        }
Пример #14
0
        /// <summary>
        /// Callback for LoadServerCalendars
        /// </summary>
        void LoadCalendarInfoComplete(object sender, Net.LoadCalendarInfoCompleteArgs e) {
            if (!e.Success)
                return;

            //Run things in main thread
            System.Windows.Deployment.Current.Dispatcher.BeginInvoke(async () => {
                    using (Data.OwnCloudDataContext context = new OwnCloudDataContext()) {
                        //Get the account, to get the Url, where we can get all calendars
                        var account = await App.AccountService.GetAccountByID(_accountId.Value);

                        //enumerate all calendars and add it to list
                        foreach (var calendar in e.CalendarInfo) {
                            ServerCalendars.Add(
                                new ServerCalendarDisplayInfo {
                                    CalendarInfo = calendar,
                                    //If the calendar is in the database, the calendar is "enabled"
                                    IsClientEnabled = context.Calendars.Where(x => account.Calendars.Contains(x.Id))
                                                            .Count(o => o.Url == calendar.Url) > 0
                                });
                        }
                    }
                });

        }
        /// <summary>
        /// Loads all server calendars for the account into ServerCalendars
        /// </summary>
        private void LoadServerCalendars()
        {

            using (var context = new OwnCloudDataContext())
            {
                //Get the account, to get the Url, where we can get all calendars
                var account = context.Accounts.Where(o => o.GUID == _accountId).Single();

                //Get clear credentials
                if (account.IsEncrypted)
                    account.RestoreCredentials();

                //Create caldav client to get all calendars
                var ocClient = new Net.OcCalendarClient(account.GetUri().AbsoluteUri ,
                    new Net.OwncloudCredentials { Username = account.Username, Password = account.Password }, account.CalDAVPath);

                //Load calendars
                ocClient.LoadCalendarInfoComplete += LoadCalendarInfoComplete;
                ocClient.LoadCalendarInfo();

            }
        }