public void Send(IList <string> tos, string subject, string body, Encoding subjectEncoding, Encoding bodyEncoding, bool isHtmlBody, string attachmentPath) { if (InterceptorEmitter != null) { var record = new CommInterceptorRecord(this.TagName); record.Count = tos.Count; var isSuccess = InterceptorEmitter.IsInterceptor(record); if (!isSuccess) { //将当前服务停止 //再次触发重发事件 this.Stop(); if (OnSendComplete != null) { OnSendComplete.Invoke(this, new SendResultEventArgs(this.TagName, tos, subject, GeneratorPackgeId.GetPakcageId(), body, bodyEncoding, subjectEncoding, isHtmlBody, "", SendResult.Ohter, "")); } return; } } _emailEmitter.Send(tos, subject, body, subjectEncoding, bodyEncoding, isHtmlBody, attachmentPath); }
public bool Send(EmailPackageData data) { try { Connect(); var mailMessage = data.GetProviderData(); _smtpClient.Send(mailMessage); OnSendComplete?.Invoke(this, new SendCompleteArgs(this.TagName, data)); return(true); } catch (Exception ex) { OnSendComplete?.Invoke(this, new SendCompleteArgs(this.TagName, data, false, ex)); return(false); } finally { this.CloseConnect(); } }
private void SendCore(string message, int partition) { byte[] buffer = Encoding.UTF8.GetBytes(message); var task = KafkaProducerHelper._dic[_broker].ProduceAsync(_topic.ToString(), null, 0, 0, buffer, 0, buffer.Length, partition, false); task.ContinueWith(p => { if (p.Result.Error.HasError) { OnSendError.Invoke(p.Result); } else { OnSendComplete.Invoke(p.Result); } }); }
private void SendRequest(string batchUrl, string postData, Dictionary <string, string> headers, Action <JArray> cb) { HttpRequest.Post(batchUrl, "", postData, headers, Mage.Cookies, (requestError, responseString) => { Logger.Verbose("Recieved response: " + responseString); // Check if there was a transport error if (requestError != null) { var error = "network"; // On error var httpError = requestError as HttpRequestException; if (httpError != null && httpError.Status == 503) { error = "maintenance"; } OnTransportError.Invoke(error, requestError); return; } // Parse reponse array JArray responseArray; try { responseArray = JArray.Parse(responseString); } catch (Exception parseError) { OnTransportError.Invoke("parse", parseError); return; } // Let CommandCenter know this batch was successful OnSendComplete.Invoke(); // Return array for processing cb(responseArray); }); }
private void SendComplete(IAsyncResult asyncResult) { m_Socket?.EndReceive(asyncResult); OnSendComplete?.Invoke(Id); }
protected void ExeceOnSendComplete(Transporter transporter, bool isComplete) { OnSendComplete?.Invoke(transporter, isComplete); }