public int asociarAgente(string idAgente, string extension, string clave) { try { logger.Info("Generación de la interface con el IPCC idAgente:{0} extension:{1}", idAgente, extension); this.device = IDeviceProvider.GetIDevice(EventosHuawei.getMainEvtHuawei(this)) as IDevice; if (this.device == null) { logger.Error("No se obtuvo el acceso a la interface. agentID:{0} extension:{1}", idAgente, extension); return(-1); } logger.Trace("Carga de los datos de telefonista idAgente:{0} extension:{1}", idAgente, extension); AgentInfo agentInfo = new AgentInfo(); agentInfo.AgentId = idAgente; agentInfo.PhoneNumber = extension; agentInfo.PassWord = clave; logger.Trace("Intento de conexión idAgente:{0} extension {1}", idAgente, extension); this.device.Initialize(agentInfo, settings); EventosHuawei.ReceiveInitializeResult += ReceiveInitializeResult; EventosHuawei.ReceiveUnInitializeResult += ReceiveUnInitializeResult; return(0); } catch (Exception ex) { // Se detecto un error en el procedimiento logger.Error("Error en el intento de conexión idAgente:{0} extension:{1} error:{2}", idAgente, extension, ex.Message, ex); return(-1); } }
public int inicializarDatosConexion(string mainIPCC, string backIPCC, int timeOut, string mainIPCCWS, string backIPCCWS, string accessCode1, string accessCode2, string outboundPrefix, string extensionPrefix, int extensionLength, string transferAccessCode, MainForm frm) { try { errMsg = ""; logger.Info("Carga de los valores de conexión."); settings = new Dictionary <string, string>(); settings.Add("HuaweiCTIServerIP", mainIPCC); settings.Add("HuaweiBackupCTIServerIP", backIPCC); settings.Add("HuaweiTimeout", timeOut.ToString()); settings.Add("HuaweiWebServiceUrl", mainIPCCWS); settings.Add("HuaweiBackupWebServiceUrl", backIPCCWS); settings.Add("HuaweiAccessCode1", accessCode1); settings.Add("HuaweiAccessCode2", accessCode2); settings.Add("HuaweiOutboundPrefix", outboundPrefix); settings.Add("HuaweiExtensionPrefix", extensionPrefix); settings.Add("HuaweiExtensionLength", extensionLength.ToString()); settings.Add("HuaweiTransferAccessCode", transferAccessCode); this.timeOut = timeOut; // Inicialización de los valores de status statusAsociacion = false; statusOperacion = OpStatus.Closed; // Se intenta generar la interface de conexión bool nuevo = false; if (this.device == null) { this.device = IDeviceProvider.GetIDevice(EventosHuawei.getMainEvtHuawei(this)) as IDevice; nuevo = true; } if (nuevo) { // Se asocian los eventos con el control EventosHuawei.ReceiveInitializeResult += ReceiveInitializeResult; EventosHuawei.ReceiveUnInitializeResult += ReceiveUnInitializeResult; EventosHuawei.ReceiveSetBusyResult += ReceiveAgentStatusChangeResult; EventosHuawei.ReceiveSetIdleResult += ReceiveAgentStatusChangeResult; EventosHuawei.ReceiveAnswerCallResult += ReceiveAnswerCallResult; EventosHuawei.ReceiveHangUpResult += ReceiveHangUpResult; EventosHuawei.ReceiveAgentStatusChangeResult += ReceiveAgentStatusChange; EventosHuawei.ReceivePhoneAlertingHandle += ReceivePhoneAlerting; EventosHuawei.ReceivePhoneAlertOtherHungupHandler += ReceivePhoneAlertOtherHungup; EventosHuawei.ReceiveInitializeResult += frm.OnInitializeResultCallback; EventosHuawei.ReceiveUnInitializeResult += frm.OnUnInitializeResultCallback; EventosHuawei.ReceiveAgentStatusChangeResult += frm.OnAgentStatusChange; EventosHuawei.ReceivePhoneAlertingHandle += frm.OnPhoneAlerting; EventosHuawei.ReceivePhoneHungupHandler += frm.OnPhoneHungup; } return(0); } catch (Exception ex) { // Se detecto un error en el procedimiento errMsg = string.Format("Error en la carga de los valores de conexión. {0}", ex.Message); logger.Error("Error en la carga de los valores de conexión. {0}", ex.Message, ex); return(-1); } }