public void Execute()
        {
            IServerConnectionManager serverConnectionManager = ServiceRegistration.Get <IServerConnectionManager>();
            IContentDirectory        contentDirectory        = serverConnectionManager.ContentDirectory;
            SystemName homeServerSystem   = serverConnectionManager.LastHomeServerSystem;
            bool       localHomeServer    = homeServerSystem != null && homeServerSystem.IsLocalSystem();
            bool       homeServerConncted = contentDirectory != null;

            ILocalSharesManagement localSharesManagement = ServiceRegistration.Get <ILocalSharesManagement>();

            if (localHomeServer)
            {
                if (homeServerConncted && contentDirectory.GetShares(null, SharesFilter.All).Count == 0)
                {
                    IMediaAccessor mediaAccessor = ServiceRegistration.Get <IMediaAccessor>();
                    foreach (Share share in mediaAccessor.CreateDefaultShares())
                    {
                        ServerShares serverShareProxy = new ServerShares(share);
                        serverShareProxy.AddShare();
                    }
                }
            }
            else
            {
                if (localSharesManagement.Shares.Count == 0)
                {
                    localSharesManagement.SetupDefaultShares();
                }
            }
            // The shares config model listens to share update events from both the local shares management and the home server,
            // so we don't need to trigger an update of the shares lists here
        }
Пример #2
0
        public void Execute()
        {
            IWorkflowManager         workflowManager         = ServiceRegistration.Get <IWorkflowManager>();
            IServerConnectionManager serverConnectionManager = ServiceRegistration.Get <IServerConnectionManager>();
            IContentDirectory        contentDirectory        = serverConnectionManager.ContentDirectory;
            SystemName homeServerSystem   = serverConnectionManager.LastHomeServerSystem;
            bool       localHomeServer    = homeServerSystem == null ? false : homeServerSystem.IsLocalSystem();
            bool       homeServerConncted = contentDirectory != null;

            ILocalSharesManagement localSharesManagement = ServiceRegistration.Get <ILocalSharesManagement>();

            if (localHomeServer)
            {
                if (homeServerConncted && contentDirectory.GetShares(null, SharesFilter.All).Count == 0)
                {
                    contentDirectory.SetupDefaultServerShares();
                }
                // Update of shares lists is only necessary in case the shares are managed by our home server because
                // in this case, we don't get a notification about the change in the set of shares.
                // Maybe we should add such a notification later...
                SharesConfigModel model = workflowManager.GetModel(SharesConfigModel.MODEL_ID_SHARESCONFIG) as SharesConfigModel;
                if (model != null)
                {
                    model.UpdateSharesLists_NoLock(false);
                }
            }
            else
            {
                if (localSharesManagement.Shares.Count == 0)
                {
                    localSharesManagement.SetupDefaultShares();
                }
                // The shares config model listens to update events from the local shares management, so we don't need to
                // trigger an update of the shares lists here
            }
        }