Initial Commit of the PDM project (ready for DWS migration)
This commit is contained in:
@@ -0,0 +1,383 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Create a Task that Finds Approved Files 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">
|
||||
<style type="text/css">
|
||||
.auto-style1 {
|
||||
font-size: x-small;
|
||||
}
|
||||
.auto-style3 {
|
||||
font-size: x-small;
|
||||
}
|
||||
.auto-style2 {
|
||||
color: #2B91AF;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<meta name=MS-HKWD content="Add-ins, VB.NET">
|
||||
<meta name=MS-HKWD content="VB.NET add-ins">
|
||||
<meta name=MS-HKWD content="VB.NET add-ins,tasks">
|
||||
<meta name=MS-HKWD content="VB.NET add-ins,hooks">
|
||||
<meta name=MS-HKWD content="VB.NET add-ins,workflows">
|
||||
<meta name=MS-HKWD content="VB.NET add-ins,states">
|
||||
<meta name=MS-HKWD content="VB.NET add-ins,searches">
|
||||
<meta name=MS-HKWD content="VB.NET add-ins,notifications">
|
||||
|
||||
<body>
|
||||
<h1><font size="1"><span style="font-weight: 400">SOLIDWORKS PDM Professional API Help</span></h1>
|
||||
<h1>Create a Task that Finds Approved Files Example (VB.NET)</h1>
|
||||
<p>This example shows how to create a task add-in that notifies the logged-in
|
||||
user as to which files in
|
||||
the vault are in the Approved state.</p>
|
||||
|
||||
<p style="font-family: Courier New; font-size: 13; color: black; background: white" class="APICODE">
|
||||
<span style="color:green;">
|
||||
'--------------------------------------------------------------------------------------</span><br>
|
||||
<span style="color:green;">' Preconditions:</span><br>
|
||||
<span style="color:green;">' 1. Start Microsoft Visual Studio.</span><br>
|
||||
<span style="color:green;">' 2. Click <b>File > New > Project > Visual Basic > Class Library
|
||||
(.NET Framework)</b>.</span><br>
|
||||
<span style="color:green;">
|
||||
' 3. Select <b>.NET Framework 4.5 </b>or
|
||||
later in the dropdown.</span><br>
|
||||
<span style="color:green;">' 4. Type <b>TaskAddinExample</b> in <b>Name</b>.</span><br>
|
||||
<span style="color:green;">' 5. Click <b>Browse</b> and navigate to the folder where to create the project.</span><br>
|
||||
<span style="color:green;">' 6. Click <b>OK</b>. </span><br>
|
||||
<span style="color:green;">
|
||||
' 7. Right-click the project name in the Solution Explorer and click <b>Add Reference</b>. <br>
|
||||
' 8. In the Add Reference dialog: </span><br>
|
||||
<span style="color:green;">' a. Add the
|
||||
SOLIDWORKS PDM Professional <font size="2"><span style="color:green;">
|
||||
interop assembly</span></font> as a reference <font size="2"><span style="color:green;">(click <strong>Browse</strong> in the</span><br>
|
||||
<span style="color: #008000">//</span> left-side panel, click
|
||||
<strong>EPDM.Interop.epdm.dll</strong>, <br>
|
||||
// and click <strong>OK</strong>).</font></span><br>
|
||||
<span style="color: #008000">'</span><span style="color:green;"> b. Add <b>System.Windows.Forms</b> as a reference (click <b>Assemblies
|
||||
> Framework</b> in the</span><br>
|
||||
<span style="color: #008000">'</span><span style="color:green;"> left-side panel, click <b>System.Windows.Forms</b>, and click <b>Add</b>).</span><br>
|
||||
<span style="color: #008000">'</span><span style="color:green;"> c. Click <b>Close</b>.<br>
|
||||
' 9. Right-click the project name in the Solution Explorer and click <b>
|
||||
Properties</b>.<br>
|
||||
'10. In the Properties window:<br>
|
||||
' a. On the Application tab, click<b> Assembly Information</b>.<br>
|
||||
' b. De-select <b>Make assembly COM-Visible</b>.<br>
|
||||
' c. On the Compile tab, <font size="1" class="auto-style1">
|
||||
<span style="color:green;">select <strong>Any CPU</strong>, de-select <strong>
|
||||
Prefer 32-bit</strong>, and select <b>Register for COM interop</b></span></font>.<br>
|
||||
'11. Save the project.<br>
|
||||
'12. Copy the code below to <b>Class1.vb</b>.<br>
|
||||
'13. </span><font size="2"><font color="#008000">To populate the GUID
|
||||
attribute, click <b>Tools > Create GUID</b> in the IDE, <br>
|
||||
' select GUID Format
|
||||
6, click <b>Copy</b>, and click <b>Exit</b>. Replace
|
||||
<</font><span style="color:#008000;">Guid</span><font color="#008000">(</font><span style="color:#008000;">""</span><font color="#008000">)>
|
||||
with the <br>
|
||||
' copied string.</font></font><br>
|
||||
<span style="color:green;">'14. Click <b>Build > Build Solution</b>.</span><br>
|
||||
<span style="color:green;">'</span><br>
|
||||
<span style="color:green;">' Postconditions:<br>
|
||||
' 1. Open the SOLIDWORKS PDM Professional Administration tool, expand a <i>vault_name</i> node, <br>
|
||||
' and log in as Admin.</span><br>
|
||||
<span style="color:green;">' 2. Ensure that Default Workflow with an
|
||||
Approved state exists <br>
|
||||
' under <i>vault_name</i> <b>> Workflows</b>.</span><br>
|
||||
<span style="color:green;">' 3. </span><span style="color:green;">Under
|
||||
<i>vault_name</i>, right-click <b>Add-ins</b> and click <b>New Add-in</b>.<br>
|
||||
' a. Navigate to the </span>
|
||||
<span style="color:green;"><b>bin\Debug </b></span><span style="color:green;">directory of your built
|
||||
project.</span><br>
|
||||
<span style="color:green;">' b. Click <b>EPDM.Interop.epdm.dll</b> and <b>TaskAddinExample.dll</b>.<br>
|
||||
' c. Click <b>Open</b>.</span><br>
|
||||
<span style="color:green;">' d. Click <b>OK</b>.</span><br>
|
||||
<span style="color:green;">' 4. Click <b>OK</b> after
|
||||
reading the SOLIDWORKS PDM Professional warning dialog.<br>
|
||||
</span>
|
||||
<span style="color:green;">' 5. In the taskbar notification area:<br>
|
||||
' a. Click the SOLIDWORKS PDM icon.<br>
|
||||
' b. Click <b>Task Host Configuration</b>.<br>
|
||||
' c. Select <i>vault_name</i> in the <b>File Vault</b>
|
||||
dropdown.<br>
|
||||
' d. Select <b>Permit</b> next to the add-in you
|
||||
installed in step 3.<br>
|
||||
' e. Click <b>OK</b>.</span><br>
|
||||
<span style="color:green;">' 6. In the Administration tool under <i>vault_name, </i>
|
||||
right-click<b> Tasks </b>and click <b>New Task</b>.</span><br>
|
||||
<span style="color:green;">' a. Type</span><span style="color: green"> <b>Approved Files Task</b> in the upper-left text box.</span><br>
|
||||
<span style="color:green;">' b. Select the <b>VB.NET Task Add-in</b> from the <b>Add-in</b> dropdown.</span><br>
|
||||
<span style="color:green;">'
|
||||
c. When the attach debugger message box appears:</span><br>
|
||||
<span style="color:green;">' 1. In the IDE, click <b>Debug > Attach to Process > ConisioAdmin.exe</b>.</span><br>
|
||||
<span style="color:green;">' 2. Click <b>Attach</b>.</span><br>
|
||||
<span style="color:green;">' 3. Click <b>OK</b> to close the message box.</span><br>
|
||||
<span style="color:green;">' d. Click <b>Next</b>.</span><br>
|
||||
<span style="color:green;">' e. On the Execution Method properties page, select the
|
||||
local computer.</span><br>
|
||||
<span style="color:green;">' f. Click <b>Next</b>.</span><br>
|
||||
<span style="color:green;">' g. On the Scheduling properties page, select <b>This task is not scheduled</b>.</span><br>
|
||||
<span style="color:green;">' h. Click <b>Next</b>.</span><br>
|
||||
<span style="color:green;">' i. On the Permissions property page, select <b>Admin</b>.</span><br>
|
||||
<span style="color:green;">' j. Click <b>Next</b>.</span><br>
|
||||
<span style="color:green;">' k. On the Success Notification property page:</span><br>
|
||||
<span style="color:green;">' 1. Select <b>Notify the user who launched the task</b>.</span><br>
|
||||
<span style="color:green;">' 2. In the <b>Subject</b> field, type <b>Success</b>.</span><br>
|
||||
<span style="color:green;">' 3. In the <b>Text</b> field, type <b>The task successfully completed at</b>,
|
||||
type a space,
|
||||
<br>
|
||||
' click <b>></b>, and click <b>Current Time</b>.</span><br>
|
||||
<span style="color:green;">' l. Click <b>OK</b> to close the New Task dialog.</span><br>
|
||||
<span style="color:green;">' 7. Expand <i>vault_name</i> <b>> Tasks</b> and double-click <b>Task List</b>.</span><br>
|
||||
<span style="color:green;">' 8. Click <b>Add Task</b>. <br>
|
||||
' 9. In the Add Task dialog:</span><br>
|
||||
<span style="color:green;">'
|
||||
a. Select <b>Approved Files Task</b> from the dropdown.</span><br>
|
||||
<span style="color:green;">' b. Click <b>OK</b>.</span><br>
|
||||
<span style="color:green;">' 10. When the attach debugger message box appears:</span><br>
|
||||
<span style="color:green;">' a. In the IDE, click <b>Debug > Attach to Process > TaskExecutor.exe</b>.</span><br>
|
||||
<span style="color:green;">' b. Click <b>Attach</b>.</span><br>
|
||||
<span style="color:green;">' c. Click <b>OK</b> to close the message box.</span><br>
|
||||
<span style="color:green;">' 11. The task appears in the <b>Pending tasks</b> list. Observe the task status.</span><br>
|
||||
<span style="color:green;">
|
||||
' 12. When the task completes, the task moves
|
||||
to the <b>Completed tasks</b><br>
|
||||
' list. The logged-in user receives a notification with the list of approved files.</span><br>
|
||||
<span style="color:green;">
|
||||
'---------------------------------------------------------------------------------------</span><br>
|
||||
<br>
|
||||
<span style="color:blue;">Imports</span> EPDM.Interop.epdm<br>
|
||||
<span style="color:blue;">Imports</span> System.Runtime.InteropServices<br>
|
||||
<br>
|
||||
<<span style="color:#2b91af;">Guid</span>(<span style="color:#a31515;">""</span>)><br>
|
||||
<<span style="color:#2b91af;">ComVisible</span>(<span style="color:blue;">True</span>)><br>
|
||||
<span style="color:blue;">Public</span> <span style="color:blue;">Class</span> <span style="color:#2b91af;">TaskAddinExample</span><br>
|
||||
<span style="color:blue;">Implements</span> <span style="color:#2b91af;">IEdmAddIn5</span><br>
|
||||
<br>
|
||||
<span style="color:blue;">Public</span> <span style="color:blue;">Sub</span> GetAddInInfo( _<br>
|
||||
<span style="color:blue;">ByRef</span> poInfo <span style="color:blue;">As</span> <span style="color:#2b91af;">EdmAddInInfo</span>, _<br>
|
||||
<span style="color:blue;">ByVal</span> poVault <span style="color:blue;">As</span> <span style="color:#2b91af;">IEdmVault5</span>, _<br>
|
||||
<span style="color:blue;">ByVal</span> poCmdMgr <span style="color:blue;">As</span> <span style="color:#2b91af;">IEdmCmdMgr5</span>) _<br>
|
||||
<span style="color:blue;">Implements</span> <span style="color:#2b91af;">IEdmAddIn5</span>.<b>GetAddInInfo</b><br>
|
||||
<br>
|
||||
<span style="color:blue;">Try</span><br>
|
||||
poInfo.<b>mbsAddInName</b> = _<br>
|
||||
<span style="color:#a31515;">"VB.NET Task Add-In"</span><br>
|
||||
poInfo.<b>mbsCompany</b> = <span style="color:#a31515;">"Dassault Systemes"</span><br>
|
||||
poInfo.<b>mbsDescription</b> = _<br>
|
||||
<span style="color:#a31515;">"Exercise demonstrating a task that lists "</span> _<br>
|
||||
+ <span style="color:#a31515;">"files in the Approved state."</span><br>
|
||||
poInfo.<b>mlAddInVersion</b> = 1<br>
|
||||
<br>
|
||||
<span style="color:green;">'Minimum SOLIDWORKS PDM Professional version</span><br>
|
||||
<span style="color:green;">'needed for VB.Net Task Add-Ins is 10.0</span><br>
|
||||
poInfo.<b>mlRequiredVersionMajor</b> = 10<br>
|
||||
poInfo.<b>mlRequiredVersionMinor</b> = 0<br>
|
||||
<br>
|
||||
<span style="color:green;">'Register this add-in as a task add-in</span><br>
|
||||
poCmdMgr.<b>AddHook</b>(<span style="color:#2b91af;">EdmCmdType</span>.<b>EdmCmd_TaskRun</b>)<br>
|
||||
<span style="color:green;">'Register this add-in to be called when</span><br>
|
||||
<span style="color:green;">'selected as a task in the Administration tool</span><br>
|
||||
poCmdMgr.<b>AddHook</b>(<span style="color:#2b91af;">EdmCmdType</span>.<b>EdmCmd_TaskSetup</b>)<br>
|
||||
<span style="color:blue;">Catch</span> ex <span style="color:blue;">As</span> Runtime.InteropServices.<span style="color:#2b91af;">COMException</span><br>
|
||||
MsgBox(<span style="color:#a31515;">"HRESULT = 0x"</span> + _<br>
|
||||
ex.ErrorCode.ToString(<span style="color:#a31515;">"X"</span>) + vbCrLf + _<br>
|
||||
ex.Message)<br>
|
||||
<span style="color:blue;">Catch</span> ex <span style="color:blue;">As</span> <span style="color:#2b91af;">Exception</span><br>
|
||||
MsgBox(ex.Message)<br>
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">Try</span><br>
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">Sub</span><br>
|
||||
<br>
|
||||
<span style="color:blue;">Public</span> <span style="color:blue;">Sub</span> OnCmd(<span style="color:blue;">ByRef</span> poCmd <span style="color:blue;">As</span> <span style="color:#2b91af;">EdmCmd</span>, _<br>
|
||||
<font size="1"><span style="color:blue;" class="auto-style3">ByRef</span><span class="auto-style3"> ppoData <span style="color:blue;">As</span> <span class="auto-style2">EdmCmdData</span>[]</span></font>) _<br>
|
||||
<span style="color:blue;">Implements</span> <span style="color:#2b91af;">IEdmAddIn5</span>.<b>OnCmd</b><br>
|
||||
<br>
|
||||
<span style="color:blue;">Try</span><br>
|
||||
PauseToAttachProcess(poCmd.<b>meCmdType</b>.ToString())<br>
|
||||
<br>
|
||||
<span style="color:blue;">Select</span> <span style="color:blue;">Case</span> poCmd.<b>meCmdType</b><br>
|
||||
<span style="color:blue;">Case</span> <span style="color:#2b91af;">EdmCmdType</span>.<b>EdmCmd_TaskRun</b><br>
|
||||
OnTaskRun(poCmd, ppoData)<br>
|
||||
<span style="color:blue;">Case</span> <span style="color:#2b91af;">EdmCmdType</span>.<b>EdmCmd_TaskSetup</b><br>
|
||||
OnTaskSetup(poCmd, ppoData)<br>
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">Select</span><br>
|
||||
<span style="color:blue;">Catch</span> ex <span style="color:blue;">As</span> Runtime.InteropServices.<span style="color:#2b91af;">COMException</span><br>
|
||||
MsgBox(<span style="color:#a31515;">"HRESULT = 0x"</span> + _<br>
|
||||
ex.ErrorCode.ToString(<span style="color:#a31515;">"X"</span>) + vbCrLf + _<br>
|
||||
ex.Message)<br>
|
||||
<span style="color:blue;">Catch</span> ex <span style="color:blue;">As</span> <span style="color:#2b91af;">Exception</span><br>
|
||||
MsgBox(ex.Message)<br>
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">Try</span><br>
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">Sub</span><br>
|
||||
<br>
|
||||
<span style="color:blue;">Private</span> <span style="color:blue;">Sub</span> OnTaskRun(<span style="color:blue;">ByRef</span> poCmd <span style="color:blue;">As</span> <span style="color:#2b91af;">EdmCmd</span>, _<br>
|
||||
<font size="1"><span style="color:blue;" class="auto-style3">ByRef</span><span class="auto-style3"> ppoData <span style="color:blue;">As</span> <span class="auto-style2">EdmCmdData</span>[]</span></font>)<br>
|
||||
<br>
|
||||
<span style="color:green;">'Get the task instance interface</span><br>
|
||||
<span style="color:blue;">Dim</span> inst <span style="color:blue;">As</span> <span style="color:#2b91af;">IEdmTaskInstance</span><br>
|
||||
inst = poCmd.<b>mpoExtra</b><br>
|
||||
<span style="color:blue;">Try</span><br>
|
||||
<span style="color:green;">'Keep the task list status up to date</span><br>
|
||||
inst.<b>SetStatus</b> _<br>
|
||||
(<span style="color:#2b91af;">EdmTaskStatus</span>.<b>EdmTaskStat_Running</b>)<br>
|
||||
<br>
|
||||
<span style="color:green;">'Format a message that will be displayed</span><br>
|
||||
<span style="color:green;">'in the task list</span><br>
|
||||
inst.<b>SetProgressRange</b>(10, 1, <span style="color:#a31515;">"Task is running."</span>)<br>
|
||||
<br>
|
||||
<span style="color:blue;">Dim</span> Items <span style="color:blue;">As</span> <span style="color:#2b91af;">List</span>(<span style="color:blue;">Of</span> <span style="color:#2b91af;">EdmSelItem2</span>) = _<br>
|
||||
<span style="color:blue;">New</span> <span style="color:#2b91af;">List</span>(<span style="color:blue;">Of</span> <span style="color:#2b91af;">EdmSelItem2</span>)<br>
|
||||
inst.<b>SetProgressPos</b>(4, <span style="color:#a31515;">"Task is searching."</span>)<br>
|
||||
<br>
|
||||
<span style="color:blue;">Dim</span> Search <span style="color:blue;">As</span> <span style="color:#2b91af;">IEdmSearch6</span> = _<br>
|
||||
poCmd.<b>mpoVault</b>.<b>CreateSearch</b>()<br>
|
||||
<span style="color:blue;">If</span> Search <span style="color:blue;">Is</span> <span style="color:blue;">Nothing</span> <span style="color:blue;">Then</span> <span style="color:blue;">Return</span><br>
|
||||
<br>
|
||||
</p>
|
||||
<p style="font-family: Courier New; font-size: 13; color: black; background: white" class="APICODE">
|
||||
Search.<b>SetToken</b>( _<br>
|
||||
<span style="color:#2b91af;">EdmSearchToken</span>.<b>Edmstok_FindFiles</b>, <span style="color:blue;">True</span>)</p>
|
||||
<p style="font-family: Courier New; font-size: 13; color: black; background: white" class="APICODE">
|
||||
|
||||
<span class="auto-style1">Search.</span><strong><span class="auto-style1">SetToken</span></strong><font size="1">(<span style="color:#2b91af;" class="auto-style1">EdmSearchToken</span>.</font><strong><span class="auto-style1">Edmstok_AllVersions</span></strong><font size="1"><span class="auto-style1">,
|
||||
</span><span style="color:blue;"><span class="auto-style1">True</span>)</span></font><br>
|
||||
Search.<b>SetToken</b>( _<br>
|
||||
<span style="color:#2b91af;">EdmSearchToken</span>.<b>Edmstok_WorkflowName</b>, _<br>
|
||||
<span style="color:#a31515;">"Default Workflow"</span>)<br>
|
||||
Search.<b>SetToken</b>( _<br>
|
||||
<span style="color:#2b91af;">EdmSearchToken</span>.<b>Edmstok_StateName</b>, <span style="color:#a31515;">"Approved"</span>)<br>
|
||||
</p>
|
||||
|
||||
<p style="font-family: Courier New; font-size: 13; color: black; background: white" class="APICODE">
|
||||
<font color="#008000">
|
||||
'Uncomment and modify the following lines to look for files <br>
|
||||
'that have a
|
||||
card variable with values in a specific range</font></p>
|
||||
<p style="font-family: Courier New; font-size: 13; color: black; background: white" class="APICODE">
|
||||
<font color="#008000">'Dim varName1 As Object = "<i>Card_Variable_ID_or_Name</i>"<br>
|
||||
'Dim varValue1
|
||||
As Object = "<i>Card_Variable_Value_1</i>"<br>
|
||||
'Dim varOp1
|
||||
as Integer = <i>EdmVarOp_NumberGreaterThan</i><br>
|
||||
'Dim varValue2
|
||||
As Object = "<i>Card_Variable_Value_2</i>"<br>
|
||||
'Dim varOp2
|
||||
as Integer = <i>EdmVarOp_NumberLessThan<br>
|
||||
</i>'Search.<b>BeginAND</b><br>
|
||||
'Search.<b>AddVariable2</b>(varName1,
|
||||
varValue1, varOp1)<br>
|
||||
|
||||
'Search.<b>AddVariable2</b>(varName1,
|
||||
varValue2, varOp2)<br>
|
||||
'Search.<b>EndAND</b></font><br>
|
||||
<br>
|
||||
<span style="color:blue;">Dim</span> SearchResult <span style="color:blue;">As</span> <span style="color:#2b91af;">IEdmSearchResult5</span> = _<br>
|
||||
Search.<b>GetFirstResult</b>()<br>
|
||||
<span style="color:blue;">While</span> <span style="color:blue;">Not</span> SearchResult <span style="color:blue;">Is</span> <span style="color:blue;">Nothing</span><br>
|
||||
<span style="color:blue;">Dim</span> SelItem <span style="color:blue;">As</span> <span style="color:#2b91af;">EdmSelItem2</span> = <span style="color:blue;">New</span> <span style="color:#2b91af;">EdmSelItem2</span>()<br>
|
||||
SelItem.<b>mlID</b> = SearchResult.<b>ID</b><br>
|
||||
SelItem.<b>mlParentID</b> = SearchResult.<b>ParentFolderID</b><br>
|
||||
SelItem.<b>meType</b> = SearchResult.<b>ObjectType</b><br>
|
||||
SelItem.<b>mlVersion</b> = SearchResult.<b>Version</b><br>
|
||||
<br>
|
||||
Items.Add(SelItem)<br>
|
||||
SearchResult = Search.<b>GetNextResult</b>()<br>
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">While</span><br>
|
||||
inst.<b>SetProgressPos</b>(7, <span style="color:#a31515;">"Task finished searching."</span>)<br>
|
||||
<br>
|
||||
<span style="color:blue;">Dim</span> NotificationArray(Items.Count - 1) _<br>
|
||||
<span style="color:blue;">As</span> <span style="color:#2b91af;">EdmSelItem2</span><br>
|
||||
Items.CopyTo(NotificationArray)<br>
|
||||
<br>
|
||||
<span style="color:blue;">Dim</span> ProgresssMsg <span style="color:blue;">As</span> <span style="color:blue;">String</span><br>
|
||||
<span style="color:blue;">If</span> (Items.Count > 0) <span style="color:blue;">Then</span><br>
|
||||
ProgresssMsg = <span style="color:#a31515;">"Found "</span> + _<br>
|
||||
Items.Count.ToString() + <span style="color:#a31515;">" files."</span><br>
|
||||
<span style="color:blue;">Else</span><br>
|
||||
ProgresssMsg = (<span style="color:#a31515;">"No files found."</span>)<br>
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">If</span><br>
|
||||
<br>
|
||||
inst.<b>SetProgressPos</b>(10, ProgresssMsg)<br>
|
||||
inst.<b>SetStatus</b>( _<br>
|
||||
<span style="color:#2b91af;">EdmTaskStatus</span>.<b>EdmTaskStat_DoneOK</b>, 0, <span style="color:#a31515;">""</span>, _<br>
|
||||
NotificationArray, ProgresssMsg)<br>
|
||||
<span style="color:blue;">Catch</span> ex <span style="color:blue;">As</span> Runtime.InteropServices.<span style="color:#2b91af;">COMException</span><br>
|
||||
inst.<b>SetStatus</b> _<br>
|
||||
(<span style="color:#2b91af;">EdmTaskStatus</span>.<b>EdmTaskStat_DoneFailed</b>, _<br>
|
||||
ex.ErrorCode, <span style="color:#a31515;">"The test task failed!"</span>)<br>
|
||||
<span style="color:blue;">Catch</span> ex <span style="color:blue;">As</span> <span style="color:#2b91af;">Exception</span><br>
|
||||
inst.<b>SetStatus</b> _<br>
|
||||
(<span style="color:#2b91af;">EdmTaskStatus</span>.<b>EdmTaskStat_DoneFailed</b>, _<br>
|
||||
0, <span style="color:#a31515;">"Non COM test task failure!"</span>)<br>
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">Try</span><br>
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">Sub</span><br>
|
||||
<br>
|
||||
<span style="color:blue;">Private</span> <span style="color:blue;">Sub</span> OnTaskSetup(<span style="color:blue;">ByRef</span> poCmd <span style="color:blue;">As</span> <span style="color:#2b91af;">EdmCmd</span>, _<br>
|
||||
<font size="1"><span style="color:blue;" class="auto-style3">ByRef</span><span class="auto-style3"> ppoData <span style="color:blue;">As</span> <span class="auto-style2">EdmCmdData</span>[]</span></font>)<br>
|
||||
<br>
|
||||
<span style="color:blue;">Try</span><br>
|
||||
<span style="color:green;">'Get the property interface used to</span><br>
|
||||
<span style="color:green;">'access the framework</span><br>
|
||||
<span style="color:blue;">Dim</span> props <span style="color:blue;">As</span> <span style="color:#2b91af;">IEdmTaskProperties</span><br>
|
||||
props = poCmd.<b>mpoExtra</b><br>
|
||||
<br>
|
||||
<span style="color:green;">'Set the property flag that says you want a</span><br>
|
||||
<span style="color:green;">'menu item for the user to launch the task</span><br>
|
||||
<span style="color:green;">'and a flag to support scheduling</span><br>
|
||||
props.<b>TaskFlags</b> = _<br>
|
||||
<span style="color:#2b91af;">EdmTaskFlag</span>.<b>EdmTask_SupportsInitExec</b> + _<br>
|
||||
<span style="color:#2b91af;">EdmTaskFlag</span>.<b>EdmTask_SupportsScheduling</b><br>
|
||||
<br>
|
||||
<span style="color:green;">'Set up the menu commands to launch this task</span><br>
|
||||
<span style="color:blue;">Dim</span> cmds(0) <span style="color:blue;">As</span> <span style="color:#2b91af;">EdmTaskMenuCmd</span><br>
|
||||
cmds(0).<b>mbsMenuString</b> = <span style="color:#a31515;">"List Approved files task"</span><br>
|
||||
cmds(0).<b>mbsStatusBarHelp</b> = _<br>
|
||||
<span style="color:#a31515;">"This command runs the task add-in to get the"</span> + _<br>
|
||||
<span style="color:#a31515;">" names of the files in the Approved state."</span><br>
|
||||
cmds(0).<b>mlCmdID</b> = 1<br>
|
||||
cmds(0).<b>mlEdmMenuFlags</b> = _<br>
|
||||
<span style="color:#2b91af;">EdmMenuFlags</span>.<b>EdmMenu_Nothing</b><br>
|
||||
props.<b>SetMenuCmds</b>(cmds)<br>
|
||||
<span style="color:blue;">Catch</span> ex <span style="color:blue;">As</span> Runtime.InteropServices.<span style="color:#2b91af;">COMException</span><br>
|
||||
MsgBox(<span style="color:#a31515;">"HRESULT = 0x"</span> + _<br>
|
||||
ex.ErrorCode.ToString(<span style="color:#a31515;">"X"</span>) + vbCrLf + _<br>
|
||||
ex.Message)<br>
|
||||
<span style="color:blue;">Catch</span> ex <span style="color:blue;">As</span> <span style="color:#2b91af;">Exception</span><br>
|
||||
MsgBox(ex.Message)<br>
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">Try</span><br>
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">Sub</span><br>
|
||||
<br>
|
||||
<span style="color:blue;">Private</span> <span style="color:blue;">Sub</span> PauseToAttachProcess( _<br>
|
||||
<span style="color:blue;">ByVal</span> callbackType <span style="color:blue;">As</span> <span style="color:blue;">String</span>)<br>
|
||||
<br>
|
||||
<span style="color:blue;">Try</span><br>
|
||||
<span style="color:green;">'If the debugger isn't already attached to a</span><br>
|
||||
<span style="color:green;">'process, </span><br>
|
||||
<span style="color:blue;">If</span> <span style="color:blue;">Not</span> <span style="color:#2b91af;">Debugger</span>.IsAttached() <span style="color:blue;">Then</span><br>
|
||||
<span style="color:green;">'Launch the debug dialog</span><br>
|
||||
<span style="color:green;">'Debugger.Launch()</span><br>
|
||||
<span style="color:green;">'or</span><br>
|
||||
<span style="color:green;">'use a MsgBox dialog to pause execution</span><br>
|
||||
<span style="color:green;">'and allow the user time to attach it</span><br>
|
||||
MsgBox(<span style="color:#a31515;">"Attach debugger to process """</span> + _<br>
|
||||
<span style="color:#2b91af;">Process</span>.GetCurrentProcess.ProcessName() + _<br>
|
||||
<span style="color:#a31515;">""" for callback """</span> + callbackType + _<br>
|
||||
<span style="color:#a31515;">""" before clicking OK."</span>)<br>
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">If</span><br>
|
||||
<br>
|
||||
<span style="color:blue;">Catch</span> ex <span style="color:blue;">As</span> <span style="color:#2b91af;">Exception</span><br>
|
||||
MsgBox(ex.Message)<br>
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">Try</span><br>
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">Sub</span><br>
|
||||
<br>
|
||||
<span style="color:blue;">End</span> <span style="color:blue;">Class</span><br>
|
||||
</p>
|
||||
<pre style="font-family: Courier New; font-size: 13; color: black; background: white"> </pre>
|
||||
<p class="APICODE"> </p>
|
||||
<p class=APICODE> </p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user