コード例 #1
0
ファイル: UpdateForm.cs プロジェクト: gttrcr/RemoDome
        private void CheckInternetConnectionFileAndFolder()
        {
            try
            {
                try
                {
                    using (var client = new WebClient())
                    {
                        using (var stream = client.OpenRead("http://www.google.com"))
                        {
                        }
                    }
                }
                catch
                {
                    Messaggi.ShowError("Controllare la connessione internet e riprovare");
                    Environment.Exit(0);
                }

                if (!Directory.Exists(DIR_FOLDER_PROGRAMS))
                {
                    Directory.CreateDirectory(DIR_FOLDER_PROGRAMS);
                    Messaggi.ShowWarning("Cartella programmi non trovata all'indirizzo " + DIR_FOLDER_PROGRAMS + ". Cartella creata");
                }
            }
            catch (Exception ex)
            {
                Messaggi.ShowError("Errore al controllo iniziale: " + ex.Message);
            }
        }
コード例 #2
0
ファイル: UpdateForm.cs プロジェクト: gttrcr/RemoDome
 public Form1()
 {
     try
     {
         InitializeComponent();
         CheckInternetConnectionFileAndFolder();
         LoadList();
     }
     catch (Exception ex)
     {
         Messaggi.ShowError("Errore al caricamento del programma: " + ex.Message);
     }
 }
コード例 #3
0
ファイル: UpdateForm.cs プロジェクト: gttrcr/RemoDome
        private void button_update_Click(object sender, EventArgs e)
        {
            try
            {
                List <int> indexToUpdate = new List <int>();
                for (int i = 0; i < checkedListBox_appList.Items.Count; i++)
                {
                    if (checkedListBox_appList.GetItemCheckState(i).Equals(CheckState.Checked))
                    {
                        indexToUpdate.Add(i);
                    }
                }

                if (indexToUpdate.Count() > 0)
                {
                    foreach (int index in indexToUpdate)
                    {
                        if (!String.IsNullOrEmpty(appList[index].Url) && !String.IsNullOrWhiteSpace(appList[index].Url))
                        {
                            Process.Start(appList[index].Url);
                        }
                        else
                        {
                            Messaggi.ShowWarning("Nessun link valido per " + appList[index].AppName);
                        }
                    }
                }
                else
                {
                    Messaggi.ShowWarning("Nessuna App da aggiornare");
                }
            }
            catch (Exception ex)
            {
                Messaggi.ShowError("Errore all'update: " + ex.Message);
            }
        }
コード例 #4
0
ファイル: UpdateForm.cs プロジェクト: gttrcr/RemoDome
        public void LoadList()
        {
            try
            {
                string webText = String.Empty;
                using (var webClient = new System.Net.WebClient())
                {
                    webText = webClient.DownloadString(DATA_URL).ToString();
                }

                webText = webText.Split(START_STOP_MESSAGE, StringSplitOptions.None)[1];
                webText = webText.Split(START_STOP_MESSAGE, StringSplitOptions.None)[0];

                string dataSet = String.Empty;
                for (int i = 0; i < webText.Split(START_STOP_STRING, StringSplitOptions.None).Count(); i++)
                {
                    if (i % 2 != 0)
                    {
                        dataSet += webText.Split(START_STOP_STRING, StringSplitOptions.None)[i].Trim() + "\n";
                    }
                }

                string[] temp = dataSet.Replace("\n", "").Replace("\r", "").Replace("\t", "").Split(';');
                temp = temp.Take(temp.Count() - 1).ToArray();

                appList.Clear();
                foreach (string appString in temp)
                {
                    CompleteAppInfo compName = new CompleteAppInfo();
                    compName.AppName     = Decrypt(appString.Split(',')[0].Trim());
                    compName.Url         = Decrypt(appString.Split(',')[1].Trim());
                    compName.FileVersion = Decrypt(appString.Split(',')[2].Trim());
                    //compName.Message = Decrypt(appString.Split(',')[3].Trim());
                    appList.Add(compName); //Lista di tutte le applicazione trovate nel sito
                }

                DirectoryInfo          d = new DirectoryInfo(DIR_FOLDER_PROGRAMS);
                List <CompleteAppInfo> listAppInFolder = new List <CompleteAppInfo>();
                foreach (var file in d.GetFiles("*.exe"))
                {
                    FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(file.FullName);
                    CompleteAppInfo appInFolder     = new CompleteAppInfo();
                    appInFolder.AppName     = file.Name.Replace(".exe", "");
                    appInFolder.FileVersion = fileVersionInfo.FileVersion;
                    listAppInFolder.Add(appInFolder); //Lista di tutte le applicazione trovate nella cartella del pc
                }

                checkedListBox_appList.Items.Clear();
                foreach (CompleteAppInfo siteApp in appList)
                {
                    int index = 0;
                    checkedListBox_appList.Items.Add(siteApp.AppName + " - versione: " + siteApp.FileVersion + " - news: " + siteApp.Message);
                    foreach (CompleteAppInfo pcApp in listAppInFolder)
                    {
                        if (pcApp.AppName.Equals(siteApp.AppName))
                        {
                            if (!siteApp.FileVersion.Equals(pcApp.FileVersion))
                            {
                                checkedListBox_appList.SetItemChecked(index, true);
                            }
                        }
                        index++;
                    }
                }
            }
            catch (Exception ex)
            {
                Messaggi.ShowError("Errore al LoadItems: " + ex.Message);
            }
        }