Example #1
0
        public Boolean ConnectToMatric()
        {
            SampleSimConnect.Form1.Global.statusLabelMatric = "Attempting to connect to MATRIC..";
RetryMatricAuth:
            if (!MatricIntegration.CheckMatricAuthorized())
            {
                string msg = $@"
                {{""command"":""CONNECT"", 
                    ""appName"":""{APP_NAME}""}}
                ";
                UDPSend(msg);
                SampleSimConnect.Form1.Global.statusLabelMatric = "Interface not authorised by MATRIC..";
                DialogResult dialogResult = MessageBox.Show("You need to authorise this app in MATRIC, please confirm in the MATRIC application and then click Retry to try again.", "Please authorise app", MessageBoxButtons.RetryCancel);
                if (dialogResult == DialogResult.Retry)
                {
                    goto RetryMatricAuth;
                }
                SampleSimConnect.Form1.Global.statusLabelMatric = "Could not confirm authority to connect..";
                Form1.StatusMatric = false;
                return(false);
            }
            else
            {
                SampleSimConnect.Form1.Global.statusLabelMatric = "Connection established..";
                Form1.StatusMatric = true;
                return(true);
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Environment.GetCommandLineArgs(); //allow command line switches

                foreach (string arg in args)
                {
                    switch (arg.Substring(0, 2).ToUpper())
                    {
                    case "-DEBUG":
                        StartDebug();
                        break;

                    default:
                        //StartDebug(); //for dev
                        break;
                    }
                }

                Stream myFile = File.Create("debug.log");
                Trace.AutoFlush = true;
                Trace.Listeners.Add(new TextWriterTraceListener("debug.log"));

                try
                {
                    //open the connection to Matric
                    mtrx = new MatricIntegration();

                    mtrx.ConnectToMatric();

                    if (Form1.StatusMatric)
                    {
                        //Console.WriteLine("GetConnectedClients");
                        mtrx.GetConnectedClients();
                    }
                }
                catch
                {
                    MessageBox.Show("Unable to connect to MATRIC, Please start MATRIC and try again.");
                    Form1.setStatusMatric(false);
                    Trace.TraceError("Unable to connect to MATRIC");
                }

                Application.Run(new Form1());
            } catch (Exception e)
            {
                Trace.TraceError(e.Message);
            }
        }