Initial Commit of the PDM project (ready for DWS migration)
This commit is contained in:
@@ -0,0 +1,235 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Send Message to Users Example (VB.NET)</title>
|
||||
<meta http-equiv="Content-Language" content="en-us">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
|
||||
<link rel="stylesheet" type="text/css" href="ApiHelp.css">
|
||||
</head>
|
||||
<meta name=MS-HKWD content="VB.NET examples,notifications">
|
||||
<meta name=MS-HKWD content="VB.NET examples,users">
|
||||
<meta name=MS-HKWD content="VB.NET examples,messages">
|
||||
<meta name=MS-HKWD content="VB.NET examples,categories">
|
||||
|
||||
<body>
|
||||
<h1><font size="1"><span style="font-weight: 400">SOLIDWORKS PDM Professional API Help</span></h1>
|
||||
<h1>Send Message to Users Example (VB.NET)</h1>
|
||||
<p><a name="Top"></a>This example shows how to send a message, also called a notification, to logged-in users who have
|
||||
permission to modify Categories.</p>
|
||||
<p><b>NOTE</b>: If using the primary interop assembly
|
||||
provided with SOLIDWORKS PDM Professional, see
|
||||
<a href="Using_NET_Framework_in_Applications.htm">Using .NET Framework 4.0 in
|
||||
Stand-alone Applications</a>.</p>
|
||||
<p><img border="0" src="SendMessage.gif" width="268" height="206"></p>
|
||||
|
||||
<pre style="font-family: Courier New; font-size: 13; color: black; background: white"><span style="color: green">'----------------------------------------------------------------------------</span>
|
||||
<span style="color: green">' Preconditions:</span>
|
||||
<span style="color: green">' 1. Start Microsoft Visual Studio.</span>
|
||||
<span style="color: green">' 2. Click <b>File > New > Project > Visual Basic > Windows Forms Application</b>.</span>
|
||||
<span style="color: green">' 3. Type <b>Exercise3</b> in Name.</span>
|
||||
<span style="color: green">' 4. Click the <b>Browse</b> button and browse to the folder where to create the project.</span>
|
||||
<span style="color: green">' 5. Click <b>OK</b>. </span>
|
||||
<span style="color: green">' 6. Create a form similar to the form shown above and change: </span>
|
||||
<span style="color: green">' a. Label to <b>VaultsLabel</b>.</span>
|
||||
<span style="color: green">' b. Combo box to <b>VaultsComboBox</b>. </span>
|
||||
<span style="color: green">' c. Button to <b>TraverseUsersButton</b>. </span>
|
||||
<span style="color: green">' 7. Replace the code in <b>Form1.vb</b> with <a href="#Form">this code</a>.
|
||||
' 8. Replace the code in <b>Form1.Designer.vb</b> with <a href="#Designer">this code</a>.</span>
|
||||
<span style="color: green">' 9. Add <b>EPDM.Interop.epdm.dll</b> as a reference (right-click the project</span>
|
||||
<span style="color: green">' name in the Solution Explorer, click <b>Add Reference</b>, click </span>
|
||||
<span style="color: green">' <b>Framework</b> in the left-side panel, browse to the top folder of your </span>
|
||||
<span style="color: green">' SOLIDWORKS PDM Professional installation, locate and click </span>
|
||||
<span style="color: green">' <b>EPDM.Interop.epdm.dll</b>, click <b>Open</b>, click <b>Add</b>, and click <b>Close</b>).</span>
|
||||
<span style="color: green">' 10. Right-click E<b>PDM.Interop.epdm</b> in References, click <b>Properties</b>, and set </span>
|
||||
<span style="color: green">' <b>Embed Interop Types</b> to <b>False</b> to handle methods that pass arrays of </span>
|
||||
<span style="color: green">' structures.</span>
|
||||
<span style="color: green">' 11. Switch back to the <b>Form1.vb</b> code window.</span>
|
||||
<span style="color: green">' 12. Click <b>Debug > Start Debugging</b> or press F5.</span>
|
||||
<span style="color: green">'</span>
|
||||
<span style="color: green">' Postconditions: </span>
|
||||
<span style="color: green">' 1. Displays a dialog.</span>
|
||||
<span style="color: green">' 2. Select a vault.</span>
|
||||
<span style="color: green">' 3. Click the <b>Send message to users who can modify Categories</b> button.</span>
|
||||
<span style="color: green">' 4. After several minutes, a SOLIDWORKS PDM Professional notification
|
||||
' is displayed only to logged-in users who have permission
|
||||
' to modify Categories.
|
||||
</span><span style="COLOR: green">' 5. To open the the message, click:
|
||||
' * either the notification while it is displayed or
|
||||
</span>'<span style="COLOR: green"> the SOLIDWORKS PDM Professional tray icon.
|
||||
' - or - </span>
|
||||
<span style="color: #008000">'</span><span style="COLOR: green"> * <b>Tools > Inbox</b> in File Explorer.</span><span style="color: green">
|
||||
' 6. Close the dialog.</span>
|
||||
<span style="color: green">'----------------------------------------------------------------------------</span></pre>
|
||||
<pre style="font-family: Courier New; font-size: 13; color: black; background: white"> </pre>
|
||||
<pre style="font-family: Courier New; font-size: 13; color: black; background: white"><span style="color: green"><a name="Form"></a>'Form1.vb</span>
|
||||
|
||||
<span style="color: blue">Imports</span> EPDM.Interop.epdm
|
||||
|
||||
<span style="color: blue">Public</span> <span style="color: blue">Class</span> <span style="color: #2b91af">Exercise3</span>
|
||||
|
||||
<span style="color: blue">Private</span> <span style="color: blue">Sub</span> Exercise3_Load( _
|
||||
<span style="color: blue">ByVal</span> sender <span style="color: blue">As</span> System.<span style="color: #2b91af">Object</span>, _
|
||||
<span style="color: blue">ByVal</span> e <span style="color: blue">As</span> System.<span style="color: #2b91af">EventArgs</span>) _
|
||||
<span style="color: blue">Handles</span> <span style="color: blue">MyBase</span>.Load
|
||||
|
||||
<span style="color: blue">Try</span>
|
||||
<span style="color: blue">Dim</span> vault <span style="color: blue">As</span> <span style="color: #2b91af">IEdmVault8</span> = <span style="color: blue">New</span> <span style="color: #2b91af">EdmVault5</span>
|
||||
<span style="color: blue">Dim</span> Views() <span style="color: blue">As</span> <span style="color: #2b91af">EdmViewInfo</span> = <font color="#0000FF">Nothing</font>
|
||||
|
||||
vault.<b>GetVaultViews</b>(Views, <span style="color: blue">False</span>)
|
||||
VaultsComboBox.Items.Clear()
|
||||
<span style="color: blue">For</span> <span style="color: blue">Each</span> View <span style="color: blue">As</span> <span style="color: #2b91af">EdmViewInfo</span> <span style="color: blue">In</span> Views
|
||||
VaultsComboBox.Items.Add(View.<b>mbsVaultName</b>)
|
||||
<span style="color: blue">Next</span>
|
||||
<span style="color: blue">If</span> VaultsComboBox.Items.Count > 0 <span style="color: blue">Then</span>
|
||||
VaultsComboBox.Text = VaultsComboBox.Items(0)
|
||||
<span style="color: blue">End</span> <span style="color: blue">If</span>
|
||||
|
||||
<span style="color: blue">Catch</span> ex <span style="color: blue">As</span> Runtime.InteropServices.<span style="color: #2b91af">COMException</span>
|
||||
<span style="color: #2b91af">MessageBox</span>.Show(<span style="color: #a31515">"HRESULT = 0x"</span> + _
|
||||
ex.ErrorCode.ToString(<span style="color: #a31515">"X"</span>) + vbCrLf + _
|
||||
ex.Message)
|
||||
<span style="color: blue">Catch</span> ex <span style="color: blue">As</span> <span style="color: #2b91af">Exception</span>
|
||||
<span style="color: #2b91af">MessageBox</span>.Show(ex.Message)
|
||||
<span style="color: blue">End</span> <span style="color: blue">Try</span>
|
||||
<span style="color: blue">End</span> <span style="color: blue">Sub</span>
|
||||
|
||||
<span style="color: blue">Private</span> <span style="color: blue">Sub</span> TraverseUsersButton_Click( _
|
||||
<span style="color: blue">ByVal</span> sender <span style="color: blue">As</span> System.<span style="color: #2b91af">Object</span>, _
|
||||
<span style="color: blue">ByVal</span> e <span style="color: blue">As</span> System.<span style="color: #2b91af">EventArgs</span>) _
|
||||
<span style="color: blue">Handles</span> TraverseUsersButton.Click
|
||||
|
||||
<span style="color: blue">Try</span>
|
||||
<span style="color: green">'Declare and create an instance of IEdmVault5 object</span>
|
||||
<span style="color: blue">Dim</span> vault <span style="color: blue">As</span> <span style="color: #2b91af">IEdmVault5</span> = <span style="color: blue">New</span> <span style="color: #2b91af">EdmVault5</span>()
|
||||
<span style="color: green">'Log into selected vault as the current user</span>
|
||||
vault.<b>LoginAuto</b>(VaultsComboBox.Text, _
|
||||
<span style="color: blue">Me</span>.Handle.ToInt32())
|
||||
|
||||
<span style="color: green">'Declare an IEdmUserMgr5 object</span>
|
||||
<span style="color: blue">Dim</span> UserMgr <span style="color: blue">As</span> <span style="color: #2b91af">IEdmUserMgr5</span>
|
||||
<span style="color: green">'The IEdmUserMgr5 interface is implemented by the</span>
|
||||
<span style="color: green">'same class as the IEdmVault5 interface,</span>
|
||||
<span style="color: green">'so in VB we can simply assign the value of</span>
|
||||
<span style="color: green">'the IEdmVault5 object</span>
|
||||
UserMgr = vault
|
||||
|
||||
<span style="color: blue">Dim</span> UserPos <span style="color: blue">As</span> <span style="color: #2b91af">IEdmPos5</span>
|
||||
UserPos = UserMgr.<b>GetFirstUserPosition</b>()
|
||||
<span style="color: blue">While</span> <span style="color: blue">Not</span> UserPos.<b>IsNull</b>
|
||||
<span style="color: blue">Dim</span> User <span style="color: blue">As</span> <span style="color: #2b91af">IEdmUser7</span>
|
||||
User = UserMgr.<b>GetNextUser</b>(UserPos)
|
||||
<span style="color: blue">If</span> User.<b>IsLoggedIn</b> <span style="color: blue">Then</span>
|
||||
<span style="color: blue">If</span> User.<b>HasSysRightEx</b>(<span style="color: #2b91af">EdmSysPerm</span>. _
|
||||
EdmSysPerm_ModifyCategories) _
|
||||
<span style="color: blue">Then</span>
|
||||
User.<b>SendMsg</b>(<span style="color: #a31515">"Category request"</span>, _
|
||||
<span style="color: #a31515">"Please stop by my office sometime "</span> + _
|
||||
<span style="color: #a31515">"this morning to discuss adding "</span> + _
|
||||
<span style="color: #a31515">"a new file type to a Category."</span>)
|
||||
<span style="color: blue">End</span> <span style="color: blue">If</span>
|
||||
<span style="color: blue">End</span> <span style="color: blue">If</span>
|
||||
<span style="color: blue">End</span> <span style="color: blue">While</span>
|
||||
|
||||
<span style="color: blue">Catch</span> ex <span style="color: blue">As</span> Runtime.InteropServices.<span style="color: #2b91af">COMException</span>
|
||||
<span style="color: #2b91af">MessageBox</span>.Show(<span style="color: #a31515">"HRESULT = 0x"</span> + _
|
||||
ex.ErrorCode.ToString(<span style="color: #a31515">"X"</span>) + vbCrLf + _
|
||||
ex.Message)
|
||||
<span style="color: blue">Catch</span> ex <span style="color: blue">As</span> <span style="color: #2b91af">Exception</span>
|
||||
<span style="color: #2b91af">MessageBox</span>.Show(ex.Message)
|
||||
<span style="color: blue">End</span> <span style="color: blue">Try</span>
|
||||
<span style="color: blue">End</span> <span style="color: blue">Sub</span>
|
||||
|
||||
<span style="color: blue">End</span> <span style="color: blue">Class</span></pre>
|
||||
<pre style="font-family: Courier New; font-size: 13; color: black; background: white"> </pre>
|
||||
<div align="center">
|
||||
<pre style="font-family: Courier New; font-size: 13; color: #0000FF; background: white"><a href="#Top">Back to top</a></pre>
|
||||
</div>
|
||||
<div align="left">
|
||||
<pre style="background-position: 0% 0%; font-family: Courier New; font-size: 13; color: #008000; background-image:none; background-repeat:repeat; background-attachment:scroll"><span style="background-color: #FFFFFF"><a name="Designer"></a>'Form1.Designer.vb</span></pre>
|
||||
<pre style="font-family: Courier New; font-size: 13; color: black; background: white"><<span style="color:blue;">Global</span>.Microsoft.VisualBasic.CompilerServices.<span style="color:#2b91af;">DesignerGenerated</span>()> _
|
||||
<span style="color:blue;">Partial</span> <span style="color:blue;">Class</span> <span style="color:#2b91af;">Exercise3</span>
|
||||
<span style="color:blue;">Inherits</span> System.Windows.Forms.<span style="color:#2b91af;">Form</span>
|
||||
|
||||
<span style="color:green;">'Form overrides dispose to clean up the component list.</span>
|
||||
<System.Diagnostics.<span style="color:#2b91af;">DebuggerNonUserCode</span>()> _
|
||||
<span style="color:blue;">Protected</span> <span style="color:blue;">Overrides</span> <span style="color:blue;">Sub</span> Dispose(<span style="color:blue;">ByVal</span> disposing <span style="color:blue;">As</span> <span style="color:blue;">Boolean</span>)
|
||||
<span style="color:blue;">Try</span>
|
||||
<span style="color:blue;">If</span> disposing <span style="color:blue;">AndAlso</span> components <span style="color:blue;">IsNot</span> <span style="color:blue;">Nothing</span> <span style="color:blue;">Then</span>
|
||||
components.Dispose()
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">If</span>
|
||||
<span style="color:blue;">Finally</span>
|
||||
<span style="color:blue;">MyBase</span>.Dispose(disposing)
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">Try</span>
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">Sub</span>
|
||||
|
||||
<span style="color:green;">'Required by the Windows Form Designer</span>
|
||||
<span style="color:blue;">Private</span> components <span style="color:blue;">As</span> System.ComponentModel.<span style="color:#2b91af;">IContainer</span>
|
||||
|
||||
<span style="color:green;">'NOTE: The following procedure is required by the Windows Form Designer</span>
|
||||
<span style="color:green;">'It can be modified using the Windows Form Designer. </span>
|
||||
<span style="color:green;">'Do not modify it using the code editor.</span>
|
||||
<System.Diagnostics.<span style="color:#2b91af;">DebuggerStepThrough</span>()> _
|
||||
<span style="color:blue;">Private</span> <span style="color:blue;">Sub</span> InitializeComponent()
|
||||
<span style="color:blue;">Me</span>.TraverseUsersButton = <span style="color:blue;">New</span> System.Windows.Forms.<span style="color:#2b91af;">Button</span>()
|
||||
<span style="color:blue;">Me</span>.VaultsComboBox = <span style="color:blue;">New</span> System.Windows.Forms.<span style="color:#2b91af;">ComboBox</span>()
|
||||
<span style="color:blue;">Me</span>.VaultsLabel = <span style="color:blue;">New</span> System.Windows.Forms.<span style="color:#2b91af;">Label</span>()
|
||||
<span style="color:blue;">Me</span>.SuspendLayout()
|
||||
<span style="color:green;">'</span>
|
||||
<span style="color:green;">'TraverseUsersButton</span>
|
||||
<span style="color:green;">'</span>
|
||||
<span style="color:blue;">Me</span>.TraverseUsersButton.Location = <span style="color:blue;">New</span> System.Drawing.<span style="color:#2b91af;">Point</span>(57, 90)
|
||||
<span style="color:blue;">Me</span>.TraverseUsersButton.Margin = <span style="color:blue;">New</span> System.Windows.Forms.<span style="color:#2b91af;">Padding</span>(2, 2, 2, 2)
|
||||
<span style="color:blue;">Me</span>.TraverseUsersButton.Name = <span style="color:#a31515;">"TraverseUsersButton"</span>
|
||||
<span style="color:blue;">Me</span>.TraverseUsersButton.Size = <span style="color:blue;">New</span> System.Drawing.<span style="color:#2b91af;">Size</span>(136, 67)
|
||||
<span style="color:blue;">Me</span>.TraverseUsersButton.TabIndex = 18
|
||||
<span style="color:blue;">Me</span>.TraverseUsersButton.Text = <span style="color:#a31515;">"Send message to users who can modify Categories"</span>
|
||||
<span style="color:blue;">Me</span>.TraverseUsersButton.UseVisualStyleBackColor = <span style="color:blue;">True</span>
|
||||
<span style="color:green;">'</span>
|
||||
<span style="color:green;">'VaultsComboBox</span>
|
||||
<span style="color:green;">'</span>
|
||||
<span style="color:blue;">Me</span>.VaultsComboBox.FormattingEnabled = <span style="color:blue;">True</span>
|
||||
<span style="color:blue;">Me</span>.VaultsComboBox.Location = <span style="color:blue;">New</span> System.Drawing.<span style="color:#2b91af;">Point</span>(57, 41)
|
||||
<span style="color:blue;">Me</span>.VaultsComboBox.Margin = <span style="color:blue;">New</span> System.Windows.Forms.<span style="color:#2b91af;">Padding</span>(2, 2, 2, 2)
|
||||
<span style="color:blue;">Me</span>.VaultsComboBox.Name = <span style="color:#a31515;">"VaultsComboBox"</span>
|
||||
<span style="color:blue;">Me</span>.VaultsComboBox.Size = <span style="color:blue;">New</span> System.Drawing.<span style="color:#2b91af;">Size</span>(136, 21)
|
||||
<span style="color:blue;">Me</span>.VaultsComboBox.TabIndex = 16
|
||||
<span style="color:green;">'</span>
|
||||
<span style="color:green;">'VaultsLabel</span>
|
||||
<span style="color:green;">'</span>
|
||||
<span style="color:blue;">Me</span>.VaultsLabel.AutoSize = <span style="color:blue;">True</span>
|
||||
<span style="color:blue;">Me</span>.VaultsLabel.Location = <span style="color:blue;">New</span> System.Drawing.<span style="color:#2b91af;">Point</span>(71, 9)
|
||||
<span style="color:blue;">Me</span>.VaultsLabel.Margin = <span style="color:blue;">New</span> System.Windows.Forms.<span style="color:#2b91af;">Padding</span>(2, 0, 2, 0)
|
||||
<span style="color:blue;">Me</span>.VaultsLabel.Name = <span style="color:#a31515;">"VaultsLabel"</span>
|
||||
<span style="color:blue;">Me</span>.VaultsLabel.Size = <span style="color:blue;">New</span> System.Drawing.<span style="color:#2b91af;">Size</span>(91, 13)
|
||||
<span style="color:blue;">Me</span>.VaultsLabel.TabIndex = 17
|
||||
<span style="color:blue;">Me</span>.VaultsLabel.Text = <span style="color:#a31515;">"Select vault view:"</span>
|
||||
<span style="color:green;">'</span>
|
||||
<span style="color:green;">'Exercise3</span>
|
||||
<span style="color:green;">'</span>
|
||||
<span style="color:blue;">Me</span>.AutoScaleDimensions = <span style="color:blue;">New</span> System.Drawing.<span style="color:#2b91af;">SizeF</span>(6.0!, 13.0!)
|
||||
<span style="color:blue;">Me</span>.AutoScaleMode = System.Windows.Forms.<span style="color:#2b91af;">AutoScaleMode</span>.Font
|
||||
<span style="color:blue;">Me</span>.ClientSize = <span style="color:blue;">New</span> System.Drawing.<span style="color:#2b91af;">Size</span>(252, 168)
|
||||
<span style="color:blue;">Me</span>.Controls.Add(<span style="color:blue;">Me</span>.TraverseUsersButton)
|
||||
<span style="color:blue;">Me</span>.Controls.Add(<span style="color:blue;">Me</span>.VaultsComboBox)
|
||||
<span style="color:blue;">Me</span>.Controls.Add(<span style="color:blue;">Me</span>.VaultsLabel)
|
||||
<span style="color:blue;">Me</span>.Margin = <span style="color:blue;">New</span> System.Windows.Forms.<span style="color:#2b91af;">Padding</span>(2, 2, 2, 2)
|
||||
<span style="color:blue;">Me</span>.Name = <span style="color:#a31515;">"Exercise3"</span>
|
||||
<span style="color:blue;">Me</span>.Text = <span style="color:#a31515;">"Send Message to Users"</span>
|
||||
<span style="color:blue;">Me</span>.ResumeLayout(<span style="color:blue;">False</span>)
|
||||
<span style="color:blue;">Me</span>.PerformLayout()
|
||||
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">Sub</span>
|
||||
<span style="color:blue;">Friend</span> <span style="color:blue;">WithEvents</span> TraverseUsersButton <span style="color:blue;">As</span> System.Windows.Forms.<span style="color:#2b91af;">Button</span>
|
||||
<span style="color:blue;">Friend</span> <span style="color:blue;">WithEvents</span> VaultsComboBox <span style="color:blue;">As</span> System.Windows.Forms.<span style="color:#2b91af;">ComboBox</span>
|
||||
<span style="color:blue;">Friend</span> <span style="color:blue;">WithEvents</span> VaultsLabel <span style="color:blue;">As</span> System.Windows.Forms.<span style="color:#2b91af;">Label</span>
|
||||
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">Class</span></pre>
|
||||
</div>
|
||||
<div align="center">
|
||||
<pre style="font-family: Courier New; font-size: 13; color: #0000FF; background: white"><a href="#Top">Back to top</a></pre>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user