Example #1
0
        private void WizardPageLogin_Commit(object sender, AeroWizard.WizardPageConfirmEventArgs e)
        {
            //Point p = System.Windows.Forms.Cursor.Position;
            //Point p1 = new Point();
            //p1.X = p.X - this.DesktopLocation.X ;
            //p1.Y = p.Y - this.DesktopLocation.Y ;
            //Program.logIt($"position: {p1} on N {theRect}: {theRect.Contains(p1)}");

            if (wizardPageLogin.Tag == null)
            {
                this.Enabled   = false;
                Cursor.Current = Cursors.WaitCursor;
                e.Cancel       = true;
                // start log in process
                Task t = Task.Run(() =>
                {
                    try
                    {
                        // log in
                        string dir = System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "hydra");
                        System.IO.File.Delete(System.IO.Path.Combine(dir, "HydraLogin.xml"));
                        string exe   = System.IO.Path.Combine(dir, "HydraLogin.exe");
                        string param = $"-u={textBoxUsername.Text} -p={textBoxPassword.Text}";
                        if (System.IO.File.Exists(exe))
                        {
                            System.Collections.Specialized.StringDictionary envs = new System.Collections.Specialized.StringDictionary();
                            envs.Add("APSTHOME", System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA"));
                            //Tuple<int, string[]> res = Program.run_exe(@"c:\windows\system32\notepad.exe", param, envs);
                            Tuple <int, string[]> res = Program.run_exe(exe, param, envs);
                            if (res.Item1 == 0)
                            {
                                // login success, run OE
                                //Task tt = Task.Run(() =>
                                //{
                                //    string exe1 = System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "iLauncher.exe");
                                //    string param1 = $"-desktop=test -exe=\"{System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "AviaToolset.exe")}\" -args=\"-oecontrol -start\"";
                                //    Process p = new Process();
                                //    p.StartInfo.FileName = exe1;
                                //    p.StartInfo.Arguments = param1;
                                //    p.StartInfo.UseShellExecute = false;
                                //    p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                                //    p.StartInfo.CreateNoWindow = true;
                                //    p.Start();
                                //});
                                if (System.IO.File.Exists(System.IO.Path.Combine(dir, "HydraLogin.xml")))
                                {
                                    utility.IniFile config = new utility.IniFile(System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "config.ini"));
                                    // load xml
                                    try
                                    {
                                        XmlDocument doc = new XmlDocument();
                                        doc.Load(System.IO.Path.Combine(dir, "HydraLogin.xml"));
                                        string uid = doc.DocumentElement?["id"]?.InnerText;
                                        config.WriteValue("config", "uid", uid);
                                        //tt.Wait();
                                        wizardControl1.Invoke(new Action(() =>
                                        {
                                            wizardControl1.NextPage();
                                        }));
                                        // clear ini device section
                                        utility.IniFile ini = new utility.IniFile(System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("FDHOME"), "AVIA", "aviaDevice.ini"));
                                        ini.DeleteSection("device");
                                        // OE Control start
                                        OEControl.start();
                                    }
                                    catch (Exception) { }
                                }
                            }
                            else
                            {
                                wizardControl1.Invoke(new Action(() =>
                                {
                                    labelLoginStatus.Text    = $"Fail to login, error code: {res.Item1}";
                                    labelLoginStatus.Visible = true;
                                }));
                            }
                        }
                    }
                    catch (Exception) { }
                    finally
                    {
                        this.Invoke(new Action(() =>
                        {
                            this.Enabled        = true;
                            wizardPageLogin.Tag = null;
                        }));
                        //wizardPageLogin.Tag = null;
                    }
                });
                wizardPageLogin.Tag = t;
            }
            else
            {
                wizardPageLogin.Tag = null;
            }
        }
Example #2
0
 private void ButtonStart_Click(object sender, EventArgs e)
 {
     OEControl.start();
 }