コード例 #1
0
ファイル: AreaHandler.cs プロジェクト: hhahh2011/CH.Gps
        public EAreaAlertReport CreateAlertReport(AlarmHandleContext context, EGPSCurrentInfo current, EnumAreaAlert state, EAreaAlertSetting alertSetting)
        {
            EAreaAlertReport newReport = new EAreaAlertReport();

            newReport.EnumAlarmGrade = EnumAlarmGrade.Prompt;
            newReport.EnumSMSInfoType = EnumSMSInfoType.Area;
            newReport.ACCState = current.ACCState;
            newReport.Speed = current.Speed;
            newReport.VStarkMileage = current.StarkMileage;
            newReport.GPSCode = current.GPSCode;
            newReport.GPSReportTime = current.ReportTime;
            newReport.Latitude = current.Latitude;
            newReport.Longitude = current.Longitude;
            newReport.MobileReceiveBeginTime = alertSetting.MobileReceiveBeginTime;
            newReport.MobileReceiveEndTime = alertSetting.MobileReceiveEndTime;
            newReport.ReceiveMobileList = alertSetting.ReceiveMobileList;
            newReport.ReceiveUserList = alertSetting.ReceiveUserList;
            newReport.TenantCode = alertSetting.TenantCode;
            newReport.UserReceiveBeginTime = alertSetting.UserReceiveBeginTime;
            newReport.UserReceiveEndTime = alertSetting.UserReceiveEndTime;
            newReport.VehicleCode = alertSetting.VehicleCode;
            newReport.VehiclePosition = this.GetPlaceName(context, current.Latitude, current.Longitude);
            newReport.LicensePlate = this.GetLicensePlate(context, current.VehicleCode.Value, alertSetting.TenantCode);
            newReport.DownSendOrderCode = DownSendCodeHelper.GPS.LogisticVehicle.IntoRegion;
            newReport.IsInArea = state != EnumAreaAlert.OutArea ? true : false;
            newReport.Area = alertSetting.Area;

            if (state == EnumAreaAlert.OutArea)
            {
                newReport.DownSendOrderCode = DownSendCodeHelper.GPS.LogisticVehicle.OutRegion;
                EAreaAlertReport inReport = GPSServiceFacade.Report.Area.GetRectInAreaEntity(newReport.Area.RecordID, newReport.VehicleCode, newReport.GPSReportTime);
                if (inReport != null)
                {
                    newReport.InAreaID = inReport.RecordID;
                    newReport.StayTime = newReport.GPSReportTime - inReport.GPSReportTime;
                }
            }
            else if (state == EnumAreaAlert.DelayStay)
            {
                newReport.DownSendOrderCode = DownSendCodeHelper.GPS.LogisticVehicle.DelayOutRegion;
                EAreaAlertReport inReport = GPSServiceFacade.Report.Area.GetRectInAreaEntity(newReport.Area.RecordID, newReport.VehicleCode, newReport.GPSReportTime);
                if (inReport != null)
                {
                    newReport.InAreaID = inReport.RecordID;
                    newReport.StayTime = newReport.GPSReportTime - inReport.GPSReportTime;
                }
                newReport.IsDelayStay = true;
                newReport.DelayDuration = alertSetting.DelayDuration;
            }

            return newReport;
        }
コード例 #2
0
ファイル: AreaHandler.cs プロジェクト: hhahh2011/CH.Gps
        private void Alert(AlarmHandleContext context, EGPSCurrentInfo current, EnumAreaAlert enumAreaAlert, EAreaAlertSetting areaSet, bool isAlert)
        {
            DateTime dt1 = DateTime.Now;
            EAreaAlertReport alertReport = this.CreateAlertReport(context, current, enumAreaAlert, areaSet);
            GPSServiceFacade.Report.Area.Add<EAreaAlertReport>(alertReport);
            Logger.Info(string.Format("Static_AreaAlertReportService.Add<EAreaAlertReport>(alertReport)共花销{0}毫秒", (DateTime.Now - dt1).TotalMilliseconds));

            if (isAlert)
            {
                if (areaSet.EnableSMS || areaSet.Enable)
                {
                    if (areaSet.EnableSMS && this.IsInMobileReceiveTime(alertReport))
                    {
                        this.SendSMS(context, alertReport);
                    }
                    if (areaSet.Enable && this.IsInUserReceiveTime(alertReport))
                    {
                        this.SendWebSiteSMS(context, alertReport);
                    }
                }
            }
        }