public static TModel.Location.Work.InspectionTrack ToTModel(this DbModel.Location.Work.InspectionTrack item1, bool clearRoute = true)
        {
            if (item1 == null)
            {
                return(null);
            }
            var item2 = new TModel.Location.Work.InspectionTrack();

            item2.Id           = item1.Id;
            item2.Abutment_Id  = item1.Abutment_Id;
            item2.Code         = item1.Code;
            item2.Name         = item1.Name;
            item2.dtCreateTime = item1.dtCreateTime;
            item2.CreateTime   = item1.CreateTime;
            item2.State        = item1.State;
            item2.dtStartTime  = item1.dtStartTime;
            item2.StartTime    = item1.StartTime;
            item2.dtEndTime    = item1.dtEndTime;
            item2.EndTime      = item1.EndTime;
            if (clearRoute)
            {
                item2.Route = null;
            }
            else
            {
                item2.Route = item1.Route == null || item1.Route.Count == 0?null:item1.Route.ToTModel();
            }
            return(item2);
        }
        /// <summary>
        /// 获取巡检轨迹列表
        /// </summary>
        /// <param name="lBegin"></param>
        /// <param name="lEnd"></param>
        /// <param name="bFlag"></param>
        //public void Getinspectionlist(long lBegin, long lEnd, bool bFlag)
        //{
        //    var client = GetClient();
        //    var recv = client.Getinspectionlist(lBegin, lEnd, bFlag);
        //    if (recv == null)
        //    {
        //        return;
        //    }

        //    return;
        //}

        //根据巡检Id,获取详细巡检信息
        public InspectionTrack GetInspectionTrackById(InspectionTrack trackId)
        {
            try
            {
                List <DbModel.Location.Work.InspectionTrack> lst = dbEx.InspectionTracks.ToList();
                if (lst == null)
                {
                    return(null);
                }
                DbModel.Location.Work.InspectionTrack trackDBModel = lst.Find(i => i.Id == trackId.Id);
                if (trackDBModel != null)
                {
                    InspectionTrack inspectTemp = trackDBModel.ToTModel(false);
                    return(inspectTemp);
                }
                else
                {
                    return(null);
                }
            }
            catch (System.Exception ex)
            {
                Log.Error(LogTags.BaseData, "GetInspectionTrackById", ex.ToString());
                return(null);
            }
        }
Exemplo n.º 3
0
 public static DbModel.Location.Work.InspectionTrack CreateInspectionTrack(patrols item)
 {
     DbModel.Location.Work.InspectionTrack now = new DbModel.Location.Work.InspectionTrack();
     now.Abutment_Id  = item.id;
     now.Code         = item.code;
     now.Name         = item.name;
     now.CreateTime   = (item.createTimes + nEightHourSecond) * 1000;
     now.dtCreateTime = Location.TModel.Tools.TimeConvert.ToDateTime(now.CreateTime);
     now.State        = item.state;
     now.StartTime    = (item.startTime + nEightHourSecond) * 1000;
     now.dtStartTime  = Location.TModel.Tools.TimeConvert.ToDateTime(now.StartTime);
     now.EndTime      = (item.endTime + nEightHourSecond) * 1000;
     now.dtEndTime    = Location.TModel.Tools.TimeConvert.ToDateTime(now.EndTime);
     return(now);
 }
        public static DbModel.Location.Work.InspectionTrack ToDbModel(this TModel.Location.Work.InspectionTrack item1)
        {
            if (item1 == null)
            {
                return(null);
            }
            var item2 = new DbModel.Location.Work.InspectionTrack();

            item2.Id           = item1.Id;
            item2.Abutment_Id  = item1.Abutment_Id;
            item2.Code         = item1.Code;
            item2.Name         = item1.Name;
            item2.dtCreateTime = item1.dtCreateTime;
            item2.CreateTime   = item1.CreateTime;
            item2.State        = item1.State;
            item2.dtStartTime  = item1.dtStartTime;
            item2.StartTime    = item1.StartTime;
            item2.dtEndTime    = item1.dtEndTime;
            item2.EndTime      = item1.EndTime;
            item2.Route        = item1.Route.ToDbModel();
            return(item2);
        }
