/// <summary> /// 获取文件上传器 /// </summary> /// <param name="permission">权限路径</param> /// <param name="onUpload">上传结束委托</param> /// <param name="listName">列表名称</param> /// <param name="fileStream">文件流</param> /// <returns>文件上传器</returns> public static Action GetUpload(permission permission, Func <returnValue <fileState>, bool> onUpload , listName listName, Stream fileStream, int backupIdentity, bool isTimeVersion) { uploader uploader = typePool <uploader> .Pop() ?? new uploader(); uploader.permission = permission; uploader.listName = listName; uploader.onUpload = onUpload; uploader.fileStream = fileStream; uploader.backupIdentity = backupIdentity; uploader.isTimeVersion = isTimeVersion; return(uploader.uploadHandle); }
bool getFirmware(uploader.Uploader.Board device, bool custom = false) { // was https://raw.github.com/tridge/SiK/master/Firmware/dst/radio.hm_trp.hex // was http://www.samba.org/tridge/UAV/3DR/radio.hm_trp.hex // now http://firmware.diydrones.com/SiK/stable/ if (custom) { return getFirmwareLocal(device); } if (device == uploader.Uploader.Board.DEVICE_ID_HM_TRP) { if (beta) { return Common.getFilefromNet("http://firmware.diydrones.com/SiK/beta/radio~hm_trp.ihx", firmwarefile); } else { return Common.getFilefromNet("http://firmware.diydrones.com/SiK/stable/radio~hm_trp.ihx", firmwarefile); } } else if (device == uploader.Uploader.Board.DEVICE_ID_RFD900) { if (beta) { return Common.getFilefromNet("http://firmware.diydrones.com/SiK/beta/radio~rfd900.ihx", firmwarefile); } else { return Common.getFilefromNet("http://firmware.diydrones.com/SiK/stable/radio~rfd900.ihx", firmwarefile); } } else if (device == uploader.Uploader.Board.DEVICE_ID_RFD900A) { // return Common.getFilefromNet("http://rfdesign.com.au/firmware/MPSik%20V2.3%20radio~rfd900a.ihx", firmwarefile); if (beta) { return Common.getFilefromNet("http://firmware.diydrones.com/SiK/beta/radio~rfd900a.ihx", firmwarefile); } else { return Common.getFilefromNet("http://firmware.diydrones.com/SiK/stable/radio~rfd900a.ihx", firmwarefile); } } else { return false; } }
bool getFirmware(uploader.Uploader.Code device) { // was https://raw.github.com/tridge/SiK/master/Firmware/dst/radio.hm_trp.hex // now http://www.samba.org/tridge/UAV/3DR/radio.hm_trp.hex if (device == uploader.Uploader.Code.DEVICE_ID_HM_TRP) { return Common.getFilefromNet("http://www.samba.org/tridge/UAV/3DR/radio.hm_trp.hex", firmwarefile); } else if (device == uploader.Uploader.Code.DEVICE_ID_RFD900) { return Common.getFilefromNet("http://rfdesign.com.au/firmware/radio.rfd900.hex", firmwarefile); } else if (device == uploader.Uploader.Code.DEVICE_ID_RFD900A) { return Common.getFilefromNet("http://rfdesign.com.au/firmware/radio.rfd900a.hex", firmwarefile); } else { return false; } }
bool getFirmwareLocal(uploader.Uploader.Board device) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Firmware|*.hex;*.ihx"; openFileDialog1.RestoreDirectory = true; openFileDialog1.Multiselect = false; if (openFileDialog1.ShowDialog() == DialogResult.OK) { File.Copy(openFileDialog1.FileName, firmwarefile,true); return true; } return false; }
bool getFirmware(uploader.Uploader.Board device, bool custom = false) { if (custom) { return getFirmwareLocal(device); } if (device == uploader.Uploader.Board.DEVICE_ID_HM_TRP) { if (beta) { return Common.getFilefromNet("http://firmware.diydrones.com/SiK/beta/radio~hm_trp.ihx", firmwarefile); } else { return Common.getFilefromNet("http://firmware.diydrones.com/SiK/stable/radio~hm_trp.ihx", firmwarefile); } } else if (device == uploader.Uploader.Board.DEVICE_ID_RFD900) { if (beta) { return Common.getFilefromNet("http://firmware.diydrones.com/SiK/beta/radio~rfd900.ihx", firmwarefile); } else { return Common.getFilefromNet("http://rfdesign.com.au/firmware/radio.rfd900.hex", firmwarefile); } } else if (device == uploader.Uploader.Board.DEVICE_ID_RFD900A) { if (beta) { return Common.getFilefromNet("http://firmware.diydrones.com/SiK/beta/radio~rfd900a.ihx", firmwarefile); } else { return Common.getFilefromNet("http://rfdesign.com.au/firmware/radio.rfd900a.hex", firmwarefile); } } else if (device == uploader.Uploader.Board.DEVICE_ID_RFD900U) { if (beta) { return Common.getFilefromNet("http://rfdesign.com.au/firmware/radio~rfd900u.ihx", firmwarefile); } else { return Common.getFilefromNet("http://rfdesign.com.au/firmware/radio~rfd900u.ihx", firmwarefile); } } else if (device == uploader.Uploader.Board.DEVICE_ID_RFD900P) { if (beta) { return Common.getFilefromNet("http://rfdesign.com.au/firmware/radio~rfd900p.ihx", firmwarefile); } else { return Common.getFilefromNet("http://rfdesign.com.au/firmware/radio~rfd900p.ihx", firmwarefile); } } else { return false; } }
bool getFirmwareLocal(uploader.Uploader.Board device) { using (OpenFileDialog openFileDialog1 = new OpenFileDialog()) { openFileDialog1.Filter = "Firmware|*.hex;*.ihx"; openFileDialog1.RestoreDirectory = true; openFileDialog1.Multiselect = false; if (openFileDialog1.ShowDialog() == DialogResult.OK) { try { File.Copy(openFileDialog1.FileName, firmwarefile, true); } catch (Exception ex) { CustomMessageBox.Show("Error copying file\n" + ex.ToString(), "ERROR"); return false; } return true; } return false; } }