示例#1
0
        public RefreshForm()
        {
            // ? apre connessione
            m_db = new csDatabase("aggiornamentoPlugins");

            InitializeComponent();

            refreshButtonStartup();

            workerThread = new Thread(frmLoadingShowing);
            workerThread.Start();

            // ? Riferimenti ai plugin
            Dictionary <string, string> data = Controller.controlloStatoSoftware();


            // ? Operazione automatica allo startup
            Controller.DisinstallaPlugins(Controller.controlloStatoSoftware(), m_db);
            Controller.InstallaPlugins(Controller.controlloStatoSoftware(), m_db);

            workerThread.Abort();
        }
示例#2
0
        internal static void InstallaPlugins(Dictionary <string, string> dictionaries, csDatabase db)
        {
            foreach (KeyValuePair <string, string> v in dictionaries)
            {
                string nomePlugin = v.Key;
                string pathLocale = v.Value;

                if (string.IsNullOrEmpty(pathLocale))
                {
                    if (destinazioneInstallazionePlugins.ContainsKey(nomePlugin))
                    {
                        string pathInstallazione = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString() + destinazioneInstallazionePlugins[nomePlugin] + "\\" + nomePlugin;

                        if (fonteInstallazionePlugins.ContainsKey(nomePlugin))
                        {
                            string pathFonte = fonteInstallazionePlugins[nomePlugin];

                            Directory.CreateDirectory(pathInstallazione);

                            //Now Create all of the directories
                            foreach (string dirPath in Directory.GetDirectories(pathFonte, "*",
                                                                                SearchOption.AllDirectories))
                            {
                                Directory.CreateDirectory(dirPath.Replace(pathFonte, pathInstallazione));
                                Application.DoEvents();
                            }

                            //Copy all the files & Replaces any files with the same name
                            foreach (string newPath in Directory.GetFiles(pathFonte, "*.*",
                                                                          SearchOption.AllDirectories))
                            {
                                File.Copy(newPath, newPath.Replace(pathFonte, pathInstallazione), true);
                                Application.DoEvents();
                            }
                        }

                        if (Directory.Exists(pathInstallazione))
                        {
                            // ? installato
                            db.addRecordToUsernameAggiornamento(new csOperazione()
                            {
                                m_Utente       = Environment.UserName,
                                m_Software     = nomePlugin,
                                m_DataSoftware = DateTime.Now,
                                m_Status       = true,
                                m_Action       = "installazione"
                            });
                        }
                        else
                        {
                            // ? non installato
                            db.addRecordToUsernameAggiornamento(new csOperazione()
                            {
                                m_Utente       = Environment.UserName,
                                m_Software     = nomePlugin,
                                m_DataSoftware = DateTime.Now,
                                m_Status       = false,
                                m_Action       = "installazione"
                            });
                        }
                    }
                }
            }
        }
示例#3
0
        internal static void DisinstallaPlugins(Dictionary <string, string> dictionaries, csDatabase db)
        {
            foreach (KeyValuePair <string, string> v in dictionaries)
            {
                string nomePlugin = v.Key;
                string pathLocale = v.Value;

                if (!string.IsNullOrEmpty(pathLocale))
                {
                    DirectoryInfo di = new DirectoryInfo(pathLocale);

                    foreach (FileInfo file in di.EnumerateFiles())
                    {
                        try
                        {
                            file.Delete();
                        }
                        catch { }
                    }
                    foreach (DirectoryInfo dir in di.EnumerateDirectories())
                    {
                        try
                        {
                            dir.Delete(true);
                        }
                        catch { }
                    }

                    try
                    {
                        Directory.Delete(pathLocale);
                    }
                    catch { }
                    finally
                    {
                        if (!Directory.Exists(pathLocale))
                        {
                            // ? Plugin disinstallato correttamente
                            db.addRecordToUsernameAggiornamento(new csOperazione()
                            {
                                m_Utente       = Environment.UserName,
                                m_Software     = nomePlugin,
                                m_DataSoftware = DateTime.Now,
                                m_Status       = true,
                                m_Action       = "Eliminazione"
                            });
                        }
                        else
                        {
                            // ? Plugin non disinstallato
                            db.addRecordToUsernameAggiornamento(new csOperazione()
                            {
                                m_Utente       = Environment.UserName,
                                m_Software     = nomePlugin,
                                m_DataSoftware = DateTime.Now,
                                m_Status       = false,
                                m_Action       = "Eliminazione"
                            });
                        }
                    }
                }
            }
        }