Tabla de Contenidos



Notifications


With notifications the end user can get information in a visual and interactive way of what is happening below the application. So that, when it gets important data operations in the application do not leave messages or take the application to important places.

The types of notifications are two:

  1. Integrated with the Appwizard menu.
  2. By free and autonomous control, where the developer has the total control.


Special Replica Event REPLICA OK


We can capture the event when an operation enters by replica in a certain table of the database, in a specific node that is defined within the enterprises collection.

<replica-ok-gen_tareas>
	<action name="runscript">
		<script language="VBScript">
			dim hay
			hay=0
			set coll=appdata.getcollection("AvisosTareasAsignadas")
			coll.startbrowse
			if not coll.currentitem is nothing then
				hay=coll.CurrentItem("MAP_MAX")
				if hay&lt;&gt;0 then
					'Actualizamos las tareas para marcarlas como notificadas sin que la operación entre en réplica.
					appdata.GetCollection("ForMaintenance").ExecuteSqlString "UPDATE gen_tareas set NOTIFICADA=1 WHERE ID_USUARIO IN (SELECT ID_USUARIO FROM GEN_USUARIOS WHERE ID="+ user("ID") +") AND ID_ULTIMO_ESTADO= 2 AND (NOTIFICADA&lt;&gt;1 OR NOTIFICADA IS NULL)"
					ui.msgbox "Se le ha asignado " + cstr(hay) + " nueva/s tarea/s", "aviso", 0
					hay=0
				end if
			end if
			coll.endbrowse
			coll.clear
			set coll=nothing
		</script>
	</action>
</replica-ok-gen_tareas>
...
...
<!-- Aquí definimos la colección que nos cuenta las tareas nuevas que han entrado para un usuario -->
<coll name="AvisosTareasAsignadas" nostopreplica="true" title="Envios Pendientes" sql="SELECT COUNT(ID) AS MAP_MAX  FROM GEN_TAREAS 
		WHERE ID_USUARIO IN (SELECT ID_USUARIO FROM GEN_USUARIOS WHERE ID=##USERID##) 
		AND ID_ULTIMO_ESTADO= 2
		AND (NOTIFICADA&lt;&gt;1 OR NOTIFICADA IS NULL)" objname="Tareas" updateobj="Tareas" progid="ASData.CASBasicDataObj"  autorefresh="true">
	<group name="General" id="1" />
	<prop name="MAP_MAX" title="ID" visible="0" fieldsize="1" size="1" type="N" />
</coll>

Integrated with the Appwizard Menu


These notifications are linked to the collection that are called from the Appwizard menu through a series of attributes.


For this case, a coll like this one will be created:

<coll name="Avisos" title="el aviso" sql="SELECT d.ID
 	FROM (##PREF##Documentos d
	LEFT OUTER JOIN ##PREF##TiposDocumento td ON d.IDTIPODOC=td.ID)
	WHERE td.SIMBOLO='PD' AND d.OP1=1" objname="Documentos" updateobj="Documentos" progid="ASData.CASBasicDataObj" 
	notify="true" notify_counter="false" notify_coll="ParteDiario" alternate-counter="true" notify_title="Entregas Avisos">
 
	<group name="General" id="1"></group>
	<prop name="ID" group="1" visible="7" type="N" fieldsize="5"></prop>
</coll>

The related attributes are:

Notify


Attribute with which we indicate the framework that is a notifications collection and has to be checked every time it replicates in order to see if it meets the SQL of such collection and notify the user about such event.

Notify_counter


It makes a counting about the elements of that collection. If this attribute is not specified, instead counting the elements of that collection, it is necessary to check if there are elements.

Notify_coll


It is the name of the secondary collection that will be used for edition. If this attribute is not specified, the collection which defines these attributes will be edited. Usually, when we want to count the elements of a collection (in order to see the notices) it is notably faster counting a collection with a very simple SQL like the one of the example and at the time to edit, we call to the collection which will have the complex SQL. This collection must be called from the Appwizard.

Notify_title


If this attributte is specified, it will be the text which appears identifying the notice, otherwise it will be the caption attribute used to notify at the appwizard.

By free and autonomous control where the programmer has the full control


For this type of notifications we use the maintenance node, with which maintenances in background will be launched and we will be able to use to show the messages we need.


With this type of notifications, the programmer has the full control. They are useful to be used when an application without appwizard has be created and the entry is made through “entry-point”.

<action name="MensajesInc" type="runscript" period="X" frecuency="5" showintab="false" executealways="true">
	<script language="VBScript">
		'Variable para controlar si se ha ejecutado al menos 1 vez                 
		vGo=0
		'variable para cada cuantos minutos se ha ejecutado
		vDiff=0
		'Se comprueba que la variable global de control se ha ejecutado ya o no
		If Len(CStr(appdata.CurrentEnterprise.Variables("MsgTime")))=0 Then
			'si entra aqui, es que es la primera vez que se ejecuta
			vGo=1
		Else
			'si entra aqui, es que es la segunda vez, y entonces ya lo que hacemos en controlar la diferencia en minutos
			'de cuando se ejecuto por ultima vez
			vDiff=DateDiff("n",appdata.CurrentEnterprise.Variables("MsgTime"),Now)
		End If
		'Ahora comprobamos que es la primera vez que se ejecuta o que ya lleva por lo menos 5 minutos desde la ultima vez.
		'este control se realiza para no dejar pantallas en segundo plano cada muy poco tiempo.                  
		If vDiff&gt;=4 Or vGo=1 Then 
			'Aqui ya se realizan los script donde se comprueban las tablas para nuestras notificaciones
			'Si se cumplen, tenemos varias opciones:
			'Aviso sonoro y si en el framework esta implementado vibrador
			appdata.userinterface.PlaySoundAndVibrate "##DEFAULT##","##DEFAULT##",1
			'Aviso por un mensaje en pantalla
			appdata.userinterface.msgbox strShow,"AVISO!",0
			'Aviso realizando la apertura de un objeto
			set obj=appdata.GetCollection("ColeccionAvisada")("ID",cstr(nuestroid))
			appdata.PushValue obj
			'Por último seteamos la variable global para su siguiente ejecución y así sepamos cuando se realizó el ultimo aviso
			appdata.CurrentEnterprise.Variables("MsgTime")=Now                        
		End If
	</script>
</action>