Programming Tips
  .  Home   .  MXPBridge   .  Emails & Q-A   .  ServiceBase   .  HUM   .  SQL   .  Image Stream   .  Milestone Forum   .  Milestone Projects   .  HttpReq   .  NewTech&Websockets   .  SNMP   .

 This Page's Links (Table Of Contents)

 Other Links

 Vocabulary ... [Table Of Contents]

 Definitions ... [Table Of Contents]

  1. Windows Management Instrumentation - (WMI)
    WMI consists of a set of extensions to the Windows Driver Model that provides an operating system interface through which instrumented components provide information and notification. WMI is Microsoft's implementation of the Web-Based Enterprise Management (WBEM) and Common Information Model (CIM) standards from the Distributed Management Task Force (DMTF).
       WMI allows scripting languages (such as VBScript or Windows PowerShell) to manage Microsoft Windows personal computers and servers, both locally and remotely. WMI comes preinstalled in Windows 2000 and in newer Microsoft OSs. It is available as a download for Windows NT,[1] Windows 95 and Windows 98.[2]
       Microsoft also provides a command-line interface to WMI called Windows Management Instrumentation Command-line (WMIC).[3]

 Miscellaneous Tips ... [Table Of Contents]

 IIS Log Help ... [Table Of Contents] IIS Log File Formats
IIS Status Codes (microsoft) (.Net)
// 2016-08-30: status(404-error): The parameter) was too long, limit was about 2048, Dan fixed in webconfig by making it bigger.
// 2016-08-30: this was an ajax call.
// <security>
//     <requestFiltering>
//         <requestLimits maxAllowedContentLength="50000000" maxQueryString="3072" />
//     </requestFiltering>
// </security>

The time is recorded as local time.

 - status=200 (if 200 then no error) -------------------------------------------------+
 - and returned, without error, 3223 bytes of data -----------------------------+     |
 - 163-byte HTTP request --------------------------------------------------+    |     |
 - 4502 milliseconds processing time of to complete, ----------------+     |    |     |, -, 03/20/01, 7:55:20, W3SVC2, SALES1,, 4502, 163, 3223, 200, 0, GET, /DeptLogo.gif, -,, anonymous, 03/20/01, 23:58:11, MSFTPSVC, SALES1,, 60, 275, 0, 0, 0, PASS, /Intro.htm, -, 

In the previous example, 
the first entry indicates that ...
 - an anonymous user with the IP address of 
 - issued an HTTP GET command for the image file /DeptLogo.gif
 - at 7:55 A.M. on March 20, 2001,
 - from a server named SALES1 at IP address 
 - to the anonymous user. 

 Milestone Help ... [Table Of Contents]

 Git and BitBucket(ForIsonas) Help, Installer notes, and PANRServ bitbucket repository. ... [Table Of Contents] repository

From: Jesse
Sent: Wednesday, March 21, 2018 4:13 PM
To: Dave; Melissa; Cc: 'Dan Fritsch'
Subject: RE: LinkToSrc: IMACX, PANRSERV: desktops and services.
If you want to set up some time to go over Git, how to use it, etc let me know.

Here are some tutorials on the git basics if you need a refresher:

 IM-ACX: Milestone to ISONAS: Door, Area, etc ... [Table Of Contents]

// [NOTE]ORDER: [srvr] [ctrlrs] [doors] [accessPts=Readers].
// -----02/03/2014  Clarification of Doors and Readers. In Milestone and ISONAS.
//  Milestone         ISONAS
// -----------------+---------------------
//  Door              Area
//  AccessPt=Reader   Door=Reader
//  AP|Door|AP        Door|Area|Door
//                    "Main Entrance" is a reader (ISONAS calls it a Door)
DoorItem[] doorItemAy = _configurationItems.Values.OfType<DoorItem>().ToArray();
for (int i = 0; i < doorItemAy.Length; i++)
    DoorItem doorItem = doorItemAy[i];
    if (doorItem.Children.Count < 1)

 Visual Studio Links ... [Table Of Contents]

 Programming Links ... [Table Of Contents]

