TOPIC: Command Line Replacements using C#

Command Line Replacements using C# 30 Aug 2011 19:59 #871

  • sduranceau
  • sduranceau's Avatar
  • Offline
Hello.
This is how you would use a C# form application for Command Line Replacements.
You will need to replace the variables in this code to work with your .rrd of course.
Keep in mind, “PRINTER_NAME” is the variable of the printer you chose in your .RRD (In this case, it was %PRINTER_NAME% )
string LogicityDesktopPath = @"C:\Program Files\SaberLogic\Logicity\Logicity Desktop.exe";
string RRDPath = @"<LOCATION OF RRD FILE>";

        private void bttnReports_Click(System.Object sender, System.EventArgs e)
        {
            // Check path to Logicity Desktop
            System.IO.FileInfo logicityPath = new System.IO.FileInfo(LogicityDesktopPath);
            if (logicityPath.Exists == false)
            {
                MessageBox.Show("Logicity Desktop is not installed at " + LogicityDesktopPath + ".  Please check the application configuration file.");
                return;
            }

            // Check path to RRD
            System.IO.FileInfo rrdPath = new System.IO.FileInfo(RRDPath);
            if (rrdPath.Exists == false)
            {
                MessageBox.Show("RRD is not installed at " + RRDPath + ".  Please check the application configuration file.");
                return;
            }

            System.Diagnostics.ProcessStartInfo startInfo = null;
            System.Diagnostics.Process pStart = new System.Diagnostics.Process();

            startInfo = new System.Diagnostics.ProcessStartInfo(LogicityDesktopPath, "\"" + RRDPath + "\"" + " PRINTER_NAME=<PRINTER NAME HERE>");
            pStart.StartInfo = startInfo;

            try
            {
                pStart.Start();
            }
            catch (Exception ex)
            {
                // Display error
                MessageBox.Show("Error: " + ex.ToString());
            }
        }


I hope this works for you!

- Devin Ellis
Last Edit: 30 Aug 2011 20:00 by sduranceau.
The administrator has disabled public write access.