示例#1
0
        public void SetTime()
        {
            DateTime now = DateTime.Now;

            DateTimeStamp = TimeConvert.DateTimeToTimeStamp(now);
            DateTime now2 = TimeConvert.TimeStampToDateTime(DateTimeStamp);
        }
        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.DateTimeToTimeStamp((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.Enabled        = item1.Enabled;
            item2.ParentId       = item1.ParentId;
            item2.Pst            = item1.Pst;
            return(item2);
        }
示例#3
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.DateTimeToTimeStamp(history.HistoryTime);

            return(history);
        }
        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.DateTimeToTimeStamp(history.HistoryTime);

            return(history);
        }
        private void SetTime()
        {
            AlarmTime      = DateTime.Now;
            AlarmTimeStamp = TimeConvert.DateTimeToTimeStamp(AlarmTime);

            HandleTime      = new DateTime(2000, 1, 1);
            HandleTimeStamp = TimeConvert.DateTimeToTimeStamp(HandleTime);
        }
示例#6
0
        public DevInfo()
        {
            CreateTime = DateTime.Now;
            ModifyTime = DateTime.Now;

            CreateTimeStamp = TimeConvert.DateTimeToTimeStamp(CreateTime);
            ModifyTimeStamp = TimeConvert.DateTimeToTimeStamp(ModifyTime);
        }
示例#7
0
        public TEntity Put(TEntity item)
        {
            var dbItem = item.ToDbModel();

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

            return(result ? dbItem.ToTModel() : null);
        }
        /// <summary>
        /// 获取单个设备信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public device GetSingleDeviceInfo(int id)
        {
            device recv  = new device();
            string strId = Convert.ToString(id);

            try
            {
                string path = "api/devices/" + strId;
                string url  = BaseUri + path;
                recv = GetEntityDetail <device>(url);

                DevInfo devinfo = bll.DevInfos.DbSet.Where(p => p.KKS == recv.kksCode).FirstOrDefault();
                int     nFlag   = 0;
                if (devinfo == null)
                {
                    devinfo = new DevInfo();
                    nFlag   = 1;
                }

                devinfo.Abutment_Id    = recv.id;
                devinfo.Code           = recv.code;
                devinfo.KKS            = recv.kksCode;
                devinfo.Name           = recv.name;
                devinfo.Abutment_Type  = (Abutment_DevTypes)recv.type;
                devinfo.Status         = (Abutment_Status)recv.state;
                devinfo.RunStatus      = (Abutment_RunStatus)recv.running_state;
                devinfo.Placed         = recv.placed;
                devinfo.Abutment_DevID = recv.raw_id;

                if (nFlag == 1)
                {
                    devinfo.CreateTime = DateTime.Now;
                    devinfo.ModifyTime = DateTime.Now;

                    devinfo.CreateTimeStamp = TimeConvert.DateTimeToTimeStamp(devinfo.CreateTime);
                    devinfo.ModifyTimeStamp = TimeConvert.DateTimeToTimeStamp(devinfo.ModifyTime);

                    bll.DevInfos.Add(devinfo);
                }
                else
                {
                    devinfo.ModifyTime      = DateTime.Now;
                    devinfo.ModifyTimeStamp = TimeConvert.DateTimeToTimeStamp(devinfo.ModifyTime);

                    bll.DevInfos.Edit(devinfo);
                }
            }
            catch (Exception ex)
            {
                string messgae = ex.Message;
            }

            return(recv);
        }
        public BaseTran <sis> GetSomesisList(string kks)
        {
            BaseTran <sis> recv = new BaseTran <sis>();

            try
            {
                string path = "api/rt/sis?kks=" + kks;
                string url  = BaseUri + path;
                recv = GetEntityList <sis>(url);

                if (recv.data == null)
                {
                    recv.data = new List <sis>();
                }

                foreach (sis item in recv.data)
                {
                    DevInfo DevInfo = bll.DevInfos.DbSet.Where(p => p.KKS == item.kks).FirstOrDefault();
                    if (DevInfo == null)
                    {
                        continue;
                    }

                    DevInstantData did = bll.DevInstantDatas.DbSet.Where(p => p.Id == item.kks).FirstOrDefault();

                    if (did == null)
                    {
                        did               = new DevInstantData();
                        did.Id            = item.kks;
                        did.Value         = item.value;
                        did.DateTime      = DateTime.Now;
                        did.DateTimeStamp = TimeConvert.DateTimeToTimeStamp(did.DateTime);
                        bll.DevInstantDatas.Add(did);
                    }
                    else
                    {
                        DevInstantDataHistory didh = did.RemoveToHistory();
                        did.Value         = item.value;
                        did.DateTime      = DateTime.Now;
                        did.DateTimeStamp = TimeConvert.DateTimeToTimeStamp(did.DateTime);

                        bll.DevInstantDatas.Edit(did);
                        bll.DevInstantDataHistorys.Add(didh);
                    }
                }
            }
            catch (Exception ex)
            {
                string messgae = ex.Message;
            }

            return(recv);
        }
示例#10
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.DateTimeToTimeStamp(history.HistoryTime);

            return(history);
        }
示例#11
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.DateTimeToTimeStamp(time);//秒

            return(msStamp2);
        }
        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.DateTimeToTimeStamp(history.HistoryTime);

            return(history);
        }
示例#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.DateTimeToTimeStamp(history.HistoryTime);

            return(history);
        }
示例#14
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.HistoryTime      = DateTime.Now;
            history.HistoryTimeStamp = TimeConvert.DateTimeToTimeStamp(history.HistoryTime);

            return(history);
        }
示例#15
0
        /// <summary>
        /// 初始化实时位置信息
        /// </summary>
        public void InitRealTimePositions()
        {
            DateTime dt        = DateTime.Now;
            long     TimeStamp = TimeConvert.DateTimeToTimeStamp(dt);

            LocationCardPositions.Clear();
            List <LocationCardPosition> tagpositions = new List <LocationCardPosition>();
            var cardPersons = _bll.LocationCardToPersonnels.ToList(); //和卡绑定的人才有位置信息
            var cards       = _bll.LocationCards.ToList();
            var area        = _bll.Areas.Find(2);                     //电厂
            var bound       = area.InitBound;

            bound.Points = _bll.Points.FindAll(i => i.BoundId == bound.Id);

            for (int i = 0; i < cardPersons.Count; i++)
            {
                var cp   = cardPersons[i];
                var card = cards.Find(j => j.Id == cp.LocationCardId);
                if (i < 10)//这部分固定初始位置
                {
                    var tagposition = new LocationCardPosition()
                    {
                        CardId = cp.LocationCardId, Id = card.Code, X = 2292.5f + i, Y = 2, Z = 1715.5f, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = i, Flag = "0:0:0:0:0", AreaId = 2, PersonId = cp.Id
                    };
                    tagpositions.Add(tagposition);
                }
                else//这部分随机初始位置
                {
                    var x = r.Next((int)bound.GetSizeX()) + bound.MinX;
                    var z = r.Next((int)bound.GetSizeY()) + bound.MinY;
                    while (!bound.Contains(x, z))
                    {
                        x = r.Next((int)bound.GetSizeX()) + bound.MinX;
                        z = r.Next((int)bound.GetSizeY()) + bound.MinY;
                    }
                    var tagposition = new LocationCardPosition()
                    {
                        CardId = cp.LocationCardId, Id = card.Code, X = x, Y = 2, Z = z, DateTime = dt, DateTimeStamp = TimeStamp, Power = 0, Number = i, Flag = "0:0:0:0:0", PersonId = cp.Id
                    };
                    tagpositions.Add(tagposition);
                }
            }
            LocationCardPositions.AddRange(tagpositions);
        }
示例#16
0
        public ActionResult Create([Bind(Include = "Id,Name,Sex,Photo,BirthDay,Nation,Address,WorkNumber,Email,Phone,Mobile,Enabled,ParentId,Pst")] Personnel pel)
        {
            if (ModelState.IsValid)
            {
                pel.BirthTimeStamp = TimeConvert.DateTimeToTimeStamp(pel.BirthDay);

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

            GetListToViewBag();
            return(View(pel));
        }
示例#17
0
        public DevAlarmHistory RemoveToHistory()
        {
            DevAlarmHistory history = new DevAlarmHistory();

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

            return(history);
        }
示例#18
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.DateTimeToTimeStamp(history.HistoryTime);

            return(history);
        }
示例#19
0
        public List <EntranceGuardActionInfo> GetEntranceActionInfoByPerson24Hours(int id)
        {
            DateTime dtNow = DateTime.Now;
            DateTime dtOld = DateTime.Now.AddHours(-24);

            long lNow = TimeConvert.DateTimeToTimeStamp(dtNow);
            long lOld = TimeConvert.DateTimeToTimeStamp(dtOld);

            List <EntranceGuardActionInfo> lst = new List <EntranceGuardActionInfo>();
            List <int> lst2 = db.EntranceGuardCardToPersonnels.DbSet.Where(p => p.PersonnelId == id).Select(p => p.EntranceGuardCardId).ToList();
            List <DbModel.LocationHistory.AreaAndDev.DevEntranceGuardCardAction> lst3 = null;
            List <DbModel.Location.AreaAndDev.EntranceGuardCard> lst4 = db.EntranceGuardCards.ToList();
            List <DbModel.Location.AreaAndDev.DevInfo>           lst5 = db.DevInfos.ToList();
            List <DbModel.Location.AreaAndDev.Area> lst6 = db.Areas.ToList();

            if (lst2 == null)
            {
                return(lst);
            }

            var query = from t1 in db.DevEntranceGuardCardActions.DbSet
                        where lst2.Contains(t1.EntranceGuardCardId) && t1.OperateTimeStamp >= lOld && t1.OperateTimeStamp <= lNow
                        select t1;

            if (query == null)
            {
                return(lst);
            }

            lst3 = query.ToList();

            foreach (DbModel.LocationHistory.AreaAndDev.DevEntranceGuardCardAction item in lst3)
            {
                int      DevInfoId           = item.DevInfoId;
                int      EntranceGuardCardId = item.EntranceGuardCardId;
                DateTime?OperateTime         = item.OperateTime;
                int      nInOutState         = item.nInOutState;

                var card = lst4.Find(p => p.Id == EntranceGuardCardId);
                if (card == null || card.Code == null || card.Code == "")
                {
                    continue;
                }

                var devinfo = lst5.Find(p => p.Id == DevInfoId);
                if (devinfo == null || devinfo.Name == null || devinfo.Name == "" || devinfo.ParentId == null)
                {
                    continue;
                }

                string Name   = devinfo.Name;
                int    AreaId = (int)devinfo.ParentId;
                var    area   = lst6.Find(p => p.Id == AreaId);
                if (area == null || area.Name == "" || area.Name == null)
                {
                    continue;
                }

                EntranceGuardActionInfo ega = new EntranceGuardActionInfo();
                ega.Id          = DevInfoId;
                ega.Name        = Name;
                ega.AreadId     = AreaId;
                ega.AreadName   = area.Name;
                ega.Code        = card.Code;
                ega.OperateTime = OperateTime;
                ega.nInOutState = nInOutState;

                lst.Add(ega);
            }

            return(lst);
        }
示例#20
0
 public LocationAlarm()
 {
     CreateTime     = DateTime.Now;
     AlarmTimeStamp = TimeConvert.DateTimeToTimeStamp(CreateTime);
 }
 public DevInstantData()
 {
     DateTime      = DateTime.Now;
     DateTimeStamp = TimeConvert.DateTimeToTimeStamp(DateTime);
 }
