Exemplo n.º 1
0
        /// <summary>发送告警</summary>
        /// <param name="groupName">告警组</param>
        /// <param name="webhook">告警Url</param>
        /// <param name="title">告警标题</param>
        /// <param name="message">告警消息</param>
        public static void SendAlarm(String groupName, String webhook, String title, String message)
        {
            XTrace.WriteLine(message);

            var group = AlarmGroup.FindByName(groupName);

            var hi = new AlarmHistory
            {
                GroupId = group?.Id ?? 0,
                Name    = groupName,
                Success = true,
                Action  = title,
                Content = message,

                Creator = Environment.MachineName,
            };

            try
            {
                if (webhook.IsNullOrEmpty() && group != null && group.Enable)
                {
                    webhook = group?.WebHook;
                }
                if (webhook.IsNullOrEmpty())
                {
                    throw new InvalidOperationException("未设置或未启用告警地址!");
                }

                if (webhook.Contains("qyapi.weixin"))
                {
                    hi.Category = "QyWeixin";

                    var weixin = new WeiXinClient {
                        Url = webhook
                    };

                    using var span = DefaultTracer.Instance?.NewSpan("SendWeixin", message);
                    weixin.SendMarkDown(message);
                }
                else if (webhook.Contains("dingtalk"))
                {
                    hi.Category = "DingTalk";

                    var dingTalk = new DingTalkClient {
                        Url = webhook
                    };

                    using var span = DefaultTracer.Instance?.NewSpan("SendDingTalk", message);
                    dingTalk.SendMarkDown(title, message, null);
                }
            }
            catch (Exception ex)
            {
                hi.Success  = false;
                hi.Content += Environment.NewLine + ex.ToString();
            }

            hi.SaveAsync();
        }
Exemplo n.º 2
0
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         AlarmHistory = _db.AlarmHistory.Where(o => o.RecoveryTime == null && o.DrillId == AppDrill.DrillID).FirstOrDefault();
     }
     catch { }
 }
Exemplo n.º 3
0
 private void btnAlarm_Click(object sender, EventArgs e)
 {
     panel1.Controls.Clear();
     almhis             = new AlarmHistory();
     almhis.Location    = new Point(0, 0);
     almhis.Name        = "UC_ToolManagement";
     almhis.MaximumSize = new System.Drawing.Size(0, 0);
     almhis.MinimumSize = new System.Drawing.Size(0, 0);
     almhis.Dock        = DockStyle.Fill;
     panel1.Controls.Add(almhis);
 }
Exemplo n.º 4
0
        public ActionResult UpdateAlarm(AlarmHistory alarm)
        {
            String retValue = String.Empty;

            if (alarm != null)
            {
                using (TowTruckServiceRef.TowTruckServiceClient service = new TowTruckServiceRef.TowTruckServiceClient())
                {
                    if (alarm.IsExcused)
                    {
                        service.ExcuseAlarm(alarm.VehicleNumber, alarm.BeatNumber, alarm.AlarmType, alarm.DriverName, alarm.Comments);
                        retValue = "Thank you! Alarm successfully excused";
                    }

                    else
                    {
                        service.UnexcuseAlarm(alarm.VehicleNumber, alarm.BeatNumber, alarm.AlarmType, alarm.DriverName, alarm.Comments);
                        retValue = "Thank you! Alarm successfully un-excused";
                    }
                }
            }

            return(Json(retValue, JsonRequestBehavior.AllowGet));
        }
 public int Delete(AlarmHistory model)
 {
     return(CommonAccess.ComSQLiteDelete(model, "ID"));
 }
 public int Update(AlarmHistory model, string _identity)
 {
     return(CommonAccess.ComSQLiteUpdate(model, _identity));
 }
 public int Insert(AlarmHistory model)
 {
     return(CommonAccess.ComSQLiteInsert(model));
 }
 public int delete(AlarmHistory _model)
 {
     return(dal.Delete(_model));
 }
 public int InsertOrUpdateBy(AlarmHistory _model, string _identity)
 {
     return(_model.ID == 0 ? dal.Insert(_model) : dal.Update(_model, _identity));
 }
Exemplo n.º 10
0
 public int UpdateBy(AlarmHistory _model, string _identity)
 {
     return(dal.Update(_model, _identity));
 }
Exemplo n.º 11
0
 public int Update(AlarmHistory _model)
 {
     return(dal.Update(_model, "ID"));
 }
Exemplo n.º 12
0
 public int Insert(AlarmHistory _model)
 {
     return(dal.Insert(_model));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes a default instance of the <see cref="AlarmDetailsReply"/> class.
 /// All properties except AlarmHistories will have their C# default value.
 /// AlarmHistories will default to an empty list to match the XML deserializer behavior
 /// when deserializing and empty AlarmDetailsReply element.
 /// </summary>
 public AlarmDetailsReply()
 {
     AlarmHistories = new AlarmHistory[0];
 }