public GEDClientViewModel()
        {
            try
            {
                GEDServiceClient        gedService = new GEDServiceClient();
                IList <GedDocumentoDTO> doc        = gedService.selectDocumento(new GedDocumentoDTO());
                listaDocumento = new ObservableCollection <GedDocumentoDTO>(doc);
                IList <GedTipoDocumentoDTO> listaTipo = gedService.selectGedTipoDocumento(new GedTipoDocumentoDTO());
                listaTipoDocumento = new ObservableCollection <GedTipoDocumentoDTO>(listaTipo);

                documento = criarDocumento();
                documento.GedTipoDocumento = new GedTipoDocumentoDTO();

                contentPresenterDocumento = new ContentPresenter();

                store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
                store.Open(OpenFlags.ReadOnly);
                X509Certificate2Collection certCollection = store.Certificates;

                ListaNomeCertificados.Add("Não");
                foreach (X509Certificate2 c in certCollection)
                {
                    ListaNomeCertificados.Add(c.Subject.Split('=')[1].Split(',')[0]);
                    listaCertificados.Add(c);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void atualizarListaGedTipoDocumento(int pagina)
        {
            try
            {
                using (GEDServiceClient serv = new GEDServiceClient())
                {
                    if (pagina == 0)
                    {
                        primeiroResultado = 0;
                    }
                    else if (pagina > 0)
                    {
                        primeiroResultado += QUANTIDADE_PAGINA;
                    }
                    else if (pagina < 0)
                    {
                        primeiroResultado -= QUANTIDADE_PAGINA;
                    }

                    List <GedTipoDocumentoDTO> listaServ = serv.selectGedTipoDocumentoPagina(primeiroResultado, QUANTIDADE_PAGINA, new GedTipoDocumentoDTO());

                    ListaGedTipoDocumento.Clear();

                    foreach (GedTipoDocumentoDTO objAdd in listaServ)
                    {
                        ListaGedTipoDocumento.Add(objAdd);
                    }
                    GedTipoDocumentoSelected = null;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public int incluirDocumento()
        {
            try
            {
                GEDServiceClient gedService = new GEDServiceClient();

                if (uriImagem != null)
                {
                    documento.arquivo = carregarArquivo();
                }

                // documento.GedTipoDocumento = listaTipoDocumento.ElementAt<GedTipoDocumentoDTO>(1);

                documento.Empresa  = Empresa;
                documento.Assinado = "N";
                if (assinado > 0)
                {
                    assinarArquivo(documento.arquivo);
                    documento.Assinado = "S";
                }


                documento = gedService.saveDocumento(documento);

                int resultado = documento.Id;

                documento = criarDocumento();

                return(resultado);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void visualizarDocumento()
        {
            try
            {
                GEDServiceClient gedService = new GEDServiceClient();
                documentoSelected = gedService.selectDocumentoId(documentoSelected);

                string caminhoTemp = salvaArquivoTempLocal(documentoSelected.arquivo);
                System.Diagnostics.Process.Start(caminhoTemp);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void excluirDocumento()
        {
            try
            {
                GEDServiceClient gedService = new GEDServiceClient();
                documentoSelected.DataExclusao = DateTime.Now;

                gedService.deleteDocumento(documentoSelected);
                documentoSelected = null;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public void excluirGedTipoDocumento()
 {
     try
     {
         using (GEDServiceClient serv = new GEDServiceClient())
         {
             serv.deleteGedTipoDocumento(GedTipoDocumentoSelected);
             GedTipoDocumentoSelected = null;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void salvarAtualizarGedTipoDocumento()
 {
     try
     {
         using (GEDServiceClient serv = new GEDServiceClient())
         {
             GedTipoDocumentoSelected.Empresa = Empresa;
             serv.salvarAtualizarGedTipoDocumento(GedTipoDocumentoSelected);
             GedTipoDocumentoSelected = null;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        private void carregarDocumentoSelected()
        {
            try
            {
                GEDServiceClient gedService = new GEDServiceClient();
                documentoSelected = gedService.selectDocumentoId(documentoSelected);

                uriImagem = salvaArquivoTempLocal(documentoSelected.arquivo);

                if (documentoSelected.Assinado != null && documentoSelected.Assinado == "S")
                {
                    documentoSelected.Assinado = verificarAssinatura(documentoSelected.arquivo) ? "S" : "N";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public void pesquisarDocumento()
 {
     try
     {
         GEDServiceClient gedService = new GEDServiceClient();
         GedDocumentoDTO  docPesq    = new GedDocumentoDTO {
             Nome = textoPesquisaDoc
         };
         IList <GedDocumentoDTO> listaDoc = gedService.selectDocumento(docPesq);
         listaDocumento.Clear();
         foreach (GedDocumentoDTO doc in listaDoc)
         {
             listaDocumento.Add(doc);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public bool login(String login, String senha)
        {
            try
            {
                using (GEDServiceClient serv = new GEDServiceClient())
                {
                    UsuarioDTO usuario = serv.selectUsuario(login, senha);
                    if (usuario != null)
                    {
                        UsuarioLogado = usuario;
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
        public void alterarDocumento()
        {
            try
            {
                GEDServiceClient gedService = new GEDServiceClient();

                documentoSelected.arquivo  = carregarArquivo();
                documentoSelected.Assinado = "N";
                if (assinado > 0)
                {
                    assinarArquivo(documentoSelected.arquivo);
                    documentoSelected.Assinado = "S";
                }

                gedService.updateDocumento(documentoSelected);
                documentoSelected = null;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void acesso(int papel, String formulario)
        {
            try
            {
                using (GEDServiceClient serv = new GEDServiceClient())
                {
                    ViewControleAcessoDTO ControleAcesso = new ViewControleAcessoDTO();
                    ControleAcesso.IdPapel    = papel;
                    ControleAcesso.Formulario = formulario;
                    List <ViewControleAcessoDTO> listaServ = serv.selectControleAcesso(ControleAcesso);

                    ListaControleAcesso.Clear();

                    foreach (ViewControleAcessoDTO objAdd in listaServ)
                    {
                        ListaControleAcesso.Add(objAdd);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }