public void UpdateSelectedWorkbin()
 {
     try
     {
         if (ConfigContainer.Instance().AllKeys.Contains("CfgPerson"))
         {
             CfgPerson person = ConfigContainer.Instance().GetValue("CfgPerson") as CfgPerson;
             if (!person.UserProperties.ContainsKey("agent.ixn.desktop"))
             {
                 person.UserProperties.Add("agent.ixn.desktop", new KeyValueCollection());
             }
             KeyValueCollection option = person.UserProperties["agent.ixn.desktop"] as KeyValueCollection;
             if (!string.IsNullOrEmpty(WorkbinUtility.Instance().SelectedWorkbinName))
             {
                 if (!option.ContainsKey("workbins.workbin-selected"))
                 {
                     option.Add("workbins.workbin-selected", WorkbinUtility.Instance().SelectedWorkbinName);
                 }
                 else
                 {
                     option["workbins.workbin-selected"] = WorkbinUtility.Instance().SelectedWorkbinName;
                 }
             }
             person.UserProperties["agent.ixn.desktop"] = option;
             person.Save();
             person = null;
         }
     }
     catch (Exception ex)
     {
         logger.Error("Error when updating selected workbin " + ex.ToString());
     }
 }
Esempio n. 2
0
        /// <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);
        }
Esempio n. 3
0
        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>
 /// Converts a PSDK Person object to its CTI equivalent.
 /// </summary>
 /// <param name="person">The Person object to convert.</param>
 /// <returns>A <see cref="Person"/> object equivalent to the provided PSDK object.</returns>
 public static Person ToPerson(this CfgPerson person)
 => new Person
 {
     Dbid              = person.DBID,
     Email             = person.EmailAddress,
     Enabled           = person.State.IsEnabled(),
     ExternalId        = person.ExternalID,
     FirstName         = person.FirstName,
     LastName          = person.LastName,
     FolderId          = person.FolderId,
     FolderPath        = person.ObjectPath,
     IsAgent           = person.IsAgent.IsTrue() ?? false,
     Name              = person.UserName,
     TenantDbid        = person.GetTenantDBID(),
     UsingExternalAuth = person.IsExternalAuth.IsTrue()
 };
Esempio n. 5
0
 /// <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");
 }
Esempio n. 6
0
        public KeyValueCollection ReadGeneralConfigurations(CfgApplication myApplication, List <CfgAgentGroup> agentGroups, CfgPerson personObject)
        {
            try
            {
                logger.Info("ReadGeneralConfigurations : Reading salesforce-integration Configuration");
                KeyValueCollection SFDCConfig = null;

                #region Reading General Configurations

                try
                {
                    if (myApplication != null)
                    {
                        //Reading Agent Level Configurations
                        if (myApplication.Options.ContainsKey("salesforce-integration"))
                        {
                            SFDCConfig = myApplication.Options.GetAsKeyValueCollection("salesforce-integration");
                            this.logger.Info("ReadGeneralConfigurations : " + (SFDCConfig != null ? "Read Configuration at Application Level" : " No configuration found at Application Level"));
                        }
                        else
                        {
                            this.logger.Info("ReadGeneralConfigurations : SFDC General Configuration is not found at Application Level.");
                        }
                    }
                }
                catch (Exception generalException)
                {
                    this.logger.Error("ReadGeneralConfigurations : Error occurred while reading configuration at application level :" + generalException.ToString());
                }

                //Reading AgentGroupLevel Configurartions

                try
                {
                    if (agentGroups != null)
                    {
                        foreach (CfgAgentGroup agentgroup in agentGroups)
                        {
                            if (agentgroup.GroupInfo.UserProperties.ContainsKey("salesforce-integration"))
                            {
                                KeyValueCollection agentGroupConfig = agentgroup.GroupInfo.UserProperties.GetAsKeyValueCollection("salesforce-integration");
                                if (agentGroupConfig != null)
                                {
                                    if (SFDCConfig != null)
                                    {
                                        foreach (string key in agentGroupConfig.AllKeys)
                                        {
                                            if (SFDCConfig.ContainsKey(key))
                                            {
                                                SFDCConfig.Set(key, agentGroupConfig.GetAsString(key));
                                            }
                                            else
                                            {
                                                SFDCConfig.Add(key, agentGroupConfig.GetAsString(key));
                                            }
                                        }
                                    }
                                    else
                                    {
                                        SFDCConfig = agentGroupConfig;
                                    }
                                    logger.Info("ReadGeneralConfigurations : SFDC configuration taken from Agent Group : " + agentgroup.GroupInfo.Name);
                                    break;
                                }
                            }
                            else
                            {
                                logger.Info("ReadGeneralConfigurations : No SFDC configuration found at Agent Group : " + agentgroup.GroupInfo.Name);
                            }
                        }
                    }
                }
                catch (Exception generalException)
                {
                    this.logger.Error("ReadGeneralConfigurations : Error occurred while reading configuration at AgentGroup level :" + generalException.ToString());
                }

                //Reading Agent Level Configurations

                try
                {
                    if (personObject.UserProperties.ContainsKey("salesforce-integration"))
                    {
                        KeyValueCollection agentConfig = personObject.UserProperties.GetAsKeyValueCollection("salesforce-integration");
                        if (agentConfig != null)
                        {
                            if (SFDCConfig != null)
                            {
                                foreach (string key in agentConfig.AllKeys)
                                {
                                    if (SFDCConfig.ContainsKey(key))
                                    {
                                        SFDCConfig.Set(key, agentConfig.GetAsString(key));
                                    }
                                    else
                                    {
                                        SFDCConfig.Add(key, agentConfig.GetAsString(key));
                                    }
                                }
                            }
                            else
                            {
                                SFDCConfig = agentConfig;
                            }
                        }
                    }
                    else
                    {
                        logger.Info("ReadGeneralConfigurations :  No SFDC configuration found at Agent Level");
                    }
                }
                catch (Exception generalException)
                {
                    this.logger.Error("ReadGeneralConfigurations : Error occurred while reading configuration at Agent level :" + generalException.ToString());
                }

                #endregion Reading General Configurations

                if (SFDCConfig != null)
                {
                    logger.Info("ReadGeneralConfigurations : General salesforce-integration Configuration Read : " + SFDCConfig.ToString());
                }

                return(SFDCConfig);
            }
            catch (Exception generalException)
            {
                logger.Error("ReadGeneralConfigurations : Error Occurred while reading SFDC General Configuration : " + generalException.ToString());
            }
            return(null);
        }
        /// <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());
        }
