Ejemplo n.º 1
0
 /// <summary>
 /// 添加报警
 /// </summary>
 public static void AddAlarm(Alarm alarm)
 {
     alarm.AlarmTime = DateTime.Now;
     Task.Run(() => {
         try
         {
             using (SysDB db = new SysDB())
             {
                 if (db.Alarm.Any(m => m.IsConfirm == false && m.IsReset == false && m.IsBack == false && m.Address == alarm.Address && m.Content == alarm.Content))
                 {
                     //有同样的报警,而且没有确认
                     return;
                 }
                 db.Insert(alarm);
             }
         }
         catch (Exception ex)
         {
             using (Way.Lib.CLog log = new Way.Lib.CLog("AddAlarm error"))
             {
                 log.Log(ex.ToString());
             }
         }
     });
 }
Ejemplo n.º 2
0
 static SysDB()
 {
     using (var db = new SysDB())
     {
         if (db.UserInfo.Count() == 0)
         {
             db.Insert(new UserInfo()
             {
                 Name     = "sa",
                 Password = "******",
                 Role     = UserInfo_RoleEnum.Admin
             });
         }
     }
 }