Closed Nnino closed 11 years ago
En la funcion fun_account_event_notifications_sms() en postgres ingresar este codigo (tambien subo la correccion):
DECLARE
CursorEvents CURSOR FOR SELECT * FROM usaga.events WHERE process1=0 ORDER BY priority, datetimeevent; EventROWDATA usaga.events%ROWTYPE;
CursorNotifactions refcursor; NotificationROWDATA usaga.account_notifications%ROWTYPE;
TextSMS TEXT DEFAULT 'Alarma!'; InternalidphoneToAlarmaFromCall INTEGER DEFAULT 0; InternalidincallToAlarmaFromCall INTEGER DEFAULT 0;
BEGIN -- Obtenemos todos los eventos que no hay sido procesados automaticamente
OPEN CursorEvents;
loop
FETCH CursorEvents INTO EventROWDATA;
EXIT WHEN NOT FOUND;
-- El el evento es tipo 72 (Generado por llamada telefonica) Enviamos las notificaciones a todas las persona configuradas -- TODO: Debe enviarse a las personas que tiene asignado ese tipo de evento
OPEN CursorNotifactions FOR SELECT * FROM
usaga.account_notifications WHERE idaccount = EventROWDATA.idaccount; loop
FETCH CursorNotifactions INTO NotificationROWDATA;
EXIT WHEN NOT FOUND;
-- Definimos el texto del mensaje IF length(NotificationROWDATA.smstext) > 0 THEN TextSMS := usaga.fun_notification_gen_message(EventROWDATA.idevent::INTEGER, NotificationROWDATA.smstext::TEXT); ELSE TextSMS := EventROWDATA.description; END IF;
PERFORM fun_smsout_insert_sendnow(0, 10, NotificationROWDATA.idphone::INTEGER, 1, ''::text, TextSMS, false, 1, 'Notificacion generada automaticamente');
end loop;
CLOSE CursorNotifactions;
-- Tipo de evento 72 es alarma por llamada telefonica, debemos enviar una notificacion al propietario de la linea informando la recepcion de la alarma IF EventROWDATA.ideventtype = 72 THEN
SELECT idincall INTO InternalidincallToAlarmaFromCall FROM usaga.events_generated_by_calls WHERE idevent = EventROWDATA.idevent;
IF InternalidincallToAlarmaFromCall>0 THEN
SELECT idphone INTO InternalidphoneToAlarmaFromCall FROM incomingcalls WHERE idincall = InternalidincallToAlarmaFromCall; IF InternalidphoneToAlarmaFromCall > 0 THEN PERFORM fun_smsout_insert_sendnow(0, 10, InternalidphoneToAlarmaFromCall, 10, ''::text, 'uSAGA ha recibido su señal', true, 0, 'SMS generado automaticamente'); END IF; END IF;
END IF;
-- Actualizamos el proceso del evento a 1 UPDATE usaga.events SET process1 = 1, dateprocess1 = now() WHERE idevent = EventROWDATA.idevent;
end loop;
CLOSE CursorEvents;
RETURN TRUE; END;
Ahora recibió bien la llamada, pero de los SMS enviados, hubo uno que un celular no pudo abrir y dio el error "Tipo de mensaje no admitido"
Revisar en la tabla smsout si hay algun caracter extraño o fuera de lo normal.
El registro del SMS enviado a ese celular, luce igual que el de los demás celulares.
El error del tipo de mensaje no admitido o mensaje no soportado fue un bug de https://github.com/edwinspire/libspire_pdu Está solucionado.
Al realizar una llamada para generar una alarma, aparece el siguiente error en la consola: FETCH ALL failed: ERROR: no existe la función usaga.fun_notification_gen_message(integer, integer, integer, text) LINE 1: SELECT usaga.fun_notification_gen_message(EventROWDATA.idacc... ^ HINT: Ninguna función coincide en el nombre y tipos de argumentos. Puede ser necesario agregar conversión explícita de tipos. QUERY: SELECT usaga.fun_notification_gen_message(EventROWDATA.idaccount::INTEGER, EventROWDATA.idevent::INTEGER, EventROWDATA.ideventtype::INTEGER, NotificationROWDATA.smstext::TEXT) CONTEXT: PL/pgSQL function "fun_account_event_notifications_sms" line 34 at asignación sentencia SQL: «SELECT usaga.fun_account_event_notifications_sms()» PL/pgSQL function "fun_auto_process_events" line 2 at PERFORM sentencia SQL: «SELECT usaga.fun_auto_process_events()» PL/pgSQL function "fun_receiver_from_incomingcalls" line 69 at PERFORM