Esempio n. 1
0
        public async Task TesteImportacaoSpoolEJunta()
        {
            var application = new Application(false);
            IObjectSpaceProvider objectSpaceProvider = application.serverApplication.ObjectSpaceProvider;
            var          objectSpace = objectSpaceProvider.CreateObjectSpace();
            var          parametros  = objectSpace.CreateObject <ParametrosImportSpoolJuntaExcel>();
            MemoryStream stream      = new MemoryStream();

            stream.Seek(0, SeekOrigin.Begin);
            var arquivo = parametros.Padrao;

            arquivo.SaveToStream(stream);
            stream.Seek(0, SeekOrigin.Begin);

            using (var excelReader = new Module.ExcelDataReaderHelper.Excel.Reader(stream))
            {
                var dtcollectionImport = excelReader.CreateDataTableCollection(false);

                var itba     = new ImportSpoolEJunta(objectSpace, parametros);
                var progress = new Progress <ImportProgressReport>(itba.LogTrace);

                await Observable.Start(() => itba.ImportarSpools(dtcollectionImport["SGS"], progress));

                await Observable.Start(() => itba.ImportarJuntas(dtcollectionImport["SGJ"], progress));

                objectSpace.CommitChanges();
            }
        }
Esempio n. 2
0
        private async void DialogControllerImportarPlanilha_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            DataTableCollection dtcollectionImport = null;

            ((DialogController)sender).AcceptAction.Enabled["NoEnabled"] = false;
            //Necessário para não fechar a janela após a conclusão do processamento
            e.Cancel = true;
            e.AcceptActionArgs.Action.Caption = "Procesando";

            var          parametros = (ParametrosImportSpoolJuntaExcel)e.AcceptActionArgs.SelectedObjects[0];
            MemoryStream stream     = new MemoryStream();

            stream.Seek(0, SeekOrigin.Begin);

            var arquivo = parametros.Padrao;

            arquivo.SaveToStream(stream);

            stream.Seek(0, SeekOrigin.Begin);

            using (var excelReader = new ExcelDataReaderHelper.Excel.Reader(stream))
            {
                dtcollectionImport = excelReader.CreateDataTableCollection(false);
            }

            var import   = new ImportSpoolEJunta(objectSpace, parametrosImportSpoolJuntaExcel);
            var progress = new Progress <ImportProgressReport>(import.LogTrace);

            await Observable.Start(() => import.ImportarSpools(dtcollectionImport["SGS"], progress));

            await Observable.Start(() => import.ImportarJuntas(dtcollectionImport["SGJ"], progress));

            objectSpace.CommitChanges();
            e.AcceptActionArgs.Action.Caption = "Finalizado";
            ((DialogController)sender).AcceptAction.Enabled["NoEnabled"] = true;
        }