private void SyncShares(ZPushAccount account)
        {
            using (SharedFoldersManager manager = Manage(account))
            {
                Logger.Instance.Debug(this, "Starting sync for account {0}", account);

                if (account.IsShare)
                {
                    Logger.Instance.Debug(this, "Account {0} is a share", account);
                    manager.UpdateSharedStore();
                }
                else
                {
                    // Fetch the current shares
                    ICollection <SharedFolder> shares = manager.GetCurrentShares(null);
                    Logger.Instance.Trace(this, "AdditionalFolders_Sync: {0}", shares.Count);

                    // Convert to dictionary
                    Dictionary <SyncId, SharedFolder> dict = shares.ToDictionary(x => x.SyncId);
                    Logger.Instance.Trace(this, "AdditionalFolders_Sync2: {0}", shares.Count);

                    // Store any send-as properties
                    FeatureSendAs sendAs = ThisAddIn.Instance.GetFeature <FeatureSendAs>();
                    sendAs?.UpdateSendAsAddresses(account, shares);

                    // Store with the account
                    account.SetFeatureData(this, KEY_SHARES, dict);
                }
            }
        }
Ejemplo n.º 2
0
        private void AddSharedFolderDialog_Shown(object sender, EventArgs args)
        {
            BusyText = Properties.Resources.SharedFolders_Fetching_Label;
            KUITask
            .New((ctx) =>
            {
                // TODO: bind cancellation token to Cancel button
                // Fetch current shares
                ICollection <SharedFolder> folders = _folders.GetCurrentShares(ctx.CancellationToken);

                // Find the initial folder if required
                if (_initialSyncId != null)
                {
                    _initialFolder = folders.FirstOrDefault(f => f.SyncId == _initialSyncId);
                }

                // Group by store and folder id
                return(folders.GroupBy(f => f.Store)
                       .ToDictionary(group => group.Key,
                                     group => group.ToDictionary(folder => folder.BackendId)));
            })
            .OnSuccess(InitialiseTree, true)
            .OnError((e) =>
            {
                UI.ErrorUtil.HandleErrorNew(typeof(FeatureSharedFolders), "Exception fetching shared folders for account {0}", e,
                                            Properties.Resources.SharedFolders_Fetching_Title,
                                            Properties.Resources.SharedFolders_Fetching_Failure,
                                            _account.DisplayName);
                DialogResult = DialogResult.Cancel;
            })
            .Start(this)
            ;
        }
Ejemplo n.º 3
0
        private void AdditionalFolders_Sync(ZPushConnection connection)
        {
            using (SharedFoldersManager manager = Manage(connection.Account))
            {
                Logger.Instance.Debug(this, "Starting sync for account {0}", connection.Account);

                // Fetch the current shares
                ICollection <SharedFolder> shares = manager.GetCurrentShares(null);
                Logger.Instance.Trace(this, "AdditionalFolders_Sync: {0}", shares.Count);

                // Convert to dictionary
                Dictionary <SyncId, SharedFolder> dict = shares.ToDictionary(x => x.SyncId);
                Logger.Instance.Trace(this, "AdditionalFolders_Sync2: {0}", shares.Count);

                // Store with the account
                connection.Account.SetFeatureData(this, KEY_SHARES, dict);
            }
        }