Wednesday, December 18, 2013

How can I get K2 worklistitems without open Item

I need to get work flow Item by serial number without opening Item.

When I used below code does not return any  thing:

WorklistCriteria criteria = new WorklistCriteria();
criteria.AddFilterField(WCField.SerialNumber, WCCompare.Equal, serialNumber);
SourceCode.Workflow.Management.WorklistItems wl = cnnWMS.GetWorklistItems(criteria);

Work Field doesn't contain field called serialnumber

I use this code instead:

WorklistCriteriaFilter criteria = new WorklistCriteriaFilter();
RegularFilter rfPID = new RegularFilter();
RegularFilter rfActID = new RegularFilter();
// why doesn't setting this prevent me from knowing alias? Are there constants or enums to use?
//rfPID.TableName = "K2Server.dbo._ProcInst";
rfPID.ColumnName = "PI.ID";
rfPID.ParameterValue = serialNumber.Substring(0, serialNumber.IndexOf('_'));
rfPID.DbType = DbType.Int32;
rfPID.Comparison = Comparison.Equals;
rfPID.ParameterName = "@ICE_ProcInstID";
criteria.FilterCollection.Add(rfPID);

rfActID.Condition = RegularFilter.FilterCondition.AND;
// why doesn't setting this prevent me from knowing alias? Are there constants or enums to use?
//rfActID.TableName = "K2Server.dbo._WorklistHeader";
rfActID.ColumnName = "WLH.ActInstDestID";
rfActID.ParameterValue = serialNumber.Substring(serialNumber.IndexOf('_') + 1);
rfActID.Comparison = Comparison.Equals;
rfActID.ParameterName = "@ICE_ActInstID";
rfActID.DbType = DbType.Int32;
criteria.FilterCollection.Add(rfActID);

SourceCode.Workflow.Management.WorklistItems wl = cnnWMS.GetWorklistItems(criteria);

Install to global assembly cache without gacutil

In Windows Server 2012 you can't install a DLL to the GAC by drag/drop, but you can do it using GACUTIL.exe.
GacUtil.exe is not present on the server by default.
You can do it using the following script instead of Gacutil.exe
Run your powershell and use command like sample below:
.\Add-AssemblyToGlobalAssemblyCache.ps1 FullPath\itegration.dll
This will applied in legacy windows versions

In Windows 2012 you can use the following PowerShell to install dll to GAC

Set-location "c:\temp"
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
$publish = New-Object System.EnterpriseServices.Internal.Publish
$publish.GacInstall("c:\temp\MyDLL.dll")
iisreset

 In Windows 2012 you can use the following PowerShell to remove dll from GAC:

Set-location "c:\temp"
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
$publish = New-Object System.EnterpriseServices.Internal.Publish
$publish.GacRemove("c:\temp\MyDLL.dll")
iisreset