Esempio n. 1
0
        public static void process(CPE cpe, float[] specL, float[] specR)
        {
            var ics          = cpe.getLeftChannel();
            var info         = ics.getInfo();
            var offsets      = info.getSWBOffsets();
            int windowGroups = info.getWindowGroupCount();
            int maxSFB       = info.getMaxSFB();
            var sfbCBl       = ics.getSfbCB();
            var sfbCBr       = cpe.getRightChannel().getSfbCB();
            int groupOff     = 0;
            int idx          = 0;

            for (int g = 0; g < windowGroups; g++)
            {
                for (int i = 0; i < maxSFB; i++, idx++)
                {
                    if (cpe.isMSUsed(idx) && sfbCBl[idx] < NOISE_HCB && sfbCBr[idx] < NOISE_HCB)
                    {
                        for (int w = 0; w < info.getWindowGroupLength(g); w++)
                        {
                            int off = groupOff + w * 128 + offsets[i];
                            for (int j = 0; j < offsets[i + 1] - offsets[i]; j++)
                            {
                                float t = specL[off + j] - specR[off + j];
                                specL[off + j] += specR[off + j];
                                specR[off + j]  = t;
                            }
                        }
                    }
                }
                groupOff += info.getWindowGroupLength(g) * 128;
            }
        }
Esempio n. 2
0
        public static void process(CPE cpe, float[] specL, float[] specR)
        {
            var ics          = cpe.getRightChannel();
            var info         = ics.getInfo();
            var offsets      = info.getSWBOffsets();
            int windowGroups = info.getWindowGroupCount();
            int maxSFB       = info.getMaxSFB();
            var sfbCB        = ics.getSfbCB();
            var sectEnd      = ics.getSectEnd();
            var scaleFactors = ics.getScaleFactors();

            int idx = 0, groupOff = 0;

            for (int g = 0; g < windowGroups; g++)
            {
                for (int i = 0; i < maxSFB;)
                {
                    int end;
                    if (sfbCB[idx] == INTENSITY_HCB || sfbCB[idx] == INTENSITY_HCB2)
                    {
                        end = sectEnd[idx];
                        for (; i < end; i++, idx++)
                        {
                            int c = sfbCB[idx] == INTENSITY_HCB ? 1 : -1;
                            if (cpe.isMSMaskPresent())
                            {
                                c *= cpe.isMSUsed(idx) ? -1 : 1;
                            }
                            float scale = c * scaleFactors[idx];
                            for (int w = 0; w < info.getWindowGroupLength(g); w++)
                            {
                                int off = groupOff + w * 128 + offsets[i];
                                for (int j = 0; j < offsets[i + 1] - offsets[i]; j++)
                                {
                                    specR[off + j] = specL[off + j] * scale;
                                }
                            }
                        }
                    }
                    else
                    {
                        end  = sectEnd[idx];
                        idx += end - i;
                        i    = end;
                    }
                }
                groupOff += info.getWindowGroupLength(g) * 128;
            }
        }
