public void Send() { if (this.path == null || this.path.Trim().Equals(string.Empty)) { this.Hint = "请指定上传的FTP目录!"; return; } if (this.fileName == null || this.fileName.Trim().Equals(string.Empty)) { this.Hint = "请选择一个文件!"; } else { string newName = System.IO.Path.GetFileName(this.fileName); FtpUpload ftpUpload = new FtpUpload(this.path, this.fileName, newName); if (this.userName != null && (!this.userName.Trim().Equals(string.Empty))) { ftpUpload.User = this.userName.Trim(); } if (this.pwd != null && (!this.pwd.Trim().Equals(string.Empty))) { ftpUpload.Pwd = this.pwd.Trim(); } try { ftpUpload.Upload(); } catch (Exception) { this.Hint = "文件上传失败,请检查FTP设置!"; return; } this.Hint = "文件上传成功!"; } }
public void OneKeySend() { if (this.SendList == null || this.SendList.Count == 0) { this.Hint = "请至少选择一个分发产品!"; return; } if (this.EmailOptions != null && this.EmailOptions.Count > 0) { this.Hint = "Email发送中..."; EmailSend email = new EmailSend(); email.EmailTo = new List <string>(); foreach (var item in this.EmailOptions) { if (item.IsSelected == true) { email.EmailTo.Add(item.Address.EmailName); } } email.Subject = ""; email.AttFileName = new List <string>(); foreach (var item in this.SendList) { email.AttFileName.Add(item); FileInfo fi = new FileInfo(item); if (fi.Extension.Equals(".doc") || fi.Extension.Equals(".docx")) { string name = Path.GetFileNameWithoutExtension(item); email.Subject = name; break; } email.Subject += new FileInfo(item).Name + " | "; } if (email.EmailTo.Count > 0) { email.Send(); } this.Hint = "Email发送完成!"; } if (this.NotesOptions != null && this.NotesOptions.Count > 0) { this.Hint = "Notes发送中..."; NotesSend notes = new NotesSend(); notes.MailTo = new List <string>(); foreach (var item in this.NotesOptions) { if (item.IsSelected == true) { notes.MailTo.Add(item.Address.NotesName); } } notes.Subject = ""; notes.AttFileName = new List <string>(); foreach (var item in this.SendList) { notes.AttFileName.Add(item); FileInfo fi = new FileInfo(item); if (fi.Extension.Equals(".doc") || fi.Extension.Equals(".docx")) { string name = Path.GetFileNameWithoutExtension(item); notes.Subject = name; break; } notes.Subject += new FileInfo(item).Name + " | "; } if (notes.MailTo.Count > 0) { notes.SendMail(); } this.Hint = "Notes发送完成!"; } if (this.ftpOptions != null && this.ftpOptions.Count > 0) { this.Hint = "FTP上传中..."; foreach (var op in this.ftpOptions) { if (op.IsSelected == true) { foreach (var file in this.SendList) { string newName = Path.GetFileName(new FileInfo(file).Name); FtpUpload ftpUpload = new FtpUpload(op.Address.FtpPath, file, newName); if (op.Address.FtpUserName != null && (!op.Address.FtpUserName.Trim().Equals(string.Empty))) { ftpUpload.User = op.Address.FtpUserName.Trim(); } if (op.Address.FtpPwd != null && (!op.Address.FtpPwd.Trim().Equals(string.Empty))) { ftpUpload.Pwd = op.Address.FtpPwd.Trim(); } try { ftpUpload.Upload(); } catch (Exception) { this.Hint = "FTP文件上传失败,请检查FTP设置!"; } } } } this.Hint = "FTP上传完成!"; } if (this.lanOptions != null && this.lanOptions.Count > 0) { this.Hint = "局域网上传中..."; foreach (var op in this.lanOptions) { if (op.IsSelected == true) { foreach (var file in this.SendList) { LanSend lanSend = new LanSend(file.Trim(), op.Address.LanPath.Trim()); if (op.Address.LanName != null && (!op.Address.LanName.Trim().Equals(string.Empty))) { lanSend.UserName = op.Address.LanName.Trim(); } if (op.Address.LanPwd != null && (!op.Address.LanPwd.Trim().Equals(string.Empty))) { lanSend.Pwd = op.Address.LanPwd.Trim(); } if (lanSend.SendFile() != true) { this.Hint = file + "上传失败!"; } } } } this.Hint = "局域网上传完成!"; this.Hint = "一键分发完成!"; } }