<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    ★33°空間‰


                           ----★七彩服飾  【最潮拜☆日單精品】【Esprit】【Hotwind】滿150包郵-女裝-流行女裝    www.7color.hb.cn

                           ----智力比知識(shí)重要,素質(zhì)比智力重要,覺(jué)悟比素質(zhì)更重要
    posts - 110,comments - 35,trackbacks - 0

    //這是一個(gè)webservice

    private AppUpdate.UpdateServ? UpdateSvr;


    ??private void button1_Click(object sender, System.EventArgs e)
    ??{
    ???
    ???if(LinkWebServices()==true)
    ???{
    ????this.label1.Text="連接服務(wù)器....... PASS";
    ????
    ????if(CheckVer()==true)
    ????{
    ?????this.label2.Text="檢查最新版本并下載.......PASS";
    ??????????????????
    ????}
    ????else
    ????{
    ?????this.label2.Text="檢查最新版本并下載.......FAIL";
    ????}
    ???}
    ???else
    ???{
    ????this.label1.Text="連接服務(wù)器.......FAIL";
    ???}
    ??}

    //這是用來(lái)與升級(jí)服務(wù)器建立連接
    ??private bool LinkWebServices()
    ??{
    ???try
    ???{
    ????UpdateSvr=new UpdateServ();
    ????return true;
    ???}
    ???catch
    ???{
    ????return false;
    ???}
    ??}

    //調(diào)用webservice用來(lái)檢查是不是有最新的版本
    ??private bool CheckVer()
    ??{
    ???string path =Application.StartupPath;
    ???try
    ???{
    ????VersionCheck(path);
    ????return true;
    ???}
    ???catch(Exception ex)
    ???{
    ????MessageBox.Show(ex.ToString());
    ????return false;
    ???}
    ??}

    ??private void VersionCheck(string desPath)
    ??{
    ???try
    ???{
    ????#region 查看文件和目錄
    ????if(!desPath.EndsWith(@"\"))
    ?????desPath += @"\";

    ????if(!System.IO.Directory.Exists(desPath))
    ????{
    ?????System.IO.Directory.CreateDirectory(desPath);
    ????}

    ????string tempPath = desPath + @"tempDesPathCache\";

    ????if(System.IO.Directory.Exists(tempPath))
    ????{
    ?????System.IO.Directory.Delete(tempPath,true);
    ?????System.IO.Directory.CreateDirectory(tempPath);
    ????}
    ????else
    ?????System.IO.Directory.CreateDirectory(tempPath);

    ????if(!System.IO.File.Exists(desPath + "UpdateConfig.xml"))
    ????{
    ?????System.Xml.XmlDocument updateConfig = new System.Xml.XmlDocument();
    ?????updateConfig.LoadXml(@"<root></root>");
    ?????updateConfig.Save(desPath + "UpdateConfig.xml");
    ????}
    ????#endregion

    ???
    ????System.Xml.XmlDocument serverXmlDoc = UpdateSvr.AppUpdateVertion();
    ????System.Xml.XmlDocument localXmlDoc = new System.Xml.XmlDocument();
    ????localXmlDoc.Load(desPath + "UpdateConfig.xml");
    ????bool newVersionExist = false;
    ????bool moduleExist = false;
    ????System.Xml.XmlNode serverNode0 = serverXmlDoc.ChildNodes[0];
    ????System.Xml.XmlNode localNode0 = localXmlDoc.ChildNodes[0];
    ????foreach(System.Xml.XmlNode serverNode in serverNode0)
    ????{
    ?????moduleExist = false;
    ?????foreach(System.Xml.XmlNode localNode in localNode0)
    ?????{
    ??????//找到對(duì)應(yīng)模塊
    ??????if(localNode.ChildNodes[0].InnerText == serverNode.ChildNodes[0].InnerText)
    ??????{
    ???????moduleExist = true;
    ???????//版本號(hào)判斷
    ???????if(localNode.ChildNodes[1].InnerText.CompareTo(serverNode.ChildNodes[1].InnerText) < 0)
    ???????{
    ????????newVersionExist = true;
    ????????if(System.Configuration.ConfigurationSettings.AppSettings["NetStyle"].ToString()=="internet")
    ????????{
    ?????????DownloadFile(serverNode.ChildNodes[2].InnerText,tempPath + serverNode.ChildNodes[0].InnerText);
    ????????}
    ????????else
    ????????{
    ?????????DownloadFile(serverNode.ChildNodes[3].InnerText,tempPath + serverNode.ChildNodes[0].InnerText);
    ????????}
    ???????}
    ???????break;
    ??????}
    ?????}
    ?????//沒(méi)找到對(duì)應(yīng)模塊
    ?????if(false == moduleExist)
    ?????{
    ??????
    ??????if(System.Configuration.ConfigurationSettings.AppSettings["NetStyle"].ToString()=="internet")
    ??????{
    ???????DownloadFile(serverNode.ChildNodes[2].InnerText,tempPath + serverNode.ChildNodes[0].InnerText);
    ??????}
    ??????else
    ??????{
    ???????DownloadFile(serverNode.ChildNodes[3].InnerText,tempPath + serverNode.ChildNodes[0].InnerText);
    ??????}
    ?????}
    ????}
    ????//寫(xiě)入新UpdateConfig.xml升級(jí)完畢后替換
    ????if(newVersionExist)
    ????{
    ?????serverXmlDoc.Save(tempPath + "UpdateConfig.xml");
    ?????if(DialogResult.Yes == MessageBox.Show("有新版本,是否更新?","提示",MessageBoxButtons.YesNo))
    ?????{
    ??????string[] dirs = System.IO.Directory.GetFiles(tempPath, "*.*");
    ??????string fileName;
    ??????foreach (string dir in dirs)
    ??????{
    ???????fileName = ((dir.Split(Convert.ToChar(@"\")))[dir.Split(Convert.ToChar(@"\")).Length - 1]);
    ???????if(System.IO.File.Exists(desPath + fileName))
    ???????{
    ????????//TODO:可以支持備份以前版本
    ????????System.IO.File.Delete(desPath + fileName);
    ???????}
    ???????//TODO:如果系統(tǒng)正在運(yùn)行,您得停止系統(tǒng),至于如何停止,也許可以使用System.Diagnostics.Process
    ???????System.IO.File.Move(dir,desPath + fileName);
    ??????}
    ??????MessageBox.Show("升級(jí)完畢");
    ?????}
    ?????else
    ?????{
    ??????//TODO:可以支持重新提示升級(jí)
    ?????}
    ????}
    ???}
    ???catch(Exception ex)
    ???{
    ????throw new Exception("升級(jí)失敗,原因是:" + ex.Message,ex);
    ???}
    ??}

    //下載最新的文件

    ??private void DownloadFile(string source,string fileName)
    ??{
    ???try
    ???{
    ????System.Net.WebClient myWebClient = new System.Net.WebClient();
    ????myWebClient.DownloadFile(source,fileName);
    ???}
    ???catch(Exception ex)
    ???{
    ????throw new Exception("下載失敗,原因是:" + ex.Message,ex);
    ???}
    ??}

    posted on 2006-09-20 12:51 圣域飛俠 閱讀(229) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): C#文章
    主站蜘蛛池模板: 亚洲AV午夜福利精品一区二区| 国语成本人片免费av无码| 免费永久国产在线视频| 亚洲国产午夜精品理论片在线播放 | 亚洲动漫精品无码av天堂| 日日摸夜夜添夜夜免费视频| 午夜亚洲av永久无码精品| 亚洲综合一区无码精品| 免费A级毛片无码免费视| 国产99在线|亚洲| 成年在线观看免费人视频草莓| 亚洲七久久之综合七久久| 四虎成人免费大片在线| 亚洲AV成人片无码网站| 免费在线观看亚洲| 二级毛片免费观看全程| 国产亚洲日韩一区二区三区| 中出五十路免费视频| 亚洲成a人片在线观看无码| 久久国产色AV免费观看| 亚洲午夜精品国产电影在线观看| 日韩欧毛片免费视频| 亚洲av永久无码一区二区三区| 四虎永久免费地址在线观看| 一级毛片不卡免费看老司机| 精品亚洲综合在线第一区| 最近免费中文字幕高清大全| 国产色在线|亚洲| 免费日本黄色网址| 99视频在线免费观看| 亚洲影视一区二区| 暖暖免费高清日本中文| jizz免费在线观看| 久久精品国产亚洲AV无码娇色| 18禁成年无码免费网站无遮挡| 国产成人高清亚洲一区91| 亚洲国产精品一区二区第一页 | 又爽又高潮的BB视频免费看| 男女一进一出抽搐免费视频| 亚洲国产综合专区电影在线| 午夜男人一级毛片免费|