protected override void ProcessRecord() { base.ProcessRecord(); if ((Workgroup != null) && (UserId != null)) { ConfigurationManager manager = ConfigurationManager.GetInstance(Session); WorkgroupConfigurationList workgroupConfigurationList = new WorkgroupConfigurationList(manager); var querySettings = workgroupConfigurationList.CreateQuerySettings(); querySettings.SetFilterDefinition(WorkgroupConfiguration.Property.Id, Workgroup, FilterMatchType.Exact); querySettings.SetRightsFilterToAdmin(); querySettings.SetPropertiesToRetrieveToAll(); workgroupConfigurationList.StartCaching(querySettings); if (workgroupConfigurationList.GetConfigurationList().Count > 0) { var workgroup = workgroupConfigurationList.GetConfigurationList()[0]; workgroup.PrepareForEdit(); workgroup.Members.Value.Remove(new ConfigurationId(UserId)); workgroup.Commit(); } workgroupConfigurationList.StopCaching(); } }
private void StartWatchingWorkgroups() { _isStarting = true; //_logging.LogNote("StartWatchingWorkgroups"); try { if (_configurationManager != null && _configurationManager.Session != null && _configurationManager.Session.ConnectionState == ConnectionState.Up) { _workgroupConfigurationList = new WorkgroupConfigurationList(_configurationManager); var querySettings = _workgroupConfigurationList.CreateQuerySettings(); querySettings.SetResultCountLimit(QueryResultLimit.Unlimited); var properties = new List <WorkgroupConfiguration.Property> { WorkgroupConfiguration.Property.Id, WorkgroupConfiguration.Property.DisplayName, WorkgroupConfiguration.Property.IsActive, WorkgroupConfiguration.Property.HasQueue, WorkgroupConfiguration.Property.QueueType, WorkgroupConfiguration.Property.Utilizations }; querySettings.SetPropertiesToRetrieve(properties); using (var repository = Repository) { if (!repository.Workgroups.Any()) { _workgroupConfigurationList.StartCaching(querySettings); var workgroups = _workgroupConfigurationList.GetConfigurationList(); _workgroupConfigurationList.StopCaching(); if (workgroups.Any()) { foreach (var workgroupConfiguration in workgroups) { CreateWorkgroup(workgroupConfiguration); } _workgroups = workgroups; } } } _workgroupConfigurationList.ConfigurationObjectsRemoved += Workgroups_ConfigurationObjectsRemoved; _workgroupConfigurationList.ConfigurationObjectsChanged += Workgroups_ConfigurationObjectsChanged; _workgroupConfigurationList.StartWatchingAsync(querySettings, Workgroups_StartOrRefreshWatchingCompleted, null); } } catch (Exception e) { _logging.LogException(e); _logging.TraceException(e, "WorkgroupConfigurations Error"); _isStarting = false; } }
protected override void ProcessRecord() { base.ProcessRecord(); ConfigurationManager manager = ConfigurationManager.GetInstance(Session); WorkgroupConfigurationList workgroupConfigurationList = new WorkgroupConfigurationList(manager); var querySettings = workgroupConfigurationList.CreateQuerySettings(); querySettings.SetFilterDefinition(WorkgroupConfiguration.Property.Id, Workgroup, FilterMatchType.Exact); if (Workgroup != null) { querySettings.SetPropertiesToRetrieveToAll(); workgroupConfigurationList.StartCaching(querySettings); foreach (var workgroup in workgroupConfigurationList.GetConfigurationList()) { WriteObject(workgroup, true); } } workgroupConfigurationList.StopCaching(); }