亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? downloader.cs

?? 一個飯店管理系統
?? CS
?? 第 1 頁 / 共 2 頁
字號:
using System;
using System.Diagnostics;
using System.Threading;
using System.Collections;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Reflection;
using System.ComponentModel;
using System.Globalization;

namespace Microsoft.Samples.AppUpdater
{
	//**************************************************************
	// AppDownloader class
	// - Responsible for downloading & applying updates.
	//**************************************************************
	public class AppDownloader
	{
		private AppUpdater AppMan;
		private Thread UpdaterThread;
		private AppStartConfig Config;
		private UpdateLog Log;
		private UpdateCompleteEventArgs UpdateEventArgs;
		private AppKeys Keys;

		//Enable checking of downloaded assemblies
		private bool _ValidateAssemblies = false;
		[DefaultValue(false)]
		[Description("Specifies whether or not downloaded assemblies must be signed with valid public keys inorder to be downloaded.")]		 
		public bool ValidateAssemblies
		{
			get {return _ValidateAssemblies;}
			set {_ValidateAssemblies = value;}
		}

		//Delay between download retries when a network problem is encountered
		private int _SecondsBetweenDownloadRetry = 60;
		[DefaultValue(60)]
		[Description("Seconds between download retry attempts.")]
		public int SecondsBetweenDownloadRetry
		{
			get { return _SecondsBetweenDownloadRetry; }
			set { _SecondsBetweenDownloadRetry = value; }
		}

		//Number of times to retry when a download error is encountered
		private int _DownloadRetryAttempts = 3;
		[DefaultValue(3)]
		[Description("Number of times to retry downloads when an error is encountered.")]
		public int DownloadRetryAttempts
		{
			get { return _DownloadRetryAttempts; }
			set { _DownloadRetryAttempts = value; }
		}

		//Number of times to retry the overall update
		private int _UpdateRetryAttempts = 2;
		[DefaultValue(2)]
		[Description("Number of times times to retry the app update.")]
		public int UpdateRetryAttempts
		{
			get { return _UpdateRetryAttempts; }
			set { _UpdateRetryAttempts = value; }
		}

		[Browsable(false)]
		public UpdateState State
		{
			get
			{
				return AppMan.Manifest.State;
			}
		}

		//**************************************************************
		// OnUpdateComplete Event	
		//**************************************************************
		internal delegate void UpdateCompleteEventHandler(object sender, UpdateCompleteEventArgs e);
		internal event UpdateCompleteEventHandler OnUpdateComplete;

		//**************************************************************
		// AppUpdater Constructor	
		//**************************************************************
		public AppDownloader(AppUpdater appMan)
		{
			AppMan = appMan;
			Log = new UpdateLog();
			UpdateEventArgs = new UpdateCompleteEventArgs();
		}

		//**************************************************************
		// Start()	
		//**************************************************************
		public void Start()
		{
			if (UpdaterThread == null) 
				UpdaterThread = new Thread(new ThreadStart(RunThread));
			else if (!UpdaterThread.IsAlive)
				UpdaterThread = new Thread(new ThreadStart(RunThread));

			UpdaterThread.Name="Updater Thread";

			if (!UpdaterThread.IsAlive)
				UpdaterThread.Start();
		}

		//**************************************************************
		// Stop()	
		//**************************************************************
		public void Stop()
		{
			if (UpdaterThread != null && UpdaterThread.IsAlive) 
			{
				UpdaterThread.Abort();
				UpdaterThread = null;
			}
		}