Exemplo n.º 5
0
        private void DealPatrolPointItem(List <DbModel.Location.Work.InspectionTrack> All, List <DbModel.LocationHistory.Work.InspectionTrackHistory> HAdd, List <DbModel.Location.Work.PatrolPoint> PAll, List <DbModel.Location.Work.PatrolPoint> PDelete, List <DbModel.LocationHistory.Work.PatrolPointHistory> PHAdd, WebApiLib.Clients.BaseDataClient client)
        {
            try
            {
                Bll bll = Bll.NewBllNoRelation();
                List <DbModel.Location.Work.PatrolPointItem> ppiList = bll.PatrolPointItems.ToList();
                List <DbModel.LocationHistory.Work.PatrolPointItemHistory> ppiHList = bll.PatrolPointItemHistorys.ToList();
                if (ppiList == null)
                {
                    ppiList = new List <DbModel.Location.Work.PatrolPointItem>();
                }

                if (ppiHList == null)
                {
                    ppiHList = new List <DbModel.LocationHistory.Work.PatrolPointItemHistory>();
                }

                List <DbModel.Location.Work.PatrolPointItem> PIAll                = new List <DbModel.Location.Work.PatrolPointItem>();
                List <DbModel.Location.Work.PatrolPointItem> PIAdd                = new List <DbModel.Location.Work.PatrolPointItem>();
                List <DbModel.Location.Work.PatrolPointItem> PIEdit               = new List <DbModel.Location.Work.PatrolPointItem>();
                List <DbModel.Location.Work.PatrolPointItem> PIDelete             = new List <DbModel.Location.Work.PatrolPointItem>();
                List <DbModel.LocationHistory.Work.PatrolPointItemHistory> PIHAdd = new List <DbModel.LocationHistory.Work.PatrolPointItemHistory>();

                for (int i = 0; i < PAll.Count; i++)
                //foreach (DbModel.Location.Work.PatrolPoint item in PAll)
                {
                    var item = PAll[i];

                    if (All.Count > 1000)
                    {
                        if (i % 20 == 0)
                        {
                            Log.Info(LogTags.Inspection, string.Format("DealPatrolPointItem Progress1(PAll) :{0}/{1}", i + 1, PAll.Count));
                        }
                    }
                    else
                    {
                        Log.Info(LogTags.Inspection, string.Format("DealPatrolPointItem Progress1(PAll) :{0}/{1}", i + 1, PAll.Count));
                    }


                    try
                    {
                        int    Id       = item.Id;
                        string deviceId = item.DeviceId;
                        int    ParentId = item.ParentId;
                        DbModel.Location.Work.InspectionTrack it = All.Find(p => p.Id == ParentId);
                        if (it == null)
                        {
                            continue;
                        }

                        int patrolId = (int)it.Abutment_Id;
                        var recv     = client.Getcheckresults(patrolId, deviceId);
                        //  CommunicationClass.SihuiThermalPowerPlant.Models.checkpoints recv = Getcheckresults(patrolId, deviceId);
                        if (recv == null || recv.checks.Count() <= 0)
                        {
                            continue;
                        }

                        foreach (results item2 in recv.checks)
                        {
                            try
                            {
                                if (isAllNew)
                                {
                                    var now = CreatePatrolPointItem(Id, item2);
                                    PIAdd.Add(now);
                                }
                                else
                                {
                                    var now = ppiList.Find(p => p.CheckId == item2.checkId && p.ParentId == Id);

                                    if (now == null)
                                    {
                                        now = CreatePatrolPointItem(Id, item2);
                                        PIAdd.Add(now);
                                    }
                                    else
                                    {
                                        SetCheckTime(item2, now);

                                        now.CheckResult = item2.checkResult;
                                        PIEdit.Add(now);
                                    }
                                }
                            }
                            catch (Exception ex1)
                            {
                                Log.Error(LogTags.Inspection, ex1);
                            }
                        }

                        if (PIAdd.Count > 1000)
                        {
                            bll.PatrolPointItems.AddRange(PIAdd);
                            PIAdd.Clear();
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(LogTags.Inspection, ex);
                    }
                }

                foreach (var item in PDelete)
                {
                    int Id = item.Id;
                    List <DbModel.Location.Work.PatrolPointItem> lstDelete = ppiList.FindAll(p => p.ParentId == Id).ToList();
                    if (lstDelete != null && lstDelete.Count() > 0)
                    {
                        PIDelete.AddRange(lstDelete);
                    }
                }
                for (int i = 0; i < PHAdd.Count; i++)
                //foreach (var item in PHAdd)
                {
                    if (All.Count > 10000)
                    {
                        if (i % 100 == 0)
                        {
                            Log.Info(LogTags.Inspection, string.Format("DealPatrolPointItem Progress2(PHAdd) :{0}/{1}", i + 1, PHAdd.Count));
                        }
                    }
                    else
                    {
                        Log.Info(LogTags.Inspection, string.Format("DealPatrolPointItem Progress2(PHAdd) :{0}/{1}", i + 1, PHAdd.Count));
                    }

                    var item = PHAdd[i];
                    try
                    {
                        int    Id       = item.Id;
                        string deviceId = item.DeviceId;
                        int    ParentId = item.ParentId;
                        DbModel.LocationHistory.Work.InspectionTrackHistory ith = HAdd.Find(p => p.Id == ParentId);
                        if (ith == null)
                        {
                            continue;
                        }
                        int patrolId = (int)ith.Abutment_Id;
                        var recv     = client.Getcheckresults(patrolId, deviceId);
                        //CommunicationClass.SihuiThermalPowerPlant.Models.checkpoints recv = Getcheckresults(patrolId, deviceId);

                        if (recv == null || recv.checks.Count() <= 0)
                        {
                            continue;
                        }

                        foreach (results item2 in recv.checks)
                        {
                            if (isAllNew)
                            {
                                var history = CreatePatrolPointItemHistory(Id, item2);
                                PIHAdd.Add(history);
                            }
                            else
                            {
                                var history = bll.PatrolPointItemHistorys.Find(p => p.CheckId == item2.checkId && p.ParentId == Id);
                                if (history == null)
                                {
                                    history = CreatePatrolPointItemHistory(Id, item2);
                                    PIHAdd.Add(history);
                                }
                            }
                        }
                        if (PIHAdd.Count > 1000)
                        {
                            bll.PatrolPointItemHistorys.AddRange(PIHAdd);
                            PIHAdd.Clear();
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(LogTags.Inspection, ex);
                    }
                }

                bll.PatrolPointItems.AddRange(PIAdd);
                bll.PatrolPointItems.EditRange(PIEdit);
                bll.PatrolPointItems.RemoveList(PIDelete);
                bll.PatrolPointItemHistorys.AddRange(PIHAdd);
                bll.Dispose();

                isAllNew = false;
            }
            catch (Exception ex)
            {
                string strMessage = ex.Message;
                Log.Error(LogTags.Inspection, ex);
            }
            return;
        }