3 using System.Collections.Generic;
5 using System.ComponentModel;
11 using System.Windows.Forms;
19 #region Clase ObjetoGestDoc 26 # region Propiedades privadas 27 private BindingList<IUsuario> _lisUsuariosDelete;
28 private BindingList<IPropiedad> _lisPropiedadesDelete;
29 private BindingList<ITag> _lisTagsDelete;
31 # endregion Propiedades privadas 33 # region Propiedades protected internal 34 protected internal bool _lSubscripcionActiva =
true;
42 protected internal bool _bSincronizar =
false;
47 protected internal string _cRutaDocsOneDrive =
string.Empty;
57 protected internal int _nId = 0;
62 protected internal string _cNombre =
string.Empty;
67 protected internal BindingList<IUsuario> _lisUsuarios;
72 protected internal BindingList<IPropiedad> _lisPropiedades;
77 protected internal BindingList<ITag> _lisTags;
82 protected internal BindingList<IObjetoGestDoc> _lisChildren = null;
88 protected internal DateTime _dFechaCreacion = DateTime.Now.Date;
93 protected internal string _cUsuarioCreacion =
string.Empty;
98 protected internal string _cRutaLocal =
string.Empty;
103 protected internal string _cError_message =
string.Empty;
108 protected internal bool _lLoading =
false;
113 protected internal FormBase _Form = null;
118 protected internal ToolStripProgressBar _oProgressbar = null;
135 if (!
string.IsNullOrWhiteSpace(_UsuarioCreacion))
136 _oUser.
_Codigo = _cUsuarioCreacion;
149 # endregion Propiedades protected internal 151 # region Propiedades públicas 170 public virtual string _Nombre
185 public bool _EsCarpeta
196 public BindingList<IUsuario> _Usuarios
200 if (_lisUsuarios == null)
201 _lisUsuarios =
new BindingList<IUsuario>();
207 _lisUsuarios = value;
214 public BindingList<IPropiedad> _Propiedades
218 if (_lisPropiedades == null)
219 _lisPropiedades =
new BindingList<IPropiedad>();
221 return _lisPropiedades;
225 _lisPropiedades = value;
232 public BindingList<ITag> _Tags
236 if (_lisTags == null)
237 _lisTags =
new BindingList<ITag>();
250 public DateTime _FechaCreacion
254 return _dFechaCreacion;
258 _dFechaCreacion = value;
265 public string _UsuarioCreacion
269 return _cUsuarioCreacion;
273 _cUsuarioCreacion = value;
280 public string _NombreUsuarioCreacion
284 string lcNombre =
string.Empty;
286 if (_oUsuario != null)
287 lcNombre = Convert.ToString(_oUsuario._Nombre).Trim();
296 public virtual string _FullPath
307 public string _Error_message
311 return _cError_message;
315 _cError_message = value;
318 # endregion Propiedades públicas 326 _lisUsuarios =
new BindingList<IUsuario>();
327 _lisPropiedades =
new BindingList<IPropiedad>();
328 _lisTags =
new BindingList<ITag>();
330 _lisChildren =
new BindingList<IObjetoGestDoc>();
332 _lisUsuariosDelete =
new BindingList<IUsuario>();
333 _lisPropiedadesDelete =
new BindingList<IPropiedad>();
334 _lisTagsDelete =
new BindingList<ITag>();
337 if (_oGestDoc != null)
339 _lSubscripcionActiva = (_oGestDoc._BajaSuscripcion ==
false);
340 ConfiguacioneSincronizar();
343 #endregion Constructor 345 # region Métodos públicos de la interfaz "IObjetoGestDoc" 346 public virtual bool _New(
int tnIdParent)
411 public virtual bool _Upload(
string tcPathOrigen)
432 return DialogResult.Cancel;
440 public virtual bool _Move(
int tnIDObjetoDocDestino)
452 _lisPropiedadesDelete.Add(toPropiedad);
453 _lisPropiedades.Remove(toPropiedad);
465 _lisUsuariosDelete.Add(toUsuario);
466 _lisUsuarios.Remove(toUsuario);
478 _lisTagsDelete.Add(toTag);
479 _lisTags.Remove(toTag);
490 if (_Propiedades.Where(prop =>
string.IsNullOrWhiteSpace(prop._Propiedad)).Count() == 0)
510 if (loTag._oObjetoGestDoc == null)
511 loTag._oObjetoGestDoc =
this;
513 _Propiedades.Add(toPropiedad);
526 if (_Tags.Where(tag =>
string.IsNullOrWhiteSpace(tag._Cadena)).Count() == 0)
528 _Tags.Add(
new Tag(
this));
546 if (loTag._oObjetoGestDoc == null)
547 loTag._oObjetoGestDoc =
this;
562 if (_Usuarios.Where(usuario =>
string.IsNullOrWhiteSpace(usuario._Usuario)).Count() == 0)
564 _Usuarios.Add(
new Usuario(
this));
581 if (_ValidUsuario(toIUsuario.
_Usuario))
583 if (loUsuario._oObjetoGestDoc == null)
584 loUsuario._oObjetoGestDoc =
this;
586 _Usuarios.Add(toIUsuario);
604 if (
string.IsNullOrWhiteSpace(tcUsuario))
605 lcUsuario = UsuarioActual();
607 lcUsuario = tcUsuario;
609 if (lcUsuario !=
"SUPERVISOR")
611 var loUsuario = _Usuarios.AsEnumerable().Where(user => user._Usuario == lcUsuario);
613 if (loUsuario.Count() > 0)
614 leTipoAcceso = (
eTipoAcceso)loUsuario.First()._Nivel;
622 # endregion Métodos públicos de la interfaz "IObjetoGestDoc" 624 #region Métodos public virtual 625 public virtual void _DescargarDatos()
631 _cNombre =
string.Empty;
632 _dFechaCreacion = DateTime.Now.Date;
634 if (_lisUsuarios != null)
635 _lisUsuarios.Clear();
637 if (_lisPropiedades != null)
638 _lisPropiedades.Clear();
640 if (_lisTags != null)
643 if (_lisChildren != null)
644 _lisChildren.Clear();
646 if (_lisUsuariosDelete != null)
647 _lisUsuariosDelete.Clear();
649 if (_lisPropiedadesDelete != null)
650 _lisPropiedadesDelete.Clear();
652 if (_lisTagsDelete != null)
653 _lisTagsDelete.Clear();
682 #endregion Métodos public virtual 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)
696 DialogResult toResultado =
new DialogResult();
700 string lcCaption = _Form.Text;
701 toResultado = FUNCTIONS.
_MessageBox(tcMensaje, lcCaption, toBotones, toIcono, toBotonDefecto, _Form);
705 _Error_message = tcMensaje;
706 toResultado = toResultadoDefecte;
718 protected internal void _MensajeError(
string tcMensaje, MessageBoxButtons toMessageBoxButtons = MessageBoxButtons.OK, MessageBoxIcon toMessageBoxIcon = MessageBoxIcon.Exclamation)
720 _MessageBox(tcMensaje, toMessageBoxButtons, toMessageBoxIcon, MessageBoxDefaultButton.Button1, DialogResult.OK);
730 protected internal bool _FeaturesParent(
int tnIdParent)
736 ICarpeta loCarpeta =
new Carpeta(tnIdParent);
738 if (loCarpeta.
_Id > 0)
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)));
753 protected internal string UsuarioActual()
755 return Convert.ToString(EW_GLOBAL._GetVariable(
"wc_usuario"));
762 protected internal bool _LoadFeatures()
766 llOk = _LoadPropiedades();
767 llOk = llOk && _LoadUsuarios();
768 llOk = llOk && _LoadTags();
779 protected internal bool _Download(
string tcPathDestino, ToolStripProgressBar toewProgressbar)
783 if (toewProgressbar != null)
784 _oProgressbar = toewProgressbar;
786 llOk = _Download(tcPathDestino);
795 protected internal bool _DeleteFeatures()
800 llOk = DeletePropiedades(_lisPropiedades);
801 llOk = llOk && DeleteUsuarios(_lisUsuarios);
802 llOk = llOk && DeleteTags(_lisTags);
811 protected internal bool _SaveFeatures()
816 llOk = DeletePropiedades(_lisPropiedadesDelete);
817 llOk = llOk && DeleteUsuarios(_lisUsuariosDelete);
818 llOk = llOk && DeleteTags(_lisTagsDelete);
821 llOk = llOk && SavePropiedades();
822 llOk = llOk && SaveUsuarios();
823 llOk = llOk && SaveTags();
835 protected internal int _MaxLinea(
string tcTabla,
string tcCampoWhere,
int tnIdGestDoc = 0)
838 int lnLinea = 0, lnId = 0;
840 DataTable ldtLineaMax =
new DataTable();
842 if (tnIdGestDoc == 0)
847 lcSql =
"SELECT MAX(LINEA) AS LINEA " +
848 " FROM " + DB.SQLDatabase(
"GESTDOC", tcTabla) +
849 " WHERE " + tcCampoWhere +
" = " + DB.SQLString(lnId);
851 llOk = DB.SQLExec(lcSql, ref ldtLineaMax);
853 if (llOk && ldtLineaMax != null && ldtLineaMax.Rows.Count > 0 && ldtLineaMax.Rows[0][
"LINEA"] != DBNull.Value)
854 lnLinea = Convert.ToInt32(ldtLineaMax.Rows[0][
"LINEA"]);
867 protected internal void _AddUsuarios(DataTable tdtUsuarios,
bool tlDataRowCopia =
true)
869 if (tdtUsuarios.Rows.Count > 0)
871 foreach (DataRow ldrUsuario
in tdtUsuarios.Rows)
873 IUsuario loUsuario =
new Usuario(
this,ldrUsuario);
874 _Usuarios.Add(loUsuario);
879 _Usuarios.ToList<
IUsuario>().ForEach(user => ((Usuario)user)._DataRowCopia());
888 protected internal void _AddPropiedades(DataTable tdtPropiedades,
bool tlDataRowCopia =
true)
890 if (tdtPropiedades.Rows.Count > 0)
892 foreach (DataRow ldrPropiedad
in tdtPropiedades.Rows)
894 IPropiedad loPropiedad =
new Propiedad(
this,ldrPropiedad);
895 _Propiedades.Add(loPropiedad);
900 _Propiedades.ToList<
IPropiedad>().ForEach(user => ((Propiedad)user)._DataRowCopia());
909 protected internal void _AddTags(DataTable tdtTags,
bool tlDataRowCopia =
true)
911 if (tdtTags.Rows.Count > 0)
913 foreach (DataRow ldrTag
in tdtTags.Rows)
915 ITag loTag =
new Tag(
this,ldrTag);
921 _Tags.ToList<
ITag>().ForEach(user => ((Tag)user)._DataRowCopia());
928 protected internal bool _ValidNombre()
932 string lcNombre = _cNombre.Trim();
934 if (!
string.IsNullOrWhiteSpace(lcNombre) && lcNombre.IndexOfAny(
new char[] {
'\\',
'/',
':',
'*',
'?',
'\"',
'<',
'>',
'|' }) != -1)
939 lcMensaje =
"archivos";
941 lcMensaje =
"carpetas";
944 _MessageBox(
"Los nombres de " + lcMensaje +
" no pueden contener ninguno de los siguientes carácteres:" + Environment.NewLine +
"\\/:*?\"<>|");
948 if (
this is
ICarpeta && lcNombre.Length > 50)
950 _MessageBox(
"El ancho máximo de una carpeta es de 50 carácteres.");
953 else if (
this is
IDocumento && lcNombre.Length > 100)
955 _MessageBox(
"El ancho máximo de un documento es de 100 carácteres.");
968 protected internal bool _ValidPropiedad(
string tcPropiedad)
970 if (tcPropiedad == null)
973 string lcPropiedad = tcPropiedad.Trim();
975 if (!
string.IsNullOrWhiteSpace(lcPropiedad) && _Propiedades.Where(prop => prop._Propiedad == lcPropiedad).Count() > 0)
977 _MessageBox(
"La propiedad '" + lcPropiedad +
"' se ha entrado previamente");
989 protected internal bool _ValidUsuario(
string tcUsuario)
991 string lcUsuario = tcUsuario.Trim();
993 if (!
string.IsNullOrWhiteSpace(lcUsuario) && _Usuarios.Where(user => user._Usuario == lcUsuario).Count() > 0)
995 _MessageBox(
"El usuario " + lcUsuario +
" se ha entrado previamente");
1007 protected internal bool _ValidTag(
string tcCadenaTag)
1009 string lcCadenaTag = tcCadenaTag.Trim();
1011 if (!
string.IsNullOrWhiteSpace(lcCadenaTag) && _Tags.Where(tag => tag._Cadena.Trim() == lcCadenaTag).Count() > 0)
1013 _MessageBox(
"La etiqueta " + lcCadenaTag +
" se ha entrado previamente");
1024 protected internal DataTable _DataTableUsuarios()
1028 DataTable ldtUsuarios =
new DataTable();
1030 lcSql =
"SELECT CODIGO, NOMBRE " +
1031 " FROM " + DB.SQLDatabase(
"COMUNES",
"USUARIOS") +
1032 " WHERE VISIBLE = " + DB.SQLTrue() +
1035 llOk = DB.SQLExec(lcSql, ref ldtUsuarios);
1038 _MensajeError(
"Se ha producido un error al consultar los usuarios.");
1048 protected internal int _MaxId(
string tcTabla)
1051 string lcSql =
string.Empty;
1052 DataTable ldtMaxId =
new DataTable();
1054 lcSql =
"SELECT MAX(id) AS maxim FROM " + DB.SQLDatabase(
"GESTDOC", tcTabla);
1056 DB.SQLExec(lcSql, ref ldtMaxId);
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);
1070 protected internal string _DirectoryParents(ref
string tcCarpeta,
int tnCarpeta)
1072 string lcSql, lcCarpeta =
string.Empty;
1074 DataTable ldtCarpetas =
new DataTable();
1076 lcSql =
"SELECT ID, NOMBRE, PARENT" +
1077 " FROM " + DB.SQLDatabase(
"GESTDOC",
"CARPETAS") +
1080 bool llOk = DB.SQLExec(lcSql, ref ldtCarpetas);
1082 if (llOk && ldtCarpetas.Rows.Count > 0)
1083 DirectoryParents(ref tcCarpeta, tnCarpeta, ldtCarpetas);
1093 protected internal bool _ExisteMantePropiedades(
string tcPropiedad)
1095 DataTable ldtProps =
new DataTable();
1099 lcSql =
"SELECT PROPIEDAD FROM " + DB.SQLDatabase(
"GESTDOC", _TaulaPropiedad()) +
1100 " WHERE PROPIEDAD = " + DB.SQLString(tcPropiedad);
1102 DB.SQLExec(lcSql, ref ldtProps);
1103 llOk = (ldtProps != null && ldtProps.Rows.Count > 0);
1113 protected internal bool _DeleteMantePropiedades(
string tcPropiedad)
1118 lcSql =
"DELETE FROM " + DB.SQLDatabase(
"GESTDOC", _TaulaPropiedad()) +
1119 " WHERE PROPIEDAD = " + DB.SQLString(tcPropiedad);
1121 llOk = DB.SQLExec(lcSql);
1124 _MensajeError(
"Se ha producido un error al borrrar las propiedades.");
1134 protected internal string _TaulaPropiedad(
IObjetoGestDoc toObjetoGestDoc = null)
1136 if (ObjetoGestDocumental(toObjetoGestDoc) is Documento)
1147 protected internal string _TaulaTags(
IObjetoGestDoc toObjetoGestDoc = null)
1149 if (ObjetoGestDocumental(toObjetoGestDoc) is Documento)
1160 protected internal string _TaulaUsuarios(
IObjetoGestDoc toObjetoGestDoc = null)
1162 if (ObjetoGestDocumental(toObjetoGestDoc) is Documento)
1173 protected internal string _IdTaula(
IObjetoGestDoc toObjetoGestDoc = null)
1175 if (ObjetoGestDocumental(toObjetoGestDoc) is Documento)
1190 protected internal bool _InsertPropiedad(
int tnIdGestDoc,
IPropiedad toPropiedad,
int tnLinea = 0,
bool tlParents =
true,
IObjetoGestDoc toObjetoGestDoc = null)
1193 string lcSql , lcTaula , lcCampoId;
1197 lcTaula = _TaulaPropiedad(toObjetoGestDoc);
1198 lcCampoId = _IdTaula(toObjetoGestDoc);
1201 lnLinea = _MaxLinea(lcTaula, lcCampoId, tnIdGestDoc);
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) +
")";
1207 llOk = DB.SQLExec(lcSql);
1209 if (llOk && tlParents && (
this is
ICarpeta))
1210 InsertPropiedadesParents(tnIdGestDoc, toPropiedad);
1225 protected internal bool _InsertTag(
int tnIdGestDoc,
ITag toTag,
string tcIdTag,
int tnLinea = 0,
bool tlParents =
true,
IObjetoGestDoc toObjetoGestDoc = null)
1228 string lcSql, lcTaula, lcCampoId;
1232 lcTaula = _TaulaTags(toObjetoGestDoc);
1233 lcCampoId = _IdTaula(toObjetoGestDoc);
1236 lnLinea = _MaxLinea(lcTaula, lcCampoId, tnIdGestDoc);
1238 lcSql =
"INSERT INTO " + DB.SQLDatabase(
"GESTDOC", lcTaula) +
1239 " (" + lcCampoId +
", IDTAG, LINEA)" +
1240 " Values(" + DB.SQLString(tnIdGestDoc) +
", " + DB.SQLString(tcIdTag) +
", " + DB.SQLString(lnLinea) +
")";
1242 llOk = DB.SQLExec(lcSql);
1244 if (llOk && tlParents && (
this is
ICarpeta))
1245 InsertTagParents(tnIdGestDoc, toTag, tcIdTag);
1259 protected internal bool _InsertUsuario(
int tnIdGestDoc,
IUsuario toUsuario,
int tnLinea = 0,
bool tlParents =
true,
IObjetoGestDoc toObjetoGestDoc = null)
1262 string lcSql, lcTaula, lcCampoId;
1266 lcTaula = _TaulaUsuarios(toObjetoGestDoc);
1267 lcCampoId = _IdTaula(toObjetoGestDoc);
1270 lnLinea = _MaxLinea(lcTaula, lcCampoId, tnIdGestDoc);
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) +
")";
1276 llOk = DB.SQLExec(lcSql);
1278 if (llOk && tlParents && (
this is
ICarpeta))
1279 InsertUsuarioParents(tnIdGestDoc, toUsuario);
1287 protected internal void _PerformStepProggressbar()
1289 if (_oProgressbar != null)
1291 if (_oProgressbar.Value < _oProgressbar.Maximum)
1293 _oProgressbar.PerformStep();
1294 Application.DoEvents();
1303 protected internal void _MensajeError(
string tcMensaje)
1305 if (!
string.IsNullOrWhiteSpace(tcMensaje))
1306 _Error_message = tcMensaje;
1315 protected internal string _DirectoryGestDocDocumentos(
string tcCarpeta)
1317 string lcPath = FunctionsGestDoc._DirectorioGestDoc();
1319 if (
string.IsNullOrWhiteSpace(lcPath))
1322 lcPath = Path.Combine(lcPath,
"Docs" + FUNCTIONS._Grupo_Actual());
1323 lcPath = Path.Combine(lcPath,
"Documentos");
1325 if (!
string.IsNullOrWhiteSpace(tcCarpeta))
1326 lcPath = Path.Combine(lcPath, tcCarpeta);
1328 return lcPath + Path.DirectorySeparatorChar;
1337 protected internal bool _DirectoryExist(
string tcPath,
bool tlCreate =
true)
1340 string lcPath =
string.Empty ,lcMensajeError =
string.Empty;
1344 lcPath = Path.GetDirectoryName(tcPath);
1345 llExist = Directory.Exists(tcPath);
1347 catch (Exception loEx)
1349 DB.Registrar_Error(loEx);
1351 lcMensajeError =
"No se ha podido crear el directorio " + lcPath +
"." + Environment.NewLine + Environment.NewLine + loEx.Message;
1355 if (
string.IsNullOrWhiteSpace(lcMensajeError) && !llExist && tlCreate)
1359 Directory.CreateDirectory(lcPath);
1360 llExist = Directory.Exists(lcPath);
1362 catch (Exception loEx)
1364 DB.Registrar_Error(loEx);
1365 lcMensajeError =
"No se ha podido crear el directorio " + lcPath +
"." + Environment.NewLine + Environment.NewLine + loEx.Message;
1369 if (!
string.IsNullOrWhiteSpace(lcMensajeError))
1370 _MensajeError(lcMensajeError);
1381 protected internal bool _DeleteDirectoryRecursive(
string tcDirectory,
bool tlRecursive =
true)
1385 string lcMensaje =
string.Empty, lcDirectoryRename =
string.Empty;
1387 if (Directory.Exists(tcDirectory))
1392 lcDirectoryRename = FunctionsGestDoc._DirectorySeparatorChar(tcDirectory);
1394 if (Path.GetDirectoryName(tcDirectory).Length < 230)
1396 lcDirectoryRename =
System.IO.Directory.GetParent(tcDirectory).Parent.FullName;
1398 string lcGuid = Guid.NewGuid().ToString(
"N").Substring(0, 8);
1399 lcDirectoryRename = FunctionsGestDoc._DirectorySeparatorChar(Path.Combine(lcDirectoryRename, lcGuid));
1400 Directory.Move(tcDirectory, lcDirectoryRename);
1403 catch (Exception loEx)
1406 lcMensaje =
"No se ha podido eliminar las versiones del documento." + Environment.NewLine + Environment.NewLine + loEx.Message;
1413 Directory.Delete(FunctionsGestDoc._DirectorySeparatorChar(lcDirectoryRename),
true);
1415 catch (Exception loEx)
1417 lcMensaje =
"No se ha podido eliminar las versiones del documento." + Environment.NewLine + loEx.Message;
1420 llOk = !Directory.Exists(tcDirectory);
1425 _MensajeError(
"No se ha podido eliminar el directorio " + tcDirectory +
"." + lcMensaje);
1434 protected internal bool _ProcesoGestDoc()
1436 return (Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_gestdoc_proceso")));
1444 protected internal bool _GestDocPendiente(
string tcMensaje)
1446 if (_ProcesoGestDoc())
1449 bool llKo = (Convert.ToBoolean(EW_GLOBAL._GetVariable(
"wl_ewgestdoc")));
1452 _MensajeError(tcMensaje);
1456 # endregion Métodos protected internal 1458 # region Métodos privados 1459 private bool DeletePropiedades(BindingList<IPropiedad> toListPropiedades)
1468 foreach (
IPropiedad loPropiedad
in toListPropiedades)
1470 llOk = llOk && loPropiedad.
_Delete();
1484 private bool DeleteTags(BindingList<ITag> toListTags)
1488 foreach (
ITag loTag
in toListTags)
1490 llOk = llOk && loTag.
_Delete();
1504 private bool DeleteUsuarios(BindingList<IUsuario> toListUuarios)
1508 foreach (
IUsuario loUsuario
in toListUuarios)
1510 llOk = llOk && loUsuario.
_Delete();
1523 private bool SavePropiedades()
1527 foreach (
IPropiedad loPropiedad
in _Propiedades)
1529 llOk = llOk && loPropiedad.
_Save();
1542 private bool SaveTags()
1546 foreach (
ITag loTag
in _Tags)
1548 llOk = llOk && loTag.
_Save();
1561 private bool SaveUsuarios()
1565 foreach (
IUsuario loUsuario
in _Usuarios)
1567 llOk = llOk && loUsuario.
_Save();
1584 private bool ExistPropiedad(
int tnId,
string tcTaula,
string tcCampoId,
string tcPropiedad)
1587 bool llExist =
false;
1588 DataTable ldtExist =
new DataTable();
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);
1595 llExist = (llOk && ldtExist != null && ldtExist.Rows.Count > 0);
1608 private bool ExistTag(
int tnId,
string tcTaula,
string tcCampoId,
string tcIdTag)
1611 bool llExist =
false;
1612 DataTable ldtExist =
new DataTable();
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);
1619 llExist = (llOk && ldtExist != null && ldtExist.Rows.Count > 0);
1632 private bool ExistUsuario(
int tnId,
string tcTaula,
string tcCampoId,
string tcUsuario)
1635 bool llExist =
false;
1636 DataTable ldtExist =
new DataTable();
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);
1643 llExist = (llOk && ldtExist != null && ldtExist.Rows.Count > 0);
1654 private bool InsertPropiedadesParents(
int tnIdParent,
IPropiedad toIPropiedad)
1657 string lcTaula, lcCampoId;
1658 bool llOk =
true, llCarpeta;
1659 Carpeta loCarpeta =
new Carpeta();
1661 ObjetoGestDoc loObjetoGestDoc;
1665 foreach (DataRow ldrParent
in ldtParents.Rows)
1667 lnId = Convert.ToInt32(ldrParent[
"id"]);
1668 llCarpeta = Convert.ToBoolean(ldrParent[
"carpeta"]);
1671 loObjetoGestDoc = loCarpeta;
1673 loObjetoGestDoc = loDocumento;
1675 lcTaula = _TaulaPropiedad(loObjetoGestDoc);
1676 lcCampoId = _IdTaula(loObjetoGestDoc);
1678 if (!ExistPropiedad(lnId, lcTaula, lcCampoId, toIPropiedad.
_Propiedad))
1681 llOk = _InsertPropiedad(lnId, toIPropiedad, tlParents:
false, toObjetoGestDoc: loObjetoGestDoc);
1698 private bool InsertTagParents(
int tnIdParent,
ITag toITag,
string tcIdTag)
1701 string lcTaula, lcCampoId;
1702 bool llOk =
true, llCarpeta;
1703 Carpeta loCarpeta =
new Carpeta();
1705 ObjetoGestDoc loObjetoGestDoc = null;
1709 foreach (DataRow ldrParent
in ldtParents.Rows)
1711 lnId = Convert.ToInt32(ldrParent[
"id"]);
1712 llCarpeta = Convert.ToBoolean(ldrParent[
"carpeta"]);
1715 loObjetoGestDoc = loCarpeta;
1717 loObjetoGestDoc = loDocumento;
1719 lcTaula = _TaulaTags(loObjetoGestDoc);
1720 lcCampoId = _IdTaula(loObjetoGestDoc);
1722 if (!ExistTag(lnId, lcTaula, lcCampoId, tcIdTag))
1725 llOk = _InsertTag(lnId, toITag, tcIdTag, tlParents:
false, toObjetoGestDoc: loObjetoGestDoc);
1741 private bool InsertUsuarioParents(
int tnIdParent,
IUsuario toIUsario)
1744 string lcTaula,lcCampoId;
1745 bool llOk =
true, llCarpeta;
1746 Carpeta loCarpeta =
new Carpeta();
1748 ObjetoGestDoc loObjetoGestDoc = null;
1752 foreach (DataRow ldrParent
in ldtParents.Rows)
1754 lnId = Convert.ToInt32(ldrParent[
"id"]);
1755 llCarpeta = Convert.ToBoolean(ldrParent[
"carpeta"]);
1758 loObjetoGestDoc = loCarpeta;
1760 loObjetoGestDoc = loDocumento;
1762 lcTaula = _TaulaUsuarios(loObjetoGestDoc);
1763 lcCampoId = _IdTaula(loObjetoGestDoc);
1765 if (!ExistUsuario(lnId, lcTaula, lcCampoId, toIUsario.
_Usuario))
1768 llOk = _InsertUsuario(lnId, toIUsario, tlParents:
false, toObjetoGestDoc: loObjetoGestDoc);
1787 if (toObjetoGestDoc != null)
1788 loObjetoGestDoc = toObjetoGestDoc;
1790 loObjetoGestDoc =
this;
1792 return loObjetoGestDoc;
1802 private void DirectoryParents(ref
string tcCarpeta,
int tnIdCarpetaParent, DataTable tdtCarpetas)
1804 int lnCarpetaParent;
1806 DataRow[] ldrCarpeta = tdtCarpetas.Select(
" id = " + Convert.ToString(tnIdCarpetaParent).Trim());
1808 if (ldrCarpeta != null && ldrCarpeta.Count() > 0)
1810 tcCarpeta = Path.Combine(Convert.ToString(ldrCarpeta[0][
"nombre"]).Trim(), tcCarpeta);
1811 lnCarpetaParent = Convert.ToInt32(ldrCarpeta[0][
"parent"]);
1813 if (lnCarpetaParent > 0)
1814 DirectoryParents(ref tcCarpeta, lnCarpetaParent, tdtCarpetas);
1821 private void ConfiguacioneSincronizar()
1823 _bSincronizar = !
string.IsNullOrWhiteSpace(_oGestDoc._Configuracion._RefreshTokenOneDrive) && !
string.IsNullOrWhiteSpace(_oGestDoc._Configuracion._CuentaOneDrive);
1824 _cRutaDocsOneDrive = _oGestDoc._Configuracion._RutaDocsOneDrive;
1826 if (_oGestDoc._Configuracion._TipoServicio == 0)
1831 #endregion Métodos privados 1833 #endregion Clase ObjetoGestDoc 1835 # region Clase StateDataRow 1836 public class StateDataRow
1841 # region Propiedades privadas 1842 private DataRow _drObjeto = null;
1843 private DataTable _dtObjeto = null;
1845 # endregion Propiedades privadas 1847 # region Protected internal 1848 protected internal Type _Tipo = null;
1852 # endregion Protected internal 1854 # region Métodos public virtual 1855 public virtual bool _DataRowCondicion()
1863 # endregion Métodos public virtual 1865 # region Métodos protected internal 1866 protected internal void _DataRowCopia()
1871 if (_DataRowCondicion())
1872 _drObjeto = DataRowObjeto();
1882 return _eInsertUpdate;
1884 DataRow ldrTemp = DataRowObjeto();
1886 if (_drObjeto != null)
1888 if (!DataRowComparer.Default.Equals(_drObjeto, ldrTemp))
1897 _drObjeto = ldrTemp;
1899 return _eInsertUpdate;
1901 # endregion Métodos protected internal 1903 # region Métodos privados 1904 private DataRow DataRowObjeto()
1913 PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(_Tipo);
1915 List<string> lstName =
new List<string> {
"_Children",
"_Error_message" };
1917 if (_drObjeto == null)
1919 _dtObjeto =
new DataTable();
1920 foreach (PropertyDescriptor prop
in properties)
1922 if (!
string.IsNullOrWhiteSpace(prop.Name) && prop.Name.Substring(0, 1) ==
"_" && !lstName.Contains(prop.Name))
1923 _dtObjeto.Columns.Add(prop.Name, Nullable.GetUnderlyingType(prop.PropertyType) ?? prop.PropertyType);
1927 DataRow row = _dtObjeto.NewRow();
1928 foreach (PropertyDescriptor prop
in properties)
1930 if (!
string.IsNullOrWhiteSpace(prop.Name) && prop.Name.Substring(0, 1) ==
"_" && !lstName.Contains(prop.Name))
1934 row[prop.Name] = prop.GetValue(
this) ?? DBNull.Value;
1938 row[prop.Name] = DBNull.Value;
1945 # endregion Métodos privados 1947 # endregion Clase StateDataRow
bool _Delete()
Borramos el Tag
bool _AddTag()
Añadimos un Tag
bool _AddUsuario(IUsuario toIUsuario)
Añadimos un usuario
Clase de usuarios para la gestión documental
string _Propiedad
Código de propiedad
eTipoAcceso _AccesoUsuario(string tcUsuario="")
Devuelve el acceso del usuario del objeto
bool _Delete()
Borramos la propiedad
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
eTipoConsultaCarpetasDocumentos
Enumeración para gestionar la consulta de la estructura de carpetas y documentos
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
string _Usuario
Código de usuario
bool _Save()
Guardamos el usuario
bool _Delete()
Borramos el usuario
bool _Save()
Guardamos el Tag
bool _DeleteUsuario(IUsuario toUsuario)
Borramos el usuario del BindingList "_Usuarios" y la guardamos en la lista de usuarios a borrar ...
bool _Save()
Guardamos la propiedad
Clase statica para funciones base del addon GESTDOC
bool _AddPropiedad()
Añadimos una propiedad
new string _Codigo
Valor de campo clave
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
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
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
int _Nivel
Nivel del usuario
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
BindingList< ITag > _Tags
Lista de tags asociados para este objeto
Clase del addon de gestión documental.
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
TipoConexion
Tipo de conexión
virtual bool _Load()
Nos carga el objeto
string _Valor
Valor de la propiedad
Definición de la clase Usuario
BindingList< IPropiedad > _Propiedades
Lista de propiedades adicionales para este objeto
bool _AddUsuario()
Añadimos un usuario