void ComboServiceNames_TextChanged(object sender, TextChangedEventArgs e) { try { var item = ComboServiceNames.SelectedItem as PropertyValueEnumItem; if (item == null) { string strName = ComboServiceNames.Text; if (string.IsNullOrEmpty(strName)) { return; } CTIServiceNameInfo info = new CTIServiceNameInfo(); info.Name = strName; item = new PropertyValueEnumItem(); item.Value = info.Name; item.Display = info.Name; item.Description = info.Name; item.Info = info; //mListCTIServiceNameItems.Add(item); } if (mPropertyValue != null) { mPropertyValue.Value = item.Value; } OnPropertyValueChanged(); } catch (Exception ex) { ShowException(ex.Message); } }
private void Init() { try { if (PropertyInfoItem == null) { return; } CurrentApp = PropertyInfoItem.CurrentApp; ConfigObject configObject = PropertyInfoItem.ConfigObject; if (configObject != null) { mConfigObject = configObject; } ObjectPropertyInfo propertyInfo = PropertyInfoItem.PropertyInfo; if (propertyInfo != null) { mPropertyInfo = propertyInfo; } ResourceProperty propertyValue = PropertyInfoItem.ResourceProperty; if (propertyValue != null) { mPropertyValue = propertyValue; } if (mPropertyValue == null) { return; } if (!string.IsNullOrEmpty(mPropertyValue.Value)) { mListCTIServiceNameItems.Clear(); CTIServiceNameInfo info = new CTIServiceNameInfo(); info.Name = mPropertyValue.Value; PropertyValueEnumItem item = new PropertyValueEnumItem(); item.Value = info.Name; item.Display = info.Name; item.Description = info.Name; item.Info = info; mListCTIServiceNameItems.Add(item); for (int i = 0; i < ComboServiceNames.Items.Count; i++) { var temp = ComboServiceNames.Items[i] as PropertyValueEnumItem; if (temp != null) { if (temp.Value == item.Value) { ComboServiceNames.SelectedItem = temp; } } } } } catch (Exception ex) { ShowException(ex.Message); } }
private void LoadCTIServiceNames() { try { if (PropertyInfoItem == null || PropertyInfoItem.ListConfigObjects == null) { return; } if (mConfigObject == null) { return; } var parentObj = PropertyInfoItem.ListConfigObjects.FirstOrDefault( o => o.ObjectID == mConfigObject.ParentID); if (parentObj == null) { return; } //Property 11 is CTI Type ResourceProperty propertyValue = parentObj.ListProperties.FirstOrDefault(p => p.PropertyID == 11); if (propertyValue == null) { return; } //AES, CVCT 才有效 if (propertyValue.Value != "4" && propertyValue.Value != "5") { return; } string strAddress = GetService00Address(); string strPBXAddress = GetPBXAddress(); if (string.IsNullOrEmpty(strAddress) || string.IsNullOrEmpty(strPBXAddress)) { ShowException(string.Format("Server address or PBX address is empty")); return; } ServerRequestInfo requestInfo = new ServerRequestInfo(); requestInfo.ServerHost = strAddress; requestInfo.ServerPort = 8009; requestInfo.Command = (int)ServerRequestCommand.GetCTIServiceName; requestInfo.ListData.Add(strPBXAddress); OperationReturn optReturn = XMLHelper.SeriallizeObject(requestInfo); if (!optReturn.Result) { ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } WebRequest webRequest = new WebRequest(); webRequest.Session = CurrentApp.Session; webRequest.Code = (int)S1110Codes.GetServerInfo; webRequest.Data = optReturn.Data.ToString(); Service11102Client client = new Service11102Client( WebHelper.CreateBasicHttpBinding(CurrentApp.Session), WebHelper.CreateEndpointAddress( CurrentApp.Session.AppServerInfo, "Service11102")); WebReturn webReturn = null; if (MainPage != null) { MainPage.SetBusy(true, CurrentApp.GetMessageLanguageInfo("011", "Getting PBX serviceName...")); } mWorker = new BackgroundWorker(); mWorker.DoWork += (s, de) => { try { webReturn = client.DoOperation(webRequest); client.Close(); } catch (Exception ex) { ShowException(ex.Message); } }; mWorker.RunWorkerCompleted += (s, re) => { mWorker.Dispose(); if (MainPage != null) { MainPage.SetBusy(false, string.Empty); } if (webReturn == null) { return; } if (!webReturn.Result) { ShowException(string.Format("WSFail.\t{0}\t{1}", webReturn.Code, webReturn.Message)); return; } if (webReturn.ListData == null) { ShowException(string.Format("ListData is null")); return; } for (int i = 0; i < webReturn.ListData.Count; i++) { string name = webReturn.ListData[i]; CTIServiceNameInfo info = new CTIServiceNameInfo(); info.Name = name; var temp = mListCTIServiceNameItems.FirstOrDefault(t => t.Value == info.Name); if (temp == null) { temp = new PropertyValueEnumItem(); temp.Value = info.Name; temp.Display = info.Name; temp.Description = info.Name; temp.Info = info; mListCTIServiceNameItems.Add(temp); } } }; mWorker.RunWorkerAsync(); } catch (Exception ex) { ShowException(ex.Message); } }