Exferia/SigmaERP_2017/SigmaERP/3_Vistas/P_Principal.cs

1173 lines
59 KiB
C#

using Exferia_Actualizacion_BD;
using Exferia_Aplicacion.General;
using Exferia_Aplicacion.Modelos_Generales;
using Exferia_Aplicacion.Modelos_ServiciosWeb;
using Exferia_Aplicacion.Terminal;
using Exferia_Aplicacion.Visualizacion;
using Exferia_Controles;
using Exferia_EntityFramework;
using Exferia_Formularios;
using Exferia_General;
using Microsoft.Win32;
using SigmaERP._3_Vistas;
using SigmaERP._3_Vistas.Controladoras;
using SigmaERP.General;
using SigmaERP.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SigmaERP
{
public partial class P_Principal : Form
{
#region Variables privadas
private P_Principal_Controladora g_obj_Controladora;
//Validacion de la Lincencia
private bool g_bol_ValidandoLicencia = false;
private BackgroundWorker g_bgw_Validacion_Licencia = null;//Tarea Asincrona para Validar Licencia
private System.Windows.Forms.Timer g_timer_TareaAsicrona_Validacion_Licencia = new System.Windows.Forms.Timer();
//Buscar opciones en el menu
private System.Windows.Forms.Timer g_timer_Menu_Buscar = new System.Windows.Forms.Timer();
#endregion
#region Objetos en Pantalla
//Panel
internal Panel Panel_PantallasEmpotrar_Principal { get { return spl_Principal.Panel1; } }
internal Panel Panel_PantallasEmpotrar_Secundario { get { return spl_Principal.Panel2; } }
//Label
internal Label Label_EmpleadoValidado { get { return lbl_EmpleadoValidado; } }
internal Label Label_EmpresaEjercicioOrden_Activo { get { return lbl_EmpresaEjercicioOrden_Activo; } }
//ImageList
internal ImageList ImageList_ArbolPrincipal { get { return imglst_ArbolPrincipal; } }
//Exferia_TextBox
internal Exferia_TextBox Exferia_TextBox_Busqueda { get { return ex_txt_P_Principal_Busqueda; } }
//Exferia_TreeView
internal Exferia_TreeView Exferia_TreeView_Menu { get { return ex_trv_Menu; } }
//Exferia_Panel_Degradado_CambioColor
internal Exferia_Panel_Degradado_CambioColor Exferia_Panel_Degradado_CambioColor_MenuIzquierdo { get { return ex_pnl_MenuIzquierdo; } }
internal Exferia_Panel_Degradado_CambioColor Exferia_Panel_Degradado_CambioColor_Athos { get { return ex_pnl_Athos; } }
//Exferia_Button
internal Exferia_Button Exferia_Button_MenuIzquierdo_AnclarDesanclar { get { return ex_btn_MenuIzquierdo_AnclarDesanclar; } }
internal Exferia_Button Exferia_Button_Athos_AnclarDesanclar { get { return ex_btn_Athos_AnclarDesanclar; } }
internal Exferia_Button Exferia_Button_GestionControl { get { return ex_btn_MenuIzquierdo_GestionControl; } }
internal Exferia_Button Exferia_Button_TipoCompraVenta { get { return ex_btn_MenuIzquierdo_TipoCompraVenta; } }
//Exferia_Button_ConBorde
internal Exferia_Button_ConBorde Exferia_Button_ConBorde_CambiarEmpresa { get { return ex_btn_CambiarEmpresa; } }
//Exferia_Button_Vertical
internal Exferia_Button_Vertical Exferia_Button_Vertical_MenuIzquierdo_Mostrar { get { return ex_btn_MenuIzquierdo_Mostrar; } }
internal Exferia_Button_Vertical Exferia_Button_Vertical_Athos_Mostrar { get { return ex_btn_MenuAthos_Mostrar; } }
//Label
internal Label Label_ValidacionLicencia { get { return lbl_ValidacionLicencia; } }
#endregion
#region Constructor
public P_Principal(string[] _arr_Argumentos_Recibidos)
{
InitializeComponent();
//Asignar Colores de Exferia ..................................................................
Colores.G_COLOR_FONDO_BOTON = Color.Transparent;
Colores.G_COLOR_PRINCIPAL_BASE = ColorTranslator.FromHtml("#A19CC3");
Colores.G_COLOR_PRINCIPAL_OSCURO = ColorTranslator.FromHtml("#504888");
Colores.G_COLOR_PRINCIPAL_ATENUADO = ColorTranslator.FromHtml("#CBC8DF");
Colores.G_COLOR_PRINCIPAL_CLARO = ColorTranslator.FromHtml("#EDECF4");
Colores.G_COLOR_PRINCIPAL_TRASLUCIDO = Color.FromArgb(50, 191, 186, 225);
Colores.G_COLOR_SECUNDARIO_BASE = ColorTranslator.FromHtml("#FFF2C4");
Colores.G_COLOR_SECUNDARIO_CLARO = ColorTranslator.FromHtml("#FFF9E1");
Colores.G_COLOR_FONDO_BASE = ColorTranslator.FromHtml("#FFFFFF");
Colores.G_COLOR_TEXTO_ESCRITO = ColorTranslator.FromHtml("#000000");
Colores.G_COLOR_ATENCION = ColorTranslator.FromHtml("#c40909");
Colores.G_COLOR_LISTADO_FILTROS = Color.FromArgb(50, 161, 156, 195);
Colores.G_COLOR_LISTADO_FILTROS_CONTROLESPERSONALIZADOS = Color.FromArgb(70, 161, 156, 195);
Colores.G_COLOR_FONDO_BARRAPROGRESO_RELLENA = ColorTranslator.FromHtml("#504888");
Repintar.Empezar(this);
Cargar_Imagen_Fondo();
g_obj_Controladora = new P_Principal_Controladora(this, _arr_Argumentos_Recibidos);
try
{
CheckForIllegalCrossThreadCalls = false;
Borrar_Ficheros_Viejos();
Copiar_FicherosIncrustados();
Funciones.Rellenar_Denominaciones();
Funciones.Rellenar_OpcionTablaCampoCodigo();
Funciones_Procesos.Rellenar_Procesos();
Funciones_PanelSecundario.Rellenar_Listados_ArbolSecundarioSeleccion();
Funciones_FicherosXML.CargarDatosXML_ImpresoraDocumentoLocal();
Variables.G_SPL_PANTALLASPRINCIPAL = spl_Principal;
Variables.G_PNL_PANTALLASEMPOTRADAS = spl_Principal.Panel1;
Variables.G_PNL_PANTALLASEMPOTRADAS_SECUNDARIA = spl_Principal.Panel2;
Variables.G_EMS_CONTROL_MENUSUPERIOR = ex_msp_Menu;
Variables.G_OBJ_CONTROLADORA_PANTALLAPRINCIPAL = g_obj_Controladora;
Variables.G_EX_BTN_IMPRESORASLOCALES_PANTALLAPRINCIPAL = ex_btn_P_Principal_ImpresorasLocal;
//calcular distancia del splitter
spl_Principal.SplitterDistance = this.Width / 2;
spl_Principal.Panel2Collapsed = true;
//Version
FileVersionInfo fv = System.Diagnostics.FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
lbl_Version.Text = "Versión: " + fv.FileVersion.ToString();
//Datos del Equipo
try
{
Variables.G_STR_VERSION_SIGMAERP = fv.FileVersion.ToString();
Variables.G_STR_EQUIPO_MAC = Funciones.Obtener_Direccion_Mac();
Variables.G_STR_EQUIPO_NOMBRE = Funciones.Obtener_NombreEquipo();
}
catch
{ }
try
{
Funciones_FicherosXML.CargarDatosXML_OrdenDireccionesActualizacion();
}
catch
{}
//Tarea Asincrona para Comprobar la Validación de la Activación
g_bgw_Validacion_Licencia = new BackgroundWorker();
g_bgw_Validacion_Licencia.DoWork += new DoWorkEventHandler(TareaAsincrona_Validacion_Licencia_DoWork);
g_bgw_Validacion_Licencia.RunWorkerCompleted += new RunWorkerCompletedEventHandler(TareaAsincrona_Validacion_Licencia_Completed);
g_bgw_Validacion_Licencia.WorkerReportsProgress = false;
g_bgw_Validacion_Licencia.WorkerSupportsCancellation = true;
//El Timer se Utiliza para que cada 5 minutos intente validar si esta activada correctamente esta aplicacion en el Servidor
g_timer_TareaAsicrona_Validacion_Licencia.Interval = 10000;
g_timer_TareaAsicrona_Validacion_Licencia.Tick += delegate (object s, EventArgs ee)
{
Validacion_Licencia();
};
}
catch (Control_Errores)
{ }
catch (Exception ex)
{
//No se muestra mensaje pero se guarda en el log
Control_Errores.Errores_Log("", ex, nameof(P_Principal) + "/" + nameof(P_Principal));
}
finally
{
//Bloquear pantalla hasta que termine la carga por defecto .....
Enabled = true;
//.............................................................
}
}
#endregion
#region Inicio de pantalla
private void P_Principal_Load(object sender, EventArgs e)
{
try
{
#region TEMPORIZADOR MENU BUSCAR
g_timer_Menu_Buscar.Interval = 1000;
g_timer_Menu_Buscar.Tick += delegate (object s, EventArgs ee)
{
g_timer_Menu_Buscar.Stop();
g_obj_Controladora.Recarga_Datos_Arbol_Permisos(true);
};
#endregion
}
catch(Exception ex)
{
Control_Errores.Errores_Log("", ex, nameof(P_Principal) + "/" + nameof(P_Principal_Load));
}
}
private void P_Principal_Shown(object sender, EventArgs e)
{
Iniciar();
}
#endregion
#region Borrar Ficheros y librerias que no sirven
private void Borrar_Ficheros_Viejos()
{
try
{
#region Tesseract
//Libreria
File.Delete(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\Tesseract.dll");
File.Delete(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\Tesseract.txt");
//Carpetas
if (Directory.Exists(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\tessdata"))
{
Directory.Delete(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\tessdata", true);
}
if (Directory.Exists(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\x64"))
{
Directory.Delete(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\x64", true);
}
if (Directory.Exists(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\x86"))
{
Directory.Delete(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\x86", true);
}
#endregion
#region Spire
//Libreria
File.Delete(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\Spire.dll");
File.Delete(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\Spire.txt");
#endregion
}
catch (Exception ex)
{
//No se muestra mensaje pero se guarda en el log
Control_Errores.Errores_Log("", ex, nameof(P_Principal) + "/" + nameof(Borrar_Ficheros_Viejos));
}
}
#endregion
#region Copiar Ficheros Incrustados
private void Copiar_FicherosIncrustados()
{
try
{
#region Librerias PDFLibNet
//PdfLibNetLibrary ##################################################################################
byte[] arr_Fichero_incrustado_PdfLibNetLibrary = null;
Assembly obj_Assembly_PdfLibNetLibrary = System.Reflection.Assembly.GetExecutingAssembly();
using (Stream obj_Stream_Fichero = obj_Assembly_PdfLibNetLibrary.GetManifestResourceStream("SigmaERP.FicherosIncrustados.PdfLibNetLibrary.dll"))
{
if (obj_Stream_Fichero != null)
{
arr_Fichero_incrustado_PdfLibNetLibrary = new byte[obj_Stream_Fichero.Length];
obj_Stream_Fichero.Read(arr_Fichero_incrustado_PdfLibNetLibrary, 0, arr_Fichero_incrustado_PdfLibNetLibrary.Length);
}
}
if (!File.Exists(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables_SigmaERP.G_STR_EXFERIA_PDFLIBNETLIBRARY))
{
//poner en la carpeta
File.WriteAllBytes(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables_SigmaERP.G_STR_EXFERIA_PDFLIBNETLIBRARY, arr_Fichero_incrustado_PdfLibNetLibrary);
}
//PdfLibNet32 ##################################################################################
byte[] arr_Fichero_incrustado_PdfLibNet32 = null;
Assembly obj_Assembly_PdfLibNet32 = System.Reflection.Assembly.GetExecutingAssembly();
using (Stream obj_Stream_Fichero = obj_Assembly_PdfLibNet32.GetManifestResourceStream("SigmaERP.FicherosIncrustados.PdfLibNet32.dll"))
{
if (obj_Stream_Fichero != null)
{
arr_Fichero_incrustado_PdfLibNet32 = new byte[obj_Stream_Fichero.Length];
obj_Stream_Fichero.Read(arr_Fichero_incrustado_PdfLibNet32, 0, arr_Fichero_incrustado_PdfLibNet32.Length);
}
}
if (!File.Exists(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables_SigmaERP.G_STR_EXFERIA_PDFLIBNET32))
{
//poner en la carpeta
File.WriteAllBytes(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables_SigmaERP.G_STR_EXFERIA_PDFLIBNET32, arr_Fichero_incrustado_PdfLibNet32);
}
//PDFLibNet64 ##################################################################################
byte[] arr_Fichero_incrustado_PDFLibNet64 = null;
Assembly obj_Assembly_PDFLibNet64 = System.Reflection.Assembly.GetExecutingAssembly();
using (Stream obj_Stream_Fichero = obj_Assembly_PDFLibNet64.GetManifestResourceStream("SigmaERP.FicherosIncrustados.PDFLibNet64.dll"))
{
if (obj_Stream_Fichero != null)
{
arr_Fichero_incrustado_PDFLibNet64 = new byte[obj_Stream_Fichero.Length];
obj_Stream_Fichero.Read(arr_Fichero_incrustado_PDFLibNet64, 0, arr_Fichero_incrustado_PDFLibNet64.Length);
}
}
if (!File.Exists(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables_SigmaERP.G_STR_EXFERIA_PDFLIBNET64))
{
//poner en la carpeta
File.WriteAllBytes(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables_SigmaERP.G_STR_EXFERIA_PDFLIBNET64, arr_Fichero_incrustado_PDFLibNet64);
}
#endregion
#region Actualizador
bool bol_Copiar_ExferiaActualizador = false;
byte[] arr_Fichero_incrustado_Actualizador = null;
//Version del ExferiaActualiazdor.exe incrustado
string str_Version_Fichero_Incrustado = "";
Assembly obj_Assembly_Actualizador = System.Reflection.Assembly.GetExecutingAssembly();
using (Stream obj_Stream_Fichero = obj_Assembly_Actualizador.GetManifestResourceStream("SigmaERP.FicherosIncrustados.ExferiaActualizador.exe"))
{
if (obj_Stream_Fichero != null)
{
arr_Fichero_incrustado_Actualizador = new byte[obj_Stream_Fichero.Length];
obj_Stream_Fichero.Read(arr_Fichero_incrustado_Actualizador, 0, arr_Fichero_incrustado_Actualizador.Length);
Assembly obj_Assembly_AUX = System.Reflection.Assembly.Load(arr_Fichero_incrustado_Actualizador);
str_Version_Fichero_Incrustado = obj_Assembly_AUX.GetName().Version.ToString();
}
}
//Existe ExferiaActualiazdor.exe
if (File.Exists(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables_SigmaERP.G_STR_EXFERIA_ACTUALIZADOR))
{
FileVersionInfo obj_FileVersion_Exferia_Aplicacion = FileVersionInfo.GetVersionInfo(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables_SigmaERP.G_STR_EXFERIA_ACTUALIZADOR);
Version obj_Version_Exferia_Aplicacion = Version.Parse(obj_FileVersion_Exferia_Aplicacion.FileVersion);
string str_Version_Fichero_Local = obj_Version_Exferia_Aplicacion.ToString();
if (str_Version_Fichero_Local != str_Version_Fichero_Incrustado)
{
//Borrar el Fichero Local
File.Delete(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables_SigmaERP.G_STR_EXFERIA_ACTUALIZADOR);
bol_Copiar_ExferiaActualizador = true;
}
}
else
{
bol_Copiar_ExferiaActualizador = true;
}
if (bol_Copiar_ExferiaActualizador)
{
//poner en la carpeta
File.WriteAllBytes(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables_SigmaERP.G_STR_EXFERIA_ACTUALIZADOR, arr_Fichero_incrustado_Actualizador);
}
#endregion
}
catch (Exception ex)
{
//No se muestra mensaje pero se guarda en el log
Control_Errores.Errores_Log("", ex, nameof(P_Principal) + "/" + nameof(Copiar_FicherosIncrustados));
}
}
#endregion
private void Iniciar()
{
try
{
//1º Conexion a base de datos
if (Iniciar_ConexionBD())
{
//2º Licencia
if (Iniciar_Licencia())
{
//3º Iniciar las Actualizaciones de las librerias
if (Variables.G_MDL_LICENCIA_VALIDADA.fechaFinActualizaciones == "")
{
Iniciar_Actualizaciones();
}
//4º Validar el Usuario
g_obj_Controladora.Validacion_Usuario();
}
else
{
this.Close();
}
}
else
{
this.Close();
}
}
catch (Exception ex)
{
Control_Errores.Errores_Log("", ex, nameof(P_Principal) + "/" + nameof(Iniciar));
this.Close();
}
}
private bool Iniciar_ConexionBD()
{
bool bol_TodoCorrecto = true;
try
{
//Conexion .......................................
try
{
Funciones_FicherosXML.CargarDatosXML_ConexionBD();
}
catch (Control_Errores)
{
Mensajes.MostrarMensaje(Mensajes.G_STR_MENSAJES_GENERAL_ERROR_CARGA_DATOSXML());
}
//.................................................
//Validar si la Conexion es Correcta ..............
if (Datos_Generales.Comprobar_Conexion_SQLServer())
{
try
{
Funciones_FicherosXML.CargarDatosXML_ConexionBD_KairosPRO();
//Validar Version de EntityFramework de Exferia, por si hay que ejecutar script
Datos_Actualizacion_BD obj_Datos_Actualizacion_BD = new Datos_Actualizacion_BD();
int int_ValorDevuelto = obj_Datos_Actualizacion_BD.Comprobar_Actualizaciones_BD(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_ENTITYFRAMEWORK);
//-1 Ocurrio un Error
// 1 incompatible, version antigua de Exferia_EntityFramework
// 0 Todo Correcto
if (int_ValorDevuelto == 0)
{
//Cambiar el Icono de la impresoras Locales
//Cargamos el ensamblado #########################################################################################################################################################################
Assembly m_assembly_1 = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_INFORMES + ".dll");
//Obtenemos el tipo de la clase
Type m_type_1 = m_assembly_1.GetType("" + Variables.G_STR_LIBRERIA_INFORMES + "." + Variables.G_STR_LIBRERIA_DATOSINFORMES);
//creamos la instancia
var obj_Clase_1 = Activator.CreateInstance(m_type_1);
//Cargamos el metodo solicitado
MethodInfo obj_MethodInfo_1 = obj_Clase_1.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSINFORMES_PROCEDIMIENTO_INFIMPRESORAS_DEVOLVERASIGNACIONIMPRESORASLOCALES, BindingFlags.Instance | BindingFlags.NonPublic);
//Obtener valores
object[] arr_Parametros_1 = { };
//Pasamos los parametros al metodo y lo ejecutamos
int int_ValorAsignacion = (int)obj_MethodInfo_1.Invoke(obj_Clase_1, arr_Parametros_1);
//##################################################################################################################################################################################################
Funciones.Cambiar_Icono_Impresora_PantallaPrincipal(int_ValorAsignacion);
//Comprobamos que exista o no el superadmin, si no existe, lo creará.
Datos_Generales.USR_Usuarios_Existe_SuperAdmin();
}
else
{
bol_TodoCorrecto = false;
}
}
catch (Control_Errores)
{ }
}
else//Si es False se Cierra la Aplicacion
{
bol_TodoCorrecto = false;
}
}
catch (Control_Errores)
{
bol_TodoCorrecto = false;
}
catch (Exception ex)
{
Control_Errores.Errores_Log("", ex, nameof(P_Principal) + "/" + nameof(Iniciar_ConexionBD));
bol_TodoCorrecto = false;
}
return bol_TodoCorrecto;
}
private bool Iniciar_Licencia()
{
bool bol_TodoCorrecto = true;
try
{
INTERNO_ServicioWeb_Licencia_Modelo mdl_INTERNO_ServicioWeb_Licencia_Modelo_Temporal = Funciones_FicherosXML.CargarDatosXML_Licencia();
if (mdl_INTERNO_ServicioWeb_Licencia_Modelo_Temporal == null)
{
//Pedir Datos del Cliente
PE_ValidacionLicencia frm_PE_ValidacionLicencia = new PE_ValidacionLicencia();
frm_PE_ValidacionLicencia.ShowDialog();
if (frm_PE_ValidacionLicencia.PE_ValidacionLicencia_ValidacionCorrecta == false)
{
bol_TodoCorrecto = false;
}
else
{
//Reiniciar Aplicacion
Application.Restart();
}
}
else
{
Variables.G_LNG_IDCLIENTE_LICENCIAVALIDADO = mdl_INTERNO_ServicioWeb_Licencia_Modelo_Temporal.idCliente;
Variables.G_MDL_LICENCIA_VALIDADA = mdl_INTERNO_ServicioWeb_Licencia_Modelo_Temporal;
//GRBAR EN BASE DE DATOS
PRV_LicenciaDatos mdl_PRV_LicenciaDatos = new PRV_LicenciaDatos();
mdl_PRV_LicenciaDatos.id = -1;
mdl_PRV_LicenciaDatos.idCliente = mdl_INTERNO_ServicioWeb_Licencia_Modelo_Temporal.idCliente;
mdl_PRV_LicenciaDatos.nombreComercial = mdl_INTERNO_ServicioWeb_Licencia_Modelo_Temporal.ClienteNombreComercial;
mdl_PRV_LicenciaDatos.razonSocial = mdl_INTERNO_ServicioWeb_Licencia_Modelo_Temporal.ClienteRazonSocial;
Datos_Generales.PRV_LicenciaDatos_Grabar(mdl_PRV_LicenciaDatos);
//Bloquear opciones antes de que se valide con el ServicioWEB
Datos_Generales.PRV_OpcionesDisponiblesParaCliente_Bloquear_Productos_SegunLicenciasFechas(mdl_INTERNO_ServicioWeb_Licencia_Modelo_Temporal);
Datos_Generales.PRV_Productos_Cargar();
//validar licencia con el Servidor
g_timer_TareaAsicrona_Validacion_Licencia.Start();
}
}
catch (Control_Errores)
{
bol_TodoCorrecto = false;
}
catch (Exception ex)
{
Control_Errores.Errores_Log("", ex, nameof(P_Principal) + "/" + nameof(Iniciar_Licencia));
bol_TodoCorrecto = false;
}
return bol_TodoCorrecto;
}
private void Iniciar_Actualizaciones()
{
try
{
// Proceso de actualización
ProcessStartInfo obj_ProcessStartInfo = new ProcessStartInfo();
//Grabar en Fichero
Registry.SetValue(Variables.G_STR_KEYNAME, Variables.G_STR_KEYVALUE, 1);
//Ruta Principal
string str_Ruta = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
str_Ruta = str_Ruta.Replace(" ", ",");
//Nombre del Ejecutable
string str_NombreEjecutable = System.IO.Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location);
str_NombreEjecutable = str_NombreEjecutable.Replace(" ", ",");
#region Fibra/ADSL/Local
string str_DireccionesActualizacion = "";
//ADSL/Fibra/Local
if (Variables.G_STR_ORDEN_ACTUALIZACION.Equals("AFL"))
{
str_DireccionesActualizacion = Variables_SigmaERP.G_STR_URL_ACTUALIZACION_NORMAL + "|" +
Variables_SigmaERP.G_STR_URL_ACTUALIZACION_FIBRA + "|" +
Variables_SigmaERP.G_STR_URL_ACTUALIZACION_INTERNA + " ";
}
//ADSL/Local/Fibra
else if (Variables.G_STR_ORDEN_ACTUALIZACION.Equals("ALF"))
{
str_DireccionesActualizacion = Variables_SigmaERP.G_STR_URL_ACTUALIZACION_NORMAL + "|" +
Variables_SigmaERP.G_STR_URL_ACTUALIZACION_INTERNA + "|" +
Variables_SigmaERP.G_STR_URL_ACTUALIZACION_FIBRA + " ";
}
//Local/Fibra/ADSL
else if (Variables.G_STR_ORDEN_ACTUALIZACION.Equals("LFA"))
{
str_DireccionesActualizacion = Variables_SigmaERP.G_STR_URL_ACTUALIZACION_INTERNA + "|" +
Variables_SigmaERP.G_STR_URL_ACTUALIZACION_FIBRA + "|" +
Variables_SigmaERP.G_STR_URL_ACTUALIZACION_NORMAL + " ";
}
//Local/ADSL/Fibra
else if (Variables.G_STR_ORDEN_ACTUALIZACION.Equals("LAF"))
{
str_DireccionesActualizacion = Variables_SigmaERP.G_STR_URL_ACTUALIZACION_INTERNA + "|" +
Variables_SigmaERP.G_STR_URL_ACTUALIZACION_NORMAL + "|" +
Variables_SigmaERP.G_STR_URL_ACTUALIZACION_FIBRA + " ";
}
//Fibra/Local/ADSL
else if (Variables.G_STR_ORDEN_ACTUALIZACION.Equals("FLA"))
{
str_DireccionesActualizacion = Variables_SigmaERP.G_STR_URL_ACTUALIZACION_FIBRA + "|" +
Variables_SigmaERP.G_STR_URL_ACTUALIZACION_INTERNA + "|" +
Variables_SigmaERP.G_STR_URL_ACTUALIZACION_NORMAL + " ";
}
//Fibra/ADSL/Local
else
{
str_DireccionesActualizacion = Variables_SigmaERP.G_STR_URL_ACTUALIZACION_FIBRA + "|" +
Variables_SigmaERP.G_STR_URL_ACTUALIZACION_NORMAL + "|" +
Variables_SigmaERP.G_STR_URL_ACTUALIZACION_INTERNA + " ";
}
#endregion
obj_ProcessStartInfo.Arguments = str_Ruta + " " +
str_DireccionesActualizacion +
str_NombreEjecutable + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_BARCODELIB + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_MAPA_CORE + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_MAPA_WINDOWSFORMS + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_MSHTML + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_ITEXTSHERP + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_PDF4ME + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_NEWTONSOFT + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_GMAQRCODENETENCODINGNET45 + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_ACTUALIZACION_BD + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_AGENDA + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_APLICACION + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_AYUDA + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_COMPRAS + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_CONTABILIDAD + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_CONTROLGASTOS + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_CONTROLES + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_CRM + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_ENTITYFRAMEWORK + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_EXPEDIENTES + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_FORMULARIOS + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_GENERAL + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_GESTIONTASAS + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_HERMES + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_HOTELPUNTOVENTA + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_INFORMES + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_INVENTARIOS + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_KAIROSPRO + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_KAIROSPRO_EF + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_KAIROSPRO_INFORMES + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_KRONOS + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_KRONOS_SERVICIO_WINDOWS + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_MAESTROS + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_MYTHOS + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_PERSONAL + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_PREVISIONES + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_VENTAS + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_SERVICIOS + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_SINCRONIZACION + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_SERVICIOSWEB + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_SISTEMAGESTIONALMACEN + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_TRASPASODATOS + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_CONTRATOSPUBLICOS + " " +
Variables_SigmaERP.G_STR_NOMBRELIBRERIAS_EXFERIA_GESTIONDOCUMENTAL
;
obj_ProcessStartInfo.WindowStyle = ProcessWindowStyle.Normal;
obj_ProcessStartInfo.FileName = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\" + Variables_SigmaERP.G_STR_EXFERIA_ACTUALIZADOR;
//Se lanza el Proceso
Process.Start(obj_ProcessStartInfo);
Application.DoEvents();
Thread.Sleep(1000);
Application.DoEvents();
//Comprobar que la libreria de exferia termino
System.Windows.Forms.Timer timer_AUX = new System.Windows.Forms.Timer();
timer_AUX.Interval = 50;
timer_AUX.Tick += delegate (object s, EventArgs ee)
{
int int_Valor_Actualizador = (int)Registry.GetValue(Variables.G_STR_KEYNAME, Variables.G_STR_KEYVALUE, 0);
if (int_Valor_Actualizador == 1)
{
timer_AUX.Stop();
timer_AUX.Dispose();
}
};
timer_AUX.Start();
//####################################################################
}
catch (Exception ex)
{
Control_Errores.Errores_Log("", ex, nameof(P_Principal) + "/" + nameof(Iniciar_Actualizaciones));
//Grabar en Fichero
Registry.SetValue(Variables.G_STR_KEYNAME, Variables.G_STR_KEYVALUE, 0);
}
}
private void ex_trv_Menu_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
if (e.Node.Tag.ToString().Equals("0"))//Esta Activo
{
g_obj_Controladora.Cargar_Pantalla_SegunNodo(e.Node.Name);
}
}
#region Impresora Local
private void ex_btn_P_Principal_ImpresorasLocal_Click(object sender, EventArgs e)
{
g_obj_Controladora.ImpresorasLocales();
}
#endregion
#region Menu Athos Emergente
private void btn_MenuAthos_Mostrar_Click(object sender, EventArgs e)
{
if (ex_pnl_Athos.Visible)
{
ex_pnl_Athos.Visible = false;
}
else
{
ex_pnl_Athos.Visible = true;
}
}
private void btn_Athos_AnclarDesanclar_Click(object sender, EventArgs e)
{
MenuAthos_AnclarDesanclar(ex_btn_Athos_AnclarDesanclar.Tag.ToString());
}
public void MenuAthos_AnclarDesanclar(string _str_Tipo)
{
//Anclar
if (_str_Tipo.Equals("0"))
{
Variables.G_BOL_MENUATHOS_ANCLADO = true;
Exferia_Button_Athos_AnclarDesanclar.Tag = "1";
Exferia_Button_Athos_AnclarDesanclar.Text = "7";
//Oculto el boton de Menu
Exferia_Button_Vertical_Athos_Mostrar.Visible = false;
//Ruedo el menu para la derecha
Exferia_Panel_Degradado_CambioColor_Athos.Location = new Point(Exferia_Panel_Degradado_CambioColor_Athos.Location.X + Exferia_Button_Vertical_Athos_Mostrar.Width, Exferia_Panel_Degradado_CambioColor_Athos.Location.Y);
//Mover el panel principal
spl_Principal.Size = new Size((spl_Principal.Size.Width - Exferia_Panel_Degradado_CambioColor_Athos.Width) + Exferia_Button_Vertical_Athos_Mostrar.Width, spl_Principal.Size.Height);
}
//Desanclar
else
{
Variables.G_BOL_MENUATHOS_ANCLADO = false;
Exferia_Button_Athos_AnclarDesanclar.Tag = "0";
Exferia_Button_Athos_AnclarDesanclar.Text = "8";
//Ruedo el panel de athos para la izquierda
Exferia_Panel_Degradado_CambioColor_Athos.Location = new Point(Exferia_Panel_Degradado_CambioColor_Athos.Location.X - Exferia_Button_Vertical_Athos_Mostrar.Width, Exferia_Panel_Degradado_CambioColor_Athos.Location.Y);
//Mustro el boton de Menu
Exferia_Button_Vertical_Athos_Mostrar.Visible = true;
//Mover el panel principal
spl_Principal.Size = new Size((spl_Principal.Size.Width + Exferia_Panel_Degradado_CambioColor_Athos.Width) - Exferia_Button_Vertical_Athos_Mostrar.Width, spl_Principal.Size.Height);
}
}
#endregion
#region Menu Izquierdo Emergente
private void btn_MenuIzquierdo_Mostrar_Click(object sender, EventArgs e)
{
if (ex_pnl_MenuIzquierdo.Visible)
{
ex_pnl_MenuIzquierdo.Visible = false;
}
else
{
ex_pnl_MenuIzquierdo.Visible = true;
}
}
private void btn_MenuIzquierdo_AnclarDesanclar_Click(object sender, EventArgs e)
{
MenuIzquierdo_AnclarDesanclar(ex_btn_MenuIzquierdo_AnclarDesanclar.Tag.ToString());
}
public void MenuIzquierdo_AnclarDesanclar(string _str_Tipo)
{
//Anclar
if (_str_Tipo.Equals("0"))
{
Variables.G_BOL_MENUIZQUIERDO_ANCLADO = true;
Exferia_Button_MenuIzquierdo_AnclarDesanclar.Tag = "1";
Exferia_Button_MenuIzquierdo_AnclarDesanclar.Text = "7";
//Oculto el boton de Menu
Exferia_Button_Vertical_MenuIzquierdo_Mostrar.Visible = false;
//Ruedo el menu para la izquierda
Exferia_Panel_Degradado_CambioColor_MenuIzquierdo.Location = new Point(0, Exferia_Panel_Degradado_CambioColor_MenuIzquierdo.Location.Y);
//Mover el panel principal
spl_Principal.Location = new Point(Exferia_Panel_Degradado_CambioColor_MenuIzquierdo.Width + 5, spl_Principal.Location.Y);
spl_Principal.Size = new Size((spl_Principal.Size.Width - Exferia_Panel_Degradado_CambioColor_MenuIzquierdo.Width) + Exferia_Button_Vertical_MenuIzquierdo_Mostrar.Width, spl_Principal.Size.Height);
}
//Desanclar
else
{
Variables.G_BOL_MENUIZQUIERDO_ANCLADO = false;
Exferia_Button_MenuIzquierdo_AnclarDesanclar.Tag = "0";
Exferia_Button_MenuIzquierdo_AnclarDesanclar.Text = "9";
//btn_MenuIzquierdo_AnclarDesanclar.BackgroundImage = global::SigmaERP.Properties.Resources.i_Anclar_No;
//Ruedo el menu para la derecha
Exferia_Panel_Degradado_CambioColor_MenuIzquierdo.Location = new Point(21, Exferia_Panel_Degradado_CambioColor_MenuIzquierdo.Location.Y);
//Mustro el boton de Menu
Exferia_Button_Vertical_MenuIzquierdo_Mostrar.Visible = true;
//Mover el panel principal
spl_Principal.Location = new Point(Exferia_Button_Vertical_MenuIzquierdo_Mostrar.Width + 5, spl_Principal.Location.Y);
spl_Principal.Size = new Size((spl_Principal.Size.Width + Exferia_Panel_Degradado_CambioColor_MenuIzquierdo.Width) - Exferia_Button_Vertical_MenuIzquierdo_Mostrar.Width, spl_Principal.Size.Height);
}
}
private void ex_txt_P_Principal_Busqueda_Exferia_TextBox_Evento_TextChanged(object sender, EventArgs e)
{
g_timer_Menu_Buscar.Stop();
g_timer_Menu_Buscar.Start();
}
#endregion
#region Empresas
public void Cargar_Empresa_Activo()
{
Label_EmpresaEjercicioOrden_Activo.Text =
Variables.G_MDL_INTERNO_VALORESGENERALES_MODELO.str_Empresa_Descripcion + " - " +
"(" + Variables.G_DTT_FECHA_INICIAL_PORDEFECTO.ToString("dd/MM/yyyy") + ")";
}
private void ex_btn_CambiarEmpresa_Click(object sender, EventArgs e)
{
g_obj_Controladora.Cargar_Pantalla_SegunOpcion(Variables.G_STR_OPCION_GEN_EMPRESASELECCION);
}
#endregion
private void Cargar_Imagen_Fondo()
{
try
{
//Si la Imagen en la ruta no existe, copia la que tengo incrustada en el proyecto a la ruta local
if (!File.Exists(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\Imagen_Sigma.png"))
{
Resources.logo_sigmaERP.Save(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\Imagen_Sigma.png");
}
BackgroundImage = Image.FromFile(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\Imagen_Sigma.png");
}
catch (Exception)
{ }
}
#region Licencia
private bool g_bol_Recargar_Arbol = false;
private void ex_btn_CambiarLicencia_Click(object sender, EventArgs e)
{
try
{
//Buscar la opcion del nodo pulsdo
INTERNO_OpcionesDetalle_Modelo mdl_INTERNO_OpcionesDetalle_Modelo = Datos_Generales.PRV_Opciones_Buscar_Detalles(Variables.G_STR_OPCION_GEN_LICENCIASPRODUCTOS);
if (mdl_INTERNO_OpcionesDetalle_Modelo != null)
{
//Cargamos el ensamblado
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_GENERAL + ".dll");
//Obtenemos el tipo de la clase
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_GENERAL + "." + Variables.G_STR_LIBRERIA_OPCIONES);
//creamos la instancia
var obj_Clase = Activator.CreateInstance(m_type);
//Cargamos el metodo solicitado
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_OPCIONES_PROCEDIMIENTO_MOSTRAR_EN_MANTENIMIENTO, BindingFlags.Instance | BindingFlags.NonPublic);
//Obtener valores
object[] arr_Parametros = { Variables.G_STR_OPCION_GEN_LICENCIASPRODUCTOS, null, null, Variables.G_MDL_INTERNO_VALORESGENERALES_MODELO, Variables.G_DTT_FECHA_INICIAL_PORDEFECTO, mdl_INTERNO_OpcionesDetalle_Modelo, -1, "", "", null,null };
//Pasamos los parametros al metodo y lo ejecutamos
obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
}
}
catch (FileNotFoundException ex)
{
Mensajes.MostrarMensaje(Mensajes.G_STR_MENSAJES_GENERAL_NOENCUENTRALIBRERIA());
Control_Errores.Errores_Log("", ex, nameof(P_Principal) + "/" + nameof(ex_btn_CambiarLicencia_Click));
}
catch (Exception ex)
{
Control_Errores.Errores_Log("", ex, nameof(P_Principal) + "/" + nameof(ex_btn_CambiarLicencia_Click));
}
}
private void Validacion_Licencia()
{
try
{
if (g_bol_ValidandoLicencia == false)
{
g_bol_ValidandoLicencia = true;
//## Arrancar Tarea Asincrona ######################
g_bgw_Validacion_Licencia.RunWorkerAsync();
//##################################################
}
}
catch (Exception ex)
{
Control_Errores.Errores_Log("",ex, nameof(P_Principal) + "/" + nameof(Validacion_Licencia));
g_bol_ValidandoLicencia = false;
}
}
private void TareaAsincrona_Validacion_Licencia_DoWork(object sender, DoWorkEventArgs e)
{
INTERNO_ServicioWeb_Licencia_Modelo mdl_INTERNO_ServicioWeb_Licencia_Modelo = new INTERNO_ServicioWeb_Licencia_Modelo();
mdl_INTERNO_ServicioWeb_Licencia_Modelo.respuesta = Variables.G_INT_VALIDARLICENCIA_RESPUESTA_ERROR;
try
{
//Llama al Servicio Web para Actualizar
//Cargamos el ensamblado #########################################################################################################################################################################
Assembly m_assembly_1 = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_SERVICIOWEB + ".dll");
//Obtenemos el tipo de la clase
Type m_type_1 = m_assembly_1.GetType("" + Variables.G_STR_LIBRERIA_SERVICIOWEB + "." + Variables.G_STR_LIBRERIA_DATOSSERVICIOWEB);
//creamos la instancia
var obj_Clase_1 = Activator.CreateInstance(m_type_1);
//Cargamos el metodo solicitado
MethodInfo obj_MethodInfo_1 = obj_Clase_1.GetType().GetMethod(Variables.G_STR_LIBRERIA_DATOSSERVICIOWEB_PROCEDIMIENTO_VALIDAR_LICENCIA, BindingFlags.Instance | BindingFlags.NonPublic);
//Obtener valores
object[] arr_Parametros_1 = { Variables.G_MDL_LICENCIA_VALIDADA.idCliente,
Variables.G_MDL_LICENCIA_VALIDADA.numeroLicencia
};
//Pasamos los parametros al metodo y lo ejecutamos
mdl_INTERNO_ServicioWeb_Licencia_Modelo = (INTERNO_ServicioWeb_Licencia_Modelo)obj_MethodInfo_1.Invoke(obj_Clase_1, arr_Parametros_1);
//##################################################################################################################################################################################################
//Esta validado correctamente
if (mdl_INTERNO_ServicioWeb_Licencia_Modelo.respuesta.Equals(Variables.G_INT_VALIDARLICENCIA_RESPUESTA_NUMEROLICENCIA_CORRECTO))
{
//Actualizar variables validacion de licencia
Variables.G_MDL_LICENCIA_VALIDADA = mdl_INTERNO_ServicioWeb_Licencia_Modelo;
Funciones_FicherosXML.CrearDocumentoXML_Licencia(Variables.G_MDL_LICENCIA_VALIDADA);
g_bol_Recargar_Arbol = Datos_Generales.PRV_OpcionesDisponiblesParaCliente_Actualizar_Segun_ProductosLicenciasFechas();
Datos_Generales.PRV_Productos_Cargar();
//GRBAR EN BASE DE DATOS
PRV_LicenciaDatos mdl_PRV_LicenciaDatos = new PRV_LicenciaDatos();
mdl_PRV_LicenciaDatos.id = -1;
mdl_PRV_LicenciaDatos.idCliente = mdl_INTERNO_ServicioWeb_Licencia_Modelo.idCliente;
mdl_PRV_LicenciaDatos.nombreComercial = mdl_INTERNO_ServicioWeb_Licencia_Modelo.ClienteNombreComercial;
mdl_PRV_LicenciaDatos.razonSocial = mdl_INTERNO_ServicioWeb_Licencia_Modelo.ClienteRazonSocial;
Datos_Generales.PRV_LicenciaDatos_Grabar(mdl_PRV_LicenciaDatos);
}
}
catch (ThreadAbortException ex)
{
Control_Errores.Errores_Log("", ex, nameof(P_Principal) + "" + nameof(TareaAsincrona_Validacion_Licencia_DoWork));
mdl_INTERNO_ServicioWeb_Licencia_Modelo.respuesta = Variables.G_INT_VALIDARLICENCIA_RESPUESTA_ERROR_TAREAASINCRONA;
}
catch (Control_Errores)
{
mdl_INTERNO_ServicioWeb_Licencia_Modelo.respuesta = Variables.G_INT_VALIDARLICENCIA_RESPUESTA_ERROR_TAREAASINCRONA;
}
catch (Exception ex)
{
Control_Errores.Errores_Log("", ex, nameof(P_Principal) + "" + nameof(TareaAsincrona_Validacion_Licencia_DoWork));
mdl_INTERNO_ServicioWeb_Licencia_Modelo.respuesta = Variables.G_INT_VALIDARLICENCIA_RESPUESTA_ERROR_TAREAASINCRONA;
}
finally
{
e.Result = mdl_INTERNO_ServicioWeb_Licencia_Modelo;
}
}
private void TareaAsincrona_Validacion_Licencia_Completed(object sender, RunWorkerCompletedEventArgs e)
{
try
{
INTERNO_ServicioWeb_Licencia_Modelo mdl_INTERNO_ServicioWeb_Licencia_Modelo = (INTERNO_ServicioWeb_Licencia_Modelo)e.Result;
// Hubo un Error en tarea Asincrna
if (mdl_INTERNO_ServicioWeb_Licencia_Modelo.respuesta.Equals(Variables.G_INT_VALIDARLICENCIA_RESPUESTA_ERROR_TAREAASINCRONA))
{ }
// Hubo un Error
else if (mdl_INTERNO_ServicioWeb_Licencia_Modelo.respuesta.Equals(Variables.G_INT_VALIDARLICENCIA_RESPUESTA_ERROR))
{ }
//No esta Activado Correctamente
else if (mdl_INTERNO_ServicioWeb_Licencia_Modelo.respuesta.Equals(Variables.G_INT_VALIDARLICENCIA_RESPUESTA_NUMEROLICENCIA_INCORRECTO))
{
g_timer_TareaAsicrona_Validacion_Licencia.Stop();
g_timer_TareaAsicrona_Validacion_Licencia.Dispose();
PE_ValidacionLicencia frm_PE_ValidacionLicencia = new PE_ValidacionLicencia();
frm_PE_ValidacionLicencia.ShowDialog();
if (frm_PE_ValidacionLicencia.PE_ValidacionLicencia_ValidacionCorrecta == false)
{
this.Close();
}
else
{
if (g_obj_Controladora != null)
{
g_obj_Controladora.Mostrar_DatosLicencia();
}
}
}
// Existe y esta dentro de la validez
else if (mdl_INTERNO_ServicioWeb_Licencia_Modelo.respuesta.Equals(Variables.G_INT_VALIDARLICENCIA_RESPUESTA_NUMEROLICENCIA_CORRECTO))
{
g_timer_TareaAsicrona_Validacion_Licencia.Stop();
g_timer_TareaAsicrona_Validacion_Licencia.Dispose();
if (g_obj_Controladora != null)
{
g_obj_Controladora.Mostrar_DatosLicencia();
}
if (g_bol_Recargar_Arbol)
{
g_obj_Controladora.Recarga_Datos_Arbol_Permisos(false);
}
}
}
catch (Exception ex)
{
Control_Errores.Errores_Log("",ex, nameof(P_Principal) + "/" + nameof(TareaAsincrona_Validacion_Licencia_Completed));
}
finally
{
g_bol_ValidandoLicencia = false;
}
}
#endregion
#region Opciones del Super Administrador
private void ex_btn_MenuIzquierdo_GestionControl_Click(object sender, EventArgs e)
{
try
{
//Buscar la opcion del nodo pulsdo
INTERNO_OpcionesDetalle_Modelo mdl_INTERNO_OpcionesDetalle_Modelo = Datos_Generales.PRV_Opciones_Buscar_Detalles(Variables.G_STR_OPCION_GEN_PERFILESFUNCIONALIDAD);
if (mdl_INTERNO_OpcionesDetalle_Modelo != null)
{
//Cargamos el ensamblado
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_GENERAL + ".dll");
//Obtenemos el tipo de la clase
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_GENERAL + "." + Variables.G_STR_LIBRERIA_OPCIONES);
//creamos la instancia
var obj_Clase = Activator.CreateInstance(m_type);
//Cargamos el metodo solicitado
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_OPCIONES_PROCEDIMIENTO_CARGAR_LISTADO, BindingFlags.Instance | BindingFlags.NonPublic);
//Obtener valores
object[] arr_Parametros = { mdl_INTERNO_OpcionesDetalle_Modelo.opcion, false, 0, null, Variables.G_MDL_INTERNO_VALORESGENERALES_MODELO, Variables.G_DTT_FECHA_INICIAL_PORDEFECTO, "", "", false, false, null, null, null, null, null, null };
//Pasamos los parametros al metodo y lo ejecutamos
obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
}
}
catch (FileNotFoundException ex)
{
Control_Errores.Errores_Log("", ex, nameof(P_Principal) + "/" + nameof(ex_btn_MenuIzquierdo_GestionControl_Click));
}
catch (Exception ex)
{
Control_Errores.Errores_Log("", ex, nameof(P_Principal) + "/" + nameof(ex_btn_MenuIzquierdo_GestionControl_Click));
}
}
private void ex_btn_MenuIzquierdo_TipoCompraVenta_Click(object sender, EventArgs e)
{
try
{
//Buscar la opcion del nodo pulsdo
INTERNO_OpcionesDetalle_Modelo mdl_INTERNO_OpcionesDetalle_Modelo = Datos_Generales.PRV_Opciones_Buscar_Detalles(Variables.G_STR_OPCION_GEN_TIPOCOMPRAVENTA);
if (mdl_INTERNO_OpcionesDetalle_Modelo != null)
{
//Cargamos el ensamblado
Assembly m_assembly = Assembly.LoadFrom(Variables.G_STR_LIBRERIA_RUTAINICIAL + @"\" + Variables.G_STR_LIBRERIA_GENERAL + ".dll");
//Obtenemos el tipo de la clase
Type m_type = m_assembly.GetType(Variables.G_STR_LIBRERIA_GENERAL + "." + Variables.G_STR_LIBRERIA_OPCIONES);
//creamos la instancia
var obj_Clase = Activator.CreateInstance(m_type);
//Cargamos el metodo solicitado
MethodInfo obj_MethodInfo = obj_Clase.GetType().GetMethod(Variables.G_STR_LIBRERIA_OPCIONES_PROCEDIMIENTO_CARGAR_LISTADO, BindingFlags.Instance | BindingFlags.NonPublic);
//Obtener valores
object[] arr_Parametros = { mdl_INTERNO_OpcionesDetalle_Modelo.opcion, false, 0, null, Variables.G_MDL_INTERNO_VALORESGENERALES_MODELO, Variables.G_DTT_FECHA_INICIAL_PORDEFECTO, "", "", false, false, null, null, null, null ,null,null};
//Pasamos los parametros al metodo y lo ejecutamos
obj_MethodInfo.Invoke(obj_Clase, arr_Parametros);
}
}
catch (FileNotFoundException ex)
{
Control_Errores.Errores_Log("", ex, nameof(P_Principal) + "/" + nameof(ex_btn_MenuIzquierdo_TipoCompraVenta_Click));
}
catch (Exception ex)
{
Control_Errores.Errores_Log("", ex, nameof(P_Principal) + "/" + nameof(ex_btn_MenuIzquierdo_TipoCompraVenta_Click));
}
}
#endregion
private void P_Principal_FormClosed(object sender, FormClosedEventArgs e)
{
g_obj_Controladora.Actualizar_Fichero_ConfiguracionXML();
}
#region para que solo tenga una instancia el ERp, y si tiene argumentos abra una pantalla aparte
protected override void WndProc(ref Message m)
{
if (m.Msg == NativeMethods.WM_SHOWME)
{
Activar_FormularioPrincipal();
}
base.WndProc(ref m);
}
private void Activar_FormularioPrincipal()
{
try
{
if (WindowState == FormWindowState.Minimized)
{
WindowState = FormWindowState.Normal;
}
// get our current "TopMost" value (ours will always be false though)
bool top = TopMost;
// make our form jump to the top of everything
TopMost = true;
// set it back to whatever it was
TopMost = top;
string str_RutaTemporal = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\GT.txt";
if (File.Exists(str_RutaTemporal))
{
string str_Argumento = File.ReadAllText(str_RutaTemporal);
File.Delete(str_RutaTemporal);
if (str_Argumento.Trim().Length > 0)
{
string[] arr_Argumentos = new string[1];
arr_Argumentos[0] = str_Argumento;
g_obj_Controladora.g_arr_Argumentos_Recibidos = arr_Argumentos;
g_obj_Controladora.Validar_ArgumentosProgramaExterno();
}
}
}
catch (Exception ex)
{
Control_Errores.Errores_Log("", ex, nameof(P_Principal) + "/" + nameof(Activar_FormularioPrincipal));
}
}
#endregion
}
}