		//**************************************************************
		// RunThread()	
		//**************************************************************
		public void RunThread()
		{
			Debug.WriteLine("APPMANAGER:  Starting Update");

			//Load the AppStart config File
			string ConfigFilePath =Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
			ConfigFilePath = Path.Combine(Directory.GetParent(ConfigFilePath).FullName,"AppStart.config");
			Config = AppStartConfig.Load(ConfigFilePath);

			try 
			{
				//Mark in the manifest that a download is in progress.  Persisted in 
				//manifest in case the app is stop & restarted during the download.
				if (AppMan.Manifest.State.Phase == UpdatePhases.Complete) 
				{
					AppMan.Manifest.State.Phase = UpdatePhases.Scavenging;
					AppMan.Manifest.State.UpdateFailureCount=0;
					AppMan.Manifest.State.UpdateFailureEncoutered = false;
					AppMan.Manifest.State.DownloadDestination = CreateTempDirectory();

					if (AppMan.ChangeDetectionMode == ChangeDetectionModes.ServerManifestCheck)
					{	
						ServerManifest SM = new ServerManifest();
						SM.Load(AppMan.UpdateUrl);
						AppMan.Manifest.State.DownloadSource = SM.ApplicationUrl;
					}
					else 
						AppMan.Manifest.State.DownloadSource = AppMan.UpdateUrl;

					AppMan.Manifest.Update();
				}

				//Scavenge Existing Directories
				if (AppMan.Manifest.State.Phase == UpdatePhases.Scavenging)
				{
					Debug.WriteLine("APPMANAGER:  Scavaging older versions");
					Scavenge();
					AppMan.Manifest.State.Phase=UpdatePhases.Downloading;
					AppMan.Manifest.Update();
				}

				//Download the New Version
				if (AppMan.Manifest.State.Phase == UpdatePhases.Downloading)
				{
					Debug.WriteLine("APPMANAGER:  Downloading new version");
					Download();
					AppMan.Manifest.State.Phase = UpdatePhases.Validating;
					AppMan.Manifest.Update();
				}

				//Validate the downloaded bits
				if (AppMan.Manifest.State.Phase == UpdatePhases.Validating)
				{
					Debug.WriteLine("APPMANAGER:  Downloading new version");
					Validate();
					AppMan.Manifest.State.Phase = UpdatePhases.Merging;
					AppMan.Manifest.Update();
				}

				//Merge the existing version into the new version
				if (AppMan.Manifest.State.Phase == UpdatePhases.Merging)
				{
					Debug.WriteLine("APPMANAGER:  Merging current & new versions");
					MergeDirectory(AppDomain.CurrentDomain.BaseDirectory,AppMan.Manifest.State.DownloadDestination);
					AppMan.Manifest.State.Phase = UpdatePhases.Finalizing;
					AppMan.Manifest.Update();
				}

				//Finalize the update.  Rename the new version directory, etc...
				if (AppMan.Manifest.State.Phase == UpdatePhases.Finalizing)
				{
					Debug.WriteLine("APPMANAGER:  Finalizing update");
					FinalizeUpdate();						
				}

				//Reset Update State
				AppMan.Manifest.State.Phase = UpdatePhases.Complete;
				AppMan.Manifest.State.UpdateFailureCount=0;
				AppMan.Manifest.State.UpdateFailureEncoutered = false;
				AppMan.Manifest.State.DownloadSource = "";
				AppMan.Manifest.State.DownloadDestination = "";
				AppMan.Manifest.State.NewVersionDirectory = "";
				AppMan.Manifest.Update();	
			} 
			catch (ThreadAbortException)
			{
				Thread.ResetAbort();
				Debug.WriteLine("APPMANAGER:  ThreadAborted: Updater Thread stopped, stopping download.");
				return;
			}
			catch (Exception e)
			{
				UpdateEventArgs.FailureException = e;
			}

			if (AppMan.Manifest.State.Phase != UpdatePhases.Complete)
				HandleUpdateFailure();
			else
				HandleUpdateSuccess();
		}

		//**************************************************************
		// HandleUpdateSuccess()	
		//**************************************************************
		private void HandleUpdateSuccess()
		{
			Debug.WriteLine("APPMANAGER:  Update Succeeded");

			try 
			{
				Log.AddSuccess(GetFileVersion(Config.AppExePath));
			} 
			catch (Exception e)
			{
				Debug.WriteLine("APPMANAGER:  Failed to log update success");
				Debug.WriteLine("APPMANAGER:  " + e.ToString());
			}

			//Fire Update Event
			if (OnUpdateComplete != null)
			{
				UpdateEventArgs.UpdateSucceeded = true;
				UpdateEventArgs.NewVersion = new Version(GetFileVersion(Config.AppExePath));
				if (UpdateEventArgs.ErrorMessage == "")
					UpdateEventArgs.ErrorMessage = "Unknown Error";
				OnUpdateComplete(this, UpdateEventArgs);
			}
		}

