/// <summary> /// 获取员工编号对应的UserName /// </summary> /// <param name="employeeId"></param> /// <returns></returns> public static string GetPersonUserName(string employeeId) { var icfg = OpenCfg(); try { CfgPersonQuery qPerson1 = new CfgPersonQuery(icfg); qPerson1.TenantDbid = 101; qPerson1.EmployeeId = employeeId; qPerson1.State = CfgObjectState.CFGEnabled; //qPerson1.IsAgent = 2; var person = qPerson1.ExecuteSingleResult(); if (person != null) { return(person.UserName); } } catch (Exception ex) { throw ex; } finally { CloseCfg(icfg); } return(string.Empty); }
/// <summary> /// 获取所有员工。不包含坐席信息,坐席能力 /// </summary> /// <returns></returns> public static List <Person> GetPersonsShort() { var result = new List <Person>(); var icfg = OpenCfg(); try { CfgPersonQuery qPerson1 = new CfgPersonQuery(icfg); qPerson1.TenantDbid = 101; qPerson1.State = CfgObjectState.CFGEnabled; qPerson1.IsAgent = 2; var persons = qPerson1.Execute(); foreach (var person1 in persons) { var info = new Person(); info.DBID = person1.DBID; info.EmployeeID = person1.EmployeeID; info.FirstName = person1.FirstName; info.UserName = person1.UserName; result.Add(info); } } catch (Exception ex) { throw ex; } finally { CloseCfg(icfg); } return(result); }
private static CfgPersonQuery BuildQuery(params Action <CfgPersonQuery>[] queryBuilders) { var query = new CfgPersonQuery(); foreach (var builder in queryBuilders) { builder?.Invoke(query); } return(query); }
private static CfgPersonQuery BuildExecutableQuery(IConfService service, params Action <CfgPersonQuery>[] queryBuilders) { var query = new CfgPersonQuery(service); foreach (var builder in queryBuilders) { builder?.Invoke(query); } return(query); }
/// <summary> /// Authenticates the user. /// </summary> internal OutputValues AuthenticateUser(string userName, string password) { OutputValues output = new OutputValues(); try { RequestAuthenticate requestAuthenticate = RequestAuthenticate.Create(userName, password); IMessage response = ProtocolManagers.Instance().ProtocolManager[ServerType.Configserver.ToString()].Request(requestAuthenticate); if (response != null) { switch (response.Id) { case EventAuthenticated.MessageId: { output.MessageCode = "200"; output.Message = "User " + userName + " Authenticated "; _logger.Info("User " + userName + " Authenticated "); CfgPersonQuery qPerson = new CfgPersonQuery(); qPerson.UserName = userName; CfgPerson person = _configContainer.ConfServiceObject.RetrieveObject <CfgPerson>(qPerson); if (person != null) { CfgTenant tenant = person.Tenant; if (tenant != null) { _configContainer.TenantDbId = tenant.DBID; } } break; } case EventError.MessageId: { EventError eventError = (EventError)response; if (eventError.Description != null) { _logger.Warn("User " + userName + " is not Authenticated " + eventError.Description); } output.MessageCode = "2001"; output.Message = "User " + userName + " not Authenticated "; _logger.Warn("User " + userName + " is not Authenticated "); break; } } } } catch (Exception commonException) { _logger.Error("Error occurred while authenticating user " + userName + " " + commonException.ToString()); } return(output); }
internal static OutputValues DeleteSkillFromAgent(string userName, string skillName) { OutputValues output = new OutputValues(); try { CfgPersonQuery queryPerson = new CfgPersonQuery(); queryPerson.UserName = userName; queryPerson.TenantDbid = _configContainer.TenantDbId; CfgPerson person = _configContainer.ConfServiceObject.RetrieveObject <CfgPerson>(queryPerson); if (person != null) { ICollection <CfgSkillLevel> agentSkills = person.AgentInfo.SkillLevels; foreach (CfgSkillLevel skillToRemove in person.AgentInfo.SkillLevels) { if (skillToRemove.Skill.Name == skillName) { person.AgentInfo.SkillLevels.Remove(skillToRemove); person.Save(); break; } } } output.MessageCode = "200"; output.Message = "Skill deleted Successfully."; person = _configContainer.ConfServiceObject.RetrieveObject <CfgPerson>(queryPerson); if (person != null) { //Update the skill level to MySkills if (person.AgentInfo.SkillLevels != null && person.AgentInfo.SkillLevels.Count > 0) { Datacontext.GetInstance().MySkills.Clear(); foreach (CfgSkillLevel skillLevel in person.AgentInfo.SkillLevels) { Datacontext.GetInstance().MySkills.Add(new Agent.Interaction.Desktop.Helpers.MySkills(skillLevel.Skill.Name.ToString(), skillLevel.Level)); } } else { Datacontext.GetInstance().MySkills.Clear(); } } } catch (Exception commonException) { output.MessageCode = "2001"; output.Message = (commonException.InnerException == null ? commonException.Message : commonException.InnerException.Message); } return(output); }
/// <summary> /// 获取座席列表 /// </summary> /// <param name="_confService"></param> /// <param name="campaignname"></param> /// <param name="tenantid"></param> /// <param name="switchname"></param> public static ICollection <CfgPerson> RetrieveAgentList(IConfService _confService, int tenantid) { ICollection <CfgPerson> person = null; CfgPersonQuery qperson = new CfgPersonQuery(_confService); try { qperson.TenantDbid = tenantid; person = _confService .RetrieveMultipleObjects <CfgPerson>(qperson); } catch (Exception ex) { log.Error("获取qperson列表失败 " + ex.Message); } return(person); }
/// <summary> /// Gets the full name of the agent. /// </summary> /// <param name="agentDbId">The agent db id.</param> /// <param name="tenantDbId">The tenant db id.</param> /// <returns></returns> public static string GetAgentFullName(int agentDbId, int tenantDbId) { if (Pointel.Configuration.Manager.ConfigContainer.Instance().ConfServiceObject.Protocol.State == ChannelState.Opened) { CfgPersonQuery personQuery = new CfgPersonQuery(); personQuery.TenantDbid = tenantDbId; personQuery.Dbid = agentDbId; CfgPerson person = Pointel.Configuration.Manager.ConfigContainer.Instance().ConfServiceObject.RetrieveObject <CfgPerson>(personQuery); if (person != null) { string name = string.Empty; if (!string.IsNullOrEmpty(person.FirstName)) { name += person.FirstName; } if (!string.IsNullOrEmpty(person.LastName)) { name += string.IsNullOrEmpty(name) ? "" : " " + person.LastName; } return(name); } } return("Unidentified Agent"); }
/// <summary> /// Establish connection to the configuration server /// </summary> /// <param name="pri_ConfigServerHost">The pri_ configuration server host.</param> /// <param name="pri_ConfigServerPort">The pri_ configuration server port.</param> /// <param name="clientName">Name of the client.</param> /// <param name="applicationName">Name of the application.</param> /// <param name="userName">Name of the user.</param> /// <param name="password">The password.</param> /// <param name="sec_ConfigServerHost">The sec_ configuration server host.</param> /// <param name="sec_ConfigServerPort">The sec_ configuration server port.</param> /// <returns></returns> public OutputValues ConfigConnectionEstablish(string pri_ConfigServerHost, string pri_ConfigServerPort, string applicationName, string userName, string password, string sec_ConfigServerHost, string sec_ConfigServerPort, string[] sectionToRead, params string[] sections) { _configContainer = null; _configContainer = ConfigContainer.Instance(); OutputValues output = new OutputValues(); try { var assembly = typeof(ConfigManager).Assembly; if (assembly != null) { _logger.Info("-----------------------------------------------------------------------------"); _logger.Info(assembly.GetName().Name + " : " + assembly.GetName().Version); _logger.Info("-----------------------------------------------------------------------------"); } } catch (Exception generalException) { _logger.Error("Error occurred while getting the assembly version of library : " + ((generalException.InnerException == null) ? generalException.Message : generalException.InnerException.ToString())); } ConfigConnectionManager connect = new ConfigConnectionManager(); //Clear and null all values if (_configContainer.ConfServiceObject != null) { if (_configContainer.ConfServiceObject.Protocol != null && _configContainer.ConfServiceObject.Protocol.State == ChannelState.Opened) { _configContainer.ConfServiceObject.Protocol.Close(); } if (_configContainer.ConfServiceObject != null) { ConfServiceFactory.ReleaseConfService(_configContainer.ConfServiceObject); } _configContainer.ConfServiceObject = null; } //_configContainer.AllKeys.Clear(); _configContainer.CMEValues.Clear(); //Connect Config Server output = connect.ConnectConfigServer(pri_ConfigServerHost, pri_ConfigServerPort, applicationName, userName, password, sec_ConfigServerHost, sec_ConfigServerPort); if (output.MessageCode == "200") { //Authenticate the user first and read the CME configurations output = AuthenticateUser(userName, password); if (output.MessageCode == "200") { ConfigurationHandler readValues = new ConfigurationHandler(); ConfigContainer.Instance().UserName = userName; //Get access group first then read values hierarchy //Read System section to get Tenant and switch type output = readValues.ReadSystemSection(applicationName); if (output.MessageCode == "2001") { return(output); } //Register for CME Alter Notification //readValues.RegisterCMEAlterNotification(_configContainer.TenantDbId); //Read logger to print CME values in log readValues.ReadLoggerData(userName, applicationName); InitializeLogger(userName); //Read Application keys readValues.ReadApplication(applicationName, sectionToRead, sections); //Read Agent Group Keys and override existing application keys readValues.ReadAgentGroup(userName, sectionToRead, sections); //Read person Keys and override existing application keys and Agent group keys readValues.ReadPerson(userName, sectionToRead, sections); GetContactBusinessAttribute("ContactAttributes"); //Check the user is in access group bool accessAuthenticationEnable = true; try { if (_configContainer.CMEValues.ContainsKey("login.enable.access.group-authentication")) { if (!string.IsNullOrEmpty(((ConfigValue)_configContainer.CMEValues["login.access-group"]).Value.ToString()) && !Convert.ToBoolean(((ConfigValue)_configContainer.CMEValues["login.enable.access.group-authentication"]).Value.ToString())) { accessAuthenticationEnable = false; } } } catch { _logger.Warn("Authentication using access group may not work as expected. Implementing default functionality."); } if (_configContainer.CMEValues.ContainsKey("login.access-group")) { if (_configContainer.CMEValues["login.access-group"] != null && ((ConfigValue)_configContainer.CMEValues["login.access-group"]).Value.ToString() != string.Empty) { if (accessAuthenticationEnable) { output = readValues.ReadAccessPermission(((ConfigValue)_configContainer.CMEValues["login.access-group"]).Value); if (output.MessageCode == "2001") { return(output); } } } else { _logger.Warn("login.access-group value is null or empty"); output.MessageCode = "2001"; output.Message = "Access group name is not configured. Please contact your Administrator"; return(output); } } else { _logger.Warn("login.access-group key is not configured"); output.MessageCode = "2001"; output.Message = "Access group name is not configured. Please contact your Administrator"; return(output); } //Read the available Queues such as ACD queues if (_configContainer.CMEValues.ContainsKey("login.voice.available-queues") && ((ConfigValue)_configContainer.CMEValues["login.voice.available-queues"]).Value != null) { readValues.ReadQueues(((ConfigValue)_configContainer.CMEValues["login.voice.available-queues"]).Value.ToString()); } else { _logger.Warn("login.voice.available-queues key-value is not configured"); } //Check case data and disposition from business attribute or transaction object if (_configContainer.CMEValues.ContainsKey("interaction.casedata.use-transaction-object") && ((ConfigValue)_configContainer.CMEValues["interaction.casedata.use-transaction-object"]).Value.ToLower().Equals("true") ? true : false) { //Read the case data Transaction object for add/filter/sort case data if (_configContainer.CMEValues.ContainsKey("interaction.casedata-object-name") && !string.IsNullOrEmpty(((ConfigValue)_configContainer.CMEValues["interaction.casedata-object-name"]).Value)) { readValues.ReadCaseDataTransactionObject(((ConfigValue)_configContainer.CMEValues["interaction.casedata-object-name"]).Value.ToString()); readValues.ReadCaseDataFilterTransactionObject(((ConfigValue)_configContainer.CMEValues["interaction.casedata-object-name"]).Value.ToString()); readValues.ReadCaseDataSortingTransactionObject(((ConfigValue)_configContainer.CMEValues["interaction.casedata-object-name"]).Value.ToString()); } else { _logger.Warn("interaction.casedata-object-name value is not configured"); } //Read the case data Transaction object for disposition if (_configContainer.CMEValues.ContainsKey("interaction.disposition-object-name") && !string.IsNullOrEmpty(((ConfigValue)_configContainer.CMEValues["interaction.disposition-object-name"]).Value)) { readValues.ReadDispositionTransctionObject(((ConfigValue)_configContainer.CMEValues["interaction.disposition-object-name"]).Value.ToString()); } else { _logger.Warn("interaction.disposition-object-name value is not configured"); } } else { if (_configContainer.CMEValues.ContainsKey("interaction.casedata-object-name") && !string.IsNullOrEmpty(((ConfigValue)_configContainer.CMEValues["interaction.casedata-object-name"]).Value)) { //Read casedata information from Business attributes readValues.ReadCaseDataFromBusinessAttribute(((ConfigValue)_configContainer.CMEValues["interaction.casedata-object-name"]).Value.ToString()); } else { _logger.Warn("interaction.casedata-object-name key-value is not configured"); } if (_configContainer.CMEValues.ContainsKey("interaction.disposition-object-name") && !string.IsNullOrEmpty(((ConfigValue)_configContainer.CMEValues["interaction.disposition-object-name"]).Value)) { //Read disposition information from Business attributes readValues.ReadDispositionFromBusinessAttribute(((ConfigValue)_configContainer.CMEValues["interaction.disposition-object-name"]).Value.ToString()); } else { _logger.Warn("interaction.disposition-object-name key-value is not configured"); } } //Read all skills readValues.ReadAllSkills(); //Read all places readValues.ReadAllPlaces(); //Read all DN's based on switch type //readValues.ReadAllDNs(); //Read channel based not ready reason codes for voice, email and chat medias readValues.ReadChannelNotReadyReasonCodes(); //Read global not ready reason codes if (_configContainer.AllKeys.Contains("agent-global-status.not-ready-reasoncodes")) { string[] notReadyReasonCodes = ((string)_configContainer.GetValue("agent-global-status.not-ready-reasoncodes")).Split(','); if (notReadyReasonCodes.Length > 0) { readValues.ReadGlobalNotReadyReasonCodes(notReadyReasonCodes.Distinct().ToArray <string>()); } } //Read Voice not Ready Reason Codes if (_configContainer.AllKeys.Contains("agent-voice-status.not-ready-reasoncodes")) { string[] notReadyReasonCodes = ((string)_configContainer.GetValue("agent-voice-status.not-ready-reasoncodes")).Split(','); if (notReadyReasonCodes.Length > 0) { readValues.ReadVoiceHierarchyLevelNotReadyReasonCodes(notReadyReasonCodes.Distinct().ToArray <string>()); } } CfgPersonQuery qPerson = new CfgPersonQuery(); qPerson.TenantDbid = ConfigContainer.Instance().TenantDbId; qPerson.IsAgent = 0;// 0 - Means select only Agents (or) 1 - means select only user(default) System.Collections.Generic.ICollection <CfgPerson> _allPersons = _configContainer.ConfServiceObject.RetrieveMultipleObjects <CfgPerson>(qPerson); //_configContainer.AllKeys.Add("AllPersons"); _configContainer.CMEValues.Add("AllPersons", _allPersons); readValues.RegisterCMEAlterNotification(ConfigContainer.Instance().TenantDbId); readValues = null; } else { return(output); } } return(output); }
/// <summary> /// Checks the user privilege. /// </summary> /// <param name="username">The username.</param> /// <returns></returns> public string CheckUserPrivilege(string username, IStatisticsCollection statCollection) { bool isAuthenticated = false; bool isAdmin = false; string AdminUsers = string.Empty; try { logger.Debug("ConfigConnectionManager : CheckUserPrivilege Method: Entry"); CfgAccessGroupQuery queryAccessGroup = null; CfgAccessGroup accessGroup = null; CfgPersonQuery queryPerson = null; CfgPerson Person = null; if (statCollection.ApplicationContainer.UserGroupName != null && !isAdmin) { queryAccessGroup = new CfgAccessGroupQuery(); queryAccessGroup.Name = statCollection.ApplicationContainer.UserGroupName; accessGroup = StatisticsSetting.GetInstance().confObject.RetrieveObject <CfgAccessGroup>(queryAccessGroup); queryPerson = new CfgPersonQuery(); queryPerson.UserName = username; Person = StatisticsSetting.GetInstance().confObject.RetrieveObject <CfgPerson>(queryPerson); if (accessGroup != null) { foreach (CfgID memberID in accessGroup.MemberIDs) { int id = memberID.DBID; if (memberID.Type == CfgObjectType.CFGPerson) { if (id == Person.DBID) { isAuthenticated = true; StatisticsSetting.GetInstance().isAdmin = false; } } } } queryPerson = new CfgPersonQuery(); ICollection <CfgPerson> Persons = StatisticsSetting.GetInstance().confObject.RetrieveMultipleObjects <CfgPerson>(queryPerson); if (Persons != null) { foreach (CfgPerson agent in Persons) { if (accessGroup != null) { foreach (CfgID memberID in accessGroup.MemberIDs) { int id = memberID.DBID; if (memberID.Type == CfgObjectType.CFGPerson) { if (id == agent.DBID) { StatisticsSetting.GetInstance().LstAgentUNames.Add(agent.UserName); StatisticsSetting.GetInstance().LstPersons.Add(agent); } } } } } } } if (statCollection.AdminValues.AdminUsers.Count != 0) { if (statCollection.AdminValues.AdminUsers.Contains(username)) { isAdmin = true; StatisticsSetting.GetInstance().isAdmin = true; } } } catch (Exception generalException) { logger.Error("ConfigConnectionManager : CheckUserPrivilege Method: " + generalException.Message.ToString()); } finally { logger.Debug("ConfigConnectionManager : CheckUserPrevilege Method: Exit"); GC.Collect(); } return(isAuthenticated.ToString() + "," + isAdmin.ToString()); }
private void confserv() { try { IAgent agent = container.Resolve <IAgent>(); #region ADDP settings PropertyConfiguration config = new PropertyConfiguration(); config.UseAddp = true; config.AddpServerTimeout = 30; config.AddpClientTimeout = 90; //config.AddpTrace = "both"; config.AddpTraceMode = AddpTraceMode.Both; #endregion Endpoint endpoint = new Endpoint("10.220.57.1", 2020); ConfServerProtocol confProtocol = new ConfServerProtocol(endpoint); confProtocol.ClientApplicationType = (int)CfgAppType.CFGSCE; confProtocol.ClientName = "default"; confProtocol.UserName = agent.UserName; confProtocol.UserPassword = agent.Password; try { confProtocol.BeginOpen(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } IConfService confservice = (ConfService)ConfServiceFactory.CreateConfService(confProtocol); CfgPersonQuery query = new CfgPersonQuery(); query.UserName = agent.UserName; CfgPerson person = confservice.RetrieveObject <CfgPerson>(query); //MessageBox.Show(person.ToString()); CfgAccessGroupQuery querys = new CfgAccessGroupQuery(); querys.PersonDbid = person.DBID; querys.TenantDbid = 101; ICollection <CfgAccessGroup> accessGroups = confservice.RetrieveMultipleObjects <CfgAccessGroup>(querys); foreach (CfgAccessGroup accessGroup in accessGroups) { agentProfile = accessGroup.GroupInfo.Name.ToString(); MessageBox.Show(agentProfile); if (agentProfile.Equals("Azf_Nar")) { agentProfile = "Azf_Nar"; MessageBox.Show(agentProfile); break; } else if (agentProfile.Equals("Azf_Fixed")) { agentProfile = "Azf_Fixed"; MessageBox.Show(agentProfile); break; } else if (agentProfile.Equals("Backcell")) { agentProfile = "Backcell"; MessageBox.Show(agentProfile); break; } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// 获取所有员工(坐席)、坐席信息、坐席能力 /// 此方法效率太慢 /// </summary> /// <returns></returns> public static List <Person> GetPersons() { var result = new List <Person>(); var icfg = OpenCfg(); try { CfgPersonQuery qPerson1 = new CfgPersonQuery(icfg); qPerson1.TenantDbid = 101; qPerson1.State = CfgObjectState.CFGEnabled; qPerson1.IsAgent = 2; var persons = qPerson1.Execute(); foreach (var person1 in persons) { var info = new Person(); info.DBID = person1.DBID; info.EmployeeID = person1.EmployeeID; info.FirstName = person1.FirstName; info.UserName = person1.UserName; if (person1.AgentInfo != null) { info.AgentInfo.IsInitAgentInfo = true; //坐席信息 foreach (var item in person1.AgentInfo.AgentLogins) { if (item.AgentLogin != null && item.AgentLogin.State == CfgObjectState.CFGEnabled) { info.AgentInfo.AgentLogins.Add(new AgentLogin() { DBID = item.AgentLogin.DBID, LoginCode = item.AgentLogin.LoginCode, }); } } //队列 foreach (var item in person1.AgentInfo.SkillLevels) { if (item.Skill != null && item.Skill.State == CfgObjectState.CFGEnabled) { info.AgentInfo.SkillLevels.Add(new SkillLevel() { DBID = item.Skill.DBID, Level = item.Level }); } } } //服务能力 if (person1.AgentInfo != null) { info.VOICE = 1; if (person1.AgentInfo.CapacityRule != null) { CfgScript script = person1.AgentInfo.CapacityRule; if (script != null) { KeyValueCollection kv = script.UserProperties; if (kv != null && kv.Get("_CRWizardMediaCapacityList_") != null) { KeyValueCollection kv1 = (KeyValueCollection)kv.Get("_CRWizardMediaCapacityList_"); foreach (var key in kv1.AllKeys) { if (key == "chat") { info.CHAT = kv1.GetAsInt(key); } else if (key == "voice") { info.VOICE = kv1.GetAsInt(key); } } } } } } result.Add(info); } } catch (Exception ex) { throw ex; } finally { CloseCfg(icfg); } return(result); }
/// <summary> /// 获取员工(坐席、管理员)、坐席信息、坐席能力 /// </summary> /// <param name="employeeId">员工编号</param> public static Person GetPerson(string employeeId) { var result = new List <Person>(); var icfg = OpenCfg(); try { CfgPersonQuery qPerson1 = new CfgPersonQuery(icfg); qPerson1.TenantDbid = 101; qPerson1.State = CfgObjectState.CFGEnabled; qPerson1.IsAgent = 2;//只有坐席能登录 qPerson1.EmployeeId = employeeId; var persons = qPerson1.Execute(); foreach (var person1 in persons) { var info = new Person(); info.DBID = person1.DBID; info.EmployeeID = person1.EmployeeID; info.FirstName = person1.FirstName; info.UserName = person1.UserName; if (person1.AgentInfo != null) { info.AgentInfo.IsInitAgentInfo = true; //坐席信息 foreach (var item in person1.AgentInfo.AgentLogins) { if (item.AgentLogin != null && item.AgentLogin.State == CfgObjectState.CFGEnabled) { info.LoginCode = item.AgentLogin.LoginCode; info.AgentInfo.AgentLogins.Add(new AgentLogin() { DBID = item.AgentLogin.DBID, LoginCode = item.AgentLogin.LoginCode, }); } } //队列 foreach (var item in person1.AgentInfo.SkillLevels) { if (item.Skill != null && item.Skill.State == CfgObjectState.CFGEnabled) { info.AgentInfo.SkillLevels.Add(new SkillLevel() { DBID = item.Skill.DBID, Level = item.Level }); } } } //服务能力 if (person1.AgentInfo != null) { info.VOICE = 1; if (person1.AgentInfo.CapacityRule != null) { CfgScript script = person1.AgentInfo.CapacityRule; if (script != null) { KeyValueCollection kv = script.UserProperties; if (kv != null && kv.Get("_CRWizardMediaCapacityList_") != null) { KeyValueCollection kv1 = (KeyValueCollection)kv.Get("_CRWizardMediaCapacityList_"); foreach (var key in kv1.AllKeys) { if (key == "chat") { info.CHAT = kv1.GetAsInt(key); } //else if (key == "voice") //{ // info.VOICE = kv1.GetAsInt(key); //} } } } } } if (string.IsNullOrEmpty(info.LoginCode)) { info.LoginCode = ""; } result.Add(info); } } catch (Exception ex) { throw ex; } finally { CloseCfg(icfg); } if (result.Count > 0) { var person = result.First(); var ip = HttpContext.Current.Request.UserHostAddress; using (var db = new Tele.DataLibrary.SPhoneEntities()) { var ipdn = db.SPhone_IPDN.Where(x => x.PlaceIP == ip).FirstOrDefault(); if (ipdn != null) { person.DN = ipdn.DNNo; person.Place = ipdn.Place; } } return(person); } return(null); }
internal static OutputValues AddUpdateSkillToAgent(string operationType, string userName, string skillName, Int32 skillLevel) { OutputValues output = new OutputValues(); try { CfgPersonQuery queryPerson = new CfgPersonQuery(); queryPerson.UserName = userName; queryPerson.TenantDbid = _configContainer.TenantDbId; CfgPerson person = _configContainer.ConfServiceObject.RetrieveObject <CfgPerson>(queryPerson); if (operationType == "Add") { if (person != null) { ICollection <CfgSkillLevel> agentSkills = person.AgentInfo.SkillLevels; bool flag = false; foreach (CfgSkillLevel checkSkill in agentSkills) { if (checkSkill.Skill.Name == skillName) { flag = true; break; } } if (!flag) { CfgSkillQuery querySkill = new CfgSkillQuery(); querySkill.TenantDbid = _configContainer.TenantDbId; querySkill.Name = skillName; CfgSkill skill = _configContainer.ConfServiceObject.RetrieveObject <CfgSkill>(querySkill); CfgSkillLevel skillToAdd = new CfgSkillLevel(_configContainer.ConfServiceObject, person); skillToAdd.Skill = skill; skillToAdd.Level = Convert.ToInt32(skillLevel); person.AgentInfo.SkillLevels.Add(skillToAdd); person.Save(); } } } else if (operationType == "Edit") { if (person != null) { ICollection <CfgSkillLevel> agentSkills = person.AgentInfo.SkillLevels; foreach (CfgSkillLevel editingSkill in agentSkills) { if (editingSkill.Skill.Name == skillName) { editingSkill.Level = Convert.ToInt32(skillLevel); person.Save(); break; } } } } output.MessageCode = "200"; output.Message = "Skill " + operationType + "ed Successfully."; person = _configContainer.ConfServiceObject.RetrieveObject <CfgPerson>(queryPerson); if (person != null) { //Update the skill level to MySkills if (person.AgentInfo.SkillLevels != null && person.AgentInfo.SkillLevels.Count > 0) { Datacontext.GetInstance().MySkills.Clear(); foreach (CfgSkillLevel skill in person.AgentInfo.SkillLevels) { Datacontext.GetInstance().MySkills.Add(new Agent.Interaction.Desktop.Helpers.MySkills(skill.Skill.Name.ToString(), skill.Level)); } } else { Datacontext.GetInstance().MySkills.Clear(); } } } catch (Exception commonException) { output.MessageCode = "2001"; output.Message = (commonException.InnerException == null ? commonException.Message : commonException.InnerException.Message); } return(output); }