public static void UpdateCallDetails(string message) { try { UpdateData calldata = new UpdateData(); calldata.CallDetails = new CallDetails(); foreach (string data in message.Split(PortSettings.GetInstance().ReceiveDataDelimiter.ToCharArray())) { string[] keyvalue = data.Split('='); if (keyvalue[0].ToLower().Equals(Settings.GetInstance().PortSetting.ReceiveConnectionIdName)) { calldata.CallDetails.ConnID = keyvalue[1]; } else if (PortSettings.GetInstance().ReceiveDatakey.Contains(keyvalue[0])) { switch (PortSettings.GetInstance().ReceiveDatakey.IndexOf(keyvalue[0])) { case 0: calldata.CallDetails.Ad1 = keyvalue[1]; break; case 1: calldata.CallDetails.Ad2 = keyvalue[1]; break; case 2: calldata.CallDetails.Ad3 = keyvalue[1]; break; case 3: calldata.CallDetails.Ad4 = keyvalue[1]; break; case 4: calldata.CallDetails.Ad5 = keyvalue[1]; break; case 5: calldata.CallDetails.Ad6 = keyvalue[1]; break; case 6: calldata.CallDetails.Ad7 = keyvalue[1]; break; case 7: calldata.CallDetails.Ad8 = keyvalue[1]; break; case 8: calldata.CallDetails.Ad9 = keyvalue[1]; break; case 9: calldata.CallDetails.Ad10 = keyvalue[1]; break; } } } BasicService serviceClient = new BasicService(Settings.GetInstance().PortSetting.WebServiceURL); ServiceResult serviceResult = serviceClient.UpdateCallDetailsAsyc(calldata); //logger.Info("Data received from web service while update call details, Code: " + serviceResult.ResultCode + ", Description: " + serviceResult.ResultDescription); } catch //(Exception ex) { //logger.Error("Error occurred as " + ex.Message); } }
public static void ProcessInsertCallDetails(Type objType, object obj) { try { Dictionary <string, string> filterKey = new Dictionary <string, string>(); InsertData calldata = new InsertData(); calldata.CallDetails = new CallDetails(); calldata.UserData = new UserData(); calldata.KeyTable = new KeyTable(); calldata.CallDetails.FirstName = Settings.GetInstance().FirstName; calldata.CallDetails.LastName = Settings.GetInstance().LastName; calldata.CallDetails.UserName = Settings.GetInstance().UserName; object value = null; value = GetValueFromObject(objType, obj, "ConnID"); if (value != null) { calldata.UserData.ConnID = calldata.UserData.ConnID = calldata.CallDetails.ConnID = value.ToString(); } value = GetValueFromObject(objType, obj, "ANI"); if (value != null) { calldata.CallDetails.Ani = value.ToString(); } value = GetValueFromObject(objType, obj, "DNIS"); if (value != null) { calldata.CallDetails.Dnis = value.ToString(); } value = GetValueFromObject(objType, obj, "Name"); if (value != null) { calldata.CallDetails.EventName = value.ToString(); } value = GetValueFromObject(objType, obj, "ThisDN"); if (value != null) { calldata.CallDetails.ThisDN = value.ToString(); } value = GetValueFromObject(objType, obj, "Place"); if (value != null) { calldata.CallDetails.AgentPlace = value.ToString(); } value = GetValueFromObject(objType, obj, "UserData"); if (value != null) { KeyValueCollection userData = value as KeyValueCollection; //Add All Keys and values in user data table. if (userData != null) { //Add Filter keys foreach (string key in Settings.GetInstance().VoiceFilterKey) { if (userData.ContainsKey(key)) { filterKey.Add(key, userData[key].ToString()); } } //the keys does not reach, then for add other keys if (filterKey.Count < 10) { foreach (string key in userData.AllKeys) { if (!filterKey.ContainsKey(key) && filterKey.Count < 10) { filterKey.Add(key, userData[key].ToString()); } else if (filterKey.Count == 10) { break; } } } if (userData.ContainsKey(Settings.GetInstance().VoiceDispositionCollectionName)) { KeyValueCollection dispositionCollection = userData[Settings.GetInstance().VoiceDispositionCollectionName] as KeyValueCollection; if (dispositionCollection != null) { foreach (string dispositionValue in dispositionCollection.AllValues) { if (string.IsNullOrEmpty(calldata.CallDetails.Disposition1)) { calldata.CallDetails.Disposition1 = dispositionValue; } else if (string.IsNullOrEmpty(calldata.CallDetails.Disposition2)) { calldata.CallDetails.Disposition2 = dispositionValue; } } } } //For Read Dispotion Key if (userData.ContainsKey(Settings.GetInstance().VoiceDispositionKeyName)) { if (string.IsNullOrEmpty(calldata.CallDetails.Disposition1)) { calldata.CallDetails.Disposition1 = userData[Settings.GetInstance().VoiceDispositionKeyName].ToString(); } else if (string.IsNullOrEmpty(calldata.CallDetails.Disposition2)) { calldata.CallDetails.Disposition2 = userData[Settings.GetInstance().VoiceDispositionKeyName].ToString(); } else if (string.IsNullOrEmpty(calldata.CallDetails.Disposition3)) { calldata.CallDetails.Disposition3 = userData[Settings.GetInstance().VoiceDispositionKeyName].ToString(); } } //For adding all keys in user data table calldata.UserData.UserDatas = new ArrayOfKeyValueOfstringstringKeyValueOfstringstring[userData.Count]; int index = 0; foreach (string key in userData.AllKeys) { //calldata.UserData.UserDatas[key] = userData[key].ToString(); calldata.UserData.UserDatas[index] = new ArrayOfKeyValueOfstringstringKeyValueOfstringstring(); calldata.UserData.UserDatas[index].Key = key; calldata.UserData.UserDatas[index].Value = userData[key].ToString(); index++; } if (string.IsNullOrEmpty(calldata.CallDetails.AgentPlace)) { if (userData.ContainsKey("RTargetPlaceSelected")) { calldata.CallDetails.AgentPlace = userData["RTargetPlaceSelected"].ToString(); } } } int count = 1; //For Store url key Action <string, string> MapValue; MapValue = delegate(string key, string Value) { //if (key.Equals("ReferenceId")) // return; switch (count) { case 1: calldata.CallDetails.Ad1 = Value; calldata.KeyTable.Key1 = key; break; case 2: calldata.CallDetails.Ad2 = Value; calldata.KeyTable.Key2 = key; break; case 3: calldata.CallDetails.Ad3 = Value; calldata.KeyTable.Key3 = key; break; case 4: calldata.CallDetails.Ad4 = Value; calldata.KeyTable.Key4 = key; break; case 5: calldata.CallDetails.Ad5 = Value; calldata.KeyTable.Key5 = key; break; case 6: calldata.CallDetails.Ad6 = Value; calldata.KeyTable.Key6 = key; break; case 7: calldata.CallDetails.Ad7 = Value; calldata.KeyTable.Key7 = key; break; case 8: calldata.CallDetails.Ad8 = Value; calldata.KeyTable.Key8 = key; break; case 9: calldata.CallDetails.Ad9 = Value; calldata.KeyTable.Key9 = key; break; case 10: calldata.CallDetails.Ad10 = Value; calldata.KeyTable.Key10 = key; break; } count++; }; foreach (string key in Settings.GetInstance().PortSetting.ReceiveDatakey) { if (count > 10) { break; } MapValue(key, string.Empty); } foreach (string key in filterKey.Keys) { if (count > 10) { break; } if (!PortSettings.GetInstance().ReceiveDatakey.Contains(key)) { MapValue(key, filterKey[key]); } } } BasicService serviceClient = new BasicService(Settings.GetInstance().PortSetting.WebServiceURL); ServiceResult serviceResult = serviceClient.InsertCallDetailsAsyc(calldata); //logger.Info("Data received from web service while insert call details, Code: " + serviceResult.ResultCode + ", Description: " + serviceResult.ResultDescription); } catch //(Exception ex) { //logger.Error("Error occurred as " + ex.Message); } }