Skip to content


Welcome to my blog about the software tools / techniques I have used.

The first posts, were originally hosted in a variety of places,  &  I thought it would be nice to bring them all together.   Its mainly a journal of  some of the things I have worked on, that might be useful to me in the future.  If it helps anyone else, then great.

I have been developing Web Applications with Domino / Lotus Notes since the 90s, mainly in areas where workflow & security are important. Before that I worked on financial systems with Foxpro, Oracle & PL/1.

In parallel with Domino, recently I have focused more on C# .NET, Sharepoint, JQuery , Javascript, CSS  & HTML5 .


Realtek HD Audio Voices Quiet Windows 7

Quite or underwater vocals on a stereo laptop, without any 5.1 audio

Another possible fix for this issue


1) In Control Panel, go to SOUND, not REALTEK HD AUDIO MANAGER

2) Double click the current set of speakers or click properties

3) Click the Enhancements tab



Case Insensitive QueryString in Angular

If your Angular app is expecting a QueryString parameter of myParm1,  &  instead it gets passed MypArM1, then the following command will fail:

var MyParmOne_Value = $ ; 

This JS code ( in the angular controller) deals with that by building a new array from the query_string & forcing every key to lowercase.  This new array is then used to retrieve values instead of the $ object:

var QSarr = [], hash;
var sourceQS = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i <sourceQS.length; i++) {
 hash =sourceQS[i].split('=');
 var key = hash[0].toLowerCase()
 QSarr[key] = hash[1];
//later we want that QueryString value so we search for myparm1 in the array
 var MyParmOne_Value =QSarr["myparm1"];




When Your C# deserialize fails

I had a problem deserializing some real world XML into classes created by doing an Edit \ Paste Special \ Paste XML as classes in Visual Studio 2012.

My Application (MyAPP )consumes numerous SOAP services provided by an external organisation (xtOrg) , & most work with the following code:

var responseXML = getXMLSOAPResponse(credential,url, SOAPObj);
var reader = new StringReader(responseXML.ToString());
XmlSerializer ser = new XmlSerializer(typeof(Envelope));
var instance = (Envelope)ser.Deserialize(reader);

In one service, the deserialize failed with the error “specified type was not recognized: name= PersonNameType” (See the bottom of the page for the XML)  This was frustrating because I only needed a subset of the data, a list of ‘OtherReferences’, which as far as I could see were parsing OK, before the failing data.
The ASP &  MSDN forums were full of people that offered solutions, but I could not get any of their suggestions to work, so I addressed it manually, using XPATH manual parsing.

All I wanted from this were the OtherRef fields, I could manually parse them with Xpath. This might not be suitable for a complete deserialization of the XML, but it suited the simple data I wanted : a list of other references:

List<OtherRef> retval = new List<OtherRef>();
XmlDocument xmldoc = new XmlDocument();

var responseXML = getXMLSOAPResponse(credential,url, SOAPObj);
// getSoapResponse is a custom function to fire a predefined 
// SOAPObject, at a url, with a credential. It returns a string

// retrieve XML & load to XMLDOC

XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmldoc.NameTable);
nsmgr.AddNamespace("ns4", "");
//Create a namespace manager to handle the namesspaces we want within the 
//XML. ( I suspect that this was part of the problem in my original code )

XmlNodeList nodelist = xmldoc.SelectNodes("//ns4:OtherRef", nsmgr);
// get the otherrefs Node into a nodelist. 
// This is the tricky part, and is an iterative process, 
//depending on the degree of nesting you want 

foreach (XmlNode node in nodelist)
XmlNodeList Childnodelist = node.ChildNodes;
// Build another Nodelist for the current Node
string OtherRefValue = "";
string OtherRefType = "";
// Set up empty fields for the object we want to build: a 2 column list

 foreach (XmlNode Chnode in Childnodelist)
// parse the type & value into the correct temporary variable type 
 if (Chnode.Name == "ns4:OtherRefValue")
 OtherRefValue = Chnode.InnerText; 