示例#22
0
        private bool DealInspectionTrack(BaseDataClient client, DateTime dtBegin, DateTime dtEnd, bool bFlag)
        {
            List <InspectionTrack>        All    = new List <InspectionTrack>();
            List <InspectionTrack>        Add    = new List <InspectionTrack>();
            List <InspectionTrack>        Edit   = new List <InspectionTrack>();
            List <InspectionTrack>        Delete = new List <InspectionTrack>();
            List <InspectionTrackHistory> HAdd   = new List <InspectionTrackHistory>();

            long lBegin = TimeConvert.DateTimeToTimeStamp(dtBegin) / 1000;
            long lEnd   = TimeConvert.DateTimeToTimeStamp(dtEnd) / 1000;
            var  recv   = client.Getinspectionlist(lBegin, lEnd, true);

            if (recv == null)
            {
                return(false);
            }

            Bll bll = new Bll(false, false, true, false);//第三参数要设置为true
            List <InspectionTrack> itList = bll.InspectionTracks.ToList();

            if (itList == null)
            {
                itList = new List <InspectionTrack>();
            }

            List <InspectionTrackHistory> itHList = bll.InspectionTrackHistorys.ToList();

            if (itHList == null)
            {
                itHList = new List <InspectionTrackHistory>(0);
            }

            foreach (patrols item in recv)
            {
                InspectionTrack        now     = itList.Find(p => p.Abutment_Id == item.id);
                InspectionTrackHistory history = itHList.Find(p => p.Abutment_Id == item.id);

                if (item.state == "新建" || item.state == "已下达" || item.state == "执行中")
                {
                    if (now == null)
                    {
                        now = new InspectionTrack();

                        now.Abutment_Id  = item.id;
                        now.Code         = item.code;
                        now.Name         = item.name;
                        now.CreateTime   = (item.createTime + nEightHourSecond) * 1000;
                        now.dtCreateTime = TimeConvert.TimeStampToDateTime(now.CreateTime);
                        now.State        = item.state;
                        now.StartTime    = (item.startTime + nEightHourSecond) * 1000;
                        now.dtStartTime  = TimeConvert.TimeStampToDateTime(now.StartTime);
                        now.EndTime      = (item.endTime + nEightHourSecond) * 1000;
                        now.dtEndTime    = TimeConvert.TimeStampToDateTime(now.EndTime);
                        Add.Add(now);
                    }
                    else
                    {
                        now.State = item.state;
                        Edit.Add(now);
                    }
                }
                else
                {
                    if (now != null)
                    {
                        Delete.Add(now);
                    }

                    if (history == null)
                    {
                        history = new InspectionTrackHistory();

                        history.Abutment_Id  = item.id;
                        history.Code         = item.code;
                        history.Name         = item.name;
                        history.CreateTime   = (item.createTime + nEightHourSecond) * 1000;
                        history.dtCreateTime = TimeConvert.TimeStampToDateTime(history.CreateTime);
                        history.State        = item.state;
                        history.StartTime    = (item.startTime + nEightHourSecond) * 1000;
                        history.dtStartTime  = TimeConvert.TimeStampToDateTime(history.StartTime);
                        history.EndTime      = (item.endTime + nEightHourSecond) * 1000;
                        history.dtEndTime    = TimeConvert.TimeStampToDateTime(history.EndTime);

                        HAdd.Add(history);
                    }
                }
            }

            bll.InspectionTracks.AddRange(Add);
            bll.InspectionTracks.EditRange(Edit);
            bll.InspectionTracks.RemoveList(Delete);
            bll.InspectionTrackHistorys.AddRange(HAdd);

            All.AddRange(Add);
            All.AddRange(Edit);
            DealPatrolPoint(bll, All, Delete, HAdd, client);

            return(true);
        }
        /// <summary>
        /// 获取设备列表
        /// </summary>
        /// <param name="types"></param>
        /// <param name="code"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public BaseTran <device> GetDeviceList(string types, string code, string name)
        {
            BaseTran <device> recv = new BaseTran <device>();

            try
            {
                string path = "api/devices";
                string url  = BaseUri + path;

                if (types != null)
                {
                    url += "?types=" + types;
                }
                else
                {
                    url += "?types";
                }

                if (code != null)
                {
                    url += "&code=" + code;
                }
                else
                {
                    url += "&code";
                }

                if (name != null)
                {
                    url += "&name=" + name;
                }
                else
                {
                    url += "&name";
                }

                recv = GetEntityList <device>(url);

                if (recv.data == null)
                {
                    recv.data = new List <device>();
                }

                foreach (device item in recv.data)
                {
                    DevInfo devinfo = bll.DevInfos.DbSet.Where(p => p.KKS == item.kksCode).FirstOrDefault();
                    int     nFlag   = 0;
                    if (devinfo == null)
                    {
                        devinfo = new DevInfo();
                        nFlag   = 1;
                    }

                    devinfo.Abutment_Id    = item.id;
                    devinfo.Code           = item.code;
                    devinfo.KKS            = item.kksCode;
                    devinfo.Name           = item.name;
                    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;

                    if (nFlag == 1)
                    {
                        devinfo.CreateTime = DateTime.Now;
                        devinfo.ModifyTime = DateTime.Now;

                        devinfo.CreateTimeStamp = TimeConvert.DateTimeToTimeStamp(devinfo.CreateTime);
                        devinfo.ModifyTimeStamp = TimeConvert.DateTimeToTimeStamp(devinfo.ModifyTime);

                        bll.DevInfos.Add(devinfo);
                    }
                    else
                    {
                        devinfo.ModifyTime      = DateTime.Now;
                        devinfo.ModifyTimeStamp = TimeConvert.DateTimeToTimeStamp(devinfo.ModifyTime);

                        bll.DevInfos.Edit(devinfo);
                    }
                }
            }
            catch (Exception ex)
            {
                string messgae = ex.Message;
            }

            return(recv);
        }
        /// <summary>
        /// 获取指定区域下设备列表
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public BaseTran <device> GetZoneDevList(int id)
        {
            BaseTran <device> recv  = new BaseTran <device>();
            string            strId = Convert.ToString(id);

            try
            {
                string path = "api/zones/" + strId + "/devices";
                string url  = BaseUri + path;
                recv = GetEntityList <device>(url);

                if (recv.data == null)
                {
                    recv.data = new List <device>();
                }

                Area area = bll.Areas.DbSet.Where(p => p.Abutment_Id == id).FirstOrDefault();
                if (area != null)
                {
                    foreach (device item in recv.data)
                    {
                        DevInfo devinfo = bll.DevInfos.DbSet.Where(p => p.KKS == item.kksCode).FirstOrDefault();
                        int     nFlag   = 0;
                        if (devinfo == null)
                        {
                            devinfo = new DevInfo();
                            nFlag   = 1;
                        }

                        devinfo.ParentId       = area.Id;
                        devinfo.Abutment_Id    = item.id;
                        devinfo.Code           = item.code;
                        devinfo.KKS            = item.kksCode;
                        devinfo.Name           = item.name;
                        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;

                        if (nFlag == 1)
                        {
                            devinfo.CreateTime = DateTime.Now;
                            devinfo.ModifyTime = DateTime.Now;

                            devinfo.CreateTimeStamp = TimeConvert.DateTimeToTimeStamp(devinfo.CreateTime);
                            devinfo.ModifyTimeStamp = TimeConvert.DateTimeToTimeStamp(devinfo.ModifyTime);

                            bll.DevInfos.Add(devinfo);
                        }
                        else
                        {
                            devinfo.ModifyTime      = DateTime.Now;
                            devinfo.ModifyTimeStamp = TimeConvert.DateTimeToTimeStamp(devinfo.ModifyTime);

                            bll.DevInfos.Edit(devinfo);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string messgae = ex.Message;
            }



            return(recv);
        }
示例#25
0
 public Personnel()
 {
     BirthDay       = DateTime.Now;
     BirthTimeStamp = TimeConvert.DateTimeToTimeStamp(BirthDay);
     Enabled        = true;
 }
示例#26
0
        /// <summary>
        /// 解析位置信息
        /// </summary>
        /// <param name="info"></param>
        /// <param name="offsetX">偏移量X 和定位引擎约定好具体偏移数值</param>
        /// <param name="offsetY">偏移量Y 和定位引擎约定好具体偏移数值</param>
        /// <returns></returns>
        public bool Parse(string info, float offsetX, float offsetY)
        {
            try
            {
                _info = info;
                string[] parts  = info.Split(new[] { ',' });
                int      length = parts.Length;
                if (length <= 1)
                {
                    return(false);            //心跳包回拨
                }
                Code = parts[0];
                if (Code.StartsWith("1"))
                {
                }
                float x = float.Parse(parts[1]);
                float y = float.Parse(parts[2]);
                if (x < offsetX)
                {
                    X = x + offsetX; //平面位置
                    Z = y + offsetY; //平面位置
                }
                else //模拟数据是可以没有偏移量的 看模拟程序的版本
                {
                    X = x;
                    Z = y;
                }

                Y             = float.Parse(parts[3]);//高度位置,为了和Unity坐标信息一致,Y为高度轴
                DateTimeStamp = long.Parse(parts[4]);
                DateTime      = TimeConvert.TimeStampToDateTime(DateTimeStamp);
                long DateTimeStamp2 = TimeConvert.DateTimeToTimeStamp(DateTime);

                if (length > 5)
                {
                    Power = int.Parse(parts[5]);
                }
                if (length > 6)
                {
                    Number = int.Parse(parts[6]);
                }
                if (length > 7)
                {
                    Flag = parts[7];
                }
                if (length > 8)
                {
                    ArchorsText = parts[8];
                    Archors     = ArchorsText.Split(new [] { '@' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                    if (Archors.Count > 1)
                    {
                        Console.Write("Archors.Count > 1");
                    }
                    IsSimulate = ArchorsText == "@0000" || string.IsNullOrEmpty(ArchorsText);
                }

                if (Power >= 400)
                {
                    PowerState = 0;
                }
                else
                {
                    PowerState = 1;
                }

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(false);
            }
        }
示例#27
0
 public Personnel()
 {
     BirthDay       = new DateTime(2000, 1, 1);
     BirthTimeStamp = TimeConvert.DateTimeToTimeStamp(BirthDay);
 }