Пример #1
0
        //**************************************************************
        // Load()
        // This static method is the way to instantiate manifest objects
        //**************************************************************
        public static AppManifest Load(string manifestFilePath)
        {
            Stream stream = null;

            try
            {
                if (!File.Exists(manifestFilePath))
                {
                    return(new AppManifest(manifestFilePath));
                }

                IFormatter formatter = new System.Runtime.Serialization.Formatters.Soap.SoapFormatter();
                stream = new FileStream(manifestFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                AppManifest Manifest = (AppManifest)formatter.Deserialize(stream);
                Manifest.FilePath = manifestFilePath;
                stream.Close();
                return(Manifest);
            }
            catch (Exception e)
            {
                if (stream != null)
                {
                    stream.Close();
                }

                Debug.WriteLine("APPMANAGER:  ERROR loading app manifest, creating a new manifest.");
                Debug.WriteLine("APPMANAGER:  " + e.ToString());
                return(new AppManifest(manifestFilePath));
            }
        }
Пример #2
0
        //**************************************************************
        // Initialize()
        // - Sets up the updater, generates the default manifest,
        //   starts the threads, etc...
        //**************************************************************
        public void Initialize()
        {
            //Load the Manifest Config File
            string AppManifestPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\";
            string AppManifestName = Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location);

            AppManifestName += ".xml";
            AppManifestPath  = Path.Combine(AppManifestPath, AppManifestName);
            Manifest         = AppManifest.Load(AppManifestPath);

            if (ChangeDetectionMode == ChangeDetectionModes.DirectFileCheck)
            {
                EnableManifestGeneration();
            }

            if (AutoFileLoad == true)
            {
                EnableFileAutoLoad();
            }

            if (Poller.AutoStart == true)
            {
                Poller.Start();
            }

            Downloader.OnUpdateComplete += new AppDownloader.UpdateCompleteEventHandler(OnDownloaderComplete);
            Application.ApplicationExit += new EventHandler(OnApplicationExit);

            EventControl = new Control();
            //Access the control handle to make sure it's bound to this thread
            IntPtr h = EventControl.Handle;

            //If an update was in progress when the app was shut down,
            //continue the download now that the app has restarted.
            if (Manifest.State.Phase != UpdatePhases.Complete)
            {
                Debug.WriteLine("APPMANAGER:  Continuing update already in progress");
                Downloader.Start();
            }
        }
Пример #3
0
        //**************************************************************
        // Initialize()
        // - Sets up the updater, generates the default manifest,
        //   starts the threads, etc...
        //**************************************************************
        public void Initialize()
        {
            //Load the Manifest Config File
            string AppManifestPath =Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\";
            string AppManifestName = Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location);
            AppManifestName += ".xml";
            AppManifestPath = Path.Combine(AppManifestPath,AppManifestName);
            Manifest = AppManifest.Load(AppManifestPath);

            if (ChangeDetectionMode == ChangeDetectionModes.DirectFileCheck)
                EnableManifestGeneration();

            if (AutoFileLoad == true)
                EnableFileAutoLoad();

            if (Poller.AutoStart == true)
                Poller.Start();

            if (DownloaderSettings != null){
                Downloader.MinimumConnectionKbPS = Int32.Parse(DownloaderSettings["minimumConnectionKbPS"]);
                Downloader.SecondsBetweenDownloadRetry = Int32.Parse(DownloaderSettings["secondsBetweenDownloadRetry"]);
                Downloader.DownloadRetryAttempts =Int32.Parse( DownloaderSettings["downloadRetryAttempts"]);
                Downloader.UpdateRetryAttempts = Int32.Parse(DownloaderSettings["updateRetryAttempts"]);
            }
            Downloader.OnUpdateComplete += new AppDownloader.UpdateCompleteEventHandler(OnDownloaderComplete);
            Downloader.OnConnectionStrengthChange += new AppDownloader.ConnectionStrengthChangeEventHandler(OnConnectionStrengthChange);

            Application.ApplicationExit += new EventHandler(OnApplicationExit);

            EventControl = new Control();
            //Access the control handle to make sure it's bound to this thread
            IntPtr h = EventControl.Handle;

            //If an update was in progress when the app was shut down,
            //continue the download now that the app has restarted.
            if (Manifest.State.Phase != UpdatePhases.Complete)
            {
                Debug.WriteLine("APPMANAGER:  Continuing update already in progress");
                Downloader.Start();
            }
        }