/// <summary> /// 向Flash Memory写入文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnFlashWrite_Click(object sender, EventArgs e) { try { FormWriteFlashMemory formWriteFlashMemory = new FormWriteFlashMemory(); if (formWriteFlashMemory.ShowDialog() == DialogResult.OK) { string fileName = ""; this.txtFlashWrite.Text = formWriteFlashMemory.FilePath; if (formWriteFlashMemory.FilePath == null || formWriteFlashMemory.FilePath == "") { Log.GetInstance().WarningWrite("File name is empty"); return; } if (!File.Exists(formWriteFlashMemory.FilePath)) { Log.GetInstance().WarningWrite("File does not exist.path:" + formWriteFlashMemory.FilePath); return; } fileName = Path.GetFileName(formWriteFlashMemory.FilePath); var tasks = new List <Task>(); foreach (var iixServer in Global.ListIIXSerevr) { tasks.Add(Task.Factory.StartNew(() => { if (formWriteFlashMemory.IsUploadFile) { fileName = UploadFileByFtp(formWriteFlashMemory.FilePath, iixServer.Ip); } if (fileName == "") { return; } PgSelectCode pg = iixServer.SvrType == SvrType.Left ? PgSelectCode.Primary : PgSelectCode.Secondary; IIXExecute.WriteFlashMemory(iixServer, pg, fileName); })); } Task.WaitAll(tasks.ToArray()); } } catch (Exception ex) { Log.WriterExceptionLog(ex.ToString()); } }