if (Chnode.Name == "ns4:OtherRefType")
 OtherRefType = Chnode.InnerText; 

 OtherRef tempRef = new OtherRef();
//Create a strongly typed OtherRef object 

 tempRef.OtherRefType = OtherRefType;
 tempRef.OtherRefValue = OtherRefValue;
// and populate it 

// and add it to the list 

Then you get a strongly typed list.  Its not a solution for every scenario, especially if you wanted to create  a POCO object of the entire XML.

One other gotcha with Edit \ Paste Special \ Paste XML as classes, is that sometimes number objects can be defined to be the smallest available ,  Eg uint which in sometimes can only store a value  of 65,535….  Suppose your service retrieves a value of 100000…

Here is the XML That was returned.  The green text shows the data I wanted & the red shows the data that was causing the problem

<env:Envelope xmlns:env="">
 <wsa:RelatesTo xmlns:wsa="">0b032838-d2de-db86-a3c2-nnnnnnnn</wsa:RelatesTo>
 <ns6:GetPersonDetailsResponse xmlns:ns3="" xmlns:ns4="" xmlns:ns5="" xmlns:ns6="" xmlns:ns7="" xmlns:ns8="" xmlns:ns9="" xmlns:ns10="" xmlns:ns11="">
 <ns4:PersonAddress CorrespondenceAddress="true" StartDate="2015-06-26">
 <ns5:Line>22 Acacia Ave</ns5:Line>
 <PersonBirthDate EstimatedDateOfBirth="false">1913-06-11</PersonBirthDate>
 <ns4:Telephone TelUse="home" TelMobile="no" TelPreferred="no">

 <ns4:WorkerName xsi:type="ns4:PersonNameType" xmlns:xsi="">
 <ns4:Telephone TelMobile="yes" TelPreferred="no">
 <ns4:WorkerName xsi:type="ns4:PersonNameType" xmlns:xsi="">

 <ns4:Telephone TelUse="work" TelMobile="no" TelPreferred="no">
 <ns4:Telephone TelMobile="yes" TelPreferred="no">

Jquery Datepicker with onclick remote validation

Step 1 define field in Model with the System.Web.MVC.remoteattribute

 [Remote("isDateAvailable", "Validation")]
 [DisplayName("Appointment Date")]
 public DateTime AppointmentOn { get; set; }
This tells the system to do server side validation in the client,  & look in ValidationController.cs for a function called isDateAvailable,  & return the validation as a JSON object to the client.

Step 2 define   isDateAvailable in ValidationController.cs

public JsonResult isDateAvailable(string AppointmentOn )
   string Message = "";
   if (AppointmentOn  != null)
 // Has a valid date been passed
                DateTime dt = new DateTime();
                    dt = Convert.ToDateTime(AppointmentOn);
                catch (Exception e)
                    Message = "Invalid Date";
                    return Json(Message, JsonRequestBehavior.AllowGet);
//If we have reached here date is a valid format  - so now do the validation required
                if (PerformMyCustomTestonDate(dt))
// test was passed
                    return Json(true, JsonRequestBehavior.AllowGet);
//  return false test failed 
                    Message = "The date you requested is not available";
                    return Json(Message, JsonRequestBehavior.AllowGet);
                Message = "Date cannot be EMPTY";
                return Json(Message, JsonRequestBehavior.AllowGet);
return Json(Message, JsonRequestBehavior.AllowGet);

