Catia V5 VB.net code, control instance name - vb.net

I have a Catia V5 Product inside another product :
The following code allows me to add a new part called "PART_NAME" inside the main "Product1" (Note that 2 lines are commented) :
Dim CATIA = GetObject(, "CATIA.Application")
Dim documents1 = CATIA.Documents
Dim productDocument1 = CATIA.ActiveDocument
Dim product1 = productDocument1.Product
Dim products1 = product1.Products
'Dim product2 = products1.Item("Product2.1")
'Dim products2 = product2.Products
Dim product3 = products1.AddNewComponent("Part", "")
product3.Name = "PART_NAME"
The result is the following :
Now I would like to add this part but inside "Product2.1". I then execute the same code, but uncomment everything and slightly change the last two code lines :
Dim CATIA = GetObject(, "CATIA.Application")
Dim documents1 = CATIA.Documents
Dim productDocument1 = CATIA.ActiveDocument
Dim product1 = productDocument1.Product
Dim products1 = product1.Products
Dim product2 = products1.Item("Product2.1")
Dim products2 = product2.Products
Dim product3 = products2.AddNewComponent("Part", "")
product3.Name = "PART_NAME_2"
The result is the following :
The part is indeed added but not renamed correctly.
Why ?

Related

XmlDocument in Outlook VBA

I am trying to adapt this answer, which I believe is in VB.NET, for use with Outlook VBA.
I made some progress by getting the syntax corrected for VBA, but I do not know how to resolve "Compile error: User-defined type not defined" on the line
Dim CurrentXML As XmlDocument
Tool > References includes Microsoft XML, v6.0 but searching for XmlDocument in Object Browser returns no results.
The complete code is as follows:
Sub Search2()
' https://stackoverflow.com/a/50145011/18573
Dim sFilter As String
Dim CurrentExplorer As Outlook.Explorer
Set CurrentExplorer = Nothing
Dim CurrentView As Outlook.View
Set CurrentView = Nothing
' ERROR ON THE FOLLOWING LINE
Dim CurrentXML As XmlDocument
Set CurrentXML = New XmlDocument
Dim CurrentFilterNodes, CurrentViewNodes As XmlNodeList
Dim CurrentFilterNode, CurrentParentNode As XmlNode
sFilter = "urn:schemas:httpmail:subject LIKE '%Build Error%'"
CurrentExplorer = TryCast(ExplorerObj, Outlook.Explorer)
If (CurrentExplorer Is Not Nothing) Then
CurrentView = CurrentExplorer.CurrentView
If (CurrentView Is Not Nothing) Then
CurrentXML.LoadXML (CurrentView.xml)
CurrentFilterNodes = _
CurrentXML.getElementsByTagName("filter")
If CurrentFilterNodes.Count > 0 Then
For y = 0 To CurrentFilterNodes.Count - 1
CurrentFilterNode = CurrentFilterNodes(y)
If CurrentFilterNode.HasChildNodes Then
For i = CurrentFilterNode.ChildNodes.Count - 1 To 0 Step -1
CurrentFilterNode.RemoveChild (CurrentFilterNode.ChildNodes(i))
Next i
End If
Next y
CurrentFilterNode = CurrentFilterNodes(0)
CurrentFilterNode.appendChild ( _
CurrentXML.createTextNode(sFilter))
Else
CurrentViewNodes = CurrentXML.getElementsByTagName("view")
If CurrentViewNodes Is Not Nothing Then
CurrentParentNode = CurrentViewNodes(0)
CurrentFilterNode = CurrentXML.createElement("filter")
CurrentParentNode.appendChild (CurrentFilterNode)
CurrentFilterNode.appendChild (CurrentXML.createTextNode(sFilter))
End If
End If
CurrentView.xml = CurrentXML.InnerXml
CurrentView.Apply
Marshal.ReleaseComObject (CurrentView)
End If
End Sub
The VBA code for Outlook should look like as follows
Option Explicit
Sub Search2()
' https://stackoverflow.com/a/50145011/18573
' Add reference Microsoft XML, v6.0
Dim sFilter As String
Dim oExplorer As Explorer
Dim oView As View
Dim oXML As DOMDocument60
Dim cFilterNodes As IXMLDOMNodeList
Dim cViewNodes As IXMLDOMNodeList
Dim oFilterNode As IXMLDOMNode
Dim oParentNode As IXMLDOMNode
Dim y As Long
Dim i As Long
sFilter = "urn:schemas:httpmail:subject LIKE '%Build Error%'"
Set oXML = New DOMDocument60
Set oExplorer = ActiveExplorer
If Not oExplorer Is Nothing Then
Set oView = oExplorer.CurrentView
If Not oView Is Nothing Then
oXML.LoadXML oView.XML
Set cFilterNodes = oXML.getElementsByTagName("filter")
If cFilterNodes.Length > 0 Then
For y = 0 To cFilterNodes.Length - 1
Set oFilterNode = cFilterNodes(y)
If oFilterNode.HasChildNodes Then
For i = oFilterNode.ChildNodes.Length - 1 To 0 Step -1
oFilterNode.RemoveChild oFilterNode.ChildNodes(i)
Next
End If
Next
Set oFilterNode = cFilterNodes(0)
oFilterNode.appendChild oXML.createTextNode(sFilter)
Else
Set cViewNodes = oXML.getElementsByTagName("view")
If cViewNodes.Length > 0 Then
Set oParentNode = cViewNodes(0)
Set oFilterNode = oXML.createElement("filter")
oParentNode.appendChild oFilterNode
oFilterNode.appendChild oXML.createTextNode(sFilter)
End If
End If
Else
Set cViewNodes = oXML.getElementsByTagName("view")
If cViewNodes.Length > 0 Then
Set oParentNode = cViewNodes(0)
Set oFilterNode = oXML.createElement("filter")
oParentNode.appendChild oFilterNode
oFilterNode.appendChild oXML.createTextNode(sFilter)
End If
End If
oView.XML = oXML.XML
oView.Apply
End If
End Sub

