public async Task <IHttpActionResult> PutPenaltyType(int id, PenaltyType penaltyType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != penaltyType.Id) { return(BadRequest()); } db.Entry(penaltyType).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PenaltyTypeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public Penalty(int penaltyPoints, PenaltyType type, string comment) : base() { this.penaltyPoints = penaltyPoints; this.type = type; this.comment = comment; }
public async Task <IActionResult> ListAsync(int offset = 0, PenaltyType showOnly = PenaltyType.Any) { return(await Task.FromResult(View("_List", new ViewModels.PenaltyFilterInfo() { Offset = offset, ShowOnly = showOnly }))); }
public Penalty(IGuild guild, PenaltyType penaltyType, int requiredPoints, string message = null, bool autoDelete = false) { GuildId = guild.Id; PenaltyType = penaltyType; RequiredPoints = requiredPoints; Message = message; AutoDelete = autoDelete; }
public IActionResult List(PenaltyType showOnly = PenaltyType.Any) { ViewBag.Description = "List of all the recent penalties (bans, kicks, warnings) on IW4MAdmin"; ViewBag.Title = Localization["WEBFRONT_PENALTY_TITLE"]; ViewBag.Keywords = "IW4MAdmin, penalties, ban, kick, warns"; return(View((SharedLibraryCore.Objects.Penalty.PenaltyType)showOnly)); }
public static bool ShouldPenaltyApplyToAllProfiles(this PenaltyType penaltyType) { return(penaltyType == PenaltyType.Ban || penaltyType == PenaltyType.Unban || penaltyType == PenaltyType.Flag || penaltyType == PenaltyType.Unflag || penaltyType == PenaltyType.TempBan); }
public async Task <IActionResult> ListAsync(int offset = 0, PenaltyType showOnly = PenaltyType.Any, bool hideAutomatedPenalties = true) { return(await Task.FromResult(View("_List", new ViewModels.PenaltyFilterInfo() { Offset = offset, ShowOnly = showOnly, IgnoreAutomated = hideAutomatedPenalties }))); }
public IActionResult List(PenaltyType showOnly = PenaltyType.Any, bool hideAutomatedPenalties = true) { ViewBag.Description = "List of all the recent penalties (bans, kicks, warnings) on IW4MAdmin"; ViewBag.Title = Localization["WEBFRONT_PENALTY_TITLE"]; ViewBag.Keywords = "IW4MAdmin, penalties, ban, kick, warns"; ViewBag.HideAutomatedPenalties = hideAutomatedPenalties; return(View(showOnly)); }
/// <summary> /// Возвращает путь к иконке сообщения. /// </summary> /// <param name="provider"></param> /// <param name="isRead">Сообщение прочитано</param> /// <param name="isMarked">Помечено ли сообщение флагом (очками).</param> /// <param name="isArticle">Является ли сообщение статьей.</param> /// <param name="violationPenaltyType">Тип бана</param> /// <param name="violationReason">Основание для бана</param> /// <returns>Путь к иконке сообщения.</returns> public static string GetMessageImagePath( IServiceProvider provider, bool isRead, bool isMarked, bool isArticle, PenaltyType violationPenaltyType = PenaltyType.Ban, string violationReason = null) { string path = null; if (isArticle) { path = isRead ? isMarked ? "MsgArticleMarked" : "MsgArticle" : isMarked ? "MsgArticleUnread2Marked" : "MsgArticleUnread"; } else { if (!string.IsNullOrEmpty(violationReason)) { switch (violationPenaltyType) { case PenaltyType.Ban: path = "PenaltyBan"; break; case PenaltyType.Close: path = "PenaltyClose"; break; case PenaltyType.Warning: path = "PenaltyWarning"; break; } } if (path == null) { path = isRead ? isMarked ? "MsgMarked" : "Msg" : isMarked ? "MsgUnread2Marked" : "MsgUnread"; } } return(GetImageUri(provider, @"MessageTree\" + path, StyleImageType.ConstSize)); }
public async Task <IHttpActionResult> GetPenaltyType(int id) { PenaltyType penaltyType = await db.PenaltyTypes.FindAsync(id); if (penaltyType == null) { return(NotFound()); } return(Ok(penaltyType)); }
public Penalty(string infringedRule, PenaltyType type, int value) { Type = type; if (type == PenaltyType.Measure) { throw new InvalidOperationException("Use Penalty(string infringedRule, Result measure) instead"); } Points = value; InfringedRules = infringedRule; InfringingTrack = new Track(); }
// POST: odata/PenaltyType public async Task <IHttpActionResult> Post(PenaltyType penaltyType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.PenaltyTypes.Add(penaltyType); await db.SaveChangesAsync(); return(Created(penaltyType)); }
public async Task <IHttpActionResult> PostPenaltyType(PenaltyType penaltyType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.PenaltyTypes.Add(penaltyType); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = penaltyType.Id }, penaltyType)); }
public async Task <IHttpActionResult> DeletePenaltyType(int id) { PenaltyType penaltyType = await db.PenaltyTypes.FindAsync(id); if (penaltyType == null) { return(NotFound()); } db.PenaltyTypes.Remove(penaltyType); await db.SaveChangesAsync(); return(Ok(penaltyType)); }
// DELETE: odata/PenaltyType(5) public async Task <IHttpActionResult> Delete([FromODataUri] int key) { PenaltyType penaltyType = await db.PenaltyTypes.FindAsync(key); if (penaltyType == null) { return(NotFound()); } db.PenaltyTypes.Remove(penaltyType); await db.SaveChangesAsync(); return(StatusCode(HttpStatusCode.NoContent)); }
/// <summary> /// Pokazujre wiadomość informującą o karze dla wszystkich graczy. /// </summary> /// <param name="charData"></param> /// <param name="adminData"></param> /// <param name="type"></param> /// <param name="reason"></param> private static void ShowMessage(Character charData, Character adminData, PenaltyType type, string reason) { var penClass = new { Type = GetPenaltyTypeName(type), Client = $"{charData.Name} {charData.Lastname}", Admin = adminData != null ? adminData.GlobalName : "System", Reason = reason }; foreach (Client entry in NAPI.Pools.GetAllPlayers()) { NAPI.ClientEvent.TriggerClientEvent(entry, "client.penalty.show", JsonConvert.SerializeObject(penClass, Formatting.None)); } }
public async Task Add(PenaltyType type, int at, bool autoDelete = false, [Remainder] string message = null) { var penalty = new Penalty(Context.Guild, type, at, message, autoDelete); _unit.Penalties.Add(penalty); _unit.SaveChanges(); if (at == 0) { await ReplyAsync($":white_check_mark: Penalty {type} has been added but is disabled. :white_check_mark:"); } else { await ReplyAsync($":white_check_mark: Penalty {type} has been added with {at} required points :white_check_mark:"); } }
public void AddPenalty(long accountId, PenaltyType penaltyType, DateTime dateEnd, string reason) { if (!MSManager.Instance.AuthentificatedAdmins.ContainsKey(CurrentClient.ClientId) || MSManager.Instance.AuthentificatedAdmins[CurrentClient.ClientId].Authority != AuthorityType.GameMaster) { return; } PenaltyLogDTO penalty = new PenaltyLogDTO() { AccountId = accountId, Penalty = penaltyType, DateStart = DateTime.Now, DateEnd = dateEnd, Reason = reason, AdminName = MSManager.Instance.AuthentificatedAdmins[CurrentClient.ClientId].Name }; DAOFactory.PenaltyLogDAO.InsertOrUpdate(ref penalty); }
private string GetDefaultMessage(PenaltyType penaltyType) { switch (penaltyType) { case PenaltyType.Nothing: return("Advertisement is not allowed in this Server"); case PenaltyType.Warn: return("Advertisement is not allowed in this Server! ***Last Warning***"); case PenaltyType.Kick: return("has been kicked for Advertisement"); case PenaltyType.Ban: return("has been banned for Advertisement"); default: throw new ArgumentOutOfRangeException(nameof(penaltyType), penaltyType, null); } }
public void DeleteRecord(string index) { try { //Step 1 Code to delete the object from the database PenaltyType s = new PenaltyType(); s.recordId = index; s.name = ""; //s.intName = ""; PostRequest <PenaltyType> req = new PostRequest <PenaltyType>(); req.entity = s; PostResponse <PenaltyType> r = _PayrollService.ChildDelete <PenaltyType>(req); if (!r.Success) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r);; return; } else { //Step 2 : remove the object from the store Store1.Remove(index); //Step 3 : Showing a notification for the user Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordDeletedSucc }); } } catch (Exception ex) { //In case of error, showing a message box to the user X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show(); } }
// PUT: odata/PenaltyType(5) public async Task <IHttpActionResult> Put([FromODataUri] int key, Delta <PenaltyType> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } PenaltyType penaltyType = await db.PenaltyTypes.FindAsync(key); if (penaltyType == null) { return(NotFound()); } patch.Put(penaltyType); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PenaltyTypeExists(key)) { return(NotFound()); } else { throw; } } return(Updated(penaltyType)); }
private PenaltyType GetPenaltyType(long Offset) { int result = _statreader.ReadStat(Offset); var penaltytype = new PenaltyType(); switch (result) { case 20: penaltytype = PenaltyType.Roughing; break; case 24: penaltytype = PenaltyType.Charging; break; case 26: penaltytype = PenaltyType.Slashing; break; case 28: penaltytype = PenaltyType.Roughing; break; case 30: penaltytype = PenaltyType.CrossCheck; break; case 32: penaltytype = PenaltyType.Hooking; break; case 34: penaltytype = PenaltyType.Tripping; break; case 38: penaltytype = PenaltyType.Interference; break; case 40: penaltytype = PenaltyType.Holding; break; default: //ERROR break; } return penaltytype; }
/// <summary> /// Возвращает путь к иконке сообщения. /// </summary> /// <param name="provider"></param> /// <param name="isRead">Сообщение прочитано</param> /// <param name="isMarked">Помечено ли сообщение флагом (очками).</param> /// <param name="isArticle">Является ли сообщение статьей.</param> /// <param name="violationPenaltyType">Тип бана</param> /// <param name="violationReason">Основание для бана</param> /// <returns>Путь к иконке сообщения.</returns> public static string GetMessageImagePath( IServiceProvider provider, bool isRead, bool isMarked, bool isArticle, PenaltyType violationPenaltyType = PenaltyType.Ban, string violationReason = null) { string path = null; if (isArticle) path = isRead ? isMarked ? "MsgArticleMarked" : "MsgArticle" : isMarked ? "MsgArticleUnread2Marked" : "MsgArticleUnread"; else { if (!string.IsNullOrEmpty(violationReason)) switch (violationPenaltyType) { case PenaltyType.Ban: path = "PenaltyBan"; break; case PenaltyType.Close: path = "PenaltyClose"; break; case PenaltyType.Warning: path = "PenaltyWarning"; break; } if (path == null) path = isRead ? isMarked ? "MsgMarked" : "Msg" : isMarked ? "MsgUnread2Marked" : "MsgUnread"; } return GetImageUri(provider, @"MessageTree\" + path, StyleImageType.ConstSize); }
public async Task AddAsyncTask(CancellationToken stoppingToken, PenaltyType penaltyType) { var setting = await _sRepo.GetByIdAsync(stoppingToken, 1); var dtNow = DateTime.Now; if (penaltyType == PenaltyType.Return) { var rb = await _rbRepo.TableNoTracking.Where(c => c.BorrowDate != null && c.BorrowDate.Value.AddDays(setting.BorrowDay) < dtNow).ToListAsync(cancellationToken: stoppingToken); foreach (var item in rb) { var penalty = await _repository.Table.Where(c => c.UserId == item.UserId && c.BookId == item.BookId && c.PenaltyType == PenaltyType.Return).FirstOrDefaultAsync(stoppingToken); if (penalty != null) { penalty.Amount += setting.Amount_Of_Punishment_For_Returning_The_Book; await _repository.UpdateAsync(penalty, stoppingToken); } else { penalty = new Penalty { Amount = setting.Amount_Of_Punishment_For_Returning_The_Book, BookId = item.BookId, PenaltyType = PenaltyType.Return, UserId = item.UserId, InsertDate = (DateTime)item.BorrowDate }; await _repository.AddAsync(penalty, cancellationToken : stoppingToken); } } } else { var rb2 = await _rbRepo.TableNoTracking.Where(c => c.ReserveDate != null && c.ReserveDate.Value.AddDays(setting.ReservDay) < dtNow).ToListAsync(cancellationToken: stoppingToken); foreach (var item in rb2) { var penalty2 = await _repository.Table.Where(c => c.UserId == item.UserId && c.BookId == item.BookId && c.PenaltyType == PenaltyType.Reserve).FirstOrDefaultAsync(stoppingToken); if (penalty2 == null) { penalty2 = new Penalty { Amount = setting.Amount_Of_Punishment_For_Reserving_The_Book, BookId = item.BookId, PenaltyType = PenaltyType.Reserve, UserId = item.UserId, InsertDate = (DateTime)item.ReserveDate }; await _repository.AddAsync(penalty2, cancellationToken : stoppingToken); } await _rbRepo.DeleteAsync(item, cancellationToken : stoppingToken); } } }
public async Task <List <PenaltySelectDto> > GetAll4AnyUserAsync(CancellationToken cancellationToken, string userId, PenaltyType penaltyType) { var model = await _repository.TableNoTracking.Where(c => c.UserId == userId).ProjectTo <PenaltySelectDto>().ToListAsync(cancellationToken); return(model); }
/// <summary> /// Zwraca nazwę kary. /// </summary> /// <param name="type"></param> /// <returns></returns> public static string GetPenaltyTypeName(PenaltyType type) { return(Data.PenaltyName.ContainsKey((int)type) ? Data.PenaltyName[(int)type] : "Nieznany typ kary"); }
public static double CalculateMaxValue(this DistributionConfiguration config, PenaltyType penaltyType, int sampleSize) { switch (config.Type) { case DistributionConfiguration.DistributionType.Normal: break; case DistributionConfiguration.DistributionType.LogNormal: double deviationNumber = penaltyType == PenaltyType.Flag ? 3.0 : 4.0; double marginOfError = 1.644 / (config.StandardDeviation / Math.Sqrt(sampleSize)); double maxValue = (config.StandardDeviation * deviationNumber) + marginOfError; return(maxValue); } return(double.MaxValue); }
protected void SaveNewRecord(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string obj = e.ExtraParams["values"]; PenaltyType b = JsonConvert.DeserializeObject <PenaltyType>(obj); List <PenaltyDetail> PD = JsonConvert.DeserializeObject <List <PenaltyDetail> >(e.ExtraParams["codes"]); string id = e.ExtraParams["id"]; // Define the object to add or edit as null if (!string.IsNullOrEmpty(currentPenaltyType.Text)) { id = currentPenaltyType.Text; b.recordId = currentPenaltyType.Text; } if (string.IsNullOrEmpty(id)) { try { //New Mode //Step 1 : Fill The object and insert in the store PostRequest <PenaltyType> request = new PostRequest <PenaltyType>(); request.entity = b; PostResponse <PenaltyType> r = _PayrollService.ChildAddOrUpdate <PenaltyType>(request); //check if the insert failed if (!r.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r);; return; } else { currentPenaltyType.Text = r.recordId; //PostRequest<PenaltyDetail> codesReq = new PostRequest<PenaltyDetail>(); //PD.ForEach(x => //{ // DeletePenaltyDetailsRecord(x); // codesReq.entity = x; // codesReq.entity.recordId = null; // PostResponse<PenaltyDetail> codesResp = _PayrollService.ChildAddOrUpdate<PenaltyDetail>(codesReq); // if (!codesResp.Success)//it maybe be another condition //{ // //Show an error saving... // X.MessageBox.ButtonText.Ok = Resources.Common.Ok; // X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", codesResp.ErrorCode) != null ? GetGlobalResourceObject("Errors", codesResp.ErrorCode).ToString() : codesResp.Summary).Show(); // throw new Exception(); // } //}); Store1.Reload(); penaltyDetailGrid.Disabled = false; //Display successful notification Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordSavingSucc }); //RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel; //sm.DeselectAll(); //sm.Select(b.recordId.ToString()); } } catch (Exception ex) { if (ex.Message != null) { //Error exception displaying a messsage box X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, ex.Message).Show(); } } } else { penaltyDetailGrid.Disabled = false; //Update Mode try { //getting the id of the record PostRequest <PenaltyType> request = new PostRequest <PenaltyType>(); request.entity = b; PostResponse <PenaltyType> r = _PayrollService.ChildAddOrUpdate <PenaltyType>(request); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r);; return; } else { DeleteAllPenaltyDetailsRecords(damage.Value.ToString()); PostRequest <PenaltyDetail> codesReq = new PostRequest <PenaltyDetail>(); PD.ForEach(x => { codesReq.entity = x; codesReq.entity.recordId = null; PostResponse <PenaltyDetail> codesResp = _PayrollService.ChildAddOrUpdate <PenaltyDetail>(codesReq); if (!codesResp.Success)//it maybe be another condition { //Show an error saving... X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", codesResp.ErrorCode) != null ? GetGlobalResourceObject("Errors", codesResp.ErrorCode).ToString() : codesResp.Summary).Show(); throw new Exception(); } }); Store1.Reload(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditRecordWindow.Close(); } } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } } }