예제 #1
0
        /// <summary>
        /// Sets the ALPR flag/result for a specific vehicle. This will go in the Subtitle field of the notification, so make sure the string is not too long.
        /// You are able to use RPH color codes, such as ~b~ and ~r~.
        /// NOTE: This function will NOT set corresponding Persona or Vehicle details to match the flag you set; that part is YOUR responsibility!!
        /// </summary>
        /// <param name="veh">The Vehicle to set the flag for.</param>
        /// <param name="flag">The custom flag to be set.</param>
        /// <returns>True if the operation succeeded, or false if it failed. Errors will be logged.</returns>
        public static bool SetVehicleCustomALPRFlag(Vehicle veh, string flag)
        {
            try
            {
                if (veh.Exists())
                {
                    if (Globals.ScanResults.ContainsKey(veh))
                    {
                        ALPRScanResult r = new ALPRScanResult(veh, flag);
                        r.IsCustomFlag           = true;
                        Globals.ScanResults[veh] = r;
                    }
                    else
                    {
                        ALPRScanResult r = new ALPRScanResult(veh, flag);
                        r.IsCustomFlag = true;
                        Globals.ScanResults.Add(veh, r);
                    }

                    return(true);
                }
                else
                {
                    Logger.LogVerbose("Cannot set custom vehicle ALPR flag -- Vehicle is null.");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Logger.LogVerbose(String.Format("Exception occurred in API.SetVehicleCustomALPRFlag(Vehicle veh, string flag) -- {0}", ex.ToString()));
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// Sets the ALPR flag/result for a specific vehicle. This function uses the pre-defined alert types used by ALPR+.
        /// NOTE: This function will NOT set corresponding Persona or Vehicle details to match the flag you set; that part is YOUR responsibility!!
        /// </summary>
        /// <param name="veh">The Vehicle to set the flag for.</param>
        /// <param name="flag">The pre-defined flag to be set. If this parameter is EAlertType.Null, ALPR+ will not trigger any events for the vehicle (i.e. the vehicle has a 'clear record').
        /// However, again, YOU are responsible for setting the vehicle's owner and the driver's Persona accordingly!</param>
        /// <returns>True if the operation succeeded, or false if it failed. Errors will be logged.</returns>
        public static bool SetVehiclePredefinedALPRFlag(Vehicle veh, EAlertType flag)
        {
            try
            {
                if (veh.Exists())
                {
                    if (Globals.ScanResults.ContainsKey(veh))
                    {
                        Globals.ScanResults[veh].AlertType = flag;
                    }
                    else
                    {
                        ALPRScanResult r = new ALPRScanResult(veh, flag);
                        r.IsCustomFlag = false;
                        Globals.ScanResults.Add(veh, r);
                    }

                    if (Globals.ScanResults[veh] != null)
                    {
                        if (flag == EAlertType.Null)
                        {
                            Globals.ScanResults[veh].IsCustomFlag = false;
                            Globals.ScanResults[veh].SetResult("");
                            Globals.ScanResults[veh].Persona         = null;
                            Globals.ScanResults[veh].RegisteredOwner = "";
                        }
                    }

                    if (Funcs.IsTrafficPolicerRunning())
                    {
                        TrafficPolicer.SetVehicleRegistrationStatus(veh, EVehicleStatus.Valid);
                        TrafficPolicer.SetVehicleInsuranceStatus(veh, EVehicleStatus.Valid);
                    }

                    if (flag == EAlertType.Registration_Expired)
                    {
                        if (Funcs.IsTrafficPolicerRunning())
                        {
                            TrafficPolicer.SetVehicleRegistrationStatus(veh, EVehicleStatus.Expired);
                        }
                    }

                    if (flag == EAlertType.Unregistered_Vehicle)
                    {
                        if (Funcs.IsTrafficPolicerRunning())
                        {
                            TrafficPolicer.SetVehicleRegistrationStatus(veh, EVehicleStatus.None);
                        }
                    }

                    if (flag == EAlertType.No_Insurance)
                    {
                        if (Funcs.IsTrafficPolicerRunning())
                        {
                            TrafficPolicer.SetVehicleInsuranceStatus(veh, EVehicleStatus.None);
                        }
                    }

                    if (flag == EAlertType.Insurance_Expired)
                    {
                        if (Funcs.IsTrafficPolicerRunning())
                        {
                            TrafficPolicer.SetVehicleInsuranceStatus(veh, EVehicleStatus.Expired);
                        }
                    }

                    return(true);
                }
                else
                {
                    Logger.LogVerbose("Cannot set vehicle ALPR flag -- Vehicle is null.");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                Logger.LogVerbose(String.Format("Exception occurred in API.SetVehiclePredefinedALPRFlag(Vehicle veh, string flag) -- {0}", ex.ToString()));
                return(false);
            }
        }