Exemplo n.º 1
0
        public void ExecuteQuery(string cmdKey, SQLQueryCustodian observer, params object[] paramaters)
        {
            _provider.Subcribe(observer);

            var res = _provider.ExecuteQuery(cmdKey, paramaters);

            _provider.NotifyChange(res);

            if (observer.Updated)
            {
                _provider.Unsubcribe(observer);
            }
        }
Exemplo n.º 2
0
        public async void ExecuteQueryAsync(string cmdKey, int delayTime, SQLQueryCustodian observer, params object[] paramaters)
        {
            _provider.Subcribe(observer);

            // Issue: when first boost app, query function make the app delay for a while
            await Task.Delay(delayTime);

            var res = _provider.ExecuteQuery(cmdKey, paramaters);

            _provider.NotifyChange(res);

            // Issue: provider must un-subciribe observer coz it will callback next time
            if (observer.Updated)
            {
                _provider.Unsubcribe(observer);
            }
        }
Exemplo n.º 3
0
        public void ExecuteQuery(bool isUsingSeprateProvider, string cmdKey, SQLQueryCustodian observer, params object[] paramaters)
        {
            if (isUsingSeprateProvider)
            {
                SQLResultHandler newProvider = new SQLResultHandler(_appDBContext);

                newProvider.Subcribe(observer);

                var res = newProvider.ExecuteQuery(cmdKey, paramaters);

                newProvider.NotifyChange(res);

                if (observer.Updated)
                {
                    newProvider.Unsubcribe(observer);
                }
            }
            else
            {
                ExecuteQuery(cmdKey, observer, paramaters);
            }
        }
Exemplo n.º 4
0
 private void Register(string callerClassName, string callbackName, SQLQueryCustodian custodian)
 {
     // override and set updateable for callback method
     if (CUSTODIAN_REGISTRATIONS.ContainsKey(callerClassName))
     {
         if (CUSTODIAN_REGISTRATIONS[callerClassName].ContainsKey(callbackName))
         {
             CUSTODIAN_REGISTRATIONS[callerClassName][callbackName]._canUpdate = false;
             CUSTODIAN_REGISTRATIONS[callerClassName].Remove(callbackName);
             CUSTODIAN_REGISTRATIONS[callerClassName].Add(callbackName, custodian);
         }
         else
         {
             CUSTODIAN_REGISTRATIONS[callerClassName].Add(callbackName, custodian);
         }
     }
     else
     {
         var x = new Dictionary<string, SQLQueryCustodian>();
         x.Add(callbackName, custodian);
         CUSTODIAN_REGISTRATIONS.Add(callerClassName, x);
     }
 }
Exemplo n.º 5
0
        public async void ExecuteQueryAsync(bool isUsingSeprateProvider, string cmdKey, int delayTime, SQLQueryCustodian observer, params object[] paramaters)
        {
            if (isUsingSeprateProvider)
            {
                SQLResultHandler newProvider = new SQLResultHandler(_appDBContext);

                newProvider.Subcribe(observer);

                // Issue: when first boost app, query function make the app delay for a while
                await Task.Delay(delayTime);

                var res = newProvider.ExecuteQuery(cmdKey, paramaters);

                newProvider.NotifyChange(res);

                // Issue: provider must un-subciribe observer coz it will callback next time
                if (observer.Updated)
                {
                    newProvider.Unsubcribe(observer);
                }
            }
            else
            {
                ExecuteQueryAsync(cmdKey, delayTime, observer, paramaters);
            }
        }