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

Sunday, October 6, 2013

Replace HtmlTextWriter before render

If we want to change HTML of control before rendering you can use the following code:
protected override void Render(HtmlTextWriter writer)
{

MemoryStream stream = new MemoryStream();
StreamWriter memWriter = new StreamWriter(stream);
HtmlTextWriter myWriter = new HtmlTextWriter(memWriter);
base.Render(myWriter);
myWriter.Flush();
stream.Position = 0;
using (StreamReader sr = new StreamReader(stream))
{
string renderedHtml = sr.ReadToEnd();
renderedHtml = renderedHtml.Replace("It looks like your browser does not have JavaScript enabled. Please turn on JavaScript and try again.", "");
writer.Write(renderedHtml);
writer.Close();
myWriter.Close();
}
//base.Render(writer);
}

Tuesday, April 16, 2013

How do I disable administrator prompt in Windows 8/Windows 2012?

I want disable administrator prompt in Windows 8 and Windows 2012, For this I did the following tasks:

  1. Go to Administrative Tools → Local Security Policy
    For windows 8 run secpol.msc
  2. Find Local Policies --> Security Options, in the left side of the window, and scroll down to the button.
  3. User Account Control: Admin Approval Mode for the Built-in Administrator account Disabled. (Default) The built-in Administrator account runs all applications with full administrative privilege.

SQL Server 2008 database engine login failed for administrator user in windows 7/8


I am administrator in my machine windows 8, But I cannot login to SQL using my administrator user.
Problem I installed SQL using other user and I didn't remember its password to solve this problem I followed the following steps:
  1. Open the command prompt (Right-Click on and select "Run As Administrator")
  2. From the command prompt type net stop MSSQLSERVER
  3. Next type net start MSSQLSERVER /m
  4. Open SQL Server Management Studio. Do not login, cancel the login dialog.
  5. From the file Menu select New->Database engine query, and login (Make sure you use the host name and not localhost).
  6. Execute the query ALTER LOGIN sa WITH PASSWORD = ''; to reset the password (if the sa is not enabled then type ALTER LOGIN sa ENABLE to do so)
  7. Login with the sa user and add the Administrator user.

Failed to install Lync in Windows 8


When tried to install Lync in Windows 8 I faced error Another Installation Already in Progress (Although I didn't run previous installation). After some investigation I discovered I need to call setup as administrator.

But in Windows 8, right-clicking on a program in the Start screen won’t display Run as administrator option. While Run as administrator option is available when you right-click on a program shortcut on the desktop, the same option doesn’t appear when you right-click on program shortcut in the Start screen.

Step 1: Switch to the Metro Start screen and start typing the program’s name to see your program

Step 2: Right-click on the program name to see Advanced option.
Step 3: Click on Advanced and then select Run as administrator option.
After these steps, I can install Lync