void IPropertyPredicateOperator.PutRegexMatchPredicate(QueryDocument doc, string expression, string options) { var name = this.FieldName; if (doc.Contains(name)) { throw new InvalidOperationException( String.Format( "this document should not contain {0} field.", name)); } doc.Add(name, new BsonRegularExpression(expression, options)); }
void IPropertyPredicateOperator.PutEqualPredicate(QueryDocument doc, object value) { var name = this.FieldName; if (doc.Contains(name)) { throw new InvalidOperationException( String.Format( "this document should not contain {0} field.", name)); } doc.Add(name, this.TypeProcessor.ToBsonValue(value)); }
// 开始统计 public override OpRes doStat(object param, GMUser user) { ParamQueryRecharge p = (ParamQueryRecharge)param; QueryMgr mgr = user.getSys <QueryMgr>(SysType.sysTypeQuery); m_cond.startQuery(); OpRes res = mgr.makeQuery(param, QueryType.queryTypeRecharge, user, m_cond); if (res != OpRes.opres_success) { return(res); } IMongoQuery imq = m_cond.getImq(); QueryDocument qd = (QueryDocument)imq; if (!qd.Contains("PayTime")) { return(OpRes.op_res_time_format_error); } m_result.Clear(); QueryRecharge rq = mgr.getQuery <QueryRecharge>(QueryType.queryTypeRecharge); int serverId = DBMgr.getInstance().getSpecialServerId(DbName.DB_PAYMENT); MapReduceResult map_result = DBMgr.getInstance().executeMapReduce(rq.getPlatInfo().m_tableName, serverId, DbName.DB_PAYMENT, imq, MapReduceTable.getMap("sameOrderId"), MapReduceTable.getReduce("sameOrderId")); int count = 0; if (map_result != null) { IEnumerable <BsonDocument> bson = map_result.GetResults(); foreach (BsonDocument d in bson) { BsonValue resValue = d["value"]; count = resValue["total"].ToInt32(); if (count > 1) { ResultSameOrderIdItem tmp = new ResultSameOrderIdItem(); m_result.Add(tmp); tmp.m_count = count; tmp.m_orderId = Convert.ToString(d["_id"]); } } } return(OpRes.opres_success); }
void IPropertyPredicateOperator.PutInPredicate(QueryDocument doc, IEnumerable <object> collection) { var name = this.FieldName; if (doc.Contains(name)) { throw new InvalidOperationException( String.Format( "this document should not contain {0} field.", name)); } var array = new BsonArray(); foreach (var item in collection) { var value = this.TypeProcessor.ToBsonValue(item); array.Add(value); } doc.Add(name, new BsonDocument().Add("$in", array)); }
private void PutInnerPredicate(QueryDocument doc, string op, object value) { var name = this.FieldName; BsonDocument innerDoc; if (doc.Contains(name)) { innerDoc = doc[name] as BsonDocument; if (innerDoc == null) { throw new InvalidOperationException("Should have nothing or BsonDocument object"); } } else { innerDoc = new BsonDocument(); doc.Add(name, innerDoc); } innerDoc.Add(op, this.TypeProcessor.ToBsonValue(value)); }