private void SessionOnConnectionStateChanged(object sender, ConnectionStateChangedEventArgs e) { try { // Initialize things on UP if (_session.ConnectionState == ConnectionState.Up) { Context.Send(s => { ConfigManager.Save(ConfigData); StatusText = "Connected to " + _session.ICServer; }, null); _userConfigurationList = new UserConfigurationList(ConfigurationManager.GetInstance(_session)); } else { Context.Send(s => StatusText = _session.ConnectionStateMessage, null); } // Save states Context.Send(s => { IsConnected = _session.ConnectionState == ConnectionState.Up; IsConnecting = _session.ConnectionState == ConnectionState.Attempting; ConnectionStateMessage = _session.ConnectionStateMessage; }, null); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
protected override void ProcessRecord() { base.ProcessRecord(); ConfigurationManager manager = ConfigurationManager.GetInstance(Session); UserConfigurationList userConfigurationList = new UserConfigurationList(manager); var querySettings = userConfigurationList.CreateQuerySettings(); if (UserId != null) { querySettings.SetFilterDefinition(UserConfiguration.Property.Id, UserId, FilterMatchType.Exact); querySettings.SetPropertiesToRetrieveToAll(); userConfigurationList.StartCaching(querySettings); foreach (var user in userConfigurationList.GetConfigurationList()) { WriteObject(user, true); } } if (DisplayName != null) { querySettings.SetFilterDefinition(UserConfiguration.Property.DisplayName, DisplayName, FilterMatchType.Contains); querySettings.SetPropertiesToRetrieveToAll(); querySettings.SetRightsFilterToAdmin(); userConfigurationList.StartCaching(querySettings); foreach (var user in userConfigurationList.GetConfigurationList()) { WriteObject(user, true); } } userConfigurationList.StopCaching(); }
private void ProcessUserConfigurations(UserConfigurationList userConfigurationList) { //_logging.LogNote("ProcessUserConfigurations"); lock (ProcessingLock) try { if (userConfigurationList != null) { var users = userConfigurationList.GetConfigurationList(); if (!_users.Any() && users.Any()) { foreach (var userConfiguration in users) { CreateAgent(userConfiguration); } _users = users; } else if (UsersChanged(users)) { foreach (var userConfiguration in users) { CreateAgent(userConfiguration); } _skillsChanged = false; _users = users; } } } catch (Exception exception) { _logging.LogException(exception); _logging.TraceException(exception, "AgentConfigurations Error"); } _firstRunAfterStart = false; }
private void StartWatchingUsers() { //_logging.LogNote("StartWatchingUsers"); try { if (_configurationManager != null && _configurationManager.Session != null && _configurationManager.Session.ConnectionState == ConnectionState.Up) { _userConfigurationList = new UserConfigurationList(_configurationManager); var querySettings = _userConfigurationList.CreateQuerySettings(); querySettings.SetResultCountLimit(QueryResultLimit.Unlimited); var properties = new List <UserConfiguration.Property> { UserConfiguration.Property.Id, UserConfiguration.Property.DisplayName, UserConfiguration.Property.Utilizations, UserConfiguration.Property.Skills, UserConfiguration.Property.License_LicenseActive, UserConfiguration.Property.License_HasClientAccess, UserConfiguration.Property.License_MediaLevel, UserConfiguration.Property.License_MediaTypes, UserConfiguration.Property.Workgroups }; querySettings.SetPropertiesToRetrieve(properties); using (var repository = Repository) { if (!repository.Agents.Any()) { _userConfigurationList.StartCaching(querySettings); var users = _userConfigurationList.GetConfigurationList(); _userConfigurationList.StopCaching(); if (users.Any()) { foreach (var userConfiguration in users) { CreateAgent(userConfiguration); } _users = users; } } } _userConfigurationList.ConfigurationObjectsRemoved += Users_ConfigurationObjectsRemoved; _userConfigurationList.ConfigurationObjectsChanged += Users_ConfigurationObjectsChanged; _userConfigurationList.StartWatchingAsync(querySettings, Users_StartOrRefreshWatchingCompleted, null); } } catch (Exception e) { _logging.LogException(e); _logging.TraceException(e, "AgentConfigurations Error"); } }
public void Unload() { try { if (_userConfigurationList.IsWatching) { _userConfigurationList.StopWatching(); } } catch (Exception) { Console.WriteLine(); } _userConfigurationList = null; _configurationManager = null; }
protected override void ProcessRecord() { base.ProcessRecord(); if ((UserId != null) && (EmailAddress != null) && (MailboxType != null)) { base.ProcessRecord(); ConfigurationManager manager = ConfigurationManager.GetInstance(Session); UserConfigurationList userConfigurationList = new UserConfigurationList(manager); //find the User by ID var querySettings = userConfigurationList.CreateQuerySettings(); querySettings.SetFilterDefinition(UserConfiguration.Property.Id, UserId, FilterMatchType.Exact); querySettings.SetRightsFilterToAdmin(); userConfigurationList.StartCaching(querySettings); if (userConfigurationList.GetConfigurationList().Count > 0) { var user = userConfigurationList.GetConfigurationList()[0]; user.PrepareForEdit(); //define Exchange mailbox if ((!String.IsNullOrEmpty(EmailAddress)) && (MailboxType.ToLower() == "exchange")) { //extract Domain Name from email address string[] stringAtSeperator = new string[] { "@" }; string[] stringDotSeperator = new string[] { "." }; string[] domainNameAndTLDArray = EmailAddress.Split(stringAtSeperator, StringSplitOptions.None); string[] domainNameArray = domainNameAndTLDArray[1].Split(stringDotSeperator, StringSplitOptions.None); //define mailbox configuration string mailboxDisplayName = user.PersonalInformation.GivenName.Value + " " + user.PersonalInformation.Surname.Value; string mailboxDirectoryEntry = "x-inin-mail.ex.ews.directory:/d=" + domainNameArray[0] + "." + domainNameArray[1] + "/e=" + EmailAddress; string mailboxMessageDelivery = EmailAddress; string mailboxMessageRetrieval = "x-inin-mail.ex.ews.store:/s=" + EmailAddress; //apply mailbox configuration to the specified user id GenericProviderMailboxSettings mailboxSetting = new GenericProviderMailboxSettings(mailboxDisplayName, mailboxDirectoryEntry, mailboxMessageDelivery, mailboxMessageRetrieval); user.Mailbox.ApplyMailboxSettings(mailboxSetting); } user.Commit(); } } }
public static Agent find(string id, List<UserConfiguration.Property> properties = null) { var query = new UserConfigurationList(ConfigurationManager.GetInstance(Application.ICSession)); var query_settings = query.CreateQuerySettings(); query_settings.SetFilterDefinition(UserConfiguration.Property.Id, id, FilterMatchType.Exact); query_settings.SetRightsFilterToView(); query_settings.SetPropertiesToRetrieve((properties ?? DefaultProperties).Union(MandatoryProperties)); query.StartCaching(query_settings); var results = query.GetConfigurationList(); query.StopCaching(); if (results.Count() == 0) throw new KeyNotFoundException(id); if (results.Count() > 1) throw new IndexOutOfRangeException(id); return new Agent(results.First()); }
public static Agent find(string id, List <UserConfiguration.Property> properties = null) { var query = new UserConfigurationList(ConfigurationManager.GetInstance(Application.ICSession)); var query_settings = query.CreateQuerySettings(); query_settings.SetFilterDefinition(UserConfiguration.Property.Id, id, FilterMatchType.Exact); query_settings.SetRightsFilterToView(); query_settings.SetPropertiesToRetrieve((properties ?? DefaultProperties).Union(MandatoryProperties)); query.StartCaching(query_settings); var results = query.GetConfigurationList(); query.StopCaching(); if (results.Count() == 0) { throw new KeyNotFoundException(id); } if (results.Count() > 1) { throw new IndexOutOfRangeException(id); } return(new Agent(results.First())); }
protected override void ProcessRecord() { base.ProcessRecord(); ConfigurationManager manager = ConfigurationManager.GetInstance(Session); UserConfigurationList userConfigurationList = new UserConfigurationList(manager); UserConfiguration user = userConfigurationList.CreateObject(); user.PrepareForEdit(); #region define User Properties //define i3 UserId user.SetConfigurationId(UserId); //define first and last name for user profile user.PersonalInformation.GivenName.Value = GivenName; user.PersonalInformation.Surname.Value = Surname; //define NT Username if (!String.IsNullOrEmpty(NTDomainName)) { user.NtDomainUser.Value = (NTDomainName); } //define extension if (!String.IsNullOrEmpty(Extension)) { user.Extension.Value = Extension; } //define outband ani if (!String.IsNullOrEmpty(OutbandANI)) { user.OutboundAni.Value = OutbandANI; } //define default workstation if (!String.IsNullOrEmpty(DefaultWorkstation)) { user.DefaultWorkstation.Value = new ConfigurationId(DefaultWorkstation); } //define Department name if (!String.IsNullOrEmpty(Department)) { user.PersonalInformation.DepartmentName.Value = Department; } //define Job Title if (!String.IsNullOrEmpty(JobTitle)) { user.PersonalInformation.Title.Value = JobTitle; } //define fax capability if (!String.IsNullOrEmpty(FaxCapability)) { if (FaxCapability.ToLower() == "enable") { user.FaxCapability.Value = true; } } //define password policy if (PasswordPolicy != null) { foreach (string pwPolicy in PasswordPolicy) { user.PasswordPolicies.Value.Add(new ConfigurationId(pwPolicy)); } } #endregion user.Commit(); }
protected override void ProcessRecord() { base.ProcessRecord(); if (UserId != null) { ConfigurationManager manager = ConfigurationManager.GetInstance(Session); UserConfigurationList userConfigurationList = new UserConfigurationList(manager); var querySettings = userConfigurationList.CreateQuerySettings(); querySettings.SetFilterDefinition(UserConfiguration.Property.Id, UserId, FilterMatchType.Exact); querySettings.SetRightsFilterToAdmin(); userConfigurationList.StartCaching(querySettings); if (userConfigurationList.GetConfigurationList().Count > 0) { var user = userConfigurationList.GetConfigurationList()[0]; user.PrepareForEdit(); #region define User Properties //define first and last name for user profile if (!String.IsNullOrEmpty(GivenName)) { user.PersonalInformation.GivenName.Value = GivenName; } if (!String.IsNullOrEmpty(Surname)) { user.PersonalInformation.Surname.Value = Surname; } //define NT Username if (!String.IsNullOrEmpty(UserId)) { user.NtDomainUser.Value = (NTDomainName); } //define extension if (!String.IsNullOrEmpty(Extension)) { user.Extension.Value = Extension; user.OutboundAni.Value = OutbandANI; } //define outband ani if (!String.IsNullOrEmpty(OutbandANI)) { user.OutboundAni.Value = OutbandANI; } //define default workstation if (!String.IsNullOrEmpty(DefaultWorkstation)) { user.DefaultWorkstation.Value = new ConfigurationId(DefaultWorkstation); } //define Department name if (!String.IsNullOrEmpty(Department)) { user.PersonalInformation.DepartmentName.Value = Department; } //define Job Title if (!String.IsNullOrEmpty(JobTitle)) { user.PersonalInformation.Title.Value = JobTitle; } //define fax capability if (!String.IsNullOrEmpty(FaxCapability)) { if (FaxCapability.ToLower() == "enable") { user.FaxCapability.Value = true; } //define fax capability if (FaxCapability.ToLower() == "disable") { user.FaxCapability.Value = false; } } #endregion user.Commit(); } userConfigurationList.StopCaching(); } }
protected override void ProcessRecord() { base.ProcessRecord(); if (UserId != null) { ConfigurationManager manager = ConfigurationManager.GetInstance(Session); UserConfigurationList userConfigurationList = new UserConfigurationList(manager); var querySettings = userConfigurationList.CreateQuerySettings(); querySettings.SetFilterDefinition(UserConfiguration.Property.Id, UserId, FilterMatchType.Exact); querySettings.SetRightsFilterToAdmin(); querySettings.SetPropertiesToRetrieve( new[] { UserConfiguration.Property.License_HasClientAccess, UserConfiguration.Property.License_AdditionalLicenses, UserConfiguration.Property.License_MediaLevel }); userConfigurationList.StartCaching(querySettings); if (userConfigurationList.GetConfigurationList().Count > 0) { var user = userConfigurationList.GetConfigurationList()[0]; user.PrepareForEdit(); #region define User Licensing if (Licenses != null) { foreach (string license in Licenses) { try { if (license.ToLower() == "client") { if (user.License.HasClientAccess.Value == true) { WriteWarning("User is already assigned client access license."); } else { user.License.HasClientAccess.Value = true; } } if (license.ToLower() == "accessanalyzer") { if (user.License.AdditionalLicenses.Value.Contains(new ConfigurationId("I3_ACCESS_ANALYZER"))) { WriteWarning("User already has an Access Analyzer license"); } else { user.License.AdditionalLicenses.Value.Add(new ConfigurationId("I3_ACCESS_ANALYZER")); } } if (license.ToLower() == "accesstracker") { if (user.License.AdditionalLicenses.Value.Contains(new ConfigurationId("I3_ACCESS_TRACKER"))) { WriteWarning("User already has an Access Tracker license"); } else { user.License.AdditionalLicenses.Value.Add(new ConfigurationId("I3_ACCESS_TRACKER")); } } if (license.ToLower() == "interactionscripter") { if (user.License.AdditionalLicenses.Value.Contains(new ConfigurationId("I3_ACCESS_INTERACTION_SCRIPTER_ADDON"))) { WriteWarning("User already has an Interaction Scripter license"); } else { user.License.AdditionalLicenses.Value.Add(new ConfigurationId("I3_ACCESS_INTERACTION_SCRIPTER_ADDON")); } } if (license.ToLower() == "ipadsupervisor") { if (user.License.AdditionalLicenses.Value.Contains(new ConfigurationId("I3_ACCESS_IPAD_USER_SUPERVISOR"))) { WriteWarning("User already has an iPad Supervisor license"); } else { user.License.AdditionalLicenses.Value.Add(new ConfigurationId("I3_ACCESS_IPAD_USER_SUPERVISOR")); } } if (license.ToLower() == "historicalreportsupervisor") { if (user.License.AdditionalLicenses.Value.Contains(new ConfigurationId("I3_ACCESS_HISTORICAL_REPORT_SUPERVISOR_PLUGIN"))) { WriteWarning("User already has a Historical Report Supervisor license"); } else { user.License.AdditionalLicenses.Value.Add(new ConfigurationId("I3_ACCESS_HISTORICAL_REPORT_SUPERVISOR_PLUGIN")); } } if (license.ToLower() == "dialersupervisor") { if (user.License.AdditionalLicenses.Value.Contains(new ConfigurationId("I3_ACCESS_DIALER_SUPERVISOR_PLUGIN"))) { WriteWarning("User already has a Dialer Supervisor license"); } else { user.License.AdditionalLicenses.Value.Add(new ConfigurationId("I3_ACCESS_DIALER_SUPERVISOR_PLUGIN")); } } if (license.ToLower() == "recorderaccess") { if (user.License.AdditionalLicenses.Value.Contains(new ConfigurationId("I3_ACCESS_RECORDER"))) { WriteWarning("User already has a Recorder Access license"); } else { user.License.AdditionalLicenses.Value.Add(new ConfigurationId("I3_ACCESS_RECORDER")); } } if (license.ToLower() == "recorderclient") { if (user.License.AdditionalLicenses.Value.Contains(new ConfigurationId("I3_ACCESS_RECORDER_CLIENT"))) { WriteWarning("User already has a Recorde Client license"); } else { user.License.AdditionalLicenses.Value.Add(new ConfigurationId("I3_ACCESS_RECORDER_CLIENT")); } } if (license.ToLower() == "reportassistantsupervisor") { if (user.License.AdditionalLicenses.Value.Contains(new ConfigurationId("I3_ACCESS_REPORT_ASSISTANT_SUPERVISOR_PLUGIN"))) { WriteWarning("User already has a Report Assistant Supervisor license"); } else { user.License.AdditionalLicenses.Value.Add(new ConfigurationId("I3_ACCESS_REPORT_ASSISTANT_SUPERVISOR_PLUGIN")); } } if (license.ToLower() == "systemstatussupervisor") { if (user.License.AdditionalLicenses.Value.Contains(new ConfigurationId("I3_ACCESS_SYSTEM_STATUS_SUPERVISOR_PLUGIN"))) { WriteWarning("User already has a Access System Status Supervisor license"); } else { user.License.AdditionalLicenses.Value.Add(new ConfigurationId("I3_ACCESS_SYSTEM_STATUS_SUPERVISOR_PLUGIN")); } } if (license.ToLower() == "workgroupsupervisor") { if (user.License.AdditionalLicenses.Value.Contains(new ConfigurationId("I3_ACCESS_WORKGROUP_SUPERVISOR_PLUGIN"))) { WriteWarning("User already has a Workgroup Supervisor license"); } else { user.License.AdditionalLicenses.Value.Add(new ConfigurationId("I3_ACCESS_WORKGROUP_SUPERVISOR_PLUGIN")); } } if (license.ToLower() == "salesforcebusinessuser") { if (user.License.AdditionalLicenses.Value.Contains(new ConfigurationId("I3_LICENSE_SALESFORCE_BUSINESSUSER"))) { WriteWarning("User already has a Salesforce Business User license"); } else { user.License.AdditionalLicenses.Value.Add(new ConfigurationId("I3_LICENSE_SALESFORCE_BUSINESSUSER")); } } if (license.ToLower() == "salesforcestandarduser") { if (user.License.AdditionalLicenses.Value.Contains(new ConfigurationId("I3_LICENSE_SALESFORCE"))) { WriteWarning("User already has a Salesforce Standard User license"); } else { user.License.AdditionalLicenses.Value.Add(new ConfigurationId("I3_LICENSE_SALESFORCE")); } } } catch (InvalidOperationException ex) { WriteError(new ErrorRecord( ex, "License of" + license + "Could not be Assigned", ErrorCategory.InvalidOperation, license)); continue; } } //apply licenses user.License.LicenseActive.Value = true; } if (ACDLevel != null) { if (ACDLevel == "Media1") { if (user.License.MediaLevel.Value == MediaLevel.Media1) { WriteWarning("User is already assigned ACD Level Media 1"); } else { user.License.MediaLevel.Value = MediaLevel.Media1; user.License.LicenseActive.Value = true; } } if (ACDLevel == "Media2") { if (user.License.MediaLevel.Value == MediaLevel.Media2) { WriteWarning("User is already assigned ACD Level Media 2"); } else { user.License.MediaLevel.Value = MediaLevel.Media2; user.License.LicenseActive.Value = true; } } if (ACDLevel == "Media3") { if (user.License.MediaLevel.Value == MediaLevel.Media3) { WriteWarning("User is already assigned ACD Level Media 3"); } else { user.License.MediaLevel.Value = MediaLevel.Media3; user.License.LicenseActive.Value = true; } } } #endregion user.Commit(); } userConfigurationList.StopCaching(); } }
private void UpdateLicensing() { try { using (var repository = Repository) { if (_configurationManager != null && _configurationManager.Session != null && _configurationManager.Session.ConnectionState == ConnectionState.Up) { var userConfigurationList = new UserConfigurationList(_configurationManager); var agents = repository.Agents.Where(a => a.ActiveInWorkgroups.Any()); if (agents.Any()) { var querySettings = userConfigurationList.CreateQuerySettings(); querySettings.SetResultCountLimit(QueryResultLimit.Unlimited); var properties = new List <UserConfiguration.Property> { UserConfiguration.Property.Id, UserConfiguration.Property.License_LicenseActive, UserConfiguration.Property.License_HasClientAccess, UserConfiguration.Property.License_MediaLevel, UserConfiguration.Property.License_MediaTypes }; querySettings.SetPropertiesToRetrieve(properties); //var userFilterDefinitions = agents.Select(a => a.DisplayName).ToList().Select(agentName => new BasicFilterDefinition<UserConfiguration, UserConfiguration.Property>(UserConfiguration.Property.DisplayName, agentName, FilterMatchType.Contains)).Cast<FilterDefinition<UserConfiguration, UserConfiguration.Property>>().ToList(); //var agentConfigIds = agents.Select(a => a.ConfigId).ToList(); //var userFilterDefinitions = new List<FilterDefinition<UserConfiguration, UserConfiguration.Property>>(); //foreach (var agentConfigId in agentConfigIds) //{ // userFilterDefinitions.Add(new BasicFilterDefinition<UserConfiguration, UserConfiguration.Property>(UserConfiguration.Property.Id, agentConfigId, FilterMatchType.Exact)); //} //querySettings.SetFilterDefinition(new GroupFilterDefinition<UserConfiguration, UserConfiguration.Property>(userFilterDefinitions)); userConfigurationList.StartCaching(querySettings); var users = userConfigurationList.GetConfigurationList(); userConfigurationList.StopCaching(); foreach (var userConfiguration in users) { var hasClientAccess = userConfiguration.License.HasClientAccess.Value && userConfiguration.License.LicenseActive.Value; var licenseMediaLevel = userConfiguration.License.MediaLevel.Value; var mediaLevel = licenseMediaLevel == MediaLevel.Media1 ? 1 : licenseMediaLevel == MediaLevel.Media2 ? 2 : licenseMediaLevel == MediaLevel.Media3 ? 3 : 0; var mediaTypes = userConfiguration.License.MediaTypes.Value; var isLicensedForChat = mediaTypes.Contains(MediaType.Chat); var user = repository.Agents.FirstOrDefault(a => a.ConfigId == userConfiguration.ConfigurationId.Id); if (user != null) { if (user.HasActiveClientLicense != hasClientAccess || user.IsLicensedForChat != isLicensedForChat || user.MediaLevel != mediaLevel) { user.HasActiveClientLicense = hasClientAccess; user.MediaLevel = mediaLevel; user.IsLicensedForChat = isLicensedForChat; repository.SaveChanges(); } } } } } } } catch (Exception e) { _logging.TraceException(e, "AgentLicenseConfigurations Error"); } }