Esempio n. 8
0
 private static ArgumentException InvalidAgent(CfgPerson person, string paramName)
 => new ArgumentException($"The provided Person object ({person.UserName}:{person.DBID}) is not an Agent, and is invalid for this operation.", paramName);
Esempio n. 9
0
 /// <summary>
 /// Converts a PSDK Agent object to its CTI equivalent.
 /// </summary>
 /// <remarks>
 /// Duplicates similar code in <see cref="PersonAdapter"/> to avoid clutter.
 /// </remarks>
 /// <param name="agent">The Agent object to convert.</param>
 /// <returns>An <see cref="Agent"/> object equivalent to the provided PSDK object.</returns>
 /// <exception cref="ArgumentException">
 /// Throws if the provided <paramref name="agent"/> is not really an agent.
 /// </exception>
 public static Agent ToAgent(this CfgPerson agent)
 => (agent.IsAgent.IsTrue() ?? false)
        public Form1()
        {
            InitializeComponent();

            string xml =
                "<ConfData>" +
                "<CfgPerson>" +
                "<DBID value=\"165\"/>" +
                "<tenantDBID value=\"101\"/>" +
                "<lastName value=\"GI\"/>" +
                "<firstName value=\"Sim\"/>" +
                "<employeeID value=\"simulator\"/>" +
                "<userName value=\"SimGI\"/>" +
                "<password value=\"[output suppressed]\"/>" +
                "<isAgent value=\"1\"/>" +
                "<isAdmin value=\"1\"/>" +
                "<state value=\"1\"/>" +
                "<isExternalAuth value=\"1\"/>" +
                "<changePasswordOnNextLogin value=\"0\"/>" +
                "<passwordHashAlgorithm value=\"0\"/>" +
                "<PasswordUpdatingDate value=\"0\"/>" +
                "</CfgPerson>" +
                "<CfgPerson>" +
                "<DBID value=\"257\"/>" +
                "<tenantDBID value=\"101\"/>" +
                "<lastName value=\"Scott\"/>" +
                "<firstName value=\"Mike\"/>" +
                "<employeeID value=\"00116019\"/>" +
                "<userName value=\"scottmp\"/>" +
                "<password value=\"[output suppressed]\"/>" +
                "<appRanks>" +
                "<CfgPersonRank>" +
                "<appType value=\"70\"/>" +
                "<appRank value=\"3\"/>" +
                "</CfgPersonRank>" +
                "<CfgPersonRank>" +
                "<appType value=\"47\"/>" +
                "<appRank value=\"3\"/>" +
                "</CfgPersonRank>" +
                "<CfgPersonRank>" +
                "<appType value=\"49\"/>" +
                "<appRank value=\"3\"/>" +
                "</CfgPersonRank>" +
                "</appRanks>" +
                "<isAgent value=\"1\"/>" +
                "<isAdmin value=\"1\"/>" +
                "<state value=\"1\"/>" +
                "<externalID value=\"Michael.Scott\"/>" +
                "<isExternalAuth value=\"2\"/>" +
                "<changePasswordOnNextLogin value=\"1\"/>" +
                "<passwordHashAlgorithm value=\"0\"/>" +
                "<PasswordUpdatingDate value=\"0\"/>" +
                "</CfgPerson>" +
                "</ConfData>";
            XDocument doc = XDocument.Parse(xml);
            DataTable dt  = new DataTable();

            //build table
            foreach (XElement CfgPerson in doc.Descendants("CfgPerson"))
            {
                List <XElement> appRanks = CfgPerson.Descendants("appRanks").ToList();
                foreach (XElement column in CfgPerson.Elements())
                {
                    string tagName = column.Name.LocalName;
                    if (tagName != "appRanks")
                    {
                        if (!dt.Columns.Contains(tagName))
                        {
                            dt.Columns.Add(tagName, typeof(string));
                        }
                    }
                    else
                    {
                        foreach (XElement rank in appRanks.Descendants("CfgPersonRank").Elements())
                        {
                            string tagName2 = rank.Name.LocalName;
                            if (!dt.Columns.Contains(tagName2))
                            {
                                dt.Columns.Add(tagName2, typeof(string));
                            }
                        }
                    }
                }
            }
            //add data
            DataRow row = null;

            foreach (XElement CfgPerson in doc.Descendants("CfgPerson"))
            {
                List <XElement> appRanks = CfgPerson.Descendants("appRanks").ToList();
                if (appRanks.Count == 0)
                {
                    row = dt.Rows.Add();
                    foreach (XElement column in CfgPerson.Elements())
                    {
                        row[column.Name.LocalName] = column.Attribute("value").Value;
                    }
                }
                else
                {
                    foreach (XElement appRank in appRanks.Descendants("CfgPersonRank"))
                    {
                        row = dt.Rows.Add();
                        foreach (XElement rank in appRank.Elements())
                        {
                            row[rank.Name.LocalName] = rank.Attribute("value").Value;
                        }
                        foreach (XElement column in CfgPerson.Elements())
                        {
                            if (column.Name.LocalName != "appRanks")
                            {
                                row[column.Name.LocalName] = column.Attribute("value").Value;
                            }
                        }
                    }
                }
            }
            dataGridView1.DataSource = dt;
        }
        private List <T> GetConfiguredIntegration <T>(string stringToMatch)
        {
            List <T>  lstConfigurations = new List <T>();
            CfgPerson person            = null;

            if (ConfigContainer.Instance().AllKeys.Contains("CfgPerson"))
            {
                person = ConfigContainer.Instance().GetValue("CfgPerson");
            }

            List <CfgAgentGroup> agentGroup = null;

            if (ConfigContainer.Instance().AllKeys.Contains("CfgAgentGroup"))
            {
                agentGroup = ConfigContainer.Instance().GetValue("CfgAgentGroup");
            }

            CfgApplication application = null;

            if (ConfigContainer.Instance().AllKeys.Contains("CfgApplication"))
            {
                application = ConfigContainer.Instance().GetValue("CfgApplication");
            }
            if (application != null)
            {
                List <string> lstSections = new List <string>();

                if (person != null && person.UserProperties != null)
                {
                    foreach (string sectionName in person.UserProperties.AllKeys.Where(x => x.StartsWith(stringToMatch)).ToArray())
                    {
                        lstSections.Add(sectionName);
                    }
                }

                if (agentGroup != null)
                {
                    for (int index = 0; index < agentGroup.Count; index++)
                    {
                        if (agentGroup[index].GroupInfo != null && agentGroup[index].GroupInfo.UserProperties != null)
                        {
                            foreach (string sectionName in agentGroup[index].GroupInfo.UserProperties.AllKeys.Where(x => x.StartsWith(stringToMatch)).ToArray())
                            {
                                if (!lstSections.Contains(sectionName))
                                {
                                    lstSections.Add(sectionName);
                                }
                            }
                        }
                    }
                }

                foreach (string sectionName in application.Options.AllKeys.Where(x => x.StartsWith(stringToMatch)).ToArray())
                {
                    if (!lstSections.Contains(sectionName))
                    {
                        lstSections.Add(sectionName);
                    }
                }

                _logger.Trace("Number of web integration configured: " + lstSections.Count);
                for (int index = 0; index < lstSections.Count; index++)
                {
                    KeyValueCollection section = null;
                    if (application.Options.ContainsKey(lstSections[index]))
                    {
                        section = application.Options.GetAsKeyValueCollection(lstSections[index]);
                    }

                    if (person != null && person.UserProperties != null && person.UserProperties.ContainsKey(lstSections[index]))
                    {
                        section = person.UserProperties.GetAsKeyValueCollection(lstSections[index]);
                    }
                    else if (agentGroup != null)
                    {
                        for (int agentGroupIndex = 0; agentGroupIndex < agentGroup.Count; agentGroupIndex++)
                        {
                            if (agentGroup[agentGroupIndex].GroupInfo != null && agentGroup[agentGroupIndex].GroupInfo.UserProperties != null &&
                                agentGroup[agentGroupIndex].GroupInfo.UserProperties.ContainsKey(lstSections[index]))
                            {
                                section = agentGroup[agentGroupIndex].GroupInfo.UserProperties.GetAsKeyValueCollection(lstSections[index]);
                                break;
                            }
                        }
                    }
                    if (section != null)
                    {
                        lstConfigurations.Add((T)Activator.CreateInstance(typeof(T), section));
                    }
                }
            }
            else
            {
                _logger.Warn("Application object is null");
            }

            return(lstConfigurations);
        }
