• 15 апреля стартует «Курс «SQL-injection Master» ©» от команды The Codeby

    За 3 месяца вы пройдете путь от начальных навыков работы с SQL-запросами к базам данных до продвинутых техник. Научитесь находить уязвимости связанные с базами данных, и внедрять произвольный SQL-код в уязвимые приложения.

    На последнюю неделю приходится экзамен, где нужно будет показать свои навыки, взломав ряд уязвимых учебных сайтов, и добыть флаги. Успешно сдавшие экзамен получат сертификат.

    Запись на курс до 25 апреля. Получить промодоступ ...

Одинаковые поля в документе

victorhalf

Green Team
29.05.2007
79
3
BIT
0
Всем день добрый !
Возникла у меня идея просмотреть поля в документе(письмо во входящих) в более человеческом виде: типа на отдельной формочке, посортированое, короче красиво чтобы всё было и симпатишно.
Список полей беру
Set doc=uidoc.Document
Forall i In doc.Items
fldName= i.Name
fldValue=i.Text
End Forall
проблема возникает когда попадаются поля с одинаковым названием.
Например- есть в письмах такое поле Received, оно повторяется несколько раз и всегда разное. А в списке Doc.Items почемуто храниться первое попавшееся его значение.
Кто нибудь знает как вытянуть правильные значения этого поля?
Как то ж это лотус делает если посмотреть в свойствах документа- в списке полей

Спасибо
 
S

Sandr

потому что некоторые значения в некоторые поля у вас добавлялись через AppendItemValue, а вы пытаетесь достать значения через i.Text...

сделайте так:
Код:
dim val as string
Set doc=uidoc.Document
Forall i In doc.Items
fldName= i.Name 
val=""
forall v in i.values
val = val & cSTR(v) & "; "
end forall
fldValue = val 

End Forall
 
R

Ronchik

<!--QuoteBegin-Sandr+1:11:2007, 18:27 -->
<span class="vbquote">(Sandr @ 1:11:2007, 18:27 )</span><!--QuoteEBegin-->val=""
forall v in i.values
val = val & cSTR(v) & "; "
end forall
fldValue = val
[snapback]83985" rel="nofollow" target="_blank[/snapback]​
[/quote]
мона заменить на более простое
Код:
fldValue = implode (i.values , "; ")
 

victorhalf

Green Team
29.05.2007
79
3
BIT
0
Sandr,Ronchik спасибо за ответы, но проблема осталась.
Причем смотрю в отладчике: в UIDoc-Document-Items три поля Received и у всех одинаковые значения в Values. Или это ничего не значит?
Если смотреть через свойства документа, то у этих полей ест флаг Dup Item Id.И вот он то разный.
Может можно как то через них выбрать конкретноезначение.
 
S

Sandr

Еще раз скажу, что это потому что некоторые значения в некоторые поля у вас добавлялись через AppendItemValue. Итем один, но много значений, а этот глючной метод делает так, что в свойствах документа кажется, что таких итемов много...ничего тут страшного нет...
 

victorhalf

Green Team
29.05.2007
79
3
BIT
0
Да страшного то ничего, но результат нулевой.
На выходе получаю три отдельных поля с одинаковым названием и значением. И усё. Выше UiDoc.Document не прыгнешь, а там они одинаковые.
Вобщем спасибо, пойду думать дальше.
 
S

Sandr

Так, а собственно, задача какая? Может как-то по-другому можно...

ЗЫ: И значения одинаковые? Посмотрите, как эти значения туда пишутся.. переделывать именно это скорее всего прийдется...
 

victorhalf

Green Team
29.05.2007
79
3
BIT
0
<!--QuoteBegin-Sandr+2:11:2007, 13:14 -->
<span class="vbquote">(Sandr @ 2:11:2007, 13:14 )</span><!--QuoteEBegin-->Так, а собственно, задача какая? Может как-то по-другому можно...[/quote]
Задача- получить значения всех(ну или почти всех) полей из документа. Документ -входящие письма. Заполняю, как вы понимаете, их не я. В поле Received содержится путь письма и заполняется он скорее всего еще до лотуса. Поэтому чтото гдето изменить я не могу.
Гдето проскакивала идея копировать письмо без записи на диск и постепеннно удалять поля. Но сам пока не пробовал.
 
S

Sandr

В таком случае, приведеный выше код работать должен... итем там один.. значений у него просто много... перебирайте значения...
 

victorhalf

