Ejemplo n.º 1
0
        public Form1()
        {
            InitializeComponent();
            Control.CheckForIllegalCrossThreadCalls = false;

            NetCard.NetCard n         = new NetCard.NetCard();
            string          ipAddress = n.getComputerIP();
            clsRegistry     reg       = new clsRegistry();

            if (ipAddress == "0.0.0.0")
            {
                string bip = reg.GetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Field", "IpAddress");
                if (reg.strRegError == null)
                {
                }
                else
                {
                    GetManualIpAddress g = new GetManualIpAddress();
                    if (g.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        ipAddress = g.IpAddress;
                        reg.SetStringValue(Registry.LocalMachine, "SOFTWARE\\Goji solutions\\Field", "IpAddress", ipAddress);
                    }
                }
            }
            label5.Visible = true;
            label5.Text    = ipAddress;
            label1.Text    = "Goji MPFM Watson WCF Field installation version " + Properties.Settings.Default.WatsonInstallerVersion;
            ThreadedExecuter <string> executer = new ThreadedExecuter <string>(ProcessThread_1, ThreadCompleted);

            executer.Start();
        }
Ejemplo n.º 2
0
        string ProcessThread_1()
        {
            try
            {
                //ServiceInstaller.Uninstall("PhidgetWCFWinService");
                //ServiceInstaller.Uninstall("WatsonWCFWinService");
                //ServiceInstaller.Uninstall("GojiWCFStreamingClient");
                //ServiceInstaller.Uninstall("GojiMPFMWatsonService");

                if (ServiceInstaller.ServiceIsInstalled("GojiWCFStreamingClient") == true)
                {
                    ServiceInstaller.StopService("GojiWCFStreamingClient");
                    for (int i = 0; i < 5; i++)
                    {
                        if (ServiceInstaller.getStatus("GojiWCFStreamingClient") != "Stopped")
                        {
                            label4.Text += ".";
                            Thread.Sleep(1000);
                            continue;
                        }
                        break;
                    }
                }

                label4.Visible = true;

                label4.Text = "";
                if (Directory.Exists(@"C:\Program Files\Goji Solutions\GojiLTDTrunk\WCF Streaming\GojiWCFStreamingClient\bin\Release"))
                {
                    try
                    {
                        if (ServiceInstaller.ServiceIsInstalled("GojiWCFStreamingClient") == true)
                        {
                            ServiceInstaller.Uninstall("GojiWCFStreamingClient");
                        }
                    }
                    catch (Exception err)
                    {
                        throw (new SystemException(err.Message));
                    }
                    try
                    {
                        DeleteOldVersion(@"C:\Program Files\Goji Solutions\GojiLTDTrunk\WCF Streaming\GojiWCFStreamingClient\bin\Release");
                        Directory.Delete(@"C:\Program Files\Goji Solutions\GojiLTDTrunk\WCF Streaming\GojiWCFStreamingClient\bin\Release");
                    }
                    catch (Exception err)
                    {
                    }
                }

                int tryTimes  = 15;
                int delayTime = 2500;

                string deleteError = string.Empty;
                label4.Visible = false;
                label4.Text    = string.Empty;
                deleteError    = string.Empty;
                for (int i = 0; i < tryTimes; i++)
                {
                    try
                    {
                        DeleteOldVersion(@"C:\Program Files\Goji Solutions\GojiLTDTrunk\WCF Streaming\GojiWCFStreamingField\GojiWCFStreamingClient\bin\Release");
                        deleteError = string.Empty;
                        break;
                    }
                    catch (Exception err)
                    {
                        label3.Visible = true;
                        label4.Visible = true;
                        label4.Text   += ".";
                        deleteError    = err.Message;
                        Refresh();
                        Thread.Sleep(delayTime);
                    }
                }
                if (deleteError != string.Empty)
                {
                    return("Error delete file: " + deleteError);
                }
                label4.Visible = false;
                label4.Text    = string.Empty;
                deleteError    = "";
                label3.Visible = false;
                Listener listen = new Listener(progressBar1, label2);
                listen.Subscribe();

                FebrisInstaller.Unzip(true);
                FebrisInstaller.CreateShortcuts(true);
                label2.Text = string.Empty;
                label2.Refresh();

                string msg = "Installation endded successfuly";
                ///////////////// INSTALL GojiWCFStreamingClient  Service /////////////////////
                if (ServiceInstaller.ServiceIsInstalled("GojiWCFStreamingClient") == false)
                {
                    ServiceInstaller.InstallAndStart("GojiWCFStreamingClient", "Goji WCF Streaming client", @"C:\Program Files\Goji Solutions\GojiLTDTrunk\WCF Streaming\GojiWCFStreamingField\GojiWCFStreamingClient\bin\Release\GojiWCFStreamingClient.exe");
                    Thread.Sleep(1000);
                    if (ServiceInstaller.getStatus("GojiWCFStreamingClient") != "Running")
                    {
                        msg = "Service GojiWCFStreamingClient did not started";
                    }
                }
                else
                {
                    bool started = false;
                    for (int i = 0; i < 3; i++)
                    {
                        ServiceInstaller.StartService("GojiWCFStreamingClient");
                        Thread.Sleep(1000);
                        if (ServiceInstaller.getStatus("GojiWCFStreamingClient") != "Running")
                        {
                        }
                        else
                        {
                            started = true;
                            break;
                        }
                    }
                    if (started == false)
                    {
                        msg = "Service GojiWCFStreamingClient did not started";
                    }
                }

                AuthorizeApplication("GojiWCFStreamingClient", @"C:\Program Files\Goji Solutions\GojiLTDTrunk\WCF Streaming\GojiWCFStreamingField\GojiWCFStreamingClient\bin\Release\GojiWCFStreamingClient.exe",
                                     NET_FW_SCOPE_.NET_FW_SCOPE_ALL,
                                     NET_FW_IP_VERSION_.NET_FW_IP_VERSION_ANY);
                /////////////////////////////////////////////////////////

                if (false)
                {
                    label2.Text = "Sensing mail..";
                    NetCard.NetCard n      = new NetCard.NetCard();
                    string          ipInfo = n.getComputerIP();
                    SendEmail.Send("*****@*****.**", "Eli Arad", "Watson field installer", msg + Environment.NewLine + ipInfo);
                    label2.Text = "mail sent.";
                }

                return(msg);
            }
            catch (Exception err)
            {
                return(err.Message);
            }
        }