public void TestDepuraJSON() { LogUtil.LogDirPath = @"..\..\TestOutput\"; LogUtil.Inicializa(); var stringAux = "\"_id\" : ObjectId(\"5a999af09e50b407b8f4c0f7\"),\"FechaInstante\" : ISODate(\"2016-12-31T00:00:00.000Z\")"; var ajustada = CellStoreUtil.DepurarIdentificadorBson(stringAux); LogUtil.Info("\r\nTextoOriginal: " + stringAux + "\r\nTextoAjustado: " + ajustada); }
public void TestLLenarHechoSpotfire() { LogUtil.LogDirPath = @"..\..\TestOutput\"; LogUtil.Inicializa(); JsonSerializerSettings settings = new JsonSerializerSettings(); settings.NullValueHandling = NullValueHandling.Ignore; var cellStoreMongo = (AbaxXBRLCellStoreMongo)applicationContext.GetObject("AbaxXBRLCellStoreMongo"); var spotfireCollection = cellStoreMongo.ObtenerCollection("HechoSpotfire"); var envioCollection = cellStoreMongo.ObtenNombreCollecion(ENVIO); var hechoCollection = cellStoreMongo.ObtenNombreCollecion(HECHO); var queryEnvio = Query.EQ("EsVersionActual", true); var enviosBSON = cellStoreMongo.Consulta(envioCollection, queryEnvio); var enviosJSON = CellStoreUtil.DepurarIdentificadorBson(enviosBSON.ToJson()); var envios = JsonConvert.DeserializeObject <List <Envio> >(enviosJSON, settings); var queryNoChunks = Query.EQ("EsValorChunks", false); var types = new List <BsonValue>(); types.Add("http://www.xbrl.org/2003/instance:base64BinaryItemType"); types.Add("http://www.xbrl.org/dtr/type/non-numeric:textBlockItemType"); var queryTiposNoIncluidos = Query.NotIn("Concepto.TipoDato", types); foreach (var envio in envios) { try { var queryIdEnvio = Query.EQ("IdEnvio", envio.IdEnvio); //var countHechosSpotfire = cellStoreMongo.Count("HechoSpotfire", queryIdEnvio); //if (countHechosSpotfire > 0) //{ // continue; //} var queryHecho = Query.And( queryIdEnvio, queryNoChunks, queryTiposNoIncluidos ); var hechosBSON = cellStoreMongo.Consulta(hechoCollection, queryHecho); var hechosJSON = CellStoreUtil.DepurarIdentificadorBson(hechosBSON.ToJson()); var hechos = JsonConvert.DeserializeObject <List <Hecho> >(hechosJSON, settings); var taxonomia = ObtenerTaxonomia(envio.Taxonomia); IList <String> roles = null; IList <String> dimensiones = null; IDictionary <String, IDictionary <String, int> > concepotsRol = null; ObtenElementosTaxonomia(cellStoreMongo, taxonomia, out roles, out dimensiones, out concepotsRol); List <BsonDocument> hechosSpotfire = new List <BsonDocument>(); foreach (var hecho in hechos) { var queryIdHecho = Query.EQ("IdHecho", hecho.IdHecho); var countHechosSpotfire = cellStoreMongo.Count("HechoSpotfire", queryIdHecho); if (countHechosSpotfire > 0) { continue; } HechoSpotfire hechoSpotfire = new HechoSpotfire(envio, hecho, roles, concepotsRol, dimensiones); hechosSpotfire.Add(hechoSpotfire.ToBson()); } if (hechosSpotfire.Count > 0) { spotfireCollection.InsertBatch(hechosSpotfire); } } catch (Exception ex) { LogUtil.Error(ex); } } }