Esempio n. 12
0
        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());
            }
        }
Esempio n. 13
0
        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);
        }
        private void CrossnetEventHandler(object eventObject)
        {
            var eventMessage = eventObject as string;

            if (eventMessage != null)
            {
                switch (eventMessage)
                {
                case "Loggin":
                    try
                    {
                        EResultado error;
                        Agente       = _container.Resolve <IAgent>();
                        AgenteConfig = Agente.ConfPerson;
                        var lala = Agente.MonitoredCfgPersonAgents;
                        if (Agente != null)
                        {
                            Agente agent = new Agente
                            {
                                userName = Agente.UserName != null ?
                                           Agente.UserName : "",
                            };
                            if (AgenteConfig != null)
                            {
                                var lala2 = AgenteConfig.GetType();
                                agent.firstName = AgenteConfig.FirstName != null ?
                                                  AgenteConfig.FirstName : "";
                                agent.lastName = AgenteConfig.LastName != null ?
                                                 AgenteConfig.LastName : "";
                                agent.tenantDBid = 147;
                                agent.agentDBid  = AgenteConfig.DBID != null ?
                                                   AgenteConfig.DBID : 0;
                                agent.EmployeeId = AgenteConfig.EmployeeID != null ?
                                                   AgenteConfig.EmployeeID : "";
                            }
                            var resultado = _metodoApi.autentificacion(out error, agent);
                            if (resultado != null)
                            {
                                token = resultado.token;
                            }
                        }
                        var itemsLista = _metodoApi.ArbolTipificacion(out error, token);
                        if (itemsLista != null)
                        {
                            if (itemsLista.listaArbol != null)
                            {
                                TablaTipificaciones = Utility.ListToDataTable(itemsLista.listaArbol);
                            }
                        }
                        else
                        {
                            TablaTipificaciones = null;
                        }

                        var itemsFiltro = _metodoApi.ListaFiltro(out error, token);
                        if (itemsFiltro != null)
                        {
                            listaFiltro = itemsFiltro.listaFiltro;
                        }
                        listaAtached = _metodoApi.ListAtached(out error, token);
                        _TablaInteraccion.Columns.Add("IdMarkDone");
                        _TablaInteraccion.Columns.Add("EventoMarkdone");
                        _TablaInteraccion.Columns.Add("Estado");
                        _TablaInteraccion.Columns.Add("Agente");
                    }
                    catch (Exception error)
                    {
                        GenesysAlert.SendMessage(
                            "Se ha producido un error en el login: "******"Public",
                            SeverityType.Error);
                    }


                    break;
                }
            }
        }