Example #1
0
        private static void UpdateShortcuts(string installDirectory)
        {
            var installActions = new InstallActions
            {
                InstallDirectory = installDirectory
            };

            installActions.UpdateShortcuts();
        }
Example #2
0
 /// <summary>
 /// Queues an install action to be run in a few seconds.
 /// </summary>
 /// <param name="action">
 /// The install action.
 /// </param>
 private void QueueInstallAction(Action action)
 {
     lock (InstallActionsLock)
     {
         InstallActions.Add(action);
         if (InstallTimer == null)
         {
             var twentySeconds = 1000 * 20;
             InstallTimer           = new Timer(twentySeconds);
             InstallTimer.AutoReset = false;
             InstallTimer.Elapsed  += HandleInstallTimerElapsed;
             InstallTimer.Start();
         }
     }
 }
Example #3
0
        /// <summary>
        /// Once the install timer elapses, run the install actions.
        /// </summary>
        private void HandleInstallTimerElapsed(object sender, ElapsedEventArgs e)
        {
            // Logging.
            LogHelper.Info <ApplicationStartedHandler>("Running the queue of Formulate install actions.");


            // Queueing this way should avoid application pool recycles during the install process,
            // which will ensure that only one application pool recyle occurs, even if there are multiple
            // configuration changes made.
            HostingEnvironment.QueueBackgroundWorkItem(token =>
            {
                lock (InstallActionsLock)
                {
                    try
                    {
                        InstallActions.ForEach(x =>
                                               x()
                                               );
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Error <ApplicationStartedHandler>(InstallActionsError, ex);
                    }
                    finally
                    {
                        // Reset queue.
                        InstallTimer   = null;
                        InstallActions = new List <Action>();


                        // Logging.
                        LogHelper.Info <ApplicationStartedHandler>("Done running the queue of Formulate install actions.");
                    }
                }
            });
        }
Example #4
0
        private ModDestinations findDestination()
        {
            ReadOnlyCollection <ArchiveFileInfo> info;

            info = new SevenZipExtractor(FilePath).ArchiveFileData;
            bool  couldBeJAR = false;
            bool  couldBeMOD = false;
            Regex builtIn    = new Regex(@"^[a-z]{1,3}.class");
            Regex mod        = new Regex(@"^mod_.+");

            foreach (ArchiveFileInfo finfo in info)
            {
                if (builtIn.Match(finfo.FileName).Success)
                {
                    couldBeJAR = true;
                }
                if (mod.Match(finfo.FileName).Success)
                {
                    couldBeMOD = true;
                }
            }
            if (couldBeJAR)
            {
                InstallActions.Add(new DirectoryCopyAction(@"MODROOT", @"JAR", tags));
                return(ModDestinations.JAR);
            }
            else if (couldBeMOD)
            {
                InstallActions.Add(new FileCopyAction(@"ZIP", @"MODS/NAME", tags));
                return(ModDestinations.MODS);
            }
            else
            {
                return(ModDestinations.COMPLEX);
            }
        }