コード例 #1
0
        private CommunicationClass.SihuiThermalPowerPlant.Models.patrols Getcheckpointss_File(int id)
        {
            string strResult = "";

            string basePath = AppDomain.CurrentDomain.BaseDirectory;
            string strPath  = basePath + "Data\\InspectionJson\\PatrolPoint" + Convert.ToString(id) + ".txt";

            strResult = System.IO.File.ReadAllText(strPath, Encoding.Default);

            if (strResult.Contains("404 Not Found"))
            {
                throw new Exception("404 Not Found");
            }

            CommunicationClass.SihuiThermalPowerPlant.Models.patrols obj = Newtonsoft.Json.JsonConvert.DeserializeObject <CommunicationClass.SihuiThermalPowerPlant.Models.patrols>(strResult);

            return(obj);
        }
コード例 #2
0
        private void DealPatrolPoint(Bll bll, List <InspectionTrack> All, List <InspectionTrack> Delete, List <InspectionTrackHistory> HAdd, WebApiLib.Clients.BaseDataClient client)
        {
            List <PatrolPoint>        ppList  = bll.PatrolPoints.ToList();
            List <PatrolPointHistory> ppHList = bll.PatrolPointHistorys.ToList();
            List <DbModel.Location.AreaAndDev.DevInfo> devList = bll.DevInfos.ToList();

            if (ppList == null)
            {
                ppList = new List <PatrolPoint>();
            }

            if (ppHList == null)
            {
                ppHList = new List <PatrolPointHistory>();
            }

            if (devList == null)
            {
                devList = new List <DbModel.Location.AreaAndDev.DevInfo>();
            }

            List <PatrolPoint>        PAll    = new List <PatrolPoint>();
            List <PatrolPoint>        PAdd    = new List <PatrolPoint>();
            List <PatrolPoint>        PEdit   = new List <PatrolPoint>();
            List <PatrolPoint>        PDelete = new List <PatrolPoint>();
            List <PatrolPointHistory> PHAdd   = new List <PatrolPointHistory>();

            foreach (InspectionTrack item in All)
            {
                int Id       = item.Id;
                int patrolId = (int)item.Abutment_Id;
                CommunicationClass.SihuiThermalPowerPlant.Models.patrols recv = client.Getcheckpoints(patrolId);
                if (recv == null || recv.route.Count() <= 0)
                {
                    continue;
                }

                foreach (CommunicationClass.SihuiThermalPowerPlant.Models.checkpoints item2 in recv.route)
                {
                    DbModel.Location.AreaAndDev.DevInfo dev1 = devList.Find(p => p.KKS == item2.kksCode);
                    PatrolPoint now = ppList.Find(p => p.DeviceId == item2.deviceId && p.ParentId == Id);
                    if (now == null)
                    {
                        now = new PatrolPoint();

                        now.ParentId   = Id;
                        now.StaffCode  = item2.staffCode;
                        now.StaffName  = item2.staffName;
                        now.KksCode    = item2.kksCode;
                        now.DevName    = item2.deviceName;
                        now.DeviceCode = item2.deviceCode;
                        now.DeviceId   = item2.deviceId;
                        if (dev1 != null)
                        {
                            now.DevId = dev1.Id;
                        }

                        PAdd.Add(now);
                    }
                    else
                    {
                        now.ParentId   = Id;
                        now.StaffCode  = item2.staffCode;
                        now.StaffName  = item2.staffName;
                        now.KksCode    = item2.kksCode;
                        now.DevName    = item2.deviceName;
                        now.DeviceCode = item2.deviceCode;
                        now.DeviceId   = item2.deviceId;
                        if (dev1 != null)
                        {
                            now.DevId = dev1.Id;
                        }

                        PEdit.Add(now);
                    }
                }
            }

            foreach (InspectionTrack item in Delete)
            {
                int Id = item.Id;
                List <PatrolPoint> lstDelete = ppList.FindAll(p => p.ParentId == Id).ToList();
                if (lstDelete != null && lstDelete.Count() > 0)
                {
                    PDelete.AddRange(lstDelete);
                }
            }

            foreach (InspectionTrackHistory item in HAdd)
            {
                int Id       = item.Id;
                int patrolId = (int)item.Abutment_Id;
                CommunicationClass.SihuiThermalPowerPlant.Models.patrols recv = client.Getcheckpoints(patrolId);
                if (recv == null || recv.route.Count() <= 0)
                {
                    continue;
                }

                foreach (CommunicationClass.SihuiThermalPowerPlant.Models.checkpoints item2 in recv.route)
                {
                    DbModel.Location.AreaAndDev.DevInfo dev1 = devList.Find(p => p.KKS == item2.kksCode);
                    PatrolPointHistory history = ppHList.Find(p => p.DeviceId == item2.deviceId && p.ParentId == Id);
                    if (history == null)
                    {
                        history = new PatrolPointHistory();

                        history.ParentId   = Id;
                        history.StaffCode  = item2.staffCode;
                        history.StaffName  = item2.staffName;
                        history.KksCode    = item2.kksCode;
                        history.DevName    = item2.deviceName;
                        history.DeviceCode = item2.deviceCode;
                        history.DeviceId   = item2.deviceId;
                        if (dev1 != null)
                        {
                            history.DevId = dev1.Id;
                        }

                        PHAdd.Add(history);
                    }
                }
            }

            bll.PatrolPoints.AddRange(PAdd);
            bll.PatrolPoints.EditRange(PEdit);
            bll.PatrolPoints.RemoveList(PDelete);
            bll.PatrolPointHistorys.AddRange(PHAdd);

            PAll.AddRange(PAdd);
            PAll.AddRange(PEdit);
            DealPatrolPointItem(bll, All, HAdd, PAll, PDelete, PHAdd, client);

            return;
        }