		//**************************************************************
		// HandleUpdateFailure()	
		//**************************************************************
		private void HandleUpdateFailure()
		{
			Debug.WriteLine("APPMANAGER:  Update Failed");

			try 
			{
				Log.AddError(UpdateEventArgs.FailureException.ToString());
			} 
			catch (Exception e)
			{
				Debug.WriteLine("APPMANAGER:  Failed to log update failure");
				Debug.WriteLine("APPMANAGER:  " + e.ToString());
			}

			AppMan.Manifest.State.UpdateFailureEncoutered = true;
			AppMan.Manifest.State.UpdateFailureCount++;
			AppMan.Manifest.Update();

			//If the update has failed too many times
			if (AppMan.Manifest.State.UpdateFailureCount >= UpdateRetryAttempts)
			{
				Debug.WriteLine("APPMANAGER:  Updated Failed 2 times.  Reseting Manifest");
				AppMan.Manifest.State.Phase = UpdatePhases.Complete;
				AppMan.Manifest.State.UpdateFailureEncoutered = false;
				AppMan.Manifest.State.UpdateFailureCount = 0;
				AppMan.Manifest.State.DownloadSource = "";
				AppMan.Manifest.State.DownloadDestination = "";				
				AppMan.Manifest.Update();
			}

			if (OnUpdateComplete != null)
			{
				UpdateEventArgs.UpdateSucceeded = false;
				if (UpdateEventArgs.ErrorMessage == "")
					UpdateEventArgs.ErrorMessage = "Unknown Error";
				OnUpdateComplete(this, UpdateEventArgs);
			}
		}

		//**************************************************************
		// Download()	
		//**************************************************************
		private void Download()
		{
			bool DownloadInProgress = true;
			int DownloadAttemptCount = 0;
			int SecondsToSleep = 0;

			while (DownloadInProgress)
			{
				Thread.Sleep(TimeSpan.FromSeconds(SecondsToSleep));
				SecondsToSleep = SecondsBetweenDownloadRetry;

				DownloadAttemptCount++;

				Trace.WriteLine("APPMANAGER:  Attempting to download update from:  " + AppMan.Manifest.State.DownloadSource);

				try
				{
					int UpdateCount = WebFileLoader.CopyDirectory(AppMan.Manifest.State.DownloadSource,AppMan.Manifest.State.DownloadDestination); 
					Debug.WriteLine("APPMANAGER:  Number of files updated from the server:  " + UpdateCount);

					Debug.WriteLine("APPMANAGER:  App update downloaded successfully");

					DownloadInProgress = false;
				} 
					//Things that could go wrong while downloading are pretty much any kind of 
					//network problem, like the client just going offline.  However, this can cause
					//itself to manifest in any number of ways... like exceptions on the stream
					//objects used to copy the file to disk.
				catch (WebException e)
				{
					Debug.WriteLine("APPMANAGER:  Update download failed due to network exception:");
					Debug.WriteLine("APPMANAGER:  " + e.ToString());
					
					if (DownloadAttemptCount >= DownloadRetryAttempts)
					{
						Debug.WriteLine("APPMANAGER:  Download attempt has failed 3 times.  Aborting Update");
						UpdateEventArgs.ErrorMessage = "Download of a new update from '"+ AppMan.Manifest.State.DownloadSource 
							+"' failed with the network error:  " + e.Message;
						throw e;
					}
				}
				catch (IOException e)
				{
					Debug.WriteLine("APPMANAGER:  Update download failed due to file I/O exception:");
					Debug.WriteLine("APPMANAGER:  " + e.ToString());
					
					if (DownloadAttemptCount >= DownloadRetryAttempts)
					{
						Debug.WriteLine("APPMANAGER:  Download attempt has failed 3 times.  Aborting Update");
						UpdateEventArgs.ErrorMessage = "Saving the new update to disk at '" + AppMan.Manifest.State.DownloadDestination 
							+"' failed with the following error:  " + e.Message;
						throw e;
					}
				}
				catch (Exception e)
				{
					Debug.WriteLine("APPMANAGER:  Update download failed due to the following error:  " + e.Message);
					Debug.WriteLine("APPMANAGER:  " + e.ToString());
					
					if (DownloadAttemptCount >= DownloadRetryAttempts)
					{
						Debug.WriteLine("APPMANAGER:  Download attempt has failed 3 times.  Aborting Update");
						UpdateEventArgs.ErrorMessage = "Update failed with the following error:  '"+ e.Message + "'";
						throw e;
					}
				}
			}
		}

