public void UnRegisterDependency()
        {
            _notification.OnChanged -= Dependency_OnChange;

            WantedVehicle vehicle = _operationDB.WantedVehicles.Where(x => x.PlateNumber == _plateNumber).FirstOrDefault();

            if (vehicle != null)
            {
                vehicle.IsActive = false;

                _operationDB.SaveChanges();
            }
        }
Esempio n. 2
0
        public void AddWantedVehicle(string plateNumber, string plateCategory, string plateAuthority, string plateColor, DateTime violationTime, int corelationPeriod = 600, string reason = "")
        {
            WantedVehicle wantedVehicle = new WantedVehicle()
            {
                PlateNumber    = plateNumber,
                PlateCategory  = plateCategory,
                PlateAuthority = plateAuthority,
                PlateColor     = plateColor,
                WantedDate     = violationTime,
                IsActive       = true
            };

            if (!operationalDataContext.WantedVehicles.Any(x => x.PlateNumber == plateNumber && x.PlateCategory == plateCategory && x.PlateAuthority == plateAuthority && x.PlateColor == plateColor && x.IsActive))
            {
                operationalDataContext.WantedVehicles.Add(wantedVehicle);
                operationalDataContext.SaveChanges();
            }
            try
            {
                //        List<ViolationNotificationDTO> violationList = GetDangerousVehicleViolationList(plateNumber, plateColor,
                //plateAuthority, plateCategory, DateTime.Now.AddMinutes(corelationPeriod * -1), DateTime.Now);

                DangerousVehicleView vehicle = new DangerousVehicleView
                {
                    PlateNumber                 = plateNumber,
                    PlateKind                   = plateCategory,
                    PlateCode                   = plateAuthority,
                    PlateColor                  = plateColor,
                    SourceName                  = "DangerousVehicle",
                    ActivityCategoryCode        = "DangerousVehicle",
                    ActivityCategoryDescription = "New Dangerous Vehicle",
                    ActivityReasonCode          = reason.Trim().Length == 0 ? "New Dangerous Vehicle " : reason,
                    ActivityReasonDescription   = reason.Trim().Length == 0 ? "New Dangerous Vehicle " : reason,
                    StatusCode                  = "1",
                    StatusDescription           = "New",
                    ActivityDate                = DateTime.Now,
                    CorrelationPeriod           = corelationPeriod
                };

                stcDataContext.DangerousVehicleViews.Add(vehicle);

                //if (violationList != null && violationList.Count > 0)
                //{
                //    foreach (ViolationNotificationDTO violation in violationList)
                //    {
                //        DangerousVehicleViolation vehicleViolation = new DangerousVehicleViolation
                //        {
                //           // ActivityId = vehicle.ActivityId,
                //            OldViolationActivityId = violation.ViolationNotificationId
                //        };
                //        //vehicle.
                //        stcDataContext.DangerousVehicleViolations.Add(vehicleViolation);
                //    }
                //}

                stcDataContext.SaveChanges();
            }
            catch (Exception ex)
            {
                try
                {
                    Utility.WriteLog(ex, @"C:\STC\Websites\Server\WCF\");
                }
                catch (Exception exm)
                {
                }
            }
        }