Advertisement
Guest User

Untitled

a guest
Jun 11th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.51 KB | None | 0 0
  1. %REM
  2. Agent ActualizarIndicesMotivoPase
  3. Created Jun 7, 2018 Por Santiago Alpuy
  4. Description: Comments for Agent
  5. %END REM
  6. Option Public
  7. Option Declare
  8.  
  9. Use "ConfEE 1.0"
  10. UseLSX "*lsxlc"
  11.  
  12. '------------- Constantes Datos Externos -------------
  13.  
  14. Private Const BASE_DATOS_EXTERNOS = "DATOSEXTERNOS"
  15. Private Const BASE_PORTAL = "PORTAL"
  16. Private Const BASE_RUTAS = "RUTAS"
  17. Private Const BASE_ALARMAS = "sistemas/expedientes/LogAlarmas.nsf"
  18. Private Const VISTA_MOTIVOS = "(BusquedaDatoPorClave)"
  19. Private Const TAG_MOTIVOS_PASE = "MotivosDePase"
  20.  
  21.  
  22. '------------- Constantes Conexion Oracle -------------
  23.  
  24. Private Const ORACLE = "oracle"
  25. 'Private Const ORACLE_SERVER = "BRF9" Produccion
  26. 'Private Const ORACLE_USER = "iem" Produccion
  27. 'Private Const ORACLE_PASSWORD = "mei" Produccion
  28.  
  29. Private Const ORACLE_SERVER = "BDE9"
  30. Private Const ORACLE_USER = "prh"
  31. Private Const ORACLE_PASSWORD = "prh"
  32.  
  33. '------------- Constantes Vistas Portal -------------
  34. 'Las vistas deben ser sin categorizar por que de lo contrario, habran problemas a la hora de iterar a traves de los documentos.
  35. Private Const VISTA_BANDEJA_ENTRADA = "ExpedienteBandejaEntradaSinCategorizar"
  36. Private Const VISTA_BANDEJA_TRABAJO = "ExpedienteBandejaTrabajoSinCategorizar"
  37.  
  38. '------------- Constantes Vistas Gestion ------------
  39.  
  40. 'En esta vista vemos las actuaciones de la forma (NroActuacion)(NroExpe) por ejemplo 102018-4000-98-000004 es la 10ava actuación del
  41. 'expediente 2018-4000-98-000004.
  42. Private Const VISTA_ACTUACIONES_NRO_EXPE = "(BusquedaActuacion)"
  43.  
  44. '------------- Constantes Documentos Indice ----------------
  45.  
  46. Private Const CANTIDAD_ACTUACIONES = "ccnNroAct"
  47. Private Const BASE_GESTION_DE_INDICE = "base"
  48. Private Const NUMERO_EXPEDIENTE_INDICE = "clave"
  49. Private Const ALARMA = "AlarmaMotivoPase"
  50. Private Const ALARMA_SI = "SI"
  51. Private Const ALARMA_NO = "NO"
  52. Private Const TIENE_PAQUETE = "rTienePaquete"
  53. Private Const ESTADO_INDICE = "ccEstado"
  54. Private Const ESTADO_TRANSITO = "EN TRÁNSITO"
  55. Private Const TEMA = "sTema"
  56.  
  57. '------------- Constantes Ultima Actuacion -----------------
  58.  
  59. Private Const FECHA_RECIBIDO = "fRecibido"
  60. Private Const FECHA_ENTRADA = "fEntrada"
  61. Private Const MOTIVO_PASE = "sMotivoDePase"
  62. Private Const OFICINA_ACTUAL = "ccOficina"
  63.  
  64. '------------- Constantes Base Alarma Log ------------------
  65.  
  66. Private Const VISTA_ALARMA_LOG = "LogAlarmas"
  67. Private Const VISTA_TEMAS_POR_NOMBRE = "Reportes\Temas por Nombre"
  68. Private Const VISTA_CATEGORIAS_POR_NUMERO = "(BusquedaCategoriaXNum)"
  69.  
  70. '------------------------------------------------------
  71.  
  72.  
  73. Sub Initialize
  74. On Error GoTo ErrorActIndice
  75. Dim session As New NotesSession
  76. Dim dbPortal As NotesDatabase
  77. Dim dbGestion As NotesDatabase
  78. Dim dbDatosExternos As NotesDatabase
  79. Dim dbRutas As NotesDatabase
  80. Dim dbLogAlarmas As NotesDatabase
  81. Dim servidorPrimario As String
  82. Dim servidorActual As String
  83. Dim c As Configuracion
  84. Dim flag_Bandeja_Entrada As Boolean
  85.  
  86.  
  87. '----------------- Bandera para habilitar que busque en Bandeja de Entrada -----------------
  88. 'Si la bandera es TRUE, busca ademas de la bandeja de trabajo, en bandeja de entrada, tambien contemplara los casos donde
  89. 'el expediente tenga paquete.
  90. 'En ese caso (hay paquete) no debo verificar nada. Para los demas documentos debo comparar la fecha habil con la fecha de entrada.
  91.  
  92. 'Si la bandera es FALSE busco solamente en la bandeja de trabajo y en el campo fRecibido de las ultimas actuaciones.
  93.  
  94. flag_Bandeja_Entrada = True
  95. '-------------------------------------------------------------------------------------------
  96.  
  97. Set c = New Configuracion
  98. Set dbDatosExternos = c.ReferenciarBaseDeDatos(BASE_DATOS_EXTERNOS)
  99. Set dbPortal = c.ReferenciarBaseDeDatos(BASE_PORTAL)
  100. Set dbRutas = c.ReferenciarBaseDeDatos(BASE_RUTAS)
  101. Set dbLogAlarmas = session.Getdatabase("", BASE_ALARMAS , False)
  102.  
  103. '----------------- Busco el servidor primario ------------------'
  104.  
  105. 'El agente va a correr unicamente si el servidor actual es el servidor primario
  106. servidorPrimario = c.ServidorDomino(CLAVE_DBMOTORDOC)
  107. servidorActual = FullTrim(Replace(session.Currentdatabase.server, "CN=", ""))
  108. servidorActual = Replace(servidorActual, "O=", "")
  109.  
  110. If UCase(servidorPrimario) = UCase(servidorActual) Then
  111.  
  112. 'Guardare en dos variants los motivos de pase y la cantidad de días del mismo
  113. Dim motivosPase As Vector
  114. Dim diasMotivos As Vector
  115. Dim fechaHabil As Vector
  116.  
  117. Set motivosPase = New Vector(0)
  118. Set diasMotivos = New Vector(0)
  119. Set fechaHabil = New Vector(0)
  120.  
  121. Dim viewDatosExternos As NotesView
  122. Dim viewPortal As NotesView
  123.  
  124. Set viewDatosExternos = dbDatosExternos.Getview(VISTA_MOTIVOS)
  125. Dim coleccionMotivosPase As NotesDocumentCollection
  126. Set coleccionMotivosPase = viewDatosExternos.Getalldocumentsbykey(TAG_MOTIVOS_PASE, False)
  127. Dim docMotivoPase As NotesDocument
  128. Set docMotivoPase = coleccionMotivosPase.Getfirstdocument()
  129. Dim valorMotivoPase As String
  130. Dim splitValorMotivoPase As Variant
  131.  
  132. While Not docMotivoPase Is Nothing
  133. valorMotivoPase = docMotivoPase.Getitemvalue("Codigo")(0)
  134. splitValorMotivoPase = Split(valorMotivoPase,"|")
  135.  
  136. Call motivosPase.insertElement(splitValorMotivoPase(0), motivosPase.cantElem+1)
  137. Call diasMotivos.insertElement(splitValorMotivoPase(1), diasMotivos.cantElem+1)
  138. Call fechaHabil.insertElement(obtenerFechaHabil(splitValorMotivoPase(1)), fechaHabil.cantElem+1)
  139. Set docMotivoPase = coleccionMotivosPase.Getnextdocument(docMotivoPase)
  140. MsgBox "FechHabil: " & obtenerFechaHabil(splitValorMotivoPase(1)) + "Cantidad Días: " & splitValorMotivoPase(1)
  141. Wend
  142.  
  143.  
  144. 'Luego de este while, los vectores motivosPase, diasMotivos y fechaHabil estan cargados con los motivos, los dias y la fecha ->
  145. 'habil esa cantidad de dias atras.
  146.  
  147. 'Ahora debo recorrer toda la bandeja de entrada y de trabajo y para cada indice debo calcular si amerita poner una alarma o no.
  148. 'La reglas para despertar una alarma son las siguientes:
  149. '-Si fechaHabil de ese motivo de pase >= fechaRecibido y/o fechaPase entonces salta alarma.
  150. '-Si dicha aritmetica es < fechaRecibido y/o fechaPase entonces no salta alarma.
  151.  
  152.  
  153. Dim viewBandejaEntrada As NotesView
  154. Dim viewBandejaTrabajo As NotesView
  155. Set viewBandejaEntrada = dbPortal.Getview(VISTA_BANDEJA_ENTRADA)
  156. Set viewBandejaTrabajo = dbPortal.Getview(VISTA_BANDEJA_TRABAJO)
  157. viewBandejaEntrada.Autoupdate = False
  158. viewBandejaTrabajo.Autoupdate = False
  159.  
  160. Dim viewActuacionesGestion As NotesView
  161. Dim ultimaActuacion As NotesDocument
  162. Dim actuacionYNroExpe As String
  163. Dim fechaRecibido As NotesDateTime
  164. Dim fecha As NotesDateTime 'Se usa indistintamente cuando flag_Bandeja_Entrada = True tanto para fecha de entrada como fecha de recibido
  165. Dim motivoPaseUltimaActuacion As String
  166. Dim isMemberVectorMotivos As Integer
  167. Dim pos As Long
  168. Dim fechaHabilActuacion As NotesDateTime
  169. Dim timeDifference As Long
  170.  
  171. 'Si solo debo recorrer la bandeja de trabajo
  172. If Not flag_Bandeja_Entrada Then
  173.  
  174. Dim docBandejaTrabajo As NotesDocument
  175. Set docBandejaTrabajo = viewBandejaTrabajo.Getfirstdocument()
  176. While Not docBandejaTrabajo Is Nothing
  177. 'Si la cantidad de actuaciones es 1, el documento esta en generación y no amerita poner alarma alguna. No tiene Motivo Pase.
  178. If docBandejaTrabajo.Hasitem(CANTIDAD_ACTUACIONES) And docBandejaTrabajo.Getitemvalue(CANTIDAD_ACTUACIONES)(0) <> 1 Then
  179.  
  180.  
  181. 'Tengo que ir hasta la ultima actuación del expediente correspondiente al indice seleccionado.
  182. 'Para eso hago uso de información ya existente en dicho indice, como la base, el nro expediente y la cantidad de actuaciones.
  183. Set dbGestion = session.Getdatabase("", docBandejaTrabajo.Getitemvalue(BASE_GESTION_DE_INDICE)(0), False)
  184. 'Si la base gestion correspondiente al indice pudo obtenerse, hago lo siguiente.
  185. If Not dbGestion Is Nothing Then
  186.  
  187. Set viewActuacionesGestion = dbGestion.Getview(VISTA_ACTUACIONES_NRO_EXPE)
  188. actuacionYNroExpe = CStr(docBandejaTrabajo.Getitemvalue(CANTIDAD_ACTUACIONES)(0)) + CStr(docBandejaTrabajo.Getitemvalue(NUMERO_EXPEDIENTE_INDICE)(0))
  189. Set ultimaActuacion = viewActuacionesGestion.Getdocumentbykey(actuacionYNroExpe, True)
  190.  
  191. 'Si se pudo obtener de la ultima actuacion, debo agarrar el motivo de pase y la fecha de recibido
  192. If Not ultimaActuacion Is Nothing Then
  193.  
  194. Set fechaRecibido = New NotesDateTime(CStr(ultimaActuacion.Getitemvalue(FECHA_RECIBIDO)(0)))
  195. motivoPaseUltimaActuacion = ultimaActuacion.Getitemvalue(MOTIVO_PASE)(0)
  196.  
  197. If motivoPaseUltimaActuacion <> "" Then
  198.  
  199. 'Si entro a esta condición significa se obtuvo un motivo de pase distinto de vacio
  200. isMemberVectorMotivos = motivosPase.isMember(motivoPaseUltimaActuacion, Pos, False)
  201. 'Luego del isMember en la variable Pos se guardo la posición en el vector de dicho motivo.
  202. 'Si Pos=-1, no se encontro. Si Pos>=1 se encontro.
  203.  
  204. MsgBox "Pos: " & Pos
  205. If Pos >= 1 Then
  206.  
  207. 'Esto significa que en mi vector que cargue anteriormente desde datos externos se encontro el motivo de
  208. 'pase que tiene la ultima actuación encontrada a partir del documento indice.
  209. 'Ahora sabiendo la posicion busco en el vector de fechas habiles y tendre la fecha con que comparar a la
  210. 'fecha de recibido.
  211.  
  212. Set fechaHabilActuacion = New NotesDateTime(fechaHabil.getElement(Pos))
  213. 'Ahora tengo la fecha habil de la actuación. Esta fecha representa la fecha en que debio haber sido
  214. 'enviado el pase para caducara el día de hoy.
  215. 'Lo que tengo que hacer ahora son comparaciones a fin de cuenta de calcular si hay alarma o no.
  216. 'La aritmetica es la comentaba al comienzo del codigo.
  217.  
  218. timeDifference = fechaHabilActuacion.Timedifference(fechaRecibido)
  219. If timeDifference >= 0 Then
  220.  
  221. 'La diferencia de la fecha habil del motivo de pase y la fecha de recibido es mayor a 0.
  222. 'Hay que saltar la alarma.
  223. MsgBox "Se metio alarma al expediente: " + docBandejaTrabajo.getitemvalue("clave")(0)
  224. Call docBandejaTrabajo.Replaceitemvalue(ALARMA, ALARMA_SI)
  225. Call docBandejaTrabajo.Save(True,False)
  226.  
  227. Call generarLog(dbLogAlarmas, dbRutas, docBandejaTrabajo, ultimaActuacion)
  228.  
  229. Else 'En este caso no hay que saltar la alarma, PERO LUEGO TENDRE QUE LOGEAR IGUAL.
  230.  
  231. MsgBox "Se nego alarma al expediente: " + docBandejaTrabajo.getitemvalue("clave")(0)
  232. Call docBandejaTrabajo.Replaceitemvalue(ALARMA, ALARMA_NO)
  233. Call docBandejaTrabajo.Save(True,False)
  234.  
  235. Call generarLog(dbLogAlarmas, dbRutas, docBandejaTrabajo, ultimaActuacion)
  236.  
  237. End If
  238.  
  239. End If
  240.  
  241. 'Seteamos Pos a -1 para volver a buscar.
  242. Pos = -1
  243.  
  244. End If
  245.  
  246. End If
  247. End If
  248.  
  249. End If
  250. actuacionYNroExpe = ""
  251. Set docBandejaTrabajo = viewBandejaTrabajo.Getnextdocument(docBandejaTrabajo)
  252.  
  253. Wend
  254.  
  255. Else
  256. 'Esto es cuando flag_Bandeja_Entrad = True.
  257. 'En este caso debo recorrer tanto la bandeja de trabajo como la bandeja de entrada.
  258. 'Tambien debo ver en la bandeja de entrada si el expediente tiene paquete. En ese caso debo omitirlo, no prestarle atención.
  259. 'Para todos los demas documentos, ya sea de la bandeja de entrada o bandeja de trabajo, debo comparar la fecha habil del motivo
  260. 'que tenga dicho documento, con la fecha de pase (fEntrada).
  261.  
  262. Dim docBandeja As NotesDocument
  263. Set docBandeja = viewBandejaTrabajo.Getfirstdocument()
  264.  
  265. Dim finalizoRecorridaBandejaTrabajo As Boolean
  266. finalizoRecorridaBandejaTrabajo = False
  267.  
  268. While Not docBandeja Is Nothing
  269. 'Si las siguientes condiciones son verdaderas, entonces hay que considerar hacer el respectivo chequeo.
  270. 'Si la cantidad de actuaciones es 1, el documento esta en generación.
  271. 'Si TIENE_PAQUETE <> "SI" o TIENE_PAQUETE = "SI" y ESTADO_INDICE <> "En Transito" o No tiene paquete.
  272. If docBandeja.Hasitem(CANTIDAD_ACTUACIONES) And docBandeja.Getitemvalue(CANTIDAD_ACTUACIONES)(0) <> 1 And ( (docBandeja.Hasitem(TIENE_PAQUETE) And UCase(docBandeja.Getitemvalue(TIENE_PAQUETE)(0)) <> "SI") Or (docBandeja.Hasitem(TIENE_PAQUETE) And UCase(docBandeja.Getitemvalue(TIENE_PAQUETE)(0)) = "SI" And docBandeja.Hasitem(ESTADO_INDICE) And UCase(docBandeja.Getitemvalue(ESTADO_INDICE)(0)) <> ESTADO_TRANSITO ) Or Not docBandeja.Hasitem(TIENE_PAQUETE) ) Then
  273.  
  274.  
  275. 'Tengo que ir hasta la ultima actuación del expediente correspondiente al indice seleccionado.
  276. 'Para eso hago uso de información ya existente en dicho indice, como la base, el nro expediente y la cantidad de actuaciones.
  277. Set dbGestion = session.Getdatabase("", docBandeja.Getitemvalue(BASE_GESTION_DE_INDICE)(0), False)
  278. 'Si la base gestion correspondiente al indice pudo obtenerse, hago lo siguiente.
  279. If Not dbGestion Is Nothing Then
  280.  
  281. Set viewActuacionesGestion = dbGestion.Getview(VISTA_ACTUACIONES_NRO_EXPE)
  282. actuacionYNroExpe = CStr(docBandeja.Getitemvalue(CANTIDAD_ACTUACIONES)(0)) + CStr(docBandeja.Getitemvalue(NUMERO_EXPEDIENTE_INDICE)(0))
  283. Set ultimaActuacion = viewActuacionesGestion.Getdocumentbykey(actuacionYNroExpe, True)
  284.  
  285. 'Si se pudo obtener de la ultima actuacion, debo agarrar el motivo de pase y la fecha de entrada
  286. If Not ultimaActuacion Is Nothing Then
  287.  
  288. 'Aqui discrimino si tiene paquete o no. Si tiene paquete debo considerar la fecha de recibido.
  289. 'Si no tiene paquete debo considerar la fecha de entrada.
  290. If docBandeja.Hasitem(TIENE_PAQUETE) And UCase(docBandeja.Getitemvalue(TIENE_PAQUETE)(0)) = "SI" Then
  291. Set fecha = New NotesDateTime(CStr(ultimaActuacion.Getitemvalue(FECHA_RECIBIDO)(0)))
  292. Else
  293. Set fecha = New NotesDateTime(CStr(ultimaActuacion.Getitemvalue(FECHA_ENTRADA)(0)))
  294. End If
  295.  
  296. motivoPaseUltimaActuacion = ultimaActuacion.Getitemvalue(MOTIVO_PASE)(0)
  297.  
  298. If motivoPaseUltimaActuacion <> "" Then
  299.  
  300. 'Si entro a esta condición significa se obtuvo un motivo de pase distinto de vacio
  301. isMemberVectorMotivos = motivosPase.isMember(motivoPaseUltimaActuacion, Pos, False)
  302. 'Luego del isMember en la variable Pos se guardo la posición en el vector de dicho motivo.
  303. 'Si Pos=-1, no se encontro. Si Pos>=1 se encontro.
  304.  
  305. MsgBox "Pos: " & Pos
  306. If Pos >= 1 Then
  307.  
  308. 'Esto significa que en mi vector que cargue anteriormente desde datos externos se encontro el motivo de
  309. 'pase que tiene la ultima actuación encontrada a partir del documento indice.
  310. 'Ahora sabiendo la posicion busco en el vector de fechas habiles y tendre la fecha con que comparar a la
  311. 'fecha de entrada.
  312.  
  313. Set fechaHabilActuacion = New NotesDateTime(fechaHabil.getElement(Pos))
  314. 'Ahora tengo la fecha habil de la actuación. Esta fecha representa la fecha en que debio haber sido
  315. 'enviado el pase para caducara el día de hoy.
  316. 'Lo que tengo que hacer ahora son comparaciones a fin de cuenta de calcular si hay alarma o no.
  317. 'La aritmetica es la comentaba al comienzo del codigo.
  318.  
  319. timeDifference = fechaHabilActuacion.Timedifference(fecha)
  320. If timeDifference >= 0 Then
  321.  
  322. 'La diferencia de la fecha habil del motivo de pase y la fecha de recibido o de pase es mayor a 0.
  323. 'Hay que saltar la alarma.
  324. MsgBox "Se metio alarma al expediente: " + docBandeja.getitemvalue("clave")(0)
  325. Call docBandeja.Replaceitemvalue(ALARMA, ALARMA_SI)
  326. Call docBandeja.Save(True,False)
  327.  
  328. Call generarLog(dbLogAlarmas, dbRutas, docBandeja, ultimaActuacion)
  329.  
  330. Else 'En este caso no hay que saltar la alarma, PERO LUEGO TENDRE QUE LOGEAR IGUAL.
  331.  
  332. MsgBox "Se nego alarma al expediente: " + docBandeja.getitemvalue("clave")(0)
  333. Call docBandeja.Replaceitemvalue(ALARMA, ALARMA_NO)
  334. Call docBandeja.Save(True,False)
  335.  
  336. Call generarLog(dbLogAlarmas, dbRutas, docBandeja, ultimaActuacion)
  337.  
  338. End If
  339.  
  340. End If
  341.  
  342. 'Seteamos Pos a -1 para volver a buscar.
  343. Pos = -1
  344.  
  345. End If
  346.  
  347. End If
  348. End If
  349.  
  350. End If
  351. actuacionYNroExpe = ""
  352.  
  353.  
  354. 'El siguiente codigo es para que una vez que termine de iterar en la bandeja de trabajo, empiece a iterar en la de entrada.
  355. If Not finalizoRecorridaBandejaTrabajo Then
  356. Set docBandeja = viewBandejaTrabajo.Getnextdocument(docBandeja)
  357. Else
  358. Set docBandeja = viewBandejaEntrada.Getnextdocument(docBandeja)
  359. End If
  360.  
  361. If docBandeja Is Nothing Then
  362.  
  363. If Not finalizoRecorridaBandejaTrabajo Then
  364. 'Si entra aca es por que termino la recorrida de la bandeja de trabajo y hay que setear la bandeja de entrada
  365. finalizoRecorridaBandejaTrabajo = True
  366. MsgBox "Fin de la bandeja de trabajo, comienzo de bandeja de entrada"
  367. Set docBandeja = viewBandejaEntrada.Getfirstdocument()
  368. End If
  369.  
  370. End If
  371.  
  372.  
  373. Wend
  374.  
  375. End If
  376.  
  377. End If
  378.  
  379.  
  380. Exit Sub
  381. ErrorActIndice:
  382. MsgBox "ERRROR: " + Error
  383. MsgBox "ERL: " & ERL
  384. Exit Sub
  385.  
  386. End Sub
  387.  
  388.  
  389. Function generarFechaHoy() As String
  390. Dim fileNameAnio, fileNameMes, fileNameDia As String
  391. fileNameAnio = Right(CStr(Year(Today)),2)
  392. fileNameMes = CStr(Month(Today))
  393. If Month(Today) < 10 Then fileNameMes = "0" & fileNameMes
  394. fileNameDia = CStr(Day(Today))
  395. If Day(Today) < 10 Then fileNameDia = "0" & fileNameDia
  396. generarFechaHoy = fileNameDia + "/" + fileNameMes + "/" + fileNameAnio
  397. End Function
  398. %REM
  399. Sub generarLog
  400. Description: Comments for Sub
  401. %END REM
  402. Sub generarLog(baseNotes As NotesDatabase, baseRutas As NotesDatabase, docIndice As NotesDocument, ultimaActuacion As NotesDocument)
  403. On Error GoTo errorGenerarLog
  404. If Not baseNotes Is Nothing Then
  405. Dim viewLog As NotesView
  406. Set viewLog = baseNotes.Getview(VISTA_ALARMA_LOG)
  407. Dim actuacionYNroExpe As String
  408. actuacionYNroExpe = Trim(CStr(docIndice.Getitemvalue(CANTIDAD_ACTUACIONES)(0)) + CStr(docIndice.Getitemvalue(NUMERO_EXPEDIENTE_INDICE)(0)))
  409.  
  410. Dim documentoLog As NotesDocument
  411. Set documentoLog =viewLog.Getdocumentbykey(actuacionYNroExpe, True)
  412.  
  413. If Not documentoLog Is Nothing Then
  414. 'Si en la vista se encuentra el log, debo modificar los valores pertinentes como AlarmaHasta
  415. If docIndice.Hasitem(ALARMA) And docIndice.Getitemvalue(ALARMA)(0) = ALARMA_SI Then
  416. Call documentoLog.Replaceitemvalue("HayAlarma", ALARMA_SI)
  417. Call documentoLog.Replaceitemvalue("AlarmaHasta", Today)
  418. End If
  419. Else
  420. 'Si no se encuentra en la vista, el documento log no existe y debo crear uno.
  421.  
  422. Set documentoLog = baseNotes.Createdocument()
  423. Call documentoLog.Replaceitemvalue("Form", "LogAlarmas")
  424. Call documentoLog.Replaceitemvalue("NumeroExpediente", docIndice.Getitemvalue(NUMERO_EXPEDIENTE_INDICE)(0))
  425. Call documentoLog.Replaceitemvalue("Actuacion", docIndice.Getitemvalue(CANTIDAD_ACTUACIONES)(0))
  426.  
  427. If ultimaActuacion.Hasitem(OFICINA_ACTUAL) Then
  428. Call documentoLog.Replaceitemvalue("Unidad", ultimaActuacion.Getitemvalue(OFICINA_ACTUAL)(0))
  429. End If
  430.  
  431. If docIndice.Hasitem(ALARMA) Then
  432. If docIndice.Getitemvalue(ALARMA)(0) = ALARMA_SI Then
  433. Call documentoLog.Replaceitemvalue("HayAlarma", ALARMA_SI)
  434. Call documentoLog.Replaceitemvalue("AlarmaDesde", Today)
  435. Call documentoLog.Replaceitemvalue("AlarmaHasta", Today)
  436. Else
  437. Call documentoLog.Replaceitemvalue("HayAlarma", ALARMA_NO)
  438. Call documentoLog.Replaceitemvalue("AlarmaDesde", "")
  439. Call documentoLog.Replaceitemvalue("AlarmaHasta", "")
  440. End If
  441. End If
  442.  
  443. If ultimaActuacion.Hasitem(FECHA_ENTRADA) Then
  444. Call documentoLog.Replaceitemvalue("FechaEntradaUnidad", ultimaActuacion.Getitemvalue(FECHA_ENTRADA)(0))
  445. End If
  446.  
  447. If ultimaActuacion.Hasitem(FECHA_RECIBIDO) Then
  448. Call documentoLog.Replaceitemvalue("FechaRecibidoUnidad", ultimaActuacion.Getitemvalue(FECHA_RECIBIDO)(0))
  449. End If
  450.  
  451. If docIndice.Hasitem(TEMA) Then
  452. Call documentoLog.Replaceitemvalue("Tema", docIndice.Getitemvalue(TEMA)(0))
  453.  
  454. 'Ahora sabiendo el tema debo buscar en una vista de temas por nombre y obtener su número de categoria.
  455. 'Sabiendo dicho número de categoría puedo obtener esta ultima.
  456. Dim viewTemasPorNombre As NotesView
  457. Dim viewCategoriasPorNumero As NotesView
  458. Dim docTema As NotesDocument
  459. Dim docCategoria As NotesDocument
  460. Set viewTemasPorNombre = baseRutas.Getview(VISTA_TEMAS_POR_NOMBRE)
  461. Set viewCategoriasPorNumero = baseRutas.Getview(VISTA_CATEGORIAS_POR_NUMERO)
  462.  
  463. Set docTema = viewTemasPorNombre.Getdocumentbykey(docIndice.Getitemvalue(TEMA)(0), True)
  464. MsgBox "cat: " + docTema.Getitemvalue("sCategoria")(0)
  465.  
  466. If Not docTema Is Nothing Then
  467. 'Si pude obtener el tema, dado el numero de categoria conseguire el nombre de la misma
  468. Set docCategoria = viewCategoriasPorNumero.Getdocumentbykey(docTema.Getitemvalue("sCategoria")(0), True)
  469. If Not docCategoria Is Nothing Then
  470. Call documentoLog.Replaceitemvalue("Categoria", docCategoria.Getitemvalue("sNombreCategoria")(0))
  471. Else
  472. Call documentoLog.Replaceitemvalue("Categoria", "NO TIENE")
  473. End If
  474. End If
  475. Else 'No tiene tema, y por consiguiente, tampoco categoria
  476. Call documentoLog.Replaceitemvalue("Tema", "NO TIENE")
  477. Call documentoLog.ReplaceItemValue("Categoria", "NO TIENE")
  478. End If
  479.  
  480. If ultimaActuacion.Hasitem(MOTIVO_PASE) Then
  481. Call documentoLog.Replaceitemvalue("MotivoDePase", ultimaActuacion.Getitemvalue(MOTIVO_PASE)(0))
  482. Else
  483. Call documentoLog.Replaceitemvalue("MotivoDePase", "NO TIENE O ERROR")
  484. End If
  485.  
  486. If docIndice.Hasitem("ccEstado") And UCase(docIndice.Getitemvalue("ccEstado")(0)) <> ESTADO_TRANSITO Then
  487. Call documentoLog.Replaceitemvalue("Bandeja", "Trabajo")
  488. Else
  489. Call documentoLog.Replaceitemvalue("Bandeja", "Entrada")
  490. End If
  491.  
  492. End If
  493. MsgBox "JIJJI"
  494. Call documentoLog.Save(True,False)
  495. Else
  496. 'ERROR
  497. End If
  498.  
  499. Exit sub
  500. errorGenerarLog:
  501. MsgBox "Error: " + Error
  502. MsgBox "Error en la linea : " & erl
  503. Exit sub
  504. End Sub
  505. %REM
  506. Function obtenerFechaHabil
  507. Description: Dado una cantidad de dias pasada como parametro, devuelve la fecha habil.
  508. %END REM
  509. Function obtenerFechaHabil(CantidadDias As String) As String
  510. On Error GoTo errorObtenerFecha
  511.  
  512. Dim SQL As String
  513. Dim count As Long
  514. Dim fldLst As New LCFieldList
  515. Dim cantidadResultado As Integer
  516. Dim fechaHabil As LCfield
  517. Dim connect As New LCConnection (ORACLE)
  518.  
  519. connect.server = ORACLE_SERVER
  520. connect.Userid = ORACLE_USER
  521. connect.Password = ORACLE_PASSWORD
  522. connect.Connect
  523.  
  524. If Not connect.IsConnected Then
  525. RegistrarYGenerarError NOMBRE_APLICACION,"Agente ActualizarIndicesMotivoPase - obtenerFechaHabil - No se conecto a SQL",""
  526. Exit Function
  527. End If
  528.  
  529. SQL = "Select F_RESTAR_HABILES(TO_DATE(" + "'" + generarFechaHoy() +"'" + ",'dd/mm/yy')," + CantidadDias +") from DUAL"
  530. 'MsgBox "SQL: " + SQL
  531. count=connect.Execute (SQL, fldLst)
  532. cantidadResultado = connect.Fetch(fldLst)
  533.  
  534. 'Obtengo el dia habil
  535. obtenerFechaHabil = CDat(fldLst.Getfield(1).Value(0))
  536. Exit Function
  537. errorObtenerFecha:
  538. MsgBox "Error en funcion ObtenerFechaHabil - Agente ActualizarIndicesMotivoPase en linea " & erl
  539. Exit Function
  540. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement