Esempio n. 1
0
        //对比XML文件检查是否有升级条目
        private void XMLCheckUpdate()
        {
            label1.Text = "正在检查更新,请稍候...";
            string localXmlFile  = Application.StartupPath + "\\Update\\UpdateList.xml";
            string serverXmlFile = string.Empty;


            try
            {
                //从本地读取更新配置文件信息
                updaterXmlFiles = new XmlFiles(localXmlFile);
            }
            catch
            {
                MessageBox.Show("本地配置文件出错!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                return;
            }
            //获取服务器地址
            updateUrl = updaterXmlFiles.GetNodeValue("//Url");

            AppUpdater appUpdater = new AppUpdater();

            appUpdater.UpdaterUrl  = updateUrl + "/UpdateList.xml";
            appUpdater.UpdaterUrl1 = updateUrl + "/Update.xml";


            //与服务器连接,下载更新配置文件
            try
            {
                tempUpdatePath  = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "y" + "_" + "x" + "_" + "m" + "_" + "\\";                     //非配置文件临时文件顶级路径
                tempUpdatePath1 = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "y" + "_" + "x" + "_" + "m" + "_" + "\\" + "ISoft\\Update\\"; //配置文件临时文件路径
                appUpdater.DownAutoUpdateFile(tempUpdatePath1);
            }
            catch
            {
                MessageBox.Show("与服务器连接失败,操作超时!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
                return;
            }

            //获取更新文件列表
            Hashtable htUpdateFile = new Hashtable();

            serverXmlFile = tempUpdatePath1 + "\\UpdateList.xml";
            if (!File.Exists(serverXmlFile))
            {
                return;
            }

            availableUpdate = appUpdater.CheckForUpdate(serverXmlFile, localXmlFile, out htUpdateFile);
            if (availableUpdate > 0)
            {
                for (int i = 0; i < htUpdateFile.Count; i++)
                {
                    string[] fileArray = (string[])htUpdateFile[i];

                    lvUpdateList1.Items.Add(new ListViewItem(fileArray[0]));

                    if (fileArray[0] == "ISoft\\ISoft.exe")
                    {
                        fileArray[0] = "主程序";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\Update\\AutoUpdate.exe")
                    {
                        fileArray[0] = "自动更新程序";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\HotTools\\FileDestrory\\FileDestory.exe")
                    {
                        fileArray[0] = "文件粉碎机";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\HotTools\\Individuation\\Individuation.exe")
                    {
                        fileArray[0] = "个性化";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\HotTools\\RubbishCleaner\\RubbishCleaner.exe")
                    {
                        fileArray[0] = "垃圾清理";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\SysOptimizedTools\\OSSpeed\\OSSpeed.exe")
                    {
                        fileArray[0] = "系统加速";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\SysOptimizedTools\\ScanLargeFile\\ScanLargeFile.exe")
                    {
                        fileArray[0] = "大文件扫描";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\SysTools\\DefaultSet\\DefaultSet.exe")
                    {
                        fileArray[0] = "默认软件设置";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\SysTools\\ReadText\\ReadText.exe")
                    {
                        fileArray[0] = "语音朗读机";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\SysTools\\FileMonitor\\FileMonitor.exe")
                    {
                        fileArray[0] = "磁盘监视";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\SysTools\\TimeSyn\\TimeSyn.exe")
                    {
                        fileArray[0] = "时间同步助手";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\OtherTools\\VideoRec\\VideoRec.exe")
                    {
                        fileArray[0] = "视频录制器";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\OtherTools\\FileSplitAndJion\\FileSplitAndJion.exe")
                    {
                        fileArray[0] = "文件分割与合并";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\OtherTools\\CompTxt\\CompTxt.exe")
                    {
                        fileArray[0] = "文件内容比较器";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\OtherTools\\ThunderEncodeDecode\\ThunderEncodeDecode.exe")
                    {
                        fileArray[0] = "迅雷地址解码器";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }
                }
            }
            if (availableUpdate == 0)
            {
                InvalidateControl1();
            }
            else
            {
                label1.Text     = "以下为更新文件列表,请点击“下一步”开始更新";
                btnNext.Visible = true;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 检查更新文件
        /// </summary>
        /// <param name="serverXmlFile"></param>
        /// <param name="localXmlFile"></param>
        /// <param name="updateFileList"></param>
        /// <returns></returns>
        public int CheckForUpdate()
        {
            string localXmlFile = Application.StartupPath + "\\UpdateList.xml";

            if (!File.Exists(localXmlFile))
            {
                return(-1);
            }

            XmlFiles updaterXmlFiles = new XmlFiles(localXmlFile);


            string tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "y" + "_" + "x" + "_" + "m" + "_" + "\\";

            this.UpdaterUrl = updaterXmlFiles.GetNodeValue("//Url") + "/UpdateList.xml";
            this.DownAutoUpdateFile(tempUpdatePath);

            string serverXmlFile = tempUpdatePath + "\\UpdateList.xml";

            if (!File.Exists(serverXmlFile))
            {
                return(-1);
            }

            XmlFiles serverXmlFiles = new XmlFiles(serverXmlFile);
            XmlFiles localXmlFiles  = new XmlFiles(localXmlFile);

            XmlNodeList newNodeList = serverXmlFiles.GetNodeList("AutoUpdater/Files");
            XmlNodeList oldNodeList = localXmlFiles.GetNodeList("AutoUpdater/Files");

            int k = 0;

            for (int i = 0; i < newNodeList.Count; i++)
            {
                string [] fileList = new string[3];

                string newFileName = newNodeList.Item(i).Attributes["Name"].Value.Trim();
                string newVer      = newNodeList.Item(i).Attributes["Ver"].Value.Trim();

                ArrayList oldFileAl = new ArrayList();
                for (int j = 0; j < oldNodeList.Count; j++)
                {
                    string oldFileName = oldNodeList.Item(j).Attributes["Name"].Value.Trim();
                    string oldVer      = oldNodeList.Item(j).Attributes["Ver"].Value.Trim();

                    oldFileAl.Add(oldFileName);
                    oldFileAl.Add(oldVer);
                }
                int pos = oldFileAl.IndexOf(newFileName);
                if (pos == -1)
                {
                    fileList[0] = newFileName;
                    fileList[1] = newVer;
                    k++;
                }
                else if (pos > -1 && newVer.CompareTo(oldFileAl[pos + 1].ToString()) != 0)
                {
                    fileList[0] = newFileName;
                    fileList[1] = newVer;
                    k++;
                }
            }
            return(k);
        }
Esempio n. 3
0
        /// <summary>
        /// �������ļ�
        /// </summary>
        /// <param name="serverXmlFile"></param>
        /// <param name="localXmlFile"></param>
        /// <param name="updateFileList"></param>
        /// <returns></returns>
        public int CheckForUpdate()
        {
            string localXmlFile = Application.StartupPath + "\\UpdateList.xml";
            if(!File.Exists(localXmlFile))
            {
                return -1;
            }

            XmlFiles updaterXmlFiles = new XmlFiles(localXmlFile );

            string tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\"+ "_"+ updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value+"_"+"y"+"_"+"x"+"_"+"m"+"_"+"\\";
            this.UpdaterUrl = updaterXmlFiles.GetNodeValue("//Url") + "/UpdateList.xml";
            this.DownAutoUpdateFile(tempUpdatePath);

            string serverXmlFile = tempUpdatePath  +"\\UpdateList.xml";
            if(!File.Exists(serverXmlFile))
            {
                return -1;
            }

            XmlFiles serverXmlFiles = new XmlFiles(serverXmlFile);
            XmlFiles localXmlFiles = new XmlFiles(localXmlFile);

            XmlNodeList newNodeList = serverXmlFiles.GetNodeList("AutoUpdater/Files");
            XmlNodeList oldNodeList = localXmlFiles.GetNodeList("AutoUpdater/Files");

            int k = 0;
            for(int i = 0;i < newNodeList.Count;i++)
            {
                string [] fileList = new string[3];

                string newFileName = newNodeList.Item(i).Attributes["Name"].Value.Trim();
                string newVer = newNodeList.Item(i).Attributes["Ver"].Value.Trim();

                ArrayList oldFileAl = new ArrayList();
                for(int j = 0;j < oldNodeList.Count;j++)
                {
                    string oldFileName = oldNodeList.Item(j).Attributes["Name"].Value.Trim();
                    string oldVer = oldNodeList.Item(j).Attributes["Ver"].Value.Trim();

                    oldFileAl.Add(oldFileName);
                    oldFileAl.Add(oldVer);

                }
                int pos = oldFileAl.IndexOf(newFileName);
                if(pos == -1)
                {
                    fileList[0] = newFileName;
                    fileList[1] = newVer;
                    k++;
                }
                else if(pos > -1 && newVer.CompareTo(oldFileAl[pos+1].ToString())>0 )
                {
                    fileList[0] = newFileName;
                    fileList[1] = newVer;
                    k++;
                }

            }
            return k;
        }
Esempio n. 4
0
        private void FrmUpdate_Load(object sender, System.EventArgs e)
        {
            string localXmlFile  = Application.StartupPath + "\\Version.xml";
            string serverXmlFile = string.Empty;


            try
            {
                //从本地读取更新配置文件信息
                updaterXmlFiles = new XmlFiles(localXmlFile);
            }
            catch
            {
                //MessageBox.Show("配置文件出错!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
                WriteLog("配置文件出错");
                this.Close();
                return;
            }
            //获取服务器地址
            updateUrl = updaterXmlFiles.GetNodeValue("//Url");

            AppUpdater appUpdater = new AppUpdater();

            appUpdater.UpdaterUrl = updateUrl + "Version.xml";

            //WriteLog(appUpdater.UpdaterUrl);

            //与服务器连接,下载更新配置文件
            try
            {
                tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "u" + "_" + "p" + "_" + "\\";
                deleteDirectory(tempUpdatePath);//删除临时目录
                appUpdater.DownAutoUpdateFile(tempUpdatePath);
            }
            catch
            {
                //MessageBox.Show("与服务器连接失败,操作超时!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
                WriteLog("与服务器连接失败,操作超时!");
                this.Close();
                return;
            }

            //获取更新文件列表

            serverXmlFile = tempUpdatePath + "Version.xml";
            if (!File.Exists(serverXmlFile))
            {
                this.Close();
                return;
            }

            availableUpdate = appUpdater.CheckForUpdate(serverXmlFile, localXmlFile, out htUpdateFile);
            if (availableUpdate > 0)
            {
                if (DialogResult.OK == MessageBox.Show("发现新版本! 要更新吗?", mainAppName, MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
                {
                    for (int i = 0; i < htUpdateFile.Count; i++)
                    {
                        string[] fileArray = (string[])htUpdateFile[i];
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                    }

                    //this.btnNext_Click(sender, e);
                }
                else
                {
                    this.Close();//do not need to open the window
                }
            }
            else
            {
                this.Close();
            }
        }
Esempio n. 5
0
        private void FrmUpdate_Load(object sender, System.EventArgs e)
        {
//			if (!CheckInetConnection())
//			{
//				MessageBox.Show("无网络连接!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
//				this.Close();
//				return;
//			}

            panel2.Visible    = false;
            btnFinish.Visible = false;

            string localXmlFile  = Application.StartupPath + "\\UpdateList.xml";
            string serverXmlFile = string.Empty;


            try
            {
                //从本地读取更新配置文件信息
                updaterXmlFiles = new XmlFiles(localXmlFile);
            }
            catch
            {
                MessageBox.Show("配置文件出错!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                return;
            }
            //获取服务器地址
            updateUrl = updaterXmlFiles.GetNodeValue("//Url");

            AppUpdater appUpdater = new AppUpdater();

            appUpdater.UpdaterUrl = updateUrl + "/UpdateList.xml";

            //与服务器连接,下载更新配置文件
            try
            {
                tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "y" + "_" + "x" + "_" + "m" + "_" + "\\";
                appUpdater.DownAutoUpdateFile(tempUpdatePath);
            }
            catch
            {
                MessageBox.Show("与服务器连接失败,操作超时!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
                return;
            }

            //获取更新文件列表
            Hashtable htUpdateFile = new Hashtable();

            serverXmlFile = tempUpdatePath + "\\UpdateList.xml";
            if (!File.Exists(serverXmlFile))
            {
                return;
            }

            availableUpdate = appUpdater.CheckForUpdate(serverXmlFile, localXmlFile, out htUpdateFile);
            if (availableUpdate > 0)
            {
                for (int i = 0; i < htUpdateFile.Count; i++)
                {
                    string [] fileArray = (string [])htUpdateFile[i];
                    lvUpdateList.Items.Add(new ListViewItem(fileArray));
                }
            }
//			else
//				btnNext.Enabled = false;
        }
Esempio n. 6
0
        private void CheckWrok()
        {
            string strXmlPath = Application.StartupPath + "\\UpdateList.xml", serverXmlFile = string.Empty;

            try
            {
                m_UpdaterXmlFiles = new XmlFiles(strXmlPath);
            }
            catch (Exception exc)
            {
                MessageBox.Show("��ȡ�����ļ�����!" + exc.Message, "����", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            m_Url = m_UpdaterXmlFiles.GetNodeValue("//Url");

            AppUpdater appUpdater = new AppUpdater();
            appUpdater.UpdaterUrl = m_Url + "/UpdateList.xml";
            try
            {
                m_TempPath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + m_UpdaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "l" + "_" + "i" + "_" + "s" + "_";
                appUpdater.DownAutoUpdateFile(m_TempPath);
            }
            catch (Exception exc)
            {
                MessageBox.Show("�����������ʧ��,������ʱ!" + exc.Message, "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }

            //��ȡ�����ļ��б�
            Hashtable htUpdateFile = new Hashtable();
            serverXmlFile = m_TempPath + "\\UpdateList.xml";
            if (!File.Exists(serverXmlFile))
                return;
            m_UpdateCount = appUpdater.CheckForUpdate(serverXmlFile, strXmlPath, out htUpdateFile);
            if (m_UpdateCount > 0)
            {
                label1.Text = "��������Ҫ���µ��ļ��б��";
                btnNext.Enabled = true;
                for (int i = 0; i < htUpdateFile.Count; i++)
                {
                    string[] fileArray = (string[])htUpdateFile[i];
                    lvUpdateList.Items.Add(new ListViewItem(fileArray));
                }
            }
            else
            {
                label1.Text = "δ������Ҫ���µ��ļ���";
                MessageBox.Show("��ǰΪ���°汾��");
                this.Close();
                Application.ExitThread();
                Application.Exit();
            }
        }
Esempio n. 7
0
        private void update_Tick(object sender, EventArgs e)
        {
            timer.Stop();
            timer.Dispose();
            if (!IsConnectInternet())
            {
                label1.Visible = true;
                label7.Text    = "无法连接到互联网!";
                MessageBox.Show(this, "无法连接到互联网,请检查网络!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            string localXmlFile  = Application.StartupPath + "\\UpdateList.xml";
            string serverXmlFile = string.Empty;

            try
            {
                //从本地读取更新配置文件信息
                updaterXmlFiles = new XmlFiles(localXmlFile);
            }
            catch
            {
                MessageBox.Show(this, "读取配置文件出错,请联系管理员!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                return;
            }
            //获取服务器地址
            updateUrl = updaterXmlFiles.GetNodeValue("//Url");
            AppUpdater appUpdater = new AppUpdater();

            appUpdater.UpdaterUrl = updateUrl + "/UpdateList.xml";
            //与服务器连接,下载更新配置文件
            try
            {
                tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "y" + "_" + "x" + "_" + "m" + "_" + "\\";
                appUpdater.DownAutoUpdateFile(tempUpdatePath);
            }
            catch
            {
                MessageBox.Show(this, "与服务器连接失败,请求超时!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                return;
            }
            //获取更新文件列表
            Hashtable htUpdateFile = new Hashtable();

            serverXmlFile = tempUpdatePath + "\\UpdateList.xml";
            if (!File.Exists(serverXmlFile))
            {
                label1.Visible = true;
                label7.Text    = "当前版本已经是最新版本!";
                label7.Visible = true;
                MessageBox.Show(this, "当前版本已经是最新版本!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
                return;
            }
            availableUpdate = appUpdater.CheckForUpdate(serverXmlFile, localXmlFile, out htUpdateFile);
            if (availableUpdate > 0)
            {
                //获取更新内容说明
                this.txt_updateNotes.Visible     = true;
                this.panel_updateNotes.Visible   = true;
                this.btn_showUpdateNotes.Enabled = true;
                this.btn_showUpdateNotes.Text    = "查看更新列表(&S)";
                string[] updateNotes = appUpdater.GetUpdateNotes(serverXmlFile);
                if (updateNotes != null)
                {
                    foreach (string note in updateNotes)
                    {
                        this.txt_updateNotes.AppendText(note + "\r\n");
                    }
                }
                else
                {
                    this.txt_updateNotes.AppendText("暂时没有版本更新说明!");
                }

                for (int i = 0; i < htUpdateFile.Count; i++)
                {
                    string[] fileArray = (string[])htUpdateFile[i];
                    lvUpdateList.Items.Add(new ListViewItem(fileArray));
                }
                label1.Visible       = true;
                label1.Text          = "发现新版本";
                lvUpdateList.Visible = true;
                lbState.Visible      = true;
                pbDownFile.Visible   = true;
                label7.Visible       = false;
                btnNext.Enabled      = true;
            }
            else
            {
                label1.Visible = true;
                label7.Text    = "当前版本已经是最新版本!";
                label7.Visible = true;
                MessageBox.Show(this, "当前版本已经是最新版本!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
        }
Esempio n. 8
0
		private void FrmUpdate_Load(object sender, System.EventArgs e)
		{
			
			panel2.Visible = false;
			btnFinish.Visible = false;

			string localXmlFile = Application.StartupPath + "\\UpdateList.xml";
			string serverXmlFile = string.Empty;

			
			try
			{
				//从本地读取更新配置文件信息
				updaterXmlFiles = new XmlFiles(localXmlFile );
			}
			catch
			{
				MessageBox.Show("配置文件出错!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
				this.Close();
				return;
			}
			//获取服务器地址
			updateUrl = updaterXmlFiles.GetNodeValue("//Url");

			AppUpdater appUpdater = new AppUpdater();
			appUpdater.UpdaterUrl = updateUrl + "/UpdateList.xml";

			//与服务器连接,下载更新配置文件
			try
			{
				tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\"+ "_"+ updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value+"_"+"y"+"_"+"x"+"_"+"m"+"_"+"\\";
				appUpdater.DownAutoUpdateFile(tempUpdatePath);
			}
			catch
			{
				MessageBox.Show("与服务器连接失败,操作超时!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
				this.Close();
				return;

			}

			//获取更新文件列表
			Hashtable htUpdateFile = new Hashtable();

			serverXmlFile = tempUpdatePath + "\\UpdateList.xml";
			if(!File.Exists(serverXmlFile))
			{
				return;
			}

			availableUpdate = appUpdater.CheckForUpdate(serverXmlFile,localXmlFile,out htUpdateFile);
			if (availableUpdate > 0)
			{
				for(int i=0;i<htUpdateFile.Count;i++)
				{
					string [] fileArray =(string []) htUpdateFile[i];
					lvUpdateList.Items.Add(new ListViewItem(fileArray));
				}
			}
//			else
//				btnNext.Enabled = false;
		}
        public int CheckUpdate()
        {
            string localXmlFile  = Application.StartupPath + "\\UpdateList.xml";
            string serverXmlFile = string.Empty;

            try
            {
                //从本地读取更新配置文件信息
                updaterXmlFiles = new XmlFiles(localXmlFile);
            }
            catch
            {
                //MessageBox.Show("配置文件出错!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(-1);
            }
            //获取服务器地址
            updateUrl = updaterXmlFiles.GetNodeValue("//Url");

            AppUpdater appUpdater = new AppUpdater();

            appUpdater.UpdaterUrl = updateUrl + "/UpdateList.xml";

            //与服务器连接,下载更新配置文件
            try
            {
                tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "y" + "_" + "x" + "_" + "m" + "_" + "\\";
                appUpdater.DownAutoUpdateFile(tempUpdatePath);
            }
            catch
            {
                //MessageBox.Show("与服务器连接失败,操作超时!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(-2);
            }

            //获取更新文件列表
            Hashtable htUpdateFile = new Hashtable();

            serverXmlFile = tempUpdatePath + "\\UpdateList.xml";
            if (!File.Exists(serverXmlFile))
            {
                return(-3);
            }

            availableUpdate = appUpdater.CheckForUpdate(serverXmlFile, localXmlFile, out htUpdateFile);

            return(availableUpdate);
        }
Esempio n. 10
0
        //�Ա�XML�ļ�����Ƿ���������Ŀ
        private void XMLCheckUpdate()
        {
            label1.Text = "���ڼ����£����Ժ�...";
            string localXmlFile = Application.StartupPath + "\\Update\\UpdateList.xml";
            string serverXmlFile = string.Empty;

            try
            {
                //�ӱ��ض�ȡ���������ļ���Ϣ
                updaterXmlFiles = new XmlFiles(localXmlFile);
            }
            catch
            {
                MessageBox.Show("���������ļ�����!", "����", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                return;
            }
            //��ȡ��������ַ
            updateUrl = updaterXmlFiles.GetNodeValue("//Url");

            AppUpdater appUpdater = new AppUpdater();
            appUpdater.UpdaterUrl = updateUrl + "/UpdateList.xml";
            appUpdater.UpdaterUrl1 = updateUrl + "/Update.xml";

            //�����������,���ظ��������ļ�
            try
            {
                tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "y" + "_" + "x" + "_" + "m" + "_" + "\\";//�������ļ���ʱ�ļ�����·��
                tempUpdatePath1 = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "y" + "_" + "x" + "_" + "m" + "_" + "\\" + "ISoft\\Update\\";//�����ļ���ʱ�ļ�·��
                appUpdater.DownAutoUpdateFile(tempUpdatePath1);
            }
            catch
            {
                MessageBox.Show("�����������ʧ��,������ʱ!", "��ʾ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
                return;

            }

            //��ȡ�����ļ��б�
            Hashtable htUpdateFile = new Hashtable();

            serverXmlFile = tempUpdatePath1 + "\\UpdateList.xml";
            if (!File.Exists(serverXmlFile))
            {
                return;
            }

            availableUpdate = appUpdater.CheckForUpdate(serverXmlFile, localXmlFile, out htUpdateFile);
            if (availableUpdate > 0)
            {
                for (int i = 0; i < htUpdateFile.Count; i++)
                {
                    string[] fileArray = (string[])htUpdateFile[i];

                    lvUpdateList1.Items.Add(new ListViewItem(fileArray[0]));

                    if (fileArray[0] == "ISoft\\ISoft.exe")
                    {
                        fileArray[0] = "������";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\Update\\AutoUpdate.exe")
                    {
                        fileArray[0] = "�Զ����³���";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\HotTools\\FileDestrory\\FileDestory.exe")
                    {
                        fileArray[0] = "�ļ������";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\HotTools\\Individuation\\Individuation.exe")
                    {
                        fileArray[0] = "���Ի�";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\HotTools\\RubbishCleaner\\RubbishCleaner.exe")
                    {
                        fileArray[0] = "��������";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\SysOptimizedTools\\OSSpeed\\OSSpeed.exe")
                    {
                        fileArray[0] = "ϵͳ����";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\SysOptimizedTools\\ScanLargeFile\\ScanLargeFile.exe")
                    {
                        fileArray[0] = "���ļ�ɨ��";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\SysTools\\DefaultSet\\DefaultSet.exe")
                    {
                        fileArray[0] = "Ĭ���������";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\SysTools\\ReadText\\ReadText.exe")
                    {
                        fileArray[0] = "�����ʶ���";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\SysTools\\FileMonitor\\FileMonitor.exe")
                    {
                        fileArray[0] = "���̼���";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\SysTools\\TimeSyn\\TimeSyn.exe")
                    {
                        fileArray[0] = "ʱ��ͬ������";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\OtherTools\\VideoRec\\VideoRec.exe")
                    {
                        fileArray[0] = "��Ƶ¼����";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\OtherTools\\FileSplitAndJion\\FileSplitAndJion.exe")
                    {
                        fileArray[0] = "�ļ��ָ���ϲ�";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\OtherTools\\CompTxt\\CompTxt.exe")
                    {
                        fileArray[0] = "�ļ����ݱȽ���";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }

                    if (fileArray[0] == "ISoft\\AdvancedFunctions\\OtherTools\\ThunderEncodeDecode\\ThunderEncodeDecode.exe")
                    {
                        fileArray[0] = "Ѹ�׵�ַ������";
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                        continue;
                    }
                }
            }
            if (availableUpdate == 0)
            {
                InvalidateControl1();
            }
            else
            {
                label1.Text = "����Ϊ�����ļ��б����������һ������ʼ����";
                btnNext.Visible = true;
            }
        }
Esempio n. 11
0
        private void FrmUpdate_Load(object sender, System.EventArgs e)
        {
            panel2.Visible    = false;
            btnFinish.Visible = false;

            string localXmlFile  = Application.StartupPath + "\\UpdateList.xml";
            string serverXmlFile = string.Empty;


            try
            {
                //从本地读取更新配置文件信息
                TempLog.Debug("准备加载启动路径下的UpdateList.xml更新文件!");
                updaterXmlFiles = new XmlFiles(localXmlFile);
                mainAppExe      = updaterXmlFiles.GetNodeValue("//EntryPoint");
                TempLog.Debug("加载启动路径下的UpdateList.xml更新文件并读取更新完需执行的exe文件名完毕!");
            }
            catch (Exception ex)
            {
                TempLog.Info("加载UpdateList.xml出现异常:" + ex);
                //MessageBox.Show("配置文件出错!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
                this.StartMainApplication();
                return;
            }
            //获取服务器地址
            updateUrl = updaterXmlFiles.GetNodeValue("//Url");

            AppUpdater appUpdater = new AppUpdater();

            appUpdater.UpdaterUrl = updateUrl + "UpdateList.xml";

            //与服务器连接,下载更新配置文件
            try
            {
                TempLog.Debug("准备下载更新配置文件列表UpdateList.xml");
                tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "y" + "_" + "x" + "_" + "m" + "_" + "\\";
                appUpdater.DownAutoUpdateFile(tempUpdatePath);
                TempLog.Debug("完成下载更新配置文件列表UpdateList.xml");
            }
            catch (Exception ex)
            {
                TempLog.Info("下载更新配置文件列表UpdateList.xml出现异常:" + ex);
                //MessageBox.Show("与服务器连接失败,操作超时!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
                this.StartMainApplication();
                return;
            }

            //获取更新文件列表
            Hashtable htUpdateFile = new Hashtable();

            serverXmlFile = tempUpdatePath + "\\UpdateList.xml";
            if (!File.Exists(serverXmlFile))
            {
                return;
            }

            availableUpdate = appUpdater.CheckForUpdate(serverXmlFile, localXmlFile, out htUpdateFile);
            if (availableUpdate > 0)
            {
                for (int i = 0; i < htUpdateFile.Count; i++)
                {
                    string [] fileArray = (string [])htUpdateFile[i];
                    lvUpdateList.Items.Add(new ListViewItem(fileArray));
                }
            }
            this.lbFileListHint.Text = string.Format("共{0}个文件待更新,准备更新中{1}", lvUpdateList.Items.Count.ToString(), string.Empty);
            btnNext_Click(null, null);
//			else
//				btnNext.Enabled = false;
        }
Esempio n. 12
0
        private void CheckWrok()
        {
            string strXmlPath = Application.StartupPath + "\\UpdateList.xml", serverXmlFile = string.Empty;

            try
            {
                m_UpdaterXmlFiles = new XmlFiles(strXmlPath);
            }
            catch (Exception exc)
            {
                MessageBox.Show("读取配置文件出错!" + exc.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
            m_Url = m_UpdaterXmlFiles.GetNodeValue("//Url");

            AppUpdater appUpdater = new AppUpdater();

            appUpdater.UpdaterUrl = m_Url + "/UpdateList.xml";
            try
            {
                m_TempPath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + m_UpdaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "l" + "_" + "i" + "_" + "s" + "_";
                appUpdater.DownAutoUpdateFile(m_TempPath);
            }
            catch (Exception exc)
            {
                MessageBox.Show("与服务器连接失败,操作超时!" + exc.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }

            //获取更新文件列表
            Hashtable htUpdateFile = new Hashtable();

            serverXmlFile = m_TempPath + "\\UpdateList.xml";
            if (!File.Exists(serverXmlFile))
            {
                return;
            }
            m_UpdateCount = appUpdater.CheckForUpdate(serverXmlFile, strXmlPath, out htUpdateFile);
            if (m_UpdateCount > 0)
            {
                label1.Text     = "以下是需要更新的文件列表:";
                btnNext.Enabled = true;
                for (int i = 0; i < htUpdateFile.Count; i++)
                {
                    string[] fileArray = (string[])htUpdateFile[i];
                    lvUpdateList.Items.Add(new ListViewItem(fileArray));
                }
            }
            else
            {
                label1.Text = "未发现需要更新的文件!";
                MessageBox.Show("当前为最新版本!");
                this.Close();
                Application.ExitThread();
                Application.Exit();
            }
        }
Esempio n. 13
0
        private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
        {
            string localXmlFile  = Application.StartupPath + "\\UpdateList.xml";
            string serverXmlFile = string.Empty;


            try
            {
                //从本地读取更新配置文件信息
                updaterXmlFiles = new XmlFiles(localXmlFile);
            }
            catch (Exception ee)
            {
                MessageBox.Show("配置文件出错!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                return;
            }
            //获取服务器地址
            updateUrl = updaterXmlFiles.GetNodeValue("//Url");

            AppUpdater appUpdater = new AppUpdater();

            appUpdater.UpdaterUrl = updateUrl + "/UpdateList.xml";

            //与服务器连接,下载更新配置文件
            try
            {
                tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "y" + "_" + "x" + "_" + "m" + "_" + "\\";
                appUpdater.DownAutoUpdateFile(tempUpdatePath);
            }
            catch
            {
                MessageBox.Show("与服务器连接失败,操作超时!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
                return;
            }

            //获取更新文件列表
            htUpdateFile = new Hashtable();

            serverXmlFile = tempUpdatePath + "\\UpdateList.xml";
            if (!File.Exists(serverXmlFile))
            {
                MessageBox.Show("更新地址错误");
                Application.Exit();
                return;
            }

            availableUpdate = appUpdater.CheckForUpdate(serverXmlFile, localXmlFile, out htUpdateFile);
        }
Esempio n. 14
0
        public int CheckForUpdate()
        {
            string text = Application.StartupPath + "\\UpdateList.xml";
            int    result;

            if (!File.Exists(text))
            {
                result = -1;
            }
            else
            {
                XmlFiles xmlFiles = new XmlFiles(text);
                string   text2    = Environment.GetEnvironmentVariable("Temp") + "\\_" + xmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_y_x_m_\\";
                this.UpdaterUrl = xmlFiles.GetNodeValue("//Url") + "/UpdateList.xml";
                this.DownAutoUpdateFile(text2);
                string text3 = text2 + "\\UpdateList.xml";
                if (!File.Exists(text3))
                {
                    result = -1;
                }
                else
                {
                    XmlFiles    xmlFiles2 = new XmlFiles(text3);
                    XmlFiles    xmlFiles3 = new XmlFiles(text);
                    XmlNodeList nodeList  = xmlFiles2.GetNodeList("AutoUpdater/Files");
                    XmlNodeList nodeList2 = xmlFiles3.GetNodeList("AutoUpdater/Files");
                    int         num       = 0;
                    for (int i = 0; i < nodeList.Count; i++)
                    {
                        string[]  array     = new string[3];
                        string    text4     = nodeList.Item(i).Attributes["Name"].Value.Trim();
                        string    text5     = nodeList.Item(i).Attributes["Ver"].Value.Trim();
                        ArrayList arrayList = new ArrayList();
                        for (int j = 0; j < nodeList2.Count; j++)
                        {
                            string value  = nodeList2.Item(j).Attributes["Name"].Value.Trim();
                            string value2 = nodeList2.Item(j).Attributes["Ver"].Value.Trim();
                            arrayList.Add(value);
                            arrayList.Add(value2);
                        }
                        int num2 = arrayList.IndexOf(text4);
                        if (num2 == -1)
                        {
                            array[0] = text4;
                            array[1] = text5;
                            num++;
                        }
                        else if (num2 > -1 && text5.CompareTo(arrayList[num2 + 1].ToString()) > 0)
                        {
                            array[0] = text4;
                            array[1] = text5;
                            num++;
                        }
                    }
                    result = num;
                }
            }
            return(result);
        }