private void CallLogForm_Load(object sender, EventArgs e) { try { this.dtpFromDate.Format = DateTimePickerFormat.Custom; this.dtpFromDate.CustomFormat = "MM/ dd / yyyy hh : mm "; this.dtpDateTo.Format = DateTimePickerFormat.Custom; this.dtpDateTo.CustomFormat = "MM/ dd / yyyy hh : mm "; pluginUser = ConfigurationManager.AppSettings["User"]; pluginPassword = ConfigurationManager.AppSettings["Password"]; defaultGroup = ConfigurationManager.AppSettings["DefaultGroup"]; defaultAgent = ConfigurationManager.AppSettings["DefaultAgent"]; BasicHttpBinding binding = new BasicHttpBinding(); binding.Name = "svcOrganizationSoap"; // load the group combo box // create a new Organization client organizationClient = new svcOrganizationSoapClient(binding, organizationEndpoint); GroupInfoArrayResult giResult = new GroupInfoArrayResult(); giResult = organizationClient.GetAllGroups(pluginUser, pluginPassword); for (int i = 0; i < giResult.Groups.Length; i++) { GroupInfo info = giResult.Groups[i]; dictGroup.Add(info.Name, info.ID); } // fill the box foreach (KeyValuePair<string, int> pair in dictGroup) { cboGroupName.Items.Add(pair.Key); } // set the default group cboGroupName.SelectedItem = defaultGroup; // get the slelected group id from the dictionary if (dictGroup.ContainsKey(cboGroupName.SelectedItem.ToString())) { groupId = dictGroup[cboGroupName.SelectedItem.ToString()]; } // get a list of agents for the group AgentInfoArrayResult agentResult = organizationClient.GetAgentsForGroup(pluginUser, pluginPassword, groupId); // clear any previous dictionary items dictAgent = new Dictionary<string, int>(); dictUser = new Dictionary<int, string>(); // load the list to the agents dictionary for (int i = 0; i < agentResult.Agents.Length; i++) { AgentInfo agent = agentResult.Agents[i]; dictAgent.Add(agent.DisplayName, agent.ID); dictUser.Add(agent.ID, agent.UserName); } // load the agents combo box cboAgent.Items.Clear(); foreach (KeyValuePair<string, int> pair in dictAgent) { cboAgent.Items.Add(pair.Key); } // set the default agent cboAgent.SelectedItem = defaultAgent; // fill the call boxes this.txtPhone.Text = phone; this.dtpFromDate.Value = DateTime.Now; this.dtpDateTo.Value = DateTime.Now; } catch (Exception ex) { MessageBox.Show("An error occurred loading the CyberSharksPlugin CallLog form..." + Environment.NewLine + ex.ToString(), "CyberShark Plugin Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void PluginForm_Load(object sender, EventArgs e) { try { //Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); //config.AppSettings.Settings["IP"].Value = "10.0.0.2"; //config.Save(ConfigurationSaveMode.Modified); //ConfigurationManager.RefreshSection("appSettings"); //Open the configuration file using the dll location Configuration myDllConfig = System.Configuration.ConfigurationManager.OpenExeConfiguration(this.GetType().Assembly.Location); // Get the appSettings section AppSettingsSection myDllConfigAppSettings = (AppSettingsSection)myDllConfig.GetSection("appSettings"); // return the desired field string defaultGroup = myDllConfigAppSettings.Settings["DefaultGroup"].Value; string defaultAgent = myDllConfigAppSettings.Settings["DefaultAgent"].Value; BasicHttpBinding binding = new BasicHttpBinding(); binding.Name = "svcOrganizationSoap"; // load the group combo box // create a new Organization client organizationClient = new svcOrganizationSoapClient(binding , organizationEndpoint ); // fill the group dictionary GroupInfoArrayResult giResult = new GroupInfoArrayResult(); giResult = organizationClient.GetAllGroups(pluginUser , pluginPassword ); for (int i = 0; i < giResult.Groups.Length; i++) { GroupInfo info = giResult.Groups[i]; dictGroup.Add(info.Name, info.ID); } // fill the box foreach (KeyValuePair<string, int> pair in dictGroup) { cboGroupName.Items.Add(pair.Key); } // set the default group cboGroupName.SelectedItem = defaultGroup; // get the slelected group id from the dictionary if (dictGroup.ContainsKey(cboGroupName.SelectedItem.ToString())) { groupId = dictGroup[cboGroupName.SelectedItem.ToString()]; } // get a list of agents for the group AgentInfoArrayResult agentResult = organizationClient.GetAgentsForGroup(pluginUser, pluginPassword, groupId); // clear any previous dictionary items dictAgent = new Dictionary<string, int>(); dictUser = new Dictionary<int, string>(); // load the list to the agents dictionary for (int i = 0; i < agentResult.Agents.Length; i++) { AgentInfo agent = agentResult.Agents[i]; dictAgent.Add(agent.DisplayName, agent.ID); dictUser.Add(agent.ID, agent.UserName); } // load the agents combo box cboAgent.Items.Clear(); foreach (KeyValuePair<string, int> pair in dictAgent) { cboAgent.Items.Add(pair.Key); } // set the default agent cboAgent.SelectedItem = defaultAgent; // fill the call boxes this.txtPhone.Text = phone; this.dtpFromDate.Value = fromDate; this.dtpFromTime.Value = fromDate; this.dtpDateTo.Value = toDate; this.dtpTimeTo.Value = toDate; } catch (Exception ex) { MessageBox.Show("An error occurred loading the CyberSharksPlugin CallLog form..." + Environment.NewLine + ex.ToString() , "CyberShark Plugin Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }