In lotus I have a view with order documents.
I am building an agent to search for all orders which are modified in the last 25 minutes.
For this I have done code like:
strFormule = "Form=""Order"" & #Modified >= #Adjust(#Today;0;0;0;0;-25;0) & Deleted !=""J"""
Set ndcOrder = currentDB.Search( strFormule, Nothing, 0 )
If ndcOrder.Count <> 0 Then
Set doc = ndcOrder.GetFirstDocument
While Not doc Is Nothing
So if it is 11.00 then it need to take orders which are modified today from 10.35
But in the debugger I also get orders which where modified 2 hours earlier.
How is this possible?
I think it's might be because you're using #today which doesn't have a time element. Try #Now instead ?
In the past I used the LotusScript method GetModifiedDocuments which lets you specify a NotesDateTime object to retrieve any document modified since.
Your code could then look like this:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As notesdocumentcollection
Dim since As New NotesDateTime("")
Set db = session.CurrentDatabase
Call since.SetNow()
Call since.AdjustMinute(-25)
Set dc = db.GetModifiedDocuments(since)
My experience with this method was very good so far. More info on GetModifiedDocuments
Why use formula at all?
I would create a hidden view, first column is last modified date-time, sorted descending.
Then I would write my Lotusscript code to start at the top and work its way down until it encounters a date/time value that is older than 25 minutes ago.
Something like this:
Dim docs List As NotesDocument
Set dt25 = New NotesDateEntry(Now())
Call dt25.AdjustMinutes(-25)
Dim col as NotesViewEntryCollection
Dim entry as NotesViewEntry
Set col = view.AllEntries
Set entry = col.GetFirstEntry
Do Until entry Is Nothing
If Cdat(entry.ColumnValues(0))<Cdat(dt25.LSLocalTime) Then
Exit Loop
End If
Set docs(entry.Document.UniversalID) = entry.Document
Loop
' Now you have a list of documents created in the last 25 minutes.
Related
When I open a T-Code from SAP GUI, some of the fields are pre-populated from past queries. Is it possible to enter a T-Code and all the fields in the next window to be forced blank?
I develop scripts for SAP GUI and run into problems if fields already have content from prior queries.
The history cannot be disabled user-wise. Period.
Either all or nobody.
If you want to disable the history go to SAPgui options into Local data setting
The history in Windows is a simple Access MDB file but it is password-protected, so you may try to crack it and delete only your user lines but it is a bunch of work.
However, I guess the history that makes you crazy is not what I described above, but SPA/GPA parameters. Check it first
You can empty some fields with :
""
session.findById("wnd[1]/usr/ctxtRMMG1_REF-BWTAR").Text = ""
But doesn't work all the time...
My method for this is to loop through all the fields (and recursively on all children elements) and set the text value of them to an empty string.
On read-only fields it throws an error and this is why "On Error Resume Next" is necessary.
Sub Start_Clearing()
'setup SAP
If Not IsObject(SAPApplication) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set SAPApplication = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = SAPApplication.Children(0)
End If
If Not IsObject(Session) Then
Set Session = Connection.Children(0)
End If
If IsObject(WScript) Then
WScript.ConnectObject Session, "on"
WScript.ConnectObject SAPApplication, "on"
End If
Dim UserArea As Object
Set UserArea = Session.findByID("wnd[0]/usr")
Clear_Fields UserArea
End Sub
'_______________________________
Sub Clear_Fields(Area As Object)
Set SAPApplication = GetObject("SAPGUI").GetScriptingEngine
Dim Obj As Object
Dim NextArea As Object
On Error Resume Next
For i = 0 To Area.Children.Count - 1
Set Obj = Area.Children(CInt(i))
If Obj.ContainerType = True Then
If Obj.Children.Count > 0 Then
Set NextArea = SAPApplication.findByID(Obj.ID)
Clear_Fields NextArea
End If
End If
Obj.Text = ""
Next i
End Sub
I am writing a web form that has a unique travelID per travel request. (see blank column in picture below, I'm not high enough reputation to embed the picture in here)
Some of the travel requests have attached documents and others do not. I wrote this code:
Dim dirs As String() = Directory.GetFiles("E:\DomainWebs\Intranet\fileups\TravelDocs\")
Dim i As Integer = 0
For Each GridRecord As GridRecord In TravelWebDataGrid.Rows
For Each doc As String In dirs
If doc.Contains(TravelWebDataGrid.Rows(i).Items(10).Value) = True Then
TravelWebDataGrid.Rows(i).Items(11).Value = True
End If
Next
i += 1
Next
Just for testing, only the top Travel Request has documents attached. As you can see, it is checking the second row checkbox as well even though it doesn't have any documents attached.
This is what is being compared to row 2:
"DocName" - E:\DomainWebs\Intranet\fileups\TravelDocs\RONNIEP20180124141116-Hello.docx
"TravelID" - RONNIEP20180124135357
Does anyone know why it is doing this? Let me know if you need any more information. Thanks in advance for your responses.
This might be off because I haven't worked with a datagrid but it looks like the code has been over-complicated with the counter. Can you do this?
' you're looping gridrecords/rows.
For Each GridRecord As GridRecord In TravelWebDataGrid.Rows
For Each doc As String In dirs
' use the gridrecord here, not rows(i).
If doc.Contains(GridRecord.Items(10).Value) = True Then
' and here.
GridRecord.Items(11).Value = True
End If
Next
Next
I'm working on a web service using asp.net.
I'm creating a timetable display board like you see in airports, bus stations or train stations.
I am in charge of creating the services for 1 station, and there are other people in charge of the other stations.
I have created my web services and now im trying to consume the others.
I can consume them but everyone else has got their web services returning different values, for example, I'm returning route id, journey id, start location, end location, stops, days running, times. but other peoples web services may return data like route id, start, end, stops, times, platform, journey status. in one table, and the other data that matches up with mine in another web service.
So how do i filter out the data that i do not need, like platform and journey status in the example.
Also, how would I merge everyone's data from web services into 1 grid view so i can display all the trains that pass through my station.
I'm quite new to web services, but I am trying and I have got quite a bit done by myself, im just stuck on this bit.
I hope this isn't a stupid question
Dim allStations As New List(Of ScheduleEntry)
Dim ws1 As New Hull.ArrivaServices()
For Each u1 As Hull.Result In ws1.ShowRouteByStation("hrw")
Dim s As New ScheduleEntry
s.StartTime = u1.Departure
s.StopTime = u1.Arrival
allStations.Add(s)
Next
Dim ws2 As New Heathrow.Heathrow_Airport()
For Each u2 As Heathrow.Result In ws2.GetHeathrowTrains
Dim s As New ScheduleEntry
s.StartTime = u2.BeginTime
s.StopTime = u2.EndTime
allStations.Add(s)
Next
GridView1.DataSource = allStations
GridView1.DataBind()
I converted the datasets to datatables to make it compatable with each other.
DatatableA.Merge(DatatableB)
So now DatatableA also Contains all the DatatableB collumns and rows.
If the column names are the same and the data type is the same, the 2 columns become 1.
So I made sure the data types were the same, if they werent I converted them, then renamed the column name in DatatableB to the column name in DatatableA.
DatatableA.Columns(columnnumber).ColumnName = "NewName"
Remember when counting the columnnumber, its left to right and the first column is 0
If I had to convert the datatype, I made a new column in DatatableB (Same name as corrisponding collumn in DatatableA)
DatatableB.Columns.Add("NewColumnName", GetType(DataType))
Then I created a loop to go through the datatable rows of the collumn with the data I want to convert
Dim i as integer
Dim z as integer
i = 0
z = DatatableB.Rows.Count`
and putting the new converted data in the NewColumn by using
Do until i = z
DatatableB.Rows(i)("ColumnName") = "ConvertedData)
Next
Hope this helps someone
Your problem isn't what we normally call sorting and merging, not really. The largest problem is that you have a number of services which all return similar data formats, but not identical. So your first step will be to make them identical: within your program.
First, decide what you want to display in your grid. Let's say you only want to display start and stop time. So make a class that can hold a start and stop time:
Public Class ScheduleEntry
Public Property Start As DateTime
Public Property Stop As DateTime
End Class
You will use a List(Of ScheduleEntry) to populate your grid.
Now, depending on which service you call, just take the Start and Stop and add them to your list. Assume the case of two services with different return values:
Dim allStations As New List(Of ScheduleEntry)
Dim ws1 As New SERVICE1.CLASS()
For Each u1 As SERVICE1.Result In ws1.METHOD
Dim s As New ScheduleEntry
s.StartTime = u1.Departure
s.StopTime = u1.Arrival
allStations.Add(s)
Next
Dim ws2 As New SERVICE2.CLASS()
For Each u2 As SERVICE2.Result In ws2.METHOD2
Dim s As New ScheduleEntry
s.StartTime = u2.BeginTime
s.StopTime = u2.EndTime
allStations.Add(s)
Next
GridView1.DataSource = allStations
GridView1.DataBind()
I am creating a application that allows users to upload an image to the server of my site. But I want to allow users to upload multiple files with the same name by renaming the new file.
But I don't know what methods to use to perform this check.
I am thinking about trying to put all of the filenames into an arraylist individually and creating a loop to check the new filename against the rest and if there is a match then I would randomly generate a string of letters to tag onto the new filename.
But I haven't figured out how to populate the arraylist yet and this is the code I have for checking for repeats against the arraylist:
Dim i As Integer = 0
For i = 0 To arrayFileNames.Count
If (fileName = arrayFileNames(i)) Then
Dim random As Random = New Random()
random.Next(1, 100000)
fileName = fileName & random.ToString
End If
i = i + 1
Next
But this code throws the following error:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Any help would be appreciated, thank you.
If you're creating a For loop, you don't need to manually increase the counter. Remove the line i = i + 1.
Dim i As Integer = 0
For i = 0 To arrayFileNames.Count
If (fileName = arrayFileNames(i)) Then
Dim random As Random = New Random()
random.Next(1, 100000)
fileName = fileName & random.ToString
End If
Next
The for loop already takes care of increasing i.
You'll have a problem if you get a new fileName that is equal to a previous index.
When you create a new instance of random, you'll get the same value.
random.ToString() doesn't return what you think it does (check the output).
You might get a very big filename if you keep appending a big number.
You'll have to change your logic (I haven't tested this code, it's an example to help you out).
Dim random As Random = New Random()
Do While arrayFileNames.Contains(fileName)
fileName = fileName & random.Next(1, 9).ToString
Loop
Im looking for help with trying to vary a variable-name in a for loop:
For b = 1 To Count
' the below image_var(b) varible needs to vary on each iteration'
Dim image_var(b) As New LinkedResource(Server.MapPath(myArray(b-1)))
' need also to have the b in myArray(b-1) bit work through the loop too'
' that is I''m after the array index b minus 1'
image_var(b).ContentId = "imageContentId_" + b.ToString
' add the LinkedResource to the appropriate view'
htmlView.LinkedResources.Add(image_var(b))
Next b
Thanks in advance as I can't logon to accept an answer...
Thanks Guffa - my pics are now making it through to the email and showing up.
The (b) in the image_var(b) was just a stub for me too - till I found the code I was after... Am new and didn't even know/realise that it made an array... am a nobb.
Thanks again...
I don't know why you think that you need a separate variable for each instance. The variable just holds a reference to the object, it doesn't matter at all what you call the variable. You can just reuse the same variable for each of the objects:
For b = 1 To Count
Dim image As New LinkedResource(Server.MapPath(myArray(b-1)))
image.ContentId = "imageContentId_" + b.ToString
' add the LinkedResource to the appropriate view'
htmlView.LinkedResources.Add(image)
Next b