Ejemplo n.º 1
0
        private async void DialogControllerImportarPlanilha_Accepting(object sender, DialogControllerAcceptingEventArgs e)
        {
            ((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 = (ParametrosAtualizacaoTabelasAuxiliares)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 itba     = new ImportTabelaAuxiliares(objectSpace, parametrosAtualizacaoTabelasAuxiliares);
            var progress = new Progress <ImportProgressReport>(itba.LogTrace);

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

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

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

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

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

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

            objectSpace.CommitChanges();
            e.AcceptActionArgs.Action.Caption = "Finalizado";
            ((DialogController)sender).AcceptAction.Enabled["NoEnabled"] = true;
        }
Ejemplo n.º 2
0
        public async Task TesteImportacaoTabelaAuxiliar()
        {
            var application = new Application(false);
            IObjectSpaceProvider objectSpaceProvider = application.serverApplication.ObjectSpaceProvider;
            var          objectSpace = objectSpaceProvider.CreateObjectSpace();
            var          parametros  = objectSpace.CreateObject <ParametrosAtualizacaoTabelasAuxiliares>();
            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 ImportTabelaAuxiliares(objectSpace, parametros);
                var progress = new Progress <ImportProgressReport>(itba.LogTrace);

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

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

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

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

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

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

                objectSpace.CommitChanges();
            }
        }