Step 3 Wire up jquery ui date picker with the validation

 changeMonth: true,
 changeYear: true,
 dateFormat: "dd/mm/yy",
 onSelect: function (dateText, inst) {
// On select workout what element is being clicked & get the form
                var id ="#"+ $(this).attr('id');
                var Aform = $(id).closest('form');
// Tell the form to validate this field
                var validator = $(Aform).validate();
                var thisValidate = validator.element(id);



Angular JS filter array by date & jquery date picker

Step 1 Add Date picker filter fields from & to to form decorated with angular ng tags to HTML page

From Date:<input type="text" ng-model="fromDate" id="from" ng-click="First()">
To Date:<input type="text" ng-model="toDate" id="to" ng-click="First()">

When clicked into it runs the “First()” function that takes you to the first row in the array

Step 2 Jquery Date picker for the Fields with ids = “from” & “to”   to JQUERY $ function

$(function () {
 changeMonth: true,
 changeYear: true,
 dateFormat: "dd/mm/yy",
 onClose: function (selectedDate) {
 $("#to").datepicker("option", "minDate", selectedDate);
 changeMonth: true,
 changeYear: true,
 dateFormat: "dd/mm/yy",
 onClose: function (selectedDate) {
 $("#from").datepicker("option", "maxDate", selectedDate);

Step 3 Set up ng-repeat loop with filter on the HTML Page:

......   other table html
 <tr ng-repeat ="item in filtered = ( rows | filter:otherTextfilter | dateFilter:fromDate:'from' | dateFilter:toDate:'to') | .... other filters / sort etc...
 <td>{{ item.field1}} </td> <td>{{ item.PersonBirthDate}} </td>   etc....

Step 4 Define dateFilter  in the Angular js controller:

myApp.filter('dateFilter', function () {
return function (items, parmDate, mode) {
// function reads in the items array, 
//the value of the parameter date field, 
//& whether this is a greater than or less than comparison.
//  If this is initialising or there are no parameters, return the list unfiltered
if (parmDate === undefined) {
 return items;
// If the parmDate is not yet in the format dd/mm/yyyy - return it unfiltered
if (parmDate.length < 8) {
 return items;
// we must have a valid parmdate to to have reached here.
mode = mode.toLowerCase();
 var dateArr = parmDate.split("/");
 var  reccnt = 0;
 // Convert the parameter date string into a date.  
//This assumes dd/mm/yyyy - the format set in the jquery date picker in step 2
var filtered = [];
var parmDateDTE = new Date(dateArr[2], dateArr[1] - 1, dateArr[0]);
// adjust parmDateDte by 1 day to allow for cleaner greater than or less than
// tests.  GE or LE tests are messy due to time components
if (mode == "from") {
 parmDateDTE.setDate(parmDateDTE.getDate() - 1);
if (mode == "to") {
 parmDateDTE.setDate(parmDateDTE.getDate() + 1);
angular.forEach(items, function (item) {
// create a date field for each item in the array. Redefine it each time so that if
//the item field is missing, itemDateVal is set to today's date .
 //A null would trigger an error .  But you could set itemDateVal to anything 
var itemDateVal = new Date();
 if (item.PersonBirthDate) {
 itemDateVal = new Date(item.PersonBirthDate.Value);
 // Push the item to the filtered list if it matches the criteria. 
if (mode == "from") {
 if (itemDateVal > parmDateDTE) {
 } }
if (mode == "to") {
 if (itemDateVal < parmDateDTE) {
return filtered;
 catch (err){
First goes in the main controller

$scope.First = function (value) {
 $scope.startFrom = 0;
 $scope.goTo = $scope.pageSize;
 $scope.pageNo = getPageNo();
 return $scope.startFrom;

C# WebClient and Soap Services with WSSe security

Adding a WSDL to a .NET project’s service references is meant to give a series of proxy classes to run a remote SOAP service.

Sometimes it doesn’t always work.

When that happened to me, I decided to manually build a SOAP packet, & use .NET  WebClient.upload to run the service directly.


To eliminate my own code from the mix,  I downloaded SOAPUI, & built a new project and request based on the service WSDL.  There is one gotcha here.  The default request generates a Soap header like

<soapenv:Header/>   whereas we need one that looks like

To generate the WSSE Header in Soap UI ( with a plain text password), click the Auth(Basic) button, add the Username Password  & click Use global preference.

Then place the cursor between the header start / end tags,  right click to show a menu & select Add WSS Username token

 <wsse:Security soapenv:mustUnderstand="1" xmlns:soapenv="" xmlns:wsse="" xmlns:wsu="">
 <wsse:UsernameToken wsu:Id="UsernameToken-&&tokenValue">
 <wsse:Password Type="">&&passwordValue</wsse:Password>
 <wsse:Nonce EncodingType="">&&generatedNonce</wsse:Nonce>

The Green “play” triangle lets you debug your SOAP query & get responses ( both success & failure) in the window on the right. One gotcha is that you will need to generate new tokens on each query.  Simply delete the Username node or the Security node & generate a new token with the right click menu.

Step 2 Build your SOAP in .NET  & test in SOAPUI

In my .NET project I created a string builder object & used it to build my SOAP packet.  I ran the code in debug mode & pasted the resulting XML string into SOAP UI, where I could validate it & run it against the web service.  This was quite an iterative process.  One particular area of fun was building the WSSE header in C#.  I used these functions ( where credid & credpassword are the credentials required by the service.

 private string BuildSoapHeader(string credid, string credpassword)
 var nonce = getNonce();
 string nonceToSend = Convert.ToBase64String(Encoding.UTF8.GetBytes(nonce));
 string utc = DateTime.Now.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"); ;
 StringBuilder rawSOAP = new StringBuilder(@"<soapenv:Envelope xmlns:sear="""" xmlns:soapenv="""">");
 rawSOAP.Append(@"<wsse:Security soapenv:mustUnderstand=""1"" xmlns:wsse="""" xmlns:wsu="""">");
 rawSOAP.Append(@"<wsse:UsernameToken wsu:Id=""UsernameToken-D1A5C91F8C11FC7F2614479411111111"">");
 rawSOAP.Append(@"<wsse:Username>" + credid + "</wsse:Username>");
 rawSOAP.Append(@"<wsse:Password Type="""">" + credpassword + "</wsse:Password>");
 rawSOAP.Append(@"<wsse:Nonce EncodingType="""">" + nonceToSend + "</wsse:Nonce>");
 rawSOAP.Append(@"<wsu:Created>" + utc + "</wsu:Created>");
 return rawSOAP.ToString();
 protected string getNonce()
 string phrase = Guid.NewGuid().ToString();
 return phrase;

Step 3 Use .NET to send your SOAP to the service, & get a RAW object back.

string url = "";
 string credid = "&&&userid";
 string credpassword = "&&&Passwordval";
 string searchparms = " <" + parmname + ">" + parmval + "</" + parmname + ">";
 StringBuilder rawSOAP = new StringBuilder();
 rawSOAP.Append(BuildSoapHeader(credid, credpassword));
string SOAPObj = rawSOAP.ToString();
 using (var wb = new WebClient())
 wb.Credentials = new NetworkCredential(credid, credpassword);
var responseVal = wb.UploadString(url, "POST", SOAPObj);

This code builds your SOAP, creates a web client with credentials for the remote service  & provides responseVal as a ‘home’ the reply.

Step 4 parsing the results

Go to the Models area ( I did this in MVC) & create a new class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MosaicAPITest.Models
 public class MyNewClass1
 {/// Cursor goes here

Go To SOAPUI, & copy the XML from a successful query to the clipboard.

Put the cursor where indicated in the class definition, then go to the EDIT menu.  Paste Special , Paste XML as classes. & all your Serialize / Deserialize classes are there.

Update your service call code as follows ( I am parsing out a SearchPersonResults object:

wb.Credentials = new NetworkCredential(credid, credpassword);
 var responseVal = wb.UploadString(url, "POST", SOAPObj);
 XmlSerializer ser = new XmlSerializer(typeof(Envelope));
 var reader = new StringReader(responseVal.ToString());
 var instance = (Envelope)ser.Deserialize(reader);
foreach (SearchPersonResults person in instance.Body.SearchPersonResponse)





Dynamic URL links from web.config which are rewritten in jquery to reflect a querystring parameter from the current page

The need for this came because we needed an extendable menu (hence the web config settings) for a page, which had a  querystring parm of  ‘ID = nnnn’, was to be injected into those menus at run time. In standard MVC you could do this in the controller. But the previous developer had written this as a single page application, & also got the system to dynamically overwrite the querystring & store some of those values as cookies as the user navigated the system!  Throughout this example {IDVAR} is the value of id=parameter

So we needed to use the controller & jquery to address this.

Web.Config values for url template, title, & which button to mark as active :

<add key="RemotelinksUtls" value="http://app1:1234/#/dash?ID={IDVAR}/&z=m|http://app3/?q={IDVAR}&vv=po|http://app2:999/Home/Index?ID={IDVAR}&=ff" />
<add key="RemotelinksTitle" value="Application One | App3 | app Two " />
<add key="RemotelinksActive" value="1" />

Snippet from the home controller

 public ActionResult Index()
 Regex pattern = new Regex("[:.0123456789]");
// get config values into memory variables
 string SLinks = (ConfigurationManager.AppSettings["RemotelinksUtls"]);
 string Titles = ConfigurationManager.AppSettings["RemotelinksTitle"];
 string ActiveString = ConfigurationManager.AppSettings["RemotelinksActive"];
// Convert the ActiveString into an int so we can compare the loop position with it.
 int ActiveElement = 0;
 int.TryParse(ActiveString, out ActiveElement);
 // Split the url &title strings at | into lists
 List<string> RemoteList = new List<string>();
 List<String> LList = SLinks.Split('|').ToList();
 List<String> TList = Titles.Split('|').ToList();
 int LinkCnt = LList.Count;
// Use the lists to create a link button for each element & set one to be active 
 string templink = "";
 for (int i = 0; i < LinkCnt; i++)
 templink = "<span ><a href=\"http://" + LList[i] + "\" class=";

 if (i == ActiveElement)
 { // if the current element is the one which is set to be active, set its class to primary
 templink += "\"btn btn-primary\" >";
 {// Or set its class to default
 templink += "\"btn btn-default\" >";
 templink += TList[i] + "</a></span> ";
//add the link to the RemoteList list 
// Put the RemoteList into the Remotelinks viewbag item
 ViewBag.Remotelinks = RemoteList;
return View();

In the index.cshtml loop through viewbag.Remotelinks, nested under the div remlinks to render the HTML link buttons

At this point, the hrefs will all include the static value  q={IDVAR}. In an ordinary MVC program we’d have reset {IDVAR} in the controller.  But we aren’t going back to the controller because this is a single page application.  Additionally as the querystring gets rewritten,  we need to set / check the cookie values.  It would be more efficient to have reused some of the JS variables, but for the sake of clarity I have kept them distinct

This is done using JQUERY & javascript:

$( document ).ready(function() {
// if there's an id parm in the querystring , use that , otherwise use the existing cookie
var qparm = "";
//Set scope for in memory variable
var idno = qs("id");
if (!$.isEmptyObject(idno))
{//Set the cookie
qparm = idno;
else {//Read the Cookie
var Lastno=getCookie("IDNumber")
qparm = Lastno;

//set all of the hrefs under the 'remlinks' div, so that the relevant id value 
// ( from query string if its there, from the cookie if its not)  replaces
// {idvar} - some websamples show you concatenating this, 
//but suppose we have hash variables too...

$('#remlinks a').each(function () {
var href = $(this).attr('href');
if (href) {
href = href.replace('{IDVAR}',qparm)
$(this).attr('href', href);
// end remlinks each loop
//end document ready fn

function qs(key) {
//parse querystring for key value
key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&"); 
// escape RegEx control chars
var match = RegExp("[?&]" + key + "=([^&]+)(&|$)"));
return match && decodeURIComponent(match[1].replace(/\+/g, " "));

function setCookie(key, value) {
var expires = new Date();
//if needed, expire cookie tomorrow
//expires.setTime(expires.getTime() + (1 * 24 * 60 * 60 * 1000));
// document.cookie = key + '=' + value + '; path =/;expires=' + expires.toUTCString();
// or leave expires off, so we loose cookie when browser closes 
document.cookie = key + '=' + value + '; path =/;';

function getCookie(key) {
var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)');
return keyValue ? keyValue[2] : null;