public void Inicializar()
        {
            RegistroBase.InicializarProcessamentoRegistros();

            DbCommand cmd = UndTrabalho.DBArquivoSpedFiscal.GetStoredProcCommand(
                SqlExpressionsPisCofinsRepository.GetExpressionNovaSequenciaArquivo());

            this._NumeroIdentificacaoArquivo = Convert.ToInt32(
                UndTrabalho.DBArquivoSpedFiscal.ExecuteScalar(cmd));
            this._informacoesArquivo = this.GetRecordInformacoesArquivo();

            this._informacoesArquivo.CodigoEmpresa = UndTrabalho.CodigoEmpresa;
            this._informacoesArquivo.DataInicial   = UndTrabalho.DataInicial;
            this._informacoesArquivo.DataFinal     = UndTrabalho.DataFinal;
            this._informacoesArquivo.TipoArquivo   = UndTrabalho.TipoArquivo.ToString().ToUpper();
            this._informacoesArquivo.TipoRemessa   = UndTrabalho.TipoRemessa.ToString().ToUpper();
            this._informacoesArquivo.Save();
        }
        private ArquivoPisCofinsRecord GetRecordInformacoesArquivo()
        {
            IDictionary <string, string> properties = new Dictionary <string, string>();

            properties.Add("connection.driver_class",
                           ConfigurationManager.AppSettings["ActiveRecordDriver"]);
            properties.Add("dialect",
                           ConfigurationManager.AppSettings["ActiveRecordDialect"]);
            properties.Add("connection.provider",
                           ConfigurationManager.AppSettings["ActiveRecordConnectionProvider"]);
            properties.Add("connection.connection_string",
                           ConfigurationManager.ConnectionStrings["DBArquivoSpedFiscal"].ConnectionString);
            properties.Add("proxyfactory.factory_class",
                           ConfigurationManager.AppSettings["ActiveRecordProxyFactory"]);

            InPlaceConfigurationSource source = new InPlaceConfigurationSource();

            source.Add(typeof(ActiveRecordBase), properties);
            ActiveRecordStarter.Initialize(source, typeof(ArquivoPisCofinsRecord));

            return(ArquivoPisCofinsRecord.Find(this._NumeroIdentificacaoArquivo));
        }