private void cleanupNMTToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string Warning = "";
            string Command = Settings.Default.CommandsScriptURL.Substring(Settings.Default.CommandsScriptURL.LastIndexOf('/') + 1);

            Command = Command.Substring(0, Command.Length - 3) + "cgi";
            string WarningTitle = "";

            if (sender == shutdownNMTToolStripMenuItem)
            {
                Warning      = Resources.MessageBox_HaltWarning;
                WarningTitle = Resources.MessageBox_HaltWarningCaption;
                Command     += "?halt";
            }
            else
            if (sender == cleanupNMTDeepToolStripMenuItem)
            {
                Warning      = Resources.MessageBox_DeepCleanWarning;
                WarningTitle = Resources.MessageBox_DeepCleanCaption;
                Command     += "?deepclean";
            }
            else
            if (sender == cleanupNMTToolStripMenuItem)
            {
                Warning      = Resources.MessageBox_CleanWarning;
                WarningTitle = Resources.MessageBox_CleanCaption;
                Command     += "?clean";
            }
            else
            {
                Warning     += Resources.MessageBox_RestartNMTConfirm;
                WarningTitle = Resources.MessageBox_RestartNMTCaption;
                Command     += "?reboot";
            }

            if (MessageBox.Show(Warning, WarningTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                try
                {
                    btnPrev.Enabled = btnNext.Enabled = btnExit.Enabled = menuStrip1.Enabled = false;
                    Application.DoEvents();
                    string LocalFolder = HttpCommands.DownloadHTTPFileAndExtract(Settings.Default.CommandsScriptURL, Constants.TemporaryFolder, true, null);

                    RepositoryApplicationInfo app    = new RepositoryApplicationInfo(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, new string[0], Command, string.Empty, string.Empty);
                    UploadInstaller           ulinst = new UploadInstaller(app, ProgressChanges, OnInstallComplete);
                    ulinst.Install();
                }
                catch (Exception ex)
                {
                    menuStrip1.Enabled = true;
                    UpdateButtonState();
                    Logger.GetInstance().AddLogLine(LogLevel.Error, "Cleanup or restart of NMT failed", ex);
                    MessageBox.Show(Resources.MessageBox_CleanupActionFailed, Resources.MessageBox_CleanupActionCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #2
0
        public override bool Execute()
        {
            if ((SelectedItem != null) && (SelectedItem is RepositoryFileInfoBase) && ((SelectedItem.DownloadURL.Length > 0) || (SelectedItem is RepositoryWebserviceInfo)))
            {
                string LocalFolder = Constants.TemporaryFolder;

                try
                {
                    if (!(SelectedItem is RepositoryWebserviceInfo))
                    {
                        string DownloadURL = ((RepositoryFileInfoBase)SelectedItem).DownloadURL;
                        LocalFolder = HttpCommands.DownloadHTTPFileAndExtract(DownloadURL, Constants.TemporaryFolder, true, OnProgress);
                    }

                    //download installprepare when installing an application, waitimage or webservice
                    if ((SelectedItem is RepositoryApplicationInfo) || (SelectedItem is RepositoryWaitImagesInfo) || (SelectedItem is RepositoryWebserviceInfo))
                    {
                        HttpCommands.DownloadHTTPFileAndExtract(Settings.Default.InstallPrepareScriptURL, LocalFolder, false, null);
                    }

                    //download AppInit during installation of Application
                    if (SelectedItem is RepositoryApplicationInfo)
                    {
                        HttpCommands.DownloadHTTPFileAndExtract(Settings.Default.AppInitScriptURL, LocalFolder, false, null);
                    }

                    panelResults.Remove("SelectedItem");
                    panelResults.Remove("ThemeFormat");
                    panelResults.Add("SelectedItem", SelectedItem);
                    if (SelectedItem is RepositoryThemeInfo)
                    {
                        if (cbxThemeFormat.SelectedIndex == 0)
                        {
                            panelResults.Add("ThemeFormat", "HD");
                        }
                        else
                        {
                            panelResults.Add("ThemeFormat", "SD");
                        }
                    }

                    return(true);
                }
                catch (Exception ex)
                {
                    Logger.GetInstance().AddLogLine(LogLevel.Error, "Error while trying to download installation files", ex);
                    MessageBox.Show(Resources.MessageBox_DownloadPackageFailed, Resources.MessageBox_DownloadPackageCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }
            else
            {
                return(SelectedItem is RepositoryWebserviceInfo);
            }
        }
        private void installFirmwareToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(Resources.MessageBox_InstallFirmwareWarning, Resources.MessageBox_InstallFirmwareCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                OpenFileDialog odf = new OpenFileDialog();
                odf.Title  = Resources.FileDialog_SelectFirmwareFileCaption;
                odf.Filter = Resources.FileDialog_SelectFirmwareFileFilter;
                if (odf.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        string LocalFolder = Constants.TemporaryFolder;
                        if (Directory.Exists(LocalFolder))
                        {
                            Directory.Delete(LocalFolder, true);
                        }
                        Directory.CreateDirectory(LocalFolder);

                        File.Copy(odf.FileName, LocalFolder + "firmware.zip");
                        SimpleUnZipper.UnZipTo(LocalFolder + "firmware.zip", LocalFolder);

                        File.Delete(LocalFolder + "firmware.zip");

                        if ((Directory.GetFiles(LocalFolder).Length == 0) && (Directory.GetDirectories(LocalFolder).Length == 1))
                        {
                            LocalFolder = Directory.GetDirectories(LocalFolder)[0] + Path.DirectorySeparatorChar;
                        }
                        HttpCommands.DownloadHTTPFileAndExtract(Settings.Default.CommandsScriptURL, LocalFolder, false, ProgressChanges);

                        btnPrev.Enabled = btnNext.Enabled = btnExit.Enabled = menuStrip1.Enabled = false;
                        Application.DoEvents();
                        RepositoryApplicationInfo app    = new RepositoryApplicationInfo(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, new string[0], "commands.cgi?firmwareinstall", string.Empty, string.Empty);
                        UploadInstaller           ulinst = new UploadInstaller(app, ProgressChanges, OnInstallComplete);
                        ulinst.Install();
                    }
                    catch (Exception ex)
                    {
                        menuStrip1.Enabled = true;
                        UpdateButtonState();
                        Logger.GetInstance().AddLogLine(LogLevel.Error, "Installing firmware failed", ex);
                        MessageBox.Show(Resources.MessageBox_InstallFirmwareFailed, Resources.MessageBox_InstallFirmwareCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Пример #4
0
        public override bool Execute()
        {
            errorProvider.Clear();
            if (!Regex.Match(tbName.Text, @"^[0-9A-Za-z\s]+$").Success)
            {
                errorProvider.SetError(tbName, Resources.Validate_InvalidWebserviceName);
                return(false);
            }

            if (!Regex.Match(tbURL.Text, @"^http://(?<www>.*?\.)?(?<name>.*)\.(?<tld>.{2,})").Success)
            {
                errorProvider.SetError(tbURL, Resources.Validate_InvalidWebserviceURL);
                return(false);
            }

            string LocalFolder = HttpCommands.DownloadHTTPFileAndExtract(Settings.Default.InstallPrepareScriptURL, Constants.TemporaryFolder, true, null);

            panelResults.Remove("SelectedItem");
            panelResults.Add("SelectedItem", new RepositoryWebserviceInfo(tbName.Text, "", "", "", "", "", "", "", "", "", new string[0], tbURL.Text));
            return(true);
        }
Пример #5
0
        public override bool Execute()
        {
            if (!cbxDoNotUpdate.Checked)
            {
                try
                {
                    //remove update file if still present
                    if (File.Exists(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar + Settings.Default.CSIUpdateArchiveURL.Substring(Settings.Default.CSIUpdateArchiveURL.LastIndexOf('/') + 1)))
                    {
                        File.Delete(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar + Settings.Default.CSIUpdateArchiveURL.Substring(Settings.Default.CSIUpdateArchiveURL.LastIndexOf('/') + 1));
                    }

                    //moveout all current exe and dll's
                    foreach (string fileName in Directory.GetFiles(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "*.exe", SearchOption.AllDirectories))
                    {
                        File.Move(fileName, fileName + ".old");
                    }
                    foreach (string fileName in Directory.GetFiles(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "*.dll", SearchOption.AllDirectories))
                    {
                        File.Move(fileName, fileName + ".old");
                    }

                    HttpCommands.DownloadHTTPFileAndExtract(Settings.Default.CSIUpdateArchiveURL, Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar, false, OnProgress);

                    Process.Start(Assembly.GetEntryAssembly().Location);
                    ((Form)this.Parent.Parent).Close();
                }
                catch (Exception ex)
                {
                    Logger.GetInstance().AddLogLine(LogLevel.Error, "Exception during update process", ex);
                    MessageBox.Show(Resources.MessageBox_CsiUpdateFailed, Resources.MessageBox_CsiUpdatesCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return(false);
            }
            else
            {
                return(true);
            }
        }
Пример #6
0
        public override bool Execute()
        {
            if (gbxApplication.Visible)
            {
                SelectedItem = new RepositoryApplicationInfo(Resources.InstallItem_ApplicationString, "", "", "", "", "", "", "", "", "", new string[0], cbxInstallScript.Text + tbInstallScriptParameters.Text, "", "");
            }

            if (SelectedItem != null)
            {
                if (SelectedItem is RepositoryThemeInfo)
                {
                    if (cbxThemeFormat.Text == Resources.Text_HighDefinition)
                    {
                        panelResults.Add("ThemeFormat", "HD");
                    }
                    else
                    {
                        panelResults.Add("ThemeFormat", "SD");
                    }
                }

                panelResults.Add("SelectedItem", SelectedItem);
            }


            if ((SelectedItem is RepositoryApplicationInfo) || (SelectedItem is RepositoryWaitImagesInfo))
            {
                HttpCommands.DownloadHTTPFileAndExtract(Settings.Default.InstallPrepareScriptURL, Constants.TemporaryFolder, false, null);
            }

            if (SelectedItem is RepositoryApplicationInfo)
            {
                HttpCommands.DownloadHTTPFileAndExtract(Settings.Default.AppInitScriptURL, Constants.TemporaryFolder, false, null);
            }

            return(SelectedItem != null);
        }