Network Information to Listview VB.NET

Hi guys I am trying to get the information on the active connection to listview.
So far I have:
Dim allProcess As String
Dim sl As String = "ProcessSplit"
Dim ipProps As System.Net.NetworkInformation.IPGlobalProperties = System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties()
For Each connection As System.Net.NetworkInformation.TcpConnectionInformation In ipProps.GetActiveTcpConnections
Dim LEP As String = connection.LocalEndPoint.ToString
Dim REP As String = connection.RemoteEndPoint.ToString
Dim CState As String = connection.State.ToString
Next
How can I get a new row entry for every connection? Sorry I am just starting out. Thanks in advance.
Inside your For Each loop, just add the ListView adding code:
Dim data(3) as String
Dim itm as ListViewItem
For Each connection As System.Net.NetworkInformation.TcpConnectionInformation In ipProps.GetActiveTcpConnections
Dim LEP As String = connection.LocalEndPoint.ToString
Dim REP As String = connection.RemoteEndPoint.ToString
Dim CState As String = connection.State.ToString
data(0) = LEP
data(1) = REP
data(2) = CState
Next
itm = New ListViewItem(data)
ListView1.Items.Add(itm)

Docusign webservice using vb.net - anchor tags Custom

Here is the problem I am having.
I have a document that I am creating using the DocuSign webservice.
I can create normal fields/tabs on it ie SignHere / SignDate / Initial fields.
However when i wan to use a custom field it just doesn't work. The code runs and the document is sent but all that is in the place of the EXPECTED custom field is just a bisc text box. It's like it's just ignoring the custom field settings.
I have attached the document i am using for reference and my code is below.
Everything works but the parts where the 2 customer fields should be I think is the issue.
Dim DocuSignSoap As New ServiceReference2.DSAPIServiceSoapClient
Dim DocuSignRecipient(0) As ServiceReference2.Recipient
Dim DocuSignRecipientType As ServiceReference2.RecipientTypeCode
Dim DocuSignTabType As ServiceReference2.TabTypeCode
Dim DocuSignCustomTabType As ServiceReference2.CustomTabType
Dim DocuSignEnvelope As New ServiceReference2.Envelope
Dim DocuSignDocument(0) As ServiceReference2.Document
Dim DocuSignTab(7) As ServiceReference2.Tab
Dim DocuSignEnvelopeStatus As ServiceReference2.EnvelopeStatus
Dim DocusignSig1 As New ServiceReference2.AnchorTab
Dim DocusignSig2 As New ServiceReference2.AnchorTab
Dim DocusignDateLOA As New ServiceReference2.AnchorTab
Dim DocusignDDDate As New ServiceReference2.AnchorTab
Dim DocusignFreq1 As New ServiceReference2.AnchorTab
Dim DocusignFreq2 As New ServiceReference2.AnchorTab
Dim DocusignFreq3 As New ServiceReference2.AnchorTab
Dim DocusignFreq4 As New ServiceReference2.AnchorTab
Dim strAuth As String
Dim strDocID As String
strDocID = Format(Now, "ddMMyyyyhhmmss")
Dim Mystream As New FileStream("c:\dantestdocusign.pdf", FileMode.Open)
Dim filesize As Long = Mystream.Length
Dim buffer(filesize) As Byte
Mystream.Read(buffer, 0, filesize)
Mystream.Close()
'Create Recipent
DocuSignRecipient(0) = New ServiceReference2.Recipient
DocuSignRecipient(0).Email = "daniel.rodgers#idebtplan.co.uk"
DocuSignRecipient(0).UserName = "Daniel Rodgers"
DocuSignRecipient(0).SignerName = "Daniel Rodgers"
DocuSignRecipient(0).Type = DocuSignRecipientType.Signer
DocuSignRecipient(0).ID = "1"
DocuSignRecipient(0).RoutingOrder = 1
'Create the envelope content
DocuSignEnvelope.Subject = "Your iDebtPlan Pack"
DocuSignEnvelope.EmailBlurb = "Email content"
DocuSignEnvelope.Recipients = DocuSignRecipient
DocuSignEnvelope.AccountId = "2f447fb0-243a-4a3f-acb5-adefbef43492"
'Create the document
DocuSignDocument(0) = New ServiceReference2.Document
DocuSignDocument(0).ID = strDocID
DocuSignDocument(0).Name = "DAN TESTING DOC"
DocuSignDocument(0).PDFBytes = buffer
' Attach the document(s)
DocuSignEnvelope.Documents = DocuSignDocument
' Create a new signature tab 1
DocuSignTab(0) = New ServiceReference2.Tab
DocuSignTab(0).DocumentID = DocuSignDocument(0).ID
DocuSignTab(0).RecipientID = "1"
DocuSignTab(0).Type = DocuSignTabType.SignHere
DocusignSig1.AnchorTabString = "\s1\"
DocuSignTab(0).AnchorTabItem = DocusignSig1
DocuSignTab(0).TabLabel = "Sig1"
' Create a new signature tab 2
DocuSignTab(1) = New ServiceReference2.Tab
DocuSignTab(1).DocumentID = DocuSignDocument(0).ID
DocuSignTab(1).RecipientID = "1"
DocuSignTab(1).Type = DocuSignTabType.SignHere
DocusignSig2.AnchorTabString = "\s2\"
DocuSignTab(1).AnchorTabItem = DocusignSig2
DocuSignTab(1).TabLabel = "Sig2"
' Create a DateLOA
DocuSignTab(2) = New ServiceReference2.Tab
DocuSignTab(2).DocumentID = DocuSignDocument(0).ID
DocuSignTab(2).RecipientID = "1"
DocuSignTab(2).Type = DocuSignTabType.DateSigned
DocusignDateLOA.AnchorTabString = "\loadate\"
DocuSignTab(2).AnchorTabItem = DocusignDateLOA
DocuSignTab(2).TabLabel = "DateLOA"
'CUSTOM FIELD 1
' Create a DD Date
DocuSignTab(3) = New ServiceReference2.Tab
DocuSignTab(3).DocumentID = DocuSignDocument(0).ID
DocuSignTab(3).RecipientID = "1"
DocuSignTab(3).Type = 11
DocuSignTab(3).CustomTabType = 4 'date
DocuSignTab(3).CustomTabWidth = 100
DocuSignTab(3).CustomTabDisableAutoSize = True
DocuSignTab(3).CustomTabRequired = True
DocuSignTab(3).CustomTabValidationPattern ="(^(?:(?:[12][0-9]|0?[1-9])/0?2|(?:30|[12][0-9]|0?[1-9])/(?:0?[469]|11)|(?:3[01]|[12][0-9]|0?[1-9])/(?:0?[13578]|1[02]))/\d{4}$)"
DocuSignTab(3).MaxLength = 10
DocuSignTab(3).CustomTabValidationMessage = "Your First Payment Date
Must be format dd/mm/yyyy (example: 01/03/2012), and a valid UK Date"
DocusignDDDate.AnchorTabString = "\dddate\"
DocuSignTab(3).AnchorTabItem = DocusignDDDate
DocuSignTab(3).TabLabel = "DDDate"
'CUSTOM FIELD 2
''Create Frequency Radio Buttons
DocuSignTab(4) = New ServiceReference2.Tab
DocuSignTab(4).DocumentID = DocuSignDocument(0).ID
DocuSignTab(4).RecipientID = "1"
DocuSignTab(4).Type = 11
DocuSignTab(4).CustomTabType = 2 'radio
DocuSignTab(4).CustomTabRequired = True
DocuSignTab(4).CustomTabWidth = 100
DocuSignTab(4).CustomTabDisableAutoSize = True
DocuSignTab(4).CustomTabRadioGroupName = "Frequency"
DocuSignTab(4).TabLabel = "Frequency"
DocuSignTab(4).Value = ""
DocusignFreq1.AnchorTabString = "\ow\"
DocuSignTab(4).AnchorTabItem = DocusignFreq1
DocuSignEnvelope.Tabs = DocuSignTab
strAuth = "<DocuSignCredentials<Usernameinfo#idebtplan.co.uk<mailto:info#idebtplan.co.uk</Username<Passwordjemima79</Password<IntegratorKeyIDEB-8ce296aa-0dff-4347-8ece-b62836a6a94e</IntegratorKey</DocuSignCredentials"
Dim x As New OperationContextScope(DocuSignSoap.InnerChannel)
Dim httpRequest As New System.ServiceModel.Channels.HttpRequestMessageProperty
httpRequest.Headers.Add("X-DocuSign-Authentication", strAuth)
OperationContext.Current.OutgoingMessageProperties(httpRequest.Name) = httpRequest
' Create the envelope on the account -- it will be a draft
DocuSignEnvelopeStatus = DocuSignSoap.CreateAndSendEnvelope(DocuSignEnvelope)
buffer = Nothing
Mystream = Nothing
httpRequest = Nothing
I would suggest the following:
Try adding your custom fields without the use of anchor tabs (i.e. use absolute positioning)
Compare how you are configuring your custom fields with the sample code from the SOAP SDK up on GitHub.
Create the envelope using the newer REST API from DocuSign.

