Exemple #1
0
        public async Task TesteImportacaoPieceAndJoints()
        {
            var application = new Application(false);
            IObjectSpaceProvider objectSpaceProvider = application.serverApplication.ObjectSpaceProvider;
            var          objectSpace = objectSpaceProvider.CreateObjectSpace();
            var          parametros  = objectSpace.CreateObject <ParametrosImportComponentEJunta>();
            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 piecejoints = new ImportComponentEJunta(objectSpaceProvider, parametros);
                var progress    = new Progress <ImportProgressReport>(piecejoints.LogTrace);

                await Task.Run(() => piecejoints.ImportarComponente(dtcollectionImport["Piece"], progress));

                //await Observable.Start(() => piecejoints.ImportarJuntas(dtcollectionImport["Joints"], progress));

                objectSpace.CommitChanges();
            }
        }
Exemple #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 = (ParametrosImportComponentEJunta)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 ImportComponentEJunta(objectSpaceProvider, parametrosImportComponentEJunta);
            var progress       = new Progress <ImportProgressReport>(import.LogTrace);
            var simpleProgress = new Progress <string>();

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

            parametros.ConcluidoComponente = true;

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

            parametros.ConcluidoJuntas = true;

            //var gerador = new Calculator.ProcessoLoteLPPM.GerarLoteLPPM(objectSpaceProvider);
            //await gerador.GerarLoteLPPMAsync(simpleProgress);
            //parametros.ConcluidoLoteLPPM = true;


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