string ProcessThread_1() { try { string msg = string.Empty; //ServiceInstaller.Uninstall("GojiWCFStreamingServer"); if (ServiceInstaller.ServiceIsInstalled("GojiWCFStreamingServer") == true) { ServiceInstaller.StopService("GojiWCFStreamingServer"); label2.Text = "Stop service"; for (int i = 0; i < 18; i++) { if (ServiceInstaller.getStatus("GojiWCFStreamingServer") == "Stopped") { break; } label2.Text += "."; Thread.Sleep(1000); } if (ServiceInstaller.getStatus("GojiWCFStreamingServer") == "Running") { msg = "Service GojiWCFStreamingServer not stopped"; MessageBox.Show(msg); return("ok"); } } DeleteAllFiles(); Listener listen = new Listener(progressBar1, label2); listen.Subscribe(); FebrisInstaller.Unzip(true); // FebrisInstaller.CreateShortcuts(true); label2.Text = string.Empty; label2.Refresh(); msg = "Installation endded successfuly"; //ReplaceIPAddressInConfigFile(@"C:\Program Files\Goji Solutions\GojiLTDTrunk\WCF Streaming\GojiWCFStreamingServer\bin\Release", // "GojiWCFStreamingServer.exe.config"); ///////////////// INSTALL GojiWCFStreamingServer Service ///////////////////// if (ServiceInstaller.ServiceIsInstalled("GojiWCFStreamingServer") == false) { ServiceInstaller.InstallAndStart("GojiWCFStreamingServer", "Goji WCF Streaming server", @"C:\Program Files\Goji Solutions\GojiLTDTrunk\WCF Streaming\GojiWCFStreamingServer\bin\Release\GojiWCFStreamingServer.exe"); label2.Text = "Install and start service"; for (int i = 0; i < 8; i++) { if (ServiceInstaller.getStatus("GojiWCFStreamingServer") == "Running") { break; } label2.Text += "."; Thread.Sleep(1000); } if (ServiceInstaller.getStatus("GojiWCFStreamingServer") != "Running") { msg = "Service GojiWCFStreamingServer did not started"; } } else { ServiceInstaller.StartService("GojiWCFStreamingServer"); label2.Text = "Start service"; for (int i = 0; i < 5; i++) { if (ServiceInstaller.getStatus("GojiWCFStreamingServer") == "Running") { break; } label2.Text += "."; Thread.Sleep(1000); } if (ServiceInstaller.getStatus("GojiWCFStreamingServer") != "Running") { msg = "Service GojiWCFStreamingServer did not started"; } } AuthorizeApplication("GojiWCFStreamingServer", @"C:\Program Files\Goji Solutions\GojiLTDTrunk\WCF Streaming\GojiWCFStreamingServer\bin\Release\GojiWCFStreamingServer.exe", NET_FW_SCOPE_.NET_FW_SCOPE_ALL, NET_FW_IP_VERSION_.NET_FW_IP_VERSION_ANY); ///////////////////////////////////////////////////////// if (false) { label2.Text = "Sensing mail.."; string ipInfo = getComputerIP().ToString(); SendEmail.Send("*****@*****.**", "Eli Arad", "Goji WCF Streaming server", msg + Environment.NewLine + ipInfo); label2.Text = "mail sent."; } return(msg); } catch (Exception err) { return(err.Message); } }
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); } }