public FrmPrincipal() { InitializeComponent(); var connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; service = new PrincipalService(connectionString); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); var seleniumConfigurations = new SeleniumConfiguration(); new ConfigureFromConfigurationOptions <SeleniumConfiguration>( configuration.GetSection("SeleniumConfiguration")) .Configure(seleniumConfigurations); TelegramService ts = new TelegramService(); PrincipalService ps = new PrincipalService(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); try { ts.EnviaMensagemParaOGrupo("App Iniciado"); // ps.SalvaJogosAmanha(2,false).GetAwaiter().GetResult(); ps.Iniciar(2, false).GetAwaiter().GetResult(); } catch (Exception e) { GC.Collect(); Console.WriteLine("Erro: " + e.Message + " - " + e.StackTrace); ps.Dispose(); ts.EnviaMensagemParaOGrupo("Erro App : " + e.Message); } }
private void Buscar() { PrincipalService service = new PrincipalService(); string cedula = TxtCedula.Text.Trim(); if (cedula != "") { Principal principal = service.BuscarEmpresa(cedula); if (principal != null) { TxtCedula.Text = principal.Cedula; TxtNombre.Text = principal.Nombre; TxtTelefono.Text = principal.Telefono; TxtDireccion.Text = principal.Direccion; CmbTipoProducto.Text = principal.TipoProducto; TxtProducto.Text = principal.Producto; TxtPrecio.Text = principal.Precio.ToString(); CmbAfiliacion.Text = principal.Afiliacion; } else { MessageBox.Show($"La empresa con cedula: {cedula} NO SE ENCUENTRA EN NUESTRA BASE DE DATOS"); Limpiar(); } } else { MessageBox.Show("Por favor digite una cedula Valida", "Registros", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void Login(string u, string p) { var user = new Identity(u, this.ActionContext.Request.Headers.Authorization.Scheme, true); var principal = new PrincipalService(); principal.CreatePrincipal(user); this.User = principal; HttpContext.Current.User = principal; }
private void BtnGuardar_Click(object sender, EventArgs e) { Principal principal = MapearDatos(); PrincipalService service = new PrincipalService(); string mensaje = service.Guardar(principal); MessageBox.Show(mensaje, "Mensaje de Guardado", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); Limpiar(); }
public FrmListado() { InitializeComponent(); var connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; service = new PrincipalService(connectionString); DgvListado.DataSource = null; principals.Clear(); principals = service.Consultar(); DgvListado.DataSource = principals; }
private void ModificarEmpresa() { PrincipalService service = new PrincipalService(); Principal principal = new Principal(); principal.Cedula = TxtCedula.Text.Trim(); principal.Nombre = TxtNombre.Text; principal.Direccion = TxtDireccion.Text; principal.FechaRegistro = DtpFechaRegistro.Value.Date; service.Modificar(principal); MessageBox.Show("SE MODIFICO CORRECTAMENTE EL REGISTRO"); }
private void EliminarEmpresa() { var respuesta = MessageBox.Show("Esta seguro de eliminar el registro, PARA SIEMPRE!", "Eliminar Registro", MessageBoxButtons.YesNo); if (respuesta == DialogResult.Yes) { PrincipalService service = new PrincipalService(); string cedula = TxtCedula.Text; string msjeliminado = service.EliminarEmpresa(cedula); MessageBox.Show(msjeliminado); } }
public override void OnAuthorization(HttpActionContext actionContext) { if (actionContext == null) { throw new ArgumentException("actionContext"); } HttpControllerContext context = actionContext.ControllerContext; if (context.Request.Headers.Authorization == null) { actionContext.Response = new HttpResponseMessage(HttpStatusCode.Unauthorized) { Content = new StringContent("未授权访问") }; return; } var(isAuthorized, jwtIdentity) = JsonWebTokenHelper.ValidateToken(context.Request.Headers.Authorization.Parameter); if (!isAuthorized) { actionContext.Response = new HttpResponseMessage(HttpStatusCode.Unauthorized) { Content = new StringContent("未授权访问") }; return; } Identity identity = new Identity(jwtIdentity.Name, context.Request.Headers.Authorization.Scheme, jwtIdentity.IsAuthenticated); PrincipalService p = new PrincipalService(); p.CreatePrincipal(identity); p.Role = ((ClaimsIdentity)jwtIdentity).Claims.ToList().Find(i => i.Type == ClaimTypes.Role).Value; if (!p.IsInRole()) { actionContext.Response = new HttpResponseMessage(HttpStatusCode.Unauthorized) { Content = new StringContent("用户未授予身份资格") }; return; } context.RequestContext.Principal = p; base.OnAuthorization(actionContext); }
public PrincipalController() { _service = new PrincipalService(ModelState); }
public void TestInit() { resourceService = new Mock <IResourceService>(); context = new TestInMemoryCamModel(); service = new PrincipalService(context, resourceService.Object); }