public override OpRes makeQuery(object param, GMUser user, QueryCondition queryCond) { ParamSearch p = (ParamSearch)param; IMongoQuery imq1 = Query.LT("date", BsonValue.Create(p.m_maxT)); IMongoQuery imq2 = Query.GTE("date", BsonValue.Create(p.m_minT)); queryCond.addImq(Query.And(imq1, imq2)); return(OpRes.opres_success); }
public override OpRes doQuery(object param, GMUser user) { m_result.Clear(); m_cond.startQuery(); OpRes res = makeQuery(param, user, m_cond); if (res != OpRes.opres_success) { return(res); } IMongoQuery imq = m_cond.getImq(); ParamSearch p = (ParamSearch)param; return(query(p, imq, user, TableName.DAILY_RECHARGE_SUM, DbName.DB_PAYMENT)); }
protected OpRes query(ParamSearch param, IMongoQuery imq, GMUser user, string tableName, int dbName) { user.totalRecord = DBMgr.getInstance().getRecordCount(tableName, imq, user.getDbServerID(), dbName); List <Dictionary <string, object> > data = DBMgr.getInstance().executeQuery(tableName, user.getDbServerID(), DbName.DB_ACCOUNT, imq, (param.m_curPage - 1) * param.m_countEachPage, param.m_countEachPage, param.m_retFields, "date", false); if (data == null || data.Count == 0) { return(OpRes.op_res_not_found_data); } int i = 0; for (i = 0; i < data.Count; i++) { ResultItem tmp = new ResultItem(); m_result.Add(tmp); tmp.m_time = Convert.ToDateTime(data[i]["date"]).ToLocalTime().ToShortDateString(); foreach (var d in data[i]) { if (d.Key == "date") { continue; } tmp.addValue(d.Key, Convert.ToInt64(d.Value)); } } return(OpRes.opres_success); }
public void startQuery() { GMUser user = (GMUser)Session["user"]; if (m_channelList.Count == 0) { return; } ParamSearch param = new ParamSearch(); param.m_minT = m_minT; param.m_maxT = m_maxT; param.m_retFields = m_dbFields; param.m_countEachPage = 0; param.m_curPage = 1; QueryMgr mgr = user.getSys <QueryMgr>(SysType.sysTypeQuery); OpRes res = mgr.doQuery(param, m_queryType, user); genTable(m_resultData, OpRes.opres_success, user, mgr); }
public void ParamSearch_FindOptimalCVTest() { //attempt to find longest range where PV=2 with CV range 0.0 - 1.0 step 0.1 ParamSearch ps = new ParamSearch(2, 0.0, 1.0, 0.1, 1, ParamSearchMode.Exact, true); Assert.IsTrue(Math.Abs(ps.Update(1) - 0.1) < 0.00001); //note: ret value is always 1 step higher than stored Assert.IsTrue(Math.Abs(ps.Update(3) - 0.2) < 0.00001); Assert.IsTrue(Math.Abs(ps.Update(2) - 0.3) < 0.00001); Assert.IsTrue(Math.Abs(ps.Update(2) - 0.4) < 0.00001); Assert.IsTrue(Math.Abs(ps.Update(4) - 0.5) < 0.00001); Assert.IsTrue(Math.Abs(ps.Update(2) - 0.6) < 0.00001); Assert.IsTrue(Math.Abs(ps.Update(2) - 0.7) < 0.00001); //<- this should be the middle range for best stability: CV=0.6 Assert.IsTrue(Math.Abs(ps.Update(2) - 0.8) < 0.00001); Assert.IsTrue(Math.Abs(ps.Update(0) - 0.9) < 0.00001); Assert.IsTrue(Math.Abs(ps.Update(5) - 1.0) < 0.00001); // at this point, ParamSearch should have built the response curve and be ready to return best CV double bestCV = ps.Update(1.0); //here actual search result should be returned Assert.IsTrue(Math.Abs(bestCV - 0.6) < 0.00001); }
public void ParamSearch_FindOptimalCV_ClosestLower_Test() { //attempt to find longest range where PV=5 with CV range 0.0 - 1.0 step 0.1 //test for exact range not found and closest higher selected ParamSearch ps = new ParamSearch(5, 0.0, 1.0, 0.1, 1, ParamSearchMode.Lower, true); Assert.IsTrue(Math.Abs(ps.Update(20) - 0.1) < 0.00001); //note: ret value is always 1 step higher than stored Assert.IsTrue(Math.Abs(ps.Update(1) - 0.2) < 0.00001); Assert.IsTrue(Math.Abs(ps.Update(1) - 0.3) < 0.00001); Assert.IsTrue(Math.Abs(ps.Update(3) - 0.4) < 0.00001); //<- this should be the closest lower than 5: CV=0.3 Assert.IsTrue(Math.Abs(ps.Update(4) - 0.5) < 0.00001); Assert.IsTrue(Math.Abs(ps.Update(6) - 0.6) < 0.00001); Assert.IsTrue(Math.Abs(ps.Update(9) - 0.7) < 0.00001); Assert.IsTrue(Math.Abs(ps.Update(20) - 0.8) < 0.00001); Assert.IsTrue(Math.Abs(ps.Update(20) - 0.9) < 0.00001); Assert.IsTrue(Math.Abs(ps.Update(6) - 1.0) < 0.00001); // at this point, ParamSearch should have built the response curve and be ready to return best CV double bestCV = ps.Update(1.0); //here actual search result should be returned Assert.IsTrue(Math.Abs(bestCV - 0.3) < 0.00001); }