Esempio n. 1
0
 public CacheService(TzktContext db)
 {
     AppState     = new AppStateCache(db);
     BakerCycles  = new BakerCyclesCache(db);
     BakingRights = new BakingRightsCache(db);
     Accounts     = new AccountsCache(this, db);
     Blocks       = new BlocksCache(this, db);
     Periods      = new PeriodsCache(db);
     Proposals    = new ProposalsCache(db);
     Protocols    = new ProtocolsCache(db);
     Statistics   = new StatisticsCache(db);
     Software     = new SoftwareCache(db);
     Schemas      = new SchemasCache(db);
     Storages     = new StoragesCache(db);
 }
        /// <inheritdoc />
        public override string GetSchema(SchemaCTe schema)
        {
            if (SchemasCache.ContainsKey(schema))
            {
                return(SchemasCache[schema]);
            }

            var schemaPath = "";
            var versao     = Parent.Configuracoes.Geral.VersaoDFe;

            switch (schema)
            {
            case SchemaCTe.CTe:
                schemaPath = Path.Combine(PathSchemas, $"cte_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.CTeOS:
                schemaPath = Path.Combine(PathSchemas, $"cteOS_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.CancCTe:
                schemaPath = Path.Combine(PathSchemas, $"evCancCTe_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.InutCTe:
                schemaPath = Path.Combine(PathSchemas, $"inutCTe_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.EventoCTe:
                schemaPath = Path.Combine(PathSchemas, $"eventoCTe_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.ProcCTe:
                schemaPath = Path.Combine(PathSchemas, $"procCTe_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.ProcEventoCTe:
                schemaPath = Path.Combine(PathSchemas, $"procEventoCTe_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.ConsSitCTe:
                schemaPath = Path.Combine(PathSchemas, $"consSitCTe_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.ConsStatServCTe:
                schemaPath = Path.Combine(PathSchemas, $"consStatServCTe_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.ConsCad:
                schemaPath = Path.Combine(PathSchemas, "consCad_v2.00.xsd");
                break;

            case SchemaCTe.CTeModalAereo:
                schemaPath = Path.Combine(PathSchemas, $"cteModalAereo_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.CTeModalAquaviario:
                schemaPath = Path.Combine(PathSchemas, $"cteModalAquaviario_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.CTeModalDutoviario:
                schemaPath = Path.Combine(PathSchemas, $"cteModalDutoviario_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.CTeModalFerroviario:
                schemaPath = Path.Combine(PathSchemas, $"cteModalFerroviario_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.CTeModalRodoviario:
                schemaPath = Path.Combine(PathSchemas, $"cteModalRodoviario_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.CTeMultiModal:
                schemaPath = Path.Combine(PathSchemas, $"cteMultiModal_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.EvEPECCTe:
                schemaPath = Path.Combine(PathSchemas, $"evEPECCTe_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.EvCancCTe:
                schemaPath = Path.Combine(PathSchemas, $"evCancCTe_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.EvRegMultimodal:
                schemaPath = Path.Combine(PathSchemas, $"evRegMultimodal_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.EvCCeCTe:
                schemaPath = Path.Combine(PathSchemas, $"evCCeCTe_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.DistDFeInt:
                schemaPath = Path.Combine(PathSchemas, "distDFeInt_v1.00.xsd");
                break;

            case SchemaCTe.CTeModalRodoviarioOS:
                schemaPath = Path.Combine(PathSchemas, $"cteModalRodoviarioOS_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.EvPrestDesacordo:
                schemaPath = Path.Combine(PathSchemas, $"evPrestDesacordo_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.EvGTV:
                schemaPath = Path.Combine(PathSchemas, $"evGTV_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.ProcCTeOS:
                schemaPath = Path.Combine(PathSchemas, $"procCTeOS_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.EnviCTe:
                schemaPath = Path.Combine(PathSchemas, $"enviCTe_v{versao.GetDescription()}.xsd");
                break;

            case SchemaCTe.ConsReciCTe:
                schemaPath = Path.Combine(PathSchemas, $"consReciCTe_v{versao.GetDescription()}.xsd");
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(schema), schema, null);
            }

            SchemasCache.Add(schema, schemaPath);

            return(SchemasCache[schema]);
        }