コード例 #1
0
        public async Task <IHttpActionResult> PutCFlag(int id, CFlag cFlag)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cFlag.ID)
            {
                return(BadRequest());
            }

            db.Entry(cFlag).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CFlagExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
 public static InventoryLocColumn ToSyncModel(this inventoryLocation v, CFlag flag, long?offlineid = null)
 {
     return(new InventoryLocColumn
     {
         cflag = flag,
         serverid = v.id,
         name = v.name,
         id = offlineid
     });
 }
コード例 #3
0
ファイル: StockUnitColumn.cs プロジェクト: seanlinmt/tradelr
 public static StockUnitColumn ToSyncModel(this stockUnit v, CFlag flag, long?offlineid = null)
 {
     return(new StockUnitColumn()
     {
         cflag = flag,
         serverid = v.id,
         name = v.MASTERstockUnit.name,
         id = offlineid
     });
 }
コード例 #4
0
ファイル: UserColumn.cs プロジェクト: seanlinmt/tradelr
        public static List <UserColumn> ToSyncModel(this IEnumerable <user> values, CFlag flag, long?offlineid = null)
        {
            var result = new List <UserColumn>();

            foreach (var v in values)
            {
                result.Add(v.ToSyncModel(flag, offlineid));
            }
            return(result);
        }
コード例 #5
0
        public async Task <IHttpActionResult> GetCFlag(int id)
        {
            CFlag cFlag = await db.CFlags.FindAsync(id);

            if (cFlag == null)
            {
                return(NotFound());
            }

            return(Ok(cFlag));
        }
コード例 #6
0
 public static CategoryColumn ToSyncModel(this productCategory v, CFlag flag, long?offlineid = null)
 {
     return(new CategoryColumn
     {
         cflag = flag,
         id = offlineid,
         name = v.MASTERproductCategory.name,
         parentid = v.parentID,
         serverid = v.id
     });
 }
コード例 #7
0
        public async Task <IHttpActionResult> PostCFlag(CFlag cFlag)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CFlags.Add(cFlag);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = cFlag.ID }, cFlag));
        }
コード例 #8
0
 public static PhotosColumn ToSyncModel(this image v, CFlag flag, long?offlineid = null)
 {
     return(new PhotosColumn
     {
         cflag = flag,
         serverid = v.id,
         url = v.url.ToDataUri(),
         contextid = v.contextID,
         type = v.imageType,
         id = offlineid
     });
 }
コード例 #9
0
        public async Task <IHttpActionResult> DeleteCFlag(int id)
        {
            CFlag cFlag = await db.CFlags.FindAsync(id);

            if (cFlag == null)
            {
                return(NotFound());
            }

            db.CFlags.Remove(cFlag);
            await db.SaveChangesAsync();

            return(Ok(cFlag));
        }
コード例 #10
0
 public static List <SettingsColumn> ToSyncModel(this MASTERsubdomain v, CFlag flag)
 {
     return(new List <SettingsColumn>
     {
         new SettingsColumn
         {
             cflag = flag,
             id = v.id,
             currency = v.organisation.MASTERsubdomain.currency.ToCurrencySymbol(),
             flags = v.flags,
             serverid = v.id                 // required so we don't keep creating more rows in offlne db
         }
     });
 }
コード例 #11
0
ファイル: ProductColumn.cs プロジェクト: seanlinmt/tradelr
 public static ProductColumn ToSyncModel(this product p, CFlag flag, long?offlineid = null)
 {
     return(new ProductColumn
     {
         categoryid = p.category,
         cflag = flag,
         id = offlineid,
         thumbnailid = p.thumb,
         //SKU = p.SKU,
         title = p.title,
         details = p.details,
         sellingPrice = p.sellingPrice,
         costPrice = p.costPrice,
         notes = p.otherNotes,
         stockunitid = p.stockUnitId,
         flags = p.flags,
         serverid = p.id
     });
 }
コード例 #12
0
ファイル: OrgColumn.cs プロジェクト: seanlinmt/tradelr
 public static OrgColumn ToSyncModel(this organisation v, CFlag flag, long?offlineid = null)
 {
     return(new OrgColumn());
 }
