Пример #1
0
 private new void Update()
 {
     isUpdating = true;
     if (updateVersionList.Count > 0)
     {
         int step = updateVersionList.Count;
         int i    = 0;
         foreach (FileVersion fileVersion in updateVersionList)
         {
             com.ccf.bip.framework.server.file.FileInfo fileInfo = this.FindOne <com.ccf.bip.framework.server.file.FileInfo>(Globals.PROGRAM_UPDATE_SERVICE_NAME, "download", new object[] { fileVersion.GetFullName() });
             //无法从服务器获取文件时忽略该文件更新,下次重新更新
             if (fileInfo == null)
             {
                 FileVersion tempVersion = remoteVersionList.Find(r => r.GetFullName().Equals(fileVersion.GetFullName()));
                 if (tempVersion != null)
                 {
                     if (tempVersion.Version > 1)
                     {
                         tempVersion.Version = tempVersion.Version - 1;
                     }
                     else
                     {
                         remoteVersionList.Remove(tempVersion);
                     }
                 }
                 continue;
             }
             string fullName = Globals.AppPath + Path.DirectorySeparatorChar.ToString() + fileVersion.GetFullName();
             string fullPath = Globals.AppPath + Path.DirectorySeparatorChar.ToString() + fileVersion.Directory;
             if (!Directory.Exists(fullPath))
             {
                 Directory.CreateDirectory(fullPath);
             }
             else
             {
                 if (File.Exists(fullName))
                 {
                     File.Delete(fullName);
                 }
             }
             File.WriteAllBytes(fullName, fileInfo.Content);
             Invoke(new ShowDelegete(UpdateProgressValue), new object[] { (++i) * 100 / step < 100 ? i * 100 / step : 100 });
             Thread.Sleep(1000);
             //progressBar1.Value = (++i) * 100 / step < 100 ? i * 100 / step : 100;
         }
         //update version
         BipConfig.StoreObject(Globals.FileVersionConfigName, remoteVersionList);
     }
     isUpdating = false;
     //run bip
     Invoke(new UpdateDelegate(RunBip));
 }
Пример #2
0
 private void Upload()
 {
     com.ccf.bip.framework.server.file.FileInfo fileInfo = new com.ccf.bip.framework.server.file.FileInfo();
     fileInfo.Directory = this.UploadDirectory;
     foreach (UltraGridRow row in ultraGrid1.Rows)
     {
         string fullName = row.Cells[0].Value.ToString();
         fileInfo.Name      = fullName.Substring(fullName.LastIndexOf(Path.DirectorySeparatorChar) + 1);
         fileInfo.Content   = FileUtil.FileToArray(fullName);
         row.Cells[1].Value = "正在上传";
         try
         {
             this.Update(Globals.PROGRAM_UPDATE_SERVICE_NAME, "upload", new object[] { fileInfo });
             row.Cells[1].Value = "上传成功";
         }
         catch (Exception ex)
         {
             row.Cells[1].Value = "上传失败";
         }
     }
     metroButtonUpload.Enabled = false;
 }