コード例 #1
0
ファイル: Impl.cs プロジェクト: WVitek/DotGlue
 private static Fn FuncRawIntervalQuery(QueryTemplate qt)
 {
     return((IList args) =>
     {
         return (LazyAsync)(async ctx =>
         {
             var begTime = OPs.FromExcelDate(Convert.ToDouble(args[1]));
             var endTime = OPs.FromExcelDate(Convert.ToDouble(args[2]));
             var conn = (IDbConn)await ctx.GetValue(qt.connName);
             var mq = qt.GetQuery(new object[] { args[0] }
                                  , conn.dbms.TimeToSqlText(begTime)
                                  , conn.dbms.TimeToSqlText(endTime)
                                  );
             if (mq == null)
             {
                 return ValuesDictionary.Empties;
             }
             var cmd = new SqlCommandData()
             {
                 Kind = CommandKind.Query,
                 ConvertMultiResultsToLists = qt.arrayResults
             };
             using (mq)
             {
                 cmd.SqlText = mq.QueryText;
                 var res = await conn.ExecCmd(cmd, ctx.Cancellation);
                 if (((IList)res).Count == 0)
                 {
                     res = ValuesDictionary.Empties;
                 }
                 return res;
             }
         });
     });
 }
コード例 #2
0
ファイル: Impl.cs プロジェクト: WVitek/DotGlue
 private static Fn FuncTimedSliceQuery(TimeSpan actuality, QueryTemplate qt)
 {
     return((IList args) =>
     {
         return (LazyAsync)(async ctx =>
         {
             var lst = args[0] as IList;
             if (lst != null && lst.Count == 0)
             {
                 return lst;
             }
             bool range = args.Count > 2;
             var begTime = OPs.FromExcelDate(Convert.ToDouble(range ? args[2] : args[1]));
             var minTime = range ? OPs.FromExcelDate(Convert.ToDouble(args[1])) : begTime - actuality;
             var conn = (IDbConn)await ctx.GetValue(qt.connName);
             var mq = qt.GetQuery(new object[] { args[0] }, conn.dbms.TimeToSqlText(minTime), conn.dbms.TimeToSqlText(begTime));
             if (mq == null)
             {
                 return ValuesDictionary.Empties;
             }
             var cmd = new SqlCommandData()
             {
                 Kind = CommandKind.Query,
                 ConvertMultiResultsToLists = qt.arrayResults
             };
             using (mq)
             {
                 cmd.SqlText = mq.QueryText;
                 var res = await conn.ExecCmd(cmd, ctx.Cancellation);
                 if (((IList)res).Count == 0)
                 {
                     res = ValuesDictionary.Empties;
                 }
                 return res;
             }
         });
     });
 }