6 using System.Collections.Generic;
7 using System.ComponentModel;
11 using System.Windows.Forms;
18 internal class AsistenteOffBase : Interficies.IAsistenteOffBase
25 protected internal delegate
void _Mostrar_Progreso(String message);
32 protected internal delegate
void _Porcen_Progreso(decimal porcen,
string message);
37 protected internal event _Mostrar_Progreso _Mostrar_Progreso_Async;
42 protected internal event _Porcen_Progreso _Porcen_Progreso_Async;
46 #region Variables Privadas 48 private bool TerminalSeguridad =
false;
49 private int TipoOffline = 1;
50 private int TipoComunicacion = 2;
52 private clsOffLine toolsOffline =
new clsOffLine();
54 private DataRow sucursal;
56 #endregion Variables Privadas 62 public FtpUserData ftp_user_data =
new FtpUserData();
63 public BindingList<Sucursales> _Sucursales =
new BindingList<Sucursales>();
68 public int IdConf {
get;
set; } = 0;
70 public string IdLog {
get;
set; } =
string.Empty;
75 public int EnvioImagenes {
get;
set; } = 0;
77 public bool NoRecalculoStockTrasRecibir {
get;
set; } =
false;
79 public bool BackupSel {
get;
set; } =
false;
80 public string BackupPath {
get;
set; } =
"";
81 public int BackupNumArchivos {
get;
set; } = 0;
83 public string Hora_Envio {
get;
set; } =
"";
84 public string Hora_Recepcion {
get;
set; } =
"";
85 public string Hora_CargaIni {
get;
set; } =
"";
87 public int Delete_Cen_Mant {
get;
set; } = 1;
88 public int Delete_Cen_Doc {
get;
set; } = 1;
90 public string Serie_Central {
get;
set; } =
"";
92 public string Serie_Sucursal {
get;
set; } =
"";
93 public string Almacen_Sucursal {
get;
set; } =
"";
94 public bool FiltroPorAlmacen {
get;
set; } =
false;
96 public string CuentaOneDrive {
get;
set; } =
"";
97 public string RutaOneDrive {
get;
set; } =
"";
99 public bool ConCargaInicial {
get;
set; } =
false;
104 public string CodigoConfiguracion
108 return _CodigoConfiguracion;
112 bool llCambiado = (_CodigoConfiguracion != value);
114 _CodigoConfiguracion = value;
118 Dictionary<string, object> tablaMultconf = _asistenteOfflineDA.
GetMulticonf(value);
121 IdConf = Convert.ToInt16(tablaMultconf[
"idconf"]);
123 if (tablaMultconf[
"conexion"].ToString() ==
"0")
125 string cadenaEncriptada = tablaMultconf[
"cfg_ftp"].ToString().Trim();
127 string cadenaDesencriptada = toolsOffline.Cadena_Desencriptar(cadenaEncriptada);
129 var trozos = cadenaDesencriptada.Split(
'~');
131 if (trozos.Length == 7)
133 ftp_user_data =
new FtpUserData();
134 ftp_user_data.server = trozos[0].Trim();
135 ftp_user_data.user = trozos[1].Trim();
136 ftp_user_data.password = trozos[2].Trim();
137 ftp_user_data.port = Convert.ToDecimal(trozos[3]);
138 ftp_user_data.proxy = trozos[4].Trim();
139 ftp_user_data.rutaserv = trozos[5].Trim();
140 ftp_user_data.ftp_activo = trozos[6].Trim().ToUpper() ==
"SI";
142 else if (trozos.Length == 9)
144 ftp_user_data =
new FtpUserData();
145 ftp_user_data.server = trozos[0].Trim();
146 ftp_user_data.user = trozos[1].Trim();
147 ftp_user_data.password = trozos[2].Trim();
148 ftp_user_data.port = Convert.ToDecimal(trozos[3]);
149 ftp_user_data.proxy = trozos[4].Trim();
150 ftp_user_data.rutaserv = trozos[5].Trim();
151 ftp_user_data.ftp_activo = trozos[6].Trim().ToUpper() ==
"SI";
152 ftp_user_data.use_ssl_tls = trozos[7].Trim().ToUpper() ==
"SI";
153 ftp_user_data.validate_server_cert = trozos[8].Trim().ToUpper() ==
"SI";
161 ftp_user_data = null;
165 OfflineUpAndDown.IdConf = IdConf;
167 NoRecalculoStockTrasRecibir = Convert.ToBoolean(tablaMultconf[
"rec_stock"]);
173 private string _CodigoConfiguracion =
string.Empty;
178 public bool IsCentral
180 get {
return TipoOffline == 1; }
193 public bool IsSucursal
195 get {
return TipoOffline == 2; }
210 get {
return TipoComunicacion == 2; }
214 TipoComunicacion = 2;
216 TipoComunicacion = 1;
223 public bool IsOneDrive
225 get {
return TipoComunicacion == 1; }
229 TipoComunicacion = 1;
231 TipoComunicacion = 2;
235 protected internal int TipoRecepcion = 1;
236 public bool IsAutomatica
238 get {
return TipoRecepcion == 1; }
248 public bool IsPersonalizada
250 get {
return TipoRecepcion == 2; }
261 public string CodigoSucursal
265 return _CodigoSucursal;
269 _CodigoSucursal = value;
271 if (!
string.IsNullOrEmpty(value))
273 Serie_Sucursal = GetSerieDefectoCurrentSucursal();
274 Almacen_Sucursal = GetAlmacenDefectoCurrentSucursal();
278 private string _CodigoSucursal =
"";
283 public bool EnviarImagenes
287 return _EnviarImagenes;
291 _EnviarImagenes = value;
292 EnvioImagenes = (value ? 0 : 1);
295 private bool _EnviarImagenes =
false;
300 public List<string> Sucursales
304 List<string> sucursales =
new List<string>();
305 foreach (DataRow row
in dtSucursales.Rows)
307 if (row[
"sel"] != DBNull.Value && Convert.ToBoolean(row[
"sel"]))
309 if (IsCentral || (IsSucursal && row[
"codigo"].ToString() == _asistenteOfflineDA.
CodigoSucursalActual()))
311 sucursales.Add(row[
"codigo"].ToString());
322 public DateTime FechaConf
326 if (_FechaConf == null)
328 _FechaConf = GetDate();
337 private DateTime _FechaConf;
342 public DateTime FechaInicial
346 if (_FechaInicial == null)
348 _FechaInicial = GetDate();
350 return _FechaInicial;
354 if (_FechaInicial != value)
356 if (!ValidarQueFechasSonCorrectas(value, FechaFinal))
363 _FechaInicial = value;
367 _FechaInicial = value.Date;
372 private DateTime _FechaInicial;
377 public DateTime FechaFinal
385 if (value <
new DateTime(1900, 1, 1))
387 value = value.Date.AddHours(23).AddMinutes(59).AddSeconds(59);
390 if (_FechaFinal != value)
392 if (!ValidarQueFechasSonCorrectas(_FechaInicial, value))
397 _FechaFinal = value.Date.AddHours(23).AddMinutes(59).AddSeconds(59);
401 private DateTime _FechaFinal = DateTime.Today.AddHours(23).AddMinutes(59).AddSeconds(59);
404 public bool Incidencias
406 get {
return Finalizacion == 2; }
419 private int Finalizacion = 1;
432 private bool _Error =
false;
437 public string _TextStepDetalle
441 if (!
string.IsNullOrEmpty(value))
443 _cTextStepDetalle = value;
444 ActualizarProgresoDetalle();
447 get {
return _cTextStepDetalle; }
449 private string _cTextStepDetalle =
"";
454 public string _TextStepProgreso
458 if (!
string.IsNullOrEmpty(value))
460 _cTextStepProgreso = value;
463 get {
return _cTextStepProgreso; }
465 private string _cTextStepProgreso =
"";
470 public decimal _PorcenProgreso
474 _lnPorcenProgreso = value;
475 ActualizarBarraProgreso();
477 get {
return _lnPorcenProgreso; }
479 private decimal _lnPorcenProgreso = 0.0M;
482 #endregion Propiedades 489 public DataTable dtSucursales =
new DataTable();
492 public AsistenteOffBase()
496 #endregion Constructors 497 public bool ValidarQueFechasSonCorrectas(Nullable<DateTime> tdFechaIni, Nullable<DateTime> tdFechaFin)
503 if (!tdFechaIni.HasValue && !tdFechaFin.HasValue)
508 if (tdFechaIni.HasValue && tdFechaFin.HasValue)
511 int lnResult = DateTime.Compare(tdFechaIni.Value, tdFechaFin.Value);
514 ew.functions.FUNCTIONS._MessageBox(
"La fecha final no puede ser inferior a la inicial.",
"Atención", MessageBoxButtons.OK, MessageBoxIcon.Warning);
521 if (!tdFechaIni.HasValue && tdFechaFin.HasValue)
523 ew.functions.FUNCTIONS._MessageBox(
"No se puede definir la fecha fin sin haber definido la inicial.",
"Atención", MessageBoxButtons.OK, MessageBoxIcon.Warning);
531 public void Cargar_Variables()
533 DataTable tablaDatos = _asistenteOfflineDA.
GetVariables(IdConf.ToString());
534 if (tablaDatos.Rows.Count == 0 || tablaDatos == null)
539 foreach (DataRow variable
in tablaDatos.Rows)
541 switch (variable[
"VARIABLE"].ToString().Trim().ToUpper())
544 if (variable[
"VALOR"].ToString().Trim().ToUpper() ==
"CENTRAL")
550 case "CODIGOSUCURSAL":
551 CodigoSucursal = variable[
"VALOR"].ToString().Trim();
556 var trozos = variable[
"VALOR"].ToString().Split(
'|');
558 if (trozos.Length == 3)
560 BackupSel = trozos[0].Trim().ToUpper() ==
".T.";
561 BackupPath = trozos[1].Trim();
562 BackupNumArchivos = Convert.ToInt32(trozos[2]);
571 case "ENVIARIMAGENES":
572 EnviarImagenes = variable[
"VALOR"].ToString().Trim() ==
".T.";
574 case "FILTROPORALMACEN":
575 FiltroPorAlmacen = variable[
"VALOR"].ToString().Trim() ==
".T.";
577 case "TERMINALSEGURIDAD":
578 TerminalSeguridad = variable[
"VALOR"].ToString().Trim() ==
".T.";
581 Hora_Envio = variable[
"VALOR"].ToString().Trim();
583 case "HORA_RECEPCION":
584 Hora_Recepcion = variable[
"VALOR"].ToString().Trim();
586 case "HORA_CARGAINI":
587 Hora_CargaIni = variable[
"VALOR"].ToString().Trim();
589 case "DELETE_CEN_MANT":
590 Delete_Cen_Mant = variable[
"VALOR"].ToString().Trim() ==
".T." ? 1 : 2;
592 case "DELETE_CEN_DOC":
593 Delete_Cen_Doc = variable[
"VALOR"].ToString().Trim() ==
".T." ? 1 : 2;
596 Serie_Central = variable[
"VALOR"].ToString().Trim();
598 case "NORECALCULOSTOCKIMP":
599 NoRecalculoStockTrasRecibir = variable[
"VALOR"].ToString().Trim() ==
".T.";
604 string lcUsuario = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_usuario")).TrimEnd();
606 if (lcUsuario ==
"SUPERVISOR" || lcUsuario ==
"OFFLINE")
614 if (!
string.IsNullOrEmpty(codConf))
616 CodigoConfiguracion = codConf;
621 if (TipoOffline != 1)
623 sucursal = _asistenteOfflineDA.
GetSucursal(IdConf.ToString(), CodigoSucursal) ?? null;
627 private void cargarSucursales()
629 DataTable tablaDatos = _asistenteOfflineDA.
GetSucursales(IdConf);
632 foreach (DataRow ldrFila
in tablaDatos.Rows)
634 Sucursales suc =
new Sucursales(ldrFila);
638 _Sucursales.Add(suc);
647 public bool ComprobacionesConfiguradoCentraloSucursal()
651 ret = GrupoEmpresaConfiguradoComoCentraloSucursal();
660 public bool ComprobacionesCreadoConfiguracion(
bool lbAsistConf)
664 ret = SeHaCreadoConfiguracion(lbAsistConf);
673 public bool ComprobacionesConfigSoloRecepcion()
682 public bool ComprobacionesConfigSoloEnvio()
691 public bool ComprobacionesUsuarioConfiguracion()
693 string lcUsuario = Convert.ToString(EW_GLOBAL._GetVariable(
"wc_usuario")).TrimEnd();
694 if (lcUsuario !=
"SUPERVISOR" && lcUsuario !=
"OFFLINE" && lcUsuario !=
"SAGESYSTEM")
715 public bool ValidacionEjercicioPredet()
719 if (lcAny == Convert.ToString(EW_GLOBAL._GetVariable(
"wc_any")))
731 public string GetEjercicioPredeterminado()
736 public DataTable GetEjerciciosOffline()
747 public DataTable GetClaves(Dictionary<Int32, string> claves,
string where =
"")
749 StringBuilder sb =
new StringBuilder();
751 foreach (KeyValuePair<int, string> item
in claves)
753 sb.Append(
"'" + item.Value.TrimEnd() +
"'");
754 if (i < claves.Count - 1)
760 string sClaves =
"(" + sb.ToString() +
")";
761 return _asistenteOfflineDA.
GetClaves(sClaves, where);
778 public bool ValidarFechas()
788 public DataTable Datos_TabNetConf(
string codigoConfiguracion)
797 public virtual bool AlmenosUnoMarcadaActivaPaso1()
800 foreach (DataRow row
in dtSucursales.Rows)
802 if (row[
"sel"] != DBNull.Value && Convert.ToBoolean(row[
"sel"]) && Convert.ToBoolean(row[
"activa"]))
816 public DataTable GetSucursales()
818 DataTable ret = dtSucursales.Clone();
820 foreach (DataRow row
in dtSucursales.Rows)
822 if (row[
"sel"] != DBNull.Value && Convert.ToBoolean(row[
"sel"]) && Convert.ToInt32(row[
"activa"]) != 0)
835 public Dictionary<int, int> ObtenerPrioridades()
839 Dictionary<int, int> dicPrioridades =
new Dictionary<int, int>();
845 foreach (DataRow rowPrioridad
in datos.Rows)
847 dicPrioridades.Add(Convert.ToInt32(rowPrioridad[
"IDTABREL"]), Convert.ToInt32(rowPrioridad[
"PRIO_DATOS"]));
850 return dicPrioridades;
853 internal DateTime GetDate()
865 internal bool SeHaCreadoConfiguracion(
bool lbAsistConf)
881 internal bool GrupoEmpresaConfiguradoComoCentraloSucursal()
883 return !
string.IsNullOrEmpty(Convert.ToString(ew.db.DB.SQLValor(
"VARIABLES",
"VARIABLE",
"TIPOOFFLINE",
"VALOR",
"OFFLINE")).Trim().ToUpper());
886 internal bool Result_LogComunicaciones(ref DataTable table, DateTime startProces,
int resultado = 1)
891 internal bool Result_LogComunicaciones_Error(ref DataTable table, DateTime startProces)
896 internal Dictionary<string, int> Result_LogComunicaciones_IdLog(ref DataTable table,
string idLog)
901 #region Metodos privados 904 private void ActualizarProgresoDetalle()
906 if (_Mostrar_Progreso_Async != null)
907 _Mostrar_Progreso_Async(_TextStepDetalle);
911 private void ActualizarBarraProgreso()
913 if (_Porcen_Progreso_Async != null)
914 _Porcen_Progreso_Async(_PorcenProgreso, _TextStepDetalle);
918 private string GetSerieDefectoCurrentSucursal()
933 private string GetAlmacenDefectoCurrentSucursal()
bool Result_LogComunicaciones(ref DataTable table, DateTime startProces, int resultado=1)
string GetAlmacenDefectoCurrentSucursal(string codigoSucursal)
Obtiene el almacen por defecto de la sucursal
DataTable GetSucursales(int idConf)
Obtiene las sucursales con esa configuración
bool IsConfigSoloTipoEnvio()
Todas las configuraciones son de tipo envio
string CodigoSucursalActual()
Devuelve el código de la sucursal actual
object Retrieve(Type T)
Resuelve objeto de tipo T
Es como el tipo de entrada asientos pero por negocio, sin formulario, pq quiero que me haga las propu...
DateTime GetFechaIni()
Obtiene fecha inicio de ejercicio
DataTable Datos_TabNetConf(string codigoConfiguracion)
DataTable GetClaves(string claves, string where)
Obtener claves
Dictionary< string, object > GetMulticonf(string codigo)
Devuelve datos de multiconf
bool IsUsuarioConfiguracion(string usuario)
Tiene comfiguracion ese usuario
bool Result_LogComunicaciones_Error(ref DataTable table, DateTime startProces)
DataRow GetSucursal(string idConf, string codigoSucursal)
Obtiene datos de la sucursal
string GetEjercicioPredeterminado()
Devuelve el ejercicio prederminado
string GetCodigoConfiguracion(string idConf)
Obtiene codigo de configuración
DataTable GetVariables(string idConf)
Obtiene registro de variables
bool IsConfigSoloTipoRecepcion()
Todas las configuraciones son de tipo recepción
DataTable GetPrioridades()
Obtiene las prioridades
Interfaz de acceso a datos para asistente
Dictionary< string, int > Result_LogComunicaciones_IdLog(ref DataTable table, string idLog)
static DependencyInjector Instance
Instancia
string GetSerieDefectoCurrentSucursal(string codigoSucursal)
Obtiene la serie por defecto de la sucursal
bool SeHaCreadoConfiguracion(bool lbAsistConf)
Si se creó configuración
DataTable GetEjerciciosOffline()
Obtener los ejercicios del OFFLINE
Clase Inyector de dependencias para resolver las dependencias