re: Shutdown / Startup of Services - It can be done from command line, and there r probably a few functions in the compiler library as well.  Meanwhile, look at this ... Google: windows class or method to stop and start services
Found: WMI Tasks: Services ... Determine which services are running and which ones are not. - [TIP: for Arrow Imgs in Hdr]
// (Note:) Working well in eqip.asp.
// (Note: To debug hdr-arrow-icons:) Use (Step 5b, not 5a), and don't add list-even and list-odd classes to your table tags.
// (Step 1) Add something like this (or more, see above link)...
<link rel="stylesheet" type="text/css" href="/util/jquery_tablesorter/themes/blue/" />
<script type="text/javascript" src="/util/jq/jquery-1.8.2.min.js"></script> 
<script type="text/javascript" src="/util/jquery_tablesorter/jquery.tablesorter.js"></script>

// (Step 2) id the table you are adding Table Sorter to.
// (Step 3) Add 'tablesorter' class to the table.
// (Step 4) Then add 'thead' and 'tbody' tags.
      <table id="myTable" class="tablesorter std" ...
          <thead> <tr class='tblSortHdr-even'> <th> ... </th> </tr> </thead> 
          <tbody> <tr> <td> ... </td> </tr> </tbody> 
<script type="text/javascript">
// (Step 5a) Place this somewhere in root of javascript section. (parameters could be improved) -->
        // Make sure 'myTable' is replaced with id from your table, step 4.
        $(document).ready(function () {
                // pass the headers argument and assign an object
                headers: {
                    // assign the first column (we start counting zero)
                    0: {
                        // disable it by setting the property sorter to false
                        sorter: false
            }, { widgets: ['zebra'] });
// or (Step 5b) call registerTblSortTableId("myTable");  // use when creating table at run-time. -->
    function registerTblSortTableId(jqTableId) {
        // NOTE: Unclear if these parameters are valid or relevant to this solution.
        // NOTE: These parameters where copied from "view source" of
        $(function() {
		    $("#" + jqTableId).tablesorter( {widgets: ['zebra']} );
        // $(function() {
        //     $("#" + jqTableId).tablesorter({sortList:[[0,0],[2,1]], widgets: ['zebra']});
        //     $("#options").tablesorter({sortList: [[0,0]], headers: { 3:{sorter: false}, 4:{sorter: false}}});
        // });

(Step 6) // should already be done, by App-Techs.
         Mod to their source: ...\jquery_tablesorter\jquery.tablesorter.js
					$tr.removeClass("list-even")    // 2015-08-21  djg
					$tr.removeClass("list-odd")     // 2015-08-21  djg
                    // Where in their code the above is placed.
						.removeClass( wo.zebra[ even ? 1 : 0 ] )
						.addClass( wo.zebra[ even ? 0 : 1 ] );

(Step 7) Assign following css values:

    .odd  {border-width:1;border-style:solid;border-color:silver;border-width:1px;background-color:#fafaff;}
    .even {border-width:1;border-style:solid;border-color:silver;border-width:1px;background-color:#efefff;}


tr.even .header {
tr.odd td {
tr.even td {
tr.tblSortHdr-even th 

 Programming Links (web) ... [Table Of Contents]

 Perl Programming Language

  1. Perl Home Page (w/download and free books links) ( - (Perl DOCUMENTATION)
  2. Modern Perl (free online book home)
  3. Perl Introduction (
  4. If you are completely new to perl
  5. See if you have Perl installed? "perl -v"
  6. Perl\README.txt
       'Strawberry Perl' is a perl environment for Microsoft Windows containing all you need to run and develop perl
       applications. It is close to the perl environment on UNIX. See
       (note: A text editor to create perl scripts is NOT included with Strawberry Perl.)
  7. In the command prompt window you can:
       (1) run any perl script by launching c:\> perl c:\path\to\
       (2) install additional perl modules (libraries) from by c:\> cpan Module::Name
       (3) run other tools included in Strawberry Perl like: perldoc, gcc, dmake ...
     -  On this system: Complete documentation for Perl, including FAQ lists, use "man perl" or "perldoc perl".
$size = int(size);  # You can also turn strings into integers: 

# Either single or double quotes on the ends of strings. 
# Double quotes tell the language to include variables that have already ben previously defined. 
$flavor = ‘strawberry’; $food = “$flavor ice cream”; Print “I love $food.”; 
# this prints “I love strawberry ice cream.” 
# NOTE: Strings may also be combined with a period.
$variable = ‘I\’m learning.’;
$variable = q[I’m learning.]; 
$length = length($variable); # number of characters in the specified variable.
$chop($variable);   # Removes the last character.
$chomp($ variable); # Removes the last character only if the character is a return.

 Programming Links (w3schools) ... [Table Of Contents]

// JavaScript Dialog Question Box.
// Also see: prompt()
var r=confirm("Press a button!")
if (r==true)
  alert("You pressed OK!")
  alert("You pressed Cancel!")

// alert("Line one \n Line two.")

 Programming Links Technologies ... [Table Of Contents]

 Windows Services

Should pretty simple. Add a service project to your solution, reference your business dlls, spawn some threads or create some kinda loop that does your business logic,stop them on the onstop, add installer (in design view go to properties for service and click on the "Add Installer" button), and then use the install util to install your service.

Here are some links on msdn to help you out.

 TCP IP ... [Table Of Contents]

// Find out where the TcpClient is connected.
string clientIPAddress = ((System.Net.IPEndPoint)_TcpClient.Client.RemoteEndPoint).Address.ToString();
int clientPort = ((System.Net.IPEndPoint)_TcpClient.Client.RemoteEndPoint).Port;

 XML ... [Table Of Contents]

The most useful XPath path expressions are listed below...
Expression Description
nodename Selects all nodes with the name "nodename"
/ Selects from the root node
// Selects nodes in the document from the current node that match the selection no matter where they are
. Selects the current node
.. Selects the parent of the current node
@ Selects attributes

 WPF ... [Table Of Contents]

  • Wpf GridSplitter
  • WPF Tutorial (
  • Walkthrough: Getting Started with WPF
    This walkthrough provides an introduction to the development of a Windows Presentation Foundation (WPF) application
    that includes the elements that are common to most WPF applications: Extensible Application Markup Language (XAML) markup,
    code-behind, application definitions, controls, layout, data binding, and styles.

 VBScript ... [Table Of Contents]

Debug VBScript without running the code
  *  Checking For Script Syntax Errors Eric Lippert’s Blog (
  *  IActiveScriptParse::ParseScriptText and found from

=== VBScript / ASP LOG FILES: on web server box, Desktop link: "IIS LogFiles" to C:\inetpub\logs\LogFiles\W3SVC1 (directory)

=== How To Log Events from Active Server Pages (ASP)
Where Is My Event Log?
• On Windows 2000-based or Windows NT-based systems, you can use the Event Viewer to read event logs. To open Event Viewer, from the Start menu, point to Programs, point to Administrative Tools, and then click Event Viewer. Click Application Log to see if the test event has been logged.

 Current Project ... [Table Of Contents]

Project: MXHistory
From: SDK Support [sdksupport@MILESTONE.DK]
Sent: Tuesday, May 28, 2013 4:38 AM
To: 'Dan Fritsch'; SDK Support; 'David Gradwell'
Subject: RE: can sdk delete recorded video?
Dear Dan,
I am assuming that you use XProtect Enterprise..
The scenario sounds perfect to do the right thing; set down the retention time , see that the footage goes then raise the retention time again. This has to be done in each XProtect server, but is still by far easier than going around deleting archive folders.

1+2) You are right, turn off the Milestone services, delete the 1+archive folders, turn the system back on. I would say that the safe thing is to turn off the system before deleting anything, whether you reboot the server or just restart the services should make no difference.

3) No, the archive paths are not exposed to the MIP SDK. Maybe you will find this logical if you consider that there is no support for any kind of file manipulation or deletion.

If you use XProtect Corporate (one system), you can do all the retention time modification from one Management Client making the "set retention" method even easier! If using Corporate and delete archive folders you will need to delete index files and the rebuild (on startup) might take long.

Yours Sincerely,
Bo Andersen
Senior Support Engineer

 Other Applications ... [Table Of Contents]

WMI Code Creator: stand alone app

 Video ... [Table Of Contents]

 Object Oriented ... [Table Of Contents]

 Code Tips ... [Table Of Contents]

 Tips (Window Versions Compatibility)

 Tips (.Net)

  1. string.Format(CultureInfo.InvariantCulture, "Event triggered: {0} ", eventType)
  2. Auto-generate a try catch block (Visual Studio)
    Type 'try' then press [Tab] once or twice.
  3. Automating Keystroke Tasks with Macros (Visual Studio .NET 2003)
  4. C# Constructors (
    [_]Q: How do I write several constuctors with different signatures?
  5. Setting a Breakpoint When a Variable Changes Value (
  6. Setting a Breakpoint When a Variable Changes Value (broken link)
  7. Operator precedence and associativity (Visual Studio .NET 2003)
  8. C# - Wait for keyboard: Console.ReadKey();
  9. C# - Process messages: Application.DoEvents();
  10. C# - System.Diagnostics.Process.Start("notepad.exe", _fileName); // Wait for exit, see note bellow...
  11. Reusable Templates
  12. DotNet ini alternative: textBoxLog.Font = Properties.Settings.Default.logFileFont;
  13. How to: Add Items to the Toolbox (Visual Studio)
    === To Add to Toolbox: public partial class myUserControl : UserControl
      1)   [?]: Add New 'FormTemp' to your solution. then...
      2)   [*]: In Toolbox's Search, Paste in: 'myUserControl'
// 2018-07-26 :
// To close all your threads you should set all of them to background threads before you start them, then they will be closed automatically when the application exits, e.g.:

Thread myThread = new Thread(...);
myThread.IsBackground = true; // Set your thread to background
A "HOWTO: Stop Multiple Threads" article from microsoft:
    // Wait for exit of Process.Start()
    System.Diagnostics.Process process = System.Diagnostics.Process.Start("notepad.exe", _fileName);
    while (!process.HasExited)
        Application.DoEvents();  // update UI
    // Possibly best way to get dir of current app.
    string curDir = AppDomain.CurrentDomain.BaseDirectory;
    if (curDir.Substring(curDir.Length - 1) != "\\")
        curDir += "\\";
    string xmlFile = curDir + justTheXmlFileName;
    #_region //

    // If the file is small, you can read and write in two code lines.
    var myString = File.ReadAllText("c:\\test.txt");
    File.AppendAllText(Path.Combine("c:\\test2.txt"), myString);

    // If the file is huge, you can read and write line-by - line:
    using (var source = new StreamReader("c:\\test.txt"))
    using (var destination = File.AppendText("c:\\test2.txt"))
        var line = source.ReadLine();
// I see that there are some ways to get the application folder path:
// What is the best way depending on the situation?

 Tips (Miscellaneous) ... [Table Of Contents]

----- var test = parseInt("xyz"); // javascript
    var test = parseInt("xyz");
    if (test <= 0)
        g = "[LE0]";
    else if (test > 0)
        g = "[GT0]";
        g = "[ERROR]"; // this is the result.
----- To create a single- or multiple-instance application
=== First try (
=== Console App possibility ( ... 
    #region === Using Mutex for: "only one instance at a time"
    static System.Threading.Mutex mutex = new System.Threading.Mutex(true, "MXDiscover.RunOnlyOne");
    //static void Main() {
    static void Main(string[] args)
        // === Using Mutex for: "only one instance at a time"
        if (mutex.WaitOne(TimeSpan.Zero, true))
            //Application.Run(new Form1());
            MainWorker(args);  // This is what used to be named 'Main".
            //MessageBox.Show("only one instance at a time");
            Console.WriteLine("only one instance at a time");
        } // end: if (mutex.WaitOne(TimeSpan.Zero, true))
=== Note: (This topic applies only to Visual Basic projects.) (
1. With a project selected in Solution Explorer, on the Project menu, click Properties.
2. Click the Application tab.
3. Under Windows application framework properties, select or clear the Make single instance application check box.
----- Minimize to tray - taskbar notification area (by clock)

-----NSIS Installer

=== D.1 Error Levels
Like other applications, installers made by NSIS return error levels as a result of their execution. 
Checking the error level can be useful if you call an NSIS installer from another application or installer.
 • 0 - Normal execution (no error)
 • 1 - Installation aborted by user (cancel button)
 • 2 - Installation aborted by script

As of NSIS 2.01, you can set the error level to other values using SetErrorLevel.

 Pages to read ... [Table Of Contents]

 Programming Projects ... [Table Of Contents]

 (category template)

Name Notes Language Directory

 Reusable Templates ... [Table Of Contents]

  1. Splash Screen: J:\dev\MediaKiosk\VCS2015\MediaKiosk\mediaViewer\SplashForm.cs

 Red Text Plugin

  1. Red Text Plugin: dev\MXPBridgeWithSrv\VCS2010\Plugins\MXPBridge_Analytics\MXPBridge_Analytics.sln


- Can watch preview of a time span of a camera. Not sure what else it does.

-----2015/03/23 - Latest at: J:\dev\MXHistory\VCS2010\MXHistory\MXHistory.sln
- Currently used command line arg to MXPBridge instead to get camera names.

 MXPBridge (Milestone w/FORUM) ... [Table Of Contents]

How to find things ...

  1. Search Samples ... C:\Program Files\Milestone>findstr /s RegisterCommunicationFilter *.cs
  2. djg: Log.Log: J:\dev\MXPBridgeWithSrv\VCS2010\MXPBridge\MXPBridge\bin\Debug
  3. 179: Mip Dll: C:\Program Files\Milestone\XProtect Event Server\MIPPlugins\ISONAS_IM-ACX
  4. 179: Mip Log: C:\ProgramData\Milestone\XProtect Event Server\logs\MIPLogs
      1) Stop: Milestone XProtect Event Server
      2) Copy: IM-ACX.dll
      3) Start: Milestone XProtect Event Server

(MXPBridge) FORM APPLICATION solution: MXPBridgeWithSrv\VCS2010\MXPBridge\MXPBridge.sln
AssemblyName Conditional compilation symbols This note changed
MXPBridge (exe) notIsonasBrand notPANRServ MXPBRIDGE multiSock notmultiSock1 2017-05-03
IM-ACX (exe) IsonasBrand notPANRServ MXPBRIDGE multiSock notmultiSock1 2017-05-03
IM-ACX_PA (exe) IsonasBrand PANRServ MXPBRIDGE multiSock notmultiSock1 2017-05-03
(MXPBridge) SERVICE solution: MXPBridgeWithSrv\VCS2010\MXPBridgeSrv\MXPBridgeSrv.sln
AssemblyName Conditional compilation symbols This note changed
MXPBridge_Service (exe) notIsonasBrand notPANRServ isService MXPBRIDGE 2017-05-03
IM-ACX_Service (exe) IsonasBrand notPANRServ isService MXPBRIDGE 2017-05-03
IM-ACX_PA_Service (exe) IsonasBrand PANRServ isService MXPBRIDGE 2017-05-03
(MXPB_ACM) PLUGIN solution: MXPBridgeWithSrv\VCS2010\Plugins\MXPB_ACM\MXPB_ACM.sln
AssemblyName Conditional compilation symbols This note changed
MXPBridge(?) (dll) PLUGIN,SAME_APID 2017-05-03
IM-ACX (dll) PLUGIN,SAME_APID 2017-05-03
(Inovonics) FORM APPLICATION solution: Inovonics\VCS2015\FromIsonas\IVNRServ_3\IVNRServ_3.sln
AssemblyName Conditional compilation symbols This note changed
IVNRServ (exe) multiSock 2017-06-28
IVNRServ_Service (dll) ???? 2017-06-28
NOTE: This is App-Tech's 1st service solution with a separate project
for the service. (why this may be a good template.)
Q[_]: Will this cause a conflict for 'Conditional compilation symbols'?
____: A better solution might be to put both the form's project and the service in a new project. The original form folder structure identical to the original, but link in all the src files (as was done for MXPBridge's, and PANRServ's service solutions. And in this new project to have one root folder to store all the service files.
(PhoneHomeMonitor) FORM APPLICATION solution: HUM\VCS2015\PhoneHomeMonitor\PhoneHomeMonitor.sln
AssemblyName Conditional compilation symbols This note changed
MXPBridge (exe) notIsonasBrand notPANRServ MXPBRIDGE multiSock notmultiSock1 2017-05-03
IM-ACX (exe) IsonasBrand notPANRServ MXPBRIDGE multiSock notmultiSock1 2017-05-03
IM-ACX_PA (exe) IsonasBrand PANRServ MXPBRIDGE multiSock notmultiSock1 2017-05-03
(PhoneHomeMonitorSrv) SERVICE solution: HUM\VCS2015\PhoneHomeMonitorSrv\PhoneHomeMonitorSrv.sln
  (PhoneHomeMonitorSrv Started with copy of: Inovonics\VCS2015\FromIsonas\IVNRServ_3Srv)
AssemblyName Conditional compilation symbols This note changed
MXPBridge_Service (exe) notIsonasBrand notPANRServ isService MXPBRIDGE 2017-05-03
IM-ACX_Service (exe) IsonasBrand notPANRServ isService MXPBRIDGE 2017-05-03
IM-ACX_PA_Service (exe) IsonasBrand PANRServ isService MXPBRIDGE 2017-05-03


Name Notes Language Directory
  BothBrand dir . . J:\dev\MXPBridgeWithSrv\VCS2010\MXPBridge\MXPBridge\bin\Release\BothBrands
  IsonasBrand IM-ACX_Service.exe    
  MXPBridge Brand MXPBridge_Service.exe    
  IsonasBrand IM-ACX_logo.jpg optional For AboutBox. Place in exe directory.
  (NotIsonasBrand) MXPBridge_logo.jpg optional For AboutBox. Place in exe directory.
  FormApp Needs allowed. Firewall Incomming ports like Service Channel port.
  Point to
 configuration  Enter IP-addr of MXPBridge pc.
  Point to
 Milestone.Managment.AccessControlNode  configuration  Enter IP-addr of MXPBridge pc.
  IM-ACX_Service.exe  J:\dev\MXPBridgeWithSrv\VCS2010\MXPBridgeSrv\WindowsService1\bin\Release

 Smart Client Overlay On Event (Analytics) = MXPBridge_Analytics.dll ... [Table Of Contents]

Development: Solution in: MXPBridgeWithSrv\VCS2010\Plugins\MXPBridge_Analytics\bin\Release\MXPBridge_Analytics.dll  
On 179 Place dll in: C:\Program Files\Milestone\XProtect Smart Client\MIPPlugins\SCOverlayOnEvent  

 HUM & hum_config ... [Table Of Contents]

Name Notes Language Directory
 HUM.exe  Development solution  C#  J:\dev\HUM\VCS2010\HUM\HUM.sln
 hum_config.exe  Development solution  C#  J:\dev\HUM\VCS2010\hum_config\hum_config.sln
 HUM & hum_config
 Installer Source code origin
for both HUM & hum_config
 2015-07-14  K:\users\support\Vendor_Video\App-Techs\HUM\installer\installer\Setup_HUM.nsi
 HUM & hum_config
 Installer Source code origin
for both HUM & hum_config
 C#  J:\dev\HUM\installer\release_20150119\HUM
contains five subdirectories.
 HUM & hum_config
 ini & lic file origin
?? for both HUM & hum_config ??
 ini, lic
text files
This dir subject to change. May need more than one of these type directories.
 HUM & hum_config
 Installer nsi file(s)  nsis-3.0b1  J:\dev\HUM\installer\nsis
 HUM & hum_config
 Installer install to dir, for both HUM & hum_config.  nsis-3.0b1 / C#  C:\app-techs\HUM
will contain same five subdirectories.

 Media Viewer

Name Notes Language Directory
Media Viewer
Slide Show App
Bak: H:\users\dgradwell\VCS2010 C# 2010 E:\VCS2010\apptech\mediaViewer07_djg
Media Viewer
Slide Show App
Bak: H:\users\dgradwell\VCS2008 C# 2008 E:\VCS2008\apptech\mediaViewer06

 dmap3 - w/GoogleMapsApi ... [Table Of Contents]

Name Notes Language Directory
deviceMapNewM_Test.asp Copied from deviceMapNewMaster.asp asp & googleMaps W:\demo\dmap3\

Panasonic KX-CL500 PCL 5c ... [Table Of Contents]

1) Use File Menu. Select Print. Choose Multi-Purpose-Tray.

2) Select Quantity. And click Print.

3) Print-side-down. Top-of-page into printer first, in the
   manual-feed-fold-out tray, one at a time.