public void TriggerViolation(float posX, float positionX, float posY, float positionY, float posZ, float positionZ, int sTime, int cTime, float RunSpeed) { if (posX != positionX && posY != positionY && posZ != positionZ) { TotalOffset = GetTotalOffset(cTime, sTime); float Distance = PlayerMoveDistance(posX, positionX, posY, positionY, posZ, positionZ); if (TotalOffset >= 235 && TotalOffset < 35000) { LastMessage = $"Time Hack | Offset: {TotalOffset}"; LastViolation = ViolationType.AC_VIOLATION_SPEEDHACK_TIME; } else if (Distance >= RunSpeed) { float Estimate = (float)(Distance * 1.54); LastMessage = $"Memory Hack | Distance: {Distance} Estimated Speed: {Estimate}"; LastViolation = ViolationType.AC_VIOLATION_SPEEDHACK_MEM; } else if (Math.Abs(posZ - positionZ) >= 10f) { LastMessage = $"Jump/Fly Hack | Z: {posZ}"; LastViolation = ViolationType.AC_VIOLATION_MOVEMENT_Z; } else { LastMessage = ""; LastViolation = ViolationType.AC_VIOLATION_NONE; } } LastClientTime = cTime; LastServerTime = sTime; }
private void HandleNewState(ViolationType type) { if (!load) { switch (type) { case ViolationType.OPEN: DataModel.Instance.CurrentWorkbook.Violations.Add(this); break; case ViolationType.IGNORE: this.IsRead = true; DataModel.Instance.CurrentWorkbook.IgnoredViolations.Add(this); break; case ViolationType.LATER: this.IsRead = true; DataModel.Instance.CurrentWorkbook.LaterViolations.Add(this); break; case ViolationType.SOLVED: this.IsRead = true; DataModel.Instance.CurrentWorkbook.SolvedViolations.Add(this); break; } PersistCellLocation(); } }
private void NotifyLockdownViolation(ViolationType violationType) { var description = ""; if (violationType == ViolationType.Distance) { description = "You have traveled for more than 5 km's"; Application.Current.MainPage.DisplayAlert("Stage 4 Violation", description, "Ok"); TimeVibrated = true; } else { description = "You have traveled for more than one hour"; Application.Current.MainPage.DisplayAlert("Stage 4 Violation", description, "Ok"); DistanceVibrated = true; } // Or use specified time var duration = TimeSpan.FromSeconds(2); Vibration.Vibrate(duration); //var notification = new NotificationRequest //{ // NotificationId = 100, // Title = "Stage 4 violation", // Description = description, // ReturningData = "Dummy data", // Returning data when tapped on notification. // NotifyTime = DateTime.Now.AddSeconds(30) // Used for Scheduling local notification, if not specified notification will show immediately. //}; //NotificationCenter.Current.Show(notification); SendNotification("Stage 4 Violation", description); }
// TODO: add a map<string,object> with reason and parameters public Violation(ViolationType type, string message, int lineNumber, string line) { myType = type; myMessage = message; myLineNumber = lineNumber; myLine = line; }
public IHttpActionResult PutViolationType(int id, ViolationType violationType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != violationType.ViolationTypeId) { return(BadRequest()); } db.Entry(violationType).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ViolationTypeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
// GET: ViolationsTypes/Details/5 public ActionResult Details(int?id) { ViolationType category = null; FileStream fsViolationsTypes = null; BinaryFormatter bfViolationsTypes = new BinaryFormatter(); List <ViolationType> categories = new List <ViolationType>(); string strViolationsTypesFile = Server.MapPath("~/App_Data/ViolationsTypes.tts"); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (System.IO.File.Exists(strViolationsTypesFile)) { using (fsViolationsTypes = new FileStream(strViolationsTypesFile, FileMode.Open, FileAccess.Read, FileShare.Read)) { categories = (List <ViolationType>)bfViolationsTypes.Deserialize(fsViolationsTypes); } category = categories.Find(cat => cat.ViolationTypeId == id); } if (category == null) { return(HttpNotFound()); } return(View(category)); }
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { SeverityIgnoreToColorConverter conv = new SeverityIgnoreToColorConverter(); ViolationType violationState = (ViolationType)values[0]; ICollection <Violation> violations = values[1] as ICollection <Violation>; decimal maxSeverity = violations.Max(vi => vi.Severity); decimal minSeverity = violations.Min(vi => vi.Severity); object[] objs = new object[2]; objs[0] = maxSeverity; objs[1] = violationState; Color maxColor = (Color)conv.Convert(objs, typeof(System.Windows.Media.Color), parameter, culture); objs[0] = minSeverity; Color minColor = (Color)conv.Convert(objs, typeof(System.Windows.Media.Color), parameter, culture); LinearGradientBrush brush = new LinearGradientBrush(); brush.StartPoint = new Point(0, 1); brush.EndPoint = new Point(0, 0); brush.GradientStops.Add(new GradientStop(minColor, 0)); brush.GradientStops.Add(new GradientStop(maxColor, 1)); return(brush); }
private bool IsSecure(Assembly assembly, out ViolationType violationType) { if (Bootstrap.RedoxMod.Config.PluginSecurity) { if (assembly.IsFullyTrusted) { bool flag = assembly.GetManifestResourceNames().Count() == 0; if (flag) { violationType = ViolationType.None; } else { violationType = ViolationType.Resources; } return(flag); } violationType = ViolationType.UntrustedAssembly; return(false); } violationType = ViolationType.None; return(true); }
public ActionResult DeleteConfirmed(int id) { ViolationType violationType = db.ViolationTypes.Find(id); db.ViolationTypes.Remove(violationType); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <ActionResult> DeleteConfirmed(int id) { ViolationType violationType = await db.ViolationTypes.FindAsync(id); db.ViolationTypes.Remove(violationType); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
/// <summary> /// @overloading /// Adds violation type into database table /// </summary> /// <param name="violation">Violation type data</param> /// <returns>True or false</returns> public async Task <bool> AddAsync(ViolationType violationType) { violationType.CreatedOn = DateTime.Now; violationType.UpdatedOn = DateTime.Now; _db.ViolationsType.Add(violationType); return((await _db.SaveChangesAsync()) > 0); }
/// <summary> /// Gets related objects form violations for specified type. /// </summary> /// <param name="type">Violation's type.</param> /// <param name="violations">All detected violations.</param> /// <returns>Related objects form violations for specified type.</returns> private static ICollection <DataObject> _GetRelatedObjects(ViolationType type, ICollection <Violation> violations) { var objects = from violation in violations where !(violation.AssociatedObject is Route) && (type == violation.ViolationType) select violation.AssociatedObject; return(objects.ToList()); }
public SpeedHackViolation(string Name, int cTime, int sTime) { LastViolation = ViolationType.AC_VIOLATION_NONE; Character = Name ?? throw new ArgumentNullException(nameof(Name)); Violations = 0; LastClientTime = cTime; LastServerTime = sTime; TotalOffset = 0; LastMessage = ""; }
public ActionResult Edit([Bind(Include = "Id,Description")] ViolationType violationType) { if (ModelState.IsValid) { db.Entry(violationType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(violationType)); }
/// <summary> /// @overloading /// Updates violation type from database table /// </summary> /// <param name="id">Violation type id</param> /// <param name="violation">Violation type data</param> /// <returns>True or false</returns> public async Task <bool> UpdateAsync(int id, ViolationType data) { var violationType = _db.ViolationsType.Single(vt => vt.ViolationTypeId == id); violationType.Description = data.Description; violationType.Points = data.Points; violationType.UpdatedOn = DateTime.Now; return((await _db.SaveChangesAsync()) > 0); }
public ActionResult Edit([Bind(Include = "Id,Name,Description,OrganizationId")] ViolationType violationtype) { if (ModelState.IsValid) { db.Entry(violationtype).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OrganizationId = new SelectList(db.Organizations, "Id", "Name", violationtype.OrganizationId); return(View(violationtype)); }
public IHttpActionResult GetViolationType(int id) { ViolationType violationType = db.ViolationTypes.Find(id); if (violationType == null) { return(NotFound()); } return(Ok(violationType)); }
public ActionResult Create([Bind(Include = "Id,Description")] ViolationType violationType) { if (ModelState.IsValid) { db.ViolationTypes.Add(violationType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(violationType)); }
public static IEnumerable <string> GetViolationsFromResponse( ILogger log, TaskLogger taskLogger, string output, IDictionary <string, string> variables, StringBuilder syncLogger, out ViolationType violationType, out string outputLog) { IEnumerable <string> violations; int outputValueIndex = output.IndexOf("[\n"); log.LogInformation($" outputValueIndex of [ <new line> : {outputValueIndex}"); if (outputValueIndex < 0) { outputValueIndex = output.IndexOf("[]"); log.LogInformation($" outputValueIndex of [] : {outputValueIndex}"); } string outputValueString = outputValueIndex >= 0 ? output.Substring(outputValueIndex) : string.Empty; CommonUtilities.LogInformation($"Output of policy check : {outputValueString}", log, taskLogger, variables, syncLogger); JArray outputArray = JsonConvert.DeserializeObject(outputValueString) as JArray; if (outputArray != null) { violations = outputArray.Values().Select(val => val.ToString(Formatting.Indented)).ToList(); violationType = violations.Any() ? ViolationType.ViolationsListNotEmpty : ViolationType.None; } else { if (output.IndexOf("undefined") == 0 || output.IndexOf("\nundefined") > 0) { violationType = ViolationType.ViolationsNotDefined; violations = new List <string> { "violations is not defined in the policy. Please define a rule called violations" }; } else { violationType = ViolationType.None; violations = new List <string>(); } } // Get every line in the log to a new line, for better readability in the logs pane // Without this step, each line of the output won't go to a new line number outputLog = Regex.Replace(output, @"(?<=\S)\n", "\r\n"); CommonUtilities.LogInformation(outputLog, log, taskLogger, variables, syncLogger, true); return(violations); }
public async Task <IActionResult> PutType(int id, [FromBody] ViolationType data) { var response = await _violationService.UpdateViolationTypeAsync(id, data); if (response) { return(Ok(response)); } return(NotFound(null)); }
public async Task <IActionResult> PostType([FromBody] ViolationType data) { var response = await _violationService.AddViolationTypeAsync(data); if (response) { return(Ok(response)); } return(NotFound(null)); }
public ActionResult Create([Bind(Include = "Id,Name,Description,OrganizationId")] ViolationType violationtype) { if (ModelState.IsValid) { db.ViolationTypes.Add(violationtype); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.OrganizationId = new SelectList(db.Organizations, "Id", "Name", violationtype.OrganizationId); return(View(violationtype)); }
public IHttpActionResult PostViolationType(ViolationType violationType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ViolationTypes.Add(violationType); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = violationType.ViolationTypeId }, violationType)); }
private void RaiseInTracer(ViolationType violationType) { var span = _tracer.ActiveSpan; if (span is null) { _logger.LogDebug("There is no active span in tracer."); return; } span.Log($"QoSViolation {violationType} raised."); span.SetTag(Violation, violationType.ToString()); }
public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ViolationType violationType = await db.ViolationTypes.FindAsync(id); if (violationType == null) { return(HttpNotFound()); } return(View(violationType)); }
// GET: ViolationTypes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ViolationType violationType = db.ViolationTypes.Find(id); if (violationType == null) { return(HttpNotFound()); } return(View(violationType)); }
public ActionResult Create(FormCollection collection) { try { // TODO: Add insert logic here int vTypeId = 0; FileStream fsViolationsTypes = null; BinaryFormatter bfViolationsTypes = new BinaryFormatter(); List <ViolationType> categories = new List <ViolationType>(); string strViolationsTypesFile = Server.MapPath("~/App_Data/ViolationsTypes.tts"); if (!string.IsNullOrEmpty("DrvLicNumber")) { if (System.IO.File.Exists(strViolationsTypesFile)) { using (fsViolationsTypes = new FileStream(strViolationsTypesFile, FileMode.Open, FileAccess.Read, FileShare.Read)) { categories = (List <ViolationType>)bfViolationsTypes.Deserialize(fsViolationsTypes); } foreach (ViolationType vt in categories) { vTypeId = vt.ViolationTypeId; } } vTypeId++; ViolationType category = new ViolationType() { ViolationTypeId = vTypeId, ViolationName = collection["ViolationName"], Description = collection["Description"], }; categories.Add(category); using (fsViolationsTypes = new FileStream(strViolationsTypesFile, FileMode.Create, FileAccess.Write, FileShare.Write)) { bfViolationsTypes.Serialize(fsViolationsTypes, categories); } } return(RedirectToAction("Index")); } catch { return(View()); } }
public IHttpActionResult DeleteViolationType(int id) { ViolationType violationType = db.ViolationTypes.Find(id); if (violationType == null) { return(NotFound()); } db.ViolationTypes.Remove(violationType); db.SaveChanges(); return(Ok(violationType)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Code,Name,Description,ViolationTypeSeverity,MaxViolationTypeSeverity,AppliesTo,IsAVLViolation,ApplicableLATATraxAlarm,DetectableByLATATraxAlone,ApplicableReports,CreatedOn,CreatedBy")] ViolationType violationType) { if (ModelState.IsValid) { violationType.ModifiedBy = HttpContext.User.Identity.Name; violationType.ModifiedOn = DateTime.Now; db.Entry(violationType).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(violationType)); }
// GET: /ViolationType/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ViolationType violationtype = db.ViolationTypes.Find(id); if (violationtype == null) { return(HttpNotFound()); } ViewBag.OrganizationId = new SelectList(db.Organizations, "Id", "Name", violationtype.OrganizationId); return(View(violationtype)); }
/// <summary> /// Constructor of a violation /// </summary> /// <param name="root">the root XML element</param> /// <param name="workbook">the current workbook</param> /// <param name="scanTime">the time when this violation has been occurred</param> /// <param name="rule">the rule of this violation</param> public Violation(XElement root, Workbook workbook, DateTime scanTime, Rule rule) { //this.Id = Convert.ToInt32(root.Attribute(XName.Get("number")).Value); this.CausingElement = root.Attribute(XName.Get("causingelement")).Value; this.Description = root.Attribute(XName.Get("description")).Value; this.Severity = decimal.Parse(root.Attribute(XName.Get("severity")).Value.Replace(".0", "")); this.workbook = workbook; this.firstOccurrence = scanTime; this.rule = rule; this.foundAgain = true; FindCellLocation(root.Attribute(XName.Get("location")).Value); this.violationState = ViolationType.OPEN; }
private static string FormatMessage(Dependency dependency, ViolationType violationType) { var message = violationType == ViolationType.Warning ? dependency.QuestionableMessage() : dependency.IllegalMessage(); if (dependency.FileName != null) { var sb = new StringBuilder(message); sb.Append(" (probably at ").Append(dependency.FileName); if (dependency.StartLine > 0) { sb.Append(":").Append(dependency.StartLine); } sb.Append(")"); return sb.ToString(); } else { return message; } }
/// <summary> /// Constructor of a violation /// </summary> /// <param name="root">the root XML element</param> /// <param name="workbook">the current workbook</param> /// <param name="scanTime">the time when this violation has been occurred</param> /// <param name="rule">the rule of this violation</param> public Violation(XElement root, Workbook workbook, DateTime scanTime, Rule rule) { //this.Id = Convert.ToInt32(root.Attribute(XName.Get("number")).Value); this.CausingElement = root.Attribute(XName.Get("causingelement")).Value; this.Description = root.Attribute(XName.Get("description")).Value; var location = root.Attribute(XName.Get("location")).Value; if (!string.IsNullOrWhiteSpace(location)) { // Split the location string into its components // Input might be: [example.xlsx]Sheet1!B12 location = location.Substring(location.IndexOf(']') + 1); this.Cell = new CellLocation(workbook, location); } this.firstOccurrence = scanTime; this.rule = rule; this.foundAgain = true; this.violationState = ViolationType.NEW; this.isVisible = true; }
/// <summary> /// Overrideable method to allow the derived class to create messages. /// </summary> /// <param name="description"></param> /// <param name="code"></param> /// <param name="violationType"></param> /// <param name="elements"></param> /// <returns></returns> protected override ValidationMessage ConstructValidationMessage(string description, string code, ViolationType violationType, params ModelElement[] elements) { var message = new ProductStoreTaskValidationMessage(this, description, TaskCategory.BuildCompile, code, violationType, null); message.UpdateReferencedModelElements(elements); return message; }
/// <summary> /// Initializes a new instance of the <see cref="ProductStoreTaskValidationMessage"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="description">The description.</param> /// <param name="category">The category.</param> /// <param name="code">The code.</param> /// <param name="violationType">Type of the violation.</param> /// <param name="helpKeyword">The help keyword.</param> public ProductStoreTaskValidationMessage(ValidationContext context, string description, TaskCategory category, string code, ViolationType violationType, string helpKeyword) : base(context, description, code, violationType) { this.category = category; this.HelpKeyword = helpKeyword; }
public VCEntry(NAViolatedConstraint naType, ViolationType type, string defaultDesc, VCDesc[] hrDesc) { this.NAType = naType; this.type = type; this.defaultDesc = defaultDesc; this.hrDesc = hrDesc; }
public VCDesc(int hr, string desc, ViolationType subType) { this.HR = hr; this.desc = desc; this.subType = subType; }
private void HandleNewState(ViolationType type) { if (!load) { switch (type) { case ViolationType.OPEN: DataModel.Instance.CurrentWorkbook.Violations.Add(this); break; case ViolationType.IGNORE: IsRead = true; DataModel.Instance.CurrentWorkbook.IgnoredViolations.Add(this); break; case ViolationType.LATER: IsRead = true; DataModel.Instance.CurrentWorkbook.LaterViolations.Add(this); break; case ViolationType.SOLVED: IsRead = true; DataModel.Instance.CurrentWorkbook.SolvedViolations.Add(this); break; } PersistCellLocation(); } }
/// <summary> /// Handles the action when a new ViolationState is set /// </summary> /// <param name="type">the type of the new violation State</param> protected abstract void HandleNewState(ViolationType type);
/// <summary> /// Constructor for the xml file, that is stored in the .xls file /// </summary> /// <param name="element">The root XElement of the xml</param> /// <param name="workbook">The current workbook</param> public Violation(XElement element, Workbook workbook) { this.load = true; this.workbook = workbook; this.CausingElement = element.Attribute(XName.Get("causingelement")).Value; this.Description = element.Attribute(XName.Get("description")).Value; this.FirstOccurrence = DateTime.Parse(element.Attribute(XName.Get("firstoccurrence")).Value); this.ViolationState = (ViolationType)Enum.Parse(typeof(ViolationType), element.Attribute(XName.Get("violationstate")).Value); this.SolvedTime = DateTime.Parse(element.Attribute(XName.Get("solvedtime")).Value); this.isRead = Convert.ToBoolean(element.Attribute(XName.Get("isread")).Value); this.isSelected = Convert.ToBoolean(element.Attribute(XName.Get("isselected")).Value); this.severity = Decimal.Parse(element.Attribute(XName.Get("severity")).Value); this.Rule = new Rule(element.Element(XName.Get("rule"))); FindCellLocation(element.Attribute(XName.Get("cell")).Value); this.load = false; this.IsCellSelected = false; }
public RuleViolation(Dependency dependency, ViolationType violationType) { _dependency = dependency; _violationType = violationType; }