how to access lotus notes view contents in .net using VB

I want to access contents of a catagorized view of lotu notes in .net.... can some one help me regarding this.. I am using interop.domino.dll.
Dim s As New Domino.NotesSession
Dim txt As String
Dim key() As String = {"abcd", "abcd"}
s.Initialize("")
Dim ldb As New NotesDatabase
ldb = s.GetDatabase("", "", False)
Dim vw As NotesView
vw = ldb.GetView("Project Module Wise Configurable Item")
vw.Refresh()
Dim entry As NotesViewEntry
Dim vc As NotesViewEntryCollection
vc = vw.GetAllEntriesByKey(key, False)
entry = vc.GetFirstEntry
While Not (entry Is Nothing)
txt = CStr(entry.Item)
entry = vc.GetNextEntry(entry)
ListBox1.Items.Add(txt)
End While
try:
Dim s As New Domino.NotesSession
s.Initialize("")
Dim ldb As New NotesDatabase
ldb = s.GetDatabase("", "", False)
Dim vw As NotesView
vw = ldb.GetView("Project Module Wise Configurable Item")
vw.Refresh()
Dim txt As String
Dim entry As NotesViewEntry
Dim vc As NotesViewEntryCollection
'declare the array
' ---- edited -----
Dim key(1) As variant
'----edited ---
key(0) = "abcd"
key(1) = "abcd"
'be carefull with the second parameter 'false'
vc = vw.GetAllEntriesByKey(key, False)
entry = vc.GetFirstEntry
While Not (entry Is Nothing)
txt = CStr(entry.Item)
entry = vc.GetNextEntry(entry)
ListBox1.Items.Add(txt)
End While
What worked for me: Declaring key as array of object.
Dim keys(0 To 1) As Object
keys(0) = "asdf"
keys(1) = "sgdk"
...

