private void btnImportar_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog openFileDialog1 = new Microsoft.Win32.OpenFileDialog(); openFileDialog1.Filter = "Arquivos xml (*.xml)|*.xml"; openFileDialog1.InitialDirectory = _AppServicoParametros.GetAll().FirstOrDefault().PathSelosCenib; List <Indisponibilidades> existentes; try { if (openFileDialog1.ShowDialog() == true) { FileInfo fi = new FileInfo(openFileDialog1.FileName); string ordem = System.AppDomain.CurrentDomain.BaseDirectory.ToString() + @"\Xsd\ordem.xsd"; ValidadorSchemaXml.Validar(fi.FullName, ordem); IEnumerable <Indisponibilidades> indisp = _AppServicoIndisponibilidades.LerArquivoXml(openFileDialog1.FileName); existentes = _AppServicoIndisponibilidades.ObterArquivosImportados(string.Format("{0}_{1}", fi.Name, fi.LastWriteTime)).ToList(); if (existentes.Count() == 0) { AguardeIndisponibilidade aguardeIndisp = new AguardeIndisponibilidade(indisp.ToList(), openFileDialog1.FileName, existentes, _usuario); aguardeIndisp.Owner = this; aguardeIndisp.ShowDialog(); } else { if (MessageBox.Show("Você está tentando importar um arquivo já importado anteriormente, deseja importar novamente?", "Atenção", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { AguardeIndisponibilidade aguardeIndisp = new AguardeIndisponibilidade(indisp.ToList(), openFileDialog1.FileName, existentes, _usuario); aguardeIndisp.Owner = this; aguardeIndisp.ShowDialog(); } } } _indisponibilidades = _AppServicoIndisponibilidades.GetAll(); lblQtdRegistros.Content = CarregarGrid(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Sincronizar() { Microsoft.Win32.OpenFileDialog openFileDialog1 = new Microsoft.Win32.OpenFileDialog(); openFileDialog1.Filter = "Arquivos xml (*.xml)|*.xml"; openFileDialog1.InitialDirectory = @"\\Servidor\c\Cartorio\cgj-rj\ModuloApoioServico\Caixa de Entrada\Relatórios"; openFileDialog1.Multiselect = true; openFileDialog1.Title = "Importar Arquivos"; try { var arquivos = new List <string>(); if (openFileDialog1.ShowDialog() == true) { foreach (String file in openFileDialog1.FileNames) { arquivos.Add(file); } for (int i = 0; i < arquivos.Count; i++) { FileInfo fi = new FileInfo(arquivos[i]); string relatorio = @"\\Servidor\c\Cartorio\CS_Sistemas\CS_ISS\relatorio.xml.xsd"; ValidadorSchemaXml.Validar(fi.FullName, relatorio); List <AtoIss> AtosImportar = _appServicoAtoIss.LerArquivoXml(arquivos[i]); if (AtosImportar.Count == 0) { //MessageBox.Show("Não constam atos no arquivo: \n\n " + arquivos[i], "Atenção", MessageBoxButton.OK, MessageBoxImage.Stop); } else { _config = _AppServicoConfiguracoes.GetById(1); if (_config.NomeArquivoImportando == fi.FullName) { MessageBox.Show("Arquivo selecionado já foi importado.", "Atenção", MessageBoxButton.OK, MessageBoxImage.Stop); } else { _config.NomeArquivoImportando = fi.FullName; _AppServicoConfiguracoes.Update(_config); var aguardeIndisp = new AguardeIntegracaoIssMas(AtosImportar, arquivos[i]); aguardeIndisp.Owner = this; aguardeIndisp.ShowDialog(); } } //DateTime data = Convert.ToDateTime(AtosImportar[0].Data); //var consultaAtosIss = new ConsultaAtosIss(data, _usuario); //consultaAtosIss.Owner = this; //consultaAtosIss.ShowDialog(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }