NuevaActualizacion.cs
1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Drawing;
5 using System.Data;
6 using System.Linq;
7 using System.Windows.Forms;
8 using System.IO;
9 using sage.ew.interficies;
10 using sage.ew.objetos.Widgets;
11 using sage.ew.functions;
12 using sage.ew.db;
13 using sage.ew.images.Clases;
14 using sage.ew.formul;
15 using System.Windows.Threading;
16 using sage.ew.usuario;
17 using sage.ew.global;
18 using System.Diagnostics;
19 using System.Web.Script.Serialization;
20 using sage.ew.ewbase;
21 using sage.ew.functions.Clases;
22 using Sage.ES.Onboarding.Clases;
23 using sage._50;
24 using System.Threading;
25 
26 namespace sage.ew.objetos
27 {
35  {
36  #region Implementación de las propiedades de las interficies
37  [
41  Category("General"),
42  DisplayName("Editando"),
43  DefaultValue(false),
44  DescriptionAttribute("Indica si el control está en modo de edición"),
45  Browsable(false)
46  ]
47  public new bool _Editando
48  {
49  get { return _lEditando; }
50  set
51  {
52  _lEditando = value;
53 
54  if (_lEditando && !Visible) // En modo de edición lo tenemos de hacer visible
55  Visible = true;
56  }
57  }
58 
62  [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
63  [Browsable(false)]
64  public new ControladorDesktop _ControladorDesktop
65  {
66  get { return _oControladorDesktop; }
67  set { _oControladorDesktop = value; }
68  }
69  ControladorDesktop _oControladorDesktop = null;
70 
71  #endregion Implementación de las propiedades de las interficies
72 
73  #region Propiedades privadas
74  private bool _lEditando = false;
75 
79  private bool _lVisible = false;
80 
81  private string _cRuta_Prgs_err = string.Empty;
82  private string _cRuta_Temp_Prgs_err = string.Empty;
83  private bool _llRenameOk = true;
84  private bool _llCloseApplication = false;
85 
89  private bool _lActualizando = false;
90  private bool _lUpdateVariables = false;
91 
92  private StateActualizacion _oStateActualizacion = StateActualizacion.SinEstado;
93 
94  private string _cMensaje_Error = string.Empty;
95  private const string _cFileUpdateSage50 = "ActualizarSage50.exe";
96  private string _cPathIniTerminal = string.Empty;
97  private string _cPathIniServidor = string.Empty;
98  private string _cText = "Nueva actualización de " + Convert.ToString(EW_GLOBAL._GetVariable("wc_nameproducto"));
99 
104  private string _cVersionSage50Webservice = string.Empty;
105 
109  private string _cFechaPublicaSage50Webservice = string.Empty;
110 
111  private string _cKeyCopy = string.Empty;
112 
113  private BusinessNuevaActualizacion _oBusinessNuevaActualizacion = null;
114 
118  private BackgroundWorker _oBackgroundWorker;
119 
123  private bool _lBackgroudWorkerIsRunning = false;
124 
128  private ewToolTip _oToolTip = null;
129 
133  private string _cToolTip = string.Empty;
134 
138  private string _cVersionTerminalDllSage50
139  {
140  get
141  {
142  if (string.IsNullOrWhiteSpace(_cVersionTerminalDll))
143  _cVersionTerminalDll = VersionNumber._Sage50Version;
144 
145  return _cVersionTerminalDll;
146  }
147  }
148  private string _cVersionTerminalDll = string.Empty;
149 
153  private string _cVersionServidorDllSage50
154  {
155  get
156  {
157  if (string.IsNullOrWhiteSpace(_cVersionDllServidor))
158  _cVersionDllServidor = VersionNumber._Sage50VersionServidor();
159 
160  return _cVersionDllServidor;
161  }
162  }
163  private string _cVersionDllServidor = string.Empty;
164 
165  private string _cNameProducto = Convert.ToString(EW_GLOBAL._GetVariable("wc_nameproducto"));
166 
170  private Dictionary<string, object> _dictVersionActualizacion = new Dictionary<string, object>();
171  #endregion Propiedades privadas
172 
173  #region Propiedades públicas
174  //
178  public InfoNuevaActualizacion _InfoNuevaActualizacion
179  {
180  get
181  {
182  if (_oInfoNuevaActualizacion == null)
183  _oInfoNuevaActualizacion = new InfoNuevaActualizacion();
184 
185  return _oInfoNuevaActualizacion;
186  }
187  }
188 
189  private InfoNuevaActualizacion _oInfoNuevaActualizacion = null;
190  #endregion Propiedades públicas
191 
192  #region Delegados y eventos
193  public delegate void _Refresh_Actualizacion_Handler(bool tlVisible);
197 
201  public event _Refresh_Actualizacion_Handler _Refresh_Actualizacion;
202  #endregion Delegados y eventos
203 
204  #region Enumeración StateActualizacion
205  private enum StateActualizacion
209  {
210  SinEstado = 0,
211  Consultar = 1,
212  Actualizar = 2,
213  PendienteCerrar = 3 // Pendiente de cerrar la aplicación
214  }
215  #endregion Enumeración StateActualizacion
216 
217  #region Enumeración ServidorTerminal
218  public enum eServidorTerminalLib
222  {
226  Indefinido = 0,
230  Servidor = 1,
234  Terminal = 2
235  }
236  #endregion Enumeración StateActualizacion
237 
238  #region Constructor
239  public NuevaActualizacion()
243  {
244  InitializeComponent();
245 
246  if (!DesignMode)
247  {
248  _oBusinessNuevaActualizacion = new BusinessNuevaActualizacion();
249 
250  _cPathIniTerminal = Convert.ToString(EW_GLOBAL._GetVariable("wc_pathinicio")).Trim();
251  _cPathIniServidor = Convert.ToString(EW_GLOBAL._GetVariable("wc_iniservidor")).Trim();
252  _cKeyCopy = Convert.ToString(EW_GLOBAL._GetVariable("wc_keycopy"));
253 
254  SubscripcionEventos();
255  }
256  }
257  #endregion Constructor
258 
259  #region Implementación de los métodos de las interficies
260  public bool _Deleting()
265  {
266  return true;
267  }
268 
274  public bool _Filtrar(bool tlBefore = false)
275  {
276  return true;
277  }
278 
283  public bool _OnRefresh()
284  {
285  _cVersionDllServidor = string.Empty; // Puede que tengamos en el servidor una versión nueva de dlls, en tal caso debe de avisar
286 
287  _GetData_Async();
288 
289  return true;
290  }
291 
296  public bool _OnShow()
297  {
298  return _OnRefresh();
299  }
300 
306  public Dictionary<string, string> _Saving()
307  {
308  Dictionary<string, string> ldReturn = new Dictionary<string, string>();
309  return ldReturn;
310  }
311 
318  public bool _Loading(Dictionary<string, string> tdictPersonalizado)
319  {
320  return true;
321  }
322  #endregion Implementación de los métodos de las interficies
323 
324  #region Métodos públicos
325 
329  public void _ActualizaSage50()
330  {
331  _Actualiza();
332  }
333 
338  public bool _ExisteActualización()
339  {
340  _InfoNuevaActualizacion._ServidorTerminal = eServidorTerminalLib.Indefinido;
341 
342  // Mirar si hay una actualización disponible
343  bool llUpdate = UpdateAvailable();
344  if (!llUpdate)
345  return false;
346 
347  // Cargar la información de la actualización, versiones y fechas
348  _InfoNuevaActualizacion._VersionServidor = _cVersionServidorDllSage50;
349  _InfoNuevaActualizacion._FechaServidor = VersionNumber._ObtenerFechaVersion(Convert.ToString(EW_GLOBAL._GetVariable("wc_IniServidor")).Trim());
350  _InfoNuevaActualizacion._VersionTerminal = _cVersionTerminalDllSage50;
351  _InfoNuevaActualizacion._FechaTerminal = VersionNumber._ObtenerFechaVersion(Convert.ToString(EW_GLOBAL._GetVariable("wc_pathinicio")).Trim());
352  _InfoNuevaActualizacion._VersionActua = _cVersionSage50Webservice;
353  _InfoNuevaActualizacion._FechaActua = _cFechaPublicaSage50Webservice;
354 
355  return true;
356  }
357 
358  #endregion Métodos públicos
359 
360  #region Métodos protected
361  protected internal void _Actualiza()
365  {
366  if (!Visible)
367  {
368  MessageBox.Show($"No es necesario realizar ninguna actualización.{Environment.NewLine}En estos momentos dispone de la última versión de {_cNameProducto}.", _cText, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
369  return;
370  }
371 
372  NuevaActualizacion_Click(ewImagenInformacion, new EventArgs());
373  }
374  #endregion Métodos protected
375 
376  #region Métodos privados
377  private string PathS50(bool tlServidor)
383  {
384  if (tlServidor)
385  return Convert.ToString(EW_GLOBAL._GetVariable("wc_iniservidor"));
386  else
387  return _cPathIniTerminal;
388  }
389 
394  private void SubscripcionEventos(bool tlUnSubscribe = false)
395  {
396  if (tlUnSubscribe)
397  {
398  ewImagenInformacion.Click -= NuevaActualizacion_Click;
399 
400  ewImagenInformacion.MouseEnter -= Imagen_MouseHover;
401  ewImagenInformacion.MouseHover -= Imagen_MouseHover;
402  ewImagenInformacion.MouseLeave -= Imagen_MouseLeave;
403 
404  }
405  else
406  {
407  ewImagenInformacion.Click += NuevaActualizacion_Click;
408 
409  ewImagenInformacion.MouseEnter += Imagen_MouseHover;
410  ewImagenInformacion.MouseHover += Imagen_MouseHover;
411  ewImagenInformacion.MouseLeave += Imagen_MouseLeave;
412  }
413  }
414 
420  private void Imagen_MouseHover(object sender, EventArgs e)
421  {
422  if (Cursor != Cursors.Hand)
423  Cursor = Cursors.Hand;
424  }
425 
431  private void Imagen_MouseLeave(object sender, EventArgs e)
432  {
433  if (Cursor != Cursors.Default)
434  Cursor = Cursors.Default;
435  }
436 
443  private bool InternetConnection_Deprecated(bool tlMessage = false)
444  {
445  if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
446  {
447  if (tlMessage)
448  MessageBox.Show($"Para poder ejecutar el proceso de actualización de {_cNameProducto} es necesario tener una conexión a internet.", _cText, MessageBoxButtons.OK, MessageBoxIcon.Stop);
449 
450  return false;
451  }
452 
453  return true;
454  }
455 
461  private void NuevaActualizacion_Click(object sender, EventArgs e)
462  {
463  bool llActualizar = false;
464 
465  if (!ValidateFilePath(_cPathIniTerminal, _cFileUpdateSage50)) // Validamos que tenemos el ejecutable
466  return;
467 
468  if (_lBackgroudWorkerIsRunning && _oStateActualizacion == StateActualizacion.Actualizar)
469  {
470  DescripcionTooltTip();
471  MessageBox.Show($"En estos momentos ya se está ejecutando la actualización de {_cNameProducto}.", _cText, MessageBoxButtons.OK, MessageBoxIcon.Information);
472  return;
473  }
474 
475  if ((_oStateActualizacion != StateActualizacion.SinEstado && _lBackgroudWorkerIsRunning) || _oStateActualizacion == StateActualizacion.PendienteCerrar)
476  return;
477 
478  if (!PrevalidatePrgs_Err())
479  return;
480 
481  _cVersionDllServidor = string.Empty; // Puede que haya acabado lo actualización y tengamos una nueva versión en el servidor
482  _dictVersionActualizacion = LoadVersionVariable(); // Consultamos la información de la tabla variables
483 
484  DescripcionTooltTip(); // Revisamos el ToolTip
485 
486  if (NowUpdating(tlMessage: true)) // Prevalidamos si se está actualizando en otro terminal
487  return;
488 
489  if (!PrevalidateListasPrevias())
490  return;
491 
492  string lcPregunta = TextoActualizacion(ref llActualizar, true);
493 
494  if (llActualizar && !PuedoActualizar()) // Permitir actualizar desde dentro de la aplicación
495  {
496  MessageBox.Show($"Para poder actualizar {_cNameProducto} debe tener activado el acceso especial 'Permitir actualizar desde dentro de la aplicación'.", _cText, MessageBoxButtons.OK, MessageBoxIcon.Information);
497  return;
498  }
499 
500  if (MessageBox.Show(lcPregunta, _cText, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
501  return;
502 
503  if (VersionDLLs()) // Si tenemos una versión diferente en el servidor cerramos la aplicación
504  {
505  CloseAplication();
506  return;
507  }
508 
509  _oStateActualizacion = StateActualizacion.Actualizar;
510 
511  // Nos desubscribimos para que no pueda pulsar dos veces
512  ewImagenInformacion.Click -= NuevaActualizacion_Click;
513 
514  UpdateVersion();
515 
516  ewImagenInformacion.Click += NuevaActualizacion_Click;
517  }
518 
525  private bool PuedoActualizar()
526  {
527  return ((Convert.ToString(EW_GLOBAL._GetVariable("wc_usuario")).Trim() == "SUPERVISOR") || Usuario._This._Opcesp("5005")); // Permitir actualizar desde dentro de la aplicación
528  }
529 
534  private bool PrevalidatePrgs_Err()
535  {
536  _llRenameOk = true;
537 
538  _cRuta_Prgs_err = FUNCTIONS._AddBS(Path.Combine(_cPathIniServidor, "PRGS_ERR"));
539  _cRuta_Temp_Prgs_err = FUNCTIONS._AddBS(Path.Combine(_cRuta_Prgs_err, "TEMP_ACTUALIZACIONSAGE50"));
540 
541  if (Directory.Exists(_cRuta_Prgs_err))
542  {
543  if (!CreateDirectoryTemp())
544  {
545  MessageBox.Show("Para poder ejecutar el proceso de actualización es necesario tener permisos en la carpeta de PRGS_ERR del servidor.", _cText, MessageBoxButtons.OK, MessageBoxIcon.Stop);
546  return false;
547  }
548 
549  string[] lcFiles = Directory.GetFiles(_cRuta_Prgs_err);
550 
551  lcFiles.AsEnumerable().ToList().ForEach(f => RenameFile(f));
552 
553  RemoveDirectoryTemp();
554  }
555 
556  if (!_llRenameOk)
557  {
558  string lcError = $"Existen ficheros en uso en la carpeta {_cRuta_Prgs_err} del servidor que impiden ejecutar el proceso de actualización de {_cNameProducto}." + Environment.NewLine + Environment.NewLine +
559  $"Ejecute el proceso '{_cFileUpdateSage50}' para realizar la actualización.";
560 
561  if (Convert.ToBoolean(EW_GLOBAL._GetVariable("wl_prueva")) && !string.IsNullOrWhiteSpace(_cMensaje_Error))
562  lcError += Environment.NewLine + Environment.NewLine + _cMensaje_Error;
563 
564  MessageBox.Show(lcError, _cText, MessageBoxButtons.OK, MessageBoxIcon.Stop);
565  }
566 
567  return _llRenameOk;
568  }
569 
574  private bool CreateDirectoryTemp()
575  {
576  bool llOk = true;
577 
578  try
579  {
580  llOk = Directory.Exists(_cRuta_Temp_Prgs_err);
581 
582  if (!llOk)
583  {
584  Directory.CreateDirectory(_cRuta_Temp_Prgs_err);
585  llOk = Directory.Exists(_cRuta_Temp_Prgs_err);
586  }
587  }
588  catch (Exception loEx)
589  {
590  _cMensaje_Error = "No se ha podido crear el directorio temporal para la copia de ficheros." + Environment.NewLine + loEx.Message;
591  }
592 
593  return llOk;
594  }
595 
600  private bool RemoveDirectoryTemp()
601  {
602  bool llOk = true;
603 
604  try
605  {
606  if (Directory.Exists(_cRuta_Temp_Prgs_err))
607  {
608  Directory.Delete(_cRuta_Temp_Prgs_err);
609  llOk = !Directory.Exists(_cRuta_Temp_Prgs_err);
610  }
611  }
612  catch (Exception loEx)
613  {
614  _cMensaje_Error = "No se ha podido eliminar el directorio temporal para la copia de ficheros." + Environment.NewLine + loEx.Message;
615  }
616 
617  return llOk;
618  }
619 
624  private void RenameFile(string tcFile)
625  {
626  if (!_llRenameOk)
627  return;
628 
629  string lcFileName, lcNewFileName;
630 
631  lcFileName = Path.Combine(_cRuta_Prgs_err, tcFile);
632  lcNewFileName = Path.Combine(_cRuta_Temp_Prgs_err, tcFile);
633 
634  try
635  {
636  File.Move(lcFileName, lcNewFileName);
637  }
638  catch (Exception loEx)
639  {
640  _llRenameOk = false;
641  _cMensaje_Error = "No se ha podido renombrar el fichero " + Path.GetFileName(tcFile) + "." + Environment.NewLine + Environment.NewLine + loEx.Message;
642  }
643 
644  if (_llRenameOk)
645  {
646  try
647  {
648  // Restauramos el fichero
649  File.Move(lcNewFileName, lcFileName);
650  }
651  catch (Exception loEx)
652  {
653  _cMensaje_Error = "No se ha podido restaurar el fichero " + Path.GetFileName(tcFile) + "." + Environment.NewLine + Environment.NewLine + loEx.Message;
654  }
655  }
656  }
657 
666  private bool PreValidate()
667  {
668  if (_Editando)
669  {
670  MessageBox.Show("Para actualizar la aplicación es necesario guardar primero el diseño actual.", _cText, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
671  return false;
672  }
673 
674  if (_lActualizando && ExistProcessActualizarSage50()) // Determina que se ha abierto la aplicación
675  {
676  MessageBox.Show("Se está ejecutando el proceso de actualización.", _cText, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
677  return false;
678  }
679 
680  if (!PrevalidateListasPrevias())
681  return false;
682 
683  return true;
684  }
685 
690  private bool PrevalidateListasPrevias()
691  {
692  bool llOk = true;
693 
694  // TODO: Falta gestionar las listas previas de los diferentes terminales
695  int openformsATenerEnCuenta = EW_GLOBAL._OpenForms.Count;
696  for (int nInd = 0; nInd < EW_GLOBAL._OpenForms.Count ; nInd++)
697  {
698  if (EW_GLOBAL._OpenForms.ElementAt(nInd).GetType().Name == "frmAcercaDe" || EW_GLOBAL._OpenForms.ElementAt(nInd).GetType().Name == "frmPrincipal")
699  {
700  openformsATenerEnCuenta --;
701  }
702  }
703 
704  if (openformsATenerEnCuenta > 1)
705  {
706  var loFormsListas = EW_GLOBAL._OpenForms.Where(f => f.Name.ToLower().Trim() == "frmlistasprevias" || f.Name.ToLower().Trim() == "formtabs");
707 
708  llOk = (loFormsListas != null && loFormsListas.Count() > 0);
709 
710  if (!llOk)
711  FUNCTIONS._MessageBox("El proceso de actualización no ha podido finalizar porque se ha detectado alguna de las listas previas que están en uso necesita ser actualizada." + Environment.NewLine+ Environment.NewLine +
712  "Cierra todas las listas previas que tengas abiertas en cualquiera de los ordenadores donde se esté utilizando " + _cNameProducto + " y vuelve a lanzar el proceso de actualización.", _cText, MessageBoxButtons.OK, MessageBoxIcon.Stop);
713  }
714 
715  if (llOk) // Buscaremos el widget de listas previas ...
716  {
717  ControladorDesktop loControlador = (ControladorDesktop)EW_GLOBAL._GetVariable("wo_ControladorDesktop");
718  if (loControlador != null)
719  {
720  List<Control> lstMenus = loControlador._GetWidgets().AsEnumerable().Where(c => c.GetType() == typeof(WidgetFormTabs)).ToList();
721 
722  if (lstMenus.Count > 0 && (lstMenus[0] as WidgetFormTabs)._Listas > 0)
723  {
724  llOk = false;
725  FUNCTIONS._MessageBox("El proceso de actualización no ha podido finalizar porque se ha detectado el widget de listas previas incrustado en un escritorio en uso."+ Environment.NewLine + Environment.NewLine +
726  "Cierra todas las listas previas que tengas abiertas en el diseño del escritorio en cualquiera de los ordenadores donde se esté utilizando " + _cNameProducto + " o cambia a un escritorio donde no exista el widget de listas previas incrustado y vuelve a lanzar el proceso de actualización.", _cText, MessageBoxButtons.OK, MessageBoxIcon.Stop); // Bug 197016
727  }
728  }
729  }
730 
731  return llOk;
732  }
733 
739  private bool ValidatePath(string tcPath)
740  {
741  if (string.IsNullOrWhiteSpace(tcPath) || !Directory.Exists(tcPath))
742  {
743  MessageBox.Show("No se ha definido la ruta del terminal.", _cText, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
744  return false;
745  }
746 
747  return true;
748  }
749 
756  private bool ValidateFilePath(string tcPath, string tcFile)
757  {
758  if (!ValidatePath(tcPath))
759  return false;
760 
761  string lcFilePath = Path.Combine(tcPath, tcFile);
762 
763  if (!File.Exists(lcFilePath))
764  {
765  MessageBox.Show($"No se ha encontrado el ejecutable ActualizarSage50.exe en el terminal necesario para la actualización de {_cNameProducto}.", _cText, MessageBoxButtons.OK, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button1);
766  return false;
767  }
768 
769  return true;
770  }
771 
776  private bool UpdateAvailable()
777  {
778  bool llCont = false;
779 
780  if (!FUNCTIONS.InternetOk())
781  return false;
782 
783  // Consultamos inicialmente la versión de la tabla variables para no realizar la petició si ya se ha consultado hoy
784  _dictVersionActualizacion = LoadVersionVariable();
785 
786  if (ValidDate()) // Si tenemos un registro del día no es necesario realizar la peticion nuevamente al WebService
787  {
788  _cVersionSage50Webservice = _dictVersionActualizacion.ContainsKey("_Version") ? Convert.ToString(_dictVersionActualizacion["_Version"]) : "";
789  _cFechaPublicaSage50Webservice = _dictVersionActualizacion.ContainsKey("_Publicacion") ? Convert.ToString(_dictVersionActualizacion["_Publicacion"]) : "";
790 
791  llCont = IsSuperiorVersionWebServiceServidor() || IsSuperiorVersionWebServiceTerminal();
792  }
793  else
794  {
795  // Ahora realizamos una petición web para ver si existe una actualización pendiente
796  _VersionActualizarSage50WebService();
797 
798  llCont = !string.IsNullOrWhiteSpace(_cVersionSage50Webservice);
799 
800  if (llCont)
801  {
802  llCont = UpdateVariables(false); // Tenemos de actualizar la versión para que no realice más peticiones
803 
804  if (!IsSuperiorVersionWebServiceServidor())
805  llCont = false; // Devuelve una versión anterior a la que tenemos actualmente
806  }
807  }
808 
809  return llCont;
810  }
811 
817  private bool IsSuperiorVersionWebServiceServidor()
818  {
819  bool llOk = (!string.IsNullOrWhiteSpace(_cVersionSage50Webservice) && _cVersionSage50Webservice != _cVersionServidorDllSage50);
820 
821  try
822  {
823  llOk = (ConvertToDecimal(_cVersionSage50Webservice) > ConvertToDecimal(_cVersionServidorDllSage50));
824  }
825  catch (Exception loEx)
826  {
827  _cMensaje_Error = "No se ha podido comparar la versión del servidor" + Environment.NewLine + loEx.Message;
828  }
829 
830  _InfoNuevaActualizacion._ServidorTerminal = llOk ? eServidorTerminalLib.Servidor : _InfoNuevaActualizacion._ServidorTerminal;
831 
832  return llOk;
833  }
834 
839  private bool IsSuperiorVersionServidorTerminal()
840  {
841  bool llOk = false;
842 
843  if (_cVersionTerminalDllSage50 != _cVersionServidorDllSage50)
844  {
845  try
846  {
847  llOk = (ConvertToDecimal(_cVersionServidorDllSage50) > ConvertToDecimal(_cVersionTerminalDllSage50));
848  }
849  catch (Exception)
850  {
851  }
852  }
853 
854  return llOk;
855  }
856 
862  private bool IsSuperiorVersionWebServiceTerminal()
863  {
864  if (IsSuperiorVersionWebServiceServidor())
865  return true;
866 
867  bool llOk = true;
868 
869  try
870  {
871  // Validamos primero que la versión del servidor difiera con la versión del webservice
872  llOk = (!string.IsNullOrWhiteSpace(_cVersionSage50Webservice) && _cVersionSage50Webservice != _cVersionServidorDllSage50);
873 
874  // La versión del webservice puede ser anterior a la versión actual, al menos en entorno de QA
875  llOk = llOk && (ConvertToDecimal(_cVersionSage50Webservice) >= ConvertToDecimal(_cVersionServidorDllSage50));
876 
877  // Adicionalmente la versión del servidor debe de ser superior a la del terminal para poder presentar la imagen
878  // Se puede dar el caso que tengamos las dlls en el servidor pero no en el terminal
879  llOk = llOk && (ConvertToDecimal(_cVersionServidorDllSage50) > ConvertToDecimal(_cVersionTerminalDllSage50));
880  }
881  catch (Exception loEx)
882  {
883  _cMensaje_Error = "No se ha podido comparar la versión del servidor" + Environment.NewLine + loEx.Message;
884  }
885 
886  try
887  {
888  // Se puede dar el caso que tengamos las dlls en el servidor pero no en el terminal
889  llOk = llOk || (ConvertToDecimal(_cVersionSage50Webservice) > ConvertToDecimal(_cVersionTerminalDllSage50));
890  }
891  catch (Exception loEx)
892  {
893  _cMensaje_Error = "No se ha podido comparar la versión del terminal" + Environment.NewLine + loEx.Message;
894  }
895 
896  _InfoNuevaActualizacion._ServidorTerminal = llOk ? eServidorTerminalLib.Terminal : _InfoNuevaActualizacion._ServidorTerminal;
897 
898  return llOk;
899  }
900 
906  private decimal ConvertToDecimal(string tcVersion)
907  {
908  decimal lnVersion = 0;
909 
910  try
911  {
912  lnVersion = Convert.ToDecimal(tcVersion.Replace(".", "").Replace(",", ""));
913  }
914  catch (Exception loEx)
915  {
916  _cMensaje_Error = "Se ha producido un error al convertir la versión" + Environment.NewLine + loEx.Message;
917  }
918 
919  return lnVersion;
920  }
921 
926  private string VersionVariables()
927  {
928  string lcVersion = "0";
929 
930  if (_dictVersionActualizacion.ContainsKey("_Version"))
931  lcVersion = Convert.ToString(_dictVersionActualizacion["_Version"]);
932 
933  return lcVersion;
934  }
935 
941  private bool VersionDLLs()
942  {
943  if (_oStateActualizacion == StateActualizacion.PendienteCerrar)
944  return true;
945 
946  return IsSuperiorVersionServidorTerminal();
947  }
948 
953  private bool ValidDate()
954  {
955  bool llOk = false;
956 
957  if (_dictVersionActualizacion.Count > 0 && _dictVersionActualizacion.ContainsKey("_Fecha"))
958  {
959  try
960  {
961  //llOk = ((Convert.ToDateTime(_dictVersionActualizacion["_Fecha"]).Date) == DateTime.Now.Date);
962  //Task 182137 - Coger DateTime.UtcNow porque al deserializar coge la hora Utc
963  llOk = ((Convert.ToDateTime(_dictVersionActualizacion["_Fecha"])) > DateTime.UtcNow);
964  }
965  catch (Exception loEx)
966  {
967  _cMensaje_Error = "Fecha no válida." + Environment.NewLine + loEx.Message;
968  }
969  }
970 
971  return llOk;
972  }
973 
981  private bool NowUpdating(bool tlUpdate = false, bool tlMessage = false, bool tlAferUpdate = false)
982  {
983  if (!FUNCTIONS.InternetOk())
984  return false;
985 
986  bool llUpdating = false;
987 
988  if (_dictVersionActualizacion.Count > 0 && _dictVersionActualizacion.ContainsKey("_Actualizando"))
989  {
990  llUpdating = Convert.ToBoolean(_dictVersionActualizacion["_Actualizando"]);
991 
992  if (llUpdating && _dictVersionActualizacion.ContainsKey("_Fecha"))
993  {
994  DateTime ldFecha = Convert.ToDateTime(_dictVersionActualizacion["_Fecha"]).Date;
995  llUpdating = (ldFecha > DateTime.Now.Date && !tlAferUpdate); // Si no es la fecha del día en devolveremos que no se está actualizando
996 
997  // Podriamos gestionar el KeyCopy para saber si somos nosotros o otro terminal
998  // Despues de la actualziación ha de quedar a false si o si _Actualizando
999  if ((tlUpdate && !llUpdating) || tlAferUpdate)
1000  UpdateVariables(false);
1001  }
1002  }
1003 
1004  if (llUpdating && tlMessage)
1005  {
1006  DescripcionTooltTip();
1007  MessageBox.Show($"En estos momentos se está actualizando la versión de {_cNameProducto}.", _cText, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
1008  }
1009 
1010  return llUpdating;
1011  }
1012 
1016  private void DescripcionTooltTip()
1017  {
1018  if (_oToolTip == null)
1019  _oToolTip = new ewToolTip();
1020 
1021  bool llActualizar = false;
1022  string lcTexto = TextoActualizacion(tlActualizar: ref llActualizar);
1023  _oToolTip.SetToolTip(ewImagenInformacion, lcTexto);
1024  }
1025 
1032  private string TextoActualizacion(ref bool tlActualizar, bool tlQuestion = false)
1033  {
1034  string lcTexto = "";
1035 
1036  if (NowUpdating())
1037  lcTexto = $"En estos momentos se está ejecutando la actualización de {_cNameProducto}.";
1038  else
1039  {
1040  if (VersionDLLs())
1041  {
1042  lcTexto = $"Existe la nueva versión {_cVersionServidorDllSage50} disponible en el servidor para actualizar {_cNameProducto}";
1043 
1044  if (tlQuestion)
1045  lcTexto += "." + Environment.NewLine + Environment.NewLine + "¿Desea cerrar la aplicación para actualizar a la nueva versión?";
1046  }
1047  else
1048  {
1049  tlActualizar = true;
1050  lcTexto = $"Existe una nueva versión disponible para descargar y actualizar {_cNameProducto}";
1051 
1052  if (tlQuestion)
1053  lcTexto += "." + Environment.NewLine + Environment.NewLine + "¿Desea actualizar a la nueva versión?";
1054  }
1055  }
1056 
1057  return lcTexto;
1058  }
1059 
1064  private string _VersionActualizarSage50WebService()
1065  {
1066  if (!FUNCTIONS.InternetOk())
1067  return "";
1068 
1069  _cVersionSage50Webservice = string.Empty;
1070  _cFechaPublicaSage50Webservice = string.Empty;
1071 
1072  Dictionary<string, object> loDic = new Dictionary<string, object>();
1073  loDic = FUNCTIONS._VersionActualizarSage50WebServiceInfo();
1074 
1075  if (loDic!= null)
1076  {
1077  if (loDic.ContainsKey("Version"))
1078  _cVersionSage50Webservice = Convert.ToString(loDic["Version"]);
1079  if (loDic.ContainsKey("Publicacion"))
1080  _cFechaPublicaSage50Webservice = Convert.ToString(loDic["Publicacion"]);
1081 
1082  // Pasar a formato XX/XX/XXXX
1083  _cFechaPublicaSage50Webservice = FormatFecha(_cFechaPublicaSage50Webservice);
1084  }
1085 
1086  return _cVersionSage50Webservice;
1087  }
1088 
1089 
1095  private Dictionary<string, object> LoadVersionVariable()
1096  {
1097  bool llOk = false;
1098  DataTable ldtVariable = new DataTable();
1099  Dictionary<string, object> loDictVersion = new Dictionary<string, object>();
1100 
1101  llOk = _oBusinessNuevaActualizacion._DatatableVersionVariable(ref ldtVariable);
1102 
1103  _lUpdateVariables = (ldtVariable != null && ldtVariable.Rows.Count > 0);
1104 
1105  if (llOk)
1106  loDictVersion = DeserializaInformationDataTable(ldtVariable);
1107 
1108  FUNCTIONS._DisposeDatatable(ldtVariable);
1109 
1110  return loDictVersion;
1111  }
1112 
1118  private Dictionary<string, object> DeserializaInformationDataTable(DataTable tdtVariable)
1119  {
1120  Dictionary<string, object> loDictInformacion = new Dictionary<string, object>();
1121 
1122  if (tdtVariable != null && tdtVariable.Rows.Count > 0)
1123  {
1124  string lcValor = Convert.ToString(tdtVariable.Rows[0]["valor"]).Trim();
1125 
1126  if (!string.IsNullOrWhiteSpace(lcValor))
1127  {
1128  try
1129  {
1130  loDictInformacion = new JavaScriptSerializer().Deserialize<Dictionary<string, object>>(lcValor);
1131  }
1132  catch (Exception loEx)
1133  {
1134  _cMensaje_Error = "No se ha podido deserializar la información de la versión de la tabla variables." + Environment.NewLine + loEx.Message;
1135  }
1136  }
1137  }
1138 
1139  return loDictInformacion;
1140  }
1141 
1146  private void RefreshDictValues(bool tlActualizando)
1147  {
1148  _dictVersionActualizacion["_Fecha"] = GetNewDate();
1149  _dictVersionActualizacion["_Version"] = _cVersionSage50Webservice;
1150  _dictVersionActualizacion["_Publicacion"] = _cFechaPublicaSage50Webservice;
1151  _dictVersionActualizacion["_Actualizando"] = tlActualizando;
1152  _dictVersionActualizacion["_Keycopy"] = (tlActualizando ? _cKeyCopy : ""); // Marcamos el usuario que está actualizando
1153  }
1154 
1160  private DateTime GetNewDate()
1161  {
1162  //Cogemos la fecha actual
1163  DateTime ldNewDate = DateTime.Now;
1164 
1165  // Añadimos los días a partir de un número aleatorio entre 1 y 7
1166  ldNewDate = ldNewDate.AddDays(GetRandom(1, 7));
1167 
1168  // Añadimos los minutos a partir de un número aleatorio entre 1 y 47
1169  ldNewDate = ldNewDate.AddMinutes(GetRandom(1, 47));
1170 
1171  // Si la hora es superior a las 20.00h, pondremos 08:00h
1172  DateTime ldDateLimit = new DateTime(ldNewDate.Year, ldNewDate.Month, ldNewDate.Day, 20, 0, 0);
1173  if (DateTime.Compare(ldNewDate, ldDateLimit) > 0)
1174  ldNewDate = new DateTime(ldNewDate.Year, ldNewDate.Month, ldNewDate.Day, 8, 0, 0);
1175 
1176  // Devolver la nueva fecha
1177  return ldNewDate;
1178  }
1179 
1180 
1186  private string FormatFecha(string tcFecha)
1187  {
1188  string lcReturn = tcFecha;
1189  if (tcFecha.Length >= 10 && tcFecha.Substring(4,1) == "-" && tcFecha.Substring(7, 1) == "-")
1190  {
1191  try
1192  {
1193  DateTime ldTime = Convert.ToDateTime(tcFecha);
1194  lcReturn = ldTime.ToShortDateString();
1195  }
1196  catch
1197  {
1198  lcReturn = tcFecha;
1199  }
1200  }
1201  return lcReturn;
1202  }
1203 
1210  private int GetRandom(int tnMin, int tnMax)
1211  {
1212  Random loRandom = new Random();
1213  return loRandom.Next(tnMin, tnMax);
1214  }
1215 
1221  private string Serialize(bool tlActualizando)
1222  {
1223  string lcStringSerialize = string.Empty;
1224 
1225  RefreshDictValues(tlActualizando);
1226 
1227  try
1228  {
1229  lcStringSerialize = new JavaScriptSerializer().Serialize(_dictVersionActualizacion);
1230  }
1231  catch (Exception loEx)
1232  {
1233  _cMensaje_Error = "No se ha podido serializar la información de la versión de la tabla variables." + Environment.NewLine + loEx.Message;
1234  }
1235 
1236  return lcStringSerialize;
1237  }
1238 
1249  private bool UpdateVersion()
1250  {
1251  bool llOk = false;
1252  Dictionary<string, object> dictVersionActualizacion = new Dictionary<string, object>();
1253 
1254  if (!PreValidate())
1255  return false;
1256 
1257  _dictVersionActualizacion = LoadVersionVariable(); // Consultamos la información de la tabla variables
1258 
1259  llOk = UpdateVariables(true);
1260 
1261  if (llOk)
1262  DoWork(); // Ejecutamos la actualización de Sage50
1263 
1264  return llOk;
1265  }
1266 
1272  private bool UpdateVariables(bool tlActualizando)
1273  {
1274  bool llOk = true;
1275 
1276  string lcValores = Serialize(tlActualizando);
1277 
1278  if (_lUpdateVariables)
1279  llOk = _oBusinessNuevaActualizacion._UpdateVariable(lcValores);
1280  else
1281  {
1282  llOk = _oBusinessNuevaActualizacion._InsertVariable(lcValores);
1283  _lUpdateVariables = llOk;
1284  }
1285 
1286  return llOk;
1287  }
1288 
1293  private bool ExistProcessActualizarSage50()
1294  {
1295  Process[] loProcessName = Process.GetProcessesByName("ActualizarSage50");
1296 
1297  bool llExist = loProcessName.Length > 0;
1298 
1299  if (_lActualizando && !llExist)
1300  _lActualizando = false;
1301 
1302  return llExist;
1303  }
1304 
1308  private void AfterUpdate()
1309  {
1310  // Puede que no hay finalizado
1311  _dictVersionActualizacion = LoadVersionVariable(); // Consultamos la información de la tabla variables
1312 
1313  if (!NowUpdating(tlAferUpdate: true))
1314  {
1315  _cVersionDllServidor = string.Empty;
1316 
1317  // Avisamos si la versión del servidor es superior
1318  if (IsSuperiorVersionServidorTerminal())
1319  {
1320  if (MessageBox.Show($"El proceso de actualización de {_cNameProducto} ha finalizado." + Environment.NewLine + Environment.NewLine +
1321  $"¿Desea cerrar {_cNameProducto} para actualizar los cambios de la nueva versión?", _cText, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
1322  {
1323  _llCloseApplication = true;
1324  }
1325  else
1326  {
1327  _cVersionDllServidor = string.Empty;
1328  _oStateActualizacion = StateActualizacion.PendienteCerrar;
1329  }
1330  }
1331  }
1332  }
1333 
1337  private void CloseAplication()
1338  {
1339  if (Application.OpenForms.Count > 0)
1340  {
1341  Form loForm = Application.OpenForms["frmPrincipal"];
1342  if (loForm != null)
1343  {
1344  _50.Forms.frmPrincipal loPripal = (_50.Forms.frmPrincipal)loForm;
1345  loPripal._Terminar_Ejecucion();
1346  }
1347  }
1348  }
1349 
1353  private void ChangeVisibility()
1354  {
1355  Visible = _lVisible;
1356  ewImagenInformacion.Visible = _lVisible;
1357 
1358  if (_Refresh_Actualizacion != null)
1359  _Refresh_Actualizacion(_lVisible);
1360  }
1361 
1370  private bool ExecuteUpdate()
1371  {
1372  if (!FUNCTIONS.InternetOk())
1373  return false;
1374 
1375  bool llOk = false;
1376  string lcError = string.Empty;
1377 
1378  if (!ValidateFilePath(_cPathIniTerminal, _cFileUpdateSage50))
1379  return false;
1380 
1381  try
1382  {
1383  _lActualizando = true;
1384 
1385  llOk = Execute(_cPathIniTerminal, _cFileUpdateSage50, ParamsExecuteUpdate(), ref lcError);
1386 
1387  if (llOk)
1388  {
1389  do
1390  {
1391  Thread.Sleep(5000); // Al estar dentro de la ejecución de un BackGrounWorker el usuario puede continuar trabajando igualmente
1392  }
1393  while (ExistProcessActualizarSage50());
1394  }
1395 
1396  AfterUpdate();
1397 
1398  }
1399  catch (Exception loEx)
1400  {
1401  lcError = loEx.Message;
1402  }
1403 
1404  if (!llOk)
1405  MessageBox.Show($"No se ha podido realizar la actualización de {_cNameProducto}." + Environment.NewLine + lcError, _cText, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
1406 
1407  _lActualizando = false;
1408 
1409  return llOk;
1410  }
1411 
1416  private string ParamsExecuteUpdate()
1417  {
1418  string lcParams = string.Empty;
1419 
1420  Dictionary<string, object> dictParams = new Dictionary<string, object>();
1421  dictParams.Add("Usuario", "SUPERVISOR");
1422  dictParams.Add("ModoAvanzado", false);
1423 
1424  try
1425  {
1426  lcParams = new JavaScriptSerializer().Serialize(dictParams);
1427  lcParams = lcParams.Replace("\"", "\\\"");
1428  }
1429  catch (Exception loEx)
1430  {
1431  _cMensaje_Error = $"No se ha podido serializar la información de la actualizacion de {_cNameProducto}." + Environment.NewLine + loEx.Message;
1432  }
1433 
1434  return lcParams;
1435  }
1436 
1446  private bool Execute(string tcPath, string tcFile, string tcParams, ref string tcError)
1447  {
1448  bool llOk = true;
1449  tcError = string.Empty;
1450 
1451  Process loProcess = new Process();
1452  loProcess.EnableRaisingEvents = false;
1453  ProcessStartInfo loExe = new ProcessStartInfo(Path.Combine(tcPath, tcFile));
1454  loExe.WorkingDirectory = tcPath;
1455  loExe.Arguments = tcParams;
1456  loProcess.StartInfo = loExe;
1457  loProcess.StartInfo.CreateNoWindow = true;
1458  loProcess.EnableRaisingEvents = true;
1459 
1460  try
1461  {
1462  llOk = loProcess.Start();
1463  loProcess.WaitForExit();
1464  }
1465  catch (Exception loEx)
1466  {
1467  tcError = loEx.Message;
1468  llOk = false;
1469  }
1470 
1471  return llOk;
1472  }
1473 
1477  private void LoadImage()
1478  {
1479  if (_lVisible && ewImagenInformacion.Image == null)
1480  ewImagenInformacion.Image = images.Properties.Resources.icon_actualizacion32x24;
1481  }
1482  #endregion Métodos privados
1483 
1484  #region Métodos BackGroundWorker
1485  private void _GetData_Async()
1488  {
1489  DoWork();
1490  }
1491 
1495  private void DoWork()
1496  {
1497  if (!_lBackgroudWorkerIsRunning && _oStateActualizacion != StateActualizacion.PendienteCerrar)
1498  {
1499  _lBackgroudWorkerIsRunning = true;
1500 
1501  //Declaro un nuevo elemento
1502  _oBackgroundWorker = new BackgroundWorker();
1503 
1504  //Configuro
1505  _oBackgroundWorker.WorkerSupportsCancellation = true; // Permitimos realizar la cancelación
1506  _oBackgroundWorker.WorkerReportsProgress = false;
1507 
1508  //Declaro los procesos
1509  _oBackgroundWorker.DoWork += new DoWorkEventHandler(ExecuteRunWorker);
1510  _oBackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RunWorkerCompleted);
1511 
1512  //Inicio la tarea asíncrona
1513  _oBackgroundWorker.RunWorkerAsync();
1514  }
1515  }
1516 
1522  private void ExecuteRunWorker(object sender, DoWorkEventArgs e)
1523  {
1524  try
1525  {
1527  loResult._Resultado = new Dictionary<string, object>() { };
1528 
1529  if (_oStateActualizacion == StateActualizacion.Actualizar)
1530  ExecuteUpdate();
1531  else
1532  {
1533  bool llUpdate = UpdateAvailable();
1534 
1535  loResult._Resultado.Add("ExisteActualizacion", llUpdate);
1536  }
1537 
1538  e.Result = loResult;
1539  }
1540  catch (Exception loEx)
1541  {
1542  DB.Escribir_En_Log_Error(DB.Modo_Registro.Registro_Error, loEx);
1543  }
1544  }
1545 
1551  private void RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
1552  {
1553  if (_llCloseApplication)
1554  CloseAplication();
1555  else
1556  {
1557  if (e.Cancelled == false && e.Error == null && e.Result != null && e.Result is WidgetResultadoBackgroundWorker) //Sino he sido cancelado ni he registrado excepción
1558  {
1559  WidgetResultadoBackgroundWorker loWidgetResultadoBackgroundWorker = (WidgetResultadoBackgroundWorker)e.Result;
1560 
1561  if (_oStateActualizacion == StateActualizacion.Actualizar)
1562  {
1563  if (!_lVisible)
1564  ChangeVisibility(); // Puede que haya realizado la actualización pero no haya actualizado los cambios
1565  }
1566  else
1567  {
1568  if (loWidgetResultadoBackgroundWorker._Resultado.ContainsKey("ExisteActualizacion"))
1569  {
1570  _lVisible = Convert.ToBoolean(loWidgetResultadoBackgroundWorker._Resultado["ExisteActualizacion"]);
1571 
1572  ChangeVisibility();
1573 
1574  LoadImage();
1575  }
1576  }
1577 
1578  if (_lVisible)
1579  DescripcionTooltTip();
1580  }
1581  }
1582 
1583  _oStateActualizacion = StateActualizacion.SinEstado;
1584 
1585  _lBackgroudWorkerIsRunning = false;
1586 
1587  }
1588  #endregion Métodos BackGroundWorker
1589 
1590  #region IDisposable
1591  // Flag: Has Dispose already been called?
1592  bool disposed = false;
1593 
1597  public new void Dispose()
1598  {
1599  Dispose(true);
1600  GC.SuppressFinalize(this);
1601  }
1602 
1607  protected new virtual void Dispose(bool disposing)
1608  {
1609  if (disposed)
1610  return;
1611 
1612  if (disposing)
1613  {
1614  // Free any other managed objects here.
1615  SubscripcionEventos(true);
1616 
1617  if (_oToolTip != null)
1618  _oToolTip.Dispose();
1619 
1620  _oBusinessNuevaActualizacion = null;
1621 
1622  _oBackgroundWorker?.Dispose();
1623  _oBackgroundWorker = null;
1624 
1625  _dictVersionActualizacion?.Clear();
1626  _dictVersionActualizacion = null;
1627 
1628  if (components != null)
1629  components.Dispose();
1630  }
1631 
1632  // Free any unmanaged objects here.
1633  disposed = true;
1634  }
1635 
1640  {
1641  Dispose(false);
1642  }
1643  #endregion IDisposable
1644  }
1645 
1646  #region clase BusinessNuevaActualizacion
1647  public class BusinessNuevaActualizacion
1651  {
1652  #region Propiedades privadas
1653  private string _cVariable = "ACTUA_S50";
1654 
1658  private string _cComunesPripal = "";
1659  #endregion Propiedades privadas
1660 
1661  #region Constrcutor
1662  public BusinessNuevaActualizacion()
1666  {
1667  _cComunesPripal = Convert.ToString(EW_GLOBAL._GetVariable("wc_ComunesPripal"));
1668  _cComunesPripal = string.IsNullOrWhiteSpace(_cComunesPripal) ? DB.DbComunes : _cComunesPripal;
1669  }
1670  #endregion Constrcutor
1671 
1672  #region Métodos públicos
1673 
1679  public bool _DatatableVersionVariable(ref DataTable tdtVariable)
1680  {
1681  bool llOk = (DB.SQLExec("SELECT VALOR FROM " + DB.SQLDatabaseReal(_cComunesPripal, "VARIABLE") + Environment.NewLine +
1682  " WHERE VARIABLE = " + DB.SQLString(_cVariable), ref tdtVariable));
1683 
1684  return llOk;
1685  }
1686 
1692  public bool _InsertVariable(string tcValores)
1693  {
1694  string lcSql;
1695  bool llOk = false;
1696 
1697  lcSql = "INSERT INTO " + DB.SQLDatabaseReal(_cComunesPripal, "VARIABLE") + Environment.NewLine +
1698  " (VARIABLE, VALOR, TIPO) " + Environment.NewLine +
1699  " VALUES (" + DB.SQLString(_cVariable) + " , " + DB.SQLString(tcValores) + ", 'C')";
1700 
1701  llOk = DB.SQLExec(lcSql);
1702 
1703  return llOk;
1704  }
1705 
1711  public bool _UpdateVariable(string tcValores)
1712  {
1713  string lcSql;
1714  bool llOk = false;
1715 
1716  lcSql = "UPDATE " + DB.SQLDatabaseReal(_cComunesPripal, "VARIABLE") + Environment.NewLine +
1717  " SET VALOR = " + DB.SQLString(tcValores) + Environment.NewLine +
1718  " WHERE VARIABLE = " + DB.SQLString(_cVariable);
1719 
1720  llOk = DB.SQLExec(lcSql);
1721 
1722  return llOk;
1723  }
1724 
1725 
1726  #endregion Métodos públicos
1727  }
1728 
1729  #endregion clase BusinessNuevaActualizacion
1730 
1731  #region clase InfoNuevaActualizacion
1732  public class InfoNuevaActualizacion
1736  {
1737  #region Propiedades públicas
1738  public NuevaActualizacion.eServidorTerminalLib _ServidorTerminal { get; set; } = NuevaActualizacion.eServidorTerminalLib.Indefinido;
1742 
1746  public string _VersionServidor { get; set; } = "";
1750  public string _FechaServidor { get; set; } = "";
1751 
1755  public string _VersionTerminal { get; set; } = "";
1756 
1760  public string _FechaTerminal { get; set; } = "";
1761 
1765  public string _VersionActua { get; set; } = "";
1769  public string _FechaActua { get; set; } = "";
1770 
1771  #endregion Propiedades públicas
1772 
1773  #region Constrcutor
1774  public InfoNuevaActualizacion()
1778  {
1779  }
1780  #endregion Constrcutor
1781 
1782  }
1783  #endregion clase InfoNuevaActualizacion
1784 
1785 }
static sage.ew.usuario.Usuario _This
Instancia estática del objeto usuario con los datos del usuario actual (wc_usuario) ...
Definition: clsUsuario.cs:341
Dictionary< string, string > _Saving()
Evento que se produce al guardar el escritorio No realiza ninguna acción
bool _OnRefresh()
Evento que se produce en el refresco del widget
virtual new void Dispose(bool disposing)
Protected implementation of Dispose pattern.
bool _InsertVariable(string tcValores)
Realiza el Insert de la información en la tabla COMUNES!VARIABLE
Clase base para poder basarnos en la creación de widgets, donde ya tendremos implementadas las propie...
bool _OnShow()
Evento que se produce al mostrar el widget
bool _Filtrar(bool tlBefore=false)
Realizar los cambios necesarios en las propiedades filtradas
Estructura de resultados. Se usa este Struct para pasar el resultado de la ejecución desde el hilo de...
Definition: IElemento.cs:453
static String _Sage50Version
Versión de Sage50
_Refresh_Actualizacion_Handler _Refresh_Actualizacion
Desencadena el evento
new void Dispose()
Public implementation of Dispose pattern callable by consumers.
Interfaz que deben cumplir los objetos que se pueden poner en el escritorio de Sage 50 ...
Definition: IElemento.cs:18
Clase de negocio con la información
Widget para las notificaciones de nuevas actualizaciones de Sage50
bool _Loading(Dictionary< string, string > tdictPersonalizado)
Carga personalizada del widget De momento no realizamos el refresco debido a que luego ya realizará e...
bool _DatatableVersionVariable(ref DataTable tdtVariable)
Consulta la información de la tabla COMUNES!VARIABLE para la variable ACTUA_S50
Clase de negocio para la actualización de la información
Clase controlador que se utilizará en el escritorio de Sage 50
static String _ObtenerFechaVersion(string tcPath)
Obtener fecha de la versión del fichero según ruta definida en el parámetro
eServidorTerminalLib
Enumeración para indicar que librerias se tienen de actualizar (servidor o terminal) ...
Clase para determinar el número de versión
void _ActualizaSage50()
Lanza el asistente de actualización si hay versión para actualizar
bool _Opcesp(string tcCodigo)
Método que nos devuelve "true" en caso que el usuario actual tenga acceso a la opción especial con có...
Definition: clsUsuario.cs:1521
bool _UpdateVariable(string tcValores)
Realiza el Update de la información en la tabla COMUNES!VARIABLE
static String _Sage50VersionServidor()
Versión del servidor de Sage50
bool _ExisteActualización()
Método para saber si existe una actualización de Sage50
Interfaz que nos permite configurar el contorno del Widget
Definition: IElemento.cs:170
Dictionary< string, object > _Resultado
Resultado del BackGroundWorker
Definition: IElemento.cs:459
Definición de la clase Usuario
Definition: clsUsuario.cs:113