コード例 #13
0
        public static List <InventoryLocItemColumn> ToSyncModel(this IEnumerable <inventoryLocationItem> values, CFlag flag, long?offlineid = null)
        {
            var result = new List <InventoryLocItemColumn>();

            foreach (var v in values)
            {
                result.Add(v.ToSyncModel(flag, offlineid));
            }
            return(result);
        }
コード例 #14
0
ファイル: ProductColumn.cs プロジェクト: seanlinmt/tradelr
        public static List <ProductColumn> ToSyncModel(this IEnumerable <product> products, CFlag flag, long?offlineid = null)
        {
            var result = new List <ProductColumn>();

            foreach (var p in products)
            {
                result.Add(p.ToSyncModel(flag, offlineid));
            }
            return(result);
        }
コード例 #15
0
 public FlagSelector(CFlag f)
 {
     this.Flag     = f;
     this.Selected = false;
 }
コード例 #16
0
        public ActionResult Save(CourseFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("CourseForm", viewModel));
            }

            Person userperson = _context.People.SingleOrDefault(p => p.ID == 0);

            if (viewModel.ID == 0)
            {
                Course course = new Course();

                course.CourseName = viewModel.CourseName;
                course.Length     = viewModel.Length;
                course.Notes      = viewModel.Notes;

                foreach (var fs in viewModel.Flags.Where(f => f.Selected))
                {
                    course.Flags.Add(_context.CFlags.Single(f => f.ID == fs.Flag.ID));
                }

                if (viewModel.PreReqs != null && viewModel.PreReqs.Length > 0)
                {
                    foreach (var cs in viewModel.PreReqs.Where(c => c.Selected))
                    {
                        course.PreReqs.Add(_context.Courses.Single(c => c.ID == cs.PreReq.ID));
                    }
                }

                course.Created  = DateTime.Now;
                course.Creator  = userperson;
                course.Modified = DateTime.Now;
                course.Modifier = userperson;
                _context.Courses.Add(course);
            }
            else
            {
                var courseInDb = _context.Courses.Include(c => c.Flags).Include(c => c.PreReqs).Single(c => c.ID == viewModel.ID);

                courseInDb.CourseName = viewModel.CourseName;
                courseInDb.Length     = viewModel.Length;
                courseInDb.Notes      = viewModel.Notes;

                foreach (var fs in viewModel.Flags)
                {
                    CFlag flg = _context.CFlags.Single(f => f.ID == fs.Flag.ID);
                    if (fs.Selected)
                    {
                        if (!courseInDb.Flags.Contains(flg))
                        {
                            courseInDb.Flags.Add(flg);
                        }
                    }
                    else
                    {
                        if (courseInDb.Flags.Contains(flg))
                        {
                            courseInDb.Flags.Remove(flg);
                        }
                    }
                }

                foreach (var cs in viewModel.PreReqs)
                {
                    Course cse = _context.Courses.Single(c => c.ID == cs.PreReq.ID);
                    if (cs.Selected)
                    {
                        if (!courseInDb.PreReqs.Contains(cse))
                        {
                            courseInDb.PreReqs.Add(cse);
                        }
                    }
                    else
                    {
                        if (courseInDb.PreReqs.Contains(cse))
                        {
                            courseInDb.PreReqs.Remove(cse);
                        }
                    }
                }

                courseInDb.Modified = DateTime.Now;
                courseInDb.Modifier = userperson;
            }

            _context.SaveChanges();

            return(RedirectToAction("Index", "Course"));
        }