コード例 #3
0
        private void DealPatrolPoint(List <DbModel.Location.Work.InspectionTrack> All, List <DbModel.Location.Work.InspectionTrack> Delete, List <DbModel.LocationHistory.Work.InspectionTrackHistory> HAdd, WebApiLib.Clients.BaseDataClient client)
        {
            Log.Info(LogTags.Inspection, string.Format("DealPatrolPoint Start"));

            Bll bll = Bll.NewBllNoRelation();
            List <DbModel.Location.Work.PatrolPoint> ppList = bll.PatrolPoints.ToList();
            List <DbModel.LocationHistory.Work.PatrolPointHistory> ppHList = bll.PatrolPointHistorys.ToList();

            //List<DbModel.Location.AreaAndDev.DevInfo> devList = bll.DevInfos.ToList();
            if (ppList == null)
            {
                ppList = new List <DbModel.Location.Work.PatrolPoint>();
            }

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

            //if (devList == null)
            //{
            //    devList = new List<DbModel.Location.AreaAndDev.DevInfo>();
            //}

            List <DbModel.Location.Work.PatrolPoint> PAll                = new List <DbModel.Location.Work.PatrolPoint>();
            List <DbModel.Location.Work.PatrolPoint> PAdd                = new List <DbModel.Location.Work.PatrolPoint>();
            List <DbModel.Location.Work.PatrolPoint> PEdit               = new List <DbModel.Location.Work.PatrolPoint>();
            List <DbModel.Location.Work.PatrolPoint> PDelete             = new List <DbModel.Location.Work.PatrolPoint>();
            List <DbModel.LocationHistory.Work.PatrolPointHistory> PHAdd = new List <DbModel.LocationHistory.Work.PatrolPointHistory>();

            //foreach (DbModel.Location.Work.InspectionTrack item in All)
            for (int i = 0; i < All.Count; i++)
            {
                if (All.Count > 100)
                {
                    if (i % 10 == 0)
                    {
                        Log.Info(LogTags.Inspection, string.Format("DealPatrolPoint Progress1(All) :{0}/{1}", i + 1, All.Count));
                    }
                }
                else
                {
                    Log.Info(LogTags.Inspection, string.Format("DealPatrolPoint Progress1(All) :{0}/{1}", i + 1, All.Count));
                }

                var item     = All[i];
                int Id       = item.Id;
                int patrolId = (int)item.Abutment_Id;
                CommunicationClass.SihuiThermalPowerPlant.Models.patrols recv = client.GetPatrolDetail(patrolId);
                // CommunicationClass.SihuiThermalPowerPlant.Models.patrols recv = Getcheckpoints(patrolId);

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

                foreach (checkpoints item2 in recv.route)
                {
                    //DbModel.Location.AreaAndDev.DevInfo dev1 = devList.Find(p => p.KKS == item2.kksCode);
                    DbModel.Location.Work.PatrolPoint now = ppList.Find(p => p.DeviceId == item2.deviceId && p.ParentId == Id);
                    if (now == null)
                    {
                        now = new DbModel.Location.Work.PatrolPoint();
                        SetPatrolPointProperty(Id, item2, now);
                        PAdd.Add(now);
                    }
                    else
                    {
                        SetPatrolPointProperty(Id, item2, now);
                        PEdit.Add(now);
                    }
                }
            }

            foreach (DbModel.Location.Work.InspectionTrack item in Delete)
            {
                int Id = item.Id;
                List <DbModel.Location.Work.PatrolPoint> lstDelete = ppList.FindAll(p => p.ParentId == Id).ToList();
                if (lstDelete != null && lstDelete.Count() > 0)
                {
                    PDelete.AddRange(lstDelete);
                }
            }

            //foreach (DbModel.LocationHistory.Work.InspectionTrackHistory item in HAdd)
            for (int i = 0; i < HAdd.Count; i++)
            {
                if (All.Count > 100)
                {
                    if (i % 20 == 0)
                    {
                        Log.Info(LogTags.Inspection, string.Format("DealPatrolPoint Progress2(HAdd) :{0}/{1}", i + 1, HAdd.Count));
                    }
                }
                else
                {
                    Log.Info(LogTags.Inspection, string.Format("DealPatrolPoint Progress2(HAdd) :{0}/{1}", i + 1, HAdd.Count));
                }

                DbModel.LocationHistory.Work.InspectionTrackHistory item = HAdd[i];
                int Id       = item.Id;
                int patrolId = (int)item.Abutment_Id;
                CommunicationClass.SihuiThermalPowerPlant.Models.patrols recv = client.GetPatrolDetail(patrolId);
                //CommunicationClass.SihuiThermalPowerPlant.Models.patrols recv = Getcheckpoints(patrolId);
                if (recv == null || recv.route.Count() <= 0)
                {
                    continue;
                }

                foreach (CommunicationClass.SihuiThermalPowerPlant.Models.checkpoints item2 in recv.route)
                {
                    //DbModel.Location.AreaAndDev.DevInfo dev1 = devList.Find(p => p.KKS == item2.kksCode);
                    DbModel.LocationHistory.Work.PatrolPointHistory history = ppHList.Find(p => p.DeviceId == item2.deviceId && p.ParentId == Id);
                    if (history == null)
                    {
                        history = CreatePatrolPointHistory(Id, item2);
                        PHAdd.Add(history);
                    }
                }
            }


            Log.Info(LogTags.Inspection, string.Format("DealPatrolPoint Edit...."));

            bll.PatrolPoints.AddRange(PAdd);
            bll.PatrolPoints.EditRange(PEdit);
            bll.PatrolPoints.RemoveList(PDelete);
            bll.PatrolPointHistorys.AddRange(PHAdd);

            PAll.AddRange(PAdd);
            PAll.AddRange(PEdit);
            bll.Dispose();

            Log.Info(LogTags.Inspection, string.Format("DealPatrolPoint End...."));
            DealPatrolPointItem(All, HAdd, PAll, PDelete, PHAdd, client);

            return;
        }