예제 #1
0
 public static PushSqlDependency Instance(NotifierEntity notifierEntity, Action <String> dispatcher, bool isNomTable)
 {
     if (isNomTable)
     {
         var userId = notifierEntity.SqlParamVal;
         if (instance.ContainsKey(userId))
         {
             PushSqlDependency sqlInstancne;
             if (instance.TryGetValue(userId, out sqlInstancne))
             {
                 return(sqlInstancne);
             }
             else
             {
                 instance.Remove(userId);
                 var newSqlInstance1 = new PushSqlDependency(notifierEntity, dispatcher, isNomTable);
                 instance.Add(userId, newSqlInstance1);
                 return(newSqlInstance1);
             }
         }
         else
         {
             var newSqlInstance = new PushSqlDependency(notifierEntity, dispatcher, isNomTable);
             instance.Add(userId, newSqlInstance);
             return(newSqlInstance);
         }
     }
     else
     {
         return(new PushSqlDependency(notifierEntity, dispatcher, isNomTable));
     }
 }
예제 #2
0
 public static String ToJson(this NotifierEntity entity)
 {
     if (entity == null)
     {
         throw new ArgumentNullException("NotifierEntity can not be null!");
     }
     return(JsonConvert.SerializeObject(entity)); //new JavaScriptSerializer().Serialize(entity);
 }
예제 #3
0
        public static NotifierEntity GetNotifierEntity <TEntity>(this DbContext dbContext, IQueryable iQueryable) where TEntity : EntityBase
        {
            var objectQuery = dbContext.GetObjectQuery <TEntity>(iQueryable);
            var notifier    = new NotifierEntity()
            {
                SqlQuery            = objectQuery.ToTraceString(),
                SqlConnectionString = objectQuery.SqlConnectionString(),
                SqlParameters       = objectQuery.SqlParameters()
            };

            return(notifier);
        }
예제 #4
0
 internal SqlDependencyRegister(NotifierEntity notificationEntity, bool isNomTable)
 {
     IsNomTable = isNomTable;
     this.notificationEntity = notificationEntity;
     RegisterForNotifications(isNomTable);
 }
예제 #5
0
 private PushSqlDependency(NotifierEntity notifierEntity, Action <String> dispatcher, bool isNomTable)
 {
     this.dispatcher       = dispatcher;
     sqlDependencyNotifier = new SqlDependencyRegister(notifierEntity, isNomTable);
     sqlDependencyNotifier.SqlNotification += OnSqlDependencyNotifierResultChanged;
 }