Exemplo n.º 1
0
 public void ExistAsync(SqlCondition condition, BasicAction <bool> onExist, bool distinct)
 {
     SqlManager.PoolAsyncOperation(() => {
         var count = _database.Count <TableKey>(condition, distinct);
         onExist?.Invoke(count > 0);
     });
 }
Exemplo n.º 2
0
 public void CountAsync(string columnName, SqlCondition condition, BasicAction <long> onCounted, bool distinct)
 {
     SqlManager.PoolAsyncOperation(() => {
         var count = _database.Count <TableKey>(columnName, condition, distinct);
         onCounted?.Invoke(count);
     });
 }
Exemplo n.º 3
0
 public void AverageAsync(string columnName, SqlCondition condition, BasicAction <long> onAverage)
 {
     SqlManager.PoolAsyncOperation(() => {
         var average = _database.Average <TableKey>(columnName, condition);
         onAverage?.Invoke(average);
     });
 }
Exemplo n.º 4
0
 public void MaxAsync(string columnName, SqlCondition condition, BasicAction <TableKey> onMax)
 {
     SqlManager.PoolAsyncOperation(() => {
         var max = _database.Max <TableKey>(columnName, condition);
         onMax?.Invoke(max);
     });
 }
Exemplo n.º 5
0
 public void MinAsync(string columnName, SqlCondition condition, BasicAction <TableKey> onMin)
 {
     SqlManager.PoolAsyncOperation(() => {
         var min = _database.Min <TableKey>(columnName, condition);
         onMin?.Invoke(min);
     });
 }
Exemplo n.º 6
0
 public void SelectAllAsync(SqlCondition condition, BasicAction <TableKey[]> onSelected, bool distinct, params string[] columnsToSelect)
 {
     SqlManager.PoolAsyncOperation(() => {
         var tables = _database.SelectAll <TableKey>(condition, distinct, columnsToSelect);
         onSelected?.Invoke(tables);
     });
 }
Exemplo n.º 7
0
 public void SumAsync(string columnName, SqlCondition condition, BasicAction <decimal> onSum)
 {
     SqlManager.PoolAsyncOperation(() => {
         var sum = _database.Sum <TableKey>(columnName, condition);
         onSum?.Invoke(sum);
     });
 }
Exemplo n.º 8
0
 public void DeleteAsync(SqlCondition condition, BasicAction onDeleted)
 {
     SqlManager.PoolAsyncOperation(() => {
         var deleted = _database.Delete <TableKey>(condition);
         if (deleted)
         {
             onDeleted?.Invoke();
         }
     });
 }
Exemplo n.º 9
0
 public void UpdateAllAsync(TableKey reference, BasicAction onUpdated, params string[] columnsToUpdate)
 {
     SqlManager.PoolAsyncOperation(() => {
         var updated = _database.UpdateAll(reference, columnsToUpdate);
         if (updated)
         {
             onUpdated?.Invoke();
         }
     });
 }
Exemplo n.º 10
0
 public void DeleteAllAsync(BasicAction onDeleted)
 {
     SqlManager.PoolAsyncOperation(() => {
         var deleted = _database.DeleteAll <TableKey>();
         if (deleted)
         {
             onDeleted?.Invoke();
         }
     });
 }
Exemplo n.º 11
0
        private static string UseBuilder(string baseStr, SqlCondition condition, BasicAction <StringBuilder> onBuilder)
        {
            var sb = new StringBuilder(baseStr);

            onBuilder?.Invoke(sb);

            if (condition != null)
            {
                sb.Append($" { condition.GetQuery() }");
            }

            return(sb.ToString());
        }
Exemplo n.º 12
0
 /// <summary>
 /// Execute a HTTP POST request asynchronously.
 /// </summary>
 /// <param name="uriRequest"></param>
 /// <param name="data"></param>
 /// <param name="callback"></param>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public static void PostRequestDataAsync(Uri uriRequest, string data, BasicAction <byte[]> callback, RequestParameters parameters)
 {
     Task.Factory.StartNew(() => callback?.Invoke(PostRequestData(uriRequest, data, parameters)));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Execute a HTTP GET request asynchronously.
 /// </summary>
 /// <param name="uriRequest"></param>
 /// <param name="callback"></param>
 /// <returns></returns>
 public static void GetRequestAsync(Uri uriRequest, BasicAction <string> callback)
 {
     Task.Factory.StartNew(() => callback?.Invoke(GetRequest(uriRequest, null)));
 }
Exemplo n.º 14
0
 /// <summary>
 /// Execute a HTTP GET request asynchronously.
 /// </summary>
 /// <param name="uriRequest"></param>
 /// <param name="callback"></param>
 /// <param name="parameters"></param>
 /// <returns></returns>
 public static void GetRequestAsync(Uri uriRequest, BasicAction <string> callback, RequestParameters parameters)
 {
     Task.Factory.StartNew(() => callback?.Invoke(GetRequest(uriRequest, parameters)));
 }
Exemplo n.º 15
0
 private void Execute()
 {
     _action?.Invoke();
     RuntimeManager.RtUpdate -= Execute;
 }
Exemplo n.º 16
0
        private static double InvokeAsBatch(BasicAction action)
        {
            var stopwatch = new Stopwatch();
            long invocationCount = 0;

            stopwatch.Start();

            while (stopwatch.Elapsed < MinimumBatchTime)
            {
                action.Invoke();
                ++invocationCount;
            }

            stopwatch.Stop();

            return stopwatch.Elapsed.TotalMilliseconds / invocationCount;
        }
Exemplo n.º 17
0
 /// <summary>
 /// Execute a HTTP GET request asynchronously.
 /// </summary>
 /// <param name="uriRequest"></param>
 /// <param name="callback"></param>
 /// <returns></returns>
 public static void GetRequestDataAsync(Uri uriRequest, BasicAction <byte[]> callback)
 {
     Task.Factory.StartNew(() => callback?.Invoke(GetRequestData(uriRequest, null)));
 }