Ejemplo n.º 1
0
        public static List <DocumentoInfoArquivoGeral> GetListaDocumentosArquivoGeral(DateTime timeStamp, int maxDocs)
        {
            var docs = default(DocumentoInfoArquivoGeral[]);

            try
            {
                ServicoDocumentos sd = new ServicoDocumentos();
                sd.Credentials = new NetworkCredential(DocInPortoHelper.CMPUsername, DocInPortoHelper.CMPPassword);
                System.Diagnostics.Debug.WriteLine("Filtro documentos: " + timeStamp.ToString("dd-MM-yyyy HH:mm:ss,FFFFFFF"));
                docs = sd.ListaDocumentosArquivoGeral(timeStamp.ToString("dd-MM-yyyy HH:mm:ss,FFFFFFF"), maxDocs); //Example: "13-11-2009 18:49:43,696875000");
            }
            catch (System.Web.Services.Protocols.SoapException e)
            {
                System.Diagnostics.Trace.WriteLine("DocInPorto: " + e.Message);
                MessageBox.Show("Não foi possível obter os documentos para integração." + System.Environment.NewLine + "Ocorreu um erro no servidor.", "Obter documentos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (System.Net.WebException e)
            {
                System.Diagnostics.Trace.WriteLine("DocInPorto: " + e.Message);
                if (e.Status == WebExceptionStatus.NameResolutionFailure)
                {
                    MessageBox.Show("Não foi possível obter os documentos para integração." + System.Environment.NewLine + "O servidor está inacessível.", "Obter documentos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Não foi possível obter os documentos para integração." + System.Environment.NewLine + "Ocorreu um erro inesperado no servidor.", "Obter documentos", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.ToString());
                MessageBox.Show("Não foi possível obter os documentos para integração." + System.Environment.NewLine + "Ocorreu um erro inesperado.", "Obter documentos", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(docs == null ? new List <DocumentoInfoArquivoGeral>() : docs.ToList <DocumentoInfoArquivoGeral>());
        }
        public static string RetrieveConteudoAndWriteToFile(string username, string password, string nud)
        {
            ServicoDocumentos sd = new ServicoDocumentos();

            sd.Credentials = new NetworkCredential(username, password);
            ConteudoInfo conteudo = sd.ConsultarConteudoDocumento(nud);
            var          stream   = new System.IO.FileStream(conteudo.NOMEFICHEIRO, System.IO.FileMode.CreateNew);

            stream.Write(conteudo.FICHEIRO, 0, conteudo.FICHEIRO.Length);
            stream.Close();
            return(conteudo.NOMEFICHEIRO);
        }
Ejemplo n.º 3
0
        public static string getDocInPortoConteudo(string NUD)
        {
            byte[] result = null;
            string sUrl   = string.Empty;

            try
            {
                ServicoDocumentos sd = new ServicoDocumentos();
                sd.Credentials = new NetworkCredential(CMPUsername, CMPPassword);

                Debug.WriteLine("Obter imagem do documento...");

                Debug.WriteLine("Obter imagem do documento...");
                Debug.WriteLine("NUD: " + NUD);

                var b = sd.ConsultarConteudoDocumento(NUD);
                var SourceLocation = b.NOMEFICHEIRO;
                result = b.FICHEIRO;

                Debug.WriteLine("Imagem obtida!");

                Debug.WriteLine("A gerar ficheiro...");

                string gisaTempPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\ParadigmaXis\\GISA";
                string fileName     = Guid.NewGuid().ToString() + "_" + SourceLocation;

                FileStream createPdf = new FileStream(gisaTempPath + "\\" + fileName, FileMode.Create);
                createPdf.Write(result, 0, result.Length);
                createPdf.Close();
                Debug.WriteLine("Ficheiro gerado!");

                sUrl = gisaTempPath + "\\" + fileName;
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
                MessageBox.Show("Ocorreu um erro ao obter o ficheiro." + System.Environment.NewLine + System.Environment.NewLine +
                                ex.Message, "Obter ficheiro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Trace.WriteLine(ex.Message + System.Environment.NewLine + ex.StackTrace);
            }
            catch (Exception e)
            {
                MessageBox.Show("Servidor inacessível.", "Servidor", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Trace.WriteLine(e.ToString());
            }

            return(sUrl);
        }
        public static string[] RetrieveAnexosAndWriteToFiles(string username, string password, string timestamp, long limit)
        {
            List <string>     filenames = new List <string>();
            ServicoDocumentos sd        = new ServicoDocumentos();

            sd.Credentials = new NetworkCredential(username, password);
            DocumentoInfoArquivoGeral[] diags =
                sd.ListaDocumentosArquivoGeral(timestamp, limit);
            foreach (var d in diags)
            {
                foreach (var a in d.ARRAYCONTEUDOS.Where(a => a != null))
                {
                    ConteudoInfo conteudo = sd.ConsultarAnexoDocumento(d.NUD, a.NOMEFICHEIRO);
                    filenames.Add(conteudo.NOMEFICHEIRO);
                    var stream = new System.IO.FileStream(conteudo.NOMEFICHEIRO, System.IO.FileMode.CreateNew);
                    stream.Write(conteudo.FICHEIRO, 0, conteudo.FICHEIRO.Length);
                    stream.Close();
                }
            }
            return(filenames.ToArray());
        }