public ActionResult Edit([Bind(Include = "Id,EmpresaID,Descricao,RiscoId,DanosSaude,RecomendacaoMedica")] Agente agente) { ViewBag.UsuarioLogado = Utils.User.GetCookieUsuarioLogado(Request, Session); if (!string.IsNullOrEmpty(ViewBag.UsuarioLogado)) { Utils.User.UsuarioLogado usuariologado = Utils.User.GetDadosUsuarioLogado(ViewBag.UsuarioLogado); ViewBag.ModuloFinanceiro = usuariologado.moduloFinanceiro; ViewBag.RuleAdmin = usuariologado.admin; ViewBag.RuleFinanceiro = usuariologado.RuleFinanceiro; ViewBag.RuleMovimentacao = usuariologado.RuleMovimentacao; ViewBag.RuleCadastro = usuariologado.RuleCadastro; if (ModelState.IsValid) { agente.RecomendacaoMedica = LibProdusys.FS(agente.RecomendacaoMedica); agente.Descricao = LibProdusys.FS(agente.Descricao); agente.DanosSaude = LibProdusys.FS(agente.DanosSaude); db.Entry(agente).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RiscoId = new SelectList(db.Riscos.OrderBy(x => x.Descricao), "ID", "Descricao", agente.RiscoId); ViewBag.EmpresaID = new SelectList(db.Empresas, "ID", "Razao", agente.EmpresaID); return(View(agente)); } else { TempData["MensagemRetorno"] = "Faça Login para continuar."; return(Redirect("~/Login")); } }
public ActionResult Edit(int?id) { ViewBag.UsuarioLogado = Utils.User.GetCookieUsuarioLogado(Request, Session); if (!string.IsNullOrEmpty(ViewBag.UsuarioLogado)) { Utils.User.UsuarioLogado usuariologado = Utils.User.GetDadosUsuarioLogado(ViewBag.UsuarioLogado); ViewBag.ModuloFinanceiro = usuariologado.moduloFinanceiro; ViewBag.RuleAdmin = usuariologado.admin; ViewBag.RuleFinanceiro = usuariologado.RuleFinanceiro; ViewBag.RuleMovimentacao = usuariologado.RuleMovimentacao; ViewBag.RuleCadastro = usuariologado.RuleCadastro; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Agente agente = db.Agentes.Find(id, usuariologado.empresaId); if (agente == null) { return(HttpNotFound()); } ViewBag.RiscoId = new SelectList(db.Riscos.OrderBy(x => x.Descricao), "ID", "Descricao", agente.RiscoId); ViewBag.EmpresaID = new SelectList(db.Empresas, "ID", "Razao", agente.EmpresaID); return(View(agente)); } else { TempData["MensagemRetorno"] = "Faça Login para continuar."; return(Redirect("~/Login")); } }
public BaseVerbale CreaDettaglio(long verbaleid) { VerbaleElezioneDomicilio domicilio = new VerbaleElezioneDomicilio(); long current = verbaleid; using (ComandoEntities entities = new ComandoEntities()) { this.violazione = entities.Violazione.Where(x => x.Verbale_Id == verbaleid).FirstOrDefault(); this.verbale = this.violazione.Verbale; this.trasgressore = this.verbale.Trasgressore; if (this.verbale.Agente != null) { this.agente1 = this.verbale.Agente; } if (this.verbale.Agente1 != null) { this.agente2 = this.verbale.Agente1; } this.avvocato = this.verbale.Avvocato; this.patente = this.trasgressore.Patente; if (this.veicolo.Id_Custode.HasValue) { object[] objArray2 = new object[] { this.veicolo.Id_Custode }; this.custode = entities.Custode.Find(objArray2); } return(Helper.RiempiCampi(this.verbale, this.agente1, this.agente2, this.violazione, this.trasgressore, this.patente, null, verbale.Veicolo, this.avvocato, this.veicolo.Proprietario, this.custode)); } }
//Metodo que se manda llamar cada frame public override void UpdateState(Agente agent) { //Si se detecto al agente if (agent.targetDetected) { agent.TransitionToState(agent.attackState); //Hacer la transicion al estado de atacar } else { //Sino, realizar el comportamiento de rotar //Esta linea es la que permite rotar de forma suave al agente, llendo de su rotación actual hacia el angulo indicado en el //arreglo, se le añade la variable de velocidad para la rotación agent.transform.rotation = Quaternion.Slerp(agent.transform.rotation, Quaternion.Euler(agent.angles[agent.angleIndex]), Time.deltaTime * agent.speedRotation); //Debug.Log(agent.transform.eulerAngles.y); //Mensaje en consola para ver los angulos //Si el agente llego a la rotación que se encuentra en el arreglo if (agent.transform.eulerAngles.y >= (agent.angles[agent.angleIndex].y - 1)) { agent.angleIndex = (agent.angleIndex + 1) % agent.angles.Length; //Pasar al siguiente angulo, recorriendo el arreglo de angulos, va a recorre siempre de 0 - el tamaño del arreglo agent.TransitionToState(agent.idleState); //Una vez llegado ahí queremos que espere un momento antes de rotar, por eso se hace la transición al estado Idle } } }
private void VerificarCargoESetor(Agente ag) { if (ag.Cargo.NomeCargo.Equals("Administrador")) { // Logar como Admin frmAdmin telaAdmin = new frmAdmin(ag); Close(); telaAdmin.Show(); } if (ag.Cargo.NomeCargo.Equals("Usuario")) { // Logar como Usuario VerificarPrimeiraSenha(ag); frmUsuario telaUsuario = new frmUsuario(ag); Close(); telaUsuario.ShowDialog(); } if (ag.Cargo.NomeCargo.Equals("Gestor")) { // Logar como Gestor VerificarPrimeiraSenha(ag); frmGestor telaGestor = new frmGestor(ag); Close(); telaGestor.ShowDialog(); } }
private void SetPosicionAgenteMapa(int fila, int columna) { if (Mapa[fila, columna].Agente != null) { this._agentes.Remove(Mapa[fila, columna].Agente); this.Cueva.Children.Remove(Mapa[fila, columna].Agente.Elemento); Mapa[fila, columna].Agente = null; } else { var elemento = new Image() { Name = "Robot", Source = new BitmapImage(new Uri(@"https://res.cloudinary.com/pixel-art/image/upload/v1554320836/robot/1466134-robot-pixel-art.png")), Margin = new Thickness(0.5), }; elemento.MouseLeftButtonUp += DeleteAgente; var agente = new Agente(_dimesionMapa, new Posicion(fila, columna), elemento, this); Mapa[fila, columna].Agente = agente; _agentes.Add(agente); Grid.SetRow(agente.Elemento, agente.Posicion.X); Grid.SetColumn(agente.Elemento, agente.Posicion.Y); this.Cueva.Children.Add(agente.Elemento); } }
public ActionResult save([FromBody] Agente a) { try { var exist = agenteServices.Exist(a.Nombre); if (exist) { return(BadRequest("Base ya Existe")); } var data = agenteServices.save(a); if (data) { return(Created("", data)); } else { return(Ok(data)); } } catch (Exception ex) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Internal Error")); } return(BadRequest()); }
public frmGestor(Object agenteLogado) { InitializeComponent(); AgenteLogado = (Agente)agenteLogado; Atualizar_dtaPedidosValidados_PorSetorEStatus(); Atualizar_dtaPedidoParaValidar_PorSetorEStatus(0); if (AgenteLogado.Setor.NomeSetor.Equals("Financeiro")) { // Gestor do Setor Financeiro btnCadOrcamento.Visibility = Visibility.Visible; btnVerificarCompras.Visibility = Visibility.Hidden; } else if (AgenteLogado.Setor.NomeSetor.Equals("Compras")) { // Gestor do Setor Compras btnCadOrcamento.Visibility = Visibility.Hidden; btnVerificarCompras.Visibility = Visibility.Visible; } else { // Outro Gestor btnCadOrcamento.Visibility = Visibility.Hidden; btnVerificarCompras.Visibility = Visibility.Hidden; } }
public async Task <ActionResult> Edit(int id) { if (id <= 0) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var agente = new Agente { AgenteId = id }; var agenteRequest = await ApiServicio.ObtenerElementoAsync1 <Response>(agente, new Uri(WebApp.BaseAddress), "api/Agentes/GetAgente"); if (!agenteRequest.IsSuccess) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var result = JsonConvert.DeserializeObject <Agente>(agenteRequest.Result.ToString()); ViewBag.SectorId = new SelectList(await obtenerSectoresPorEmpresa(), "SectorId", "NombreSector", result.SectorId); return(View(result)); }
public void Load(Verbale v) { if (v != null) { using (ComandoEntities entities = new ComandoEntities()) { this.violazione = entities.Violazione.Where(x => x.Verbale_Id == v.Id).FirstOrDefault(); if (v.Agente != null) { this.ControlAgente.agente1 = v.Agente1; } if (v.Agente1 != null) { this.ControlAgente.agente2 = v.Agente; } this.ControlAgente.verbale = v; this.ControlAgente.violazione = this.violazione; this.ControlAgente.LoadData(this.ControlAgente.agente1, this.ControlAgente.agente2, v, this.ControlAgente.violazione); if (v.Trasgressore != null) { this.ControlTrasgressore.LoadData(v.Trasgressore); } if (v.Avvocato != null) { this.ControlAvvocato.LoadData(v.Avvocato); } this.ViewState["idverbale"] = v.Id; base.idverbale.Value = v.Id.ToString(); } } }
/// <summary> /// Atualiza uma única entidade na posição respectiva na interface. /// </summary> /// <param name="entidade">Entidade para atualizar na interface.</param> /// <param name="coordenadas">Posição na interface.</param> private void AtualizaEntidade(Entidade entidade, Coordenadas coordenadas) { if (entidade is Lixo) { EntidadeUC entidadeUc = GetEntidade(coordenadas); Lixo lixo = entidade as Lixo; if (lixo.Tipo == TipoLixo.SECO) { entidadeUc.Tipo = Entidades.LIXO_SECO; } else if (lixo.Tipo == TipoLixo.ORGANICO) { entidadeUc.Tipo = Entidades.LIXO_ORGANICO; } } else if (entidade is Lixeira) { EntidadeUC entidadeUc = GetEntidade(coordenadas); Lixeira lixeira = entidade as Lixeira; if (lixeira.Tipo == TipoLixo.SECO) { entidadeUc.Tipo = Entidades.LIXEIRA_SECO; entidadeUc.QtdLixoSeco = lixeira.Lixos.Count; entidadeUc.CapacidadeMaximaLixoSeco = lixeira.CapacidadeMaxima; } else if (lixeira.Tipo == TipoLixo.ORGANICO) { entidadeUc.Tipo = Entidades.LIXEIRA_ORGANICO; entidadeUc.QtdLixoOrganico = lixeira.Lixos.Count; entidadeUc.CapacidadeMaximaLixoOrganico = lixeira.CapacidadeMaxima; } } else if (entidade is Agente) { EntidadeUC entidadeUc = GetEntidade(coordenadas); Agente agente = entidade as Agente; entidadeUc.Tipo = Entidades.AGENTE; entidadeUc.QtdLixoSeco = agente.SacoLixoSeco.Count; entidadeUc.CapacidadeMaximaLixoSeco = agente.CapacidadeMaximaLixoSeco; entidadeUc.QtdLixoOrganico = agente.SacoLixoOrganico.Count; entidadeUc.CapacidadeMaximaLixoOrganico = agente.CapacidadeMaximaLixoOrganico; entidadeUc.NumeroAgente = agente.Numero; } else if (entidade is Multiplo) { EntidadeUC entidadeUc = GetEntidade(coordenadas); entidadeUc.EntidadesMultiplo = (entidade as Multiplo).Entidades; entidadeUc.Tipo = Entidades.MULTIPLO; } else { EntidadeUC entidadeUc = GetEntidade(coordenadas); entidadeUc.Tipo = Entidades.NENHUM; } }
public async Task <ActionResult> Create(Agente agente) { if (!ModelState.IsValid) { ViewBag.SectorId = new SelectList(await obtenerSectoresPorEmpresa(), "SectorId", "NombreSector", agente.SectorId); return(View(agente)); } IdentityPersonalizado ci = (IdentityPersonalizado)HttpContext.User.Identity; string nombreUsuario = ci.Identity.Name; var administrador = new Administrador { Nombre = nombreUsuario }; administrador = await ProveedorAutenticacion.GetUser(administrador); var codificar = CodificarHelper.SHA512(new Codificar { Entrada = agente.Nombre }); agente.Contrasena = codificar.Salida; agente.EmpresaId = administrador.EmpresaId; var response = await ApiServicio.InsertarAsync(agente, new Uri(WebApp.BaseAddress), "api/Agentes/CreateAgente"); if (!response.IsSuccess) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } return(RedirectToAction("Index", "Agentes")); }
public ActionResult Create(Agente agente) { try { Agente agenteExistente = agentes.GetPass(agente.Mail); if (agenteExistente != null) { ViewBag.Error = "Ya existe un usuario con ese correo electrónico"; return(View(agente)); } agente.Salt = GenerarSalt(); agente.Clave = Convert.ToBase64String(KeyDerivation.Pbkdf2( password: agente.Clave, salt: System.Text.Encoding.ASCII.GetBytes(agente.Salt), prf: KeyDerivationPrf.HMACSHA1, iterationCount: 1000, numBytesRequested: 256 / 8)); agentes.Alta(agente); TempData["Id"] = agente.Id; return(RedirectToAction(nameof(Index))); } catch (Exception e) { TempData["Error"] = e.Message; return(View()); } }
public IQueryable <LlamadaPorAgente> GetLlamadasPorAgente() { List <LlamadaPorAgente> result = new List <LlamadaPorAgente>(); var llamadas = this.Context.Llamadas.Include("Extension").Include("Extension.StatusDeExtesion").Include("ColaDeServicio").ToList(); if (llamadas != null) { foreach (var llamada in llamadas) { Agente agente = GetAgenteByExtensionId(llamada.Extension.Id); if (agente != null) { result.Add(new LlamadaPorAgente { ID = llamada.Id, IdAgente = agente.Id, Agente = string.Format("{0} {1}", agente.Nombre, agente.Apellido), Status = llamada.Status, Inicio = llamada.Inicio.ToShortTimeString(), Fin = llamada.Fin.ToShortTimeString(), Tiempo = llamada.Fin == null ? "" : ((TimeSpan)(llamada.Fin - llamada.Inicio)).ToString(@"hh\:mm\:ss"), TiempoAsInt = llamada.Fin == null ? 0 : ((TimeSpan)(llamada.Fin - llamada.Inicio)).Seconds, Numero = llamada.Numero, Extension = llamada.Extension.Numero, FechaDesde = llamada.Inicio, FechaHasta = llamada.Fin, }); } } } return(result.AsQueryable <LlamadaPorAgente>()); }
public ReporteDiarioDTO(long agenteId , DateTime fechaBuscar , Horario horario , Novedad novedad , ComisionServicio comision , Lactancia lactancia , RelojDefectuoso reloj) { AgenteId = agenteId; FechaReporte = fechaBuscar; _reporteServicio = new ReporteServicio(); _agente = _reporteServicio.BuscarPorId(AgenteId); _horario = horario; _accesos = _reporteServicio.obtenerAccesos(AgenteId, fechaBuscar); _toleraciaLlegadaTarde = _reporteServicio.obtenerMinutosLlegadaTarde(); _toleraciaAusente = _reporteServicio.obtenerMinutosAusentes(); _minutosLactancia = _reporteServicio.obtenerMinutosLactancia(); _lactancia = lactancia; _novedad = novedad; _comision = comision; _reloj = reloj; if (_novedad != null) { _tipoNovedad = new TipoNovedad(); _tipoNovedad = _reporteServicio.obtenerTipo(_novedad.Id); } }
private void Button_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(txtLogin.Text) && !string.IsNullOrEmpty(txtSenha.Password)) { Agente ag = new Agente(); ag.Login = txtLogin.Text; ag = AgenteDAO.BuscarAgentePorLogin(ag); if (ag != null) { if (ag.Login.Equals(txtLogin.Text) && ag.Senha.Equals(txtSenha.Password)) { VerificarCargoESetor(ag); } else { MessageBox.Show("Usuário e/ou Senha incorretos. Tente novamente!", "Login", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Usuário não Encontrado. Verifique!", "Login", MessageBoxButton.OK, MessageBoxImage.Error); txtLogin.Clear(); txtSenha.Clear(); } } else { MessageBox.Show("Por Favor, Preencha todos os campos e tente novamente!", "Login", MessageBoxButton.OK, MessageBoxImage.Warning); } txtLogin.Clear(); txtSenha.Clear(); }
public bool Update(Agente agente) { try { var data = db.TAgente.Find(agente.IdAgente); if (data != null) { data.Nombre = agente.Nombre == null ? data.Nombre : agente.Nombre; data.Apellido = agente.Apellido == null ? data.Apellido : agente.Apellido; data.NumeroTelefono = agente.NumeroTelefono == null ? data.NumeroTelefono : agente.NumeroTelefono; data.Salario = agente.Salario == null ? data.Salario : agente.Salario; data.IdBase = agente.IdBase == null ? data.IdBase : agente.IdBase; db.SaveChanges(); return(true); } else { return(false); } } catch (Exception) { return(false); throw; } }
public void RetornaFalsoQuandoAgenteCessionarioIsInvalid() { var agenteCessionario1 = new Agente("", "87654321"); var solicitacao = new Solicitacao(Guid.NewGuid(), Convert.ToDateTime("01/07/2020"), agenteCedente, agenteCessionario1, cliente, 10); solicitacao.AdicionarAtivo(ativo); var validRes = validator.Validate(solicitacao); var agenteCessionario2 = new Agente("XP INVESTIMENTOS CCTVM S.A. MATRIZ 3-5", ""); solicitacao = new Solicitacao(Guid.NewGuid(), Convert.ToDateTime("01/07/2020"), agenteCedente, agenteCessionario2, cliente, 10); solicitacao.AdicionarAtivo(ativo); var validRes2 = validator.Validate(solicitacao); Assert.IsFalse(validRes.IsValid || validRes2.IsValid); }
public BaseVerbale CreaDettaglio(long verbaleid) { VerbaleElezioneDomicilio domicilio = new VerbaleElezioneDomicilio(); long current = verbaleid; using (ComandoEntities entities = new ComandoEntities()) { ParameterExpression expression = null; ParameterExpression[] parameters = new ParameterExpression[] { expression }; this.violazione = entities.Violazione.Where(x => x.Verbale_Id == verbaleid).FirstOrDefault(); this.verbale = this.violazione.Verbale; this.trasgressore = this.verbale.Trasgressore; if (this.verbale.Agente != null) { this.agente1 = this.verbale.Agente; } if (this.verbale.Agente1 != null) { this.agente2 = this.verbale.Agente1; } this.avvocato = this.verbale.Avvocato; this.patente = this.trasgressore.Patente; return(Helper.RiempiCampi(this.verbale, this.agente1, this.agente2, this.violazione, this.trasgressore, this.patente, null, null, this.avvocato, null, null)); } }
public void Finalizando() { cliente = null; agenteCedente = null; agenteCessionario = null; ativo = null; }
public App(string ruta_bd) { InitializeComponent(); RUTA_DB = ruta_bd; try { List <Agente> agente = new List <Agente>(); using (var conn = new SQLite.SQLiteConnection(App.RUTA_DB)) { conn.CreateTable <Agente>(); agente = conn.Table <Agente>().ToList(); Agente agenteLog = agente[0]; App.AgenteLog = new Agente { ClaveAge = agenteLog.ClaveAge, Nombre = agenteLog.Nombre, Password = agenteLog.Password, Servidor = agenteLog.Servidor }; MainViewModel.GetInstance().Sucursales = new SucursalesViewModel(); Application.Current.MainPage = new MasterPage(); } } catch (Exception e) { MainViewModel.GetInstance().Login = new LoginViewModel(); MainPage = new NavigationPage(new LoginPage()); } }
//float orientation; public override Steering getSteering(AgenteNPC agente) { Steering steering = new Steering(0, new Vector3(0, 0, 0)); wanderOrientation += Random.Range(-1, 1) * wanderRate; float targetOrientation; targetOrientation = wanderOrientation + agente.orientation; Vector3 centro; centro = agente.position + wanderOffset * Cuerpo.orientationToVector(agente.orientation); centro += wanderRadius * orientationAsVector(targetOrientation); target = new Agente(centro); steering = base.getSteering(agente); steering.linear = agente.maxAcceleration * Cuerpo.orientationToVector(agente.orientation); return(steering); }
public void Excluir(Agente agente) { var strQuery = string.Format("DELETE FROM tblagente WHERE idagente={0}", agente.AgenteId); using (cnx = new ConexaoBD()) cnx.CommNom(strQuery); }
public override void Awake() { base.Awake(); agenteObjetivo = objetivo.GetComponent <Agente>(); objetivoAux = objetivo; objetivo = new GameObject(); }
public async Task <IActionResult> Login(Agente agente) { if (agente.Email != null && agente.Senha != null) { Microsoft.AspNetCore.Identity.SignInResult result = await _signInManager.PasswordSignInAsync(agente.Email, agente.Senha, true, false); if (result.Succeeded) { agente = _agenteDAO.BuscarAgentePorEmail(agente); AgenteLogado.Autenticado = agente; if (agente != null) { // LOGADO Como ADMINISTRADOR if (agente.Cargo.NomeCargo.Equals("Administrador")) { return(RedirectToAction(nameof(Index), "Admin")); } // LOGADO Como GESTOR if (agente.Cargo.NomeCargo.Equals("Gestor")) { return(RedirectToAction(nameof(Index), "Gestor")); } // LOGADO Como USUARIO if (agente.Cargo.NomeCargo.Equals("Usuario")) { return(RedirectToAction(nameof(Index), "Usuario")); } } } } ModelState.AddModelError("", "Falha no Login!"); return(View(new Agente())); }
private void btnGuardar_Click(object sender, EventArgs e) { if (validar()) { return; } var agente = BindViewToDomain(); ResultadoTransaccion resultado = null; try { if (_agente == null) { resultado = ClsAgente.CreaAgente(agente); } else { resultado = ClsAgente.ActualizaAgente(agente); } MessageBox.Show(resultado.Descripcion, "Mantenedor de Agentes", MessageBoxButtons.OK, MessageBoxIcon.Information); ListarAgentes(); LimpiarDatos(); _agente = null; } catch (Exception ex) { Console.Write(ex.InnerException); } }
public IHttpActionResult PutAgente(int id, Agente agente) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != agente.Id) { return(BadRequest()); } db.Entry(agente).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AgenteExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> Index() { // Fazendo o Cadastro do Administrador (Usuario Padão) no Identity AgenteLogado agLogado = new AgenteLogado { UserName = "******", Email = "*****@*****.**" }; IdentityResult result = await _userManager.CreateAsync(agLogado, "Ad@00000"); if (result.Succeeded) { //-------------------atribuir role ao user------------------------------ var applicationRole = await _roleManager.FindByNameAsync("Administrador"); if (applicationRole != null) { IdentityResult roleResult = await _userManager.AddToRoleAsync(agLogado, "Administrador"); } //-------------------atribuir role ao user------------------------------ } //Verificar se ja esta logado string email = _userManager.GetUserName(HttpContext.User); Agente agente = _agenteDAO.BuscarAgentePorEmail(email); if (agente != null) { return(await Login(agente)); } return(View()); }
public void RetornaFalsoQuandoAgenteCedenteIsInvalid() { var agenteCedente1 = new Agente("", "12345678"); var solicitacao = new Solicitacao(Guid.NewGuid(), Convert.ToDateTime("01/07/2020"), agenteCedente1, agenteCessionario, cliente, 10); solicitacao.AdicionarAtivo(ativo); var validRes = validator.Validate(solicitacao); var agenteCedente2 = new Agente("820-6 BB-BI", ""); solicitacao = new Solicitacao(Guid.NewGuid(), Convert.ToDateTime("01/07/2020"), agenteCedente2, agenteCessionario, cliente, 10); solicitacao.AdicionarAtivo(ativo); var validRes2 = validator.Validate(solicitacao); Assert.IsFalse(validRes.IsValid || validRes2.IsValid); }
public Ruta.Ruta GetRutaOAsignar(int idAgente) { Context c = (Context)context; Agente agente = c.Agentes.Include("Ruta").Where(p => p.IdAgente == idAgente).FirstOrDefault(); if (agente.Ruta != null) { return(agente.Ruta); } else { Ruta.Ruta rutaInsert = new Ruta.Ruta(); rutaInsert.Descripcion = string.Format("{0}: {1}", Rp3.AgendaComercial.Resources.LabelFor.Ruta, agente.Descripcion); rutaInsert.AsignarId(); rutaInsert.Estado = Constantes.Estado.Activo; rutaInsert.EstadoTabla = Constantes.Estado.Tabla; rutaInsert.UsrIng = Rp3.Web.Mvc.Session.LogonName; rutaInsert.FecIng = Rp3.Runtime.Current.GetCurrentDateTime(); Insert(rutaInsert); agente.IdRuta = rutaInsert.IdRuta; context.Entry <Agente>(agente).State = System.Data.Entity.EntityState.Modified; return(rutaInsert); } }
//---------(B)---------// public static IList recibeMensajeB(byte[] byteRec) { //Array.Resize(ref byteRec, 245); //ParamConexion paramConex = new ParamConexion(); Agente agente = new Agente(); PRN prn = new PRN(); Error err = new Error(); Terminal ter = new Terminal(); //paramConex.codPaquete = Conversiones.AgregaCadena(byteRec, 0, 1); // tipo de mensaje err.CodError = (ushort)Conversiones.AgregaDigito16(byteRec, 1); // codigo error ter.indiceTelecarga = (byte)Conversiones.AgregaDigito(byteRec, 3); // flag long file ter.longArchivo = (UInt32)Conversiones.AgregaDigito32(byteRec, 4); // long file ter.correo = (byte)Conversiones.AgregaDigito(byteRec, 8); // correo prn.Nombre1 = Conversiones.AgregaCadena(byteRec, 9, 10); //Usuario 0 prn.Nombre2 = Conversiones.AgregaCadena(byteRec, 19, 10); //Usuario 1 prn.Nombre3 = Conversiones.AgregaCadena(byteRec, 29, 10); //Usuario 2 prn.Port1 = Conversiones.AgregaCadena(byteRec, 39, 15); // Direccion 0 prn.Port2 = Conversiones.AgregaCadena(byteRec, 54, 15); // Direccion 1 prn.Port3 = Conversiones.AgregaCadena(byteRec, 69, 15); // Direccion 2 prn.Telefono1 = Conversiones.AgregaCadena(byteRec, 84, 15); // Telefono 0 prn.Telefono2 = Conversiones.AgregaCadena(byteRec, 99, 15); // Telefono 1 prn.Telefono3 = Conversiones.AgregaCadena(byteRec, 114, 15); // Telefono 2 int aux = (int)Conversiones.AgregaDigito32(byteRec, 129); agente.Numero = aux; agente.Nombre = Conversiones.AgregaCadena(byteRec, 133, 40); // Nombre de la agencia agente.Direccion = Conversiones.AgregaCadena(byteRec, 173, 40); // Direccion de la agencia agente.Localidad = Conversiones.AgregaCadena(byteRec, 213, 25); // Localidad de la agencia ter.defLengConc1 = (uint)Conversiones.AgregaDigito16(byteRec, 238); ter.defLengConc2 = (uint)Conversiones.AgregaDigito16(byteRec, 240); ter.statusConc = Conversiones.AgregaCadena(byteRec, 242, 3); IList menB = new List<object> { err, agente, prn, ter }; return menB; }
IEnumerator Start() { agente = (Agente) this.GetComponent(typeof(Agente)); m_Tree = BLNewBehaveLibrary0.InstantiateTree( BLNewBehaveLibrary0.TreeType.ColeccionSoldado_ArbolSoldado, this ); Debug.Log(m_Tree); while (Application.isPlaying && m_Tree != null) { yield return new WaitForSeconds(1.0f/m_Tree.Frequency); AIUpdate(); } }
static void Main(string[] args) { BaseConfig bc = new BaseConfig(); #region //Prueba de QUINIELA TransacQuinielaB jue = new TransacQuinielaB(); jue.TipoApuesta = new byte[] { 0x06, 0x06, 0x07, 0x06, 0x0b }; jue.NumeroAp1 = new string[] { "0233", "077", "12", "2411", "33" }; jue.RangoDesde1 = new byte[] { 0x01, 0x01, 0x01, 0x01, 0x00 }; jue.RangoHasta1 = new byte[] { 0x01, 0x01, 0x05, 0x14, 0x00 }; jue.NumeroAp2 = new string[] { null, null, "34", null, "77" }; jue.NumeroAp3 = new string[] { null, null, null, null, "12" }; jue.RangoDesde2 = new byte[] { 0x00, 0x00, 0x01, 0x00, 0x00 }; jue.RangoHasta2 = new byte[] { 0x00, 0x00, 0x0a, 0x00, 0x00 }; jue.Importe = new ushort[] { 300, 600, 300, 400, 200 };//en centavos //jue.TipoApuesta = new byte[] { 0x06, 0x07 }; //jue.NumeroAp1 = new string[] { "12", "21" }; //jue.RangoDesde1 = new byte[] { 0x01, 0x01 }; //jue.RangoHasta1 = new byte[] { 0x01, 0x01 }; //jue.NumeroAp2 = new string[] { null, "45" }; //jue.NumeroAp3 = new string[] { null, null }; //jue.RangoDesde2 = new byte[] { 0x00, 0x01 }; //jue.RangoHasta2 = new byte[] { 0x00, 0x05 }; //jue.Importe = new ushort[] { 1000, 1000 };//en centavos #endregion try { Opera opera = new Opera(); ArchivoConfig lee = new ArchivoConfig(); Errorof errConfig = opera.LeeArchivo(ref lee); Error errBConfig = bc.LeeBaseConfig(ref bc); if (errConfig.Error != 0) { lee = new ArchivoConfig(); #region //PARAMETROS CONFIGURACION PARA CONFIG bc.Terminal = 80732555;//1300000006; bc.Tarjeta = 19511;//50026; bc.TerminalModelo = EnumTerminalModelo.TML; bc.MAC = new byte[] { 0x15, 0xBE, 0x07, 0x91, 0xFD, 0x32, 0xA4, 0xB3 };//{ 0x8b, 0x3d, 0x39, 0xff, 0x6a, 0xdd, 0x16, 0xb8 };//{ 0x5e, 0x01, 0xd2, 0x69, 0x78, 0x8b, 0x7d, 0x02 }; { 0xa0, 0xca, 0x14, 0x1d, 0xba, 0xdf, 0x7b, 0x44 }; bc.MsgMAC = new byte[] { 0x00, 0x91, 0x00, 0x07, 0x00, 0x32, 0xBE, 0xB3, 0x00, 0x15, 0xFD, 0xA4}; //lee.EncryptMAC = mac;//new byte[] { 0x00 }; lee.ImpresoraReportes = "impresoraPDF"; lee.ImpresoraTicket = "THERMAL Receipt Printer"; lee.MaskEscape = 0xfc; //lee.MaskEnmascara = new byte[] { 0x01, 0x03, 0xfc }; //lee.MaskDesenmascara = new byte[] { 0x06, 0x07, 0x05 }; lee.MaskEnmascara = new byte[] { 0x01, 0x03, 0x04, 0x10, 0x1e, 0x9e, 0xfc, 0x83, 0x84, 0x0d, 0x8d, 0x90, 0xff }; lee.MaskDesenmascara = new byte[] { 0x06, 0x07, 0xdd, 0x0a, 0x09, 0x41, 0x05, 0xde, 0xdf, 0x15, 0x11, 0x0b, 0x08 }; lee.LogPath = "C:\\BetmakerTP\\Logs\\"; lee.LogFileName = "LogDisp.lg"; lee.LogMaxFileSize = 10485760; lee.NumeringWithSecuential = false; lee.LevelLog = EnumMessageType.DEBUG; lee.IpTerminal = IPAddress.Parse("133.61.1.12"); lee.IpMask = IPAddress.Parse("255.255.0.0"); lee.DW = IPAddress.Parse("133.61.1.30"); lee.DNS = IPAddress.Parse("133.61.1.194"); lee.PathPRN = "C:\\BetmakerTP\\Conexion\\"; lee.ArchivoPRN = "ArchivoPRN.xml"; lee.DefaultServer = IPAddress.Parse("133.61.1.71"); lee.Host = "Win7x86"; lee.Port = 9950; //MENDOZA lee.Telefono = "08006665807"; lee.PCName = "PCjorge"; lee.FTPServer = IPAddress.Parse("133.61.1.195"); lee.FTPport = 21; lee.FTPUser = "******"; lee.FTPPassword = "******"; lee.FTPWorkingDirectory = "Reportes"; #endregion //opera.GeneraArchivo(archivo, lee); } #region //Prueba de paquete A Terminal paqA = new Terminal(); var entrada = new BaseConfig(); var salida = bc.LeeBaseConfig(ref entrada); if (salida.CodError != 0) { Exception ex = new Exception(salida.Descripcion); throw ex; } else { paqA.Tarjeta = entrada.Tarjeta; paqA.NumeroTerminal = entrada.Terminal; paqA.MacTarjeta = entrada.MsgMAC; } byte[] mac = new byte[] { 0xdf, 0x72, 0x0f, 0xae, 0xdf, 0xd4, 0xe9, 0x1e, 0xdf, 0x8e, 0x1f, 0x61 };//{ 0x00, 0xc2, 0x00, 0x71, 0x00, 0x09, 0xb3, 0x5a, 0x00, 0xde, 0xbf, 0x82 };//{ 0x8e, 0xe9, 0x0f, 0x72, 0x1f, 0xd4, 0x61, 0x1e } 0xdf, , , 0xae, 0xdf, , , , 0xdf,,, }; //paqA.Tarjeta = lee.Tarjeta;//53164;//tarjeta 54781 //58977 //paqA.NumeroTerminal = lee.Terminal;//terminal paqA.FechaHora = DateTime.Now; Version assemblyversion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; paqA.Version = (ushort)((assemblyversion.Major * 1000) + (assemblyversion.Minor * 10) + (assemblyversion.Build));//version //paqA.MacTarjeta = lee.MsgMAC;//mac paqA.Tipo = EnumTerminalModelo.TML; //0x0c; #endregion MonedaJuego Monedas = new MonedaJuego(); Comunicacion com = new Comunicacion(bc, lee); ProtocoloLib.TransacManager.ProtoConfig.CLAVE_TARJETA = BitConverter.GetBytes(0x8EE9AE721FD4611E).Reverse().ToArray(); //Error errCxn = Comunicacion.AbrePuerto(); Error errCxn = com.Conectar(paqA, EnumModoConexion.ETHERNET); Agente agente = new Agente(); if (errCxn.CodError != 0) { Console.Write("Error: " + errCxn.CodError); Console.WriteLine(" " + errCxn.Descripcion + "\n"); Environment.Exit(0); } else { IList objsRec = com.InteraccionAB(ref paqA); TransaccionMSG mensaje; if(objsRec.Count == 6) mensaje = (TransaccionMSG)objsRec[5]; if (objsRec[1] is Agente) { agente = (Agente)objsRec[1]; Console.WriteLine("Agencia: " + agente.Nombre + "\nNúmero de Agencia: " + agente.Numero + "\n"); Error errOffline = new Error(); } IList objsRec3 = new List<object>(); IList objsRec2 = new List<object>(); TransacQuinielaH cabeceraAnul = new TransacQuinielaH(); TransacQuinielaB cuerposAnul = new TransacQuinielaB(); AnulReimpQuiniela anulacionQ = new AnulReimpQuiniela(); TransacPoceado poceadoAnul = new TransacPoceado(); AnulReimpPoceado anulacionP = new AnulReimpPoceado(); if (objsRec.Count < 2 && objsRec[0] is Error) { Error err = (Error)objsRec[0]; if (err.CodError != 0) { Console.Write("Error: " + err.CodError); Console.WriteLine(" " + err.Descripcion + "\n"); } } else if (objsRec.Count > 1) { bool validValue = false; while (!validValue) { Console.WriteLine("Seleccione el tipo de mensaje: "); Console.WriteLine("(1) Quiniela"); Console.WriteLine("(x) Salir"); ConsoleKeyInfo messageType = Console.ReadKey(); Console.WriteLine(); switch (messageType.KeyChar.ToString()) { case "1": #region objsRec2 = com.InteraccionPQ1(PedidosSorteos.QUINIELA, Convert.ToUInt32(paqA.NumeroTerminal), EnumEstadoParametrosOff.HABILITADO); if (objsRec2.Count > 0 && objsRec2[0] != null && objsRec2[0] is Error) { Error psQErr = (Error)objsRec2[0]; if (psQErr.CodError != 0) { Console.Write("Error: " + psQErr.CodError); Console.WriteLine(" " + psQErr.Descripcion + "\n"); } else if (objsRec[1] is Agente && objsRec2[1] is ParamSorteoQuiniela) { psQErr = (Error)objsRec2[0]; if (psQErr.CodError != 0) { Console.Write("Error: " + psQErr.CodError); Console.WriteLine(" " + psQErr.Descripcion + "\n"); } else if (objsRec[1] is Agente && objsRec2[1] is ParamSorteoQuiniela) { ParamSorteoQuiniela psQ = (ParamSorteoQuiniela)objsRec2[1]; TransacQuinielaH cabecera = new TransacQuinielaH(); cabecera.Sorteo = (ushort)psQ.SorteosNumeros[0]; cabecera.FechaHora = DateTime.Now; cabecera.NroSecuencia = 1; //cabecera.Entes = psQ.SorteoBmpEntes[0]; byte[] byteEnte = {1,2,3}; //byte[] bt = Conversiones.SeteaBits(byteEnte, 1, true); //cabecera.Entes = bt[0]; cabecera.CantApu = 5; objsRec3 = com.InteraccionPQ2(cabecera, jue, PedidosSorteos.QUINIELA); if (objsRec3[0] != null && objsRec3[0] is Error) { Error TransErr = (Error)objsRec3[0]; if (TransErr.CodError != 0) { Console.Write("Error: " + TransErr.CodError); Console.WriteLine(" " + TransErr.Descripcion + "\n"); } else if (objsRec3[1] is TransacQuinielaH) { TransacQuinielaH transRta = (TransacQuinielaH)objsRec3[1]; //certifica.CertificadoQuiniela(transRta.Protocolo, bc.MAC, (int)paqA.Tarjeta, (int)paqA.NumeroTerminal, ref transRta.Certificado); LogBMTP.LogBuffer(byteToChar(transRta.Protocolo), "Test LoggeLib", transRta.Protocolo.Length, EnumNivelLog.Trace); Console.WriteLine("Número de apuesta de QUINIELA: " + transRta.id_ticket + "\n"); Console.WriteLine("Número de certificado: " + transRta.Certificado + "\n"); Console.WriteLine("Fecha y hora de Host: " + transRta.Timehost + "\n"); cabeceraAnul.id_ticket = transRta.id_ticket; cabeceraAnul.Certificado = transRta.Certificado; cabeceraAnul.TipoTransacc = transRta.TipoTransacc; } } } } } validValue = false; break; #endregion } } validValue = false; while (!validValue) { Console.WriteLine("(x) Salir"); ConsoleKeyInfo messageType = Console.ReadKey(); Console.WriteLine(); Error err = new Error(); switch (messageType.KeyChar.ToString()) { case "x": case "X": com.Desconectar(false); Environment.Exit(0); validValue = true; break; default: Console.WriteLine("Debe seleccionar un valor válido. Seleccionó: " + messageType.KeyChar.ToString()); validValue = false; break; } } } } } catch(Exception e) { Console.WriteLine("Exception: {0}", e.ToString()); } }
public IList InteraccionAB(ref Terminal datosA, bool interno) { Conexion cxn = new Conexion(); IList objs = new List<object>(); try { TR.ordenAckE = 0; TR.ordenMsgNackE = 0; TransacManager.ProtoConfig.NACK_ENV = NackEnv.SINERROR; datosA.Tipo = TransacManager.ProtoConfig.BASE_CONFIG.TerminalModelo; Enviar(ConstructorMenEnv.crearA_Logueo(datosA, UltimaConexionOptima, TransacManager.ProtoConfig.LOCAL_IP), EnumPaquete.DATOS, TR.ordenMsgNackE); TR.ordenMsgNackE++; Errorof errOf = new Errorof(); //Recibo Mensaje B y envío ACK o NACK do { bytes = new byte[ProtocoloConfig.TamBuffer]; objs = Recibir(bytes, 2, 0, "B"); //atrapa errores de recepción if (objs.Count > 1 && !(objs[0] is string)) { byte[] ACK = { }; Enviar(ACK, EnumPaquete.ACK, TR.ordenAckE); } else { break; } } while (TransacManager.ProtoConfig.NACK_ENV != NackEnv.SINERROR); if (objs == null || objs.Count == 0 ) { throw new Exception("Lista de objetos(objs) regreso vacía de Recibir()"); } else if (objs[0] is string) { Error err = MensajeNack(objs[0]); objs.Insert(0, err); } else if (objs[0].GetType() == typeof(Error) && ((Error)objs[0]).CodError != 0) { foreach (Object obj in objs) { if (obj is PRN) { cxn.crear_XMLprn(((PRN)obj).Nombre1, ((PRN)obj).Nombre2, ((PRN)obj).Nombre3, ((PRN)obj).Port1, ((PRN)obj).Port2, ((PRN)obj).Port3, ((PRN)obj).Telefono1, ((PRN)obj).Telefono2, ((PRN)obj).Telefono3, TransacManager.ProtoConfig.CONFIG); } else if(obj is Error) ((Error)objs[0]).Estado = 0; } return objs; } else if (objs[0] is Error && ((Error)objs[0]).CodError == 0 && objs[1] is Agente) { Agente agente = (Agente)objs[1]; Agente agen = new Agente(agente, out errOf); if (errOf.Error != 0) { ((Error)objs[0]).CodError = (uint)errOf.Error; ((Error)objs[0]).Descripcion = errOf.Mensaje; ((Error)objs[0]).Estado = 2; } PRN prn = (PRN)objs[2]; Terminal terminal = (Terminal)objs[3]; datosA.indiceTelecarga = terminal.indiceTelecarga; datosA.longArchivo = terminal.longArchivo; datosA.correo = terminal.correo; datosA.defLengConc1 = terminal.defLengConc1; datosA.defLengConc2 = terminal.defLengConc2; datosA.statusConc = terminal.statusConc; if (interno) { cxn.crear_XMLprn(prn.Nombre1, prn.Nombre2, prn.Nombre3, prn.Port1, prn.Port2, prn.Port3, prn.Telefono1, prn.Telefono2, prn.Telefono3, TransacManager.ProtoConfig.CONFIG); Desconectar(interno); return objs; } else { cxn.crear_XMLprn(prn.Nombre1, prn.Nombre2, prn.Nombre3, prn.Port1, prn.Port2, prn.Port3, prn.Telefono1, prn.Telefono2, prn.Telefono3, TransacManager.ProtoConfig.CONFIG); } } return objs; } catch (Exception ex) { Error err = new Error(); err.CodError = (int)ErrComunicacion.LOGIN; err.Descripcion = "Ocurrió un error en la comunicación al intentar enviar credenciales."; //Definir que descripción pasar con Jorge err.Estado = 0; LogBMTP.LogMessage("Excepción: " + err.CodError + " " + err.Descripcion, lvlLogExcepciones, TimeStampLog); LogBMTP.LogMessage("Excepción: " + ex.Message, lvlLogDebug, TimeStampLog); objs.Insert(0, err); if (objs.Count > 1) objs.RemoveAt(1); return objs; } }
protected void CargarCuerpo(Agente agente) { IList<Pedido> pedidos = CntAriGes.GetPedidos(agente); BodyPedidos.InnerHtml = CntAriGes.GetPedidosHtmlAgente(pedidos); }
void Start() { base.Start (); agente = (Agente) transform.GetComponent(typeof(Agente)); }
private static async Task Entrenar(string lang) { Console.WriteLine("Entrenando {0}...", lang); var cantidadArticulos = TOTAL_ARTICULOS_DESCARGAR - Directory.GetFiles(lang, "*.txt").Length; if (cantidadArticulos <= 0) { Console.WriteLine("Entrenado."); return; } var wikiUrl = $"https://{lang}.wikipedia.org/w/api.php?"; using (var cliente = new WebClient()) { cliente.Encoding = Encoding.UTF8; Console.WriteLine("Obteniendo ids de articulos aleatorios"); var wikiRandoms = JsonConvert.DeserializeObject<dynamic>(await cliente.DownloadStringTaskAsync(wikiUrl + "action=query&list=random&format=json&rnlimit=" + cantidadArticulos)); foreach (var infoArticulo in wikiRandoms.query.random) { string id = infoArticulo.id; string titulo = infoArticulo.title; string articulo = null; using (var cliente2 = new WebClient()) { var wikiArticulo = JsonConvert.DeserializeObject<dynamic>(await cliente.DownloadStringTaskAsync(wikiUrl + $"action=query&prop=revisions&format=json&rvprop=content&rvparse=&rvcontentformat=text%2Fplain&pageids={id}")); foreach (var pages in wikiArticulo.query.pages) { foreach (var page in pages) { Console.WriteLine("Titulo: {0}", page.title); foreach (var revision in page.revisions) { foreach (var contenidos in revision) { foreach (var contenido in contenidos) { articulo = contenido.ToString(); if (!string.IsNullOrWhiteSpace(articulo)) { break; } } break; } break; } break; } break; } } if (!string.IsNullOrWhiteSpace(articulo)) { foreach (var item in Path.GetInvalidFileNameChars()) { titulo = titulo.Replace(item, '-'); } var path = Path.Combine(lang, titulo + ".html"); File.WriteAllText(path, articulo, Encoding.UTF8); var x = new HtmlAgilityPack.HtmlDocument(); x.Load(path); File.WriteAllText(path + ".txt", x.DocumentNode.InnerText); File.Delete(path); var agente = new Agente(path + ".txt", true); agente.SolicitarIdioma += (o, e) => e.Idioma = idiomas[lang]; await agente.IdentificarIdioma(); } } } Console.WriteLine("Entrenamiento {0} completo.", lang); }