private bool CSIUpdateAvailable()
        {
            try
            {
                string OnlineVersion = HttpCommands.GetHttpFileContent(Settings.Default.CSIUpdateVersionURL, null);
                panelResults.Remove("OnlineVersion");
                panelResults.Add("OnlineVersion", new Version(OnlineVersion));

                if (new Version(OnlineVersion) != Assembly.GetEntryAssembly().GetName().Version)
                {
                    ShowTempPanelAtLocation(0, new pnlCSIUpgrade(panelResults, ProgressChanges));
                    return(true);
                }
            }
            catch (Exception ex) { Logger.GetInstance().AddLogLine(LogLevel.Error, "Primary check for new update version failed.", ex); }
            try
            {
                string OnlineVersion = HttpCommands.GetHttpFileContent(Settings.Default.CSIUpdate2VersionURL, null);
                panelResults.Remove("OnlineVersion");
                panelResults.Add("OnlineVersion", new Version(OnlineVersion));

                if (new Version(OnlineVersion) != Assembly.GetEntryAssembly().GetName().Version)
                {
                    ShowTempPanelAtLocation(0, new pnlCSIUpgrade(panelResults, ProgressChanges));
                    return(true);
                }
            }
            catch (Exception ex) { Logger.GetInstance().AddLogLine(LogLevel.Error, "Can't check for new update version", ex); }
            return(false);
        }
Пример #2
0
 private CatalogNetInstance[] GetInstances()
 {
     try
     {
         string url = _tag.ToString();
         if (!url.EndsWith("/"))
         {
             url += "/";
         }
         Dictionary <string, string> args = new Dictionary <string, string>();
         args.Add(HttpCommands.cstArgNameCommand, HttpCommands.cstArgCmdGetInstanceList);
         url = url + HttpCommands.GetCatalogUrl(HttpCommands.cstCatalogPage, args);
         object             obj = GetObjectFromHttpStream.GetObject(url);
         InstanceIdentify[] ids = (InstanceIdentify[])obj;
         if (ids != null && ids.Length > 0)
         {
             CatalogNetInstance[] instances = new CatalogNetInstance[ids.Length];
             int i = 0;
             foreach (InstanceIdentify id in ids)
             {
                 instances[i] = new CatalogNetInstance(id.Name, id, id.Description);
                 i++;
             }
             return(instances);
         }
         return(null);
     }
     catch (Exception ex)
     {
         MsgBox.ShowError(ex.Message);
         return(null);
     }
 }
        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);
                }
            }
        }
Пример #4
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);
            }
        }
        public void UpdateAppInfo()
        {
            InstalledApps = new List <InstalledAppInfo>();
            string Info = string.Empty;

            try
            {
                Info = HttpCommands.StartScript(Settings.Default.Server, "Apps/AppInit/appinit.cgi?info");
            }
            catch (Exception ex) { Logger.GetInstance().AddLogLine(LogLevel.Warning, "", ex); }
            //catch { } my edit

            string appinfo = string.Empty;

            try
            {
                appinfo = Info.Substring(Info.IndexOf('{'));
                appinfo = appinfo.Substring(0, appinfo.LastIndexOf('}') + 1);
            }
            catch (Exception ex) { Logger.GetInstance().AddLogLine(LogLevel.Warning, "", ex); }
            //catch { } my edit

            foreach (string app in appinfo.Split(new char[] { '}' }, StringSplitOptions.RemoveEmptyEntries))
            {
                try
                {
                    string path    = GetJSONValue(app, "path");                             // Regex.Match(app, "\\s*\"?path\"?\\s*[=:]{1}\\s*\"?([^\",]+)\"?\\s*").Groups[1].Value;
                    string name    = GetJSONValue(app, "name");                             //Regex.Match(app, "\\s*\"?name\"?\\s*[=:]{1}\\s*\"?([^\",]+)\"?\\s*").Groups[1].Value;
                    bool   started = GetJSONValue(app, "started") == "1";                   //Regex.Match(app, "\\s*\"?started\"?\\s*[=:]{1}\\s*\"?([^\",]+)\"?\\s*").Groups[1].Value == "1";

                    int    appinfo_format = int.Parse(GetJSONValue(app, "appinfo_format")); //Regex.Match(app, "\\s*\"?appinfo_format\"?\\s*[=:]{1}\\s*\"?([^\",]+)\"?\\s*").Groups[1].Value);
                    string version        = GetJSONValue(app, "version");                   //Regex.Match(app, "\\s*\"?version\"?\\s*[=:]{1}\\s*\"?([^\",]+)\"?\\s*").Groups[1].Value;
                    bool   enabled        = GetJSONValue(app, "enabled") == "1";            //Regex.Match(app, "\\s*\"?enabled\"?\\s*[=:]{1}\\s*\"?([^\",]+)\"?\\s*").Groups[1].Value == "1";
                    string daemon_script  = GetJSONValue(app, "daemon_script");             //Regex.Match(app, "\\s*\"?daemon_script\"?\\s*[=:]{1}\\s*\"?([^\",]+)\"?\\s*").Groups[1].Value;
                    string crontab        = GetJSONValue(app, "crontab");                   //Regex.Match(app, "\\s*\"?crontab\"?\\s*[=:]{1}\\s*\"?([^\",]+)\"?\\s*").Groups[1].Value;
                    string setup_script   = GetJSONValue(app, "setup_script");              //Regex.Match(app, "\\s*\"?setup_script\"?\\s*[=:]{1}\\s*\"?([^\",]+)\"?\\s*").Groups[1].Value;
                    string gayaui_path    = GetJSONValue(app, "gayaui_path");               //Regex.Match(app, "\\s*\"?gayaui_path\"?\\s*[=:]{1}\\s*\"?([^\",]+)\"?\\s*").Groups[1].Value;
                    string webui_path     = GetJSONValue(app, "webui_path");                //Regex.Match(app, "\\s*\"?webui_path\"?\\s*[=:]{1}\\s*\"?([^\",]+)\"?\\s*").Groups[1].Value;

                    InstalledApps.Add(new InstalledAppInfo(started, path, appinfo_format, name, version, enabled, daemon_script, crontab, setup_script, gayaui_path, webui_path));
                }
                catch (Exception ex) { Logger.GetInstance().AddLogLine(LogLevel.Warning, "", ex); }
                //catch { } my edit
            }

            UpdateRepositoryStates();

            if (OnUpdateComplete != null)
            {
                OnUpdateComplete();
            }
        }
