Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi
Doing app for Engineering Change Management.

What I need to do is email users once a change has been initiated, and then again as each successive user approves the change.

What I would like is for users to be able to click something in the email, which would launch the app, and pass the Change note Number to the app, so that when it opens, it has already retrieved the info for that specific ECN number that requires their attention.

A web app would probably be the easiest, and then simply put a link in the mail, but I've never done a web app before, and I need to try to complete this before Monday morning - so that is NOT an option.

Was thinking along the lines of attaching a text file with a specific extension (like *.ecn) that contains one line only - the ecn number, and then associating the extension with my app. Sort of like getting the ECN number from the file, and using this as a command line parameter.

The app also has to be able to open on its own as well though.

Is this a viable option, and how could I achieve this?

Thanks

Richard
Posted

Thats probably the quickest option...

If doing a windows forms application, you can do something like this:

First, create a new Windows Forms application, then in the Program.cs file you can do

C#
static void Main(string[] args)
{
    string ecnNumber = string.empty;
    if (args.Length > 1)
    {
        ecnNumber = System.IO.File.ReadAllText(args[1]);
    }

    //... 

    WhateverYourFormType myForm = new WhateverYourFormType();
    myForm.ECNNumber = ecnNumber;

    Application.Run(myForm);
}

//In your WhateverYourFormType you have...
public class WhateverYourFormType : Form
{
    public string ECNNumber { get; set; }

    public override void OnShown(EventArgs e)
    {
        if (!string.IsNullOrEmpty(ECNNumber))
        {
            //Load your ECN information
        }
    }
}
 
Share this answer
 
v2
Hi Ron

I've already done lots of work on the form. Do I start again or am I heading in the right direction here:

In program.cs
C#
namespace ECN_Manager
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {

            string ecnNumber = "";
            if (args.Length > 1)
            {
                ecnNumber = System.IO.File.ReadAllText(args[1]);
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Form1 myForm = new Form1();
            myForm.ECNNumber = ecnNumber; 

            Application.Run(myForm);
        }
    }
}


In Form1.cs

namespace ECN_Manager
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public string ECNNumber { get; set; }

        public override void OnShown(EventArgs e)    //This is what I edited
        {
            if (!string.IsNullOrEmpty(ECNNumber))
            {
                this.txtECNNo.Text = ECNNumber;
            }
        }

        
    }
}

but getting error on: "public override void OnFormShown(EventArgs e)" (No Siutable method found to Override)

Not that familiar with C#, but could I not put an optional parameter in the constructor?

<pre lang="c#">
 public Form1(optional string ECNNumber)
        {
            InitializeComponent();
        }
 
Share this answer
 
v2
Comments
Ron Beyer 12-Oct-13 21:36pm    
I apologize, I had the wrong method name, I edited your solution and fixed it.

If you want to have the ECN in the constructor, it would be formed like this:

public Form1(string ECNNumber = "")

optional is a keyword in VB but not c#
Richard.Berry100 13-Oct-13 1:45am    
Thanks Ron - appreciated. I ran into a brick wall with the file association - I'm using clickonce deployment. It also seems there are different ways to get the info of the file clicked when using clickonce. Somthing along the lines of:
string[] activationData =
AppDomain.CurretnDomain.SetupInformation.ActivationArguments.ActivationData;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900