V
Vagor.ini
Тема для постинга мелких вопросов - ответов для разрботчиков приложений и баз Lotus Notes. Если Ваш вопрос влечет долгое обсуждение, то желательно создать отдельную тему.
Познакомьтесь с пентестом веб-приложений на практике в нашем новом бесплатном курсе
@Command([FileCloseWindow])
FIELD SaveOptions:="0";
@Command([FileCloseWindow])
Знаем, юзалиКстати, для справки: после присвоения SaveOptions:=0 не сохранит даже принудительный [FileSave]
Sub Click(Source As Button)
Dim WS As notesuiworkspace
Dim UiView As notesuiview
Dim ViewString As String
Dim session As NotesSession
Dim db As NotesDatabase
Dim v As NotesView
Dim docX As NotesDocument
Dim col As Integer
Dim row As Double
Dim xl As Variant
Dim xlWbk As Variant
Dim pagename As String
Set WS = New notesuiworkspace
Set session = New notessession
Set db=session.CurrentDatabase
Print "Please Be Patient as the Excel Spreadsheet is being created..."
' Get dynamic view name, R5 only
' Take this part out if using in R4, you have to hard-code the name of the view in ViewString
Set UiView=WS.currentview
ViewString=UiView.viewname
Set v=db.GetView(ViewString)
' Create Excel Sheet
Set xl=CreateObject("Excel.Application")
Set xlWbk=xl.Workbooks.Add
' Add column headings to first row
col=1
Forall vColumn In v.Columns
xlWbk.ActiveSheet.Cells(1, col)=vColumn.Title
col=col+1
End Forall
' Add row data from the documents
row=2
Set docX=v.GetFirstDocument
While Not docX Is Nothing
col=1
Forall cValue In docX.ColumnValues
xlWbk.ActiveSheet.Cells(row, col)=cValue
col=col+1
End Forall
row=row+1
Set docX=v.GetNextDocument(docX)
Wend
' Make all columns fit
xlWbk.ActiveSheet.Columns.AutoFit
Print "Excel Document Successfully Created!"
' Open it up in Excel
xl.Visible=True
End Sub
Option Declare
Sub Initialize
%REM
DESCRIPTION:
This agent loop through documents listed in ViewDelete and marks documents that duplicates column
values of another doc. If set it also deletes duplicates docs found in that view.
NOTES:
Design of ViewDelete:
- View should consist of at least one sorted column. To check if documents duplicate more then
one value, the appropriate number of sorted columns should be added.
- The last column in view should be UNSORTED, and got formula which names the field marking
duplicates (It's the best if there are no values displayed in the last column). Example
formula: MARK_DUPLICATES
Customizing agent:
- set nameViewDelete apropriate if you want to use your own name of view
- markOnly - set true if you want agent only to set field marking duplicates, not to
delete duplicates phisically; set false if you want to delete duplicates phisically
- doCheckMarkTags - set true if you want to preserve field names clash (agent stops if it finds
documents that already got field with name the same as field marking duplicates; set false to
delete all documents which have fields named as field marking duplicates with value valueTagItem
- set valueTagItem if you wants to mark duplicates with another value
HISTORY:
2001-09-05, T.Zoltowski, created
%END REM
'name of search view
Const nameViewDelete = "ViewDelete"
'hard delete or just marking
Const markOnly = False
'do check if there is already a field marking duplicates on doc
Const doCheckMarkTags = True
'value marking duplicates
Const valueTagItem = "1"
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim viewDelete As NotesView
Set viewDelete = db.GetView(nameViewDelete)
If viewDelete Is Nothing Then
Print |View "| & nameViewDelete & |" not found !? Exiting.|
Exit Sub
End If
Dim numberColumns As Integer
numberColumns = Ubound(viewDelete.Columns) + 1
'check if there is apropriate number of columns
If numberColumns < 2 Then
Print |There should be at least 2 columns in view "| & nameViewDelete & |" ! Exiting.|
Exit Sub
End If
Dim columnIndex As Integer
'check if apropriate columns are sorted (it's a MUST to correctly find duplicates)
For columnIndex = 0 To numberColumns - 2
If Not viewDelete.Columns(columnIndex).IsSorted Then
Print |Column | & (columnIndex + 1) & | in view "| & nameViewDelete & |" isn't sorted (it should be!) ! Exiting.|
Exit Sub
End If
Next
'check if last column is unsorted (don't want to resort docs in view at any chance)
If viewDelete.Columns(columnIndex).IsSorted Then
Print |Last column in view "| & nameViewDelete & |" is sorted (it shouldn't be!)! Exiting.|
Exit Sub
End If
Dim nameTagItem As String
'taking the name of field marking duplicates
nameTagItem = viewDelete.Columns(columnIndex).ItemName
'actual doc
Dim doc As NotesDocument
'doc preceding actual doc in view
Dim docPrev As NotesDocument
Set doc = viewDelete.GetFirstDocument
'are there any docs ?
If doc Is Nothing Then Exit Sub
'do any checks
If checkMarkTags(doc, nameTagItem, doCheckMarkTags) Then
Print |Doc has item "| & nameTagItem & |" - there could be marking clash (try another name)! Exiting.|
Exit Sub
End If
Set docPrev = doc
Set doc = viewDelete.GetNextDocument(doc)
If checkMarkTags(doc, nameTagItem, doCheckMarkTags) Then
Print |Doc has item "| & nameTagItem & |" - there could be marking clash (try another name)! Exiting.|
Exit Sub
End If
Dim countProcessed As Long
countProcessed = 1
Dim countDuplicates As Long
countDuplicates = 0
Do Until doc Is Nothing
If checkMarkTags(doc, nameTagItem, doCheckMarkTags) Then
Print |Doc has item "| & nameTagItem & |" - there could be marking clash (try another name)! Exiting.|
Exit Sub
End If
Dim isDuplicate As Variant
'we assume that actual doc is "identical" as previous
isDuplicate = True
For columnIndex = 0 To numberColumns - 2
If docPrev.ColumnValues(columnIndex) <> doc.ColumnValues(columnIndex) Then
'there is a difference in column values - it's not a duplicate
isDuplicate = False
Exit For
End If
Next
If isDuplicate Then
'mark duplicate
Call doc.ReplaceItemValue(nameTagItem, valueTagItem)
Call doc.Save(True, True)
countDuplicates = countDuplicates + 1
End If
countProcessed = countProcessed + 1
Print "Processed " & countProcessed & ", duplicates " & countDuplicates
'move to actual doc to next doc (move previous doc too)
Set docPrev = doc
Set doc = viewDelete.GetNextDocument(doc)
Loop
If countDuplicates > 0 Then
'we found some duplicates
If markOnly Then
'only mark - already done
Print "Finished processing document: " & countDuplicates & _
| found. Delete all docs with field "| & nameTagItem & |" set to "| & valueTagItem & |" manually.|
Else
'do hard delete
Print "Deleting duplicates"
'reference to doc being deleted (temporary)
Dim docRemove As NotesDocument
'we are moving upright starting at last doc - it preserves before sliding docs in view after
'deleting docs and refreshing index
Set doc = viewDelete.GetLastDocument
Dim countDeleted As Long
countDeleted = 0
Do Until doc Is Nothing
'reset reference to deleted doc
Set docRemove = Nothing
If doc.HasItem(nameTagItem) Then
If doc.GetItemValue(nameTagItem)(0) = valueTagItem Then
'if it's doc marked to removing
Set docRemove = doc
End If
End If
Set doc = viewDelete.GetPrevDocument(doc)
If Not docRemove Is Nothing Then
'if there is doc to delete
Call docRemove.Remove(True)
countDeleted = countDeleted + 1
Print "Deleted " & countDeleted & " of " & countDuplicates
End If
Loop
End If
End If
End Sub
Function checkMarkTags(doc As NotesDocument, itemName As String, doCheck As Variant) As Variant
If doCheck Then
If doc.HasItem(itemName) Then
checkMarkTags = True
Exit Function
End If
End If
checkMarkTags = False
End Function
Может кто сталкивался с подобным вопросом, подскажите пути решения.
Есть вид (view), в котором ряд колонок имеют total'ы, т.е. подбиты суммы и все это собрано в категорию и при свертке строк олучается около 100 шт. Нужно из другой базы получить total'ы категорий программно, допустим по запросу ключевой колонки (первой категоризированной в виде).
Спасибо!
Данные из категоризированного первого столбца видаЧТО БУДЕТ ЯВЛЯТЬСЯ КЛЮЧЕМ ДЛЯ ДАННЫХ
Sub Initialize
Dim session As NotesSession
Dim db As NotesDataBase
Dim doc As NotesDocument
Set session = New NotesSession
Set w = New NotesUIWorkspace
' Для текущей базы
Set db = session.CurrentDatabase
Set doc = w.CurrentDocument
' Для базы РВП
Set dbRVP = New NotesDatabase("mpovtsrv/mpovt/by","BASEMPOVT\RVP.nsf")
Set viewRVP = dbRVP.GetView("ExcelAllRVP")
Set docRVP = viewRVP.GetFirstDocument
Dim DSE As String
Dim TPrice As Double
Do While Not (docRVP Is Nothing)
DSE = docRVP.TAISRVPform(0)
Do While (docRVP.TAISRVPform(0)=DSE)
TPrice = TPrice + Cdbl(docRVP.Field15RVPform(0))
Set docRVP = viewRVP.GetNextDocument(docRVP)
If (docRVP Is Nothing) Then
Exit Do
End If
Loop
Set doc = New NotesDocument(db)
doc.Form = "RVPProductForm"
doc.DCE_RVP = DSE
doc.Price_RVP = TPrice
Call doc.Save(True,False)
TPrice=0
Loop
End Sub
Колекциями я то знаю и это делаю, я имел ввиду вопрос можно ли программно получить доступ к тоталам, не персчитываю что-то отдельно. Работаю на 5 domino.
Ну в принципе я написал, работает, просто по ключу считаю (без всяких тоталов)
Естественно, подождет, найдешь пиши. Не болейПРОГРАММНО К ТОТАЛАМ МОЖНО ЕСЛИ ДО ЗАВТРА ТЕРПИТ ТО НАЙДУ ГДЕТО ПОПАДАЛОСЬ.
Естественно, подождет, найдешь пиши. Не болей
Обучение наступательной кибербезопасности в игровой форме. Начать игру!