c# - postquerynotification - sql server query notification
SqlDependency-¿Cómo interpreto las propiedades de SqlNotificationEventArgs? (1)
Estoy usando la clase SqlDependency y he intentado sin éxito encontrar una lista de posibles combinaciones de las propiedades Type , Source e Info del objeto SqlNotificationEventArgs .
This es lo más cercano que he encontrado hasta ahora. Sin embargo, sé que esto no cubre todo porque ya he visto la combinación Cambiar / Cliente / Error.
Realmente me gustaría saber si estoy manejando todos los casos posibles de la mejor manera posible. Es decir, siempre que sea posible me gustaría restablecer la "suscripción".
Por ejemplo, el cambio / cliente / error se debió a un problema de red que interrumpió la comunicación entre SqlServer y mi aplicación. Una vez que se restableció la comunicación, pude recuperarme exitosamente.
EDITAR:
Tal vez ayudaría si diera algunos ejemplos de las preocupaciones que tengo. Para las siguientes preguntas, cuando digo "recuperar", me refiero a restablecer una suscripción en tiempo de ejecución, es decir, sin intervención manual.
- ¿Es seguro asumir que un Type de
Subscribe
significa que no hay nada que pueda hacer para recuperarme? - ¿Es seguro asumir que una Source de
Data
siempre tendrá una Info detruncate
,insert
,update
odelete
? Si no, siempre será algo similar. Actualmente no distingo entre estos casos y simplemente reestablezco la suscripción y obtengo los datos actualizados. - ¿Es seguro asumir que, con la posible excepción de una Info de
Alter
, una Source deobject
significa que mi consulta ya no es válida y no podré recuperarla?
El tipo puede ser cualquiera de: Cambiar, Suscribirse o Desconocido
public enum SqlNotificationType {
Change = 0,
Subscribe = 1,
// use negative values for client-only-generated values
Unknown = -1
}
La fuente puede ser cualquiera de: Datos, Tiempo de espera, Objeto, Base de datos, Sistema, Declaración, Entorno, Ejecución, Propietario, Desconocido o Cliente
public enum SqlNotificationSource {
Data = 0,
Timeout = 1,
Object = 2,
Database = 3,
System = 4,
Statement = 5,
Environment = 6,
Execution = 7,
Owner = 8,
// use negative values for client-only-generated values
Unknown = -1,
Client = -2
}
La información puede ser cualquiera de: Truncar, Insertar, Actualizar, Eliminar, Eliminar, Alterar, Reiniciar, Error, Consulta, Inválido, Opciones, Aislamiento, Caducado, Recurso, PreviousFire, TemplateLimit, Merge, Unknown o AlreadyChanged
public enum SqlNotificationInfo {
Truncate = 0,
Insert = 1,
Update = 2,
Delete = 3,
Drop = 4,
Alter = 5,
Restart = 6,
Error = 7,
Query = 8,
Invalid = 9,
Options = 10,
Isolation = 11,
Expired = 12,
Resource = 13,
PreviousFire = 14,
TemplateLimit = 15,
Merge = 16,
// use negative values for client-only-generated values
Unknown = -1,
AlreadyChanged = -2
}
Y finalmente, en respuesta a tu pregunta una lista de posibles combinaciones:
(Change, Data, Truncate), (Change, Data, Insert), (Change, Data, Update), (Change, Data, Delete), (Change, Data, Drop), (Change, Data, Alter), (Change, Data, Restart), (Change, Data, Error), (Change, Data, Query), (Change, Data, Invalid), (Change, Data, Options), (Change, Data, Isolation), (Change, Data, Expired), (Change, Data, Resource), (Change, Data, PreviousFire), (Change, Data, TemplateLimit), (Change, Data, Merge), (Change, Data, Unknown), (Change, Data, AlreadyChanged), (Change, Timeout, Truncate), (Change, Timeout, Insert), (Change, Timeout, Update), (Change, Timeout, Delete), (Change, Timeout, Drop), (Change, Timeout, Alter), (Change, Timeout, Restart), (Change, Timeout, Error), (Change, Timeout, Query), (Change, Timeout, Invalid), (Change, Timeout, Options), (Change, Timeout, Isolation), (Change, Timeout, Expired), (Change, Timeout, Resource), (Change, Timeout, PreviousFire), (Change, Timeout, TemplateLimit), (Change, Timeout, Merge), (Change, Timeout, Unknown), (Change, Timeout, AlreadyChanged), (Change, Object, Truncate), (Change, Object, Insert), (Change, Object, Update), (Change, Object, Delete), (Change, Object, Drop), (Change, Object, Alter), (Change, Object, Restart), (Change, Object, Error), (Change, Object, Query), (Change, Object, Invalid), (Change, Object, Options), (Change, Object, Isolation), (Change, Object, Expired), (Change, Object, Resource), (Change, Object, PreviousFire), (Change, Object, TemplateLimit), (Change, Object, Merge), (Change, Object, Unknown), (Change, Object, AlreadyChanged), (Change, Database, Truncate), (Change, Database, Insert), (Change, Database, Update), (Change, Database, Delete), (Change, Database, Drop), (Change, Database, Alter), (Change, Database, Restart), (Change, Database, Error), (Change, Database, Query), (Change, Database, Invalid), (Change, Database, Options), (Change, Database, Isolation), (Change, Database, Expired), (Change, Database, Resource), (Change, Database, PreviousFire), (Change, Database, TemplateLimit), (Change, Database, Merge), (Change, Database, Unknown), (Change, Database, AlreadyChanged), (Change, System, Truncate), (Change, System, Insert), (Change, System, Update), (Change, System, Delete), (Change, System, Drop), (Change, System, Alter), (Change, System, Restart), (Change, System, Error), (Change, System, Query), (Change, System, Invalid), (Change, System, Options), (Change, System, Isolation), (Change, System, Expired), (Change, System, Resource), (Change, System, PreviousFire), (Change, System, TemplateLimit), (Change, System, Merge), (Change, System, Unknown), (Change, System, AlreadyChanged), (Change, Statement, Truncate), (Change, Statement, Insert), (Change, Statement, Update), (Change, Statement, Delete), (Change, Statement, Drop), (Change, Statement, Alter), (Change, Statement, Restart), (Change, Statement, Error), (Change, Statement, Query), (Change, Statement, Invalid), (Change, Statement, Options), (Change, Statement, Isolation), (Change, Statement, Expired), (Change, Statement, Resource), (Change, Statement, PreviousFire), (Change, Statement, TemplateLimit), (Change, Statement, Merge), (Change, Statement, Unknown), (Change, Statement, AlreadyChanged), (Change, Environment, Truncate), (Change, Environment, Insert), (Change, Environment, Update), (Change, Environment, Delete), (Change, Environment, Drop), (Change, Environment, Alter), (Change, Environment, Restart), (Change, Environment, Error), (Change, Environment, Query), (Change, Environment, Invalid), (Change, Environment, Options), (Change, Environment, Isolation), (Change, Environment, Expired), (Change, Environment, Resource), (Change, Environment, PreviousFire), (Change, Environment, TemplateLimit), (Change, Environment, Merge), (Change, Environment, Unknown), (Change, Environment, AlreadyChanged), (Change, Execution, Truncate), (Change, Execution, Insert), (Change, Execution, Update), (Change, Execution, Delete), (Change, Execution, Drop), (Change, Execution, Alter), (Change, Execution, Restart), (Change, Execution, Error), (Change, Execution, Query), (Change, Execution, Invalid), (Change, Execution, Options), (Change, Execution, Isolation), (Change, Execution, Expired), (Change, Execution, Resource), (Change, Execution, PreviousFire), (Change, Execution, TemplateLimit), (Change, Execution, Merge), (Change, Execution, Unknown), (Change, Execution, AlreadyChanged), (Change, Owner, Truncate), (Change, Owner, Insert), (Change, Owner, Update), (Change, Owner, Delete), (Change, Owner, Drop), (Change, Owner, Alter), (Change, Owner, Restart), (Change, Owner, Error), (Change, Owner, Query), (Change, Owner, Invalid), (Change, Owner, Options), (Change, Owner, Isolation), (Change, Owner, Expired), (Change, Owner, Resource), (Change, Owner, PreviousFire), (Change, Owner, TemplateLimit), (Change, Owner, Merge), (Change, Owner, Unknown), (Change, Owner, AlreadyChanged), (Change, Unknown, Truncate), (Change, Unknown, Insert), (Change, Unknown, Update), (Change, Unknown, Delete), (Change, Unknown, Drop), (Change, Unknown, Alter), (Change, Unknown, Restart), (Change, Unknown, Error), (Change, Unknown, Query), (Change, Unknown, Invalid), (Change, Unknown, Options), (Change, Unknown, Isolation), (Change, Unknown, Expired), (Change, Unknown, Resource), (Change, Unknown, PreviousFire), (Change, Unknown, TemplateLimit), (Change, Unknown, Merge), (Change, Unknown, Unknown), (Change, Unknown, AlreadyChanged), (Change, Client, Truncate), (Change, Client, Insert), (Change, Client, Update), (Change, Client, Delete), (Change, Client, Drop), (Change, Client, Alter), (Change, Client, Restart), (Change, Client, Error), (Change, Client, Query), (Change, Client, Invalid), (Change, Client, Options), (Change, Client, Isolation), (Change, Client, Expired), (Change, Client, Resource), (Change, Client, PreviousFire), (Change, Client, TemplateLimit), (Change, Client, Merge), (Change, Client, Unknown), (Change, Client, AlreadyChanged), (Subscribe, Data, Truncate), (Subscribe, Data, Insert), (Subscribe, Data, Update), (Subscribe, Data, Delete), (Subscribe, Data, Drop), (Subscribe, Data, Alter), (Subscribe, Data, Restart), (Subscribe, Data, Error), (Subscribe, Data, Query), (Subscribe, Data, Invalid), (Subscribe, Data, Options), (Subscribe, Data, Isolation), (Subscribe, Data, Expired), (Subscribe, Data, Resource), (Subscribe, Data, PreviousFire), (Subscribe, Data, TemplateLimit), (Subscribe, Data, Merge), (Subscribe, Data, Unknown), (Subscribe, Data, AlreadyChanged), (Subscribe, Timeout, Truncate), (Subscribe, Timeout, Insert), (Subscribe, Timeout, Update), (Subscribe, Timeout, Delete), (Subscribe, Timeout, Drop), (Subscribe, Timeout, Alter), (Subscribe, Timeout, Restart), (Subscribe, Timeout, Error), (Subscribe, Timeout, Query), (Subscribe, Timeout, Invalid), (Subscribe, Timeout, Options), (Subscribe, Timeout, Isolation), (Subscribe, Timeout, Expired), (Subscribe, Timeout, Resource), (Subscribe, Timeout, PreviousFire), (Subscribe, Timeout, TemplateLimit), (Subscribe, Timeout, Merge), (Subscribe, Timeout, Unknown), (Subscribe, Timeout, AlreadyChanged), (Subscribe, Object, Truncate), (Subscribe, Object, Insert), (Subscribe, Object, Update), (Subscribe, Object, Delete), (Subscribe, Object, Drop), (Subscribe, Object, Alter), (Subscribe, Object, Restart), (Subscribe, Object, Error), (Subscribe, Object, Query), (Subscribe, Object, Invalid), (Subscribe, Object, Options), (Subscribe, Object, Isolation), (Subscribe, Object, Expired), (Subscribe, Object, Resource), (Subscribe, Object, PreviousFire), (Subscribe, Object, TemplateLimit), (Subscribe, Object, Merge), (Subscribe, Object, Unknown), (Subscribe, Object, AlreadyChanged), (Subscribe, Database, Truncate), (Subscribe, Database, Insert), (Subscribe, Database, Update), (Subscribe, Database, Delete), (Subscribe, Database, Drop), (Subscribe, Database, Alter), (Subscribe, Database, Restart), (Subscribe, Database, Error), (Subscribe, Database, Query), (Subscribe, Database, Invalid), (Subscribe, Database, Options), (Subscribe, Database, Isolation), (Subscribe, Database, Expired), (Subscribe, Database, Resource), (Subscribe, Database, PreviousFire), (Subscribe, Database, TemplateLimit), (Subscribe, Database, Merge), (Subscribe, Database, Unknown), (Subscribe, Database, AlreadyChanged), (Subscribe, System, Truncate), (Subscribe, System, Insert), (Subscribe, System, Update), (Subscribe, System, Delete), (Subscribe, System, Drop), (Subscribe, System, Alter), (Subscribe, System, Restart), (Subscribe, System, Error), (Subscribe, System, Query), (Subscribe, System, Invalid), (Subscribe, System, Options), (Subscribe, System, Isolation), (Subscribe, System, Expired), (Subscribe, System, Resource), (Subscribe, System, PreviousFire), (Subscribe, System, TemplateLimit), (Subscribe, System, Merge), (Subscribe, System, Unknown), (Subscribe, System, AlreadyChanged), (Subscribe, Statement, Truncate), (Subscribe, Statement, Insert), (Subscribe, Statement, Update), (Subscribe, Statement, Delete), (Subscribe, Statement, Drop), (Subscribe, Statement, Alter), (Subscribe, Statement, Restart), (Subscribe, Statement, Error), (Subscribe, Statement, Query), (Subscribe, Statement, Invalid), (Subscribe, Statement, Options), (Subscribe, Statement, Isolation), (Subscribe, Statement, Expired), (Subscribe, Statement, Resource), (Subscribe, Statement, PreviousFire), (Subscribe, Statement, TemplateLimit), (Subscribe, Statement, Merge), (Subscribe, Statement, Unknown), (Subscribe, Statement, AlreadyChanged), (Subscribe, Environment, Truncate), (Subscribe, Environment, Insert), (Subscribe, Environment, Update), (Subscribe, Environment, Delete), (Subscribe, Environment, Drop), (Subscribe, Environment, Alter), (Subscribe, Environment, Restart), (Subscribe, Environment, Error), (Subscribe, Environment, Query), (Subscribe, Environment, Invalid), (Subscribe, Environment, Options), (Subscribe, Environment, Isolation), (Subscribe, Environment, Expired), (Subscribe, Environment, Resource), (Subscribe, Environment, PreviousFire), (Subscribe, Environment, TemplateLimit), (Subscribe, Environment, Merge), (Subscribe, Environment, Unknown), (Subscribe, Environment, AlreadyChanged), (Subscribe, Execution, Truncate), (Subscribe, Execution, Insert), (Subscribe, Execution, Update), (Subscribe, Execution, Delete), (Subscribe, Execution, Drop), (Subscribe, Execution, Alter), (Subscribe, Execution, Restart), (Subscribe, Execution, Error), (Subscribe, Execution, Query), (Subscribe, Execution, Invalid), (Subscribe, Execution, Options), (Subscribe, Execution, Isolation), (Subscribe, Execution, Expired), (Subscribe, Execution, Resource), (Subscribe, Execution, PreviousFire), (Subscribe, Execution, TemplateLimit), (Subscribe, Execution, Merge), (Subscribe, Execution, Unknown), (Subscribe, Execution, AlreadyChanged), (Subscribe, Owner, Truncate), (Subscribe, Owner, Insert), (Subscribe, Owner, Update), (Subscribe, Owner, Delete), (Subscribe, Owner, Drop), (Subscribe, Owner, Alter), (Subscribe, Owner, Restart), (Subscribe, Owner, Error), (Subscribe, Owner, Query), (Subscribe, Owner, Invalid), (Subscribe, Owner, Options), (Subscribe, Owner, Isolation), (Subscribe, Owner, Expired), (Subscribe, Owner, Resource), (Subscribe, Owner, PreviousFire), (Subscribe, Owner, TemplateLimit), (Subscribe, Owner, Merge), (Subscribe, Owner, Unknown), (Subscribe, Owner, AlreadyChanged), (Subscribe, Unknown, Truncate), (Subscribe, Unknown, Insert), (Subscribe, Unknown, Update), (Subscribe, Unknown, Delete), (Subscribe, Unknown, Drop), (Subscribe, Unknown, Alter), (Subscribe, Unknown, Restart), (Subscribe, Unknown, Error), (Subscribe, Unknown, Query), (Subscribe, Unknown, Invalid), (Subscribe, Unknown, Options), (Subscribe, Unknown, Isolation), (Subscribe, Unknown, Expired), (Subscribe, Unknown, Resource), (Subscribe, Unknown, PreviousFire), (Subscribe, Unknown, TemplateLimit), (Subscribe, Unknown, Merge), (Subscribe, Unknown, Unknown), (Subscribe, Unknown, AlreadyChanged), (Subscribe, Client, Truncate), (Subscribe, Client, Insert), (Subscribe, Client, Update), (Subscribe, Client, Delete), (Subscribe, Client, Drop), (Subscribe, Client, Alter), (Subscribe, Client, Restart), (Subscribe, Client, Error), (Subscribe, Client, Query), (Subscribe, Client, Invalid), (Subscribe, Client, Options), (Subscribe, Client, Isolation), (Subscribe, Client, Expired), (Subscribe, Client, Resource), (Subscribe, Client, PreviousFire), (Subscribe, Client, TemplateLimit), (Subscribe, Client, Merge), (Subscribe, Client, Unknown), (Subscribe, Client, AlreadyChanged), (Unknown, Data, Truncate), (Unknown, Data, Insert), (Unknown, Data, Update), (Unknown, Data, Delete), (Unknown, Data, Drop), (Unknown, Data, Alter), (Unknown, Data, Restart), (Unknown, Data, Error), (Unknown, Data, Query), (Unknown, Data, Invalid), (Unknown, Data, Options), (Unknown, Data, Isolation), (Unknown, Data, Expired), (Unknown, Data, Resource), (Unknown, Data, PreviousFire), (Unknown, Data, TemplateLimit), (Unknown, Data, Merge), (Unknown, Data, Unknown), (Unknown, Data, AlreadyChanged), (Unknown, Timeout, Truncate), (Unknown, Timeout, Insert), (Unknown, Timeout, Update), (Unknown, Timeout, Delete), (Unknown, Timeout, Drop), (Unknown, Timeout, Alter), (Unknown, Timeout, Restart), (Unknown, Timeout, Error), (Unknown, Timeout, Query), (Unknown, Timeout, Invalid), (Unknown, Timeout, Options), (Unknown, Timeout, Isolation), (Unknown, Timeout, Expired), (Unknown, Timeout, Resource), (Unknown, Timeout, PreviousFire), (Unknown, Timeout, TemplateLimit), (Unknown, Timeout, Merge), (Unknown, Timeout, Unknown), (Unknown, Timeout, AlreadyChanged), (Unknown, Object, Truncate), (Unknown, Object, Insert), (Unknown, Object, Update), (Unknown, Object, Delete), (Unknown, Object, Drop), (Unknown, Object, Alter), (Unknown, Object, Restart), (Unknown, Object, Error), (Unknown, Object, Query), (Unknown, Object, Invalid), (Unknown, Object, Options), (Unknown, Object, Isolation), (Unknown, Object, Expired), (Unknown, Object, Resource), (Unknown, Object, PreviousFire), (Unknown, Object, TemplateLimit), (Unknown, Object, Merge), (Unknown, Object, Unknown), (Unknown, Object, AlreadyChanged), (Unknown, Database, Truncate), (Unknown, Database, Insert), (Unknown, Database, Update), (Unknown, Database, Delete), (Unknown, Database, Drop), (Unknown, Database, Alter), (Unknown, Database, Restart), (Unknown, Database, Error), (Unknown, Database, Query), (Unknown, Database, Invalid), (Unknown, Database, Options), (Unknown, Database, Isolation), (Unknown, Database, Expired), (Unknown, Database, Resource), (Unknown, Database, PreviousFire), (Unknown, Database, TemplateLimit), (Unknown, Database, Merge), (Unknown, Database, Unknown), (Unknown, Database, AlreadyChanged), (Unknown, System, Truncate), (Unknown, System, Insert), (Unknown, System, Update), (Unknown, System, Delete), (Unknown, System, Drop), (Unknown, System, Alter), (Unknown, System, Restart), (Unknown, System, Error), (Unknown, System, Query), (Unknown, System, Invalid), (Unknown, System, Options), (Unknown, System, Isolation), (Unknown, System, Expired), (Unknown, System, Resource), (Unknown, System, PreviousFire), (Unknown, System, TemplateLimit), (Unknown, System, Merge), (Unknown, System, Unknown), (Unknown, System, AlreadyChanged), (Unknown, Statement, Truncate), (Unknown, Statement, Insert), (Unknown, Statement, Update), (Unknown, Statement, Delete), (Unknown, Statement, Drop), (Unknown, Statement, Alter), (Unknown, Statement, Restart), (Unknown, Statement, Error), (Unknown, Statement, Query), (Unknown, Statement, Invalid), (Unknown, Statement, Options), (Unknown, Statement, Isolation), (Unknown, Statement, Expired), (Unknown, Statement, Resource), (Unknown, Statement, PreviousFire), (Unknown, Statement, TemplateLimit), (Unknown, Statement, Merge), (Unknown, Statement, Unknown), (Unknown, Statement, AlreadyChanged), (Unknown, Environment, Truncate), (Unknown, Environment, Insert), (Unknown, Environment, Update), (Unknown, Environment, Delete), (Unknown, Environment, Drop), (Unknown, Environment, Alter), (Unknown, Environment, Restart), (Unknown, Environment, Error), (Unknown, Environment, Query), (Unknown, Environment, Invalid), (Unknown, Environment, Options), (Unknown, Environment, Isolation), (Unknown, Environment, Expired), (Unknown, Environment, Resource), (Unknown, Environment, PreviousFire), (Unknown, Environment, TemplateLimit), (Unknown, Environment, Merge), (Unknown, Environment, Unknown), (Unknown, Environment, AlreadyChanged), (Unknown, Execution, Truncate), (Unknown, Execution, Insert), (Unknown, Execution, Update), (Unknown, Execution, Delete), (Unknown, Execution, Drop), (Unknown, Execution, Alter), (Unknown, Execution, Restart), (Unknown, Execution, Error), (Unknown, Execution, Query), (Unknown, Execution, Invalid), (Unknown, Execution, Options), (Unknown, Execution, Isolation), (Unknown, Execution, Expired), (Unknown, Execution, Resource), (Unknown, Execution, PreviousFire), (Unknown, Execution, TemplateLimit), (Unknown, Execution, Merge), (Unknown, Execution, Unknown), (Unknown, Execution, AlreadyChanged), (Unknown, Owner, Truncate), (Unknown, Owner, Insert), (Unknown, Owner, Update), (Unknown, Owner, Delete), (Unknown, Owner, Drop), (Unknown, Owner, Alter), (Unknown, Owner, Restart), (Unknown, Owner, Error), (Unknown, Owner, Query), (Unknown, Owner, Invalid), (Unknown, Owner, Options), (Unknown, Owner, Isolation), (Unknown, Owner, Expired), (Unknown, Owner, Resource), (Unknown, Owner, PreviousFire), (Unknown, Owner, TemplateLimit), (Unknown, Owner, Merge), (Unknown, Owner, Unknown), (Unknown, Owner, AlreadyChanged), (Unknown, Unknown, Truncate), (Unknown, Unknown, Insert), (Unknown, Unknown, Update), (Unknown, Unknown, Delete), (Unknown, Unknown, Drop), (Unknown, Unknown, Alter), (Unknown, Unknown, Restart), (Unknown, Unknown, Error), (Unknown, Unknown, Query), (Unknown, Unknown, Invalid), (Unknown, Unknown, Options), (Unknown, Unknown, Isolation), (Unknown, Unknown, Expired), (Unknown, Unknown, Resource), (Unknown, Unknown, PreviousFire), (Unknown, Unknown, TemplateLimit), (Unknown, Unknown, Merge), (Unknown, Unknown, Unknown), (Unknown, Unknown, AlreadyChanged), (Unknown, Client, Truncate), (Unknown, Client, Insert), (Unknown, Client, Update), (Unknown, Client, Delete), (Unknown, Client, Drop), (Unknown, Client, Alter), (Unknown, Client, Restart), (Unknown, Client, Error), (Unknown, Client, Query), (Unknown, Client, Invalid), (Unknown, Client, Options), (Unknown, Client, Isolation), (Unknown, Client, Expired), (Unknown, Client, Resource), (Unknown, Client, PreviousFire), (Unknown, Client, TemplateLimit), (Unknown, Client, Merge), (Unknown, Client, Unknown), (Unknown, Client, AlreadyChanged)
Fuentes: SqlNotificationType Enumeration , SqlNotificationSource Enumeration , SqlNotificationInfo Enumeration y SqlNotificationType.cs , SqlNotificationInfo.cs , SqlNotificationSource.cs