예제 #1
0
        /// <summary>
        /// Creates the report id from report keys
        /// </summary>
        /// <param name="reportKeys">Keys of the report.</param>
        /// <returns>Hash of the report.</returns>
        public static String GetHash(IDictionary <String, String> reportKeys)
        {
            var factAux = new FactJBRL();
            var json    = factAux.ParseJson(reportKeys);
            var hash    = factAux.GeneraHash(json);

            return(hash);
        }
예제 #2
0
        public static async Task <ResponseDto> ProcessFileAsync(Uri downloadUri, string cnbvId, DateTime receptionDate, SemaphoreSlim concurrencySemaphore)
        {
            try
            {
                using (WebClient webClient = new WebClient())
                {
                    //var azureFunctionURI = new Uri("http://localhost:7071/api/XBRLUploadFromJsonURI");
                    var azureFunctionURI = new Uri("https://jbrl-bot.azurewebsites.net/api/XBRLUploadFromJsonURI?code=gDAMhiFMTI1AW374tDqrE6nel3ddNX3FWOSDeFSF2ZJsRsdsbrJenQ==");
                    //var azureFunctionURI = new Uri("https://jbrl-bot.azurewebsites.net/api/XBRLUpdateTextFactsFromJonsURI?code=7i6yO9Cl4v/TcvwobhAiENAsR/jnSjTvFHk9ley8khItX1Kk7iTVTA==");
                    ServicePointManager.SecurityProtocol             = System.Net.SecurityProtocolType.Tls12;
                    webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
                    var respectionDateSting = receptionDate.ToString("yyyy-MM-ddTHH:mm:ssZ");
                    var jsonBody            =
                        "{" +
                        "\"uri\":" + FactJBRL.ParseJson(downloadUri.AbsoluteUri) + ", " +
                        "\"downloadId\": \"" + cnbvId + "\", " +
                        "\"receptionDate\": \"" + respectionDateSting + "\"" +
                        "}";
                    LogUtil.Info(jsonBody);
                    var jsonResponse = await webClient.UploadStringTaskAsync(azureFunctionURI, jsonBody);

                    var response = JsonConvert.DeserializeObject <ResponseDto>(jsonResponse);
                    if (response.exception == null)
                    {
                        LogUtil.Info(jsonResponse);
                    }
                    else
                    {
                        LogUtil.Error(response);
                    }

                    return(response);
                }
            }
            catch (Exception ex)
            {
                LogUtil.Error(ex);
            }
            finally
            {
                concurrencySemaphore.Release();
            }
            return(new ResponseDto());
        }
예제 #3
0
        /// <summary>
        /// The report main keys.
        /// </summary>
        /// <param name="document">Document to evaluate.</param>
        /// <returns></returns>
        public static void SetReportParams(DocumentoInstanciaXbrlDto document, IDictionary <String, String> extraParams)
        {
            if (!extraParams.ContainsKey(ConstantsJBRL.REPORT_TAXONOMY_ATT))
            {
                extraParams[ConstantsJBRL.REPORT_TAXONOMY_ATT]      = document.Taxonomia.EspacioNombresPrincipal;
                extraParams[ConstantsJBRL.REPORT_TAXONOMY_NAME_ATT] = GetTaxonomyName(document.Taxonomia.EspacioNombresPrincipal);
            }
            var         hechoPrincipal = JBRLUtils.GetMainFact(document);
            var         auxiliar       = new FactJBRL();
            ContextoDto context;

            if (!extraParams.ContainsKey(ConstantsJBRL.REPORT_ENTITY_ATT) ||
                !extraParams.ContainsKey(ConstantsJBRL.REPORT_DATE_ATT))
            {
                if (document.ContextosPorId.TryGetValue(hechoPrincipal.IdContexto, out context))
                {
                    var reportedDateOfReport = context.Periodo.Tipo.Equals(PeriodoDto.Duracion) ? context.Periodo.FechaFin : context.Periodo.FechaInstante;
                    if (!extraParams.ContainsKey(ConstantsJBRL.REPORT_ENTITY_ATT))
                    {
                        extraParams[ConstantsJBRL.REPORT_ENTITY_ATT] = context.Entidad.Id;
                    }
                    if (!extraParams.ContainsKey(ConstantsJBRL.REPORT_DATE_ATT))
                    {
                        extraParams[ConstantsJBRL.REPORT_DATE_ATT] = auxiliar.ParseString(reportedDateOfReport);
                        extraParams[ConstantsJBRL.REPORT_YEAR_ATT] = reportedDateOfReport.Year.ToString();
                    }
                }
            }
            var quarter     = JBRLUtils.GetFirstFact(ConstantsJBRL.QUARTER_CONCEPT, document);
            var trustNumber = JBRLUtils.GetFirstFact(ConstantsJBRL.TRUST_NUMBRE_CONCEPT, document);

            if (quarter != null)
            {
                extraParams[ConstantsJBRL.REPORT_QUARTER_ATT] = quarter.Valor;
            }
            if (trustNumber != null)
            {
                extraParams[ConstantsJBRL.REPORT_TRUST_NUMBER_ATT] = trustNumber.Valor;
            }
        }
