ObjetoGestDoc.cs
1 # region Usings
2 using System;
3 using System.Collections.Generic;
4 using System.Linq;
5 using System.ComponentModel;
6 using System.Data;
7 using sage.ew.db;
8 using sage.ew.global;
9 using System.IO;
11 using System.Windows.Forms; // TODO no es necesario cuando eliminemos la clase DEBUG
12 using sage.ew.functions;
13 using sage.ew.formul;
14 using sage.ew.enumerations;
15 #endregion Usings
16 
17 namespace sage.addons.gestdoc.Negocio.Clases
18 {
19  #region Clase ObjetoGestDoc
20  public class ObjetoGestDoc : StateDataRow, IObjetoGestDoc
25  {
26  # region Propiedades privadas
27  private BindingList<IUsuario> _lisUsuariosDelete;
28  private BindingList<IPropiedad> _lisPropiedadesDelete;
29  private BindingList<ITag> _lisTagsDelete;
30  private sage.ew.usuario.Usuario _oUser = null;
31  # endregion Propiedades privadas
32 
33  # region Propiedades protected internal
34  protected internal bool _lSubscripcionActiva = true;
38 
42  protected internal bool _bSincronizar = false;
43 
47  protected internal string _cRutaDocsOneDrive = string.Empty;
48 
52  protected internal TipoConexion _oTipoConexionServicio = TipoConexion.OneDrive;
53 
57  protected internal int _nId = 0;
58 
62  protected internal string _cNombre = string.Empty;
63 
67  protected internal BindingList<IUsuario> _lisUsuarios;
68 
72  protected internal BindingList<IPropiedad> _lisPropiedades;
73 
77  protected internal BindingList<ITag> _lisTags;
78 
82  protected internal BindingList<IObjetoGestDoc> _lisChildren = null;
83 
84 
88  protected internal DateTime _dFechaCreacion = DateTime.Now.Date;
89 
93  protected internal string _cUsuarioCreacion = string.Empty;
94 
98  protected internal string _cRutaLocal = string.Empty;
99 
103  protected internal string _cError_message = string.Empty;
104 
108  protected internal bool _lLoading = false;
109 
113  protected internal FormBase _Form = null;
114 
118  protected internal ToolStripProgressBar _oProgressbar = null;
119 
123  protected internal sage.addons.gestdoc.gestdoc _oGestDoc = null;
127  protected internal sage.ew.usuario.Usuario _oUsuario
128  {
129  get
130  {
131  if (_oUser == null)
132  {
133  _oUser = new sage.ew.usuario.Usuario();
134 
135  if (!string.IsNullOrWhiteSpace(_UsuarioCreacion))
136  _oUser._Codigo = _cUsuarioCreacion;
137  }
138 
139  return _oUser;
140  }
141  set
142  {
143  if (_oUser == null)
144  _oUser = new sage.ew.usuario.Usuario();
145 
146  _oUser = value;
147  }
148  }
149  # endregion Propiedades protected internal
150 
151  # region Propiedades públicas
152  public int _Id
156  {
157  get
158  {
159  return _nId;
160  }
161  set
162  {
163  _nId = value;
164  }
165  }
166 
170  public virtual string _Nombre
171  {
172  get
173  {
174  return _cNombre;
175  }
176  set
177  {
178  _cNombre = value;
179  }
180  }
181 
185  public bool _EsCarpeta
186  {
187  get
188  {
189  return (this is ICarpeta);
190  }
191  }
192 
196  public BindingList<IUsuario> _Usuarios
197  {
198  get
199  {
200  if (_lisUsuarios == null)
201  _lisUsuarios = new BindingList<IUsuario>();
202 
203  return _lisUsuarios;
204  }
205  set
206  {
207  _lisUsuarios = value;
208  }
209  }
210 
214  public BindingList<IPropiedad> _Propiedades
215  {
216  get
217  {
218  if (_lisPropiedades == null)
219  _lisPropiedades = new BindingList<IPropiedad>();
220 
221  return _lisPropiedades;
222  }
223  set
224  {
225  _lisPropiedades = value;
226  }
227  }
228 
232  public BindingList<ITag> _Tags
233  {
234  get
235  {
236  if (_lisTags == null)
237  _lisTags = new BindingList<ITag>();
238 
239  return _lisTags;
240  }
241  set
242  {
243  _lisTags = value;
244  }
245  }
246 
250  public DateTime _FechaCreacion
251  {
252  get
253  {
254  return _dFechaCreacion;
255  }
256  set
257  {
258  _dFechaCreacion = value;
259  }
260  }
261 
265  public string _UsuarioCreacion
266  {
267  get
268  {
269  return _cUsuarioCreacion;
270  }
271  set
272  {
273  _cUsuarioCreacion = value;
274  }
275  }
276 
280  public string _NombreUsuarioCreacion
281  {
282  get
283  {
284  string lcNombre = string.Empty;
285 
286  if (_oUsuario != null)
287  lcNombre = Convert.ToString(_oUsuario._Nombre).Trim();
288 
289  return lcNombre;
290  }
291  }
292 
296  public virtual string _FullPath
297  {
298  get
299  {
300  return "";
301  }
302  }
303 
307  public string _Error_message
308  {
309  get
310  {
311  return _cError_message;
312  }
313  set
314  {
315  _cError_message = value;
316  }
317  }
318  # endregion Propiedades públicas
319 
320  # region Constructor
321  public ObjetoGestDoc()
325  {
326  _lisUsuarios = new BindingList<IUsuario>();
327  _lisPropiedades = new BindingList<IPropiedad>();
328  _lisTags = new BindingList<ITag>();
329 
330  _lisChildren = new BindingList<IObjetoGestDoc>();
331 
332  _lisUsuariosDelete = new BindingList<IUsuario>();
333  _lisPropiedadesDelete = new BindingList<IPropiedad>();
334  _lisTagsDelete = new BindingList<ITag>();
335 
336  _oGestDoc = sage.addons.gestdoc.GESTDOC._Get_Objeto_GestDoc();
337  if (_oGestDoc != null)
338  {
339  _lSubscripcionActiva = (_oGestDoc._BajaSuscripcion == false);
340  ConfiguacioneSincronizar();
341  }
342  }
343  #endregion Constructor
344 
345  # region Métodos públicos de la interfaz "IObjetoGestDoc"
346  public virtual bool _New(int tnIdParent)
351  {
352  return false;
353  }
354 
359  public virtual bool _Save()
360  {
361  return false;
362  }
363 
368  public virtual bool _Cancel()
369  {
370  _DescargarDatos();
371 
372  return true;
373  }
374 
379  public virtual bool _Load()
380  {
381  return false;
382  }
383 
388  public virtual bool _Delete()
389  {
390  _DescargarDatos();
391 
392  return true;
393  }
394 
401  public virtual bool _Rename(string tcNewName)
402  {
403  return false;
404  }
405 
411  public virtual bool _Upload(string tcPathOrigen)
412  {
413  return false;
414  }
415 
421  public virtual bool _Download(string tcPathDestino)
422  {
423  return false;
424  }
425 
430  public virtual DialogResult _Show()
431  {
432  return DialogResult.Cancel;
433  }
434 
440  public virtual bool _Move(int tnIDObjetoDocDestino)
441  {
442  return false;
443  }
444 
450  public bool _DeletePropiedad(IPropiedad toPropiedad)
451  {
452  _lisPropiedadesDelete.Add(toPropiedad);
453  _lisPropiedades.Remove(toPropiedad);
454 
455  return true;
456  }
457 
463  public bool _DeleteUsuario(IUsuario toUsuario)
464  {
465  _lisUsuariosDelete.Add(toUsuario);
466  _lisUsuarios.Remove(toUsuario);
467 
468  return true;
469  }
470 
476  public bool _DeleteTag(ITag toTag)
477  {
478  _lisTagsDelete.Add(toTag);
479  _lisTags.Remove(toTag);
480 
481  return true;
482  }
483 
488  public bool _AddPropiedad()
489  {
490  if (_Propiedades.Where(prop => string.IsNullOrWhiteSpace(prop._Propiedad)).Count() == 0)
491  {
492  _Propiedades.Add(new Propiedad(this));
493  return true;
494  }
495  else
496  return false;
497  }
498 
504  public bool _AddPropiedad(IPropiedad toPropiedad)
505  {
506  Propiedad loTag = (Propiedad)toPropiedad;
507 
508  if (_ValidPropiedad(toPropiedad._Propiedad))
509  {
510  if (loTag._oObjetoGestDoc == null) // Tenemos de asegurarnos que tiene la referencia al objeto de la gestión documental
511  loTag._oObjetoGestDoc = this;
512 
513  _Propiedades.Add(toPropiedad);
514  return true;
515  }
516  else
517  return false;
518  }
519 
524  public bool _AddTag()
525  {
526  if (_Tags.Where(tag => string.IsNullOrWhiteSpace(tag._Cadena)).Count() == 0)
527  {
528  _Tags.Add(new Tag(this));
529  return true;
530  }
531  else
532  return false;
533  }
534 
540  public bool _AddTag(ITag toTag)
541  {
542  Tag loTag = (Tag)toTag;
543 
544  if (_ValidTag(loTag._Cadena))
545  {
546  if (loTag._oObjetoGestDoc == null) // Tenemos de asegurarnos que tiene la referencia al objeto de la gestión documental
547  loTag._oObjetoGestDoc = this;
548 
549  _Tags.Add(toTag);
550  return true;
551  }
552  else
553  return false;
554  }
555 
560  public bool _AddUsuario()
561  {
562  if (_Usuarios.Where(usuario => string.IsNullOrWhiteSpace(usuario._Usuario)).Count() == 0)
563  {
564  _Usuarios.Add(new Usuario(this));
565 
566  return true;
567  }
568  else
569  return false;
570  }
571 
577  public bool _AddUsuario(IUsuario toIUsuario)
578  {
579  Usuario loUsuario = (Usuario)toIUsuario;
580 
581  if (_ValidUsuario(toIUsuario._Usuario))
582  {
583  if (loUsuario._oObjetoGestDoc == null) // Tenemos de asegurarnos que tiene la referencia al objeto de la gestión documental
584  loUsuario._oObjetoGestDoc = this;
585 
586  _Usuarios.Add(toIUsuario);
587 
588  return true;
589  }
590  else
591  return false;
592  }
593 
599  public eTipoAcceso _AccesoUsuario(string tcUsuario = "")
600  {
601  eTipoAcceso leTipoAcceso = eTipoAcceso.Completo;
602  string lcUsuario;
603 
604  if (string.IsNullOrWhiteSpace(tcUsuario))
605  lcUsuario = UsuarioActual();
606  else
607  lcUsuario = tcUsuario;
608 
609  if (lcUsuario != "SUPERVISOR")
610  {
611  var loUsuario = _Usuarios.AsEnumerable().Where(user => user._Usuario == lcUsuario);
612 
613  if (loUsuario.Count() > 0)
614  leTipoAcceso = (eTipoAcceso)loUsuario.First()._Nivel;
615  else
616  leTipoAcceso = eTipoAcceso.Denegado;
617  }
618 
619  return leTipoAcceso;
620  }
621 
622  # endregion Métodos públicos de la interfaz "IObjetoGestDoc"
623 
624  #region Métodos public virtual
625  public virtual void _DescargarDatos()
629  {
630  _nId = 0;
631  _cNombre = string.Empty;
632  _dFechaCreacion = DateTime.Now.Date;
633 
634  if (_lisUsuarios != null)
635  _lisUsuarios.Clear();
636 
637  if (_lisPropiedades != null)
638  _lisPropiedades.Clear();
639 
640  if (_lisTags != null)
641  _lisTags.Clear();
642 
643  if (_lisChildren != null)
644  _lisChildren.Clear();
645 
646  if (_lisUsuariosDelete != null)
647  _lisUsuariosDelete.Clear();
648 
649  if (_lisPropiedadesDelete != null)
650  _lisPropiedadesDelete.Clear();
651 
652  if (_lisTagsDelete != null)
653  _lisTagsDelete.Clear();
654  }
655 
660  public virtual bool _LoadPropiedades()
661  {
662  return false;
663  }
664 
669  public virtual bool _LoadUsuarios()
670  {
671  return false;
672  }
673 
678  public virtual bool _LoadTags()
679  {
680  return false;
681  }
682  #endregion Métodos public virtual
683 
684  # region Métodos protected internal
685  protected internal DialogResult _MessageBox(String tcMensaje, MessageBoxButtons toBotones = MessageBoxButtons.OK, MessageBoxIcon toIcono = MessageBoxIcon.Exclamation, MessageBoxDefaultButton toBotonDefecto = MessageBoxDefaultButton.Button1, DialogResult toResultadoDefecte = DialogResult.OK)
695  {
696  DialogResult toResultado = new DialogResult();
697 
698  if (_Form != null) // Si tenemos referencia al formulario
699  {
700  string lcCaption = _Form.Text;
701  toResultado = FUNCTIONS._MessageBox(tcMensaje, lcCaption, toBotones, toIcono, toBotonDefecto, _Form);
702  }
703  else
704  {
705  _Error_message = tcMensaje;
706  toResultado = toResultadoDefecte;
707  }
708 
709  return toResultado;
710  }
711 
718  protected internal void _MensajeError(string tcMensaje, MessageBoxButtons toMessageBoxButtons = MessageBoxButtons.OK, MessageBoxIcon toMessageBoxIcon = MessageBoxIcon.Exclamation)
719  {
720  _MessageBox(tcMensaje, toMessageBoxButtons, toMessageBoxIcon, MessageBoxDefaultButton.Button1, DialogResult.OK);
721  }
722 
730  protected internal bool _FeaturesParent(int tnIdParent)
731  {
732  bool llOk = true; // De momento siempre devolvemos true
733 
734  if (tnIdParent > 0)
735  {
736  ICarpeta loCarpeta = new Carpeta(tnIdParent);
737 
738  if (loCarpeta._Id > 0)
739  {
740  loCarpeta._Tags.ToList<ITag>().ForEach(tag => _AddTag(new Tag(this)._Clonar(tag)));
741  loCarpeta._Usuarios.ToList<IUsuario>().ForEach(user => _AddUsuario(new Usuario(this)._Clonar(user)));
742  loCarpeta._Propiedades.ToList<IPropiedad>().ForEach(prop => _AddPropiedad(new Propiedad(this)._Clonar(prop)));
743  }
744  }
745 
746  return llOk;
747  }
748 
753  protected internal string UsuarioActual()
754  {
755  return Convert.ToString(EW_GLOBAL._GetVariable("wc_usuario"));
756  }
757 
762  protected internal bool _LoadFeatures()
763  {
764  bool llOk;
765 
766  llOk = _LoadPropiedades();
767  llOk = llOk && _LoadUsuarios();
768  llOk = llOk && _LoadTags();
769 
770  return llOk;
771  }
772 
779  protected internal bool _Download(string tcPathDestino, ToolStripProgressBar toewProgressbar)
780  {
781  bool llOk;
782 
783  if (toewProgressbar != null)
784  _oProgressbar = toewProgressbar;
785 
786  llOk = _Download(tcPathDestino);
787 
788  return llOk;
789  }
790 
795  protected internal bool _DeleteFeatures()
796  {
797  bool llOk;
798 
799  // Primero eliminamos los registros borrados
800  llOk = DeletePropiedades(_lisPropiedades);
801  llOk = llOk && DeleteUsuarios(_lisUsuarios);
802  llOk = llOk && DeleteTags(_lisTags);
803 
804  return llOk;
805  }
806 
811  protected internal bool _SaveFeatures()
812  {
813  bool llOk;
814 
815  // Primero eliminamos los registros borrados
816  llOk = DeletePropiedades(_lisPropiedadesDelete);
817  llOk = llOk && DeleteUsuarios(_lisUsuariosDelete);
818  llOk = llOk && DeleteTags(_lisTagsDelete);
819 
820  // Ahora podemos actualizar la información
821  llOk = llOk && SavePropiedades();
822  llOk = llOk && SaveUsuarios();
823  llOk = llOk && SaveTags();
824 
825  return llOk;
826  }
827 
835  protected internal int _MaxLinea(string tcTabla, string tcCampoWhere, int tnIdGestDoc = 0)
836  {
837  string lcSql;
838  int lnLinea = 0, lnId = 0;
839  bool llOk;
840  DataTable ldtLineaMax = new DataTable();
841 
842  if (tnIdGestDoc == 0)
843  lnId = _Id;
844  else
845  lnId = tnIdGestDoc;
846 
847  lcSql = "SELECT MAX(LINEA) AS LINEA " +
848  " FROM " + DB.SQLDatabase("GESTDOC", tcTabla) +
849  " WHERE " + tcCampoWhere + " = " + DB.SQLString(lnId);
850 
851  llOk = DB.SQLExec(lcSql, ref ldtLineaMax);
852 
853  if (llOk && ldtLineaMax != null && ldtLineaMax.Rows.Count > 0 && ldtLineaMax.Rows[0]["LINEA"] != DBNull.Value)
854  lnLinea = Convert.ToInt32(ldtLineaMax.Rows[0]["LINEA"]);
855 
856  lnLinea++;
857 
858  return lnLinea;
859  }
860 
867  protected internal void _AddUsuarios(DataTable tdtUsuarios, bool tlDataRowCopia = true)
868  {
869  if (tdtUsuarios.Rows.Count > 0)
870  {
871  foreach (DataRow ldrUsuario in tdtUsuarios.Rows)
872  {
873  IUsuario loUsuario = new Usuario(this,ldrUsuario);
874  _Usuarios.Add(loUsuario);
875  }
876  }
877 
878  if (tlDataRowCopia)
879  _Usuarios.ToList<IUsuario>().ForEach(user => ((Usuario)user)._DataRowCopia());
880  }
881 
888  protected internal void _AddPropiedades(DataTable tdtPropiedades, bool tlDataRowCopia = true)
889  {
890  if (tdtPropiedades.Rows.Count > 0)
891  {
892  foreach (DataRow ldrPropiedad in tdtPropiedades.Rows)
893  {
894  IPropiedad loPropiedad = new Propiedad(this,ldrPropiedad);
895  _Propiedades.Add(loPropiedad);
896  }
897  }
898 
899  if (tlDataRowCopia)
900  _Propiedades.ToList<IPropiedad>().ForEach(user => ((Propiedad)user)._DataRowCopia());
901  }
902 
909  protected internal void _AddTags(DataTable tdtTags, bool tlDataRowCopia = true)
910  {
911  if (tdtTags.Rows.Count > 0)
912  {
913  foreach (DataRow ldrTag in tdtTags.Rows)
914  {
915  ITag loTag = new Tag(this,ldrTag);
916  _AddTag(loTag); // Agregamos el Tag
917  }
918  }
919 
920  if (tlDataRowCopia)
921  _Tags.ToList<ITag>().ForEach(user => ((Tag)user)._DataRowCopia());
922  }
923 
928  protected internal bool _ValidNombre()
929  {
930  bool llOk = true;
931 
932  string lcNombre = _cNombre.Trim();
933 
934  if (!string.IsNullOrWhiteSpace(lcNombre) && lcNombre.IndexOfAny(new char[] { '\\', '/', ':', '*', '?', '\"', '<', '>', '|' }) != -1)
935  {
936  string lcMensaje;
937 
938  if (this is IDocumento)
939  lcMensaje = "archivos";
940  else
941  lcMensaje = "carpetas";
942 
943  llOk = false;
944  _MessageBox("Los nombres de " + lcMensaje + " no pueden contener ninguno de los siguientes carácteres:" + Environment.NewLine + "\\/:*?\"<>|");
945  }
946  else
947  {
948  if (this is ICarpeta && lcNombre.Length > 50)
949  {
950  _MessageBox("El ancho máximo de una carpeta es de 50 carácteres.");
951  llOk = false;
952  }
953  else if (this is IDocumento && lcNombre.Length > 100)
954  {
955  _MessageBox("El ancho máximo de un documento es de 100 carácteres.");
956  llOk = false;
957  }
958  }
959 
960  return llOk;
961  }
962 
968  protected internal bool _ValidPropiedad(string tcPropiedad)
969  {
970  if (tcPropiedad == null)
971  return true;
972 
973  string lcPropiedad = tcPropiedad.Trim();
974 
975  if (!string.IsNullOrWhiteSpace(lcPropiedad) && _Propiedades.Where(prop => prop._Propiedad == lcPropiedad).Count() > 0)
976  {
977  _MessageBox("La propiedad '" + lcPropiedad + "' se ha entrado previamente");
978  return false;
979  }
980 
981  return true;
982  }
983 
989  protected internal bool _ValidUsuario(string tcUsuario)
990  {
991  string lcUsuario = tcUsuario.Trim();
992 
993  if (!string.IsNullOrWhiteSpace(lcUsuario) && _Usuarios.Where(user => user._Usuario == lcUsuario).Count() > 0)
994  {
995  _MessageBox("El usuario " + lcUsuario + " se ha entrado previamente");
996  return false;
997  }
998 
999  return true;
1000  }
1001 
1007  protected internal bool _ValidTag(string tcCadenaTag)
1008  {
1009  string lcCadenaTag = tcCadenaTag.Trim();
1010 
1011  if (!string.IsNullOrWhiteSpace(lcCadenaTag) && _Tags.Where(tag => tag._Cadena.Trim() == lcCadenaTag).Count() > 0)
1012  {
1013  _MessageBox("La etiqueta " + lcCadenaTag + " se ha entrado previamente");
1014  return false;
1015  }
1016 
1017  return true;
1018  }
1019 
1024  protected internal DataTable _DataTableUsuarios()
1025  {
1026  string lcSql;
1027  bool llOk;
1028  DataTable ldtUsuarios = new DataTable();
1029 
1030  lcSql = "SELECT CODIGO, NOMBRE " +
1031  " FROM " + DB.SQLDatabase("COMUNES", "USUARIOS") +
1032  " WHERE VISIBLE = " + DB.SQLTrue() +
1033  " ORDER BY NOMBRE";
1034 
1035  llOk = DB.SQLExec(lcSql, ref ldtUsuarios);
1036 
1037  if (!llOk)
1038  _MensajeError("Se ha producido un error al consultar los usuarios.");
1039 
1040  return ldtUsuarios;
1041  }
1042 
1048  protected internal int _MaxId(string tcTabla)
1049  {
1050  int lnIdMax = 0;
1051  string lcSql = string.Empty;
1052  DataTable ldtMaxId = new DataTable();
1053 
1054  lcSql = "SELECT MAX(id) AS maxim FROM " + DB.SQLDatabase("GESTDOC", tcTabla);
1055 
1056  DB.SQLExec(lcSql, ref ldtMaxId);
1057 
1058  if (ldtMaxId != null && ldtMaxId.Rows.Count > 0 && !string.IsNullOrWhiteSpace(Convert.ToString(ldtMaxId.Rows[0]["maxim"])))
1059  lnIdMax = (Convert.ToInt32(ldtMaxId.Rows[0]["maxim"]) + 1);
1060  else
1061  lnIdMax = 1;
1062 
1063  return lnIdMax;
1064  }
1065 
1070  protected internal string _DirectoryParents(ref string tcCarpeta, int tnCarpeta)
1071  {
1072  string lcSql, lcCarpeta = string.Empty;
1073 
1074  DataTable ldtCarpetas = new DataTable();
1075 
1076  lcSql = "SELECT ID, NOMBRE, PARENT" +
1077  " FROM " + DB.SQLDatabase("GESTDOC", "CARPETAS") +
1078  " WHERE id != 1"; // Excluimos el Id 1 del directorio Documentos, siempre se ha de crear en la carpeta \Gestdoc\Documentos\
1079 
1080  bool llOk = DB.SQLExec(lcSql, ref ldtCarpetas);
1081 
1082  if (llOk && ldtCarpetas.Rows.Count > 0)
1083  DirectoryParents(ref tcCarpeta, tnCarpeta, ldtCarpetas);
1084 
1085  return lcCarpeta;
1086  }
1087 
1093  protected internal bool _ExisteMantePropiedades(string tcPropiedad)
1094  {
1095  DataTable ldtProps = new DataTable();
1096  string lcSql;
1097  bool llOk;
1098 
1099  lcSql = "SELECT PROPIEDAD FROM " + DB.SQLDatabase("GESTDOC", _TaulaPropiedad()) +
1100  " WHERE PROPIEDAD = " + DB.SQLString(tcPropiedad);
1101 
1102  DB.SQLExec(lcSql, ref ldtProps);
1103  llOk = (ldtProps != null && ldtProps.Rows.Count > 0);
1104 
1105  return llOk;
1106  }
1107 
1113  protected internal bool _DeleteMantePropiedades(string tcPropiedad)
1114  {
1115  string lcSql;
1116  bool llOk;
1117 
1118  lcSql = "DELETE FROM " + DB.SQLDatabase("GESTDOC", _TaulaPropiedad()) +
1119  " WHERE PROPIEDAD = " + DB.SQLString(tcPropiedad);
1120 
1121  llOk = DB.SQLExec(lcSql);
1122 
1123  if (!llOk)
1124  _MensajeError("Se ha producido un error al borrrar las propiedades.");
1125 
1126  return llOk;
1127  }
1128 
1134  protected internal string _TaulaPropiedad(IObjetoGestDoc toObjetoGestDoc = null)
1135  {
1136  if (ObjetoGestDocumental(toObjetoGestDoc) is Documento)
1137  return "DOC_PROP";
1138  else
1139  return "CARP_PROP";
1140  }
1141 
1147  protected internal string _TaulaTags(IObjetoGestDoc toObjetoGestDoc = null)
1148  {
1149  if (ObjetoGestDocumental(toObjetoGestDoc) is Documento)
1150  return "DOC_TAGS";
1151  else
1152  return "CARP_TAGS";
1153  }
1154 
1160  protected internal string _TaulaUsuarios(IObjetoGestDoc toObjetoGestDoc = null)
1161  {
1162  if (ObjetoGestDocumental(toObjetoGestDoc) is Documento)
1163  return "DOC_USER";
1164  else
1165  return "CARP_USER";
1166  }
1167 
1173  protected internal string _IdTaula(IObjetoGestDoc toObjetoGestDoc = null)
1174  {
1175  if (ObjetoGestDocumental(toObjetoGestDoc) is Documento)
1176  return "IDDOC";
1177  else
1178  return "IDCARPETA";
1179  }
1180 
1190  protected internal bool _InsertPropiedad(int tnIdGestDoc, IPropiedad toPropiedad, int tnLinea = 0, bool tlParents = true, IObjetoGestDoc toObjetoGestDoc = null)
1191  {
1192  bool llOk;
1193  string lcSql , lcTaula , lcCampoId;
1194  int lnLinea;
1195 
1196  lnLinea = tnLinea;
1197  lcTaula = _TaulaPropiedad(toObjetoGestDoc);
1198  lcCampoId = _IdTaula(toObjetoGestDoc);
1199 
1200  if (lnLinea == 0)
1201  lnLinea = _MaxLinea(lcTaula, lcCampoId, tnIdGestDoc);
1202 
1203  lcSql = "INSERT INTO " + DB.SQLDatabase("GESTDOC", lcTaula) +
1204  " (" + lcCampoId + ", PROPIEDAD, VALOR, LINEA)" +
1205  " Values(" + DB.SQLString(tnIdGestDoc) + ", " + DB.SQLString(toPropiedad._Propiedad) + ", " + DB.SQLString(toPropiedad._Valor) + ", " + DB.SQLString(lnLinea) + ")";
1206 
1207  llOk = DB.SQLExec(lcSql);
1208 
1209  if (llOk && tlParents && (this is ICarpeta))
1210  InsertPropiedadesParents(tnIdGestDoc, toPropiedad);
1211 
1212  return llOk;
1213  }
1214 
1225  protected internal bool _InsertTag(int tnIdGestDoc, ITag toTag, string tcIdTag, int tnLinea = 0, bool tlParents = true, IObjetoGestDoc toObjetoGestDoc = null)
1226  {
1227  bool llOk;
1228  string lcSql, lcTaula, lcCampoId;
1229  int lnLinea;
1230 
1231  lnLinea = tnLinea;
1232  lcTaula = _TaulaTags(toObjetoGestDoc);
1233  lcCampoId = _IdTaula(toObjetoGestDoc);
1234 
1235  if (lnLinea == 0)
1236  lnLinea = _MaxLinea(lcTaula, lcCampoId, tnIdGestDoc);
1237 
1238  lcSql = "INSERT INTO " + DB.SQLDatabase("GESTDOC", lcTaula) +
1239  " (" + lcCampoId + ", IDTAG, LINEA)" +
1240  " Values(" + DB.SQLString(tnIdGestDoc) + ", " + DB.SQLString(tcIdTag) + ", " + DB.SQLString(lnLinea) + ")";
1241 
1242  llOk = DB.SQLExec(lcSql);
1243 
1244  if (llOk && tlParents && (this is ICarpeta))
1245  InsertTagParents(tnIdGestDoc, toTag, tcIdTag);
1246 
1247  return llOk;
1248  }
1249 
1259  protected internal bool _InsertUsuario(int tnIdGestDoc, IUsuario toUsuario, int tnLinea = 0, bool tlParents = true, IObjetoGestDoc toObjetoGestDoc = null)
1260  {
1261  bool llOk;
1262  string lcSql, lcTaula, lcCampoId;
1263  int lnLinea;
1264 
1265  lnLinea = tnLinea;
1266  lcTaula = _TaulaUsuarios(toObjetoGestDoc);
1267  lcCampoId = _IdTaula(toObjetoGestDoc);
1268 
1269  if (lnLinea == 0)
1270  lnLinea = _MaxLinea(lcTaula, lcCampoId, tnIdGestDoc);
1271 
1272  lcSql = "INSERT INTO " + DB.SQLDatabase("GESTDOC", lcTaula) +
1273  " (" + lcCampoId + ", USUARIO, NIVEL, LINEA)" +
1274  " Values(" + DB.SQLString(tnIdGestDoc) + ", " + DB.SQLString(toUsuario._Usuario) + ", " + DB.SQLString(toUsuario._Nivel) + ", " + DB.SQLString(lnLinea) + ")";
1275 
1276  llOk = DB.SQLExec(lcSql);
1277 
1278  if (llOk && tlParents && (this is ICarpeta))
1279  InsertUsuarioParents(tnIdGestDoc, toUsuario);
1280 
1281  return llOk;
1282  }
1283 
1287  protected internal void _PerformStepProggressbar()
1288  {
1289  if (_oProgressbar != null)
1290  {
1291  if (_oProgressbar.Value < _oProgressbar.Maximum)
1292  {
1293  _oProgressbar.PerformStep();
1294  Application.DoEvents();
1295  }
1296  }
1297  }
1298 
1303  protected internal void _MensajeError(string tcMensaje)
1304  {
1305  if (!string.IsNullOrWhiteSpace(tcMensaje))
1306  _Error_message = tcMensaje;
1307  }
1308 
1315  protected internal string _DirectoryGestDocDocumentos(string tcCarpeta)
1316  {
1317  string lcPath = FunctionsGestDoc._DirectorioGestDoc();
1318 
1319  if (string.IsNullOrWhiteSpace(lcPath))
1320  return "";
1321 
1322  lcPath = Path.Combine(lcPath, "Docs" + FUNCTIONS._Grupo_Actual());
1323  lcPath = Path.Combine(lcPath, "Documentos");
1324 
1325  if (!string.IsNullOrWhiteSpace(tcCarpeta))
1326  lcPath = Path.Combine(lcPath, tcCarpeta);
1327 
1328  return lcPath + Path.DirectorySeparatorChar;
1329  }
1330 
1337  protected internal bool _DirectoryExist(string tcPath, bool tlCreate = true)
1338  {
1339  bool llExist;
1340  string lcPath = string.Empty ,lcMensajeError = string.Empty;
1341 
1342  try
1343  {
1344  lcPath = Path.GetDirectoryName(tcPath);
1345  llExist = Directory.Exists(tcPath);
1346  }
1347  catch (Exception loEx)
1348  {
1349  DB.Registrar_Error(loEx); //Registramos excepción
1350  llExist = false;
1351  lcMensajeError = "No se ha podido crear el directorio " + lcPath + "." + Environment.NewLine + Environment.NewLine + loEx.Message;
1352 
1353  }
1354 
1355  if (string.IsNullOrWhiteSpace(lcMensajeError) && !llExist && tlCreate)
1356  {
1357  try
1358  {
1359  Directory.CreateDirectory(lcPath);
1360  llExist = Directory.Exists(lcPath);
1361  }
1362  catch (Exception loEx)
1363  {
1364  DB.Registrar_Error(loEx); //Registramos excepción
1365  lcMensajeError = "No se ha podido crear el directorio " + lcPath + "." + Environment.NewLine + Environment.NewLine + loEx.Message;
1366  }
1367  }
1368 
1369  if (!string.IsNullOrWhiteSpace(lcMensajeError))
1370  _MensajeError(lcMensajeError);
1371 
1372  return llExist;
1373  }
1374 
1381  protected internal bool _DeleteDirectoryRecursive(string tcDirectory, bool tlRecursive = true)
1382  {
1383  bool llOk = true;
1384 
1385  string lcMensaje = string.Empty, lcDirectoryRename = string.Empty;
1386 
1387  if (Directory.Exists(tcDirectory))
1388  {
1389  // Primero intentamos mover el directorio. De esta forma gestionamos si hay ficheros en Uso
1390  try
1391  {
1392  lcDirectoryRename = FunctionsGestDoc._DirectorySeparatorChar(tcDirectory);
1393 
1394  if (Path.GetDirectoryName(tcDirectory).Length < 230) // Si el directorio es muy largo no lo intentamos renombrar, puede dar error, directamente lo borramos, es lo que el usuario desea hacer
1395  {
1396  lcDirectoryRename = System.IO.Directory.GetParent(tcDirectory).Parent.FullName;
1397 
1398  string lcGuid = Guid.NewGuid().ToString("N").Substring(0, 8);
1399  lcDirectoryRename = FunctionsGestDoc._DirectorySeparatorChar(Path.Combine(lcDirectoryRename, lcGuid));
1400  Directory.Move(tcDirectory, lcDirectoryRename);
1401  }
1402  }
1403  catch (Exception loEx)
1404  {
1405  llOk = false;
1406  lcMensaje = "No se ha podido eliminar las versiones del documento." + Environment.NewLine + Environment.NewLine + loEx.Message;
1407  }
1408 
1409  if (llOk) // Si todo va correcto ahora podemos eliminar la carpeta renombrada
1410  {
1411  try
1412  {
1413  Directory.Delete(FunctionsGestDoc._DirectorySeparatorChar(lcDirectoryRename), true); // Borramos recursivamente, si hay documentos o carpetas no se borraria
1414  }
1415  catch (Exception loEx)
1416  {
1417  lcMensaje = "No se ha podido eliminar las versiones del documento." + Environment.NewLine + loEx.Message;
1418  }
1419 
1420  llOk = !Directory.Exists(tcDirectory);
1421  }
1422  }
1423 
1424  if (!llOk)
1425  _MensajeError("No se ha podido eliminar el directorio " + tcDirectory + "." + lcMensaje);
1426 
1427  return llOk;
1428  }
1429 
1434  protected internal bool _ProcesoGestDoc()
1435  {
1436  return (Convert.ToBoolean(EW_GLOBAL._GetVariable("wl_gestdoc_proceso")));
1437  }
1438 
1444  protected internal bool _GestDocPendiente(string tcMensaje)
1445  {
1446  if (_ProcesoGestDoc()) // Si estamos ejecutando el proceso ya podemos salir
1447  return false;
1448 
1449  bool llKo = (Convert.ToBoolean(EW_GLOBAL._GetVariable("wl_ewgestdoc")));
1450 
1451  if (llKo)
1452  _MensajeError(tcMensaje);
1453 
1454  return llKo;
1455  }
1456  # endregion Métodos protected internal
1457 
1458  # region Métodos privados
1459  private bool DeletePropiedades(BindingList<IPropiedad> toListPropiedades)
1465  {
1466  bool llOk = true;
1467 
1468  foreach (IPropiedad loPropiedad in toListPropiedades)
1469  {
1470  llOk = llOk && loPropiedad._Delete();
1471 
1472  if (!llOk)
1473  break;
1474  }
1475 
1476  return llOk;
1477  }
1478 
1484  private bool DeleteTags(BindingList<ITag> toListTags)
1485  {
1486  bool llOk = true;
1487 
1488  foreach (ITag loTag in toListTags)
1489  {
1490  llOk = llOk && loTag._Delete();
1491 
1492  if (!llOk)
1493  break;
1494  }
1495 
1496  return llOk;
1497  }
1498 
1504  private bool DeleteUsuarios(BindingList<IUsuario> toListUuarios)
1505  {
1506  bool llOk = true;
1507 
1508  foreach (IUsuario loUsuario in toListUuarios)
1509  {
1510  llOk = llOk && loUsuario._Delete();
1511 
1512  if (!llOk)
1513  break;
1514  }
1515 
1516  return llOk;
1517  }
1518 
1523  private bool SavePropiedades()
1524  {
1525  bool llOk = true;
1526 
1527  foreach (IPropiedad loPropiedad in _Propiedades)
1528  {
1529  llOk = llOk && loPropiedad._Save();
1530 
1531  if (!llOk)
1532  break;
1533  }
1534 
1535  return llOk;
1536  }
1537 
1542  private bool SaveTags()
1543  {
1544  bool llOk = true;
1545 
1546  foreach (ITag loTag in _Tags)
1547  {
1548  llOk = llOk && loTag._Save();
1549 
1550  if (!llOk)
1551  break;
1552  }
1553 
1554  return llOk;
1555  }
1556 
1561  private bool SaveUsuarios()
1562  {
1563  bool llOk = true;
1564 
1565  foreach (IUsuario loUsuario in _Usuarios)
1566  {
1567  llOk = llOk && loUsuario._Save();
1568 
1569  if (!llOk)
1570  break;
1571  }
1572 
1573  return llOk;
1574  }
1575 
1584  private bool ExistPropiedad(int tnId, string tcTaula, string tcCampoId, string tcPropiedad)
1585  {
1586  bool llOk;
1587  bool llExist = false;
1588  DataTable ldtExist = new DataTable();
1589 
1590  llOk = DB.SQLExec("SELECT " + tcCampoId +
1591  " FROM " + DB.SQLDatabase("GESTDOC", tcTaula) +
1592  " WHERE " + tcCampoId + " = " + DB.SQLString(tnId) +
1593  " AND PROPIEDAD = " + DB.SQLString(tcPropiedad), ref ldtExist);
1594 
1595  llExist = (llOk && ldtExist != null && ldtExist.Rows.Count > 0);
1596 
1597  return llExist;
1598  }
1599 
1608  private bool ExistTag(int tnId, string tcTaula, string tcCampoId, string tcIdTag)
1609  {
1610  bool llOk;
1611  bool llExist = false;
1612  DataTable ldtExist = new DataTable();
1613 
1614  llOk = DB.SQLExec("SELECT " + tcCampoId +
1615  " FROM " + DB.SQLDatabase("GESTDOC", tcTaula) +
1616  " WHERE " + tcCampoId + " = " + DB.SQLString(tnId) +
1617  " AND IDTAG = " + DB.SQLString(tcIdTag), ref ldtExist);
1618 
1619  llExist = (llOk && ldtExist != null && ldtExist.Rows.Count > 0);
1620 
1621  return llExist;
1622  }
1623 
1632  private bool ExistUsuario(int tnId, string tcTaula, string tcCampoId, string tcUsuario)
1633  {
1634  bool llOk;
1635  bool llExist = false;
1636  DataTable ldtExist = new DataTable();
1637 
1638  llOk = DB.SQLExec("SELECT " + tcCampoId +
1639  " FROM " + DB.SQLDatabase("GESTDOC", tcTaula) +
1640  " WHERE " + tcCampoId + " = " + DB.SQLString(tnId) +
1641  " AND USUARIO = " + DB.SQLString(tcUsuario), ref ldtExist);
1642 
1643  llExist = (llOk && ldtExist != null && ldtExist.Rows.Count > 0);
1644 
1645  return llExist;
1646  }
1647 
1654  private bool InsertPropiedadesParents(int tnIdParent, IPropiedad toIPropiedad)
1655  {
1656  int lnId;
1657  string lcTaula, lcCampoId;
1658  bool llOk = true, llCarpeta;
1659  Carpeta loCarpeta = new Carpeta();
1660  Documento loDocumento = new Documento();
1661  ObjetoGestDoc loObjetoGestDoc;
1662 
1663  DataTable ldtParents = FunctionsGestDoc._Children(eTipoConsultaCarpetasDocumentos.TodosNiveles, tnIdParent, tlFiltrarNivelAcceso: false);
1664 
1665  foreach (DataRow ldrParent in ldtParents.Rows)
1666  {
1667  lnId = Convert.ToInt32(ldrParent["id"]);
1668  llCarpeta = Convert.ToBoolean(ldrParent["carpeta"]); // Si es una carpeta ha de actualizar los parents (carpetas o documentos)
1669 
1670  if (llCarpeta)
1671  loObjetoGestDoc = loCarpeta;
1672  else
1673  loObjetoGestDoc = loDocumento;
1674 
1675  lcTaula = _TaulaPropiedad(loObjetoGestDoc);
1676  lcCampoId = _IdTaula(loObjetoGestDoc);
1677 
1678  if (!ExistPropiedad(lnId, lcTaula, lcCampoId, toIPropiedad._Propiedad))
1679  {
1680  // tlParents => false. No es necesario que actualice los parents, el DataTable ya tiene todos los documentos y carpetas a actualizar
1681  llOk = _InsertPropiedad(lnId, toIPropiedad, tlParents: false, toObjetoGestDoc: loObjetoGestDoc);
1682 
1683  if (!llOk)
1684  break;
1685  }
1686  }
1687 
1688  return llOk;
1689  }
1690 
1698  private bool InsertTagParents(int tnIdParent, ITag toITag, string tcIdTag)
1699  {
1700  int lnId;
1701  string lcTaula, lcCampoId;
1702  bool llOk = true, llCarpeta;
1703  Carpeta loCarpeta = new Carpeta();
1704  Documento loDocumento = new Documento();
1705  ObjetoGestDoc loObjetoGestDoc = null;
1706 
1707  DataTable ldtParents = FunctionsGestDoc._Children(eTipoConsultaCarpetasDocumentos.TodosNiveles, tnIdParent, tlFiltrarNivelAcceso: false);
1708 
1709  foreach (DataRow ldrParent in ldtParents.Rows)
1710  {
1711  lnId = Convert.ToInt32(ldrParent["id"]);
1712  llCarpeta = Convert.ToBoolean(ldrParent["carpeta"]); // Si es una carpeta ha de actualizar los parents (carpetas o documentos)
1713 
1714  if (llCarpeta)
1715  loObjetoGestDoc = loCarpeta;
1716  else
1717  loObjetoGestDoc = loDocumento;
1718 
1719  lcTaula = _TaulaTags(loObjetoGestDoc);
1720  lcCampoId = _IdTaula(loObjetoGestDoc);
1721 
1722  if (!ExistTag(lnId, lcTaula, lcCampoId, tcIdTag))
1723  {
1724  // tlParents => false. No es necesario que actualice los parents, el DataTable ya tiene todos los documentos y carpetas a actualizar
1725  llOk = _InsertTag(lnId, toITag, tcIdTag, tlParents: false, toObjetoGestDoc: loObjetoGestDoc);
1726 
1727  if (!llOk)
1728  break;
1729  }
1730  }
1731 
1732  return llOk;
1733  }
1734 
1741  private bool InsertUsuarioParents(int tnIdParent, IUsuario toIUsario)
1742  {
1743  int lnId;
1744  string lcTaula,lcCampoId;
1745  bool llOk = true, llCarpeta;
1746  Carpeta loCarpeta = new Carpeta();
1747  Documento loDocumento = new Documento();
1748  ObjetoGestDoc loObjetoGestDoc = null;
1749 
1750  DataTable ldtParents = FunctionsGestDoc._Children(eTipoConsultaCarpetasDocumentos.TodosNiveles, tnIdParent, tlFiltrarNivelAcceso: false);
1751 
1752  foreach (DataRow ldrParent in ldtParents.Rows)
1753  {
1754  lnId = Convert.ToInt32(ldrParent["id"]);
1755  llCarpeta = Convert.ToBoolean(ldrParent["carpeta"]); // Si es una carpeta ha de actualizar los parents (carpetas o documentos)
1756 
1757  if (llCarpeta)
1758  loObjetoGestDoc = loCarpeta;
1759  else
1760  loObjetoGestDoc = loDocumento;
1761 
1762  lcTaula = _TaulaUsuarios(loObjetoGestDoc);
1763  lcCampoId = _IdTaula(loObjetoGestDoc);
1764 
1765  if (!ExistUsuario(lnId, lcTaula, lcCampoId, toIUsario._Usuario))
1766  {
1767  // tlParents => false. No es necesario que actualice los parents, el DataTable ya tiene todos los documentos y carpetas a actualizar
1768  llOk = _InsertUsuario(lnId, toIUsario, tlParents: false, toObjetoGestDoc: loObjetoGestDoc);
1769 
1770  if (!llOk)
1771  break;
1772  }
1773  }
1774 
1775  return llOk;
1776  }
1777 
1783  private IObjetoGestDoc ObjetoGestDocumental(IObjetoGestDoc toObjetoGestDoc = null)
1784  {
1785  IObjetoGestDoc loObjetoGestDoc;
1786 
1787  if (toObjetoGestDoc != null)
1788  loObjetoGestDoc = toObjetoGestDoc; // Actualización de un parent
1789  else
1790  loObjetoGestDoc = this; // Actualización del documento o carpeta actual
1791 
1792  return loObjetoGestDoc;
1793  }
1794 
1802  private void DirectoryParents(ref string tcCarpeta, int tnIdCarpetaParent, DataTable tdtCarpetas)
1803  {
1804  int lnCarpetaParent;
1805 
1806  DataRow[] ldrCarpeta = tdtCarpetas.Select(" id = " + Convert.ToString(tnIdCarpetaParent).Trim());
1807 
1808  if (ldrCarpeta != null && ldrCarpeta.Count() > 0)
1809  {
1810  tcCarpeta = Path.Combine(Convert.ToString(ldrCarpeta[0]["nombre"]).Trim(), tcCarpeta); // Agregamos la carpeta del padre PADRE + HIJA (tcCarpeta)
1811  lnCarpetaParent = Convert.ToInt32(ldrCarpeta[0]["parent"]);
1812 
1813  if (lnCarpetaParent > 0) // Si tiene padre
1814  DirectoryParents(ref tcCarpeta, lnCarpetaParent, tdtCarpetas);
1815  }
1816  }
1817 
1821  private void ConfiguacioneSincronizar()
1822  {
1823  _bSincronizar = !string.IsNullOrWhiteSpace(_oGestDoc._Configuracion._RefreshTokenOneDrive) && !string.IsNullOrWhiteSpace(_oGestDoc._Configuracion._CuentaOneDrive);
1824  _cRutaDocsOneDrive = _oGestDoc._Configuracion._RutaDocsOneDrive;
1825 
1826  if (_oGestDoc._Configuracion._TipoServicio == 0)
1827  _oTipoConexionServicio = TipoConexion.OneDrive;
1828  else
1829  _oTipoConexionServicio = TipoConexion.O365;
1830  }
1831  #endregion Métodos privados
1832  }
1833  #endregion Clase ObjetoGestDoc
1834 
1835  # region Clase StateDataRow
1836  public class StateDataRow
1840  {
1841  # region Propiedades privadas
1842  private DataRow _drObjeto = null;
1843  private DataTable _dtObjeto = null;
1844  private eTipoActualizacionObjeto _eInsertUpdate;
1845  # endregion Propiedades privadas
1846 
1847  # region Protected internal
1848  protected internal Type _Tipo = null;
1852  # endregion Protected internal
1853 
1854  # region Métodos public virtual
1855  public virtual bool _DataRowCondicion()
1860  {
1861  return true;
1862  }
1863  # endregion Métodos public virtual
1864 
1865  # region Métodos protected internal
1866  protected internal void _DataRowCopia()
1870  {
1871  if (_DataRowCondicion())
1872  _drObjeto = DataRowObjeto();
1873  }
1874 
1879  protected internal eTipoActualizacionObjeto _TipoActualizacion()
1880  {
1881  if (_eInsertUpdate == eTipoActualizacionObjeto.Delete) // SI está macardo para borrar ya podemos salir
1882  return _eInsertUpdate;
1883 
1884  DataRow ldrTemp = DataRowObjeto();
1885 
1886  if (_drObjeto != null) //si la copia de la linia es null, aleshores l'hem d'insertar la linia
1887  {
1888  if (!DataRowComparer.Default.Equals(_drObjeto, ldrTemp)) //hem d comparar si hi ha hagut algun canvi.
1889  _eInsertUpdate = eTipoActualizacionObjeto.Update;
1890  else
1891  _eInsertUpdate = eTipoActualizacionObjeto.Nothing;
1892  }
1893  else
1894  _eInsertUpdate = eTipoActualizacionObjeto.Insert;
1895 
1896  _drObjeto = null;
1897  _drObjeto = ldrTemp;
1898 
1899  return _eInsertUpdate;
1900  }
1901  # endregion Métodos protected internal
1902 
1903  # region Métodos privados
1904  private DataRow DataRowObjeto()
1909  {
1910  if (_Tipo == null)
1911  return null;
1912 
1913  PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(_Tipo);
1914 
1915  List<string> lstName = new List<string> { "_Children", "_Error_message" };
1916 
1917  if (_drObjeto == null) //si no s'ha creat el datatable amb les propietats publiques el creem
1918  {
1919  _dtObjeto = new DataTable();
1920  foreach (PropertyDescriptor prop in properties)
1921  {
1922  if (!string.IsNullOrWhiteSpace(prop.Name) && prop.Name.Substring(0, 1) == "_" && !lstName.Contains(prop.Name)) // descartem les propietats q no comencen amb _ ja que només volem les publiques
1923  _dtObjeto.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);
1924  }
1925  }
1926 
1927  DataRow row = _dtObjeto.NewRow(); //guardem la linia que es passa per parametre a un datarow
1928  foreach (PropertyDescriptor prop in properties)
1929  {
1930  if (!string.IsNullOrWhiteSpace(prop.Name) && prop.Name.Substring(0, 1) == "_" && !lstName.Contains(prop.Name)) //descartem les propietats q no comencen amb _ ja que només volem les públiques
1931  {
1932  try
1933  {
1934  row[prop.Name] = prop.GetValue(this) ?? DBNull.Value;
1935  }
1936  catch (Exception)
1937  {
1938  row[prop.Name] = DBNull.Value;
1939  }
1940  }
1941  }
1942 
1943  return row;
1944  }
1945  # endregion Métodos privados
1946  }
1947  # endregion Clase StateDataRow
1948 }
1949 
bool _AddUsuario(IUsuario toIUsuario)
Añadimos un usuario
Clase de usuarios para la gestión documental
Definition: Usuario.cs:18
eTipoAcceso _AccesoUsuario(string tcUsuario="")
Devuelve el acceso del usuario del objeto
virtual bool _LoadUsuarios()
Cargamos la lista de usuarios al cargar el objeto
virtual bool _Download(string tcPathDestino)
Nos sirve para bajar todo el objeto y lo que cuelga de él.
Objeto base ObjetoGestDoc que cumple la interfaz IObjetoGestDoc Este objeto es la base del objeto Car...
Interfaz para el el Objeto Documento
Definition: IDocumento.cs:14
eTipoConsultaCarpetasDocumentos
Enumeración para gestionar la consulta de la estructura de carpetas y documentos
Definition: EnumGestDoc.cs:29
Es como el tipo de entrada asientos pero por negocio, sin formulario, pq quiero que me haga las propu...
virtual bool _LoadTags()
Cargamos la lista de tags consultar el objeto
virtual bool _Delete()
Borra el objeto si puede
bool _DeleteUsuario(IUsuario toUsuario)
Borramos el usuario del BindingList "_Usuarios" y la guardamos en la lista de usuarios a borrar ...
Clase statica para funciones base del addon GESTDOC
Definition: SageAddons.cs:41
bool _AddPropiedad()
Añadimos una propiedad
new string _Codigo
Valor de campo clave
Definition: clsUsuario.cs:1020
bool _AddPropiedad(IPropiedad toPropiedad)
Añadimos una propiedad
virtual bool _Cancel()
Nos cancela el objeto documento o carpeta
bool _DeletePropiedad(IPropiedad toPropiedad)
Borramos la propiedad del BindingList "_Propiedades" y la guardamos en la lista de propiedades a borr...
eTipoAcceso
Tipos de accesos a las carpetas y documentos
Definition: EnumGestDoc.cs:44
virtual bool _Save()
Nos guarda todo el objeto en la tabla correspondiente
virtual DialogResult _Show()
Nos presenta el formulario asociado a este objeto
Interfaz para el el Objeto Carpeta
Definition: ICarpeta.cs:15
bool _AddTag(ITag toTag)
Añadimos un tag
BindingList< IUsuario > _Usuarios
Lista de usuarios que tienen acceso a este objeto
virtual bool _Upload(string tcPathOrigen)
Sube toda una ruta especifica
Clase de tags para la gestión documental
Definition: Tag.cs:17
Formulario base de Eurowin
Definition: clsFormul.cs:400
bool _DeleteTag(ITag toTag)
Borramos el tag del BindingList "_Tags" y la guardamos en la lista de tags a borrar ...
virtual bool _Move(int tnIDObjetoDocDestino)
Nos mueve este objeto y todo lo que cuelga de este objeto al otro objeto
virtual bool _LoadPropiedades()
Cargamos la lista de usuarios al cargar el objeto
eTipoActualizacionObjeto
Enumeración para gestionar si ha de realizar un Insert, Update o nada
Definition: EnumGestDoc.cs:6
BindingList< ITag > _Tags
Lista de tags asociados para este objeto
Clase del addon de gestión documental.
Definition: SageAddons.cs:85
virtual bool _Rename(string tcNewName)
Nos sirve para renombrar un objeto Se realizará automáticamente el Save de un objeto ...
Clase para la gestión de las propiedades de los documentos y carpetas
Definition: Propiedad.cs:17
TipoConexion
Tipo de conexión
virtual bool _Load()
Nos carga el objeto
DialogResult _MessageBox(String tcMensaje, MessageBoxButtons toBotones, MessageBoxIcon toIcono, MessageBoxDefaultButton toBotonDefecto, DialogResult toResultadoDefecte)
Messagebox propio 1
Definition: clsFormul.cs:3364
Definición de la clase Usuario
Definition: clsUsuario.cs:113
BindingList< IPropiedad > _Propiedades
Lista de propiedades adicionales para este objeto