Green Team
29.05.2007
79
3
BIT
0
<!--QuoteBegin-Sandr+2:11:2007, 15:52 -->
<span class="vbquote">(Sandr @ 2:11:2007, 15:52 )</span><!--QuoteEBegin-->В таком случае, приведеный выше код работать должен... итем там один.. значений у него просто много... перебирайте значения...[/quote]
Не, работать оно не должно. Оказывается в ИБМе это известный глюк, вот нашел у них на сайте, может кому пригодиться
<!--QuoteBegin- How to get a handle to individual entries contained within multiple item entries Technote (FAQ) +-->
<span class="vbquote">( How to get a handle to individual entries contained within multiple item entries Technote (FAQ) )</span><!--QuoteEBegin-->Problem
You have a Notes document that contains two or more items of the same name and that each contain different values. You would like to be able to display each of these item values as individual entries in a view.

Duplicate document items are most commonly seen in mail documents that originate from the Web. When e-mails from the Web reach their destination in a Notes mail file, they often have several "Received" items that have been created at each hop of the e-mails transmission. The only thing that distinguishes these items is a "Dup Item ID". These duplicate IDs are sequential and are assigned each time another instance of the item is created.

Solution
There is currently no @Formula or direct functionality to separate and view data from duplicated items. However, the following LotusScript agents can be used or modified as a workaround:

Note: The following scripts were written for testing and are set to act on only the first document in a view. Additional modifications would have to be made to each of these scripts depending on your environment and what you want to accomplish. Notes Support is not available to further customize these examples.


The following sample script runs through each "Received" item, copies the value to a new unique field and then removes the original item. This script would be used if the user wants to display each of these new fields in separate columns of a view. In order to access each item, this script has to permanently remove all original "Received" items.

Sub Initialize

Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim OldRcvd As NotesItem
Dim NewRcvd As NotesItem

Set db = session.currentdatabase
Set view = db.GetView("TempView")
Set doc = view.GetFirstDocument
Set OldRcvd = doc.getfirstitem("Received")
Dim x As Integer
x = 0
Do Until OldRcvd Is Nothing
x = x + 1
Set NewRcvd = doc.CopyItem(OldRcvd,"Received_" + Cstr(x))
NewRcvd.IsSummary = True
Call OldRcvd.Remove
Set OldRcvd = doc.getfirstitem("Received")
Loop
Call doc.save(True,True)

End Sub


The second sample script does essentially the same as the first, except that it puts all the original "Received" values into one field (TmpReceived) as separate values. This script would be used if the user wants to display each of the values in the same column of a view by using Column Property "Show Multiple values as separate entries". In order to access each item, this script has to permanently remove all original "Received" items.

Sub Initialize

Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim OldRcvd As NotesItem
Dim NewRcvd As NotesItem
Redim TmpArray(0 To 50) As String

Set db = session.currentdatabase
Set view = db.GetView("TempView")
Set doc = view.GetFirstDocument
Set OldRcvd = doc.getfirstitem("Received")
Dim x As Integer
x = 0
Do Until OldRcvd Is Nothing
TmpArray(x) = OldRcvd.values(0)
Call OldRcvd.Remove
Set OldRcvd = doc.getfirstitem("Received")
x = x + 1
Loop
Redim Preserve TmpArray(0 To x-1) As String
Set NewRcvd = doc.ReplaceItemValue("TmpReceived", TmpArray)
NewRcvd.IsSummary = True
Call doc.save(True,True)

End Sub


The following example demonstrates how you can place the values back into a multi-item field. Use the example below if you want revise the Received data so that it only contains the last 5 entries or the first 5 entries (for example). You can accomplish this using the AppendItemValue method (of the NotesDocument class) which creates a second item when applied to a item that already exists.

The following code example relies on the code from the first example, and is placed between the Loop call and the Save call:
For i=1 To x
If i<=5 Then 'Use this line if you wanted to preserve only the first 5 items
If i>(x-5) Then 'Use this line if you wanted to preserve only the last 5 items
Set newrcvd=doc.getfirstitem("Received_"+Cstr(i))
If Rcvd Is Nothing Then
Set Rcvd =doc.CopyItem(NewRcvd, "Received")
Rcvd.IsSummary = True
Else
Call doc.appenditemvalue("Received", newrcvd)
End If
End If
Call doc.removeitem("Received_"+Cstr(i))
Next
Call doc.save(True,True)[/quote]
 
Мы в соцсетях:

Обучение наступательной кибербезопасности в игровой форме. Начать игру!