Esempio n. 3
0
        public Dictionary <string, string> NOTA_DEBITO(CPE da, string RUTA, string NOMBRE)
        {
            var    diccionario = new Dictionary <string, string>();
            string json        = @"{
        '_D' : 'urn:oasis:names:specification:ubl:schema:xsd:DebitNote-2',
        '_S' : 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2',
        '_B' : 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2',
        '_E' : 'urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2',
        'DebitNote' : [ 
            {
                'UBLVersionID' : [ 
                    {
                        'IdentifierContent' : '2.1'
                    }
                ],
                'CustomizationID' : [ 
                    {
                        'IdentifierContent' : '2.0'
                    }
                ],
                'ID' : [ 
                    {
                        'IdentifierContent' : '"; json = json + da.NRO_COMPROBANTE + @"'
                    }
                ],
                'IssueDate' : [ 
                    {
                        'DateContent' : '"; json = json + DateTime.Now.ToString("hh:mm:ss") + @"'
                    }
                ],
                'IssueTime' : [ 
                    {
                        'DateTimeContent' : '"; json = json + DateTime.Now.ToString("hh:mm:ss") + @"'
                    }
                ],
                'Note' : [ 
                    {
                        'TextContent' : '"; json = json + da.TOTAL_LETRAS + @"',
                        'LanguageLocaleIdentifier' : '1000'
                    }
                ],
                'DocumentCurrencyCode' : [ 
                    {
                        'CodeContent' : '"; json = json + da.COD_MONEDA + @"'
                    }
                ],
                'DiscrepancyResponse' : [ 
                    {
                        'ReferenceID' : [ 
                            {
                                'IdentifierContent' : '"; json = json + da.SERIE + da.NRO_COMPROBANTE + @"'
                            }
                        ],
                        'ResponseCode' : [ 
                            {
                                'CodeContent' : '02'
                            }
                        ],
                        'Description' : [ 
                            {
                                'TextContent' : '"; json = json + da.DESCRIPCION_MOTIVO + @"'
                            }
                        ]
                    }
                ],
                'BillingReference' : [ 
                    {
                        'InvoiceDocumentReference' : [ 
                            {
                                'ID' : [ 
                                    {
                                        'IdentifierContent' : '"; json = json + da.SERIE + da.NRO_COMPROBANTE + @"'
                                    }
                                ],
                                'DocumentTypeCode' : [ 
                                    {
                                        'CodeContent' : '"; json = json + da.TIPO_COMPROBANTE_MODIFICA + @"'
                                    }
                                ]
                            }
                        ]
                    }
                ],
                'Signature' : [ 
                    {
                        'ID' : [ 
                            {
                                'IdentifierContent' : 'IDSignatureContratistas'
                            }
                        ],
                        'SignatoryParty' : [ 
                            {
                                'PartyIdentification' : [ 
                                    {
                                        'ID' : [ 
                                            {
                                                'IdentifierContent' : '"; json = json + da.NRO_DOCUMENTO_EMPRESA + @"'
                                            }
                                        ]
                                    }
                                ],
                                'PartyName' : [ 
                                    {
                                        'Name' : [ 
                                            {
                                                'TextContent' : '"; json = json + da.RAZON_SOCIAL_EMPRESA + @"'
                                            }
                                        ]
                                    }
                                ]
                            }
                        ],
                        'DigitalSignatureAttachment' : [ 
                            {
                                'ExternalReference' : [ 
                                    {
                                        'URI' : [ 
                                            {
                                                'TextContent' : 'IDSignatureContratistas'
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                ],
                'AccountingSupplierParty' : [ 
                    {
                        'Party' : [ 
                            {
                                'PartyName' : [ 
                                    {
                                        'Name' : [ 
                                            {
                                                'TextContent' : '"; json = json + da.NOMBRE_COMERCIAL_EMPRESA + @"'
                                            }
                                        ]
                                    }
                                ],
                                'PostalAddress' : [ 
                                    {
                                        'ID' : [ 
                                            {
                                                'IdentifierContent' : '"; json = json + da.CODIGO_UBIGEO_EMPRESA + @"'
                                            }
                                        ],
                                        'StreetName' : [ 
                                            {
                                                'TextContent' : '"; json = json + da.DIRECCION_EMPRESA + @"'
                                            }
                                        ],
                                        'CityName' : [ 
                                            {
                                                'TextContent' : '"; json = json + da.DEPARTAMENTO_EMPRESA + @"'
                                            }
                                        ],
                                        'CountrySubentity' : [ 
                                            {
                                                'TextContent' : '"; json = json + da.PROVINCIA_EMPRESA + @"'
                                            }
                                        ],
                                        'District' : [ 
                                            {
                                                'TextContent' : '"; json = json + da.DISTRITO_EMPRESA + @"'
                                            }
                                        ],
                                        'Country' : [ 
                                            {
                                                'IdentificationCode' : [ 
                                                    {
                                                        'IdentifierContent' :'"; json = json + da.CODIGO_PAIS_EMPRESA + @"'
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ],
                                'PartyTaxScheme' : [ 
                                    {
                                        'RegistrationName' : [ 
                                            {
                                                'TextContent' : '"; json = json + da.RAZON_SOCIAL_EMPRESA + @"'
                                            }
                                        ],
                                        'CompanyID' : [ 
                                            {
                                                'IdentifierContent' : '"; json = json + da.NRO_DOCUMENTO_EMPRESA + @"',
                                                'IdentificationSchemeIdentifier' :'"; json = json + da.TIPO_DOCUMENTO_EMPRESA + @"',
                                                'IdentificationSchemeNameText' : 'SUNAT:Identificador de Documento de Identidad',
                                                'IdentificationSchemeAgencyNameText' : 'PE:SUNAT',
                                                'IdentificationSchemeUniformResourceIdentifier' : 'urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo06'
                                            }
                                        ],
                                        'RegistrationAddress' : [ 
                                            {
                                                'AddressTypeCode' : [ 
                                                    {
                                                        'CodeContent' : '0001'
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                ],
                'AccountingCustomerParty' : [ 
                    {
                        'Party' : [ 
                            {
                                'PostalAddress' : [ 
                                    {
                                        'ID' : [ 
                                            {
                                                'IdentifierContent' : '-'
                                            }
                                        ],
                                        'StreetName' : [ 
                                            {
                                                'TextContent' :  '"; json = json + da.DIRECCION_CLIENTE + @"'
                                            }
                                        ],
                                        'CityName' : [ 
                                            {
                                                'TextContent' : '"; json = json + da.CIUDAD_CLIENTE + @"'
                                            }
                                        ],
                                        'CountrySubentity' : [ 
                                            {
                                                'TextContent' : '-'
                                            }
                                        ],
                                        'District' : [ 
                                            {
                                                'TextContent' : '-'
                                            }
                                        ],
                                        'Country' : [ 
                                            {
                                                'IdentificationCode' : [ 
                                                    {
                                                        'IdentifierContent' : 'PE'
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ],
                                'PartyTaxScheme' : [ 
                                    {
                                        'RegistrationName' : [ 
                                            {
                                                'TextContent' : '"; json = json + da.RAZON_SOCIAL_CLIENTE + @"'
                                            }
                                        ],
                                        'CompanyID' : [ 
                                            {
                                                'IdentifierContent' : '"; json = json + da.NRO_DOCUMENTO_CLIENTE + @"',
                                                'IdentificationSchemeIdentifier' : '"; json = json + da.TIPO_DOCUMENTO_CLIENTE + @"',
                                                'IdentificationSchemeNameText' : 'SUNAT:Identificador de Documento de Identidad',
                                                'IdentificationSchemeAgencyNameText' : 'PE:SUNAT',
                                                'IdentificationSchemeUniformResourceIdentifier' : 'urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo06'
                                            }
                                        ],
                                        'RegistrationAddress' : [ 
                                            {
                                                'AddressTypeCode' : [ 
                                                    {
                                                        'CodeContent' : '0001'
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ],
                                'Contact' : [ 
                                    {
                                        'ElectronicMail' : [ 
                                            {
                                                'TextContent' : '*****@*****.**'
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                ],
                'TaxTotal' : [ 
                    {
                        'TaxAmount' : [ 
                            {
                                'AmountContent' : '"; json = json + da.TOTAL_IGV + @"',
                                'AmountCurrencyIdentifier' : '"; json = json + da.COD_MONEDA + @"'
                            }
                        ],
                        'TaxSubtotal' : [ 
                            {
                                'TaxableAmount' : [ 
                                    {
                                        'AmountContent' : '"; json = json + da.SUB_TOTAL + @"',
                                        'AmountCurrencyIdentifier' : '"; json = json + da.COD_MONEDA + @"'
                                    }
                                ],
                                'TaxAmount' : [ 
                                    {
                                        'AmountContent' : '"; json = json + da.TOTAL_IGV + @"',
                                        'AmountCurrencyIdentifier' : '"; json = json + da.COD_MONEDA + @"'
                                    }
                                ],
                                'TaxCategory' : [ 
                                    {
                                        'ID' : [ 
                                            {
                                                'IdentifierContent' : 'S',
                                                'IdentificationSchemeIdentifier' : 'UN/ECE 5305',
                                                'IdentificationSchemeNameText' : 'Tax Category Identifier',
                                                'IdentificationSchemeAgencyNameText' : 'United Nations Economic Commission for Europe'
                                            }
                                        ],
                                        'Percent' : [ 
                                            {
                                                'NumericContent' : 18.00
                                            }
                                        ],
                                        'TaxScheme' : [ 
                                            {
                                                'ID' : [ 
                                                    {
                                                        'IdentifierContent' : '1000',
                                                        'IdentificationSchemeIdentifier' : 'UN/ECE 5153',
                                                        'IdentificationSchemeAgencyIdentifier' : '6'
                                                    }
                                                ],
                                                'Name' : [ 
                                                    {
                                                        'TextContent' : 'IGV'
                                                    }
                                                ],
                                                'TaxTypeCode' : [ 
                                                    {
                                                        'CodeContent' : 'VAT'
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                ],
                'RequestedMonetaryTotal' : [ 
                    {
                        'LineExtensionAmount' : [ 
                            {
                                'AmountContent' : '"; json = json + da.TOTAL + @"',
                                'AmountCurrencyIdentifier' : '"; json = json + da.COD_MONEDA + @"'
                            }
                        ],
                        'TaxInclusiveAmount' : [ 
                            {
                                'AmountContent' : '"; json = json + da.TOTAL_GRAVADAS + @"',
                                'AmountCurrencyIdentifier' : '"; json = json + da.COD_MONEDA + @"'
                            }
                        ],
                        'PayableAmount' : [ 
                            {
                                'AmountContent' : '"; json = json + da.TOTAL_GRAVADAS + @"',
                                'AmountCurrencyIdentifier' : '"; json = json + da.COD_MONEDA + @"'
                            }
                        ]
                    }
                ],

                'DebitNoteLine' : [ ";

            for (int i = 0; i <= da.detalle.Count() - 1; i++)
            {
                json = json + @"{
                    'ID' : [ 
                            {
                                'IdentifierContent' : "; json = json + da.detalle[i].ITEM + @"
                            }
                        ],
                        'Note' : [ 
                            {
                                'TextContent' : '"; json = json + da.detalle[i].UNIDAD_MEDIDA + @"'
                            }
                        ],
                        'DebitedQuantity' : [ 
                            {
                                'QuantityContent' : '"; json = json + da.detalle[i].CANTIDAD + @"',
                                'QuantityUnitCode' : '"; json = json + da.detalle[i].UNIDAD_MEDIDA + @"',
                                'QuantityUnitCodeListIdentifier' : 'UN/ECE rec 20',
                                'QuantityUnitCodeListAgencyNameText' : 'United Nations Economic Commission for Europe'
                            }
                        ],
                        'LineExtensionAmount' : [ 
                            {
                                'AmountContent' : '"; json = json + da.detalle[i].PRECIO_SIN_IMPUESTO + @"',
                                'AmountCurrencyIdentifier' : '"; json = json + da.COD_MONEDA + @"'
                            }
                        ],
                        'PricingReference' : [ 
                            {
                                'AlternativeConditionPrice' : [ 
                                    {
                                        'PriceAmount' : [ 
                                            {
                                                'AmountContent' : '"; json = json + da.detalle[i].SUB_TOTAL + @"',
                                                'AmountCurrencyIdentifier' : '"; json = json + da.COD_MONEDA + @"'
                                            }
                                        ],
                                        'PriceTypeCode' : [ 
                                            {
                                                'CodeContent' : '01'
                                            }
                                        ]
                                    }
                                ]
                            }
                        ],
                        'TaxTotal' : [ 
                            {
                                'TaxAmount' : [ 
                                    {
                                        'AmountContent' : '"; json = json + da.detalle[i].IGV + @"',
                                        'AmountCurrencyIdentifier' : '"; json = json + da.COD_MONEDA + @"'
                                    }
                                ],
                                'TaxSubtotal' : [ 
                                    {
                                        'TaxableAmount' : [ 
                                            {
                                                'AmountContent' : '"; json = json + da.detalle[i].IMPORTE + @"',
                                                'AmountCurrencyIdentifier' : '"; json = json + da.COD_MONEDA + @"'
                                            }
                                        ],
                                        'TaxAmount' : [ 
                                            {
                                                'AmountContent' : '"; json = json + da.detalle[i].IGV + @"',
                                                'AmountCurrencyIdentifier' : '"; json = json + da.COD_MONEDA + @"'
                                            }
                                        ],
                                        'TaxCategory' : [ 
                                            {
                                                'ID' : [ 
                                                    {
                                                        'IdentifierContent' : '"; json = json + da.detalle[i].COD_TIPO_OPERACION + @"',
                                                        'IdentificationSchemeIdentifier' : 'UN/ECE 5305',
                                                        'IdentificationSchemeNameText' : 'Tax Category Identifier',
                                                        'IdentificationSchemeAgencyNameText' : 'United Nations Economic Commission for Europe'
                                                    }
                                                ],
                                                'TaxExemptionReasonCode' : [ 
                                                    {
                                                        'CodeContent' : '10',
                                                        'CodeListAgencyNameText' : 'PE:SUNAT',
                                                        'CodeListNameText' : 'SUNAT:Codigo de Tipo de Afectación del IGV',
                                                        'CodeListUniformResourceIdentifier' : 'urn:pe:gob:sunat:cpe:see:gem:catalogos:catalogo07'
                                                    }
                                                ],
                                                'TaxScheme' : [ 
                                                    {
                                                        'ID' : [ 
                                                            {
                                                                'IdentifierContent' : '1000',
                                                                'IdentificationSchemeIdentifier' : 'UN/ECE 5153',
                                                                'IdentificationSchemeAgencyIdentifier' : '6'
                                                            }
                                                        ],
                                                        'Name' : [ 
                                                            {
                                                                'TextContent' : 'IGV'
                                                            }
                                                        ],
                                                        'TaxTypeCode' : [ 
                                                            {
                                                                'CodeContent' : 'VAT'
                                                            }
                                                        ]
                                                    }
                                                ]
                                            }
                                        ]
                                    }
                                ]
                            }
                        ],
                        'Item' : [ 
                            {
                                'Description' : [ 
                                    {
                                        'TextContent' : '"; json = json + da.detalle[i].DESCRIPCION + @"'
                                    }
                                ],
                                'SellersItemIdentification' : [ 
                                    {
                                        'ID' : [ 
                                            {
                                                'IdentifierContent' : '"; json = json + da.detalle[i].CODIGO + @"'
                                            }
                                        ]
                                    }
                                ]
                            }
                        ],
                        'Price' : [ 
                            {
                                'PriceAmount' : [ 
                                    {
                                        'AmountCurrencyIdentifier' : '"; json = json + da.detalle[i].PRECIO + @"',
                                        'AmountContent' : '10.0000'
                                    }
                                ]
                            }
                        ]
                    },";
            }

            json = json + @"]
            }
        ]
    }";

            JObject rss = JObject.Parse(json);

            Console.WriteLine(rss.ToString());
            JavaScriptSerializer js = new JavaScriptSerializer(); //system.web.extension assembly....
            string outputJson       = js.Serialize(rss.ToString());
            string outputJson2      = js.Serialize(outputJson);

            File.WriteAllText(RUTA + NOMBRE, rss.ToString());

            //try
            //{
            //    Task<string> calltask = Task.Run(() => GetAPIToken(userName, password, Token_URL));

            //    calltask.Wait();
            //    TOKEN = calltask.Result;

            //    Task<string> calltask2 = Task.Run(() => postDoucumento(TOKEN, RUTA + NOMBRE, Documento_URL, NOMBRE));
            //    calltask2.Wait();
            //    TIKET = calltask.Result;

            //    Task<string> calltask3 = Task.Run(() => GetCDR_ANULA(TIKET,TOKEN,Cdr_URL));
            //    calltask3.Wait();
            //    HASH = calltask3.Result;

            //    Task<string> calltaks4 = Task.Run(()=> GetXML(TIKET, TOKEN, xml_URL));
            //    calltaks4.Wait();
            //    XML = calltaks4.Result;

            //    diccionario.Add("TIKET", TIKET);
            //    diccionario.Add("HASH", HASH);

            //}
            //catch (Exception EX)
            //{

            //    diccionario.Add("TIKET", "ERROR DE CONEXION");
            //    diccionario.Add("HASH", "ERROR DE CONEXION");
            //}
            return(diccionario);
        }