private void ExecuteSaveScreentSettings(object obj)
        {
            ProgressInfo  = "Saving " + SelectedProfile.Name + "...";
            ShowAll       = Visibility.Collapsed;
            ShowConfigAll = Visibility.Collapsed;
            ShowProgress  = Visibility.Visible;
            System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                screenpopConfigs = new ScreenPopConfig();
                screenpopConfigs.AUXReasonEnabled    = this.IsAUXReason;
                screenpopConfigs.CanScreenPop        = this.CanScreenPop;
                screenpopConfigs.AutoRecieve         = this.AutoRecieve;
                screenpopConfigs.VoiceScreenPop      = this.VoiceScreenPop;
                screenpopConfigs.ChatScreenPop       = this.ChatScreenPop;
                screenpopConfigs.IncidentScreenPop   = this.IncidentScreenPop;
                screenpopConfigs.WrapupReasonEnabled = this.IsWrapup;
                screenpopConfigs.DefaultWorkSpace    = SelectedWorkSpaceList;

                screenpopConfigs.IsEnhanced = this.Enhanced;

                screenpopConfigs.ChatDefaultWorkspace     = SelectedChatWorkSpaceList;
                screenpopConfigs.IncidentDefaultWorkspace = SelectedIncidentWorkSpaceList;

                screenpopConfigs.CanOpen         = IsDontOpen;
                screenpopConfigs.CanOpenChat     = IsDontOpenChat;
                screenpopConfigs.CanOpenIncident = IsDontOpenIncident;

                screenpopConfigs.IsDefault            = this.IsDefaultConfig;
                screenpopConfigs.LogoutReasonEnabled  = this.IsLogout;
                screenpopConfigs.ProfileId            = (int)SelectedProfile.Value;
                screenpopConfigs.PrimaryCTIEngine     = (string.IsNullOrEmpty(PrimaryCTIEngine) ? " " : PrimaryCTIEngine);
                screenpopConfigs.SecondaryCTIEngine   = (string.IsNullOrEmpty(SecondaryCTIEngine) ? " " : SecondaryCTIEngine);
                screenpopConfigs.IsQueueEnabled       = this.IsQueueEnabled;
                screenpopConfigs.ScreenPopOptionsList = new List <ScreenPopOptions>();
                SearchPopOptions.ToList().ForEach(p =>
                {
                    screenpopConfigs.ScreenPopOptionsList.Add(new ScreenPopOptions()
                    {
                        Name = p.Name, Pop_Label = p.Pop_Label, Type = p.Type, Description = p.Description
                    });
                });

                WrapupReasoncodes.ToList().ForEach(p =>
                {
                    screenpopConfigs.ScreenPopOptionsList.Add(new ScreenPopOptions()
                    {
                        Name = p.Name, Pop_Label = p.Pop_Label, Type = p.Type, Description = p.Description
                    });
                });

                LogoutReasonCodes.ToList().ForEach(p =>
                {
                    screenpopConfigs.ScreenPopOptionsList.Add(new ScreenPopOptions()
                    {
                        Name = p.Name, Pop_Label = p.Pop_Label, Type = p.Type, Description = p.Description
                    });
                });

                AUXReasonCodes.ToList().ForEach(p =>
                {
                    screenpopConfigs.ScreenPopOptionsList.Add(new ScreenPopOptions()
                    {
                        Name = p.Name, Pop_Label = p.Pop_Label, Type = p.Type, Description = p.Description
                    });
                });

                ScreenPopConfigModel.Instance.SaveAgentConfiguration(screenpopConfigs);

                BindData();
            }).ContinueWith((s) =>
            {
                ShowConfigAll = Visibility.Visible;
                ShowProgress  = Visibility.Collapsed;
                ShowAll       = Visibility.Visible;
            });
        }
        private void BindData()
        {
            try
            {
                this.SearchPopOptions.Clear();
                this.LogoutReasonCodes.Clear();
                this.AUXReasonCodes.Clear();
                this.WrapupReasoncodes.Clear();
                this.Wrapup             = "";
                this.LogoutReason       = "";
                this.NotReadyReason     = "";
                screenpopConfigs        = ScreenPopConfigModel.Instance.GetAgentConfigurationByProfile(Int32.Parse(SelectedProfile.Value.ToString()));
                this.CanScreenPop       = screenpopConfigs.CanScreenPop;
                this.AutoRecieve        = screenpopConfigs.AutoRecieve;
                this.VoiceScreenPop     = screenpopConfigs.VoiceScreenPop;
                this.ChatScreenPop      = screenpopConfigs.ChatScreenPop;
                this.IncidentScreenPop  = screenpopConfigs.IncidentScreenPop;
                this.IsDefaultConfig    = screenpopConfigs.IsDefault;
                this.IsDontOpen         = screenpopConfigs.CanOpen;
                this.IsDontOpenIncident = screenpopConfigs.CanOpenIncident;
                this.IsDontOpenChat     = screenpopConfigs.CanOpenChat;
                this.IsWrapup           = screenpopConfigs.WrapupReasonEnabled;
                this.IsLogout           = screenpopConfigs.LogoutReasonEnabled;
                this.IsAUXReason        = screenpopConfigs.AUXReasonEnabled;
                this.PrimaryCTIEngine   = screenpopConfigs.PrimaryCTIEngine;
                this.SecondaryCTIEngine = screenpopConfigs.SecondaryCTIEngine;
                this.IsQueueEnabled     = screenpopConfigs.IsQueueEnabled;
                this.AutoRecieve        = screenpopConfigs.AutoRecieve;
                this.Enhanced           = screenpopConfigs.IsEnhanced;

                if (!IsDontOpen)
                {
                    SelectedWorkSpaceList = WorkSpaceList.FirstOrDefault(p => p.ToString() == screenpopConfigs.DefaultWorkSpace);
                }
                if (!IsDontOpenChat)
                {
                    SelectedChatWorkSpaceList = WorkSpaceList.FirstOrDefault(p => p.ToString() == screenpopConfigs.ChatDefaultWorkspace);
                }
                if (!IsDontOpenIncident)
                {
                    SelectedIncidentWorkSpaceList = WorkSpaceList.FirstOrDefault(p => p.ToString() == screenpopConfigs.IncidentDefaultWorkspace);
                }

                if (screenpopConfigs.ScreenPopOptionsList != null)
                {
                    foreach (ScreenPopOptions opt in screenpopConfigs.ScreenPopOptionsList.Where(opt => opt.Type == (int)ScreenOptions.ScreenSearch))
                    {
                        SearchPopOptions.Add(new ScreenPopUpEntity()
                        {
                            ID = opt.ID, Pop_Label = opt.Pop_Label, Type = opt.Type, Description = opt.Description, Name = opt.Name
                        });
                    }

                    foreach (ScreenPopOptions opt in screenpopConfigs.ScreenPopOptionsList.Where(opt => opt.Type == (int)ScreenOptions.WrapupReasonCodes))
                    {
                        WrapupReasoncodes.Add(new ScreenPopUpEntity()
                        {
                            ID = opt.ID, Pop_Label = opt.Pop_Label, Type = opt.Type, Description = opt.Description, Name = opt.Name
                        });
                    }
                    foreach (ScreenPopOptions opt in screenpopConfigs.ScreenPopOptionsList.Where(opt => opt.Type == (int)ScreenOptions.LogoutReasonCodes))
                    {
                        LogoutReasonCodes.Add(new ScreenPopUpEntity()
                        {
                            ID = opt.ID, Pop_Label = opt.Pop_Label, Type = opt.Type, Description = opt.Description, Name = opt.Name
                        });
                    }

                    foreach (ScreenPopOptions opt in screenpopConfigs.ScreenPopOptionsList.Where(opt => opt.Type == (int)ScreenOptions.AUXReasonCodes))
                    {
                        AUXReasonCodes.Add(new ScreenPopUpEntity()
                        {
                            ID = opt.ID, Pop_Label = opt.Pop_Label, Type = opt.Type, Description = opt.Description, Name = opt.Name
                        });
                    }
                }
                SetReasonCodeLabel();
            }
            catch (Exception ex)
            {
                Logger.Logger.Log.Error("ScreenpopConfigurationViewModel: ", ex);
            }
        }