Add a Parameter Value in SSRS

I have a report already setup on the ReportServer. And its subscription as well. What I'm trying to do is add the ParameterValue "CC" and some email addresses then send the email out. It doesn't seem to work.
My code:
Dim emailReader As SqlDataReader = selCount.ExecuteReader
Dim emailsTest As List(Of String) = New List(Of String)
emailsTest.Add("test1#pen.com")
emailsTest.Add("test2#pen.com")
emailsTest.Add("test3#pen.com")
emailsTest.Add("test4#pen.com")
If emailReader.HasRows() Then 'checks to see if there any quotes in query
For Each subscrp As rs.Subscription In subscr
Dim allValues = subscrp.DeliverySettings.ParameterValues
Dim allValuesList As List(Of ReportTriggerTemplate1.rs.ParameterValueOrFieldReference) = allValues.ToList()
Dim CCParameter As ReportTriggerTemplate1.rs.ParameterValue = New ReportTriggerTemplate1.rs.ParameterValue()
CCParameter.Name = "CC"
CCParameter.Value = String.Empty
allValuesList.Add(CCParameter)
Dim toValue = CType(allValuesList.Item(7), ReportTriggerTemplate1.rs.ParameterValue)
For Each testEmail As String In emailsTest
Dim ownerEmail As String = testEmail
If toValue.Value.Contains(ownerEmail) Then
'skip
ElseIf toValue.Value = String.Empty Then
toValue.Value += ownerEmail
Else
toValue.Value += "; " & ownerEmail
End If
Next
subscrp.DeliverySettings.ParameterValues = allValuesList.ToArray()
Dim hello As String = "hi"
tr.FireEvent(EventType, subscrp.SubscriptionID) 'forces subscription to be sent
Next
What I'm adding to toValue.Value doesn't seem to be adding to the report's CC subscription field at all. So what am I missing?
http://msdn.microsoft.com/en-us/library/ms154020%28v=SQL.100%29.aspx
http://msdn.microsoft.com/en-us/library/reportservice2005.reportingservice2005.getsubscriptionproperties.aspx
http://msdn.microsoft.com/en-us/library/reportservice2005.reportingservice2005.setsubscriptionproperties%28v=SQL.105%29.aspx
Try
tr = New rs.ReportingService2005
Dim extSettings As ExtensionSettings = Nothing
Dim desc As String = Nothing
Dim active As ActiveState = Nothing
Dim status As String = Nothing
Dim matchData As String = Nothing
Dim values As ParameterValue() = Nothing
Dim extensionParams As ParameterValueOrFieldReference() = Nothing
Dim mainLogin As System.Net.NetworkCredential = New System.Net.NetworkCredential("ADUser", "Password", "NetworkName")
If mainLogin Is Nothing Then
tr.Credentials = System.Net.CredentialCache.DefaultCredentials
Else
tr.Credentials = mainLogin
End If
'skip to relevant code
For Each subscrp As rs.Subscription In subscr
Dim allValues = subscrp.DeliverySettings.ParameterValues
Dim allValuesList As List(Of ReportTriggerTemplate1.rs.ParameterValueOrFieldReference) = allValues.ToList()
If CType(allValuesList.Item(0), ReportTriggerTemplate1.rs.ParameterValue).Value = "test#pen.com" Then
Dim subsID = subscrp.SubscriptionID
'important code just below
tr.GetSubscriptionProperties(subsID, extSettings, desc, active, status, EventType, matchData, extensionParams)
''''add change to CC here
Dim extSettingsList As List(Of ReportTriggerTemplate1.rs.ParameterValueOrFieldReference) = extSettings.ParameterValues.ToList()
If CType(extSettingsList.Item(1), ReportTriggerTemplate1.rs.ParameterValue).Name = "CC" Then
If CType(extSettingsList.Item(1), ReportTriggerTemplate1.rs.ParameterValue).Value = String.Empty Then
CType(extSettingsList.Item(1), ReportTriggerTemplate1.rs.ParameterValue).Value = emailsTest.Item(0) & ";" & emailsTest.Item(1)
Else
CType(extSettingsList.Item(1), ReportTriggerTemplate1.rs.ParameterValue).Value += ";" & emailsTest.Item(0) & ";" & emailsTest.Item(1)
End If
Else
Dim CCParameter As ReportTriggerTemplate1.rs.ParameterValue = New ReportTriggerTemplate1.rs.ParameterValue()
CCParameter.Name = "CC"
CCParameter.Value = emailsTest.Item(0) & ";" & emailsTest.Item(1)
extSettingsList.Insert(1, CCParameter)
extSettings.ParameterValues = extSettingsList.ToArray
End If
'important code just below
tr.SetSubscriptionProperties(subsID, extSettings, desc, EventType, matchData, extensionParams)
tr.FireEvent(EventType, subscrp.SubscriptionID) 'forces subscription to be sent
Else
End If
Next