sexta-feira, 18 de julho de 2014

Rotina para retornar o diretório temporário do sistema operacional

UseLSX "*javacon"

Function getTempDirectory() As String
   
    On Error GoTo trataerro
   
    Dim t_sesJava As New JavaSession
    Dim t_clsFile As JavaClass
    Set t_clsFile = t_sesJava.GetClass("java/io/File")
    Dim t_mthCreateTemp As JavaMethod
    Set t_mthCreateTemp = t_clsFile.GetMethod("createTempFile", "(Ljava/lang/String;Ljava/lang/String;)Ljava/io/File;")
    Dim t_hflFile As JavaObject
   
    Set t_hflFile = t_mthCreateTemp.Invoke(, "tdoc_dir", ".tmp")
   
    Dim strParent As String
   
    strParent = strLeftBack(t_hflFile.getPath(),"\")
   
 
    If InStr(strParent, "/") <> 0 And Right(strParent, 1) <> "/" Then strParent = strParent & "/"
    If InStr(strParent, "\") <> 0 And Right(strParent, 1) <> "\" Then strParent = strParent & "\"
   
    getTempDirectory = strParent
   
   
    Exit Function
trataerro:
    Call AddToStackTrace()
End Function

quinta-feira, 10 de julho de 2014

Remover hide-when de documentos com campo richtext utilizando xsl

Option Public
Option Declare

Const CONST_XSL = {

   

   
   
       
           
       

   

   
   
   

 
}
Sub Initialize
    On Error GoTo ErrorHandler
   
    Dim S As New NotesSession
    Dim t_dbThis As NotesDatabase
    Set t_dbThis = S.Currentdatabase
   
    Dim t_nstXSLT As NotesStream
    Set t_nstXSLT = S.CreateStream()
    'Call t_nstXSLT.Open("c:\dados\removehiderichtext.xsl", "UTF-8")
   
    Call t_nstXSLT.Writetext(CONST_XSL)
    t_nstXSLT.Position = 0
   
    Dim t_ndeSource As NotesDXLExporter
    Set t_ndeSource = S.Createdxlexporter()
    Dim t_nclSource As NotesNoteCollection
    Set t_nclSource = t_dbThis.Createnotecollection(false)
    t_nclSource.Selectdocuments = True
    '// REALIZEI UM FILTRO PARA OS DOCUMENTOS COM O FORMULÁRIO QUE DESEJO ALTERAR
    t_nclSource.Selectionformula = |@Contains(@LowerCase(Form);"fo_docrichtext")|
    Call t_nclSource.BuildCollection()
    Call t_ndeSource.setInput(t_nclSource)
   
    Dim t_ndiDest As NotesDXLImporter
    Set t_ndiDest = S.Createdxlimporter()
    Call t_ndiDest.setOutput(t_dbThis)

    t_ndiDest.Documentimportoption= DXLIMPORTOPTION_REPLACE_ELSE_IGNORE
   
    Dim t_xslTransformer As NotesXSLTransformer
    Set t_xslTransformer = S.Createxsltransformer()
    Call t_xslTransformer.SetStyleSheet(t_nstXSLT)
   
    Call t_ndeSource.Setoutput(t_xslTransformer)
    Call t_ndiDest.Setinput(t_xslTransformer)
   
    Call t_ndeSource.Process()   

    Exit Sub
ErrorHandler:
    Dim t_strError As String
    t_strError = Error & ": " & Err()
    MsgBox t_strError
   
    If Not t_ndeSource Is Nothing Then
        Dim t_nosError As NotesStream
        Set t_nosError = S.Createstream()
        Call t_nosError.open("C:\dados\Error.xml", "UTF-8")
        Call t_nosError.Writetext(t_ndeSource.Log)
        Call t_nosError.Close()
    End If
    Exit sub
End Sub

quarta-feira, 9 de julho de 2014

Exporta documento para dxl, redefine a margem do campo richtext , removendo alguns valores para impressão

Option Declare
Use "OpenLogFunctions"

Sub Initialize

On Error GoTo trataerro

Dim sesSessao As New NotesSession
Dim bdCorr As NotesDatabase
Set bdCorr=sesSessao.CurrentDatabase

Dim dc As NotesDocumentCollection
Set dc=bdCorr.UnprocessedDocuments

Dim cont As Integer
cont=dc.Count

If cont=1 Then

Dim docAssis As NotesDocument
Set docAssis=dc.GetFirstDocument

Dim dxExporter As NotesDXLExporter
Dim dxImporter As NotesDXLImporter
Set dxExporter = sesSessao.Createdxlexporter
Set dxImporter = sesSessao.Createdxlimporter

Call dxExporter.setInput(docAssis)

Call dxImporter.setoutput(bdCorr)
dxImporter.Designimportoption = DXLIMPORTOPTION_CREATE
dxImporter.Documentimportoption = DXLIMPORTOPTION_CREATE

Dim t_xslTransformer As NotesXSLTransformer
Set t_xslTransformer = sesSessao.Createxsltransformer()
Dim t_istXSLT As NotesStream
Set t_istXSLT = sesSessao.Createstream()

Dim strStyleXML As String
strStyleXML = {








S






6.8743in
















fo_cadAssisImp







}

Call t_istXSLT.Writetext(strStyleXML)
Call t_xslTransformer.Setstylesheet(t_istXSLT)

Call dxExporter.Setoutput(t_xslTransformer)
Call dxImporter.Setinput(t_xslTransformer)

Call dxExporter.Process()

Dim strNoteID As String
strNoteID = dxImporter.Getfirstimportednoteid()

Dim docAssisImp As NotesDocument
Set docAssisImp = bdCorr.Getdocumentbyid(strNoteID)

If docAssisImp Is Nothing Then
MsgBox "O sistema não conseguiu processar a impressão. Por favor, contate um administrador do sistema."
Exit Sub
End If

Call sesSessao.SetEnvironmentVar("ASSISTECEXPORTACAO", "I")

Dim ws As New NotesUIWorkspace
Call ws.DialogBox("fo_cadAssisImp", False, False, True, True, True, True, "Impressão de Assistência Técnica", docAssisImp, False, True, True)

Exit Sub
End If
Msgbox "Você deve selecionar um documento para impressão!"
Exit Sub
trataerro:
Call LogError()
Exit Sub
End Sub