コード例 #1
0
        // Only user/author can delete, and only if isPrivate == true
        internal string Delete(int id, string userId)
        {
            Keep foundKeep = GetKeepById(id, userId);

            if (foundKeep.UserId != userId)
            {
                throw new Exception("This is not your Keep to delete!");
            }
            if (_repo.Delete(id, userId))
            {
                return("Keep successfully deleted.");
            }
            throw new Exception("Public Keeps cannot be deleted! Says who?");
        }
コード例 #2
0
        //
        //VAULTKEEPS
        //

        //Create a vaultkeep
        public int CreateVaultKeep(VaultKeep vk)
        {
            Keep keep = _db.Query <Keep>(@"SELECT * FROM vaultKeeps
            WHERE keepId = @KeepId AND vaultId = @VaultId;", vk).FirstOrDefault();

            if (keep != null)
            {
                return(0);
            }
            return(_db.ExecuteScalar <int>(@"INSERT INTO vaultKeeps
            (vaultId, keepId, userId)
            VALUES (@VaultId, @KeepId, @UserID);
            SELECT LAST_INSERT_ID();", vk));
        }
コード例 #3
0
        internal Keep Edit(Keep editData)
        {
            string sql = @"
            UPDATE keeps
            SET
            name = @Name,
            description = @Description,
            img = @Img
            WHERE id = @Id;
            ";

            _db.Execute(sql, editData);
            return(editData);
        }
コード例 #4
0
        public async Task <ActionResult <Keep> > EditKeepAmount(int id, [FromQuery] Keep updated)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                updated.Id = id;
                return(Ok(_ks.EditKeepAmount(updated, userInfo)));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
コード例 #5
0
        public Keep Create(Keep keep)
        {
            int id = _db.ExecuteScalar <int>(@"INSERT INTO keeps
            (name, description, userId, isPrivate, img)
            VALUES (@Name, @Description, @userId, @isPrivate, @img);
            SELECT LAST_INSERT_ID();", keep);

            if (id == 0)
            {
                return(null);
            }
            keep.Id = id;
            return(keep);
        }
コード例 #6
0
 public ActionResult <String> Delete(int vaultId, int keepId)
 {
     try
     {
         var  userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         Keep update = _ks.GetById(keepId);
         _vks.DecrementKeepCount(update);
         return(Ok(_vks.Delete(vaultId, keepId)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #7
0
ファイル: KeepsRepository.cs プロジェクト: RileyTudbury/Keepr
        internal Keep EditKeepCounts(Keep updatedKeep)
        {
            string sql = @"
      UPDATE keeps
      SET
          keeps = @Keeps,
          shares = @Shares,
          views = @Views
      WHERE id = @Id
      ";

            _db.Execute(sql, updatedKeep);
            return(updatedKeep);
        }
コード例 #8
0
        private void RecordTransition(object sender, EventArgs e)
        {
            foreach (var plr in Keep.PlayersInRange)
            {
                Keep.SendKeepInfo(plr);
            }

            var stateInformation = (Appccelerate.StateMachine.Machine.Events.TransitionCompletedEventArgs <SM.ProcessState, SM.Command>)e;

            // Save the state transition.
            _logger.Debug($"Saving keep state KeepId : {Keep.Info.KeepId} {Keep.Info.Name}, " +
                          $"State : {stateInformation.StateId}=>{stateInformation.NewStateId} due to {stateInformation.EventId}");
            RVRProgressionService.SaveBattleFrontKeepState(Keep.Info.KeepId, stateInformation.NewStateId);
        }
コード例 #9
0
ファイル: KeepsService.cs プロジェクト: tristanberris/Keepr-1
        internal string Delete(int id, string userId)
        {
            Keep foundKeep = GetById(id);

            if (foundKeep.UserId != userId)
            {
                throw new Exception("This is not your keep!");
            }
            if (_repo.Delete(id, userId))
            {
                return("Successfully deleted");
            }
            throw new Exception("Something didn't work");
        }
コード例 #10
0
        internal string DeleteAsync(int vaultKeepId, string userId)
        {
            VaultKeep originalVK   = _vkRepo.Get(vaultKeepId);
            Vault     original     = _vService.Get(originalVK.VaultId, userId);
            Keep      originalKeep = _kService.Get(originalVK.KeepId);

            Console.WriteLine("yo" + originalKeep.Id);
            if (userId != original.CreatorId)
            {
                throw new Exception("You can't access this.");
            }
            _vkRepo.Delete(vaultKeepId, originalKeep.Id);
            return("deleted");
        }
コード例 #11
0
ファイル: KeepsController.cs プロジェクト: wesquintana/keepr
 public ActionResult <Keep> Edit([FromBody] Keep Update, int id)
 {
     try
     {
         var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         Update.UserId = userId;
         Update.Id     = id;
         return(_ks.Edit(Update));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #12
0
 public Keep GetOneByIdAndUpdate(int id, Keep keep)
 {
     return(_db.QueryFirstOrDefault <Keep>($@"
         UPDATE keeps SET
             Name = @Name,
             Description = @Description,
             Image = @Image,
             Shares = @Shares,
             Views = @Views,
             Public = @Public,
             UserId = @UserId
         WHERE Id = {id};
         SELECT * FROM keeps WHERE id = {id};", keep));
 }
コード例 #13
0
        public ActionResult <Keep> Edit([FromBody] Keep keep)
        {
            try
            {
                string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;

                keep.UserId = userId;
                return(Ok(_ks.Edit(keep)));
            }
            catch (System.Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
コード例 #14
0
ファイル: KeepsService.cs プロジェクト: dnbheidrich/Keepr
        internal Keep Delete(int id, string userId)
        {
            Keep found = GetById(id);

            if (found.UserId != userId)
            {
                throw new Exception("Invalid Request");
            }
            if (_repo.Delete(id))
            {
                return(found);
            }
            throw new Exception("Something went terribly wrong");
        }
コード例 #15
0
        public Keep Update(Keep value)
        {
            string query = @"
            UPDATE keeps
            SET
                name = @name,
                description = @description,
                img = @img,
                isPrivate = @isPrivate
            WHERE id = @id;            
            SELECT * FROM keeps WHERE id = @id";

            return(_db.QueryFirstOrDefault <Keep>(query, value));
        }
コード例 #16
0
ファイル: KeepsController.cs プロジェクト: Inlic/keepr
        public async Task <ActionResult <Keep> > UpdateStats([FromBody] Keep keep, int id)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                keep.Id = id;
                return(Ok(_serve.UpdateStats(keep)));
            }
            catch (Exception error)
            {
                return(BadRequest(error.Message));
            }
        }
コード例 #17
0
ファイル: KeepsService.cs プロジェクト: StevenPackard/fave-it
        internal string Delete(int id, string userId)
        {
            Keep found = Get(id, userId);

            if (found.UserId != userId)
            {
                throw new Exception("This isnt your keep homie.");
            }
            if (_repo.Delete(id, userId))
            {
                return("Successfully Deleted");
            }
            throw new Exception("Uh Oh something went wrong.");
        }
コード例 #18
0
        internal Keep GetById(int id)
        {
            Keep exists = _repo.GetById(id);

            if (exists == null)
            {
                throw new Exception("Invalid Id");
            }
            if (exists.IsPrivate == true)
            {
                throw new Exception("Invalid Id");
            }
            return(exists);
        }
コード例 #19
0
        internal Keep Edit(Keep EditedKeep)
        {
            string sql = @"
            UPDATE keeps
            SET
                name = @Name,
                img = @Img,
                description = @Description
            WHERE id = @Id;
            ";

            _db.Execute(sql, EditedKeep);
            return(EditedKeep);
        }
コード例 #20
0
ファイル: KeepsController.cs プロジェクト: porterwilcox/keepr
        public Keep Post([FromBody] Keep rawKeep)
        {
            if (!ModelState.IsValid)
            {
                throw new Exception("Not a valid Keep.");
            }
            Keep keep = _repo.Create(rawKeep);

            if (keep == null)
            {
                throw new Exception("Error inserting keep into the db.");
            }
            return(keep);
        }
コード例 #21
0
ファイル: KeepsService.cs プロジェクト: micahjbartron/keepr
        internal string Delete(int id, string user)
        {
            Keep foundKeep = GetById(id);

            if (foundKeep.UserId != user)
            {
                throw new Exception("this is not your keep!");
            }
            if (_repo.Delete(id, user))
            {
                return("Successfully Deleted");
            }
            throw new Exception("somehting has gone terribly wrong");
        }
コード例 #22
0
 public ActionResult <Keep> Edit(int id, [FromBody] Keep updatedKeep)
 {
     try
     {
         string userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         updatedKeep.UserId = userId;
         updatedKeep.Id     = id;
         return(Ok(_ks.Edit(updatedKeep)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #23
0
ファイル: KeepsService.cs プロジェクト: Itzmack117/Keepr
        internal string Delete(int id, string userId)
        {
            Keep found = GetById(id);

            if (found.UserId != userId)
            {
                throw new Exception("You can only delete your own keeps");
            }
            if (_repo.Delete(id, userId))
            {
                return("Delete successful.");
            }
            throw new Exception("error in deletion");
        }
コード例 #24
0
        internal Keep Create(Keep KeepData)
        {
            string sql = @"
            INSERT INTO keeps 
            (name, userId, description, img, isPrivate) 
            VALUES 
            (@Name, @UserId, @Description, @Img, @IsPrivate);
            SELECT LAST_INSERT_ID();
            ";
            int    id  = _db.ExecuteScalar <int>(sql, KeepData);

            KeepData.Id = id;
            return(KeepData);
        }
コード例 #25
0
   //UPDATE KEEP
   public Keep Update(Keep keep)
   {
       _db.Execute(@"
 UPDATE keeps SET
 name = @Name, 
 description = @Description,
 img = @Img,
 isPrivate = @IsPrivate,
 views = @Views,
 shares = @Shares, 
 keeps = @Keeps 
 WHERE id = @Id", keep);
       return(keep);
   }
コード例 #26
0
        public async Task <ActionResult <Keep> > EditKeep(int id, [FromBody] Keep editedKeep)
        {
            try
            {
                Profile userInfo = await HttpContext.GetUserInfoAsync <Profile>();

                editedKeep.Id = id;
                return(Ok(_ks.EditKeep(userInfo, editedKeep)));
            }
            catch (System.Exception error)
            {
                return(BadRequest(error.Message));
            }
        }
コード例 #27
0
 public ActionResult <Keep> Post([FromBody] Keep newKeep)
 {
     try
     {
         var userId = HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;
         newKeep.UserId = userId;
         Console.WriteLine(newKeep);
         return(Ok(_ks.Create(newKeep)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #28
0
 //EDIT/UPDATE KEEP
 public Keep GetOneByIdAndUpdate(int id, Keep keep)
 {
     return(_db.QueryFirstOrDefault <Keep>($@"
         UPDATE keeps 
         SET Name = @Name, 
             ImageUrl = @ImageUrl, 
             UserId = @UserId, 
             KeepCount = @KeepCount, 
             Viewed = @Viewed, 
             Public = @Public,
             Category = @Category
         WHERE id = {id};
         SELECT * FROM keeps WHERE id = {id};", keep));
 }
コード例 #29
0
        internal string Delete(int id, string userId)
        {
            Keep foundKeep = GetById(id);

            if (foundKeep.UserId != userId)
            {
                throw new Exception("You can only delete your own keeps");
            }
            if (_repo.Delete(id, userId))
            {
                return("Deleted");
            }
            throw new Exception("Deleted yeppers");
        }
コード例 #30
0
 public ActionResult <Keep> Create([FromBody] Keep newKeep)
 {
     try
     {
         string reqUserId = HttpContext.User.FindFirstValue("Id");
         User   user      = _as.GetUserById(reqUserId);
         newKeep.UserId = user.Id;
         return(Ok(_ks.Create(newKeep)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
コード例 #31
0
        /// <summary>
        /// Writes the log.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="stream">The stream.</param>
        /// <param name="callback">The callback for UI updates.</param>
        public void WriteLog(IExecutionContext context, Stream stream, ProgressCallback callback)
        {
            using (StreamWriter s = new StreamWriter(stream))
            {
                int region = 0;
                int ZoneXOffset = 0;
                int ZoneYOffset = 0;
                Hashtable m_obj = new Hashtable();
                foreach (PacketLog log in context.LogManager.Logs)
                {
                    for (int i = 0; i < log.Count; i++)
                    {
                        if (callback != null && (i & 0xFFF) == 0) // update progress every 4096th packet
                            callback(i, log.Count - 1);

                        StoC_0x20_PlayerPositionAndObjectID_171 pak_reg20 = log[i] as StoC_0x20_PlayerPositionAndObjectID_171;
                        if (pak_reg20 != null)
                        {
                            region = pak_reg20.Region;
                            ZoneXOffset = pak_reg20.ZoneXOffset;
                            ZoneYOffset = pak_reg20.ZoneYOffset;
                            //						m_obj.Clear();
                            m_keeps.Clear();
                            continue;
                        }
                        StoC_0xB7_RegionChange pak_regB7 = log[i] as StoC_0xB7_RegionChange;
                        if (pak_regB7 != null)
                        {
                            region = pak_regB7.RegionId;
                            ZoneXOffset = 0;
                            ZoneYOffset = 0;
                            //						m_obj.Clear();
                            m_keeps.Clear();
                            continue;
                        }
                        if (region != 238) continue;
                        StoC_0x69_KeepOverview pak_keep = log[i] as StoC_0x69_KeepOverview;
                        if (pak_keep != null)
                        {
                            Keep keep = new Keep();
                            keep.KeepID = pak_keep.KeepId;
                            keep.X = (uint) (pak_keep.KeepX + ZoneXOffset*0x2000);
                            keep.Y = (uint) (pak_keep.KeepY + ZoneYOffset*0x2000);
                            keep.Heading = pak_keep.Heading;
                            keep.Realm = pak_keep.Realm;
                            keep.Level = pak_keep.Level;
                            m_keeps[keep.KeepID] = keep;
                            continue;
                        }
                        KeepGuard guard = new KeepGuard();
                        StoC_0xD9_ItemDoorCreate door = log[i] as StoC_0xD9_ItemDoorCreate;
                        string key = "";
                        if (door != null)
                        {
                            if (door.ExtraBytes == 4)
                            {
                                guard.KeepGuard_ID = door.InternalId.ToString();
                                guard.Name = door.Name;
                                guard.EquipmentID = "";
                                guard.KeepID = 0;
                                guard.BaseLevel = 0;
                                guard.X = (uint) (door.X + ZoneXOffset*0x2000);
                                guard.Y = (uint) (door.Y + ZoneYOffset*0x2000);
                                guard.Z = door.Z;
                                guard.Heading = door.Heading;
                                guard.Realm = (door.Flags & 0x30) >> 4;
                                guard.Model = door.Model;
                                guard.ClassType = "DOL.GS.GameKeepDoor";
                                key = "REGION:" + region.ToString() + "-DOOR:" + guard.KeepGuard_ID;
                            }
                            else
                                continue;
                        }
                        else
                            continue;
                        if (key == "") continue;
                        if (m_obj.ContainsKey(key)) continue;
                        Keep my_keep = getKeepCloseToSpot(guard.X, guard.Y, 2000);
                        if (my_keep != null)
                        {
                            guard.KeepID = my_keep.KeepID;
                            guard.BaseLevel = my_keep.Level;
                        }
                        m_obj[key] = guard;
                    }
                }
                s.WriteLine("<KeepGuard>");
                foreach (KeepGuard guard in m_obj.Values)
                {
                    s.WriteLine("  <KeepGuard>");
                    if(guard.KeepGuard_ID == "")
                        s.WriteLine("    <KeepGuard_ID />");
                    else
                        s.WriteLine(string.Format("    <KeepGuard_ID>{0}</KeepGuard_ID>",guard.KeepGuard_ID));
                    if(guard.Name == "")
                        s.WriteLine("    <Name />");
                    else
                        s.WriteLine(string.Format("    <Name>{0}</Name>",guard.Name));
                    if(guard.EquipmentID == "")
                        s.WriteLine("    <EquipmentID />");
                    else
                        s.WriteLine(string.Format("    <EquipmentID>{0}</EquipmentID>",guard.EquipmentID));
                    s.WriteLine(string.Format("    <KeepID>{0}</KeepID>",guard.KeepID));
                    s.WriteLine(string.Format("    <BaseLevel>{0}</BaseLevel>",guard.BaseLevel));
                    s.WriteLine(string.Format("    <X>{0}</X>",guard.X));
                    s.WriteLine(string.Format("    <Y>{0}</Y>",guard.Y));
                    s.WriteLine(string.Format("    <Z>{0}</Z>",guard.Z));
                    s.WriteLine(string.Format("    <Heading>{0}</Heading>",guard.Heading));
                    s.WriteLine(string.Format("    <Realm>{0}</Realm>",guard.Realm));
                    s.WriteLine(string.Format("    <Model>{0}</Model>",guard.Model));
                    if(guard.ClassType == "")
                        s.WriteLine("    <ClassType />");
                    else
                        s.WriteLine(string.Format("    <ClassType>{0}</ClassType>",guard.ClassType));
                    s.WriteLine("  </KeepGuard>");
                }
                s.WriteLine("</KeepGuard>");
            }
        }
コード例 #32
0
        /// <summary>
        /// Activates a log action.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="selectedPacket">The selected packet.</param>
        /// <returns><c>true</c> if log data tab should be updated.</returns>
        public override bool Activate(IExecutionContext context, PacketLocation selectedPacket)
        {
            PacketLog log = context.LogManager.GetPacketLog(selectedPacket.LogIndex);
            int selectedIndex = selectedPacket.PacketIndex;

            int currentRegion = 0;
            int currentZone = 0;
            Hashtable keepComponentsByOids = new Hashtable();
            Hashtable keepComponents = new Hashtable();
            Hashtable keeps = new Hashtable();
            StringBuilder str = new StringBuilder();
            for (int i = 0; i < selectedIndex; i++)
            {
                Packet pak = log[i];
                if (pak is StoC_0x6C_KeepComponentOverview)
                {
                    StoC_0x6C_KeepComponentOverview  keep = (StoC_0x6C_KeepComponentOverview)pak;
                    string key = keep.KeepId + "C:" + keep.ComponentId;
                    Component kc;
                    if (!keepComponents.ContainsKey(key))
                    {
                        kc = new Component();
                        kc.KeepId = keep.KeepId;
                        kc.ComponentId = keep.ComponentId;
                        kc.Oid = keep.Uid;
                        kc.Skin = keep.Skin;
                        kc.addX = (sbyte)keep.X;
                        kc.addY = (sbyte)keep.Y;
                        kc.Rotate = keep.Heading;
                        kc.Height = keep.Height;
                        kc.Health = keep.Health;
                        kc.Status = keep.Status;
                        kc.Flag = keep.Flag;
                        kc.Zone = 0;
                        keepComponents[key] = kc;
                    }
                    else kc = (Component)keepComponents[key];
                    keepComponentsByOids[keep.Uid] = kc;
                }
                else if (pak is StoC_0x69_KeepOverview)
                {
                    StoC_0x69_KeepOverview keep = (StoC_0x69_KeepOverview)pak;
                    if (!keeps.ContainsKey(keep.KeepId))
                    {
                        Keep k = new Keep();
                        k.KeepId = keep.KeepId;
                        k.Angle = keep.Heading;
                        k.X = keep.KeepX;
                        k.Y = keep.KeepY;
                        keeps[keep.KeepId] = k;
                    }
                }
                else if (pak is StoC_0xA1_NpcUpdate)
                {
                    StoC_0xA1_NpcUpdate obj = (StoC_0xA1_NpcUpdate)pak;
                    if (keepComponentsByOids.ContainsKey(obj.NpcOid))
                    {
                        Component kc = (Component)keepComponentsByOids[obj.NpcOid];
                        string key = kc.KeepId + "C:" + kc.ComponentId;
                        kc.Zone = obj.CurrentZoneId;
                        kc.Heading = (ushort)(obj.Heading & 0xFFF);
                        kc.X = obj.CurrentZoneX;
                        kc.Y = obj.CurrentZoneY;
                        kc.Z = obj.CurrentZoneZ;
                        keepComponentsByOids[obj.NpcOid] = kc;
                        keepComponents[key] = kc;
                    }
                }
                else if (pak is StoC_0xB7_RegionChange)
                {
                    StoC_0xB7_RegionChange region = (StoC_0xB7_RegionChange)pak;

                    if (region.RegionId != currentRegion)
                    {
                        currentRegion = region.RegionId;
                        currentZone = region.ZoneId;
                        keepComponentsByOids.Clear();
                    }
                }
                else if (pak is StoC_0x20_PlayerPositionAndObjectID_171)
                {
                    StoC_0x20_PlayerPositionAndObjectID_171 region = (StoC_0x20_PlayerPositionAndObjectID_171)pak;

                    if (region.Region!= currentRegion)
                    {
                        currentRegion = region.Region;
                        keepComponentsByOids.Clear();
                    }
                }
            }
            foreach (Component kc in keepComponents.Values)
            {
                if (kc.Zone != 0)
                {
                    Keep k = (Keep)keeps[kc.KeepId];
                    str.AppendFormat("keepId:{0,-4} keepX:{1,-6} keepY:{2,-6} angle:{3,-3} ", k.KeepId, k.X, k.Y, k.Angle);
                    str.AppendFormat("componentId:{0,-2} oid:{1,-5} Skin:{2,-2} X:{3,-4} Y:{4,-4} Rotate:{5} ", kc.ComponentId, kc.Oid, kc.Skin, kc.addX, kc.addY, kc.Rotate);
                    str.AppendFormat("Heading:{0,-4} Zone:{1,-3} @X:{2,-5} @Y:{3,-5} Z:{4}\n", kc.Heading, kc.Zone, kc.X, kc.Y, kc.Z);
                }
            }
            InfoWindowForm infoWindow = new InfoWindowForm();
            infoWindow.Text = "Show keep components info (right click to close)";
            infoWindow.Width = 650;
            infoWindow.InfoRichTextBox.Text = str.ToString();
            infoWindow.StartWindowThread();
            return false;
        }
コード例 #33
0
        /// <summary>
        /// Initializes the packet. All data parsing must be done here.
        /// </summary>
        public override void Init()
        {
            Position = 0;

            templeBitMask = ReadShort(); // 0x00
            countKeep = ReadByte();      // 0x02
            countTower = ReadByte();     // 0x03
            r1 = ReadByte();             // 0x04
            r2 = ReadByte();             // 0x05
            r3 = ReadByte();             // 0x06
            r4 = ReadByte();             // 0x07
            r5 = ReadByte();             // 0x08
            r6 = ReadByte();             // 0x09
            m_keeps = new Keep[countKeep + countTower];

            ArrayList arr = new ArrayList(countKeep + countTower);
            for (int i = 0; i < (countKeep + countTower); i++)
            {
                Keep keep = new Keep();

                keep.id = ReadByte();             // 0x0A+
                keep.flag = ReadByte();           // 0x0B+
                keep.guild = ReadPascalString();  // 0x0C+

                m_keeps[i] = keep;
                int keepRealmMap = keep.id >> 6;
                int keepIndexOnMap = (keep.id >> 3) & 0x7;
                int keepTower = keep.id & 7;
                arr.Add((ushort)((keepRealmMap*25) + 25+ keepIndexOnMap + (keepTower << 8)));
            }
            m_oids = (ushort[])arr.ToArray(typeof (ushort));
        }