Пример #6
0
        public pnlCSIUpgrade(Dictionary <string, object> panelResults, Functions.UpdateProgressInfo OnProgress)
            : base(Resources.PanelTitle_CSIUpgrade, panelResults, OnProgress)
        {
            InitializeComponent();
            tbCurrentVersion.Text   = Assembly.GetEntryAssembly().GetName().Version.ToString();
            tbAvailableVersion.Text = ((Version)panelResults["OnlineVersion"]).ToString();

            try
            {
                rtbChangelog.Rtf = Functions.HtmlToRtf(HttpCommands.GetHttpFileContent(Settings.Default.CSIUpdateChangelogURL, null), true);
            }
            catch (Exception ex) { Logger.GetInstance().AddLogLine(LogLevel.Error, "Invalid response on changelog request", ex); }
        }
Пример #7
0
        private void LoadDatasetAndFetclass()
        {
            InstanceIdentify id = _tag as InstanceIdentify;

            try
            {
                string url = _parent.Tag.ToString();
                Dictionary <string, string> args = new Dictionary <string, string>();
                args.Add(HttpCommands.cstArgNameCommand, HttpCommands.cstArgCmdGetCatalogList);
                args.Add(HttpCommands.cstArgInstanceId, id.Id.ToString());
                url = url + HttpCommands.GetCatalogUrl(HttpCommands.cstCatalogPage, args);
                object[] objs = GetObjectFromHttpStream.GetObject(url) as object[];
                if (objs != null && objs.Length > 0)
                {
                    FetDatasetIdentify[] dsIds   = objs[0] as FetDatasetIdentify[];
                    FetClassIdentify[]   fetcIds = objs[1] as FetClassIdentify[];
                    //
                    if (dsIds != null && dsIds.Length > 0)
                    {
                        foreach (FetDatasetIdentify did in dsIds)
                        {
                            ICatalogItem cit = new CatalogNetFeatureDataset(did.Name, did.Id, did.Description);
                            AddChild(cit);
                            //
                            if (did.FetClassIds != null && did.FetClassIds.Length > 0)
                            {
                                foreach (FetClassIdentify fetcId in did.FetClassIds)
                                {
                                    ICatalogItem fcit = new CatalogNetFeatureClass(fetcId.Name, fetcId, fetcId.Description);
                                    cit.AddChild(fcit);
                                }
                            }
                        }
                    }
                    //
                    if (fetcIds != null && fetcIds.Length > 0)
                    {
                        foreach (FetClassIdentify fetcId in fetcIds)
                        {
                            ICatalogItem fcit = new CatalogNetFeatureClass(fetcId.Name, fetcId, fetcId.Description);
                            AddChild(fcit);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MsgBox.ShowError(ex.Message);
            }
        }
        public List <RepositoryLocationInfo> GetInvalidLocations()
        {
            List <RepositoryLocationInfo> result = new List <RepositoryLocationInfo>();

            foreach (RepositoryLocationInfo loc in _locations)
            {
                if (HttpCommands.GetHTTPFileLastModified(loc.URL) == DateTime.MinValue)
                {
                    result.Add(loc);
                }
            }

            return(result);
        }
        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);
                    }
                }
            }
        }
Пример #10
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);
        }
Пример #11
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);
            }
        }
Пример #12
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);
        }
Пример #13
0
        private void ExecuteAppInitCommand(object command)
        {
            string result = HttpCommands.StartScript(Settings.Default.Server, command.ToString().Replace(" ", "%20"));

            UpdateAppInfo();
        }