Beispiel #1
0
 public frmAppSync()
 {
     szHost               = CINIFile.IniReadValue("基本信息", "FTP_IP", AppDomain.CurrentDomain.BaseDirectory + "base.ini");
     m_pUpdateID          = CINIFile.IniReadValue("基本信息", "更新标识", AppDomain.CurrentDomain.BaseDirectory + "base.ini");
     NetWorkCls.onNotify += new Notity(NetWorkCls_onNotify);
     InitializeComponent();
 }
Beispiel #2
0
 void webClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         FileInfo fileInfo = new FileInfo(string.Format("{0}\\{1}", DOWNPATH, m_pFileName));
         if (fileInfo.Length == m_nDownLoadSize)
         {
             AddMsg("下载完成,准备安装");
             if (SetupNewSoft())
             {
                 CINIFile.IniWriteValue("基本信息", "软件版本", m_pVersion, APPBASEPATH);
                 CINIFile.IniWriteValue("基本信息", "更新时间", DateTime.Now.ToString(), APPBASEPATH);
                 try
                 {
                     AddMsg("服务器提交更新完成标识...");
                     string   loginUrl = "http://www.zzdawei.com/app/rainfalls.aspx";
                     Encoding encoding = Encoding.GetEncoding("gb2312");
                     IDictionary <string, string> parameters = new Dictionary <string, string>();
                     parameters.Add("id", m_pUpdateID);
                     parameters.Add("version", m_pVersion);
                     HttpWebResponse response = HttpWebResponseUtility.CreatePostHttpResponse(loginUrl, parameters, null, null, encoding, null);
                 }
                 catch (Exception err)
                 {
                     AddMsg("提交更新标识失败:" + err.Message);
                 }
             }
         }
         else
         {
             AddMsg("文件下载不完整,请重试");
         }
     }
     else
     {
         AddMsg(string.Format("下载文件时发生错误:{0}", e.Error.Message));
         AddMsg(string.Format("下载文件时发生错误,请重试"));
     }
 }
Beispiel #3
0
 private void Completed(object sender, AsyncCompletedEventArgs e)
 {
     if (e.Error == null)
     {
         if (File.Exists(DownloadXMLPath))
         {
             long   lRemoteAppVersion;
             string szRemoteAppVersion = CINIFile.IniReadValue("APP", "Version", DownloadXMLPath);
             if (!string.IsNullOrEmpty(szRemoteAppVersion))
             {
                 m_pVersion         = szRemoteAppVersion;
                 szRemoteAppVersion = szRemoteAppVersion.Replace(".", "");
                 if (long.TryParse(szRemoteAppVersion, out lRemoteAppVersion))
                 {
                     string szLocalAppVersion = CINIFile.IniReadValue("基本信息", "软件版本", APPBASEPATH);
                     szLocalAppVersion = szLocalAppVersion.Replace(".", "");
                     long lpLocalAppVersion = long.TryParse(szLocalAppVersion, out lpLocalAppVersion) ? lpLocalAppVersion : 0;
                     if (lRemoteAppVersion > lpLocalAppVersion)
                     {
                         AddMsg("发现新版本,准备下载");
                         string dFile = CINIFile.IniReadValue("APP", "File", DownloadXMLPath);
                         DownLoadFile(dFile);
                     }
                     else
                     {
                         AddMsg("当前已是最新版本");
                     }
                 }
             }
         }
     }
     else
     {
         AddMsg(string.Format("检查更新时发生错误:{0}", e.Error.Message));
     }
 }