public ProgrammUpdater() { m_instanse = this; onMessagereceive = (_text) => { }; m_client = new WebClient(); m_proxySettings = new ProxySettings(); }
public Form1() { m_proxySettings = new ProxySettings(true, "10.10.10.100", 3128, "spirit", "54475"); InitializeComponent(); Text += " " + Assembly.GetExecutingAssembly().GetName().Version.ToString(); if(Environment.GetCommandLineArgs().Count() != 3) { MessageBox.Show("Неправильно количествое параметров командной строки"); Environment.Exit(0); } else { appName = Environment.GetCommandLineArgs().ToList()[2]; remoteDownloadPath = Environment.GetCommandLineArgs().ToList()[1]; } assemblyList = new List<UpdateAssemblyInfo>(); if (!UpdateAssemblyInfo.loadFromXml("update.dat", ref assemblyList, m_proxySettings)) { ui_updateButton.Enabled = false; ThreadSafe.WriteLog(ui_textLog, "Файл update.dat не найден!"); } if (assemblyList.Count == 0) { ui_updateButton.Enabled = false; ThreadSafe.WriteLog(ui_textLog, "Нет обновлений"); } else { ThreadSafe.WriteLog(ui_textLog, "Доступны для обновления новые файлы:"); for(int i = 0 ; i < assemblyList.Count; i++) { ThreadSafe.WriteLog(ui_textLog, assemblyList[i].name); } ThreadSafe.WriteLog(ui_textLog, String.Format("Всего файлов: {0} ", assemblyList.Count.ToString())); } m_updater = new UpdaterLib.ProgrammUpdater(); m_updater.onMessagereceive += (_text => ThreadSafe.WriteLog(ui_textLog, _text)); m_updater.m_proxySettings = new ProxySettings(true, "10.10.10.100", 3128, "spirit", "54475"); }
public static bool loadFromXml(string _path, ref List<UpdateAssemblyInfo> _assemblyList, ProxySettings _proxySettings) { try { XmlTextReader reader; if (_proxySettings.isProxyEnable) { WebProxy wp = new WebProxy(_proxySettings.proxyServer, _proxySettings.proxyPort); wp.Credentials = new NetworkCredential(_proxySettings.proxyUser, _proxySettings.proxyPassword); WebClient wc = new WebClient(); wc.Proxy = wp; MemoryStream ms = new MemoryStream(wc.DownloadData(_path)); reader = new XmlTextReader(ms); } else { reader = new XmlTextReader(_path); } while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "module": UpdateAssemblyInfo someInfo = new UpdateAssemblyInfo(); someInfo.md5 = reader["md5"]; someInfo.name = reader["name"]; _assemblyList.Add(someInfo); break; } } } reader.Close(); } catch(Exception e) { Console.WriteLine(e.Message); return false; } return true; }
public ProxySettings(ProxySettings other) { isProxyEnable = other.isProxyEnable; proxyServer = other.proxyServer; proxyPort = other.proxyPort; proxyUser = other.proxyUser; proxyPassword = other.proxyPassword; }