Version OScar
This commit is contained in:
326
ADSUtileriasWF/Views/Gral/FrmLogin.Designer.cs
generated
Normal file
326
ADSUtileriasWF/Views/Gral/FrmLogin.Designer.cs
generated
Normal file
@@ -0,0 +1,326 @@
|
||||
namespace ADSUtileriasWF.Views.Gral
|
||||
{
|
||||
partial class FrmLogin
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmLogin));
|
||||
panel1 = new System.Windows.Forms.Panel();
|
||||
label2 = new System.Windows.Forms.Label();
|
||||
PbxLogo = new System.Windows.Forms.PictureBox();
|
||||
TxtUsuario = new System.Windows.Forms.TextBox();
|
||||
PBiUsuario = new FontAwesome.Sharp.IconPictureBox();
|
||||
PbiPassword = new FontAwesome.Sharp.IconPictureBox();
|
||||
TxtPassword = new System.Windows.Forms.TextBox();
|
||||
btnClose = new FontAwesome.Sharp.IconButton();
|
||||
label1 = new System.Windows.Forms.Label();
|
||||
BtnLogin = new System.Windows.Forms.Button();
|
||||
BtnMinimizar = new FontAwesome.Sharp.IconButton();
|
||||
label3 = new System.Windows.Forms.Label();
|
||||
panel2 = new System.Windows.Forms.Panel();
|
||||
panel3 = new System.Windows.Forms.Panel();
|
||||
BtnMostrarPass = new FontAwesome.Sharp.IconPictureBox();
|
||||
Loader = new System.Windows.Forms.PictureBox();
|
||||
panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)PbxLogo).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)PBiUsuario).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)PbiPassword).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)BtnMostrarPass).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)Loader).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.BackColor = System.Drawing.Color.FromArgb(43, 54, 67);
|
||||
panel1.Controls.Add(label2);
|
||||
panel1.Controls.Add(PbxLogo);
|
||||
panel1.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
panel1.Location = new System.Drawing.Point(0, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new System.Drawing.Size(250, 310);
|
||||
panel1.TabIndex = 0;
|
||||
panel1.MouseDown += WFLogin_MouseDown;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Font = new System.Drawing.Font("Segoe UI", 10F, System.Drawing.FontStyle.Bold);
|
||||
label2.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
label2.Location = new System.Drawing.Point(60, 283);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new System.Drawing.Size(94, 19);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "versión 8.0.0";
|
||||
label2.Click += label2_Click;
|
||||
//
|
||||
// PbxLogo
|
||||
//
|
||||
PbxLogo.Image = Properties.Resources.LOGOADS;
|
||||
PbxLogo.Location = new System.Drawing.Point(12, 60);
|
||||
PbxLogo.Name = "PbxLogo";
|
||||
PbxLogo.Size = new System.Drawing.Size(227, 190);
|
||||
PbxLogo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
PbxLogo.TabIndex = 0;
|
||||
PbxLogo.TabStop = false;
|
||||
PbxLogo.MouseDown += WFLogin_MouseDown;
|
||||
//
|
||||
// TxtUsuario
|
||||
//
|
||||
TxtUsuario.AcceptsReturn = true;
|
||||
TxtUsuario.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
TxtUsuario.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
TxtUsuario.Font = new System.Drawing.Font("Segoe UI", 14F);
|
||||
TxtUsuario.Location = new System.Drawing.Point(345, 90);
|
||||
TxtUsuario.Name = "TxtUsuario";
|
||||
TxtUsuario.PlaceholderText = "Usuario";
|
||||
TxtUsuario.Size = new System.Drawing.Size(300, 25);
|
||||
TxtUsuario.TabIndex = 1;
|
||||
TxtUsuario.KeyUp += TxtUsuario_KeyUp;
|
||||
//
|
||||
// PBiUsuario
|
||||
//
|
||||
PBiUsuario.BackColor = System.Drawing.Color.FromArgb(15, 15, 15);
|
||||
PBiUsuario.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
PBiUsuario.IconChar = FontAwesome.Sharp.IconChar.User;
|
||||
PBiUsuario.IconColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
PBiUsuario.IconFont = FontAwesome.Sharp.IconFont.Auto;
|
||||
PBiUsuario.IconSize = 25;
|
||||
PBiUsuario.Location = new System.Drawing.Point(310, 90);
|
||||
PBiUsuario.Name = "PBiUsuario";
|
||||
PBiUsuario.Size = new System.Drawing.Size(25, 25);
|
||||
PBiUsuario.TabIndex = 2;
|
||||
PBiUsuario.TabStop = false;
|
||||
//
|
||||
// PbiPassword
|
||||
//
|
||||
PbiPassword.BackColor = System.Drawing.Color.FromArgb(15, 15, 15);
|
||||
PbiPassword.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
PbiPassword.IconChar = FontAwesome.Sharp.IconChar.Lock;
|
||||
PbiPassword.IconColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
PbiPassword.IconFont = FontAwesome.Sharp.IconFont.Auto;
|
||||
PbiPassword.IconSize = 25;
|
||||
PbiPassword.Location = new System.Drawing.Point(310, 145);
|
||||
PbiPassword.Name = "PbiPassword";
|
||||
PbiPassword.Size = new System.Drawing.Size(25, 25);
|
||||
PbiPassword.TabIndex = 3;
|
||||
PbiPassword.TabStop = false;
|
||||
//
|
||||
// TxtPassword
|
||||
//
|
||||
TxtPassword.AcceptsReturn = true;
|
||||
TxtPassword.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
TxtPassword.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
TxtPassword.Font = new System.Drawing.Font("Segoe UI", 14F);
|
||||
TxtPassword.Location = new System.Drawing.Point(345, 145);
|
||||
TxtPassword.Name = "TxtPassword";
|
||||
TxtPassword.PlaceholderText = "Contraseña";
|
||||
TxtPassword.Size = new System.Drawing.Size(300, 25);
|
||||
TxtPassword.TabIndex = 2;
|
||||
TxtPassword.UseSystemPasswordChar = true;
|
||||
TxtPassword.KeyUp += TxtUsuario_KeyUp;
|
||||
//
|
||||
// btnClose
|
||||
//
|
||||
btnClose.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
|
||||
btnClose.FlatAppearance.BorderSize = 0;
|
||||
btnClose.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
btnClose.Flip = FontAwesome.Sharp.FlipOrientation.Normal;
|
||||
btnClose.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
btnClose.IconChar = FontAwesome.Sharp.IconChar.Times;
|
||||
btnClose.IconColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
btnClose.IconFont = FontAwesome.Sharp.IconFont.Auto;
|
||||
btnClose.IconSize = 20;
|
||||
btnClose.Location = new System.Drawing.Point(675, 2);
|
||||
btnClose.Margin = new System.Windows.Forms.Padding(0);
|
||||
btnClose.Name = "btnClose";
|
||||
btnClose.Rotation = 0D;
|
||||
btnClose.Size = new System.Drawing.Size(25, 25);
|
||||
btnClose.TabIndex = 0;
|
||||
btnClose.UseVisualStyleBackColor = false;
|
||||
btnClose.Click += btnClose_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold);
|
||||
label1.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
label1.Location = new System.Drawing.Point(405, 20);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new System.Drawing.Size(152, 25);
|
||||
label1.TabIndex = 4;
|
||||
label1.Text = "Iniciar sesión";
|
||||
//
|
||||
// BtnLogin
|
||||
//
|
||||
BtnLogin.BackColor = System.Drawing.Color.FromArgb(40, 40, 40);
|
||||
BtnLogin.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(28, 28, 28);
|
||||
BtnLogin.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(64, 64, 64);
|
||||
BtnLogin.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
BtnLogin.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F);
|
||||
BtnLogin.ForeColor = System.Drawing.Color.LightGray;
|
||||
BtnLogin.Location = new System.Drawing.Point(310, 230);
|
||||
BtnLogin.Name = "BtnLogin";
|
||||
BtnLogin.Size = new System.Drawing.Size(330, 40);
|
||||
BtnLogin.TabIndex = 5;
|
||||
BtnLogin.Text = "ENTRAR";
|
||||
BtnLogin.UseVisualStyleBackColor = false;
|
||||
BtnLogin.Click += BtnLogin_Click;
|
||||
//
|
||||
// BtnMinimizar
|
||||
//
|
||||
BtnMinimizar.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
|
||||
BtnMinimizar.FlatAppearance.BorderSize = 0;
|
||||
BtnMinimizar.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
BtnMinimizar.Flip = FontAwesome.Sharp.FlipOrientation.Normal;
|
||||
BtnMinimizar.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
BtnMinimizar.IconChar = FontAwesome.Sharp.IconChar.WindowMinimize;
|
||||
BtnMinimizar.IconColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
BtnMinimizar.IconFont = FontAwesome.Sharp.IconFont.Auto;
|
||||
BtnMinimizar.IconSize = 20;
|
||||
BtnMinimizar.Location = new System.Drawing.Point(645, 2);
|
||||
BtnMinimizar.Margin = new System.Windows.Forms.Padding(0);
|
||||
BtnMinimizar.Name = "BtnMinimizar";
|
||||
BtnMinimizar.Rotation = 0D;
|
||||
BtnMinimizar.Size = new System.Drawing.Size(25, 25);
|
||||
BtnMinimizar.TabIndex = 0;
|
||||
BtnMinimizar.UseVisualStyleBackColor = false;
|
||||
BtnMinimizar.Click += btnMinimizar;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold);
|
||||
label3.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
label3.Location = new System.Drawing.Point(420, 285);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new System.Drawing.Size(114, 15);
|
||||
label3.TabIndex = 4;
|
||||
label3.Text = "BY ADSISTEMAS";
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
panel2.BackColor = System.Drawing.SystemColors.Window;
|
||||
panel2.Location = new System.Drawing.Point(340, 90);
|
||||
panel2.Name = "panel2";
|
||||
panel2.Size = new System.Drawing.Size(5, 25);
|
||||
panel2.TabIndex = 6;
|
||||
//
|
||||
// panel3
|
||||
//
|
||||
panel3.BackColor = System.Drawing.SystemColors.Window;
|
||||
panel3.Location = new System.Drawing.Point(340, 145);
|
||||
panel3.Name = "panel3";
|
||||
panel3.Size = new System.Drawing.Size(5, 25);
|
||||
panel3.TabIndex = 7;
|
||||
//
|
||||
// BtnMostrarPass
|
||||
//
|
||||
BtnMostrarPass.BackColor = System.Drawing.Color.FromArgb(15, 15, 15);
|
||||
BtnMostrarPass.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
BtnMostrarPass.IconChar = FontAwesome.Sharp.IconChar.EyeSlash;
|
||||
BtnMostrarPass.IconColor = System.Drawing.SystemColors.ButtonHighlight;
|
||||
BtnMostrarPass.IconFont = FontAwesome.Sharp.IconFont.Auto;
|
||||
BtnMostrarPass.IconSize = 25;
|
||||
BtnMostrarPass.Location = new System.Drawing.Point(645, 145);
|
||||
BtnMostrarPass.Name = "BtnMostrarPass";
|
||||
BtnMostrarPass.Size = new System.Drawing.Size(31, 25);
|
||||
BtnMostrarPass.TabIndex = 8;
|
||||
BtnMostrarPass.TabStop = false;
|
||||
BtnMostrarPass.Click += BtnMostrarPass_Click;
|
||||
//
|
||||
// Loader
|
||||
//
|
||||
Loader.BackColor = System.Drawing.Color.FromArgb(15, 15, 15);
|
||||
Loader.Image = Properties.Resources.Loader;
|
||||
Loader.Location = new System.Drawing.Point(443, 176);
|
||||
Loader.Name = "Loader";
|
||||
Loader.Size = new System.Drawing.Size(61, 48);
|
||||
Loader.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
Loader.TabIndex = 9;
|
||||
Loader.TabStop = false;
|
||||
//
|
||||
// FrmLogin
|
||||
//
|
||||
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
BackColor = System.Drawing.Color.FromArgb(15, 15, 15);
|
||||
ClientSize = new System.Drawing.Size(700, 310);
|
||||
Controls.Add(Loader);
|
||||
Controls.Add(BtnMostrarPass);
|
||||
Controls.Add(panel3);
|
||||
Controls.Add(panel2);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(BtnMinimizar);
|
||||
Controls.Add(BtnLogin);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(btnClose);
|
||||
Controls.Add(TxtPassword);
|
||||
Controls.Add(PbiPassword);
|
||||
Controls.Add(PBiUsuario);
|
||||
Controls.Add(TxtUsuario);
|
||||
Controls.Add(panel1);
|
||||
FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
|
||||
Name = "FrmLogin";
|
||||
Opacity = 0.9D;
|
||||
StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
Text = "Login";
|
||||
Load += WFLogin_Load;
|
||||
MouseDown += WFLogin_MouseDown;
|
||||
panel1.ResumeLayout(false);
|
||||
panel1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)PbxLogo).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)PBiUsuario).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)PbiPassword).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)BtnMostrarPass).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)Loader).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.PictureBox PbxLogo;
|
||||
private System.Windows.Forms.TextBox TxtUsuario;
|
||||
private FontAwesome.Sharp.IconPictureBox PBiUsuario;
|
||||
private FontAwesome.Sharp.IconPictureBox PbiPassword;
|
||||
private System.Windows.Forms.TextBox TxtPassword;
|
||||
private FontAwesome.Sharp.IconButton btnClose;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Button BtnLogin;
|
||||
private FontAwesome.Sharp.IconButton BtnMinimizar;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.Panel panel2;
|
||||
private System.Windows.Forms.Panel panel3;
|
||||
private FontAwesome.Sharp.IconPictureBox BtnMostrarCaracteres;
|
||||
private FontAwesome.Sharp.IconPictureBox BtnMostrarPass;
|
||||
private System.Windows.Forms.PictureBox Loader;
|
||||
private System.Windows.Forms.Label label2;
|
||||
}
|
||||
}
|
||||
380
ADSUtileriasWF/Views/Gral/FrmLogin.cs
Normal file
380
ADSUtileriasWF/Views/Gral/FrmLogin.cs
Normal file
@@ -0,0 +1,380 @@
|
||||
using ADSUtileriasWF.Helpers;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Configuration.Install;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.ServiceProcess;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using WCF_PV;
|
||||
using static ADSUtileriasWF.Helpers.ModVarsPV;
|
||||
|
||||
namespace ADSUtileriasWF.Views.Gral
|
||||
{
|
||||
|
||||
public partial class FrmLogin : FormBase
|
||||
{
|
||||
public FrmLogin()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
//this.PnlLoader.BackColor = System.Drawing.Color.FromArgb(25, System.Drawing.Color.Black);
|
||||
//this.SetStyle(System.Windows.Forms.ControlStyles.SupportsTransparentBackColor, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void btnClose_Click(object sender, EventArgs e)
|
||||
{
|
||||
Application.Exit();
|
||||
}
|
||||
private void btnMinimizar(object sender, EventArgs e)
|
||||
{
|
||||
this.WindowState = FormWindowState.Minimized;
|
||||
}
|
||||
#region "mover /arrastrar formulario"
|
||||
[DllImport("user32.DLL", EntryPoint = "ReleaseCapture")]
|
||||
private extern static void ReleaseCapture();
|
||||
|
||||
[DllImport("user32.DLL", EntryPoint = "SendMessage")]
|
||||
private extern static void SendMessage(System.IntPtr hwnd, int wmsg, int wparam, int lparam);
|
||||
private void WFLogin_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
ReleaseCapture();
|
||||
SendMessage(this.Handle, 0x112, 0xf012, 0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
protected void Login()
|
||||
{
|
||||
BtnLogin.Invoke((MethodInvoker)delegate
|
||||
{
|
||||
Loader.Visible = true;
|
||||
TxtUsuario.Enabled = false;
|
||||
TxtPassword.Enabled = false;
|
||||
BtnLogin.Enabled = false;
|
||||
});
|
||||
|
||||
if (moduloActivo == ModuloActivo.Checador)
|
||||
{
|
||||
bool continuar = true;
|
||||
string msgboxstring = "";
|
||||
string usuario = TxtUsuario.Text;
|
||||
string password = TxtPassword.Text;
|
||||
if (usuario.Trim().Length == 0)
|
||||
{
|
||||
msgboxstring = string.Format("{0}El campo 'Usuario' es necesario\r\n", msgboxstring);
|
||||
continuar = false;
|
||||
}
|
||||
if (password.Trim().Length == 0)
|
||||
{
|
||||
msgboxstring = string.Format("{0}El campo 'Password' es necesario\r\n", msgboxstring);
|
||||
continuar = false;
|
||||
}
|
||||
|
||||
if (continuar)
|
||||
{
|
||||
UtileriasServiceWCF.ResponseLogin respuesta = null;
|
||||
try
|
||||
{
|
||||
respuesta = Servicecon.Login(usuario, password, -1);
|
||||
if (respuesta != null)
|
||||
{
|
||||
BtnLogin.Invoke((MethodInvoker)delegate
|
||||
{
|
||||
ModVarsPV.UserV2 = respuesta;
|
||||
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.Close();
|
||||
//var tuiene= ModVarsPV.TieneProceso(respuesta, 1000);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
continuar = false;
|
||||
msgboxstring = string.Format("{0}Usuario o contraseña incorrectos\r\n", msgboxstring);
|
||||
}
|
||||
continuar = true;
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
GuardaLog(string.Format("{0}Ocurrió un error al validar el usuario\r\n{1}", msgboxstring, ex));
|
||||
msgboxstring = string.Format("{0}Ocurrió un error al validar el usuario\r\n", msgboxstring);
|
||||
continuar = false;
|
||||
}
|
||||
}
|
||||
BtnLogin.Invoke((MethodInvoker)delegate
|
||||
{
|
||||
ModExtensiones.Alert(msgboxstring, "Login");
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if (moduloActivo == ModuloActivo.PuntoVenta)
|
||||
{
|
||||
|
||||
var proxy = new PuntoVentaClient(EndPointName, string.Format("{0}Clase", RutaWCF));
|
||||
try
|
||||
{
|
||||
UsuarioActual = proxy.ValidarUsuario(TxtUsuario.Text, TxtPassword.Text);
|
||||
proxy = null;
|
||||
|
||||
if (UsuarioActual != null && UsuarioActual.CveUsuario > 0)
|
||||
{
|
||||
|
||||
BtnLogin.Invoke((MethodInvoker)delegate
|
||||
{
|
||||
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.Close();
|
||||
});
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (UsuarioActual != null)
|
||||
{
|
||||
ModExtensiones.Alert(UsuarioActual.Nombre, "Login");
|
||||
}
|
||||
else
|
||||
{
|
||||
ModExtensiones.Alert("Usuario o contraseña incorrecto (2)", "Login");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var msgboxstring = "Error al identificarse.";
|
||||
GuardaLog($"{msgboxstring} {ex.Message} {ex.StackTrace}");
|
||||
ModExtensiones.Alert(msgboxstring, "Login");
|
||||
}
|
||||
}
|
||||
|
||||
BtnLogin.Invoke((MethodInvoker)delegate
|
||||
{
|
||||
BtnLogin.Enabled = true;
|
||||
TxtUsuario.Enabled = true;
|
||||
TxtPassword.Enabled = true;
|
||||
Loader.Visible = false;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void BtnLogin_Click(object sender, EventArgs e)
|
||||
{
|
||||
//Login();
|
||||
System.Threading.ThreadStart threadStart = new System.Threading.ThreadStart(Login);
|
||||
System.Threading.Thread thread = new System.Threading.Thread(threadStart);
|
||||
thread.SetApartmentState(System.Threading.ApartmentState.STA);
|
||||
thread.Start();
|
||||
}
|
||||
|
||||
private void TxtUsuario_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Enter:
|
||||
{
|
||||
System.Threading.ThreadStart threadStart = new System.Threading.ThreadStart(Login);
|
||||
System.Threading.Thread thread = new System.Threading.Thread(threadStart);
|
||||
thread.SetApartmentState(System.Threading.ApartmentState.STA);
|
||||
thread.Start();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void Iniciarservicio()
|
||||
{
|
||||
|
||||
BtnLogin.Invoke((MethodInvoker)delegate
|
||||
{
|
||||
BtnLogin.Enabled = false;
|
||||
TxtUsuario.Enabled = false;
|
||||
TxtPassword.Enabled = false;
|
||||
Loader.Visible = true;
|
||||
});
|
||||
try
|
||||
{
|
||||
const string utilservicename = "ADSUtileriasAPP";
|
||||
var utilservice = ServiceController.GetServices().FirstOrDefault(s => s.ServiceName == utilservicename);
|
||||
bool isstoped = true;
|
||||
if (utilservice == null)
|
||||
{
|
||||
string filePath = $"{GetParentUriString(AppDomain.CurrentDomain.BaseDirectory)}Service/ADSUtileriasService.exe".Replace("/", "\\");
|
||||
System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(filePath);
|
||||
|
||||
|
||||
System.Diagnostics.Process process = new System.Diagnostics.Process();
|
||||
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
|
||||
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
|
||||
startInfo.FileName = "cmd.exe";
|
||||
startInfo.Arguments = $"\"C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\installutil.exe\" \"{filePath}\"";
|
||||
startInfo.Verb = "runas";
|
||||
startInfo.RedirectStandardInput = true;
|
||||
startInfo.RedirectStandardOutput = true;
|
||||
startInfo.CreateNoWindow = true;
|
||||
process.StartInfo = startInfo;
|
||||
process.Start();
|
||||
|
||||
|
||||
process.StandardInput.WriteLine(startInfo.Arguments);
|
||||
process.StandardInput.Flush();
|
||||
process.StandardInput.Close();
|
||||
process.WaitForExit();
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
isstoped = (utilservice.Status == ServiceControllerStatus.Stopped);
|
||||
}
|
||||
|
||||
if (isstoped)
|
||||
{
|
||||
|
||||
string filePath = $"{GetParentUriString(AppDomain.CurrentDomain.BaseDirectory)}Service/ADSUtileriasService.exe".Replace("/", "\\");
|
||||
System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(filePath);
|
||||
|
||||
|
||||
System.Diagnostics.Process process = new System.Diagnostics.Process();
|
||||
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
|
||||
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
|
||||
startInfo.FileName = "cmd.exe";
|
||||
startInfo.Arguments = $"net start {utilservicename}";
|
||||
startInfo.Verb = "runas";
|
||||
startInfo.RedirectStandardInput = true;
|
||||
startInfo.RedirectStandardOutput = true;
|
||||
startInfo.CreateNoWindow = true;
|
||||
process.StartInfo = startInfo;
|
||||
process.Start();
|
||||
|
||||
|
||||
process.StandardInput.WriteLine(startInfo.Arguments);
|
||||
process.StandardInput.Flush();
|
||||
process.StandardInput.Close();
|
||||
process.WaitForExit();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
GuardaLog(string.Format("Ocurrió un error al iniciar el servicio\r\n{0}", e));
|
||||
|
||||
BtnLogin.Invoke((MethodInvoker)delegate
|
||||
{
|
||||
ModExtensiones.Alert("Ocurrió un error al iniciar el servicio ", "Login");
|
||||
});
|
||||
}
|
||||
BtnLogin.Invoke((MethodInvoker)delegate
|
||||
{
|
||||
BtnLogin.Enabled = true;
|
||||
TxtUsuario.Enabled = true;
|
||||
TxtPassword.Enabled = true;
|
||||
Loader.Visible = false;
|
||||
});
|
||||
}
|
||||
private void WFLogin_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
System.Threading.ThreadStart threadStart = new System.Threading.ThreadStart(Iniciarservicio);
|
||||
System.Threading.Thread thread = new System.Threading.Thread(threadStart);
|
||||
thread.SetApartmentState(System.Threading.ApartmentState.STA);
|
||||
thread.Start();
|
||||
}
|
||||
private void BtnMostrarPass_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
this.TxtPassword.UseSystemPasswordChar = !this.TxtPassword.UseSystemPasswordChar;
|
||||
if (this.TxtPassword.UseSystemPasswordChar)
|
||||
{
|
||||
this.BtnMostrarPass.IconChar = FontAwesome.Sharp.IconChar.EyeSlash;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.BtnMostrarPass.IconChar = FontAwesome.Sharp.IconChar.Eye;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#region "Instalar servicio"
|
||||
private static string GetParentUriString(string filePath)
|
||||
{
|
||||
Uri uri = new Uri(filePath);
|
||||
return System.Web.HttpUtility.UrlDecode(uri.AbsoluteUri.Remove(uri.AbsoluteUri.Length - uri.Segments[uri.Segments.Length - 1].Length - uri.Query.Length).Remove(0, 8));
|
||||
}
|
||||
/*
|
||||
public static void InstallService(string serviceName, System.Reflection.Assembly assembly)
|
||||
{
|
||||
if (IsServiceInstalled(serviceName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using (AssemblyInstaller installer = GetInstaller(assembly))
|
||||
{
|
||||
IDictionary state = new Hashtable();
|
||||
try
|
||||
{
|
||||
installer.Install(state);
|
||||
installer.Commit(state);
|
||||
}
|
||||
catch
|
||||
{
|
||||
try
|
||||
{
|
||||
installer.Rollback(state);
|
||||
}
|
||||
catch { }
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsServiceInstalled(string serviceName)
|
||||
{
|
||||
using (ServiceController controller = new ServiceController(serviceName))
|
||||
{
|
||||
try
|
||||
{
|
||||
ServiceControllerStatus status = controller.Status;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static AssemblyInstaller GetInstaller(System.Reflection.Assembly assembly)
|
||||
{
|
||||
AssemblyInstaller installer = new AssemblyInstaller(assembly, null);
|
||||
installer.UseNewContext = true;
|
||||
|
||||
return installer;
|
||||
}
|
||||
*/
|
||||
#endregion
|
||||
|
||||
private void label2_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
3963
ADSUtileriasWF/Views/Gral/FrmLogin.resx
Normal file
3963
ADSUtileriasWF/Views/Gral/FrmLogin.resx
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user