Пример #1
0
        public abrirMensagem(int id)
        {
            idmensagem = id;
            InitializeComponent();

            string caminhoChave = "";

            if (gerenciaServlet.verificaMensagemCriptografada(id))
            {
                MessageBox.Show(MSG_CRIPTO, MSG_ATENCAO, MessageBoxButtons.OK, MessageBoxIcon.Information);
                gerenciaChave gerenciaChaveForm = new gerenciaChave();
                gerenciaChaveForm.ShowDialog();

                caminhoChave = gerenciaChaveForm.getCaminho();
            }

            msg = gerenciaServlet.buscaMensagem(id, caminhoChave);

            abreDe.Text = msg.getDe();
            abreAssunto.Text = msg.getAssunto();
            abreTexto.Text = msg.getTexto();

            foreach (string s in msg.getArquivoCripto()) abreAnexos.Text = s + "; " + abreAnexos.Text;
            foreach (string s in msg.getArquivoPlain()) abreAnexos.Text = s + "; " + abreAnexos.Text;

            if (msg.getAssunto().Equals(MSG_ERRO_ASSUNTO))
            {
                abreResponder.Visible = false;
                abreEncaminhar.Visible = false;
            }
        }
Пример #2
0
        ///<summary>
        ///
        /// Metodo para enviar a nova mensagem através do botao de enviar
        ///
        ///</summary>
        private void novoEnviarClick(object sender, EventArgs e)
        {
            try
            {
                string destinatarios = novoPara.Text;
                if (!destinatarios.EndsWith(SEPARADOR))
                {
                    destinatarios += SEPARADOR;
                }

                preMensagem msg          = new preMensagem(usuario, destinatarios, novoAssunto.Text, novoTexto.Text, novoCripto.Checked, novoAssina.Checked, CriptoFiles, PlainFiles);
                string      caminhoChave = "";

                if (novoAssina.Checked)
                {
                    gerenciaChave gerenciaChaveForm = new gerenciaChave();
                    gerenciaChaveForm.ShowDialog();
                    caminhoChave = gerenciaChaveForm.getCaminho();
                }

                if (novoPara.Text == null || novoPara.Text == "")
                {
                    MessageBox.Show(MSG_SEM_DESTINATARIO, MSG_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    List <string> destinatariosInexistentes = gerenciaServlet.criaMensagem(msg, caminhoChave);
                    //bool ret = gerenciaServlet.criaMensagem(msg,caminhoChave);

                    if (destinatariosInexistentes.Count == 0)
                    {
                        MessageBox.Show(MSG_ENVIO_OK, MSG_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else if (destinatariosInexistentes.Count > 1)
                    {
                        string nomesInexistentes = "";
                        foreach (string s in destinatariosInexistentes)
                        {
                            nomesInexistentes += s + ", ";
                        }
                        nomesInexistentes = nomesInexistentes.Remove(nomesInexistentes.LastIndexOf(", "), 2);

                        MessageBox.Show(MSG_ENVIO_OK_DESTINATARIOS_INEXISTENTES + nomesInexistentes, MSG_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }//else MessageBox.Show(MSG_ENVIO_FAIL, MSG_ERRO, MessageBoxButtons.OK, MessageBoxIcon.Error);

                    gerenciaServlet.excluiArquivos();
                    this.Close();
                }
            }
            catch (excecao except)
            {
                MessageBox.Show(except.Message, MSG_ERRO, MessageBoxButtons.OK, MessageBoxIcon.Error);
                novoPara.Clear();
            }
        }
Пример #3
0
        ///<summary>
        ///
        /// Metodo construtor para inicializar os componentes do formulario
        /// atraves de uma premensagem e um indicador do tipo de mensagem nova
        ///
        ///</summary>
        public novaMensagem(preMensagem msg, int flag, int idmensagem)
        {
            control        = flag;
            usuario        = msg.getPara();
            controleAnexos = 0;
            InitializeComponent();
            novoAssunto.Text = RE + msg.getAssunto();
            novoTexto.Text   = Environment.NewLine + Environment.NewLine + Environment.NewLine + TRACEJADO + Environment.NewLine + DE + msg.getDe() + EMAIL + Environment.NewLine + PARA + msg.getPara() + EMAIL + Environment.NewLine + ASSUNTO + msg.getAssunto() + Environment.NewLine + Environment.NewLine + msg.getTexto();

            if (flag == 1)
            {
                string caminhoChave = "";

                if (msg.getArquivoCripto().Count > 0)
                {
                    foreach (string s in msg.getArquivoCripto())
                    {
                        string nome = gerenciaServlet.recuperaNomeOriginalArquivo(s);
                        nomeAnexos.Text = nome + "; " + nomeAnexos.Text;
                        CriptoFiles.Add(caminho + s);
                    }

                    gerenciaChave gerenciaChaveForm = new gerenciaChave();
                    gerenciaChaveForm.ShowDialog();
                    caminhoChave = gerenciaChaveForm.getCaminho();
                }

                if (msg.getArquivoPlain().Count > 0)
                {
                    foreach (string s in msg.getArquivoPlain())
                    {
                        nomeAnexos.Text = s + "; " + nomeAnexos.Text;
                        PlainFiles.Add(caminho + s);
                    }
                }

                if (CriptoFiles.Count > 0 || PlainFiles.Count > 0)
                {
                    controleAnexos = 1;
                }

                gerenciaServlet.anexoEncaminhar(idmensagem, caminhoChave);
            }
            else
            {
                novoPara.Text = msg.getDe() + EMAIL;
            }
        }
Пример #4
0
        private void abreAnexos_DoubleClick(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(abreAnexos.Text))
            {
                string caminho    = "";
                int    selInicio  = abreAnexos.SelectionStart;
                int    selFim     = abreAnexos.Text.IndexOf(";", selInicio);
                int    selTamanho = selFim - selInicio;

                string nome = abreAnexos.Text.Substring(selInicio, selTamanho);

                abreAnexos.SelectionStart  = selInicio;
                abreAnexos.SelectionLength = selTamanho;

                string[] listArq = abreAnexos.Text.Split(';');

                int listCountInicio = 0;
                int listCountFim    = 0;

                foreach (string arq in listArq)
                {
                    listCountFim += arq.Trim().Length + 2;
                    if (arq.Contains(nome) && listCountInicio <= selInicio && listCountFim > selInicio)
                    {
                        nome      = arq.Trim();
                        selInicio = listCountInicio;
                        break;
                    }
                    listCountInicio = listCountFim;
                }

                if (nome.Contains(ARQUIVO_EXTENSAO))
                {
                    gerenciaChave gerenciaChaveForm = new gerenciaChave();
                    gerenciaChaveForm.ShowDialog();

                    caminho = gerenciaChaveForm.getCaminho();
                }

                gerenciaServlet.abreArquivo(nome, idmensagem, caminho);
            }
        }
Пример #5
0
        public abrirMensagem(int id)
        {
            idmensagem = id;
            InitializeComponent();

            string caminhoChave = "";

            if (gerenciaServlet.verificaMensagemCriptografada(id))
            {
                MessageBox.Show(MSG_CRIPTO, MSG_ATENCAO, MessageBoxButtons.OK, MessageBoxIcon.Information);
                gerenciaChave gerenciaChaveForm = new gerenciaChave();
                gerenciaChaveForm.ShowDialog();

                caminhoChave = gerenciaChaveForm.getCaminho();
            }

            msg = gerenciaServlet.buscaMensagem(id, caminhoChave);

            abreDe.Text      = msg.getDe();
            abreAssunto.Text = msg.getAssunto();
            abreTexto.Text   = msg.getTexto();

            foreach (string s in msg.getArquivoCripto())
            {
                abreAnexos.Text = s + "; " + abreAnexos.Text;
            }
            foreach (string s in msg.getArquivoPlain())
            {
                abreAnexos.Text = s + "; " + abreAnexos.Text;
            }

            if (msg.getAssunto().Equals(MSG_ERRO_ASSUNTO))
            {
                abreResponder.Visible  = false;
                abreEncaminhar.Visible = false;
            }
        }
Пример #6
0
        ///<summary>
        ///
        /// Metodo construtor para inicializar os componentes do formulario 
        /// atraves de uma premensagem e um indicador do tipo de mensagem nova
        /// 
        ///</summary>
        public novaMensagem(preMensagem msg, int flag, int idmensagem)
        {
            control = flag;
            usuario = msg.getPara();
            controleAnexos = 0;
            InitializeComponent();
            novoAssunto.Text = RE + msg.getAssunto();
            novoTexto.Text = Environment.NewLine + Environment.NewLine + Environment.NewLine + TRACEJADO + Environment.NewLine + DE + msg.getDe() + EMAIL + Environment.NewLine + PARA + msg.getPara() + EMAIL + Environment.NewLine + ASSUNTO + msg.getAssunto() + Environment.NewLine + Environment.NewLine + msg.getTexto();

            if (flag == 1)
            {
                string caminhoChave = "";

                if(msg.getArquivoCripto().Count > 0)
                {
                    foreach (string s in msg.getArquivoCripto())
                    {
                        string nome = gerenciaServlet.recuperaNomeOriginalArquivo(s);
                        nomeAnexos.Text = nome + "; " + nomeAnexos.Text;
                        CriptoFiles.Add(caminho + s);
                    }

                    gerenciaChave gerenciaChaveForm = new gerenciaChave();
                    gerenciaChaveForm.ShowDialog();
                    caminhoChave = gerenciaChaveForm.getCaminho();
                }

                if (msg.getArquivoPlain().Count > 0)
                {
                    foreach (string s in msg.getArquivoPlain())
                    {
                        nomeAnexos.Text = s + "; " + nomeAnexos.Text;
                        PlainFiles.Add(caminho + s);
                    }
                }

                if (CriptoFiles.Count > 0 || PlainFiles.Count > 0) controleAnexos = 1;

                gerenciaServlet.anexoEncaminhar(idmensagem, caminhoChave);
            }
            else novoPara.Text = msg.getDe() + EMAIL;
        }
Пример #7
0
        ///<summary>
        ///
        /// Metodo para enviar a nova mensagem através do botao de enviar
        ///
        ///</summary>
        private void novoEnviarClick(object sender, EventArgs e)
        {
            try
            {
                string destinatarios = novoPara.Text;
                if (!destinatarios.EndsWith(SEPARADOR)) destinatarios += SEPARADOR;

                preMensagem msg = new preMensagem(usuario, destinatarios, novoAssunto.Text, novoTexto.Text, novoCripto.Checked, novoAssina.Checked, CriptoFiles, PlainFiles);
                string caminhoChave = "";

                if (novoAssina.Checked)
                {
                    gerenciaChave gerenciaChaveForm = new gerenciaChave();
                    gerenciaChaveForm.ShowDialog();
                    caminhoChave = gerenciaChaveForm.getCaminho();
                }

                if (novoPara.Text == null || novoPara.Text == "") MessageBox.Show(MSG_SEM_DESTINATARIO, MSG_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information);
                else
                {
                    List<string> destinatariosInexistentes = gerenciaServlet.criaMensagem(msg, caminhoChave);
                    //bool ret = gerenciaServlet.criaMensagem(msg,caminhoChave);

                    if (destinatariosInexistentes.Count == 0) MessageBox.Show(MSG_ENVIO_OK, MSG_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    else if (destinatariosInexistentes.Count > 1)
                    {
                        string nomesInexistentes = "";
                        foreach (string s in destinatariosInexistentes) nomesInexistentes += s + ", ";
                        nomesInexistentes = nomesInexistentes.Remove(nomesInexistentes.LastIndexOf(", "), 2);

                        MessageBox.Show(MSG_ENVIO_OK_DESTINATARIOS_INEXISTENTES + nomesInexistentes, MSG_INFO, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }//else MessageBox.Show(MSG_ENVIO_FAIL, MSG_ERRO, MessageBoxButtons.OK, MessageBoxIcon.Error);

                    gerenciaServlet.excluiArquivos();
                    this.Close();
                }
            }
            catch (excecao except)
            {
                MessageBox.Show(except.Message, MSG_ERRO, MessageBoxButtons.OK, MessageBoxIcon.Error);
                novoPara.Clear();
            }
        }
Пример #8
0
        private void abreAnexos_DoubleClick(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(abreAnexos.Text))
            {
                string caminho = "";
                int selInicio = abreAnexos.SelectionStart;
                int selFim = abreAnexos.Text.IndexOf(";", selInicio);
                int selTamanho = selFim - selInicio;

                string nome = abreAnexos.Text.Substring(selInicio, selTamanho);

                abreAnexos.SelectionStart = selInicio;
                abreAnexos.SelectionLength = selTamanho;

                string[] listArq = abreAnexos.Text.Split(';');

                int listCountInicio = 0;
                int listCountFim = 0;

                foreach (string arq in listArq)
                {
                    listCountFim += arq.Trim().Length + 2;
                    if (arq.Contains(nome) && listCountInicio <= selInicio && listCountFim > selInicio)
                    {
                        nome = arq.Trim();
                        selInicio = listCountInicio;
                        break;
                    }
                    listCountInicio = listCountFim;
                }

                if (nome.Contains(ARQUIVO_EXTENSAO))
                {
                    gerenciaChave gerenciaChaveForm = new gerenciaChave();
                    gerenciaChaveForm.ShowDialog();

                    caminho = gerenciaChaveForm.getCaminho();
                }

                gerenciaServlet.abreArquivo(nome, idmensagem, caminho);
            }
        }