⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 productmanager.cs

📁 该源代码用 C# 写成
💻 CS
字号:
using System;
using System.IO;
using System.Net;
using System.Threading;
using System.Windows.Forms;
using System.Xml;
using Org.InteliIM.Services;

namespace Org.InteliIM.Configurations
{
	/// <summary>
	/// Product Manager
	/// </summary>
	public class ProductManager : IManager
	{
		private WebClient webClient = new WebClient();

		public ProductManager()
		{
		}

		private ProductInfoCollection availableProducts
			= new ProductInfoCollection();

		public ProductInfoCollection AvailableProducts
		{
			get { return this.availableProducts; }
			set { this.availableProducts = value; }
		}

		public void Load()
		{
		}

		public void Save()
		{
		}

		public void CheckForUpdate()
		{
			ThreadStart ts = new ThreadStart(this._CheckForUpdate);
			new Thread(ts).Start();
		}

		public void _CheckForUpdate()
		{
			this.RetrieveProductInfo();
		}

		public void RetrieveProductInfo()
		{
			try
			{
				this.AvailableProducts.Clear();

				string remoteFileName = "http://plissoft.bigwww.com/download/InteliIM/ProductInfo.xml";

				XmlDocument xml = new XmlDocument();
				xml.Load(remoteFileName);

				ProductInfo product = new ProductInfo().Deserialize(xml.OuterXml);

				this.AvailableProducts.Add(product);

				if (this.ProductInfoRetrieved != null)
					this.ProductInfoRetrieved(this, null);
			}
			catch (WebException)
			{
				Console.WriteLine("Unable to retrieve product information, please check network settings.");
			}
			catch (Exception e)
			{
				Console.WriteLine(e.ToString());
			}
		}

		private ProductInfo SampleProductInfo()
		{
			ProductInfo info = new ProductInfo();
			info.Name = "InteliIM";
			info.Series = "VS2005";
			info.Build = "2.0.0.1";
			info.DownloadUrls.Add("http://plissoft.bigwww.com/private/毕业设计/Microsoft .NET 在线软件开发平台2004-4-25.rar");
			info.Description = "InteliIM Beta 1";
			info.ReleaseTime = DateTime.Now;

			return info;
		}

		public void DownloadProduct()
		{
			string fileName = "http://plissoft.bigwww.com//web/product/DA/IMClientBuild1_0_0_13TechPreview.zip";

			try
			{
				webClient.DownloadFile(fileName,
				                       Path.Combine(Application.StartupPath,
				                                    "Hello.zip"));
			}
			catch (Exception e)
			{
				Console.WriteLine(e.ToString());
			}
		}

		public event EventHandler ProductInfoRetrieved;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -