Esempio n. 1
0
        public AreaStatistics GetAreaStatisticsCount(List <int?> lst)
        {
            try
            {
                var query = from t1 in db.LocationCardPositions.DbSet
                            join t2 in db.Personnels.DbSet on t1.PersonId equals t2.Id
                            where lst.Contains(t1.AreaId)
                            select t2;

                var query2 = from t1 in db.DevInfos.DbSet
                             where lst.Contains(t1.ParentId) && t1.Local_TypeCode != 20180821 //把基站排除了
                             select t1;

                var query3 = from t1 in db.LocationAlarms.DbSet
                             where lst.Contains(t1.AreaId) && t1.AlarmLevel != 0
                             select t1;

                DateTime now        = DateTime.Now;
                DateTime todayStart = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0, 0);
                DateTime todayEnd   = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59, 999);
                var      startStamp = TimeConvert.ToStamp(todayStart);
                var      endStamp   = TimeConvert.ToStamp(todayEnd);

                var query4 = from t1 in db.DevInfos.DbSet
                             join t2 in db.DevAlarms.DbSet on t1.Id equals t2.DevInfoId
                             where lst.Contains(t1.ParentId) && t2.AlarmTimeStamp >= startStamp && t2.AlarmTimeStamp <= endStamp
                             select t2;

                var query5 = (from t1 in db.LocationAlarms.DbSet
                              where lst.Contains(t1.AreaId) && t1.AlarmLevel != 0
                              select t1.PersonnelId).Distinct().ToList();

                var ass = new AreaStatistics();


                ass.PersonNum        = query.Count();
                ass.DevNum           = query2.Count();
                ass.LocationAlarmNum = query3.Count();
                ass.DevAlarmNum      = query4.Count();
                ass.AlarmPersonNum   = query5.Count();//只需要数量信息,不要用ToList(),避免大量数据时封装到实体类的消耗


                PersonService personService = new PersonService(db);
                var           list          = personService.GetList(false, false);
                if (list != null)
                {
                    ass.PersonNum = list.Count;
                }
                else
                {
                    ass.PersonNum = 0;
                }
                return(ass);
            }
            catch (System.Exception ex)
            {
                Log.Error(tag, "GetAreaStatisticsCount", ex.ToString());
                return(null);
            }
        }
Esempio n. 2
0
        public static DbEntity ToDbModel(this TEntity item1)
        {
            if (item1 == null)
            {
                return(null);
            }
            var item2 = new DbEntity();

            item2.Id             = item1.Id;
            item2.Abutment_Id    = item1.Abutment_Id;
            item2.Name           = item1.Name;
            item2.Sex            = item1.Sex == "男" ? Sexs.男 : item1.Sex == "女" ? Sexs.女 : Sexs.未知;
            item2.Photo          = item1.Photo;
            item2.BirthDay       = item1.BirthDay;
            item2.BirthTimeStamp = TimeConvert.ToStamp((DateTime)item1.BirthDay);
            item2.Nation         = item1.Nation;
            item2.Address        = item1.Address;
            item2.WorkNumber     = item1.WorkNumber;
            item2.Email          = item1.Email;
            item2.Phone          = item1.PhoneNumber;
            item2.Mobile         = item1.Mobile;
            item2.RtspUrl        = item1.RtspUrl;
            item2.Enabled        = item1.Enabled;
            item2.ParentId       = item1.ParentId;
            item2.Pst            = item1.Pst;
            item2.TargetModel    = item1.TargetModel;
            item2.TargetType     = item1.TargetType;
            return(item2);
        }
Esempio n. 3
0
        public void SetTime()
        {
            DateTime now = DateTime.Now;

            DateTimeStamp = TimeConvert.ToStamp(now);
            DateTime now2 = TimeConvert.ToDateTime(DateTimeStamp);
        }
Esempio n. 4
0
 private void TicketIn_Click(object sender, RoutedEventArgs e)
 {
     TicketsService service = new TicketsService();
     //List<TwoTickets> list = service.ListAll();
     //List<OperationTicketSH> dbList = new List<OperationTicketSH>();
     //foreach (TwoTickets ticket in list)
     //{
     //    OperationTicketSH dbTable = ticket.ToDbModel();
     //    dbList.Add(dbTable);
     //}
     Bll bll = Bll.NewBllNoRelation();
     //List<OperationTicketHistorySH> OperationHisList = bll.OperationTicketHistorySHs.ToList();
     //List<OperationTicketHistorySH> newList = new List<OperationTicketHistorySH>();
     //OperationHisList.Sort((a, b) => { return (int)a.Abutment_Id - (int)b.Abutment_Id; });
     //int id = (int)OperationHisList.Last().Abutment_Id + 1;
     //for (int i = 0; i < OperationHisList.Count; i++)
     //{
     //    OperationTicketHistorySH ticket = OperationHisList[i];
     //    ticket.Abutment_Id = id;
     //    newList.Add(ticket);
     //    id = id + 1;
     //}
     //bool result = bll.OperationTicketHistorySHs.AddRange(newList);
     //    string sql = "delete from  aa where id  in(99,100)";
     //  string result= bll.WorkTicketHistorySHes.AddorEditBySql(sql);
     DateTime now = DateTime.Now;
     long     a   = TimeConvert.ToStamp(now);
 }
Esempio n. 5
0
        public PersonnelHistory RemoveToHistory()
        {
            PersonnelHistory history = new PersonnelHistory();

            history.Id             = this.Id;
            history.Abutment_Id    = this.Abutment_Id;
            history.Name           = this.Name;
            history.Sex            = this.Sex;
            history.Photo          = this.Photo;
            history.BirthDay       = this.BirthDay;
            history.BirthTimeStamp = this.BirthTimeStamp;
            history.Nation         = this.Nation;
            history.Address        = this.Address;
            history.WorkNumber     = this.WorkNumber;
            history.Email          = this.Email;
            history.Phone          = this.Phone;
            history.Mobile         = this.Mobile;
            history.Enabled        = this.Enabled;
            history.ParentId       = this.ParentId;

            history.HistoryTime      = DateTime.Now;
            history.HistoryTimeStamp = TimeConvert.ToStamp(history.HistoryTime);

            return(history);
        }
Esempio n. 6
0
        private void RemoveOldDevAlarms()
        {
            while (true)
            {
                try
                {
                    //清除某一个时间之前的所有告警
                    Bll      db             = Bll.NewBllNoRelation();
                    DateTime nowTime        = DateTime.Now;
                    DateTime starttime      = DateTime.Now.AddDays(-DevAlarmKeepDays);
                    var      starttimeStamp = TimeConvert.ToStamp(starttime);
                    var      query          = db.DevAlarms.DbSet.Where(i => i.AlarmTimeStamp < starttimeStamp);
                    var      count          = query.Count();
                    if (count > 0)
                    {
                        query.DeleteFromQuery();//这样删除效率高

                        //var alarms = db.DevAlarms.Where(i => i.AlarmTimeStamp < starttimeStamp);
                        //bool r = db.DevAlarms.RemoveList(alarms);
                        //MessageBox.Show("清空成功");
                        Log.Info("RemoveAlarm", "清除历史设备告警,数量:" + count);
                    }
                    Thread.Sleep(1000 * 3600);//一小时检查一次
                }
                catch (Exception ex)
                {
                    Log.Error("RemoveAlarm", ex.ToString());
                }
            }
        }
        private DevAlarm CreateDevAlarm(UDPArchor item)
        {
            DevAlarm alarm = new DevAlarm();

            alarm.Level          = Abutment_DevAlarmLevel.低;
            alarm.Code           = "基站离线";
            alarm.Title          = "基站离线";
            alarm.Src            = Abutment_DevAlarmSrc.人员定位;//其实应该加上“基站扫描”的
            alarm.AlarmTime      = DateTime.Now;
            alarm.AlarmTimeStamp = TimeConvert.ToStamp(alarm.AlarmTime);
            var clientIP = item.GetClientIP();

            alarm.Msg = "基站离线:" + clientIP;

            var anchor = DbArchorList.Find(i => i.Ip == clientIP);

            if (anchor != null)
            {
                var devId = (int)anchor.DevId;
                var dev   = devDict[devId];
                alarm.DevInfo     = dev;
                alarm.DevInfoId   = devId;
                alarm.Device_desc = dev.Name;
                alarm.Title       = string.Format("基站离线[{0},{1}]", anchor.Code.Trim(), anchor.Ip.Trim());
                alarm.Msg         = string.Format("基站离线[{0},{1}]", anchor.Code, anchor.Ip);
                //alarm.AreaId
            }

            alarm.DictKey = alarm.Msg;

            return(alarm);
        }
Esempio n. 8
0
        public LocationAlarmHistory RemoveToHistory()
        {
            LocationAlarmHistory history = new LocationAlarmHistory();

            //history.Id = this.Id;
            history.AlarmId          = this.AlarmId;
            history.AlarmType        = this.AlarmType;
            history.AlarmLevel       = this.AlarmLevel;
            history.LocationCardId   = this.LocationCardId ?? 0;
            history.PersonnelId      = this.PersonnelId ?? 0;
            history.AreadId          = this.AreaId;
            history.CardRoleId       = this.CardRoleId;
            history.Content          = this.Content;
            history.AlarmTime        = this.AlarmTime;
            history.AlarmTimeStamp   = this.AlarmTimeStamp;
            history.HandleTime       = this.HandleTime;
            history.HandleTimeStamp  = this.HandleTimeStamp;
            history.Handler          = this.Handler;
            history.HandleType       = this.HandleType;
            history.AuzId            = this.AuzId;
            history.AllAuzId         = this.AllAuzId;
            history.HistoryTime      = DateTime.Now;
            history.HistoryTimeStamp = TimeConvert.ToStamp(history.HistoryTime);

            return(history);
        }
Esempio n. 9
0
        public DevInfo()
        {
            CreateTime = DateTime.Now;
            ModifyTime = DateTime.Now;

            CreateTimeStamp = TimeConvert.ToStamp(CreateTime);
            ModifyTimeStamp = TimeConvert.ToStamp(ModifyTime);
        }
Esempio n. 10
0
 public Personnel()
 {
     BirthDay       = DateTime.Now;
     BirthTimeStamp = TimeConvert.ToStamp(BirthDay);
     Enabled        = true;
     Sex            = Sexs.男;
     //Pst = "检修";
 }
Esempio n. 11
0
        private void SetTime()
        {
            AlarmTime      = DateTime.Now;
            AlarmTimeStamp = TimeConvert.ToStamp(AlarmTime);

            HandleTime      = new DateTime(2000, 1, 1);
            HandleTimeStamp = TimeConvert.ToStamp(HandleTime);
        }
Esempio n. 12
0
        public EntranceGuardCardToPersonnelHistory RemoveToHistory()
        {
            EntranceGuardCardToPersonnelHistory history = new EntranceGuardCardToPersonnelHistory();

            history.Id = this.Id;
            history.EntranceGuardCardId = this.EntranceGuardCardId;
            history.PersonnelId         = this.PersonnelId;
            history.HistoryTime         = DateTime.Now;
            history.HistoryTimeStamp    = TimeConvert.ToStamp(history.HistoryTime);

            return(history);
        }
Esempio n. 13
0
        public EntranceGuardCardHistory RemoveToHistory()
        {
            EntranceGuardCardHistory history = new EntranceGuardCardHistory();

            history.Id               = this.Id;
            history.Abutment_Id      = this.Abutment_Id;
            history.Code             = this.Code;
            history.State            = this.State;
            history.HistoryTime      = DateTime.Now;
            history.HistoryTimeStamp = TimeConvert.ToStamp(history.HistoryTime);

            return(history);
        }
Esempio n. 14
0
        public static long GetTimeStamp(DateTime time)
        {
            //DateTime zero = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1, 0, 0, 0, 0));
            //long msStamp = (long)(time - zero).TotalMilliseconds;//毫秒
            //if (msStamp < 0)
            //{
            //    msStamp = 0;
            //}

            long msStamp2 = TimeConvert.ToStamp(time); //秒

            return(msStamp2);
        }
Esempio n. 15
0
        private void MenuClearHisAlarms_Click(object sender, RoutedEventArgs e)
        {
            Bll      db  = Bll.NewBllNoRelation();
            DateTime now = DateTime.Now;
            //DateTime todayStart = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second, now.Millisecond);
            DateTime todayStart = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0, 0);
            DateTime todayEnd   = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59, 999);
            var      tamp       = TimeConvert.ToStamp(todayStart);
            var      alarms     = db.DevAlarms.Where(i => i.AlarmTimeStamp < tamp);
            bool     r          = db.DevAlarms.RemoveList(alarms);

            MessageBox.Show("清空成功");
        }
Esempio n. 16
0
        public LocationCardToPersonnelHistory RemoveToHistory()
        {
            LocationCardToPersonnelHistory history = new LocationCardToPersonnelHistory();

            history.Id             = this.Id;
            history.LocationCardId = this.LocationCardId;
            history.PersonnelId    = this.PersonnelId;

            history.HistoryTime      = DateTime.Now;
            history.HistoryTimeStamp = TimeConvert.ToStamp(history.HistoryTime);

            return(history);
        }
Esempio n. 17
0
        public TEntity Put(TEntity item)
        {
            if (item == null)
            {
                return(null);
            }
            var dbItem = item.ToDbModel();

            dbItem.ModifyTime      = DateTime.Now;
            dbItem.ModifyTimeStamp = TimeConvert.ToStamp(dbItem.ModifyTime);
            var result = dbSet.Edit(dbItem);

            return(result ? dbItem.ToTModel() : null);
        }
Esempio n. 18
0
        public LocationCardHistory RemoveToHistory()
        {
            LocationCardHistory history = new LocationCardHistory();

            history.Id               = this.Id;
            history.Abutment_Id      = this.Abutment_Id;
            history.Code             = this.Code;
            history.Name             = this.Name;
            history.Describe         = this.Describe;
            history.IsActive         = this.IsActive;
            history.HistoryTime      = DateTime.Now;
            history.HistoryTimeStamp = TimeConvert.ToStamp(history.HistoryTime);

            return(history);
        }
        public override bool TickFunction()
        {
            try
            {
                DateTime now = DateTime.Now;
                if (now.Hour == 1)//凌晨1点至两点执行一次
                {
                    List <DeleteTable> delList = new List <DeleteTable>();
                    //需要清除数据在此添加
                    delList.Add(new DeleteTable(6, "OperateTime", "DateTime", "deventranceguardcardactions"));  //门禁操作历史
                    delList.Add(new DeleteTable(6, "time", "long", "devmonitornodehistories"));
                    delList.Add(new DeleteTable(6, "dtCreateTime", "DateTime", "inspectiontrackhistories"));
                    delList.Add(new DeleteTable(12, "AlarmTime", "DateTime", "locationalarmhistories"));
                    delList.Add(new DeleteTable(6, "createTime", "DateTime", "operationtickethistoryshes"));
                    delList.Add(new DeleteTable(6, "createTime", "DateTime", "worktickethistoryshes"));
                    delList.Add(new DeleteTable(6, "DateTimeStamp", "long", "positions"));

                    Bll db = Bll.NewBllNoRelation();
                    foreach (DeleteTable del in delList)
                    {
                        DateTime datetime = now.AddMonths(-del.time);
                        string   sql      = "";
                        if (del.type == "long")
                        {
                            long time = TimeConvert.ToStamp(datetime);  //这里转完,是13位的数据
                            switch (del.tableName)
                            {
                            case "devmonitornodehistories":
                                time = time / 1000;     //数据库这张表,时间戳是10位的
                                break;
                            }
                            sql = string.Format("delete from {0} where {1}<'{2}';", del.tableName, del.column, time);
                        }
                        else if (del.type == "DateTime")
                        {
                            sql = string.Format("delete from {0} where {1}<'{2}';", del.tableName, del.column, datetime);
                        }
                        string result = db.WorkTicketHistorySHes.AddorEditBySql(sql);
                        Log.Info(string.Format(@"清除表:{0}  {1}个月前数据,结果:{2}", del.tableName, del.time, result));
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("DeleteHistoryDataThread:" + ex.ToString());
            }
            return(true);
        }
Esempio n. 20
0
        /// <summary>
        /// 产生晕倒告警
        /// </summary>
        /// <param name="list1"></param>
        /// <returns></returns>

        public List <LocationAlarm> GenerateFaintAlarm(string nFaintScope, int nFaintTime)
        {
            List <LocationAlarm> newAlarmList = new List <LocationAlarm>();

            using (var _bll = Bll.NewBllNoRelation())
            {
                float minFaintPointCount = nFaintTime * 60 * 0.5f;//1秒1个点,最少超过20*60*0.5=600个点,才进行晕倒计算(有时可能2s插入一次数据)
                nFaintTime = nFaintTime * 60 * 1000;
                List <LocationCard> cardList = _bll.LocationCards.ToList();


                try
                {
                    long            endTime   = TimeConvert.ToStamp(DateTime.Now);
                    long            beginTime = endTime - nFaintTime;
                    List <Position> pList     = _bll.Positions.FindAll(p => p.DateTimeStamp >= beginTime && p.DateTimeStamp <= endTime).ToList();
                    foreach (LocationCard card in cardList)
                    {
                        List <Position> pList2 = pList.FindAll(p => p.CardId == card.Id).ToList();
                        if (pList2 == null || pList2.Count() <= 0)
                        {
                            continue;
                        }
                        if (pList2.Count < minFaintPointCount)
                        {
                            continue;
                        }

                        LocationAlarm alarm = CalculationScope(pList2, nFaintScope);
                        if (alarm == null)
                        {
                            continue;
                        }

                        newAlarmList.Add(alarm);
                    }
                }
                catch (Exception ex)
                {
                    Log.Info("FaintAlarm", "AuthorizationBuffer.GenerateFaintAlarm:" + ex.ToString());
                }
            }

            return(newAlarmList);
        }
Esempio n. 21
0
        public DevAlarmHistory RemoveToHistory(DeviceAlarm alarm)
        {
            DevAlarmHistory newItem = new DevAlarmHistory();

            newItem.Id               = alarm.Id;
            newItem.Abutment_Id      = alarm.Abutment_Id;
            newItem.Title            = alarm.Title;
            newItem.Msg              = alarm.Message;
            newItem.Level            = alarm.Level;
            newItem.Code             = alarm.Code;
            newItem.Src              = alarm.Src;
            newItem.DevInfoId        = alarm.DevId;
            newItem.Device_desc      = alarm.Device_desc;
            newItem.AlarmTime        = alarm.CreateTime;
            newItem.AlarmTimeStamp   = alarm.AlarmTimeStamp;
            newItem.HistoryTime      = DateTime.Now;
            newItem.HistoryTimeStamp = TimeConvert.ToStamp((DateTime)newItem.HistoryTime);
            return(newItem);
        }
Esempio n. 22
0
        public override bool TickFunction()
        {
            Log.Info(Name, "检查设备告警");
            //清除某一个时间之前的所有告警
            Bll      db             = Bll.NewBllNoRelation();
            DateTime nowTime        = DateTime.Now;
            DateTime starttime      = DateTime.Now.AddDays(-DevAlarmKeepDays);
            var      starttimeStamp = TimeConvert.ToStamp(starttime);
            var      query          = db.DevAlarms.DbSet.Where(i => i.AlarmTimeStamp < starttimeStamp);
            var      count          = query.Count();

            if (count > 0)
            {
                query.DeleteFromQuery();//这样删除效率高
                Log.Info(Name, "清除历史设备告警,数量:" + count);
            }
            db.Dispose();
            return(true);
        }
Esempio n. 23
0
        public static void SetDeivInfo(DevInfo devinfo, device item)
        {
            devinfo.Abutment_Id    = item.id;
            devinfo.Code           = item.code;
            devinfo.Abutment_Type  = (Abutment_DevTypes)item.type;
            devinfo.Status         = (Abutment_Status)item.state;
            devinfo.RunStatus      = (Abutment_RunStatus)item.running_state;
            devinfo.Placed         = item.placed;
            devinfo.Abutment_DevID = item.raw_id;
            devinfo.IP             = item.ip;
            devinfo.Manufactor     = "霍尼韦尔";

            devinfo.ModifyTime      = DateTime.Now;
            devinfo.ModifyTimeStamp = TimeConvert.ToStamp(devinfo.ModifyTime);

            //devinfo.ParentId = area.Id;
            devinfo.KKS  = item.kks;
            devinfo.Name = item.name;
        }
Esempio n. 24
0
        public DevAlarmHistory RemoveToHistory()
        {
            DevAlarmHistory newItem = new DevAlarmHistory();

            newItem.Id               = this.Id;
            newItem.Abutment_Id      = this.Abutment_Id;
            newItem.Title            = this.Title;
            newItem.Msg              = this.Msg;
            newItem.Level            = this.Level;
            newItem.Code             = this.Code;
            newItem.Src              = this.Src;
            newItem.DevInfoId        = this.DevInfoId;
            newItem.Device_desc      = this.Device_desc;
            newItem.AlarmTime        = this.AlarmTime;
            newItem.AlarmTimeStamp   = this.AlarmTimeStamp;
            newItem.HistoryTime      = DateTime.Now;
            newItem.HistoryTimeStamp = TimeConvert.ToStamp((DateTime)newItem.HistoryTime);

            return(newItem);
        }
        public ActionResult Edit([Bind(Include = "Id,Abutment_Id,Name,Sex,Photo,BirthDay,Nation,Address,WorkNumber,Email,Phone,Mobile,Enabled,ParentId,Pst")] Personnel pel)
        {
            if (ModelState.IsValid)
            {
                pel.BirthTimeStamp = TimeConvert.ToStamp(pel.BirthDay);

                var result = bll.Personnels.Edit(pel);
                if (result)
                {
                    return(Json(new { success = result }));
                }
                else
                {
                    return(Json(new { success = result, errors = bll.Personnels.ErrorMessage }));
                }
            }

            GetListToViewBag();
            return(View(pel));
        }
Esempio n. 26
0
        public DevInfoHistory RemoveToHistory()
        {
            DevInfoHistory history = new DevInfoHistory();

            history.Id               = this.Id;
            history.Name             = this.Name;
            history.ParentId         = this.ParentId;
            history.Code             = this.Code;
            history.KKS              = this.KKS;
            history.Local_DevID      = this.Local_DevID;
            history.Local_CabinetID  = this.Local_CabinetID;
            history.Local_TypeCode   = this.Local_TypeCode;
            history.Abutment_Id      = this.Abutment_Id;
            history.Abutment_DevID   = this.Abutment_DevID;
            history.Abutment_Type    = this.Abutment_Type;
            history.Status           = this.Status;
            history.RunStatus        = this.RunStatus;
            history.Placed           = this.Placed;
            history.ModelName        = this.ModelName;
            history.CreateTime       = this.CreateTime;
            history.CreateTimeStamp  = this.CreateTimeStamp;
            history.ModifyTime       = this.ModifyTime;
            history.ModifyTimeStamp  = this.ModifyTimeStamp;
            history.UserName         = this.UserName;
            history.Manufactor       = this.Manufactor;
            history.IP               = this.IP;
            history.PosX             = this.PosX;
            history.PosY             = this.PosY;
            history.PosZ             = this.PosZ;
            history.RotationX        = this.RotationX;
            history.RotationY        = this.RotationY;
            history.RotationZ        = this.RotationZ;
            history.ScaleX           = this.ScaleX;
            history.ScaleY           = this.ScaleY;
            history.ScaleZ           = this.ScaleZ;
            history.HistoryTime      = DateTime.Now;
            history.HistoryTimeStamp = TimeConvert.ToStamp(history.HistoryTime);

            return(history);
        }
Esempio n. 27
0
        public void AddPartion()
        {
            DateTime dtNextDay  = DateTime.Now.AddDays(1);
            DateTime dtThirdDay = DateTime.Now.AddDays(2);
            string   strDay     = dtNextDay.ToString("yyyyMMdd");

            strDay = "p" + strDay;
            string strSqlSelect = "select PARTITION_NAME from INFORMATION_SCHEMA.PARTITIONS where table_name='positions' and PARTITION_NAME = '" + strDay + "';";

            dtThirdDay = dtThirdDay.Date;
            long   lTime     = TimeConvert.ToStamp(dtThirdDay);
            string strSqlAdd = "ALTER TABLE positions ADD PARTITION (PARTITION " + strDay + " values less than(" + Convert.ToString(lTime) + "));";

            DbRawSqlQuery <string> result2 = DbHistory.Database.SqlQuery <string>(strSqlSelect + ";");
            List <string>          lst2    = result2.ToList();

            if (lst2.Count == 0)
            {
                DbHistory.Database.ExecuteSqlCommand(strSqlAdd);
                Log.Info("Partion", "AddPartion:" + strSqlAdd);
            }
        }
Esempio n. 28
0
 private bool RemoveList(int day)
 {
     try
     {
         //清除列表
         Bll      db             = Bll.NewBllNoRelation();
         DateTime nowTime        = DateTime.Now;
         DateTime starttime      = DateTime.Now.AddDays(-day);
         var      starttimeStamp = TimeConvert.ToStamp(starttime);
         var      query          = db.DevAlarms.DbSet.Where(i => i.AlarmTimeStamp < starttimeStamp);
         if (query.Count() > 0)
         {
             query.DeleteFromQuery();
         }
         return(true);
     }
     catch (Exception ex)
     {
         Log.Info("RemoveDevAlarms:" + ex.ToString());
         return(false);
     }
 }
Esempio n. 29
0
        private void MenuClearRecent_Click(object sender, RoutedEventArgs e)
        {
            Worker.Run(() =>
            {
                Log.Info(LogTags.Inspection, "ClearRecent Start");

                Bll bll = Bll.NewBllNoRelation();

                DateTime now    = DateTime.Now.Date;
                DateTime start  = now.AddDays(-5);
                long startStamp = TimeConvert.ToStamp(start);

                var list = bll.InspectionTrackHistorys.FindAll(i => i.CreateTime >= startStamp);
                Log.Info(LogTags.Inspection, "InspectionTrackHistorys:" + list.Count);
                RemoveHistoryList(bll, list);
                FlushRemove(bll);

                Log.Info(LogTags.Inspection, "ClearRecent End");
            }, () =>
            {
                MessageBox.Show("完成");
            });
        }
Esempio n. 30
0
        public string GetText(float offsetX, float offsetY, int timeMode)
        {
            DateTime now = DateTime.Now;
            long     t   = 0;

            if (timeMode == 0)//当前时间作为发送时间
            {
                t = TimeConvert.ToStamp(now);
            }
            else if (timeMode == 1)//当前日期作为发送时间
            {
                DateTime t1   = TimeConvert.ToDateTime(DateTimeStamp);
                DateTime tNew = new DateTime(now.Year, now.Month, now.Day, t1.Hour, t1.Minute,
                                             t1.Second, t1.Millisecond);
                t = TimeConvert.ToStamp(tNew);
            }

            double x = (X - offsetX) / AppSetting.PositionPower;
            double y = (Z - offsetY) / AppSetting.PositionPower;
            double z = Y / AppSetting.PositionPower;

            return(string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}", Code, x, y, z,
                                 t, Power, Number, Flag, ArchorsText));
        }