/// <summary> /// Gets the join between many collections /// </summary> /// <returns> An array with the resulting search </returns> public string GetDemandTable(string varMovement, string varStatus) { //Query needed to get the result var query = Query.And(Query.EQ("movement", varMovement), Query.EQ("status", varStatus)); if (varMovement == "null") { query = Query.And(Query.EQ("status", varStatus)); } if (varStatus == "null") { query = Query.And(Query.EQ("movement", varMovement)); } JoinCollections Join = new JoinCollections(); Join.Select("Demand") .Join("MovementProfiles", "movement", "_id", "name=>movement , name=>typeMovement") .Join("Locations", "location", "_id", "name => location") .Join("ReferenceObjects", "object", "_id", "name=>object") .Join("Users", "Creator", "_id", "name=>Creator"); if (varMovement == "null" && varStatus == "null") { return(Join.Find()); } return(Join.Find(query)); }
public string GetHardware(string idHardware = null) { JoinCollections Join = new JoinCollections(); Join.Select("Hardware") .Join("HardwareReference", "hardware_reference", "_id", "name"); if (idHardware != null) { var query = Query.EQ("_id", new ObjectId(idHardware)); return(Join.Find(query)); } return(Join.Find()); }
public string GetDemandByObj(List <string> idsact, int type = 0) { BsonArray bsonarray = new BsonArray(); BsonArray bsonstatus = new BsonArray(); bsonstatus.Add(6); bsonstatus.Add(7); foreach (string x in idsact) { try { bsonarray.Add(x); } catch { } } //Get only active objects IMongoQuery query = Query.And(Query.In("status", bsonstatus), Query.In("objects.id", bsonarray)); if (type == 1) { query = Query.And(Query.NotIn("status", bsonstatus), Query.In("objects.id", bsonarray)); } JoinCollections Join = new JoinCollections(); Join.Select("Demand") .Join("MovementProfiles", "movement", "_id", "name=>namemov"); return(Join.Find(query)); }
public String getUsersByLocations(List <string> locations = null) { try { //Query needed to get the result BsonArray bsonarray = new BsonArray(); foreach (string item in locations) { bsonarray.Add(item); } var query = Query.And(Query.In("userLocations.id", bsonarray)); JoinCollections Join = new JoinCollections(); Join.Select("Users") .Join("Profiles", "profileId", "_id", "name=>profilename"); return(Join.Find(query)); } catch { return(null); } }
public string GetObjects(string varLocation, string varReference = null) { IMongoQuery query; List <IMongoQuery> listqueries = new List <IMongoQuery>(); //Query needed to get the result if (varLocation != null || varLocation == "") { listqueries.Add(Query.EQ("location", varLocation)); } if (varReference != null || varReference == "") { listqueries.Add(Query.EQ("objectReference", varReference)); } //Get only active objects // listqueries.Add(Query.EQ("system_status", true)); query = Query.And(listqueries); JoinCollections Join = new JoinCollections(); Join.Select("ObjectReal") .Join("ReferenceObjects", "objectReference", "_id", "name=>object, ext=>ext, profileFields, parentCategory") .Join("Users", "Creator", "_id", "name=>nameCreator, lastname=>lastnameCreator") .Join("Locations", "location", "_id", "name=>namelocation"); return(Join.Find(query)); }
public string GetAutorizations3(List <String> subusers, List <String> movs) { BsonArray bsonarrayids = new BsonArray(); BsonArray bsonarraymovs = new BsonArray(); foreach (string item in subusers) { bsonarrayids.Add(item); } foreach (string item in movs) { bsonarraymovs.Add(item); } List <IMongoQuery> listqueries = new List <IMongoQuery>(); IMongoQuery query = null; listqueries.Add(Query.In("Creator", bsonarrayids)); // listqueries.Add(Query.EQ("status", 6)); listqueries.Add(Query.In("movement", bsonarraymovs)); query = Query.And(listqueries); JoinCollections Join = new JoinCollections(); Join.Select("Demand") .Join("MovementProfiles", "movement", "_id", "temporal,name=>namemovement, typeMovement=>typeStatus") .Join("Users", "Creator", "_id", "name=>CreatorName, lastname => CreatorLastName"); return(Join.Find(query)); }
public String getMMO(List <string> list, int type = 0) { BsonArray bson = new BsonArray(); foreach (string element in list) { try { bson.Add(new BsonObjectId(element)); } catch { } } IMongoQuery query = Query.And(Query.In("_id", bson)); JoinCollections Join = new JoinCollections(); if (type == 0) { Join.Select("ReferenceObjects") .Join("Users", "Creator", "_id", "name=>username"); } else { Join.Select("ObjectReal") .Join("ReferenceObjects", "objectReference", "_id", "marca,modelo,object_id,profileFields, parentCategory,assetType") .Join("Users", "Creator", "_id", "name=>Creator") .Join("Locations", "location", "_id", "name=>namelocation"); } return(Join.Find(query)); }
public string ValidIds(List <string> Ids) { //Query needed to get the result BsonArray idsarray = new BsonArray(); foreach (string id in Ids) { try { if (id != "") { idsarray.Add(id); } } catch { } } var query = Query.And(Query.In("id_registro", idsarray)); JoinCollections Join = new JoinCollections(); Join.Select("ObjectReal") .Join("ReferenceObjects", "objectReference", "_id", "name=>object, ext=>ext") .Join("Locations", "location", "_id", "name=>location_name,parent=>conjunto,profileId=>profileId") .Join("Users", "Creator", "_id", "name=>Creator"); return(Join.Find(query)); }
public string GetObjectsRealTable(List <string> varLocations) { //Query needed to get the result string[] arraylocations = varLocations.ToArray(); BsonArray bsonarray = new BsonArray(); for (int i = 0; i < arraylocations.Length; i++) { bsonarray.Add(arraylocations[i]); } var query = Query.And(Query.In("location", bsonarray)); if (varLocations.Count() == 0) { query = Query.And(Query.EQ("system_status", "true")); } JoinCollections Join = new JoinCollections(); Join.Select("ObjectReal") .Join("ReferenceObjects", "objectReference", "_id", "profileFields=>customfields") .Join("Locations", "location", "_id", "name => location") .Join("ReferenceObjects", "objectReference", "_id", "name=>object"); return(Join.Find(query)); }
public string GetbyCustom(string key, List <string> datas, string Collection) { //Query needed to get the result BsonArray datasarray = new BsonArray(); foreach (string data in datas) { try { if (key == "_id") { datasarray.Add(new BsonObjectId(data)); } else { datasarray.Add(data); } } catch { } } var query = Query.And(Query.In(key, datasarray)); JoinCollections Join = new JoinCollections(); Join.Select(Collection) .Join("Users", "Creator", "_id", "name=>user_name"); return(Join.Find(query)); }
public string GetObjectsRefTable(List <string> varLocations) { //Query needed to get the result string[] arraylocations = varLocations.ToArray(); BsonArray bsonarray = new BsonArray(); for (int i = 0; i < arraylocations.Length; i++) { bsonarray.Add(arraylocations[i]); } var query = Query.And(Query.In("location", bsonarray), Query.NE("system_status", false)); if (varLocations.Count() == 0) { query = Query.And(Query.NE("system_status", false)); } JoinCollections Join = new JoinCollections(); Join.Select("ObjectReal") .Join("Locations", "location", "_id", "name => location_name,number=>number, parent=>conjunto,profileId=>profileId") .Join("ReferenceObjects", "objectReference", "_id", "name => objectReference_name,profileFields => extra"); return(Join.Find(query)); }
public string GetDemandsUpdateforContabilidad(string userid = null) { userid = (userid != null && userid != "") ? userid : ""; BsonArray bsonstatus = new BsonArray(); bsonstatus.Add(9); IMongoQuery query; if (userid != null && userid != "") { query = Query.And(Query.In("status", bsonstatus), Query.EQ("contador.id_user", userid)); } else { query = Query.And(Query.In("status", bsonstatus)); } JoinCollections Join = new JoinCollections(); Join.Select("Demand") .Join("MovementProfiles", "movement", "_id", "name=>namemove, typeMovement=>type,temporal=>temporal"); return(Join.Find(query)); }
public string Getparents(List <string> varLocations) { //Query needed to get the result string[] arraylocations = varLocations.ToArray(); BsonArray bsonarray = new BsonArray(); for (int i = 0; i < arraylocations.Length; i++) { bsonarray.Add(new BsonObjectId(arraylocations[i])); } var query = Query.And(Query.In("_id", bsonarray)); if (varLocations.Count() == 0) { query = Query.And(Query.EQ("system_status", "true")); } JoinCollections Join = new JoinCollections(); Join.Select("Locations") .Join("Locations", "parent", "_id", "name=>conjuntoname,number=>conjuntonumber"); return(Join.Find(query)); }
public String getUsersByUsers(List <string> users = null) { try { //Query needed to get the result BsonArray bsonarray = new BsonArray(); foreach (string item in users) { bsonarray.Add(item); } var query = Query.And(Query.In("Creator", bsonarray)); JoinCollections Join = new JoinCollections(); Join.Select("Demand") .Join("Users", "Creator", "_id", "name=>username"); return(Join.Find(query)); } catch { return(null); } }
/// <summary> /// Gets the profile table with each creator /// </summary> /// <returns></returns> public String getJoinRows() { JoinCollections join = new JoinCollections(); join.Select("Profiles") .Join("Users", "Creator", "_id", "name => Creator"); return(join.Find()); }
public string GetWitnesses() { JoinCollections Join = new JoinCollections(); Join.Select("witnesses") .Join("Users", "user", "_id", "name=>CreatorName, lastname => CreatorLastName"); return(Join.Find()); }
public string ExistLocation(String fisrt, string valueF, string secound, string valueS) { var query = Query.And(Query.EQ(fisrt, valueF), Query.EQ(secound, valueS)); JoinCollections Join = new JoinCollections(); Join.Select("Locations"); return(Join.Find(query)); }
public String GetRowsReportHistoryDemand(Dictionary <string, string> fields, List <string> movement = null, List <string> users = null, Int64 start = 0, Int64 end = 0) { var orderfield = "folio"; try { List <string> cols = new List <string>(); foreach (var x in fields) { cols.Add(x.Key); } cols.Add("CreatedTimeStamp"); string[] arrayfields = cols.ToArray(); string[] arraymov = movement.ToArray(); string[] arrayusers = users.ToArray(); BsonArray bsonarraymov = new BsonArray(); BsonArray bsonarrayobjs = new BsonArray(); BsonArray bsonarrayloc = new BsonArray(); BsonArray bsonarrayusers = new BsonArray(); BsonArray bsonarraystatus = new BsonArray(); for (int i = 0; i < arraymov.Length; i++) { bsonarraymov.Add(arraymov[i]); } for (int i = 0; i < arrayusers.Length; i++) { bsonarrayusers.Add(arrayusers[i]); } JoinCollections Join = new JoinCollections(); Join.Select("Demand") .Join("Locations", "objects.location", "_id", "name=>nameLocation") .Join("Users", "Creator", "_id", "name=>nameUser") .Join("MovementProfiles", "movement", "_id", "name=>nameMovement"); IMongoQuery query = null; if (movement != null && movement.Count > 0) { query = Query.And(Query.In("movement", bsonarraymov), Query.In("Creator", bsonarrayusers), Query.GTE("CreatedTimeStamp", start), Query.LTE("CreatedTimeStamp", end)); } else { query = Query.And(Query.GTE("CreatedTimeStamp", start), Query.LTE("CreatedTimeStamp", end)); } return(Join.Find(query)); } catch (Exception e) { // System.Windows.Forms.MessageBox.Show(e.ToString()); return(null); } }
public string GetFullHardware() { JoinCollections Join = new JoinCollections(); Join.Select("Hardware") .Join("HardwareReference", "hardware_reference", "_id", "name => hardwareName, ext => image"); return(Join.Find()); }
public string GetObjectsReferences() { JoinCollections Join = new JoinCollections(); Join.Select("ReferenceObjects") .Join("ObjectReal", "_id", "objectReference", "object=>object"); return(Join.Find()); }
public string GetLocations(String profileid, String parent) { IMongoQuery query = null; query = Query.And(Query.EQ("profileId", profileid), Query.EQ("parent", parent)); JoinCollections Join = new JoinCollections(); Join.Select("Locations"); return(Join.Find(query)); }
public string GetLocationsTable(string vartypeuser, string vartype, string varRegion, string varConjunto, string varSubLocation, List <string> locations = null) { List <IMongoQuery> listqueries = new List <IMongoQuery>(); IMongoQuery query = null; BsonArray bsonarrayids = new BsonArray(); if (locations != null) { foreach (string item in locations) { bsonarrayids.Add(new ObjectId(item)); } } //Query needed to get the result if (vartype == "") { listqueries.Add(Query.NE("profileId", varRegion)); listqueries.Add(Query.NE("profileId", varConjunto)); listqueries.Add(Query.NE("profileId", varSubLocation)); if (locations != null) { listqueries.Add(Query.In("_id", bsonarrayids)); } } else if (vartype == "Region") { listqueries.Add(Query.EQ("profileId", varRegion)); if (locations != null) { listqueries.Add(Query.In("_id", bsonarrayids)); } } else if (vartype == "Conjunto") { listqueries.Add(Query.EQ("profileId", varConjunto)); if (locations != null) { listqueries.Add(Query.In("_id", bsonarrayids)); } } query = Query.And(listqueries); JoinCollections Join = new JoinCollections(); Join.Select("Locations") .Join("Users", "responsable", "_id", "name=>nameResponsable"); return(Join.Find(query)); }
public string GetLocatedHardware(string id_location) { var query = Query.EQ("location_id", id_location); JoinCollections Join = new JoinCollections(); Join.Select("Hardware") .Join("HardwareReference", "hardware_reference", "_id", "name => hardwareName, ext => image"); return(Join.Find(query)); }
/// <summary> /// This function generates a query, and returns all coincidences where key = value /// </summary> /// <param name="key"> /// The collection's key value in the db /// </param> /// <param name="value"> /// The collection's value in the db /// </param> /// <author> /// Luis Gonzalo Quijada Romero /// </author> /// <returns></returns> public String get(String key, String value) { JoinCollections Join = new JoinCollections(); var query = Query.And(Query.EQ(key, value)); //creating the query Join.Select("ReferenceObjects"); Join.Join("Categories", "parentCategory", "_id", "name => categoryName"); Join.Join("Users", "Creator", "_id", "name => Creator"); var result = Join.Find(query); return(result); }
public string GetObjects(string varLocation) { //Query needed to get the result var query = Query.And(Query.EQ("location", varLocation)); JoinCollections Join = new JoinCollections(); Join.Select("ObjectReal") .Join("ReferenceObjects", "objectReference", "_id", "name=>object, ext=>ext") .Join("Users", "Creator", "_id", "name=>Creator"); return(Join.Find(query)); }
public string GetProfileTemporalDemand() { IMongoQuery query; query = Query.And(Query.EQ("temporal", true)); JoinCollections Join = new JoinCollections(); Join.Select("MovementProfiles"); // .Join("Demand", "_id", "movement", "_id=>demandid "); return(Join.Find(query)); return(null); }
public string GetCategories() { //Query needed to get the result var query = Query.NE("system_status", false); JoinCollections Join = new JoinCollections(); Join.Select("Categories") .Join("Users", "Creator", "_id", "name=>Creator"); return(Join.Find(query)); }
public string getByProfile(string profile) { //Query needed to get the result var query = Query.Matches("name", BsonRegularExpression.Create(new Regex(profile))); JoinCollections Join = new JoinCollections(); Join.Select("Profiles") .Join("Users", "Creator", "_id", "name=>Creator"); return(Join.Find(query)); }
public String getobjectbyepcjoin(string id) { //Query needed to get the result var query = Query.And(Query.EQ("EPC", id)); JoinCollections Join = new JoinCollections(); Join.Select("ObjectReal") .Join("Locations", "location", "_id", "name => location_name,number=>number, parent=>conjunto,profileId=>profileId") .Join("ReferenceObjects", "objectReference", "_id", "name=>objectReferencename,object_id=>id_articulo"); return(Join.Find(query)); }
public String getUsersByProfile(List <string> profileid) { BsonArray idprofiles = new BsonArray(); foreach (string idp in profileid) { idprofiles.Add(idp); } IMongoQuery query = Query.And(Query.In("profileId", idprofiles), Query.NE("system_status", false)); JoinCollections Join = new JoinCollections(); Join.Select("Users") .Join("Profiles", "profileId", "_id", "name=>nameprofile"); return(Join.Find(query)); }