mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 00:08:50 -07:00
Compare commits
2 Commits
fb6c935e7e
...
ea75d182a6
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ea75d182a6 | ||
![]() |
74b24d8ff5 |
203
src/Controllers/Common/ImportExportController.cs
Normal file
203
src/Controllers/Common/ImportExportController.cs
Normal file
@ -0,0 +1,203 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.Encodings.Web;
|
||||
using sodoff.Model;
|
||||
using sodoff.Schema;
|
||||
using sodoff.Util;
|
||||
|
||||
namespace sodoff.Controllers.Common;
|
||||
public class ExportController : ControllerBase {
|
||||
private readonly DBContext ctx;
|
||||
|
||||
public ExportController(DBContext ctx) {
|
||||
this.ctx = ctx;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("Export")]
|
||||
public IActionResult Export([FromForm] string username, [FromForm] string password) {
|
||||
// Authenticate user by Username
|
||||
User? user = ctx.Users.FirstOrDefault(e => e.Username == username);
|
||||
if (user is null || new PasswordHasher<object>().VerifyHashedPassword(null, user.Password, password) == PasswordVerificationResult.Failed) {
|
||||
return Unauthorized("Invalid username or password.");
|
||||
}
|
||||
|
||||
// Serialize to JSON
|
||||
var options = new JsonSerializerOptions
|
||||
{
|
||||
ReferenceHandler = ReferenceHandler.IgnoreCycles,
|
||||
Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
||||
WriteIndented = true
|
||||
};
|
||||
string jsonData = JsonSerializer.Serialize(user, options);
|
||||
|
||||
return Ok(jsonData);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("Import")]
|
||||
public IActionResult Import([FromForm] string username, [FromForm] string password, [FromForm] string vikingName, [FromForm] IFormFile dataFile, [FromForm] string? newVikingName) {
|
||||
User? user = ctx.Users.FirstOrDefault(e => e.Username == username);
|
||||
if (user is null || new PasswordHasher<object>().VerifyHashedPassword(null, user.Password, password) == PasswordVerificationResult.Failed) {
|
||||
return Unauthorized("Invalid username or password.");
|
||||
}
|
||||
|
||||
User user_data;
|
||||
using (var reader = new StreamReader(dataFile.OpenReadStream())) {
|
||||
user_data = System.Text.Json.JsonSerializer.Deserialize<User>(reader.ReadToEnd());
|
||||
}
|
||||
|
||||
foreach (var v in user_data.Vikings) {
|
||||
if (v.Name == vikingName) {
|
||||
if (String.IsNullOrEmpty(newVikingName))
|
||||
newVikingName = vikingName;
|
||||
|
||||
if (ctx.Vikings.Count(e => e.Name == newVikingName) > 0) {
|
||||
return Conflict("Viking name already in use");
|
||||
}
|
||||
|
||||
if (newVikingName != vikingName) {
|
||||
AvatarData avatarData = XmlUtil.DeserializeXml<AvatarData>(v.AvatarSerialized);
|
||||
avatarData.DisplayName = newVikingName;
|
||||
v.AvatarSerialized = XmlUtil.SerializeXml(avatarData);
|
||||
}
|
||||
|
||||
Viking viking = new Viking {
|
||||
Uid = Guid.NewGuid(),
|
||||
Name = newVikingName,
|
||||
User = user,
|
||||
AvatarSerialized = v.AvatarSerialized,
|
||||
CreationDate = DateTime.UtcNow,
|
||||
BirthDate = v.BirthDate,
|
||||
Gender = v.Gender,
|
||||
GameVersion = v.GameVersion
|
||||
};
|
||||
user.Vikings.Add(viking);
|
||||
|
||||
Dictionary<int, Guid> dragonIds = new();
|
||||
foreach (var x in v.Dragons) {
|
||||
x.Viking = viking;
|
||||
x.EntityId = Guid.NewGuid();
|
||||
dragonIds.Add(x.Id, x.EntityId);
|
||||
x.Id = 0;
|
||||
ctx.Dragons.Add(x);
|
||||
}
|
||||
Dictionary<int, int> itemIds = new();
|
||||
foreach (var x in v.InventoryItems) {
|
||||
itemIds.Add(x.Id, x.ItemId);
|
||||
x.Id = 0;
|
||||
x.Viking = viking;
|
||||
ctx.InventoryItems.Add(x);
|
||||
}
|
||||
|
||||
ctx.SaveChanges(); // need for get new ids of dragons and items
|
||||
|
||||
HashSet<int> usedItemIds = new();
|
||||
foreach (var x in v.Rooms) {
|
||||
x.Viking = viking;
|
||||
if (int.TryParse(x.RoomId, out int roomID)) {
|
||||
// numeric room name is inventory item id
|
||||
// remap old value to new value based on item id value
|
||||
roomID = viking.InventoryItems.FirstOrDefault(e => e.ItemId == itemIds[roomID] && !usedItemIds.Contains(e.Id)).Id;
|
||||
usedItemIds.Add(roomID);
|
||||
x.RoomId = roomID.ToString();
|
||||
}
|
||||
ctx.Rooms.Add(x);
|
||||
}
|
||||
foreach (var x in v.PairData) {
|
||||
x.Viking = viking;
|
||||
if (x.PairId == 2014) { // stables data
|
||||
foreach (var p in x.Pairs.Where(e => e.Key.StartsWith("Stable"))) {
|
||||
StableData stableData = XmlUtil.DeserializeXml<StableData>(p.Value);
|
||||
stableData.InventoryID = viking.InventoryItems.FirstOrDefault(e => e.ItemId == stableData.ItemID && !usedItemIds.Contains(e.Id)).Id;
|
||||
usedItemIds.Add(stableData.InventoryID);
|
||||
foreach (var n in stableData.NestList) {
|
||||
if (n.PetID != 0)
|
||||
n.PetID = viking.Dragons.FirstOrDefault(d => d.EntityId == dragonIds[n.PetID]).Id;
|
||||
}
|
||||
p.Value = XmlUtil.SerializeXml(stableData);
|
||||
}
|
||||
}
|
||||
ctx.PairData.Add(x);
|
||||
}
|
||||
|
||||
foreach (var x in v.Images) {
|
||||
x.Viking = viking;
|
||||
ctx.Images.Add(x);
|
||||
}
|
||||
foreach (var x in v.MissionStates) {
|
||||
x.Viking = viking;
|
||||
ctx.MissionStates.Add(x);
|
||||
}
|
||||
foreach (var x in v.TaskStatuses) {
|
||||
x.Viking = viking;
|
||||
ctx.TaskStatuses.Add(x);
|
||||
}
|
||||
foreach (var x in v.AchievementTaskStates) {
|
||||
x.Viking = viking;
|
||||
ctx.AchievementTaskState.Add(x);
|
||||
}
|
||||
foreach (var x in v.AchievementPoints) {
|
||||
x.Viking = viking;
|
||||
ctx.AchievementPoints.Add(x);
|
||||
}
|
||||
foreach (var x in v.ProfileAnswers) {
|
||||
x.Viking = viking;
|
||||
ctx.ProfileAnswers.Add(x);
|
||||
}
|
||||
foreach (var x in v.GameData) {
|
||||
x.Viking = viking;
|
||||
ctx.GameData.Add(x);
|
||||
}
|
||||
foreach (var x in v.SavedData) {
|
||||
x.Viking = viking;
|
||||
ctx.SavedData.Add(x);
|
||||
}
|
||||
foreach (var x in v.Parties) {
|
||||
x.Viking = viking;
|
||||
ctx.Parties.Add(x);
|
||||
}
|
||||
foreach (var x in v.UserMissions) {
|
||||
x.Viking = viking;
|
||||
ctx.UserMissions.Add(x);
|
||||
}
|
||||
foreach (var x in v.UserBadgesCompleted) {
|
||||
x.Viking = viking;
|
||||
ctx.UserBadgesCompleted.Add(x);
|
||||
}
|
||||
if (v.Ratings.Count > 0) {
|
||||
viking.Ratings = new List<Rating>();
|
||||
foreach (var x in v.Ratings) {
|
||||
// TODO (non-SoD) add rating via SetRating(viking, x.Rank.CategoryID, x.Rank.RatedEntityID, x.Rank.RatedUserID, x.Value);
|
||||
}
|
||||
}
|
||||
if (v.Neighborhood != null) {
|
||||
v.Neighborhood.Viking = viking;
|
||||
ctx.Neighborhoods.Add(v.Neighborhood);
|
||||
}
|
||||
|
||||
if (v.SelectedDragon != null)
|
||||
viking.SelectedDragon = viking.Dragons.FirstOrDefault(d => d.EntityId == dragonIds[v.SelectedDragon.Id]);
|
||||
|
||||
ctx.SaveChanges();
|
||||
return Ok("OK");
|
||||
}
|
||||
}
|
||||
return Ok("Viking Not Found");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("Export")]
|
||||
public IActionResult Export() {
|
||||
return Content(XmlUtil.ReadResourceXmlString("html.export"), "application/xhtml+xml");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("Import")]
|
||||
public IActionResult Import() {
|
||||
return Content(XmlUtil.ReadResourceXmlString("html.import"), "application/xhtml+xml");
|
||||
}
|
||||
}
|
@ -1,12 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model;
|
||||
public class AchievementPoints {
|
||||
[JsonIgnore]
|
||||
public int VikingId { get; set; }
|
||||
|
||||
public int Type { get; set; }
|
||||
|
||||
public int Value { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Viking? Viking { get; set; }
|
||||
}
|
||||
|
@ -1,15 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace sodoff.Model;
|
||||
|
||||
[PrimaryKey(nameof(TaskId), nameof(VikingId))]
|
||||
public class AchievementTaskState {
|
||||
[JsonIgnore]
|
||||
public int VikingId { get; set; }
|
||||
|
||||
public int TaskId { get; set; }
|
||||
|
||||
public int Points { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Viking? Viking { get; set; }
|
||||
}
|
||||
|
@ -23,6 +23,9 @@ public class DBContext : DbContext {
|
||||
public DbSet<ProfileAnswer> ProfileAnswers { get; set; } = null!;
|
||||
public DbSet<MMORole> MMORoles { get; set; } = null!;
|
||||
public DbSet<Party> Parties { get; set; } = null!;
|
||||
public DbSet<AchievementTaskState> AchievementTaskState { get; set; } = null!;
|
||||
public DbSet<SavedData> SavedData { get; set; } = null!;
|
||||
public DbSet<UserMissionData> UserMissions { get; set; } = null!;
|
||||
public DbSet<Neighborhood> Neighborhoods { get; set; } = null!;
|
||||
// we had a brief debate on whether it's neighborhoods or neighborheed
|
||||
public DbSet<Group> Groups { get; set; } = null!;
|
||||
|
@ -1,22 +1,29 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model;
|
||||
|
||||
[Index(nameof(EntityId), IsUnique = true)]
|
||||
public class Dragon {
|
||||
[Key]
|
||||
// [JsonIgnore] used in serialised xml (stables)
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public Guid EntityId { get; set; }
|
||||
|
||||
[Required]
|
||||
[JsonIgnore]
|
||||
public int VikingId { get; set; }
|
||||
|
||||
public string? RaisedPetData { get; set; }
|
||||
|
||||
public int? PetXP { get; set; }
|
||||
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Viking Viking { get; set; } = null!;
|
||||
public virtual ICollection<PairData> PairData { get; set; } = null!;
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model;
|
||||
public class GameData {
|
||||
[Key]
|
||||
[JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public int VikingId { get; set; }
|
||||
|
||||
public int GameId { get; set; }
|
||||
@ -15,6 +18,6 @@ public class GameData {
|
||||
public bool Win { get; set; }
|
||||
public bool Loss { get; set; }
|
||||
public virtual ICollection<GameDataPair> GameDataPairs { get; set; } = null!;
|
||||
[JsonIgnore]
|
||||
public virtual Viking Viking { get; set; } = null!;
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model;
|
||||
public class GameDataPair {
|
||||
[Key]
|
||||
[JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
[JsonIgnore]
|
||||
public int GameDataId { get; set; }
|
||||
public string Name { get; set; } = null!;
|
||||
public int Value { get; set; }
|
||||
[JsonIgnore]
|
||||
public virtual GameData GameData { get; set; } = null!;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace sodoff.Model;
|
||||
@ -12,11 +13,13 @@ public class Image {
|
||||
public int ImageSlot { get; set; }
|
||||
|
||||
[Required]
|
||||
[JsonIgnore]
|
||||
public int VikingId { get; set; }
|
||||
|
||||
public string? ImageData { get; set; }
|
||||
|
||||
public string? TemplateName { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Viking Viking { get; set; } = null!;
|
||||
}
|
||||
|
@ -1,18 +1,22 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model {
|
||||
public class InventoryItem {
|
||||
[Key]
|
||||
// [JsonIgnore] used as room id, used in serialised xml (pairs, ...)
|
||||
public int Id { get; set; }
|
||||
|
||||
public int ItemId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public int VikingId { get; set; }
|
||||
|
||||
public string? StatsSerialized { get; set; }
|
||||
|
||||
public string? AttributesSerialized { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Viking Viking { get; set; } = null!;
|
||||
|
||||
public int Quantity { get; set; }
|
||||
|
@ -1,15 +1,18 @@
|
||||
using sodoff.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model;
|
||||
|
||||
public class MMORole {
|
||||
[Key]
|
||||
[JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
|
||||
public int VikingId { get; set; }
|
||||
|
||||
public Role Role { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Viking? Viking { get; set; }
|
||||
}
|
||||
|
@ -1,15 +1,19 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model;
|
||||
|
||||
public class MissionState {
|
||||
[Key]
|
||||
[JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
|
||||
public int MissionId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public int VikingId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Viking? Viking { get; set; }
|
||||
|
||||
public MissionStatus MissionStatus { get; set; }
|
||||
@ -19,4 +23,4 @@ public class MissionState {
|
||||
|
||||
public enum MissionStatus {
|
||||
Upcoming,Active,Completed
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,20 @@
|
||||
using sodoff.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Data;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model
|
||||
{
|
||||
public class Neighborhood
|
||||
{
|
||||
[JsonIgnore]
|
||||
public virtual Viking? Viking { get; set; }
|
||||
|
||||
[Key]
|
||||
[JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
[JsonIgnore]
|
||||
public int VikingId { get; set; }
|
||||
|
||||
[Required]
|
||||
|
@ -1,18 +1,22 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model;
|
||||
|
||||
public class Pair {
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Key { get; set; } = null!;
|
||||
|
||||
public string Value { get; set; } = null!;
|
||||
|
||||
[JsonIgnore]
|
||||
public int MasterId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual PairData PairData { get; set; } = null!;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model;
|
||||
|
||||
@ -9,21 +10,28 @@ namespace sodoff.Model;
|
||||
public class PairData {
|
||||
[Key]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
|
||||
public int PairId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public Guid? UserId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public int? VikingId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public int? DragonId { get; set; }
|
||||
|
||||
public virtual ICollection<Pair> Pairs { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual User? User { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Viking? Viking { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Dragon? Dragon { get; set; }
|
||||
}
|
||||
|
@ -1,18 +1,21 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model
|
||||
{
|
||||
public class Party
|
||||
{
|
||||
[Key]
|
||||
[JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
public string Location { get; set; } = null!;
|
||||
[JsonIgnore]
|
||||
public int VikingId { get; set; }
|
||||
public DateTime ExpirationDate { get; set; } = DateTime.UtcNow;
|
||||
public bool? PrivateParty { get; set; }
|
||||
public string LocationIconAsset { get; set; } = null!;
|
||||
public string AssetBundle { get; set; } = null!;
|
||||
[JsonIgnore]
|
||||
public virtual Viking? Viking { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,19 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model
|
||||
{
|
||||
public class ProfileAnswer
|
||||
{
|
||||
[Key]
|
||||
[JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
[JsonIgnore]
|
||||
public int VikingId { get; set; }
|
||||
public int QuestionID { get; set; }
|
||||
public int AnswerID { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Viking Viking { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,21 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model;
|
||||
|
||||
public class Rating {
|
||||
[Key]
|
||||
[JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public int VikingId { get; set; }
|
||||
public int RankId { get; set; }
|
||||
|
||||
public int Value { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Viking Viking { get; set; }
|
||||
public virtual RatingRank Rank { get; set; }
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model;
|
||||
|
||||
public class RatingRank {
|
||||
[Key]
|
||||
[JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
|
||||
public int CategoryID { get; set; }
|
||||
@ -14,5 +16,6 @@ public class RatingRank {
|
||||
public float RatingAverage { get; set; } // On a scale of 1-5
|
||||
public DateTime UpdateDate { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual ICollection<Rating> Ratings { get; set; } = null!;
|
||||
}
|
||||
|
@ -1,18 +1,22 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model;
|
||||
|
||||
public class Room {
|
||||
[Key]
|
||||
[JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string RoomId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public int VikingId { get; set; }
|
||||
|
||||
public string? Name { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Viking? Viking { get; set; }
|
||||
|
||||
public virtual ICollection<RoomItem> Items { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,16 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model;
|
||||
public class RoomItem {
|
||||
[Key]
|
||||
[JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public int RoomId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Room Room { get; set; }
|
||||
|
||||
public string RoomItemData { get; set; }
|
||||
|
@ -1,8 +1,12 @@
|
||||
namespace sodoff.Model;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model;
|
||||
public class SavedData {
|
||||
[JsonIgnore]
|
||||
public int VikingId { get; set; }
|
||||
public uint SaveId { get; set; }
|
||||
public string? SerializedData { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Viking Viking { get; set; } = null!;
|
||||
}
|
||||
|
@ -1,14 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model
|
||||
{
|
||||
public class SceneData
|
||||
{
|
||||
[Key]
|
||||
[JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
public int VikingId { get; set; }
|
||||
public string SceneName { get; set; } = null!;
|
||||
public string XmlData { get; set; } = null!;
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Viking Viking { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,15 @@
|
||||
namespace sodoff.Model {
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model {
|
||||
public class TaskStatus {
|
||||
public int Id { get; set; }
|
||||
|
||||
public int MissionId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public int VikingId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Viking? Viking { get; set; }
|
||||
|
||||
public string? Payload { get; set; }
|
||||
|
@ -1,6 +1,10 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model;
|
||||
|
||||
[Index(nameof(Username), IsUnique = true)]
|
||||
public class User {
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
@ -14,6 +18,7 @@ public class User {
|
||||
[Required]
|
||||
public string Password { get; set; } = null!;
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual ICollection<Session> Sessions { get; set; } = null!;
|
||||
public virtual ICollection<Viking> Vikings { get; set; } = null!;
|
||||
public virtual ICollection<PairData> PairData { get; set; } = null!;
|
||||
|
@ -1,11 +1,16 @@
|
||||
namespace sodoff.Model
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace sodoff.Model
|
||||
{
|
||||
public class UserBadgeCompleteData
|
||||
{
|
||||
[JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
[JsonIgnore]
|
||||
public int VikingId { get; set; }
|
||||
public int BadgeId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Viking? Viking { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace sodoff.Model
|
||||
@ -6,6 +7,7 @@ namespace sodoff.Model
|
||||
[PrimaryKey(nameof(VikingId), nameof(WorldId), nameof(MissionId))]
|
||||
public class UserMissionData
|
||||
{
|
||||
[JsonIgnore]
|
||||
public int VikingId { get; set; }
|
||||
public int WorldId { get; set; }
|
||||
public int MissionId { get; set; }
|
||||
@ -13,6 +15,7 @@ namespace sodoff.Model
|
||||
public int TaskId { get; set; }
|
||||
public bool IsCompleted { get; set; } = false;
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual Viking? Viking { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Text.Json.Serialization;
|
||||
using sodoff.Schema;
|
||||
|
||||
namespace sodoff.Model;
|
||||
|
||||
[Index(nameof(Uid))]
|
||||
[Index(nameof(Uid), IsUnique = true)]
|
||||
public class Viking {
|
||||
[Key]
|
||||
[JsonIgnore]
|
||||
public int Id { get; set; }
|
||||
|
||||
public Guid Uid { get; set; }
|
||||
@ -15,13 +17,17 @@ public class Viking {
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Required]
|
||||
[JsonIgnore]
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
public string? AvatarSerialized { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public int? SelectedDragonId { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual ICollection<Session> Sessions { get; set; } = null!;
|
||||
[JsonIgnore]
|
||||
public virtual User User { get; set; } = null!;
|
||||
public virtual ICollection<Dragon> Dragons { get; set; } = null!;
|
||||
public virtual ICollection<Image> Images { get; set; } = null!;
|
||||
@ -37,8 +43,10 @@ public class Viking {
|
||||
public virtual ICollection<ProfileAnswer> ProfileAnswers { get; set; } = null!;
|
||||
public virtual ICollection<SavedData> SavedData { get; set; } = null!;
|
||||
public virtual ICollection<Party> Parties { get; set; } = null!;
|
||||
[JsonIgnore]
|
||||
public virtual ICollection<MMORole> MMORoles { get; set; } = null!;
|
||||
public virtual Neighborhood? Neighborhood { get; set; } = null!;
|
||||
[JsonIgnore]
|
||||
public virtual ICollection<Group> Groups { get; set; } = null!;
|
||||
public virtual ICollection<Rating> Ratings { get; set; } = null!;
|
||||
public virtual Dragon? SelectedDragon { get; set; }
|
||||
|
16
src/Resources/html/export.xml
Normal file
16
src/Resources/html/export.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Export SoDOff account</title>
|
||||
</head>
|
||||
<body>
|
||||
<form action="/Export" method="post">
|
||||
<label for="username">Username:</label><br />
|
||||
<input type="text" id="username" name="username" /><br />
|
||||
<label for="password">Password:</label><br />
|
||||
<input type="password" id="password" name="password" /><br /><br />
|
||||
<input type="submit" value="Submit" />
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
24
src/Resources/html/import.xml
Normal file
24
src/Resources/html/import.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Import SoDOff account</title>
|
||||
</head>
|
||||
<body>
|
||||
<form action="/Import" method="post" enctype="multipart/form-data">
|
||||
<label for="username">Username:</label><br />
|
||||
<input type="text" id="username" name="username" /><br />
|
||||
<label for="password">Password:</label><br />
|
||||
<input type="password" id="password" name="password" /><br /><br />
|
||||
|
||||
<label for="vikingName">Viking name (in imported file):</label><br />
|
||||
<input type="text" id="vikingName" name="vikingName" /><br />
|
||||
<label for="newVikingName">New viking name:</label><br />
|
||||
<input type="text" id="newVikingName" name="newVikingName" /><br />
|
||||
<label for="dataFile">Account data:</label><br />
|
||||
<input type="file" id="dataFile" name="dataFile" /><br /><br />
|
||||
|
||||
<input type="submit" value="Submit" />
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
13
src/Schema/NestData.cs
Normal file
13
src/Schema/NestData.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace sodoff.Schema;
|
||||
|
||||
[XmlRoot(ElementName = "NestData", Namespace = "")]
|
||||
[Serializable]
|
||||
public class NestData {
|
||||
[XmlElement(ElementName = "PetID")]
|
||||
public int PetID;
|
||||
|
||||
[XmlElement(ElementName = "ID")]
|
||||
public int ID;
|
||||
}
|
22
src/Schema/StableData.cs
Normal file
22
src/Schema/StableData.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace sodoff.Schema;
|
||||
|
||||
[XmlRoot(ElementName = "StableData", Namespace = "")]
|
||||
[Serializable]
|
||||
public class StableData {
|
||||
[XmlElement(ElementName = "Name")]
|
||||
public string Name;
|
||||
|
||||
[XmlElement(ElementName = "ID")]
|
||||
public int ID;
|
||||
|
||||
[XmlElement(ElementName = "ItemID")]
|
||||
public int ItemID;
|
||||
|
||||
[XmlElement(ElementName = "InventoryID")]
|
||||
public int InventoryID;
|
||||
|
||||
[XmlElement(ElementName = "Nests")]
|
||||
public List<NestData> NestList;
|
||||
}
|
23
src/Schema/UserRankData.cs
Normal file
23
src/Schema/UserRankData.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System.Diagnostics;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace sodoff.Schema;
|
||||
|
||||
[XmlRoot(ElementName = "UserRankData", Namespace = "")]
|
||||
[Serializable]
|
||||
public class UserRankData {
|
||||
[XmlElement(ElementName = "UserID")]
|
||||
public Guid UserID;
|
||||
|
||||
[XmlElement(ElementName = "Points")]
|
||||
public int Points;
|
||||
|
||||
[XmlElement(ElementName = "CurrentRank")]
|
||||
public UserRank CurrentRank;
|
||||
|
||||
[XmlElement(ElementName = "MemberRank")]
|
||||
public UserRank MemberRank;
|
||||
|
||||
[XmlElement(ElementName = "NextRank")]
|
||||
public UserRank NextRank;
|
||||
}
|
@ -155,5 +155,11 @@
|
||||
<EmbeddedResource Include="Resources\missions\badge_wojs_al.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Resources\html\export.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Resources\html\import.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
Loading…
x
Reference in New Issue
Block a user