Пример #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(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
        public static NotifierEntity GetNotifierEntityForNoms(this DbContext dbContext, IQueryable <V4_Batch> iQueryable, string userId)
        {
            IQueryable <V4_Batch> iQueryable1 = AddUserIdInQuery(iQueryable, userId);
            var objectQuery = GetObjectQueryForNom(dbContext, iQueryable1);
            var notifier    = new NotifierEntity()
            {
                SqlQuery            = objectQuery.ToTraceString(),
                SqlConnectionString = objectQuery.SqlConnectionString(),
                SqlParamVal         = objectQuery.SqlParameters().FirstOrDefault().Value.ToString(),
                SqlParam            = objectQuery.SqlParameters().FirstOrDefault().ParameterName,
                // SqlParameters = objectQuery.SqlParameters()
            };

            return(notifier);
        }
Пример #5
0
 internal SqlDependencyRegister(NotifierEntity notificationEntity, bool isNomTable)
 {
     IsNomTable = isNomTable;
     this.notificationEntity = notificationEntity;
     RegisterForNotifications(isNomTable);
 }
Пример #6
0
 private PushSqlDependency(NotifierEntity notifierEntity, Action <String> dispatcher, bool isNomTable)
 {
     this.dispatcher       = dispatcher;
     sqlDependencyNotifier = new SqlDependencyRegister(notifierEntity, isNomTable);
     sqlDependencyNotifier.SqlNotification += OnSqlDependencyNotifierResultChanged;
 }