/// <summary> /// debug 에서는 Console에 출력하고 서버에게 전달할수있다. /// Release 에서는 Console에 출력하지않고 서버에게 전달한다. /// 만약 서버에게 전달하지않을거면 SendLog.Call() 을 제거해라 /// </summary> /// <param name="exception">Exception 을 넣는다.</param> /// <param name="token">서버에게 필요한 데이터</param> public static void e(Exception exception, string token = "") { string log = ExceptionLog.Call(exception); DebugPrint(log); SendLog.Call(token, log); }
/// <summary> /// 新しく通知を送信します /// </summary> public async Task <IHttpActionResult> Post(SendFormModel data) { // 送信されたデータが正しいか検証する if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var notifications = new List <Notification>(); // 送信するペイロードを作成 if (data.Windows > 0) { notifications.Add(Payloads.Windows.Create(data.Windows, data.Message)); } if (data.WindowsPhone > 0) { notifications.Add(Payloads.WindowsPhone.Create(data.WindowsPhone, data.Message)); } if (data.Apple > 0) { notifications.Add(Payloads.Apple.Create(data.Apple, data.Message)); } if (data.Android > 0) { notifications.Add(Payloads.Android.Create(data.Android, data.Message)); } // 送信先が 1 つもない場合にはエラー if (notifications.Count == 0) { return(BadRequest("Required Platform select.")); } // 通知ハブへ通知リクエストを非同期で送信 var tasks = notifications.Select(p => _client.SendNotificationAsync(p, data.TagExpression)); // 全ての通知リクエストの完了を待機する var results = await Task.WhenAll(tasks); // 送信結果を DB に保存 var sendLog = new SendLog { Message = data.Message, TagExpression = data.TagExpression, Success = results.Sum(p => p.Success), Failure = results.Sum(p => p.Failure), CreatedOn = DateTimeOffset.UtcNow }; _context.SendLogs.Add(sendLog); await _context.SaveChangesAsync(); return(Ok()); }
/// <inheritdoc /> public void Log(LogType logType, Object context, string message) { #if DEBUG string stackTrace = Environment.StackTrace; #else string stackTrace = string.Empty; #endif Internal_Log(logType, message, context?.unmanagedPtr ?? IntPtr.Zero, stackTrace); SendLog?.Invoke(logType, message, context, stackTrace); }
public void Log(LogType logType, FlaxEngine.Object context, string message) { Debug.Logger.LogHandler.Log(logType, context, message); #if DEBUG string stackTrace = Environment.StackTrace; #else string stackTrace = string.Empty; #endif SendLog?.Invoke(logType, message, context, stackTrace); }
protected void btnSendEmail_Click(object sender, EventArgs e) { string receiver = this.txtReceiver.Text.Trim(); string subject = this.txtSubject.Text.Trim(); MailMessage mailMessage = new MailMessage(); string content = this.hideMailContent.Value; mailMessage.From = "*****@*****.**"; mailMessage.Subject = subject; mailMessage.IsBodyHtml = true; mailMessage.HtmlBody = content; string[] users = receiver.Split(','); foreach (string user in users) { int startIndex = user.IndexOf('<') + 1; int length = user.Length; string email = user.Substring(startIndex, length - startIndex - 1); mailMessage.To.Add(email); } //创建附件 if (Session["tempTable"] != null) { DataTable table = (DataTable)Session["tempTable"]; foreach (DataRow row in table.Rows) { mailMessage.Attachments.Add(new Attachment(row["FilePath"].ToString())); } } SmtpClient client = AsposeUtilities.GetSmtpClient(this.Request.ApplicationPath); try { client.Send(mailMessage); using (var context = new EmailContext()) { var entity = new SendLog { Sender = CookieUtilities.GetCookieValue("username"), Receiver = receiver, SendTime = DateTime.Now, SendType = "Email" }; context.SendLogs.Add(entity); context.SaveChanges(); } ScriptManager.RegisterStartupScript(this.UpdatePanel1, GetType(), "a", "alert('邮件发送成功')", true); } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.UpdatePanel1, GetType(), "a", "alert('邮件发送失败!" + ex.Message + "')", true); } }
/// <inheritdoc /> public void Log(LogType logType, Object context, string message) { if (message == null) { return; } #if BUILD_RELEASE string stackTrace = null; #else string stackTrace = Environment.StackTrace; #endif Internal_Log(logType, message, Object.GetUnmanagedPtr(context), stackTrace); SendLog?.Invoke(logType, message, context, stackTrace); }
public void Output(string log) { if (this.LOG.InvokeRequired) { SendLog printlog = new SendLog(Output); this.LOG.Invoke(printlog, log); } else { this.LOG.AppendText(String.Format("{0}|{1}\r\n", DateTime.Now.ToString("hh:mm:ss"), log)); } // LOG.AppendText(log + "\n"); //DateTime.Now.ToString("HH:mm:ss") + " " + //LOG.Update(); }
protected void btnSendWeiXin_Click(object sender, EventArgs e) { string content = this.txtWeiXinContent.Text; try { int count = 0; foreach (RepeaterItem item in this.Repeater3.Items) { HtmlInputCheckBox checkBox = (HtmlInputCheckBox)item.FindControl("inlineCheckbox1"); if (checkBox.Checked) { count++; } } if (count == 0) { ScriptManager.RegisterStartupScript(this.UpdatePanel1, GetType(), "a", "alert('请选择接收用户')", true); return; } StringBuilder receiverBuilder = new StringBuilder(); foreach (RepeaterItem item in this.Repeater3.Items) { HtmlInputCheckBox checkBox = (HtmlInputCheckBox)item.FindControl("inlineCheckbox1"); } string receiver = receiverBuilder.ToString().TrimEnd(','); using (var context = new EmailContext()) { var entity = new SendLog { Sender = CookieUtilities.GetCookieValue("username"), Receiver = receiver, SendTime = DateTime.Now, SendType = "WeiXin" }; context.SendLogs.Add(entity); context.SaveChanges(); } ScriptManager.RegisterStartupScript(this.UpdatePanel1, GetType(), "a", "alert('微信发送成功')", true); } catch (Exception) { ScriptManager.RegisterStartupScript(this.UpdatePanel1, GetType(), "a", "alert('微信发送可能,可能部分用户我发收到微信内容!')", true); } }