		//**************************************************************
		// Validate()	
		//**************************************************************
		private void Validate()
		{
			if (!ValidateAssemblies)
				return;

			//Initialize the Keys Object
			Keys = new AppKeys(AppMan.Manifest.State.DownloadSource);
			Keys.InitializeKeyCheck();

			try 
			{
				ValidateDirectory(AppMan.Manifest.State.DownloadDestination);
			} 
			catch (Exception)
			{
				Keys.UnInitializeKeyCheck();

				//Remove the downloaded files if any error occurs in validation.
				HardDirectoryDelete(AppMan.Manifest.State.DownloadDestination);

				//Set the update failure count to max.
				//Don't retry the update another time.  This will cause the update
				//to reset.
				AppMan.Manifest.State.UpdateFailureCount = UpdateRetryAttempts;
				AppMan.Manifest.Update();  
				throw;
			}

			Keys.UnInitializeKeyCheck();
		}


		//**************************************************************
		// ValidateDirectory()	
		//**************************************************************
		private void ValidateDirectory(string source)
		{
			try 
			{
				//Get a reference to the source directory
				DirectoryInfo Source = new DirectoryInfo(source);
			

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区激情小说| 91久久精品午夜一区二区| 高清视频一区二区| 欧美色网站导航| 国产精品色一区二区三区| 日日摸夜夜添夜夜添精品视频| 成人性生交大片| 精品国产自在久精品国产| 亚洲一区二区视频| 99视频有精品| 久久免费精品国产久精品久久久久| 一卡二卡欧美日韩| 91一区一区三区| 亚洲国产精品99久久久久久久久| 日韩精品五月天| 欧美影院一区二区| 国产精品伦理在线| 国产成人免费av在线| 亚洲精品在线观看视频| 免费观看30秒视频久久| 91精品国产综合久久久蜜臀图片| 亚洲乱码中文字幕| 99精品欧美一区二区三区小说 | 欧美韩国日本不卡| 看电影不卡的网站| 91精品国产综合久久小美女| 亚洲一区影音先锋| 日本大香伊一区二区三区| 亚洲国产激情av| 成人一级黄色片| 国产女同性恋一区二区| 国产成人高清视频| 国产欧美日韩亚州综合 | 2024国产精品| 免费成人美女在线观看.| 欧美三级午夜理伦三级中视频| 精品国产乱码久久久久久蜜臀| 日韩激情av在线| 欧美精品久久99| 久久国产精品露脸对白| 精品国产百合女同互慰| 国产精品亚洲视频| 欧美国产日产图区| 成人福利视频网站| 亚洲色图另类专区| 欧美日韩一区在线观看| 舔着乳尖日韩一区| 日韩精品专区在线| 国产一区二区三区在线观看精品 | 91国模大尺度私拍在线视频| 一个色妞综合视频在线观看| 欧美午夜在线观看| 丝袜美腿亚洲色图| 精品国产成人在线影院| 成人av影视在线观看| 一区二区三区不卡在线观看| 欧美一区二区三区人| 国内精品在线播放| 国产精品久久久久久久久快鸭 | 国产99精品国产| 亚洲私人黄色宅男| 欧美日韩激情一区二区三区| 精品中文字幕一区二区小辣椒| 国产精品无人区| 欧美日韩免费电影| 国产成人午夜99999| 亚洲一区在线电影| 久久综合九色综合久久久精品综合| av电影一区二区| 日本午夜精品视频在线观看| 日本一区二区电影| 在线播放日韩导航| 成人黄色大片在线观看| 免费xxxx性欧美18vr| 国产精品久久久久桃色tv| 欧美二区在线观看| 成人午夜精品在线| 欧美a级一区二区| 亚洲欧洲制服丝袜| 久久影音资源网| 欧美精品第一页| 91影院在线观看| 国产乱码精品1区2区3区| 亚洲一区二区三区爽爽爽爽爽| 国产丝袜美腿一区二区三区| 欧美日韩高清在线播放| 99久久伊人精品| 久久国产麻豆精品| 午夜精品久久久久久久99樱桃| 日本一区二区久久| 2020日本不卡一区二区视频| 欧美日韩高清一区二区不卡| 99久久99久久久精品齐齐| 国产一区二区女| 奇米影视7777精品一区二区| 亚洲精品欧美激情| 国产精品污污网站在线观看| 久久综合久久综合九色| 欧美大白屁股肥臀xxxxxx| 在线观看91视频| av在线不卡电影| 国产91丝袜在线18| 国产精品系列在线观看| 韩国成人精品a∨在线观看| 青青草国产精品亚洲专区无| 亚洲国产视频a| 亚洲国产日日夜夜| 亚洲永久免费av| 一区二区激情小说| 一区二区三区波多野结衣在线观看| 1024亚洲合集| 亚洲精选视频免费看| 亚洲精品国产无套在线观 | 精品国产露脸精彩对白 | 欧美国产1区2区| 久久久综合九色合综国产精品| 日韩免费观看高清完整版| 欧美一区二区三区的| 欧美一区午夜视频在线观看| 在线播放91灌醉迷j高跟美女 | 国产色婷婷亚洲99精品小说| 2023国产精品| 国产精品美女久久久久av爽李琼 | 日韩美女在线视频| 亚洲欧美日韩在线播放| 国产免费观看久久| 国产精品少妇自拍| 国产精品免费丝袜| 悠悠色在线精品| 日韩专区在线视频| 美女视频免费一区| 国产成+人+日韩+欧美+亚洲| www.欧美色图| 欧美影片第一页| 精品久久人人做人人爱| 久久婷婷成人综合色| 亚洲欧美综合网| 精品国产91乱码一区二区三区| 亚洲高清免费在线| 欧美影片第一页| 久久综合九色综合欧美98| 国产精品久久一卡二卡| 综合av第一页| 亚洲成人精品一区| 精品一区二区综合| av不卡免费在线观看| 51精品视频一区二区三区| 久久久久久麻豆| 亚洲午夜精品一区二区三区他趣| 蜜臀av一区二区三区| 成人av动漫在线| 欧美一区二区三区免费视频| 中文字幕第一区| 午夜精品福利视频网站| 国产精品1区2区| 欧美日韩国产美| 国产欧美一区二区精品仙草咪| 亚洲综合免费观看高清在线观看| 免费成人av在线播放| 91麻豆自制传媒国产之光| 欧美大片顶级少妇| 亚洲激情网站免费观看| 精品一区二区三区视频| 在线看一区二区| 国产女人水真多18毛片18精品视频| 午夜视黄欧洲亚洲| 99久久久久久99| 久久美女艺术照精彩视频福利播放 | 中文字幕av资源一区| 日本伊人午夜精品| 在线观看不卡视频| 中文字幕不卡的av| 激情图区综合网| 欧美日本一区二区| 亚洲精品视频在线看| 国产精品自拍毛片| 日韩你懂的在线观看| 午夜欧美大尺度福利影院在线看| 99久久久久久| 久久精品视频网| 国产做a爰片久久毛片| 欧美巨大另类极品videosbest| 日韩理论电影院| eeuss鲁一区二区三区| 久久一二三国产| 久久国产精品区| 日韩欧美国产综合| 美女在线观看视频一区二区| 欧美军同video69gay| 亚洲一区二三区| 欧美婷婷六月丁香综合色| 中文字幕一区二区三区不卡在线| 国产成人综合网| 欧美国产精品一区二区| 国产伦精一区二区三区| 国产欧美综合在线观看第十页 | 国产欧美一区二区精品婷婷| 捆绑调教一区二区三区| 日韩欧美一级特黄在线播放| 美腿丝袜亚洲一区|