コード例 #17
0
        /// <summary>
        /// Process stats for kill event
        /// </summary>
        /// <returns></returns>
        public async Task AddScriptKill(Player attacker, Player victim, int serverId, string map, string hitLoc, string type,
                                        string damage, string weapon, string killOrigin, string deathOrigin, string viewAngles, string offset, string isKillstreakKill, string Ads)
        {
            var     statsSvc     = ContextThreads[serverId];
            Vector3 vDeathOrigin = null;
            Vector3 vKillOrigin  = null;

            try
            {
                vDeathOrigin = Vector3.Parse(deathOrigin);
                vKillOrigin  = Vector3.Parse(killOrigin);
            }

            catch (FormatException)
            {
                Log.WriteWarning("Could not parse kill or death origin vector");
                Log.WriteDebug($"Kill - {killOrigin} Death - {deathOrigin}");
                await AddStandardKill(attacker, victim);

                return;
            }

            var kill = new EFClientKill()
            {
                Active           = true,
                AttackerId       = attacker.ClientId,
                VictimId         = victim.ClientId,
                ServerId         = serverId,
                Map              = ParseEnum <IW4Info.MapName> .Get(map, typeof(IW4Info.MapName)),
                DeathOrigin      = vDeathOrigin,
                KillOrigin       = vKillOrigin,
                DeathType        = ParseEnum <IW4Info.MeansOfDeath> .Get(type, typeof(IW4Info.MeansOfDeath)),
                Damage           = Int32.Parse(damage),
                HitLoc           = ParseEnum <IW4Info.HitLocation> .Get(hitLoc, typeof(IW4Info.HitLocation)),
                Weapon           = ParseEnum <IW4Info.WeaponName> .Get(weapon, typeof(IW4Info.WeaponName)),
                ViewAngles       = Vector3.Parse(viewAngles).FixIW4Angles(),
                TimeOffset       = Int64.Parse(offset),
                When             = DateTime.UtcNow,
                IsKillstreakKill = isKillstreakKill[0] != '0',
                AdsPercent       = float.Parse(Ads)
            };

            if (kill.DeathType == IW4Info.MeansOfDeath.MOD_SUICIDE &&
                kill.Damage == 100000)
            {
                // suicide by switching teams so let's not count it against them
                return;
            }

            await AddStandardKill(attacker, victim);

            if (kill.IsKillstreakKill)
            {
                return;
            }

            var clientDetection = Servers[serverId].PlayerDetections[attacker.ClientId];
            var clientStats     = Servers[serverId].PlayerStats[attacker.ClientId];

            // increment their hit count
            if (kill.DeathType == IW4Info.MeansOfDeath.MOD_PISTOL_BULLET ||
                kill.DeathType == IW4Info.MeansOfDeath.MOD_RIFLE_BULLET ||
                kill.DeathType == IW4Info.MeansOfDeath.MOD_HEAD_SHOT)
            {
                clientStats.HitLocations.Single(hl => hl.Location == kill.HitLoc).HitCount += 1;

                statsSvc.ClientStatSvc.Update(clientStats);
                await statsSvc.ClientStatSvc.SaveChangesAsync();
            }

            //statsSvc.KillStatsSvc.Insert(kill);
            //await statsSvc.KillStatsSvc.SaveChangesAsync();

            if (Plugin.Config.Configuration().EnableAntiCheat)
            {
                async Task executePenalty(Cheat.DetectionPenaltyResult penalty)
                {
                    switch (penalty.ClientPenalty)
                    {
                    case Penalty.PenaltyType.Ban:
                        await attacker.Ban("You appear to be cheating", new Player()
                        {
                            ClientId = 1
                        });

                        break;

                    case Penalty.PenaltyType.Flag:
                        if (attacker.Level != Player.Permission.User)
                        {
                            break;
                        }
                        var flagCmd = new CFlag();
                        await flagCmd.ExecuteAsync(new GameEvent(GameEvent.EventType.Flag, $"{(int)penalty.Bone}-{Math.Round(penalty.RatioAmount, 2).ToString()}@{penalty.KillCount}", new Player()
                        {
                            ClientId = 1,
                            Level = Player.Permission.Console,
                            ClientNumber = -1,
                            CurrentServer = attacker.CurrentServer
                        }, attacker, attacker.CurrentServer));

                        break;
                    }
                }

                await executePenalty(clientDetection.ProcessKill(kill));
                await executePenalty(clientDetection.ProcessTotalRatio(clientStats));
            }
        }
コード例 #18
0
ファイル: OrderColumn.cs プロジェクト: seanlinmt/tradelr
 public static OrderColumn ToSyncModel(this order v, CFlag flag, long?offlineid = null)
 {
     return(new OrderColumn());
 }
コード例 #19
0
 public static InventoryLocItemColumn ToSyncModel(this inventoryLocationItem v, CFlag flag, long?offlineid = null)
 {
     return(new InventoryLocItemColumn
     {
         cflag = flag,
         serverid = v.id,
         locationid = v.locationid,
         inventoryLevel = v.available,
         productid = v.variantid,
         onOrder = v.onOrder,
         alarmLevel = v.alarmLevel,
         id = offlineid
     });
 }