public ActionResult Terminar(string IDEmpregado) { try { Empregado oEmpregado = EmpregadoBusiness.Consulta.FirstOrDefault(p => string.IsNullOrEmpty(p.UsuarioExclusao) && p.IDEmpregado.Equals(IDEmpregado)); if (oEmpregado == null) { return(Json(new { resultado = new RetornoJSON() { Erro = "Não foi possível excluir o empregado, pois o mesmo não foi localizado." } })); } else { oEmpregado.DataExclusao = DateTime.Now; //oEmpregado.UsuarioExclusao = CustomAuthorizationProvider.UsuarioAutenticado.Usuario.Login; EmpregadoBusiness.Excluir(oEmpregado); return(Json(new { resultado = new RetornoJSON() { Sucesso = "O empregado '" + oEmpregado.Nome + "' foi excluído com sucesso." } })); } } catch (Exception ex) { if (ex.GetBaseException() == null) { return(Json(new { resultado = new RetornoJSON() { Erro = ex.Message } })); } else { return(Json(new { resultado = new RetornoJSON() { Erro = ex.GetBaseException().Message } })); } } }
/// <summary> /// Metodo que guarda o empregado /// </summary> /// <param name="c"></param> /// <returns></returns> public bool GuardaEmpregado(Empregado e) { int key = GetCode(e); e.InicioTrabalho = DateTime.Now; if (!empregados.ContainsKey(key)) { empregados.Add(key, new List <Empregado> { }); empregados[key].Add(e); totEmpregados++; Save(@"E:\Temp\Lesi 1º Ano 2º Semestre\LP2\trabalhoLP2\trabalhoLP2\Empregados.bin"); return(true); } else { empregados[key].Add(e); return(true); } }
public async Task <IActionResult> AddOrEdit([Bind("EmpregadoId,NameCompleto,EmpCode,Posicao,LocalizacaoTrabalho")] Empregado empregado) { if (ModelState.IsValid) { //verificando se e para salvar ou atualizar os dados if (empregado.EmpregadoId == 0) { _context.Add(empregado); } else { _context.Update(empregado); } await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(empregado)); }
public bool Gravar(Empregado empregado) { crud = new CRUD(); SQL = "INSERT INTO Empregado (Nome, Ativo, Id_Empresa, Id_Departamento) " + "VALUES (@Nome, @Ativo, @Id_Empresa, @Id_Departamento)"; try { crud.LimparParametros(); crud.AdicionarParametros("Nome", empregado.Nome); crud.AdicionarParametros("Ativo", empregado.Ativo); crud.AdicionarParametros("Id_Empresa", empregado.Empresa.Id); crud.AdicionarParametros("Id_Departamento", empregado.Departamento.Id); crud.Executar(CommandType.Text, SQL); return(true); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult Cadastrar(Empregado empregado) { if (ModelState.IsValid) { try { empregado.UsuarioInclusao = CustomAuthorizationProvider.UsuarioAutenticado.Login; empregado.Status = "Atualmente sem admissão"; EmpregadoBusiness.Inserir(empregado); Extensions.GravaCookie("MensagemSucesso", "O empregado '" + empregado.Nome + "' foi cadastrado com sucesso.", 10); return(Json(new { resultado = new RetornoJSON() { URL = Url.Action("Novo", "Empregado") } })); } catch (Exception ex) { if (ex.GetBaseException() == null) { return(Json(new { resultado = new RetornoJSON() { Erro = ex.Message } })); } else { return(Json(new { resultado = new RetornoJSON() { Erro = ex.GetBaseException().Message } })); } } } else { return(Json(new { resultado = TratarRetornoValidacaoToJSON() })); } }
private void button2_Click(object sender, EventArgs e) { Empregado emp = new Empregado(); if (codE.Text.Length != 0 && codH.Text.Length != 0) { ControlaEmpregados.GetEmpregado(Int32.Parse(codE.Text), Int32.Parse(codH.Text)); if (Int32.Parse(codE.Text) == emp.IDEmpregado) { dataGridView1.DataSource = ControlaEmpregados.RegistoEmpregado(Int32.Parse(codE.Text), Int32.Parse(codH.Text)); } else { MessageBox.Show("Empregado não existe!"); } } else { MessageBox.Show("Campos por preencher!!!"); } }
public static void Main(string[] args) { int test = 1; string name; string lastName; double salary; // Cria duas instancis da classe Empregado Kamila = new Empregado("Kamila", "Fagundes", 1045); Empregado Izabella = new Empregado("Izabella", "Freire", 4000); // Passa um novo valor de salario para o objeto Kamila Kamila.monthlySalary = 2000; // Acessa o metodo estatico dentro da classe Kamila.monthlySalary = Empregado.increasesSalary(Kamila.monthlySalary); Console.WriteLine(Kamila.monthlySalary); // Mostra o salario anual de cada instancia Console.WriteLine("Salario anual Kamila: {0}", Kamila.monthlySalary * 12); Console.WriteLine("Salario anual Izabella: {0}", Izabella.monthlySalary * 12); }
public ActionResult Atualizar(Empregado empregado) { if (ModelState.IsValid) { try { EmpregadoBusiness.Alterar(empregado); Extensions.GravaCookie("MensagemSucesso", "O empregado '" + empregado.Nome + "' foi atualizado com sucesso.", 10); return(Json(new { resultado = new RetornoJSON() { URL = Url.Action("Index", "Empregado") } })); } catch (Exception ex) { if (ex.GetBaseException() == null) { return(Json(new { resultado = new RetornoJSON() { Erro = ex.Message } })); } else { return(Json(new { resultado = new RetornoJSON() { Erro = ex.GetBaseException().Message } })); } } } else { return(Json(new { resultado = TratarRetornoValidacaoToJSON() })); } }
private void Manipular(char opc) { empregado = new Empregado(); empregadoObjeto = new EmpregadoObjeto(); try { empregadoObjeto.Id = empregadoId; empregadoObjeto.Matricula = txtMatricula.Text.Trim(); empregadoObjeto.Nome = TxtNome.Text.Trim(); empregadoObjeto.Admissao = DateTime.Parse(MktAdmissao.Text.Trim()); empregadoObjeto.Demissao = DateTime.Parse(MktDemissao.Text.Trim()); empregadoObjeto.Media = decimal.Parse(TxtMedia.Text.Trim()); empregadoObjeto.Base = int.Parse(TxtDiasBase.Text.Trim()); switch (opc) { case 'G': empregado.Gravar(empregadoObjeto); break; case 'A': empregado.Alterar(empregadoObjeto); break; case 'E': empregado.Excluir(empregadoObjeto); break; default: break; } ListarEmpregados(); Reset(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public bool Alterar(Empregado empregado) { crud = new CRUD(); SQL = "UPDATE Empregado SET Nome = @Nome, Ativo = @Ativo, Id_Empresa = @Id_Empresa, Id_Departamento = @Id_Departamento " + "WHERE Id = @Id"; try { crud.LimparParametros(); crud.AdicionarParametros("Nome", empregado.Nome); crud.AdicionarParametros("Ativo", empregado.Ativo); crud.AdicionarParametros("Id_Empresa", empregado.Empresa.Id); crud.AdicionarParametros("Id_Departamento", empregado.Departamento.Id); crud.AdicionarParametros("Id", empregado.Id); crud.Executar(CommandType.Text, SQL); return(true); } catch (Exception ex) { throw new Exception(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { //Carregar as UF no DropDown if (!IsPostBack) { if (Request.QueryString["id"] != null) { Empregado lEmpregado = EmpregadoBLL.Instance.BuscarPorId(Convert.ToInt32(Request.QueryString["id"])); lblNomeEmpregado.Text = lEmpregado.Nome; lblCpfEmpregado.Text = lEmpregado.Cpf; List <EventoFolha> lListaEnventoFolha = EventoFolhaBLL.Instance.Listar(); foreach (EventoFolha lEventoFolha in lListaEnventoFolha) { DropDownEventos.Items.Add(new ListItem(lEventoFolha.Descricao, lEventoFolha.Id.ToString())); } } else { Page.Response.Redirect("Listar.aspx"); } } }
public ActionResult Atualizar(Empregado empregado) { if (ModelState.IsValid) { try { //empregado.UsuarioExclusao = CustomAuthorizationProvider.UsuarioAutenticado.Usuario.Login; EmpregadoBusiness.Alterar(empregado); TempData["MensagemSucesso"] = "O empregado '" + empregado.Nome + "' foi atualizado com sucesso."; return(Json(new { resultado = new RetornoJSON() { URL = Url.Action("Index", "Empregado") } })); } catch (Exception ex) { if (ex.GetBaseException() == null) { return(Json(new { resultado = new RetornoJSON() { Erro = ex.Message } })); } else { return(Json(new { resultado = new RetornoJSON() { Erro = ex.GetBaseException().Message } })); } } } else { return(Json(new { resultado = TratarRetornoValidacaoToJSON() })); } }
public string GerarTxt(ContraCheque pContraCheque) { Empregado lEmpregado = pContraCheque.Empregado; string lBanco = lEmpregado.ContaBancaria.Agencia.Banco.Codigo; string lAgencia = lEmpregado.ContaBancaria.Agencia.Codigo; string lConta = lEmpregado.ContaBancaria.Numero + "-" + lEmpregado.ContaBancaria.Digito; string lCpf = lEmpregado.Cpf; string lNome = lEmpregado.Nome; string lValor = pContraCheque.ValorLiquido.ToString(); string lTipo = "P"; string[] lLinhas = { lBanco, lAgencia, lConta, lCpf, lNome, lValor, lTipo }; string lNomeArquivo = pContraCheque.Id + "-" + pContraCheque.Data.ToString(@"dd-MM-yyyy") + lEmpregado.Nome + ".txt"; string lDiretorio = @"C:\Treinamento\source\Arquivos\ContraCheque\"; try { if (!(Directory.Exists(lDiretorio))) { Directory.CreateDirectory(lDiretorio); } if (!(File.Exists(lDiretorio + lNomeArquivo))) { File.WriteAllLines(lDiretorio + lNomeArquivo, lLinhas); return(lDiretorio + lNomeArquivo); } else { return(lDiretorio + lNomeArquivo); throw new ErrorException("Ja existe um Arquivo salvo para este documento!"); } } catch (Exception ex) { throw new OperacaoNaoRealizadaException(); } }
public ActionResult Cadastrar(Empregado empregado) { if (ModelState.IsValid) { try { EmpregadoBusiness.Inserir(empregado); TempData["MensagemSucesso"] = "O empregado '" + empregado.Nome + "' foi cadastrado com sucesso."; return(Json(new { resultado = new RetornoJSON() { URL = Url.Action("ListaEmpregado", "Empregado", new { id = empregado.IDEmpregado }) } })); } catch (Exception ex) { if (ex.GetBaseException() == null) { return(Json(new { resultado = new RetornoJSON() { Erro = ex.Message } })); } else { return(Json(new { resultado = new RetornoJSON() { Erro = ex.GetBaseException().Message } })); } } } else { return(Json(new { resultado = TratarRetornoValidacaoToJSON() })); } }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { var nome = this.Nome.Text; var idade = int.Parse(this.Idade.Text); using (SessionNoServer session = new SessionNoServer("OODBMS_FOLDER")) { try { session.BeginUpdate(); var empregado = new Empregado(nome, idade, Guid.NewGuid().ToString()); session.Persist(empregado); session.Commit(); } catch (Exception ex) { session.Abort(); return; } } this.Close(); }
public ContraCheque GerarContraCheque(Empregado pEmpregado, DateTime pDataReferencia) { if (pEmpregado.Id >= 1 && pDataReferencia > pEmpregado.DataAdmissao) { foreach (ContraCheque lCH in pEmpregado.ContraCheques) { if (lCH.Data == pDataReferencia) { throw new OperacaoNaoRealizadaException(); } } ContraCheque lContraCheque = new ContraCheque(); lContraCheque.Data = pDataReferencia; lContraCheque.Empregado = pEmpregado; ContraChequeBLL.Instance.CalcularFolhaEvento(lContraCheque); ContraChequeBLL.Instance.CalcularValorLiquido(lContraCheque); return(lContraCheque); } else { throw new OperacaoNaoRealizadaException(); } }
public async Task <ActionResult> Create([Bind("ProdutoId,Nome,Descricao,Preco,UrlImagem,EmpregadoId")] Produto produto) { try { //email do user logado var email = User.FindFirstValue(ClaimTypes.Name); //Passa o id do Empregado logado para o produto a ser criado (caso este empregado exista na BD) int empregadoId = await EmpregadosController.GetUserId(email); if (empregadoId != -1) { produto.EmpregadoId = empregadoId; } //caso o empregado nao exista, cria uma entrada na BD para esse empregado e passa o seu id para o empregado do produto a ser criado else { Empregado newEmpregado = new Empregado { Email = email, Nome = email }; produto.EmpregadoId = await EmpregadosController.CreateNew(newEmpregado); } HttpClient client = new HttpClient(); var jsonObj = System.Text.Json.JsonSerializer.Serialize(produto); var content = new StringContent(jsonObj, Encoding.UTF8, "application/json"); var RespostaHTTP = await client.PostAsync(endpoint + "/api/Produtos", content); var dadosJSON = await RespostaHTTP.Content.ReadAsStringAsync(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public void AlterarChefiar(Empregado empregado) { UtilBD banco = new UtilBD(); MySqlConnection conexao = banco.ObterConexao(); try { MySqlCommand comando = new MySqlCommand(QUERY_UPDATE_CHEFIAR, conexao); comando.Parameters.AddWithValue("?codEmpregado", empregado.Codigo); comando.Parameters.AddWithValue("?codDepartamento", empregado.DepartamentoChefiado.Codigo); comando.Parameters.AddWithValue("?dataInicio", empregado.DataInicio); comando.Parameters.AddWithValue("?dataFinal", empregado.DataFinal); comando.Parameters.AddWithValue("?codEmpregado", empregado.Codigo); if (conexao.State == System.Data.ConnectionState.Closed) { conexao.Open(); } else { conexao.Close(); conexao.Open(); } int regitrosAfetados = comando.ExecuteNonQuery(); } catch (MySqlException e) { MessageBox.Show(e.Message); } finally { banco.FecharConexao(conexao); } }
//public void ChefiarRemoverChefiar(int codEmpregado) //{ // this.repEmpregado.RemoverChefiar(codEmpregado); //} #endregion #region IRepositorioEmpregado Tabela ALOCAR //public void AlocarInserirAlocar(Empregado empregado) //{ // this.repEmpregado.InserirAlocar(empregado); //} public Empregado AlocarConsultarPorCodigoEmpregadoAlocar(Empregado empregado) { return(this.repEmpregado.ConsultarPorCodigoEmpregadoAlocar(empregado)); }
public override int Calcular(Empregado empregado) { return (int) (ObterValorBase(empregado)*_bonus); }
public override bool Aplicavel(Empregado empregado) { return empregado.GetType() == _tipo; }
public override int Calcular(Empregado empregado) { const double bonus = 1.1; return (int)(ObterValorBase(empregado) * bonus); }
public abstract int Calcular(Empregado empregado);
public ActionResult BuscarQuestionarioFluidos(string UKFonteGeradora) { try { Empregado oEmpregado = EmpregadoBusiness.Consulta.FirstOrDefault(a => string.IsNullOrEmpty(a.UsuarioExclusao) && a.CPF.Trim().Replace(".", "").Replace("-", "").Equals(CustomAuthorizationProvider.UsuarioAutenticado.Login)); var UKEmpregado = oEmpregado.UniqueKey; ViewBag.UKEmpregado = UKEmpregado; ViewBag.UKFonteGeradora = UKFonteGeradora; Questionario oQuest = null; string sql = @"select q.UniqueKey, q.Nome, q.Tempo, q.Periodo, q.UKEmpresa, p.UniqueKey as UKPergunta, p.Descricao as Pergunta, p.TipoResposta, p.Ordem, tr.UniqueKey as UKTipoResposta, tr.Nome as TipoResposta, tri.Uniquekey as UKTipoRespostaItem, tri.nome as TipoRespostaItem from tbAdmissao a, tbQuestionario q left join tbPergunta p on q.UniqueKey = p.UKQuestionario and p.DataExclusao ='9999-12-31 23:59:59.997' left join tbTipoResposta tr on tr.UniqueKey = p.UKTipoResposta and tr.DataExclusao ='9999-12-31 23:59:59.997' left join tbTipoRespostaItem tri on tr.UniqueKey = tri.UKTipoResposta and tri.DataExclusao ='9999-12-31 23:59:59.997' where a.UKEmpregado = '" + UKEmpregado + @"' and a.DataExclusao = '9999-12-31 23:59:59.997' and a.UKEmpresa = q.UKEmpresa and q.DataExclusao = '9999-12-31 23:59:59.997' and q.TipoQuestionario = 10 and q.Status = 1 order by p.Ordem, tri.Ordem"; DataTable result = QuestionarioBusiness.GetDataTable(sql); if (result.Rows.Count > 0) { oQuest = new Questionario(); oQuest.UniqueKey = Guid.Parse(result.Rows[0]["UniqueKey"].ToString()); oQuest.Nome = result.Rows[0]["Nome"].ToString(); oQuest.Periodo = (EPeriodo)Enum.Parse(typeof(EPeriodo), result.Rows[0]["Periodo"].ToString(), true); oQuest.Tempo = int.Parse(result.Rows[0]["Tempo"].ToString()); oQuest.Perguntas = new List <Pergunta>(); oQuest.UKEmpresa = Guid.Parse(result.Rows[0]["UKEmpresa"].ToString()); //Guid UKEmp = Guid.Parse(UKEmpregado); //Guid UKFonte = Guid.Parse(UKFonteGeradora); string sql2 = @"select MAX(DataInclusao) as UltimoQuestRespondido from tbResposta where UKEmpregado = '" + UKEmpregado + @"' and UKQuestionario = '" + result.Rows[0]["UniqueKey"].ToString() + @"' and UKObjeto = '" + UKFonteGeradora + "'"; DataTable result2 = QuestionarioBusiness.GetDataTable(sql2); if (result2.Rows.Count > 0) { if (!string.IsNullOrEmpty(result2.Rows[0]["UltimoQuestRespondido"].ToString())) { DateTime UltimaResposta = (DateTime)result2.Rows[0]["UltimoQuestRespondido"]; DateTime DataAtualMenosTempoQuestionario = DateTime.Now.Date; var data = DateTime.Now.Date; if (UltimaResposta.Date.CompareTo(data) >= 0) { return(PartialView("_CheclistFluido")); } //if (oQuest.Periodo == EPeriodo.Dia) //{ // DataAtualMenosTempoQuestionario = DataAtualMenosTempoQuestionario.AddDays(-oQuest.Tempo); //} //else if (oQuest.Periodo == EPeriodo.Mes) //{ // DataAtualMenosTempoQuestionario = DataAtualMenosTempoQuestionario.AddMonths(-oQuest.Tempo); //} //else if (oQuest.Periodo == EPeriodo.Ano) //{ // DataAtualMenosTempoQuestionario = DataAtualMenosTempoQuestionario.AddYears(-oQuest.Tempo); //} //if (UltimaResposta.CompareTo(DataAtualMenosTempoQuestionario) >= 0) //{ // return PartialView("_BuscarAPR"); //} } } foreach (DataRow row in result.Rows) { if (!string.IsNullOrEmpty(row["UKPergunta"].ToString())) { if (!string.IsNullOrEmpty(row["UKPergunta"].ToString())) { Pergunta oPergunta = oQuest.Perguntas.FirstOrDefault(a => a.UniqueKey.ToString().Equals(row["UKPergunta"].ToString())); if (oPergunta == null) { oPergunta = new Pergunta() { UniqueKey = Guid.Parse(row["UKPergunta"].ToString()), Descricao = row["Pergunta"].ToString(), Ordem = int.Parse(row["Ordem"].ToString()), TipoResposta = (ETipoResposta)Enum.Parse(typeof(ETipoResposta), row["TipoResposta"].ToString(), true) }; if (!string.IsNullOrEmpty(row["UKTipoResposta"].ToString())) { TipoResposta oTipoResposta = new TipoResposta() { UniqueKey = Guid.Parse(row["UKTipoResposta"].ToString()), Nome = row["TipoResposta"].ToString(), TiposResposta = new List <TipoRespostaItem>() }; if (!string.IsNullOrEmpty(row["UKTipoRespostaItem"].ToString())) { TipoRespostaItem oTipoRespostaItem = new TipoRespostaItem() { UniqueKey = Guid.Parse(row["UKTipoRespostaItem"].ToString()), Nome = row["TipoRespostaItem"].ToString() }; oTipoResposta.TiposResposta.Add(oTipoRespostaItem); } oPergunta._TipoResposta = oTipoResposta; } oQuest.Perguntas.Add(oPergunta); } else { if (!string.IsNullOrEmpty(row["UKTipoRespostaItem"].ToString())) { TipoRespostaItem oTipoRespostaItem = new TipoRespostaItem() { UniqueKey = Guid.Parse(row["UKTipoRespostaItem"].ToString()), Nome = row["TipoRespostaItem"].ToString() }; oPergunta._TipoResposta.TiposResposta.Add(oTipoRespostaItem); } } } } } } return(PartialView("_CheclistFluido", oQuest)); } catch (Exception ex) { if (ex.GetBaseException() == null) { return(Json(new { resultado = new RetornoJSON() { Erro = ex.Message } })); } else { return(Json(new { resultado = new RetornoJSON() { Erro = ex.GetBaseException().Message } })); } } }
public override int Calcular(Empregado empregado) { return ObterValorBase(empregado); }
protected void BtnSalvar_Click(object sender, EventArgs e) { try { if (TxtNome.Text.Trim().Equals(String.Empty)) { TxtNome.Text = ""; TxtNome.Focus(); throw new CampoNaoInformadoException("Empregado", "Nome", true); } if (TxtCPF.Text.Trim().Equals(String.Empty)) { TxtCPF.Text = ""; TxtCPF.Focus(); throw new CampoNaoInformadoException("Empregado", "CPF", true); } if (txtDataAdmissao.Text.Trim().Equals(String.Empty)) { txtDataAdmissao.Text = ""; txtDataAdmissao.Focus(); throw new CampoNaoInformadoException("Empregado", "Data de Admissão", true); } if (TxtEndLogadouro.Text.Trim().Equals(String.Empty)) { TxtNome.Text = ""; TxtNome.Focus(); throw new CampoNaoInformadoException("Endereço", "Logadouro", true); } if (TxtEndNumero.Text.Trim().Equals(String.Empty)) { TxtNome.Text = ""; TxtNome.Focus(); throw new CampoNaoInformadoException("Endereço", "Numero", true); } if (TxtEndCep.Text.Trim().Equals(String.Empty)) { TxtNome.Text = ""; TxtNome.Focus(); throw new CampoNaoInformadoException("Endereço", "CEP", true); } Empregado lEmpregado = null; string mensagem = ""; if (Request.QueryString["id"] != null) { lEmpregado = EmpregadoBLL.Instance.BuscarPorId(Convert.ToInt32(Request.QueryString["id"])); mensagem = "Empregado alterada com sucesso."; } else { lEmpregado = new Empregado(); mensagem = "Empregado cadastrada com sucesso."; } Cidade lCidade = new Cidade(); lCidade = CidadeBLL.Instance.BuscarPorId(Convert.ToInt32(DropDownCidade.SelectedValue)); Endereco lEndereco = new Endereco(); lEndereco.Logradouro = TxtEndLogadouro.Text.Trim(); lEndereco.Numero = TxtEndNumero.Text.Trim(); lEndereco.Complemento = TxtEndComplemento.Text.Trim(); lEndereco.Cidade = lCidade; lEndereco.Cep = Convert.ToInt32(TxtEndCep.Text.Replace("-", "")); Banco lBanco = BancoBLL.Instance.BuscarPorId(Convert.ToInt32(DropDownBanco.SelectedValue)); Agencia lAgencia = AgenciaBLL.Instance.BuscarPorId(Convert.ToInt32(DropDownAgencia.SelectedValue)); TipoContaBancaria lTipoConta = TipoContaBancariaBLL.Instance.BuscarPorId(Convert.ToInt32(DropDownTipoConta.SelectedValue)); ContaBancaria lContaBancaria = new ContaBancaria(); lContaBancaria.Agencia = lAgencia; lContaBancaria.Tipo = lTipoConta; lContaBancaria.Numero = TxtConta.Text; lContaBancaria.Digito = TxtDigitoConta.Text; lEmpregado.Nome = TxtNome.Text.Trim(); lEmpregado.Endereco = lEndereco; lEmpregado.Cpf = TxtCPF.Text.Trim(); lEmpregado.DataAdmissao = DateTime.Parse(txtDataAdmissao.Text); lEmpregado.ContaBancaria = lContaBancaria; lEmpregado.SalarioBase = float.Parse(TxtSalarioBase.Text); EmpregadoBLL.Instance.Persistir(lEmpregado); Web.ExibeAlerta(Page, mensagem, "Listar.aspx"); } catch (BusinessException ex) { Web.ExibeAlerta(Page, ex.Message); } }
/// <summary> /// Devolve o codigo /// </summary> /// <param name="c"></param> /// <returns></returns> public int GetCode(Empregado e) { return(e.IDEmpregado); }
private void btnGravar_Click(object sender, EventArgs e) { bool validacao = true; if ((txtNome.Text.Trim() == "") && (validacao == true)) { validacao = false; tlMensagem.ToolTipTitle = "Campo inválido"; tlMensagem.Show("O nome não pode ser vazio", txtNome); txtNome.Focus(); txtNome.SelectAll(); } if ((!mskDataNascimento.MaskCompleted) && (validacao == true)) { validacao = false; tlMensagem.ToolTipTitle = "Campo inválido"; tlMensagem.Show("A data de Nascimento deve ser informada", mskDataNascimento); mskDataNascimento.Focus(); mskDataNascimento.SelectAll(); } if ((!mskRg.MaskCompleted) && (validacao == true)) { validacao = false; tlMensagem.ToolTipTitle = "Campo inválido"; tlMensagem.Show("O Rg deve ser informado", mskRg); mskRg.Focus(); mskRg.SelectAll(); } if ((!mskCpf.MaskCompleted) && (validacao == true)) { validacao = false; tlMensagem.ToolTipTitle = "Campo inválido"; tlMensagem.Show("O Cpf deve ser informado", mskCpf); mskCpf.Focus(); mskCpf.SelectAll(); } if ((Convert.ToDouble(txtSalario.Text) <= 0) && (validacao == true)) { validacao = false; tlMensagem.ToolTipTitle = "Campo inválido"; tlMensagem.Show("O salário deve ser informado com um valor maior que zero", txtSalario); txtSalario.Focus(); txtSalario.SelectAll(); } if ((!mskCep.MaskCompleted) && (validacao == true)) { validacao = false; tlMensagem.ToolTipTitle = "Campo inválido"; tlMensagem.Show("O Cep deve ser informado", mskCep); mskCep.Focus(); mskCep.SelectAll(); } if (validacao) { switch (status.StatusAtual()) { case "Alteração": { empregadoAtual.Endereco.Bairro = txtBairro.Text; empregadoAtual.Endereco.Cep = Convert.ToInt32(mskCep.Text); empregadoAtual.Endereco.Cidade = txtCidade.Text; empregadoAtual.Endereco.Complemento = txtComplemento.Text; empregadoAtual.Endereco.Logradouro = txtLogradouro.Text; empregadoAtual.Endereco.Numero = txtNumero.Text; empregadoAtual.Endereco.Pais = txtPais.Text; empregadoAtual.Endereco.Uf = (cmbUf.Text); empregadoAtual.Nome = txtNome.Text; empregadoAtual.Nome = txtNome.Text; empregadoAtual.Rg = mskRg.Text; empregadoAtual.Salario = Convert.ToDouble(txtSalario.Text); empregadoAtual.Supervisor = null; empregadoAtual.DepartamentoAlocado = null; empregadoAtual.DepartamentoChefiado = null; if (rdSexoMasculino.Checked) { empregadoAtual.Sexo = 'M'; } else { empregadoAtual.Sexo = 'F'; } if (lstSupervisor.Items.Count > 0) { empregadoAtual.Supervisor = (Empregado)lstSupervisor.Items[0]; } empregadoAtual.Telefone = mskTelefone.Text; empregadoAtual.Cpf = mskCpf.Text; if (mskDataNascimento.MaskCompleted) { empregadoAtual.DataNascimento = Convert.ToDateTime(mskDataNascimento.Text); } else { empregadoAtual.DataNascimento = Convert.ToDateTime("01/01/0001"); } if (lstAlocar.Items.Count > 0) { empregadoAtual.DepartamentoAlocado = (Departamento)lstAlocar.Items[0]; if (mskDataAlocacao.MaskCompleted) { empregadoAtual.DataAlocação = Convert.ToDateTime(mskDataAlocacao.Text); } else { empregadoAtual.DataAlocação = Convert.ToDateTime("01/01/0001"); } } if (lstChefiar.Items.Count > 0) { empregadoAtual.DepartamentoChefiado = (Departamento)lstChefiar.Items[0]; if (mskDataInicio.MaskCompleted) { empregadoAtual.DataInicio = Convert.ToDateTime(mskDataInicio.Text); } else { empregadoAtual.DataInicio = Convert.ToDateTime("01/01/0001"); } if (mskDataFinal.MaskCompleted) { empregadoAtual.DataFinal = Convert.ToDateTime(mskDataFinal.Text); } else { empregadoAtual.DataFinal = Convert.ToDateTime("01/01/0001"); } } controlador.EmpregadoAlterarEmpregado(empregadoAtual); break; } case "Inclusão": { Empregado emp = new Empregado(); Endereco endereco = new Endereco(); endereco.Bairro = txtBairro.Text; endereco.Cep = Convert.ToInt32(mskCep.Text); endereco.Cidade = txtCidade.Text; endereco.Complemento = txtComplemento.Text; endereco.Logradouro = txtLogradouro.Text; endereco.Numero = txtNumero.Text; endereco.Pais = txtPais.Text; endereco.Uf = (cmbSupervisor.Text); emp.Endereco = endereco; emp.Nome = txtNome.Text; emp.Rg = mskRg.Text; emp.Salario = Convert.ToDouble(txtSalario.Text); emp.Supervisor = null; emp.DepartamentoAlocado = null; emp.DepartamentoChefiado = null; if (rdSexoMasculino.Checked) { emp.Sexo = 'M'; } else { emp.Sexo = 'F'; } if (lstSupervisor.Items.Count > 0) { emp.Supervisor = (Empregado)lstSupervisor.Items[0]; } emp.Telefone = mskTelefone.Text; emp.Cpf = mskCpf.Text; if (mskDataNascimento.MaskCompleted) { emp.DataNascimento = Convert.ToDateTime(mskDataNascimento.Text); } else { emp.DataNascimento = Convert.ToDateTime("01/01/0001"); } if (lstAlocar.Items.Count > 0) { emp.DepartamentoAlocado = (Departamento)lstAlocar.Items[0]; if (mskDataAlocacao.MaskCompleted) { emp.DataAlocação = Convert.ToDateTime(mskDataAlocacao.Text); } else { emp.DataAlocação = Convert.ToDateTime("01/01/0001"); } } if (lstChefiar.Items.Count > 0) { emp.DepartamentoChefiado = (Departamento)lstChefiar.Items[0]; if (mskDataInicio.MaskCompleted) { emp.DataInicio = Convert.ToDateTime(mskDataInicio.Text); } else { emp.DataInicio = Convert.ToDateTime("01/01/0001"); } if (mskDataFinal.MaskCompleted) { emp.DataFinal = Convert.ToDateTime(mskDataFinal.Text); } else { emp.DataFinal = Convert.ToDateTime("01/01/0001"); } } controlador.EmpregadoInserirEmpregado(emp); break; } } status.Navegando(); AjustaBotoes(); } }
/// <summary> /// Adiciona empregado validando o login /// </summary> /// <param name="e"></param> /// <param name="cod"></param> /// <param name="user"></param> /// <param name="pw"></param> /// <returns></returns> static public bool AddEmpregado(Empregado e, int cod) { return(Hoteis.AddEmpregado(e, cod)); }
private void AjustaEdits() { if (pesquisando == false) { empregados = controlador.EmpregadoConsultarTodos(); } else { empregados = controlador.EmpregadoConsultarPorNome(txtLocalizar.Text); } bsEmpregado.DataSource = empregados; supervisores = controlador.EmpregadoConsultarTodos(); if (supervisores.Count > 0) { cmbSupervisor.DataSource = supervisores; cmbSupervisor.DisplayMember = "Nome"; cmbSupervisor.ValueMember = "Codigo"; lstSupervisor.DisplayMember = "Nome"; lstSupervisor.ValueMember = "Codigo"; } departamentosAlocados = controlador.DepartamentoConsultarTodos(); if (departamentosAlocados.Count > 0) { cmbAlocar.DataSource = departamentosAlocados; cmbAlocar.DisplayMember = "Nome"; cmbAlocar.ValueMember = "Codigo"; lstAlocar.DisplayMember = "Nome"; lstAlocar.ValueMember = "Codigo"; } departamentosChefiados = controlador.DepartamentoConsultarTodos(); if (departamentosChefiados.Count > 0) { cmbChefiar.DataSource = departamentosChefiados; cmbChefiar.DisplayMember = "Nome"; cmbChefiar.ValueMember = "Codigo"; lstChefiar.DisplayMember = "Nome"; lstChefiar.ValueMember = "Codigo"; } switch (status.StatusAtual()) { case "Inativa": { txtNome.ReadOnly = true; txtNome.Clear(); mskDataNascimento.ReadOnly = true; mskDataNascimento.Clear(); mskRg.ReadOnly = true; mskRg.Clear(); mskCpf.ReadOnly = true; mskCpf.Clear(); mskTelefone.ReadOnly = true; mskTelefone.Clear(); txtSalario.ReadOnly = true; txtSalario.Text = "0"; cmbSupervisor.Enabled = false; lstSupervisor.Enabled = false; txtLogradouro.ReadOnly = true; txtLogradouro.Clear(); txtNumero.ReadOnly = true; txtNumero.Clear(); txtComplemento.ReadOnly = true; txtComplemento.Clear(); txtBairro.ReadOnly = true; txtBairro.Clear(); txtCidade.ReadOnly = true; txtCidade.Clear(); cmbUf.Enabled = false; txtPais.ReadOnly = true; txtPais.Clear(); mskCep.ReadOnly = true; mskCep.Clear(); cmbAlocar.Enabled = false; lstAlocar.Enabled = false; mskDataAlocacao.ReadOnly = true; mskDataAlocacao.Clear(); cmbChefiar.Enabled = false; lstChefiar.Enabled = false; mskDataInicio.ReadOnly = true; mskDataInicio.Clear(); mskDataFinal.ReadOnly = true; mskDataFinal.Clear(); break; } case "Inclusão": { txtNome.ReadOnly = false; txtNome.Clear(); mskDataNascimento.ReadOnly = false; mskDataNascimento.Clear(); mskRg.ReadOnly = false; mskRg.Clear(); mskCpf.ReadOnly = false; mskCpf.Clear(); mskTelefone.ReadOnly = false; mskTelefone.Clear(); txtSalario.ReadOnly = false; txtSalario.Text = "0"; cmbSupervisor.Enabled = true; lstSupervisor.Enabled = true; lstSupervisor.Items.Clear(); txtLogradouro.ReadOnly = false; txtLogradouro.Clear(); txtNumero.ReadOnly = false; txtNumero.Clear(); txtComplemento.ReadOnly = false; txtComplemento.Clear(); txtBairro.ReadOnly = false; txtBairro.Clear(); txtCidade.ReadOnly = false; txtCidade.Clear(); cmbUf.Enabled = true; txtPais.ReadOnly = false; txtPais.Clear(); mskCep.ReadOnly = false; mskCep.Clear(); cmbAlocar.Enabled = true; lstAlocar.Enabled = true; lstAlocar.Items.Clear(); mskDataAlocacao.ReadOnly = false; mskDataAlocacao.Clear(); cmbChefiar.Enabled = true; lstChefiar.Enabled = true; lstChefiar.Items.Clear(); mskDataInicio.ReadOnly = false; mskDataInicio.Clear(); mskDataFinal.ReadOnly = false; mskDataFinal.Clear(); break; } case "Alteração": { txtNome.ReadOnly = false; mskDataNascimento.ReadOnly = false; mskRg.ReadOnly = false; mskCpf.ReadOnly = false; mskTelefone.ReadOnly = false; txtSalario.ReadOnly = false; cmbSupervisor.Enabled = true; lstSupervisor.Enabled = true; txtLogradouro.ReadOnly = false; txtNumero.ReadOnly = false; txtComplemento.ReadOnly = false; txtBairro.ReadOnly = false; txtCidade.ReadOnly = false; cmbUf.Enabled = true; txtPais.ReadOnly = false; mskCep.ReadOnly = false; cmbAlocar.Enabled = true; lstAlocar.Enabled = true; mskDataAlocacao.ReadOnly = false; cmbChefiar.Enabled = true; lstChefiar.Enabled = true; mskDataInicio.ReadOnly = false; mskDataFinal.ReadOnly = false; break; } case "Navegação": { txtNome.ReadOnly = true; txtNome.Clear(); mskDataNascimento.ReadOnly = true; mskDataNascimento.Clear(); mskRg.ReadOnly = true; mskRg.Clear(); mskCpf.ReadOnly = true; mskCpf.Clear(); mskTelefone.ReadOnly = true; mskTelefone.Clear(); txtSalario.ReadOnly = true; txtSalario.Text = "0"; cmbSupervisor.Enabled = false; lstSupervisor.Enabled = false; lstSupervisor.Items.Clear(); txtLogradouro.ReadOnly = true; txtLogradouro.Clear(); txtNumero.ReadOnly = true; txtNumero.Clear(); txtComplemento.ReadOnly = true; txtComplemento.Clear(); txtBairro.ReadOnly = true; txtBairro.Clear(); txtCidade.ReadOnly = true; txtCidade.Clear(); cmbUf.Enabled = false; txtPais.ReadOnly = true; txtPais.Clear(); mskCep.ReadOnly = true; mskCep.Clear(); cmbAlocar.Enabled = false; lstAlocar.Enabled = false; lstAlocar.Items.Clear(); mskDataAlocacao.ReadOnly = true; mskDataAlocacao.Clear(); cmbChefiar.Enabled = false; lstChefiar.Enabled = false; lstChefiar.Items.Clear(); mskDataInicio.ReadOnly = true; mskDataInicio.Clear(); mskDataFinal.ReadOnly = true; mskDataFinal.Clear(); if (bsEmpregado.Count > 0) { empregadoAtual = (Empregado)empregados[bsEmpregado.Position]; txtNome.Text = empregadoAtual.Nome; if (empregadoAtual.DataNascimento != Convert.ToDateTime("01/01/0001")) { mskDataNascimento.Text = empregadoAtual.DataNascimento + ""; } mskRg.Text = empregadoAtual.Rg; mskCpf.Text = empregadoAtual.Cpf; mskTelefone.Text = empregadoAtual.Telefone; txtSalario.Text = empregadoAtual.Salario + ""; if (empregadoAtual.Supervisor != null) { lstSupervisor.Items.Add(empregadoAtual.Supervisor); } if (empregadoAtual.Sexo.Equals('M')) { rdSexoMasculino.Checked = true; } else { rdSexoFeminino.Checked = true; } txtLogradouro.Text = empregadoAtual.Endereco.Logradouro; txtNumero.Text = empregadoAtual.Endereco.Numero; txtComplemento.Text = empregadoAtual.Endereco.Complemento; txtBairro.Text = empregadoAtual.Endereco.Bairro; txtCidade.Text = empregadoAtual.Endereco.Cidade; cmbUf.Text = empregadoAtual.Endereco.Uf; txtPais.Text = empregadoAtual.Endereco.Pais; mskCep.Text = empregadoAtual.Endereco.Cep + ""; if (empregadoAtual.DepartamentoAlocado != null) { lstAlocar.Items.Add(empregadoAtual.DepartamentoAlocado); if (empregadoAtual.DataAlocação != Convert.ToDateTime("01/01/0001")) { mskDataAlocacao.Text = empregadoAtual.DataAlocação + ""; } } if (empregadoAtual.DepartamentoChefiado != null) { lstChefiar.Items.Add(empregadoAtual.DepartamentoChefiado); if (empregadoAtual.DataInicio != Convert.ToDateTime("01/01/0001")) { mskDataInicio.Text = empregadoAtual.DataInicio + ""; } if (empregadoAtual.DataFinal != Convert.ToDateTime("01/01/0001")) { mskDataFinal.Text = empregadoAtual.DataFinal + ""; } } //AjustarSupervisor(); } lbInformacao.Text = "Quantidades de Empregados cadastrados: " + bsEmpregado.Count; break; } } }
public override void OnAuthorization(HttpActionContext actionContext) { // validar se foi informado no cabeçalho da mensagem o parâmetro de autenticação. if (actionContext.Request.Headers.Authorization == null) { // responde para o cliente como não autorizado var dnsHost = actionContext.Request.RequestUri.DnsSafeHost; actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized); actionContext.Response.Headers.Add("WWW-Authenticate", string.Format("Basic realm=\"{0}\"", dnsHost)); return; } else { //obtém o parâmetro (token de autenticação) string tokenAutenticacao = actionContext.Request.Headers.Authorization.Parameter; // decodifica o parâmetro, pois ele deve vir codificado em base 64 string decodedTokenAutenticacao = Encoding.Default.GetString(Convert.FromBase64String(tokenAutenticacao)); // obtém o login e senha (usuario:senha) string[] userNameAndPassword = decodedTokenAutenticacao.Split(':'); // validar as credenciais obtidas com as cadastradas no sistema Empregado empregado = null; if (ValidarUsuario(userNameAndPassword[0], userNameAndPassword[1], out empregado)) { string[] papeis = new string[1]; papeis[0] = empregado.Permissao; var identidade = new GenericIdentity(empregado.Email); var genericUser = new GenericPrincipal(identidade, papeis); // confere o perfil da action com os do usuário if (string.IsNullOrEmpty(Roles)) { // atribui o usuário informado no contexto da requisição atual Thread.CurrentPrincipal = genericUser; if (HttpContext.Current != null) { HttpContext.Current.User = genericUser; } return; } else { var currentRoles = Roles.Split(','); foreach (var currentRole in currentRoles) { if (genericUser.IsInRole(currentRole)) { // atribui o usuário informado no contexto da requisição atual Thread.CurrentPrincipal = genericUser; if (HttpContext.Current != null) { HttpContext.Current.User = genericUser; } return; } } } } } actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized, new { mensagens = new string[] { "Usuário ou senha inválidos." } }); }
public ActionResult RecoFaceUploadEPI(Arquivo arquivo, string UKFichaDeEPI, string UKEmpregado, string UKProduto) { try { Guid UKemp = Guid.Parse(UKEmpregado); Empregado empregado = EmpregadoBusiness.Consulta.FirstOrDefault(a => string.IsNullOrEmpty(a.UsuarioExclusao) && a.UniqueKey.Equals(UKemp)); var nome = empregado.Nome.Trim().Replace(" ", "") + ".jpg"; string Semelhanca = string.Empty; String resultado = string.Empty; HttpPostedFileBase arquivoPostado = null; foreach (string fileInputName in Request.Files) { arquivoPostado = Request.Files[fileInputName]; var target = new MemoryStream(); arquivoPostado.InputStream.CopyTo(target); arquivo.Conteudo = target.ToArray(); arquivo.UsuarioInclusao = CustomAuthorizationProvider.UsuarioAutenticado.Login; arquivo.DataInclusao = DateTime.Now; arquivo.Extensao = Path.GetExtension(arquivoPostado.FileName); arquivo.NomeLocal = arquivoPostado.FileName; byte[] inputImageData = arquivo.Conteudo; var inputImageStream = new MemoryStream(inputImageData); var item = arquivo.Conteudo; var input = arquivo.NomeLocal; var rekognitionClient = new AmazonRekognitionClient("AKIAIBLZ7KFAN6XG3NNA", "2nukFOTDN0zv/y2tzeCiLrAHM5TwbFgvEqqZA9zn", RegionEndpoint.USWest2); Image image = new Image() { Bytes = inputImageStream }; SearchFacesByImageRequest searchFacesByImageRequest = new SearchFacesByImageRequest() { CollectionId = "GrupoCEI", Image = image, FaceMatchThreshold = 70F, MaxFaces = 2 }; var contaFace = 0; try { SearchFacesByImageResponse searchFacesByImageResponse = rekognitionClient.SearchFacesByImage(searchFacesByImageRequest); List <FaceMatch> faceMatches = searchFacesByImageResponse.FaceMatches; BoundingBox searchedFaceBoundingBox = searchFacesByImageResponse.SearchedFaceBoundingBox; float searchedFaceConfidence = searchFacesByImageResponse.SearchedFaceConfidence; if (faceMatches.Count == 0) { contaFace = 2; } if (faceMatches.Count > 0) { foreach (FaceMatch face in faceMatches) { if (face != null && face.Face.ExternalImageId == nome) { //Extensions.GravaCookie("MensagemSucesso", "Empregado identificado com: '" + face.Similarity + "'de semlhança.", 10); //return Json(new { sucesso = "O arquivo foi anexado com êxito." }); // return Json(new { resultado = new RetornoJSON() { URL = Url.Action("Index", "AnaliseDeRisco") } }); Semelhanca = face.Similarity.ToString(); resultado = face.Face.ExternalImageId.ToString(); contaFace = 1; var validacao = ValidacoesBusiness.Consulta.FirstOrDefault(a => string.IsNullOrEmpty(a.UsuarioExclusao) && a.Registro.Equals(arquivo.NumRegistro) && a.NomeIndex.Equals(face.Face.ExternalImageId)); if (validacao == null) { ValidacaoFichaDeEpi val = new ValidacaoFichaDeEpi() { UKFichaDeEPI = Convert.ToString(arquivo.UKObjeto), NomeIndex = face.Face.ExternalImageId, }; ValidacaoFichaDeEpiBusiness.Inserir(val); } else { contaFace = 4; throw new Exception("Empregado já validou este documento!"); } } else { contaFace = 3; throw new Exception("Empregado com Nome diferente!"); } } Extensions.GravaCookie("MensagemSucesso", "Empregado '" + resultado + "' identificado com: '" + Semelhanca + "' de semelhança.", 10); } else { throw new Exception("Empregado não encontrado!"); } } catch (Exception) { if (contaFace == 2) { throw new Exception("Empregado não encontrado!"); } if (contaFace == 3) { throw new Exception("A imagem não corresponde com o empregado atual"); } if (contaFace == 4) { throw new Exception("Empregado já validou este documento!"); } else { throw new Exception("Essa não é uma imagem válida!"); } } } if (Semelhanca != null) { return(Json(new { sucesso = "O Empregado '" + resultado + "' foi analisado com êxito." })); } else { return(Json(new { sucesso = "Empregado não encontrado!" })); } } catch (Exception ex) { return(Json(new { erro = ex.Message })); } }
public static async Task Main(string[] args) { do { var builder = new ConfigurationBuilder().AddJsonFile("appsettings.json"); var config = builder.Build(); TelemetryConfiguration telemetryConfig = TelemetryConfiguration.CreateDefault(); telemetryConfig.InstrumentationKey = config.GetSection("ApplicationInsights:InstrumentationKey").Value; TelemetryClient telemetryClient = new TelemetryClient(telemetryConfig); try { Setup.SetCulture(); AzureFileStorageClient fileStorageClient = new AzureFileStorageClient(); var cloudFiles = await fileStorageClient.GetFiles(); //if (Directory.Exists(config["FilesDirectory"])) //{ // DirectoryInfo dirInfo = new DirectoryInfo(config["FilesDirectory"]); foreach (CloudFile cloudFile in cloudFiles) { //var lines = File.ReadLines(filePath); //string lines = cloudFile.DownloadTextAsync().Result; FileInfo f = new FileInfo(Path.Combine(@"D:\OneDrive\Novo", Path.GetFileName(cloudFile.Name) + "111.txt")); //File.Create(Path.Combine(@"\\FELIPE-DELLG7\Temp\", Path.GetFileName(cloudFile.Name))); if (File.Exists(f.FullName)) { StreamReader stream = new StreamReader(f.FullName); //using (var stream = await cloudFile.OpenReadAsync()) { int count = 0; bool isContent; string line; //if (lineCount > 2) //{ //using (StreamReader reader = new StreamReader(stream)) //{ while (!stream.EndOfStream) { Console.WriteLine(); line = stream.ReadLine(); count++; isContent = count > 1; if (isContent) { string realFileName = cloudFile.Name.Substring(cloudFile.Name.LastIndexOf("/") + 1); Empregado empregado = new Empregado(line, count, realFileName); Console.WriteLine(string.Format("Fim do processamento da linha {0}", count)); } } //Console.WriteLine("Fim do processamento do arquivo \"{0}\"", cloudFile.Name); //} //} //else //{ // throw new FileLoadException("O arquivo não pode ser processado pois deve conter no mínimo três linhas: header, conteúdo e trailer."); //} } stream.Close(); // se sucesso string newFileName = Path.GetFileName(cloudFile.Name) + "111.txt"; string originPath = Path.Combine(@"D:\OneDrive\Novo", newFileName); string destinationPath = Path.Combine(@"D:\OneDrive\Parcialmentebemsucedido", newFileName); File.Move(originPath, destinationPath); } //File.Move(Path.Combine(@"\\FELIPE-DELLG7\Temp\", Path.GetFileName(cloudFile.Name)), Path.Combine(@"\\FELIPE-DELLG7\Temp2\", Path.GetFileName(cloudFile.Name))); } //Console.ReadKey(); } catch (Exception ex) { telemetryClient.TrackException(ex); } Thread.Sleep(1000); } while (true); }
public override bool Aplicavel(Empregado empregado) { return empregado is Gerente; }
public async void AddAsync(Empregado empregado) { await _mapper.InsertAsync(empregado); }
protected int ObterValorBase(Empregado empregado) { return empregado.CalcularFerias() * 100; }
public override bool Aplicavel(Empregado empregado) { return empregado is Desenvolvedor; }
public abstract bool Aplicavel(Empregado empregado);
public List <Empregado> GetAllEmployee(Action <int, int> progressCallback) { List <Empregado> ret = new List <Empregado>(); cancelOperation = false; string resp = server.DoGetRequest(baseAddress + "MT/Employee/GetAll"); Match m = Regex.Match(resp, @"ENROLLED EMPLOYEES:(\d+);"); if (!m.Success) { throw new Exception("Resposta inválida"); } int total = int.Parse(m.Groups[1].Value); int read = 0; bool stop = false; int tries = 0; int maxTries = 3; while (!stop) { try { if (cancelOperation) { tries = maxTries; throw new Exception("Operação cancelada"); } string r = server.DoGetRequest(baseAddress + "MT/Employee/GetNext"); int employees = 0; foreach (string l in r.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)) { m = Regex.Match(l, @"(.+),(\d+),(\d+),(\d+),([0-9a-fA-F]+);"); if (m.Success) { Empregado e = new Empregado(); e.Nome = m.Groups[1].Value; e.PIS = m.Groups[2].Value; e.ID = m.Groups[3].Value; e.KBD = m.Groups[4].Value; e.CNTLS = m.Groups[5].Value; ret.Add(e); employees++; read++; } } if (progressCallback != null) { progressCallback(read, total); } stop = employees == 0; tries = 0; } catch (Exception ex) { tries++; if (tries > maxTries) { throw ex; } } } return(ret); }
public override bool Aplicavel(Empregado empregado) { return empregado.GetType() == typeof(Operario); }