예제 #4
0
        public static async Task <ResponseDto> ProcessFileAsync(string reportRecordId, SemaphoreSlim concurrencySemaphore)
        {
            try
            {
                using (WebClient webClient = new WebClient())
                {
                    var azureFunctionURI = new Uri("https://jbrl-bot.azurewebsites.net/api/XBRLRestoreReport?code=/YZp9LQ9E6wlMAVzVD5CiRHNG1DKD/hY7yCtENzuraYlXLfCfVmENQ==");
                    ServicePointManager.SecurityProtocol             = System.Net.SecurityProtocolType.Tls12;
                    webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
                    var jsonBody =
                        "{" +
                        "\"reportRecordId\":" + FactJBRL.ParseJson(reportRecordId) +
                        "}";
                    LogUtil.Info(jsonBody);
                    var jsonResponse = await webClient.UploadStringTaskAsync(azureFunctionURI, jsonBody);

                    var response = JsonConvert.DeserializeObject <ResponseDto>(jsonResponse);
                    if (response.exception == null)
                    {
                        LogUtil.Info(jsonResponse);
                    }
                    else
                    {
                        LogUtil.Error(response);
                    }

                    return(response);
                }
            }
            catch (Exception ex)
            {
                LogUtil.Error(ex);
            }
            finally
            {
                concurrencySemaphore.Release();
            }
            return(new ResponseDto());
        }
예제 #5
0
        /// <summary>
        /// Insert the facts of a document into the mongo database.
        /// </summary>
        /// <param name="documentoInstanciXbrlDto">Documento to evaluate.</param>
        /// <param name="reportParams">Extra params to include.</param>
        /// <param name="factsList">Extra facts to include.</param>
        /// <param name="taskList">List of task to wait befor ends.</param>
        /// <param name="registrationDate">Registration date of the document.</param>
        /// <param name="abaxXBRLCellStoreMongo">Data access object of mongo.</param>
        public static void InsertFacts(
            DocumentoInstanciaXbrlDto documentoInstanciXbrlDto,
            IDictionary <String, String> reportParams,
            IList <FactJBRL> factsList,
            IList <Task> taskList,
            DateTime registrationDate,
            AbaxXBRLCellStoreMongo abaxXBRLCellStoreMongo)
        {
            var mongoDB = abaxXBRLCellStoreMongo.GetMongoDB();

            JBRLUtils.SetReportParams(documentoInstanciXbrlDto, reportParams);
            var reportId       = JBRLUtils.CreateReportId(reportParams);
            var reportRecordId = JBRLUtils.CreateReportRecordId(reportId, registrationDate);

            if (JBRLUtils.ExistsReportRecord(reportRecordId, abaxXBRLCellStoreMongo))
            {
                return;
            }
            var replacementId =
                JBRLUtils.SarchReplacementId(reportId, reportRecordId, registrationDate, abaxXBRLCellStoreMongo);

            if (replacementId == null)
            {
                var taskVersion =
                    JBRLUtils.UpdateReportsReplacementVersionAsync(reportId, reportRecordId, abaxXBRLCellStoreMongo);
                taskList.Add(taskVersion);
            }
            foreach (var hechoId in documentoInstanciXbrlDto.HechosPorId.Keys)
            {
                var hecho = documentoInstanciXbrlDto.HechosPorId[hechoId];
                if (hecho.TipoDatoXbrl.Contains("64"))
                {
                    continue;
                }
                var hechoJbrl = FactJBRL.Parse(
                    hecho, documentoInstanciXbrlDto, reportId, reportRecordId,
                    registrationDate, reportParams, replacementId);
                if (hechoJbrl != null)
                {
                    factsList.Add(hechoJbrl);
                }
                else
                {
                    LogUtil.Error(new Dictionary <string, object>()
                    {
                        { "Error", "No fué posible convertir el hecho a JBRL" },
                        { "HechoId", hecho.Id ?? "null" },
                        { "Concepto", hecho.IdConcepto ?? "null" },
                        { "Hecho", hecho }
                    });
                }
            }
            var modeloBaseList = new List <IModeloBase>();

            modeloBaseList.AddRange(factsList);
            abaxXBRLCellStoreMongo.InserttChunksCollection(mongoDB, JBRLUtils.COLLECTION_NAME, modeloBaseList);
            var taskFactsEvaluation = JBRLUtils.
                                      UpdatePreviousFactsReplacementVersionAsync(factsList, abaxXBRLCellStoreMongo);

            taskList.Add(taskFactsEvaluation);
        }
예제 #6
0
        public void TestProcesarDistribucionDocumentosXBRL()
        {
            LogUtil.LogDirPath = @"..\..\TestOutput\";
            LogUtil.Inicializa();

            var          xpe     = XPEServiceImpl.GetInstance(false);
            var          errores = new List <ErrorCargaTaxonomiaDto>();
            TaxonomiaDto tax     = xpe.CargarTaxonomiaXbrl("http://emisnet.bmv.com.mx/taxonomy/mx-ifrs-2014-12-05/full_ifrs_mc_mx_ics_entry_point_2014-12-05.xsd",
                                                           errores, false);

            var factsById = new Dictionary <String, FactJBRL>();

            var dimensionMembersByCode = new Dictionary <String, DimensionMemberJBRL>();


            var taxFact = new FactJBRL()
            {
                conceptId = "TaxonomyCode",
                value     = tax.EspacioNombresPrincipal,
                factId    = Guid.NewGuid().ToString()
            };

            taxFact.dimensionMap = new Dictionary <string, string>();

            AddDimensionMember(dimensionMembersByCode, taxFact, "taxonomy", tax.EspacioNombresPrincipal, null);
            AddDimensionMember(dimensionMembersByCode, taxFact, "taxonomyCategory", "financialInfo", null);

            taxFact.dimensionMap["taxonomy"]         = tax.EspacioNombresPrincipal;
            taxFact.dimensionMap["taxonomyCategory"] = "financialInfo";

            var taxName = new FactJBRL()
            {
                conceptId = "TaxonomyName",
                value     = "IFRS BMV 2015 For ICS",
                factId    = Guid.NewGuid().ToString()
            };

            taxName.dimensionMap = new Dictionary <string, string>();

            taxName.dimensionMap["taxonomy"]         = tax.EspacioNombresPrincipal;
            taxName.dimensionMap["taxonomyCategory"] = "financialInfo";

            var taxDesc = new FactJBRL()
            {
                conceptId = "TaxonomyDescription",
                value     = "Mexican Taxonomy for financial information for industrial, commercial and services companies",
                factId    = Guid.NewGuid().ToString()
            };

            taxDesc.dimensionMap = new Dictionary <string, string>();

            taxDesc.dimensionMap["taxonomy"]         = tax.EspacioNombresPrincipal;
            taxDesc.dimensionMap["taxonomyCategory"] = "financialInfo";

            factsById[taxFact.factId] = taxFact;
            factsById[taxName.factId] = taxName;
            factsById[taxDesc.factId] = taxDesc;

            var conceptsByPresentation = getConceptsByPresentationLinkbase(tax);

            foreach (var conceptId in conceptsByPresentation.Keys)
            {
                var concept         = tax.ConceptosPorId[conceptId];
                var taxonomyConcept = new FactJBRL()
                {
                    conceptId = "TaxonomyConcept",
                    value     = concept.Id,
                    factId    = Guid.NewGuid().ToString()
                };



                foreach (var labelMap in concept.Etiquetas.Values)
                {
                    foreach (var label in labelMap.Values)
                    {
                        var conceptLabel = new FactJBRL()
                        {
                            conceptId = "ConceptLabel",
                            value     = label.Valor,
                            factId    = Guid.NewGuid().ToString()
                        };



                        conceptLabel.dimensionMap = new Dictionary <string, string>();

                        conceptLabel.dimensionMap["taxonomy"]         = tax.EspacioNombresPrincipal;
                        conceptLabel.dimensionMap["taxonomyCategory"] = "financialInfo";
                        conceptLabel.dimensionMap["concept"]          = concept.Id;
                        conceptLabel.dimensionMap["language"]         = label.Idioma;
                        conceptLabel.dimensionMap["labelRole"]        = label.Rol;

                        factsById[conceptLabel.factId] = conceptLabel;
                    }
                }

                taxonomyConcept.dimensionArray = new List <DimensionMemberJBRL>();
                taxonomyConcept.dimensionMap   = new Dictionary <string, string>();

                taxonomyConcept.dimensionArray.Add(new DimensionMemberJBRL()
                {
                    dimensionId = "taxonomy",
                    member      = tax.EspacioNombresPrincipal
                });
                taxonomyConcept.dimensionArray.Add(new DimensionMemberJBRL()
                {
                    dimensionId = "taxonomyCategory",
                    member      = "financialInfo"
                });
                taxonomyConcept.dimensionArray.Add(new DimensionMemberJBRL()
                {
                    dimensionId = "taxonomyRole",
                    member      = conceptsByPresentation[conceptId][0].ToString()
                });
                taxonomyConcept.dimensionArray.Add(new DimensionMemberJBRL()
                {
                    dimensionId = "roleOrder",
                    member      = conceptsByPresentation[conceptId][1].ToString()
                });

                taxonomyConcept.dimensionMap["taxonomy"]         = tax.EspacioNombresPrincipal;
                taxonomyConcept.dimensionMap["taxonomyCategory"] = "financialInfo";
                taxonomyConcept.dimensionMap["taxonomyRole"]     = conceptsByPresentation[conceptId][0].ToString();
                taxonomyConcept.dimensionMap["roleOrder"]        = conceptsByPresentation[conceptId][1].ToString();

                factsById[taxonomyConcept.factId] = taxonomyConcept;
            }

            var jsonFinal = JsonConvert.SerializeObject(factsById, Formatting.Indented);

            // LogUtil.Info(jsonFinal);

            File.WriteAllText(@"..\..\TestOutput\taxonomyTest.json", jsonFinal);
        }
예제 #7
0
        /// <summary>
        /// Agrega un valor dimensional al mapa de miembros de un hecho y agrega el miembro, si no existe,
        /// </summary>
        /// <param name="dimensionMembersByCode"></param>
        /// <param name="dimensionMap"></param>
        /// <param name="v"></param>
        /// <param name="espacioNombresPrincipal"></param>
        private void AddDimensionMember(Dictionary <string, DimensionMemberJBRL> dimensionMembersByCode, FactJBRL currentFact, string dimensionId, string memberId, string taxonomy)
        {
            string memberKey = dimensionId + memberId;

            if (!dimensionMembersByCode.ContainsKey(memberKey))
            {
                dimensionMembersByCode[memberKey] = new DimensionMemberJBRL()
                {
                    dimensionMemeberId = Guid.NewGuid().ToString(),
                    dimensionId        = dimensionId,
                    member             = memberId,
                    taxonomy           = taxonomy
                };
            }
            currentFact.dimensionMap[dimensionId] = memberId;
        }