// ReSharper disable UnusedMember.Global public static object Query( // ReSharper restore UnusedMember.Global [ExcelArgument("Alias of the connection, this value can be received by calling Open.")] string alias, [ExcelArgument("Name of the function to be called or string to be evaluated within q process.")] object query, [ExcelArgument("First parameter to the function call (optional).")] object p1 = null, [ExcelArgument("Second parameter to the function call (optional).")] object p2 = null, [ExcelArgument("Third parameter to the function call (optional).")] object p3 = null, [ExcelArgument("Fourth parameter to the function call (optional).")] object p4 = null, [ExcelArgument("Fifth parameter to the function call (optional).")] object p5 = null, [ExcelArgument("Sixth parameter to the function call (optional).")] object p6 = null, [ExcelArgument("Seventh parameter to the function call (optional).")] object p7 = null, [ExcelArgument("Eighth parameter to the function call (optional).")] object p8 = null) { if (ExcelDnaUtil.IsInFunctionWizard()) { return(ExcelEmpty.Value); } try { var key = alias + query; object[,] r; if (MemoryCache.Default.Contains(key)) { r = MemoryCache.Default[key] as object[, ]; } else { var result = _qXL.qQuery(alias, query, p1, p2, p3, p4, p5, p6, p7, p8); if (result == null) { return(query); //null gets returned only when function definition has been sent to q. } if (!(result is object[, ])) { return(result); } r = result as object[, ]; MemoryCache.Default.Add(key, r, DateTimeOffset.Now.AddSeconds(30)); } return(ArrayResizer.ResizeCached(r, key)); } catch (IOException io) { //this normally means that the process has been terminated on the receiving site // so clear the connection alias. return("ERR: " + io.Message); } catch (Exception e) { return("ERR: " + e.Message); } }