From 4ec507df6251bc1dae5204fdc6aaf14ddbb268f6 Mon Sep 17 00:00:00 2001 From: crupest Date: Sat, 18 Jan 2020 00:50:31 +0800 Subject: ... --- Timeline/Controllers/PersonalTimelineController.cs | 40 +-- Timeline/Controllers/TokenController.cs | 50 +--- Timeline/Controllers/UserAvatarController.cs | 74 ++---- Timeline/Controllers/UserController.cs | 64 +---- Timeline/ErrorCodes.cs | 35 --- Timeline/Filters/Header.cs | 55 +---- Timeline/Filters/Timeline.cs | 25 +- Timeline/Filters/User.cs | 24 +- Timeline/Helpers/InvalidModelResponseFactory.cs | 2 +- Timeline/InvalidBranchException.cs | 16 -- Timeline/Models/Http/Common.cs | 33 --- Timeline/Models/Http/ErrorResponse.cs | 261 ++++++++++++++++++++ Timeline/Models/Http/Timeline.cs | 3 - Timeline/Resources/Common.Designer.cs | 72 ------ Timeline/Resources/Common.resx | 123 ---------- .../Controllers/TimelineController.Designer.cs | 54 ----- .../Resources/Controllers/TimelineController.resx | 18 -- .../Controllers/TimelineController.zh.resx | 138 ----------- .../Controllers/TokenController.Designer.cs | 45 ---- .../Resources/Controllers/TokenController.resx | 15 -- .../Resources/Controllers/TokenController.zh.resx | 135 ----------- .../Controllers/UserAvatarController.Designer.cs | 72 ------ .../Controllers/UserAvatarController.resx | 24 -- .../Controllers/UserAvatarController.zh.resx | 144 ----------- .../Controllers/UserController.Designer.cs | 118 +-------- Timeline/Resources/Controllers/UserController.resx | 42 +--- .../Resources/Controllers/UserController.zh.resx | 138 ----------- Timeline/Resources/Filters.Designer.cs | 63 ----- Timeline/Resources/Filters.resx | 21 -- Timeline/Resources/Filters.zh.resx | 141 ----------- Timeline/Resources/Messages.Designer.cs | 270 +++++++++++++++++++++ Timeline/Resources/Messages.resx | 189 +++++++++++++++ Timeline/Resources/Messages.zh.resx | 189 +++++++++++++++ Timeline/Resources/Models/Http/Common.Designer.cs | 36 --- Timeline/Resources/Models/Http/Common.resx | 12 - Timeline/Resources/Models/Http/Common.zh.resx | 12 - Timeline/Timeline.csproj | 22 +- 37 files changed, 981 insertions(+), 1794 deletions(-) delete mode 100644 Timeline/ErrorCodes.cs delete mode 100644 Timeline/InvalidBranchException.cs create mode 100644 Timeline/Models/Http/ErrorResponse.cs delete mode 100644 Timeline/Resources/Common.Designer.cs delete mode 100644 Timeline/Resources/Common.resx delete mode 100644 Timeline/Resources/Controllers/TimelineController.zh.resx delete mode 100644 Timeline/Resources/Controllers/TokenController.zh.resx delete mode 100644 Timeline/Resources/Controllers/UserAvatarController.zh.resx delete mode 100644 Timeline/Resources/Controllers/UserController.zh.resx delete mode 100644 Timeline/Resources/Filters.zh.resx create mode 100644 Timeline/Resources/Messages.Designer.cs create mode 100644 Timeline/Resources/Messages.resx create mode 100644 Timeline/Resources/Messages.zh.resx (limited to 'Timeline') diff --git a/Timeline/Controllers/PersonalTimelineController.cs b/Timeline/Controllers/PersonalTimelineController.cs index c864ed39..e1e3aba0 100644 --- a/Timeline/Controllers/PersonalTimelineController.cs +++ b/Timeline/Controllers/PersonalTimelineController.cs @@ -12,24 +12,7 @@ using Timeline.Models.Http; using Timeline.Models.Validation; using Timeline.Services; using static Timeline.Resources.Controllers.TimelineController; - -namespace Timeline -{ - public static partial class ErrorCodes - { - public static partial class Http - { - public static class Timeline // ccc = 004 - { - public const int PostListGetForbid = 10040101; - public const int PostOperationCreateForbid = 10040102; - public const int PostOperationDeleteForbid = 10040103; - public const int PostOperationDeleteNotExist = 10040201; - public const int ChangeMemberUserNotExist = 10040301; - } - } - } -} +using static Timeline.Resources.Messages; namespace Timeline.Controllers { @@ -80,8 +63,7 @@ namespace Timeline.Controllers { if (!IsAdmin() && !await _service.HasReadPermission(username, GetAuthUsername())) { - return StatusCode(StatusCodes.Status403Forbidden, - new CommonResponse(ErrorCodes.Http.Timeline.PostListGetForbid, MessagePostListGetForbid)); + return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid()); } return await _service.GetPosts(username); @@ -94,8 +76,7 @@ namespace Timeline.Controllers { if (!IsAdmin() && !await _service.IsMemberOf(username, GetAuthUsername()!)) { - return StatusCode(StatusCodes.Status403Forbidden, - new CommonResponse(ErrorCodes.Http.Timeline.PostOperationCreateForbid, MessagePostOperationCreateForbid)); + return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid()); } var res = await _service.CreatePost(username, User.Identity.Name!, body.Content, body.Time); @@ -112,16 +93,13 @@ namespace Timeline.Controllers var postId = body.Id!.Value; if (!IsAdmin() && !await _service.HasPostModifyPermission(username, postId, GetAuthUsername()!)) { - return StatusCode(StatusCodes.Status403Forbidden, - new CommonResponse(ErrorCodes.Http.Timeline.PostOperationDeleteForbid, MessagePostOperationCreateForbid)); + return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid()); } await _service.DeletePost(username, postId); } catch (TimelinePostNotExistException) { - return BadRequest(new CommonResponse( - ErrorCodes.Http.Timeline.PostOperationDeleteNotExist, - MessagePostOperationDeleteNotExist)); + return BadRequest(ErrorResponse.TimelineController.PostOperationDelete_NotExist()); } return Ok(); } @@ -151,13 +129,13 @@ namespace Timeline.Controllers { if (e.InnerException is UsernameBadFormatException) { - return BadRequest(CommonResponse.InvalidModel( - string.Format(CultureInfo.CurrentCulture, MessageMemberUsernameBadFormat, e.Index, e.Operation))); + return BadRequest(ErrorResponse.Common.CustomMessage_InvalidModel( + TimelineController_ChangeMember_UsernameBadFormat, e.Index, e.Operation)); } else if (e.InnerException is UserNotExistException) { - return BadRequest(new CommonResponse(ErrorCodes.Http.Timeline.ChangeMemberUserNotExist, - string.Format(CultureInfo.CurrentCulture, MessageMemberUserNotExist, e.Index, e.Operation))); + return BadRequest(ErrorResponse.Common.CustomMessage_InvalidModel( + TimelineController_ChangeMember_UserNotExist, e.Index, e.Operation)); } _logger.LogError(e, LogUnknownTimelineMemberOperationUserException); diff --git a/Timeline/Controllers/TokenController.cs b/Timeline/Controllers/TokenController.cs index 01f4778f..c360a109 100644 --- a/Timeline/Controllers/TokenController.cs +++ b/Timeline/Controllers/TokenController.cs @@ -10,31 +10,6 @@ using Timeline.Models.Http; using Timeline.Services; using static Timeline.Resources.Controllers.TokenController; -namespace Timeline -{ - public static partial class ErrorCodes - { - public static partial class Http - { - public static class Token // bbb = 001 - { - public static class Create // cc = 01 - { - public const int BadCredential = 10010101; - } - - public static class Verify // cc = 02 - { - public const int BadFormat = 10010201; - public const int UserNotExist = 10010202; - public const int OldVersion = 10010203; - public const int Expired = 10010204; - } - } - } - } -} - namespace Timeline.Controllers { [Route("token")] @@ -87,16 +62,12 @@ namespace Timeline.Controllers catch (UserNotExistException e) { LogFailure(LogUserNotExist, e); - return BadRequest(new CommonResponse( - ErrorCodes.Http.Token.Create.BadCredential, - ErrorBadCredential)); + return BadRequest(ErrorResponse.TokenController.Create_BadCredential()); } catch (BadPasswordException e) { LogFailure(LogBadPassword, e); - return BadRequest(new CommonResponse( - ErrorCodes.Http.Token.Create.BadCredential, - ErrorBadCredential)); + return BadRequest(ErrorResponse.TokenController.Create_BadCredential()); } } @@ -128,31 +99,28 @@ namespace Timeline.Controllers if (e.ErrorCode == JwtVerifyException.ErrorCodes.Expired) { var innerException = e.InnerException as SecurityTokenExpiredException; - LogFailure(LogVerifyExpire, e, ("Expires", innerException?.Expires), + LogFailure(LogVerifyExpire, e, ("Expires", innerException.Expires), ("Current Time", _clock.GetCurrentTime())); - return BadRequest(new CommonResponse( - ErrorCodes.Http.Token.Verify.Expired, ErrorVerifyExpire)); + return BadRequest(ErrorResponse.TokenController.Verify_TimeExpired()); } else if (e.ErrorCode == JwtVerifyException.ErrorCodes.OldVersion) { var innerException = e.InnerException as JwtBadVersionException; LogFailure(LogVerifyOldVersion, e, - ("Token Version", innerException?.TokenVersion), ("Required Version", innerException?.RequiredVersion)); - return BadRequest(new CommonResponse( - ErrorCodes.Http.Token.Verify.OldVersion, ErrorVerifyOldVersion)); + ("Token Version", innerException.TokenVersion), + ("Required Version", innerException?.RequiredVersion)); + return BadRequest(ErrorResponse.TokenController.Verify_OldVersion()); } else { LogFailure(LogVerifyBadFormat, e); - return BadRequest(new CommonResponse( - ErrorCodes.Http.Token.Verify.BadFormat, ErrorVerifyBadFormat)); + return BadRequest(ErrorResponse.TokenController.Verify_BadFormat()); } } catch (UserNotExistException e) { LogFailure(LogVerifyUserNotExist, e); - return BadRequest(new CommonResponse( - ErrorCodes.Http.Token.Verify.UserNotExist, ErrorVerifyUserNotExist)); + return BadRequest(ErrorResponse.TokenController.Verify_UserNotExist()); } } } diff --git a/Timeline/Controllers/UserAvatarController.cs b/Timeline/Controllers/UserAvatarController.cs index 7625f962..b4a6d8fd 100644 --- a/Timeline/Controllers/UserAvatarController.cs +++ b/Timeline/Controllers/UserAvatarController.cs @@ -14,39 +14,6 @@ using Timeline.Models.Validation; using Timeline.Services; using static Timeline.Resources.Controllers.UserAvatarController; -namespace Timeline -{ - public static partial class ErrorCodes - { - public static partial class Http - { - public static class UserAvatar // bbb = 003 - { - public static class Get // cc = 01 - { - public const int UserNotExist = 10030101; - } - - public static class Put // cc = 02 - { - public const int UserNotExist = 10030201; - public const int Forbid = 10030202; - public const int BadFormat_CantDecode = 10030203; - public const int BadFormat_UnmatchedFormat = 10030204; - public const int BadFormat_BadSize = 10030205; - - } - - public static class Delete // cc = 03 - { - public const int UserNotExist = 10030301; - public const int Forbid = 10030302; - } - } - } - } -} - namespace Timeline.Controllers { [ApiController] @@ -79,7 +46,7 @@ namespace Timeline.Controllers { _logger.LogInformation(Log.Format(LogGetBadIfNoneMatch, ("Username", username), ("If-None-Match", value))); - return BadRequest(HeaderErrorResponse.BadIfNonMatch()); + return BadRequest(ErrorResponse.Common.Header.IfNonMatch_BadFormat()); } if (eTagList.FirstOrDefault(e => e.Equals(eTag)) != null) @@ -99,7 +66,7 @@ namespace Timeline.Controllers catch (UserNotExistException e) { _logger.LogInformation(e, Log.Format(LogGetUserNotExist, ("Username", username))); - return NotFound(new CommonResponse(ErrorCodes.Http.UserAvatar.Get.UserNotExist, ErrorGetUserNotExist)); + return NotFound(ErrorResponse.UserController.ChangePassword_BadOldPassword()); } } @@ -111,14 +78,13 @@ namespace Timeline.Controllers { var contentLength = Request.ContentLength!.Value; if (contentLength > 1000 * 1000 * 10) - return BadRequest(ContentErrorResponse.TooBig("10MB")); + return BadRequest(ErrorResponse.Common.Content.TooBig("10MB")); if (!User.IsAdministrator() && User.Identity.Name != username) { _logger.LogInformation(Log.Format(LogPutForbid, ("Operator Username", User.Identity.Name), ("Username To Put Avatar", username))); - return StatusCode(StatusCodes.Status403Forbidden, - new CommonResponse(ErrorCodes.Http.UserAvatar.Put.Forbid, ErrorPutForbid)); + return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid()); } try @@ -127,11 +93,11 @@ namespace Timeline.Controllers var bytesRead = await Request.Body.ReadAsync(data); if (bytesRead != contentLength) - return BadRequest(ContentErrorResponse.UnmatchedLength_Smaller()); + return BadRequest(ErrorResponse.Common.Content.UnmatchedLength_Smaller()); var extraByte = new byte[1]; if (await Request.Body.ReadAsync(extraByte) != 0) - return BadRequest(ContentErrorResponse.UnmatchedLength_Bigger()); + return BadRequest(ErrorResponse.Common.Content.UnmatchedLength_Bigger()); await _service.SetAvatar(username, new Avatar { @@ -146,24 +112,19 @@ namespace Timeline.Controllers catch (UserNotExistException e) { _logger.LogInformation(e, Log.Format(LogPutUserNotExist, ("Username", username))); - return BadRequest(new CommonResponse(ErrorCodes.Http.UserAvatar.Put.UserNotExist, ErrorPutUserNotExist)); + return BadRequest(ErrorResponse.UserController.ChangePassword_BadOldPassword()); } catch (AvatarFormatException e) { - var (code, message) = e.Error switch + _logger.LogInformation(e, Log.Format(LogPutUserBadFormat, ("Username", username))); + return BadRequest(e.Error switch { - AvatarFormatException.ErrorReason.CantDecode => - (ErrorCodes.Http.UserAvatar.Put.BadFormat_CantDecode, ErrorPutBadFormatCantDecode), - AvatarFormatException.ErrorReason.UnmatchedFormat => - (ErrorCodes.Http.UserAvatar.Put.BadFormat_UnmatchedFormat, ErrorPutBadFormatUnmatchedFormat), - AvatarFormatException.ErrorReason.BadSize => - (ErrorCodes.Http.UserAvatar.Put.BadFormat_BadSize, ErrorPutBadFormatBadSize), + AvatarFormatException.ErrorReason.CantDecode => ErrorResponse.UserAvatar.BadFormat_CantDecode(), + AvatarFormatException.ErrorReason.UnmatchedFormat => ErrorResponse.UserAvatar.BadFormat_UnmatchedFormat(), + AvatarFormatException.ErrorReason.BadSize => ErrorResponse.UserAvatar.BadFormat_BadSize(), _ => throw new Exception(ExceptionUnknownAvatarFormatError) - }; - - _logger.LogInformation(e, Log.Format(LogPutUserBadFormat, ("Username", username))); - return BadRequest(new CommonResponse(code, message)); + }); } } @@ -173,23 +134,20 @@ namespace Timeline.Controllers { if (!User.IsAdministrator() && User.Identity.Name != username) { - _logger.LogInformation(Log.Format(LogPutUserBadFormat, + _logger.LogInformation(Log.Format(LogDeleteForbid, ("Operator Username", User.Identity.Name), ("Username To Delete Avatar", username))); - return StatusCode(StatusCodes.Status403Forbidden, - new CommonResponse(ErrorCodes.Http.UserAvatar.Delete.Forbid, ErrorDeleteForbid)); + return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid()); } try { await _service.SetAvatar(username, null); - - _logger.LogInformation(Log.Format(LogDeleteSuccess, ("Username", username))); return Ok(); } catch (UserNotExistException e) { _logger.LogInformation(e, Log.Format(LogDeleteNotExist, ("Username", username))); - return BadRequest(new CommonResponse(ErrorCodes.Http.UserAvatar.Delete.UserNotExist, ErrorDeleteUserNotExist)); + return BadRequest(ErrorResponse.UserCommon.NotExist()); } } } diff --git a/Timeline/Controllers/UserController.cs b/Timeline/Controllers/UserController.cs index 0d950cd7..956865dc 100644 --- a/Timeline/Controllers/UserController.cs +++ b/Timeline/Controllers/UserController.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; -using System.Globalization; +using System; using System.Threading.Tasks; using Timeline.Auth; using Timeline.Helpers; @@ -11,43 +11,6 @@ using Timeline.Models.Validation; using Timeline.Services; using static Timeline.Resources.Controllers.UserController; -namespace Timeline -{ - public static partial class ErrorCodes - { - public static partial class Http - { - public static class User // bbb = 002 - { - public static class Get // cc = 01 - { - public const int NotExist = 10020101; // dd = 01 - } - - public static class Patch // cc = 03 - { - public const int NotExist = 10020301; // dd = 01 - } - - public static class Op // cc = 1x - { - public static class ChangeUsername // cc = 11 - { - public const int NotExist = 10021101; // dd = 01 - public const int AlreadyExist = 10021102; // dd = 02 - } - - public static class ChangePassword // cc = 12 - { - public const int BadOldPassword = 10021201; // dd = 01 - } - } - - } - } - } -} - namespace Timeline.Controllers { [ApiController] @@ -76,7 +39,7 @@ namespace Timeline.Controllers if (user == null) { _logger.LogInformation(Log.Format(LogGetUserNotExist, ("Username", username))); - return NotFound(new CommonResponse(ErrorCodes.Http.User.Get.NotExist, ErrorGetUserNotExist)); + return NotFound(ErrorResponse.UserCommon.NotExist()); } return Ok(user); } @@ -88,13 +51,11 @@ namespace Timeline.Controllers switch (result) { case PutResult.Create: - _logger.LogInformation(Log.Format(LogPutCreate, ("Username", username))); return CreatedAtAction("Get", new { username }, CommonPutResponse.Create()); case PutResult.Modify: - _logger.LogInformation(Log.Format(LogPutModify, ("Username", username))); return Ok(CommonPutResponse.Modify()); default: - throw new InvalidBranchException(); + throw new Exception(ExceptionUnknownPutResult); } } @@ -109,7 +70,7 @@ namespace Timeline.Controllers catch (UserNotExistException e) { _logger.LogInformation(e, Log.Format(LogPatchUserNotExist, ("Username", username))); - return NotFound(new CommonResponse(ErrorCodes.Http.User.Patch.NotExist, ErrorPatchUserNotExist)); + return NotFound(ErrorResponse.UserCommon.NotExist()); } } @@ -119,12 +80,10 @@ namespace Timeline.Controllers try { await _userService.DeleteUser(username); - _logger.LogInformation(Log.Format(LogDeleteDelete, ("Username", username))); return Ok(CommonDeleteResponse.Delete()); } - catch (UserNotExistException e) + catch (UserNotExistException) { - _logger.LogInformation(e, Log.Format(LogDeleteNotExist, ("Username", username))); return Ok(CommonDeleteResponse.NotExist()); } } @@ -135,22 +94,19 @@ namespace Timeline.Controllers try { await _userService.ChangeUsername(request.OldUsername, request.NewUsername); - _logger.LogInformation(Log.Format(LogChangeUsernameSuccess, - ("Old Username", request.OldUsername), ("New Username", request.NewUsername))); return Ok(); } catch (UserNotExistException e) { _logger.LogInformation(e, Log.Format(LogChangeUsernameNotExist, ("Old Username", request.OldUsername), ("New Username", request.NewUsername))); - return BadRequest(new CommonResponse(ErrorCodes.Http.User.Op.ChangeUsername.NotExist, - string.Format(CultureInfo.CurrentCulture, ErrorChangeUsernameNotExist, request.OldUsername))); + return BadRequest(ErrorResponse.UserCommon.NotExist()); } catch (UsernameConfictException e) { - _logger.LogInformation(e, Log.Format(LogChangeUsernameAlreadyExist, + _logger.LogInformation(e, Log.Format(LogChangeUsernameConflict, ("Old Username", request.OldUsername), ("New Username", request.NewUsername))); - return BadRequest(new CommonResponse(ErrorCodes.Http.User.Op.ChangeUsername.AlreadyExist, ErrorChangeUsernameAlreadyExist)); + return BadRequest(ErrorResponse.UserController.ChangeUsername_Conflict()); } // there is no need to catch bad format exception because it is already checked in model validation. } @@ -161,15 +117,13 @@ namespace Timeline.Controllers try { await _userService.ChangePassword(User.Identity.Name!, request.OldPassword, request.NewPassword); - _logger.LogInformation(Log.Format(LogChangePasswordSuccess, ("Username", User.Identity.Name))); return Ok(); } catch (BadPasswordException e) { _logger.LogInformation(e, Log.Format(LogChangePasswordBadPassword, ("Username", User.Identity.Name), ("Old Password", request.OldPassword))); - return BadRequest(new CommonResponse(ErrorCodes.Http.User.Op.ChangePassword.BadOldPassword, - ErrorChangePasswordBadPassword)); + return BadRequest(ErrorResponse.UserController.ChangePassword_BadOldPassword()); } // User can't be non-existent or the token is bad. } diff --git a/Timeline/ErrorCodes.cs b/Timeline/ErrorCodes.cs deleted file mode 100644 index c246953b..00000000 --- a/Timeline/ErrorCodes.cs +++ /dev/null @@ -1,35 +0,0 @@ -namespace Timeline -{ - /// - /// All error code constants. - /// - /// - /// Scheme: - /// abbbccdd - /// - public static partial class ErrorCodes - { - public static partial class Http // a = 1 - { - public static class Common // bbb = 000 - { - public const int InvalidModel = 10000000; - - public static class Header // cc = 0x - { - public static class IfNonMatch // cc = 01 - { - public const int BadFormat = 10000101; - } - } - - public static class Content // cc = 11 - { - public const int TooBig = 10001101; - public const int UnmatchedLength_Smaller = 10001102; - public const int UnmatchedLength_Bigger = 10001103; - } - } - } - } -} diff --git a/Timeline/Filters/Header.cs b/Timeline/Filters/Header.cs index f5fb16aa..843a619d 100644 --- a/Timeline/Filters/Header.cs +++ b/Timeline/Filters/Header.cs @@ -1,72 +1,23 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using Timeline.Models.Http; -using static Timeline.Resources.Filters; - -namespace Timeline -{ - public static partial class ErrorCodes - { - public static partial class Http - { - public static partial class Filter // bxx = 1xx - { - public static partial class Header // bbb = 100 - { - public static class ContentType // cc = 01 - { - public const int Missing = 11000101; // dd = 01 - } - - public static class ContentLength // cc = 02 - { - public const int Missing = 11000201; // dd = 01 - public const int Zero = 11000202; // dd = 02 - } - } - } - - } - } -} namespace Timeline.Filters { public class RequireContentTypeAttribute : ActionFilterAttribute { - internal static CommonResponse CreateResponse() - { - return new CommonResponse( - ErrorCodes.Http.Filter.Header.ContentType.Missing, - MessageHeaderContentTypeMissing); - } - [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods")] public override void OnActionExecuting(ActionExecutingContext context) { if (context.HttpContext.Request.ContentType == null) { - context.Result = new BadRequestObjectResult(CreateResponse()); + context.Result = new BadRequestObjectResult(ErrorResponse.Common.Header.ContentType_Missing()); } } } public class RequireContentLengthAttribute : ActionFilterAttribute { - internal static CommonResponse CreateMissingResponse() - { - return new CommonResponse( - ErrorCodes.Http.Filter.Header.ContentLength.Missing, - MessageHeaderContentLengthMissing); - } - - internal static CommonResponse CreateZeroResponse() - { - return new CommonResponse( - ErrorCodes.Http.Filter.Header.ContentLength.Zero, - MessageHeaderContentLengthZero); - } - public RequireContentLengthAttribute() : this(true) { @@ -85,13 +36,13 @@ namespace Timeline.Filters { if (context.HttpContext.Request.ContentLength == null) { - context.Result = new BadRequestObjectResult(CreateMissingResponse()); + context.Result = new BadRequestObjectResult(ErrorResponse.Common.Header.ContentLength_Missing()); return; } if (RequireNonZero && context.HttpContext.Request.ContentLength.Value == 0) { - context.Result = new BadRequestObjectResult(CreateZeroResponse()); + context.Result = new BadRequestObjectResult(ErrorResponse.Common.Header.ContentLength_Zero()); return; } } diff --git a/Timeline/Filters/Timeline.cs b/Timeline/Filters/Timeline.cs index 7859d409..bc142db0 100644 --- a/Timeline/Filters/Timeline.cs +++ b/Timeline/Filters/Timeline.cs @@ -2,25 +2,6 @@ using Microsoft.AspNetCore.Mvc.Filters; using Timeline.Models.Http; using Timeline.Services; -using static Timeline.Resources.Filters; - -namespace Timeline -{ - public static partial class ErrorCodes - { - public static partial class Http - { - public static partial class Filter // bxx = 1xx - { - public static class Timeline // bbb = 102 - { - public const int UserNotExist = 11020101; - public const int NameNotExist = 11020102; - } - } - } - } -} namespace Timeline.Filters { @@ -33,13 +14,11 @@ namespace Timeline.Filters { if (e.InnerException is UserNotExistException) { - context.Result = new BadRequestObjectResult( - new CommonResponse(ErrorCodes.Http.Filter.Timeline.UserNotExist, MessageTimelineNotExistUser)); + context.Result = new BadRequestObjectResult(ErrorResponse.UserCommon.NotExist()); } else { - context.Result = new BadRequestObjectResult( - new CommonResponse(ErrorCodes.Http.Filter.Timeline.NameNotExist, MessageTimelineNotExist)); + throw new System.NotImplementedException(); } } } diff --git a/Timeline/Filters/User.cs b/Timeline/Filters/User.cs index 16c76750..12ed6155 100644 --- a/Timeline/Filters/User.cs +++ b/Timeline/Filters/User.cs @@ -9,25 +9,6 @@ using Timeline.Models.Http; using Timeline.Services; using static Timeline.Resources.Filters; -namespace Timeline -{ - public static partial class ErrorCodes - { - public static partial class Http - { - public static partial class Filter // bxx = 1xx - { - public static class User // bbb = 101 - { - public const int NotExist = 11010101; - - public const int NotSelfOrAdminForbid = 11010201; - } - } - } - } -} - namespace Timeline.Filters { public class SelfOrAdminAttribute : ActionFilterAttribute @@ -51,8 +32,7 @@ namespace Timeline.Filters { if (!user.IsAdministrator() && user.Identity.Name != username) { - context.Result = new ObjectResult( - new CommonResponse(ErrorCodes.Http.Filter.User.NotSelfOrAdminForbid, MessageSelfOrAdminForbid)) + context.Result = new ObjectResult(ErrorResponse.Common.Forbid()) { StatusCode = StatusCodes.Status403Forbidden }; } } @@ -76,7 +56,7 @@ namespace Timeline.Filters { if (context.Exception is UserNotExistException) { - var body = new CommonResponse(ErrorCodes.Http.Filter.User.NotExist, MessageUserNotExist); + var body = ErrorResponse.UserCommon.NotExist(); if (context.HttpContext.Request.Method == "GET") context.Result = new NotFoundObjectResult(body); diff --git a/Timeline/Helpers/InvalidModelResponseFactory.cs b/Timeline/Helpers/InvalidModelResponseFactory.cs index 643c99ac..71ee44a9 100644 --- a/Timeline/Helpers/InvalidModelResponseFactory.cs +++ b/Timeline/Helpers/InvalidModelResponseFactory.cs @@ -20,7 +20,7 @@ namespace Timeline.Helpers messageBuilder.AppendLine(error.ErrorMessage); } - return new BadRequestObjectResult(CommonResponse.InvalidModel(messageBuilder.ToString())); + return new BadRequestObjectResult(ErrorResponse.Common.CustomMessage_InvalidModel(messageBuilder.ToString())); } } } diff --git a/Timeline/InvalidBranchException.cs b/Timeline/InvalidBranchException.cs deleted file mode 100644 index 32937c5d..00000000 --- a/Timeline/InvalidBranchException.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace Timeline -{ - - [Serializable] - public class InvalidBranchException : Exception - { - public InvalidBranchException() : base(Resources.Common.ExceptionInvalidBranch) { } - public InvalidBranchException(string message) : base(message) { } - public InvalidBranchException(string message, Exception inner) : base(message, inner) { } - protected InvalidBranchException( - System.Runtime.Serialization.SerializationInfo info, - System.Runtime.Serialization.StreamingContext context) : base(info, context) { } - } -} diff --git a/Timeline/Models/Http/Common.cs b/Timeline/Models/Http/Common.cs index d1e95397..a9fc8a79 100644 --- a/Timeline/Models/Http/Common.cs +++ b/Timeline/Models/Http/Common.cs @@ -1,15 +1,9 @@ -using System.Globalization; using static Timeline.Resources.Models.Http.Common; namespace Timeline.Models.Http { public class CommonResponse { - internal static CommonResponse InvalidModel(string message) - { - return new CommonResponse(ErrorCodes.Http.Common.InvalidModel, message); - } - public CommonResponse() { @@ -25,33 +19,6 @@ namespace Timeline.Models.Http public string? Message { get; set; } } - internal static class HeaderErrorResponse - { - internal static CommonResponse BadIfNonMatch() - { - return new CommonResponse(ErrorCodes.Http.Common.Header.IfNonMatch.BadFormat, MessageHeaderIfNonMatchBad); - } - } - - internal static class ContentErrorResponse - { - internal static CommonResponse TooBig(string maxLength) - { - return new CommonResponse(ErrorCodes.Http.Common.Content.TooBig, - string.Format(CultureInfo.CurrentCulture, MessageContentTooBig, maxLength)); - } - - internal static CommonResponse UnmatchedLength_Smaller() - { - return new CommonResponse(ErrorCodes.Http.Common.Content.UnmatchedLength_Smaller, MessageContentUnmatchedLengthSmaller); - } - internal static CommonResponse UnmatchedLength_Bigger() - { - return new CommonResponse(ErrorCodes.Http.Common.Content.UnmatchedLength_Bigger, MessageContentUnmatchedLengthBigger); - } - } - - public class CommonDataResponse : CommonResponse { public CommonDataResponse() diff --git a/Timeline/Models/Http/ErrorResponse.cs b/Timeline/Models/Http/ErrorResponse.cs new file mode 100644 index 00000000..6a53e0c3 --- /dev/null +++ b/Timeline/Models/Http/ErrorResponse.cs @@ -0,0 +1,261 @@ +using static Timeline.Resources.Messages; + +namespace Timeline.Models.Http +{ + + public static class ErrorResponse + { + + public static class Common + { + + public static CommonResponse InvalidModel(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.InvalidModel, string.Format(Common_InvalidModel, formatArgs)); + } + + public static CommonResponse CustomMessage_InvalidModel(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.InvalidModel, string.Format(message, formatArgs)); + } + + public static CommonResponse Forbid(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.Forbid, string.Format(Common_Forbid, formatArgs)); + } + + public static CommonResponse CustomMessage_Forbid(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.Forbid, string.Format(message, formatArgs)); + } + + public static class Header + { + + public static CommonResponse IfNonMatch_BadFormat(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.Header.IfNonMatch_BadFormat, string.Format(Common_Header_IfNonMatch_BadFormat, formatArgs)); + } + + public static CommonResponse CustomMessage_IfNonMatch_BadFormat(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.Header.IfNonMatch_BadFormat, string.Format(message, formatArgs)); + } + + public static CommonResponse ContentType_Missing(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.Header.ContentType_Missing, string.Format(Common_Header_ContentType_Missing, formatArgs)); + } + + public static CommonResponse CustomMessage_ContentType_Missing(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.Header.ContentType_Missing, string.Format(message, formatArgs)); + } + + public static CommonResponse ContentLength_Missing(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.Header.ContentLength_Missing, string.Format(Common_Header_ContentLength_Missing, formatArgs)); + } + + public static CommonResponse CustomMessage_ContentLength_Missing(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.Header.ContentLength_Missing, string.Format(message, formatArgs)); + } + + public static CommonResponse ContentLength_Zero(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.Header.ContentLength_Zero, string.Format(Common_Header_ContentLength_Zero, formatArgs)); + } + + public static CommonResponse CustomMessage_ContentLength_Zero(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.Header.ContentLength_Zero, string.Format(message, formatArgs)); + } + + } + + public static class Content + { + + public static CommonResponse TooBig(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.Content.TooBig, string.Format(Common_Content_TooBig, formatArgs)); + } + + public static CommonResponse CustomMessage_TooBig(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.Content.TooBig, string.Format(message, formatArgs)); + } + + public static CommonResponse UnmatchedLength_Smaller(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.Content.UnmatchedLength_Smaller, string.Format(Common_Content_UnmatchedLength_Smaller, formatArgs)); + } + + public static CommonResponse CustomMessage_UnmatchedLength_Smaller(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.Content.UnmatchedLength_Smaller, string.Format(message, formatArgs)); + } + + public static CommonResponse UnmatchedLength_Bigger(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.Content.UnmatchedLength_Bigger, string.Format(Common_Content_UnmatchedLength_Bigger, formatArgs)); + } + + public static CommonResponse CustomMessage_UnmatchedLength_Bigger(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.Common.Content.UnmatchedLength_Bigger, string.Format(message, formatArgs)); + } + + } + + } + + public static class UserCommon + { + + public static CommonResponse NotExist(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.UserCommon.NotExist, string.Format(UserCommon_NotExist, formatArgs)); + } + + public static CommonResponse CustomMessage_NotExist(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.UserCommon.NotExist, string.Format(message, formatArgs)); + } + + } + + public static class TokenController + { + + public static CommonResponse Create_BadCredential(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.TokenController.Create_BadCredential, string.Format(TokenController_Create_BadCredential, formatArgs)); + } + + public static CommonResponse CustomMessage_Create_BadCredential(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.TokenController.Create_BadCredential, string.Format(message, formatArgs)); + } + + public static CommonResponse Verify_BadFormat(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.TokenController.Verify_BadFormat, string.Format(TokenController_Verify_BadFormat, formatArgs)); + } + + public static CommonResponse CustomMessage_Verify_BadFormat(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.TokenController.Verify_BadFormat, string.Format(message, formatArgs)); + } + + public static CommonResponse Verify_UserNotExist(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.TokenController.Verify_UserNotExist, string.Format(TokenController_Verify_UserNotExist, formatArgs)); + } + + public static CommonResponse CustomMessage_Verify_UserNotExist(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.TokenController.Verify_UserNotExist, string.Format(message, formatArgs)); + } + + public static CommonResponse Verify_OldVersion(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.TokenController.Verify_OldVersion, string.Format(TokenController_Verify_OldVersion, formatArgs)); + } + + public static CommonResponse CustomMessage_Verify_OldVersion(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.TokenController.Verify_OldVersion, string.Format(message, formatArgs)); + } + + public static CommonResponse Verify_TimeExpired(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.TokenController.Verify_TimeExpired, string.Format(TokenController_Verify_TimeExpired, formatArgs)); + } + + public static CommonResponse CustomMessage_Verify_TimeExpired(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.TokenController.Verify_TimeExpired, string.Format(message, formatArgs)); + } + + } + + public static class UserController + { + + public static CommonResponse ChangeUsername_Conflict(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.UserController.ChangeUsername_Conflict, string.Format(UserController_ChangeUsername_Conflict, formatArgs)); + } + + public static CommonResponse CustomMessage_ChangeUsername_Conflict(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.UserController.ChangeUsername_Conflict, string.Format(message, formatArgs)); + } + + public static CommonResponse ChangePassword_BadOldPassword(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.UserController.ChangePassword_BadOldPassword, string.Format(UserController_ChangePassword_BadOldPassword, formatArgs)); + } + + public static CommonResponse CustomMessage_ChangePassword_BadOldPassword(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.UserController.ChangePassword_BadOldPassword, string.Format(message, formatArgs)); + } + + } + + public static class UserAvatar + { + + public static CommonResponse BadFormat_CantDecode(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_CantDecode, string.Format(UserAvatar_BadFormat_CantDecode, formatArgs)); + } + + public static CommonResponse CustomMessage_BadFormat_CantDecode(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_CantDecode, string.Format(message, formatArgs)); + } + + public static CommonResponse BadFormat_UnmatchedFormat(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_UnmatchedFormat, string.Format(UserAvatar_BadFormat_UnmatchedFormat, formatArgs)); + } + + public static CommonResponse CustomMessage_BadFormat_UnmatchedFormat(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_UnmatchedFormat, string.Format(message, formatArgs)); + } + + public static CommonResponse BadFormat_BadSize(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_BadSize, string.Format(UserAvatar_BadFormat_BadSize, formatArgs)); + } + + public static CommonResponse CustomMessage_BadFormat_BadSize(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_BadSize, string.Format(message, formatArgs)); + } + + } + + public static class TimelineController + { + + public static CommonResponse PostOperationDelete_NotExist(params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.TimelineController.PostOperationDelete_NotExist, string.Format(TimelineController_PostOperationDelete_NotExist, formatArgs)); + } + + public static CommonResponse CustomMessage_PostOperationDelete_NotExist(string message, params object?[] formatArgs) + { + return new CommonResponse(ErrorCodes.TimelineController.PostOperationDelete_NotExist, string.Format(message, formatArgs)); + } + + } + + } + +} diff --git a/Timeline/Models/Http/Timeline.cs b/Timeline/Models/Http/Timeline.cs index 06b88ad1..3029434e 100644 --- a/Timeline/Models/Http/Timeline.cs +++ b/Timeline/Models/Http/Timeline.cs @@ -1,9 +1,6 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Threading.Tasks; -using Timeline.Entities; namespace Timeline.Models.Http { diff --git a/Timeline/Resources/Common.Designer.cs b/Timeline/Resources/Common.Designer.cs deleted file mode 100644 index 4f1c8e3f..00000000 --- a/Timeline/Resources/Common.Designer.cs +++ /dev/null @@ -1,72 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Timeline.Resources { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Common { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Common() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Common", typeof(Common).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to The branch is invalid. Normally this branch is not reachable.. - /// - internal static string ExceptionInvalidBranch { - get { - return ResourceManager.GetString("ExceptionInvalidBranch", resourceCulture); - } - } - } -} diff --git a/Timeline/Resources/Common.resx b/Timeline/Resources/Common.resx deleted file mode 100644 index 8a036996..00000000 --- a/Timeline/Resources/Common.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - The branch is invalid. Normally this branch is not reachable. - - \ No newline at end of file diff --git a/Timeline/Resources/Controllers/TimelineController.Designer.cs b/Timeline/Resources/Controllers/TimelineController.Designer.cs index 47c43fa2..ae6414e6 100644 --- a/Timeline/Resources/Controllers/TimelineController.Designer.cs +++ b/Timeline/Resources/Controllers/TimelineController.Designer.cs @@ -77,59 +77,5 @@ namespace Timeline.Resources.Controllers { return ResourceManager.GetString("LogUnknownTimelineMemberOperationUserException", resourceCulture); } } - - /// - /// Looks up a localized string similar to The {0}-st username to do operation {1} on is of bad format.. - /// - internal static string MessageMemberUsernameBadFormat { - get { - return ResourceManager.GetString("MessageMemberUsernameBadFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The {0}-st user to do operation {1} on does not exist.. - /// - internal static string MessageMemberUserNotExist { - get { - return ResourceManager.GetString("MessageMemberUserNotExist", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to You have no permission to read posts of the timeline.. - /// - internal static string MessagePostListGetForbid { - get { - return ResourceManager.GetString("MessagePostListGetForbid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to You have no permission to create posts in the timeline.. - /// - internal static string MessagePostOperationCreateForbid { - get { - return ResourceManager.GetString("MessagePostOperationCreateForbid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to You have no permission to delete posts in the timeline.. - /// - internal static string MessagePostOperationDeleteForbid { - get { - return ResourceManager.GetString("MessagePostOperationDeleteForbid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The post to delete does not exist.. - /// - internal static string MessagePostOperationDeleteNotExist { - get { - return ResourceManager.GetString("MessagePostOperationDeleteNotExist", resourceCulture); - } - } } } diff --git a/Timeline/Resources/Controllers/TimelineController.resx b/Timeline/Resources/Controllers/TimelineController.resx index 0cf7e881..4cf3d6fb 100644 --- a/Timeline/Resources/Controllers/TimelineController.resx +++ b/Timeline/Resources/Controllers/TimelineController.resx @@ -123,22 +123,4 @@ An unknown TimelineMemberOperationUserException is thrown. Can't recognize its inner exception. It is rethrown. - - The {0}-st username to do operation {1} on is of bad format. - - - The {0}-st user to do operation {1} on does not exist. - - - You have no permission to read posts of the timeline. - - - You have no permission to create posts in the timeline. - - - You have no permission to delete posts in the timeline. - - - The post to delete does not exist. - \ No newline at end of file diff --git a/Timeline/Resources/Controllers/TimelineController.zh.resx b/Timeline/Resources/Controllers/TimelineController.zh.resx deleted file mode 100644 index 170ab4cd..00000000 --- a/Timeline/Resources/Controllers/TimelineController.zh.resx +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 第{0}个做{1}操作的用户名格式错误。 - - - 第{0}个做{1}操作的用户不存在。 - - - 你没有权限读取这个时间线消息。 - - - 你没有权限在这个时间线中创建消息。 - - - 你没有权限在这个时间线中删除消息。 - - - 要删除的消息不存在。 - - \ No newline at end of file diff --git a/Timeline/Resources/Controllers/TokenController.Designer.cs b/Timeline/Resources/Controllers/TokenController.Designer.cs index 22e6a8be..a7c2864b 100644 --- a/Timeline/Resources/Controllers/TokenController.Designer.cs +++ b/Timeline/Resources/Controllers/TokenController.Designer.cs @@ -60,51 +60,6 @@ namespace Timeline.Resources.Controllers { } } - /// - /// Looks up a localized string similar to Username or password is invalid.. - /// - internal static string ErrorBadCredential { - get { - return ResourceManager.GetString("ErrorBadCredential", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The token is of bad format. It might not be created by the server.. - /// - internal static string ErrorVerifyBadFormat { - get { - return ResourceManager.GetString("ErrorVerifyBadFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The token is expired.. - /// - internal static string ErrorVerifyExpire { - get { - return ResourceManager.GetString("ErrorVerifyExpire", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Token has an old version. User might have update some info.. - /// - internal static string ErrorVerifyOldVersion { - get { - return ResourceManager.GetString("ErrorVerifyOldVersion", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to User does not exist. Administrator might have deleted this user.. - /// - internal static string ErrorVerifyUserNotExist { - get { - return ResourceManager.GetString("ErrorVerifyUserNotExist", resourceCulture); - } - } - /// /// Looks up a localized string similar to The password is wrong.. /// diff --git a/Timeline/Resources/Controllers/TokenController.resx b/Timeline/Resources/Controllers/TokenController.resx index 42e1ff92..683d6cc9 100644 --- a/Timeline/Resources/Controllers/TokenController.resx +++ b/Timeline/Resources/Controllers/TokenController.resx @@ -117,21 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Username or password is invalid. - - - The token is of bad format. It might not be created by the server. - - - The token is expired. - - - Token has an old version. User might have update some info. - - - User does not exist. Administrator might have deleted this user. - The password is wrong. diff --git a/Timeline/Resources/Controllers/TokenController.zh.resx b/Timeline/Resources/Controllers/TokenController.zh.resx deleted file mode 100644 index 51e0f25b..00000000 --- a/Timeline/Resources/Controllers/TokenController.zh.resx +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 用户名或密码错误。 - - - 符号格式错误。这个符号可能不是这个服务器创建的。 - - - 符号过期了。 - - - 符号是一个旧版本。用户可能已经更新了信息。 - - - 用户不存在。管理员可能已经删除了这个用户。 - - \ No newline at end of file diff --git a/Timeline/Resources/Controllers/UserAvatarController.Designer.cs b/Timeline/Resources/Controllers/UserAvatarController.Designer.cs index 1dacb19f..e6eeb1e8 100644 --- a/Timeline/Resources/Controllers/UserAvatarController.Designer.cs +++ b/Timeline/Resources/Controllers/UserAvatarController.Designer.cs @@ -60,78 +60,6 @@ namespace Timeline.Resources.Controllers { } } - /// - /// Looks up a localized string similar to Normal user can't delete other's avatar.. - /// - internal static string ErrorDeleteForbid { - get { - return ResourceManager.GetString("ErrorDeleteForbid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to User does not exist.. - /// - internal static string ErrorDeleteUserNotExist { - get { - return ResourceManager.GetString("ErrorDeleteUserNotExist", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to User does not exist.. - /// - internal static string ErrorGetUserNotExist { - get { - return ResourceManager.GetString("ErrorGetUserNotExist", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Image is not a square.. - /// - internal static string ErrorPutBadFormatBadSize { - get { - return ResourceManager.GetString("ErrorPutBadFormatBadSize", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Decoding image failed.. - /// - internal static string ErrorPutBadFormatCantDecode { - get { - return ResourceManager.GetString("ErrorPutBadFormatCantDecode", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Image format is not the one in header.. - /// - internal static string ErrorPutBadFormatUnmatchedFormat { - get { - return ResourceManager.GetString("ErrorPutBadFormatUnmatchedFormat", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Normal user can't change other's avatar.. - /// - internal static string ErrorPutForbid { - get { - return ResourceManager.GetString("ErrorPutForbid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to User does not exist.. - /// - internal static string ErrorPutUserNotExist { - get { - return ResourceManager.GetString("ErrorPutUserNotExist", resourceCulture); - } - } - /// /// Looks up a localized string similar to Unknown AvatarDataException.ErrorReason value.. /// diff --git a/Timeline/Resources/Controllers/UserAvatarController.resx b/Timeline/Resources/Controllers/UserAvatarController.resx index 3f444b04..58860c83 100644 --- a/Timeline/Resources/Controllers/UserAvatarController.resx +++ b/Timeline/Resources/Controllers/UserAvatarController.resx @@ -117,30 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Normal user can't delete other's avatar. - - - User does not exist. - - - User does not exist. - - - Image is not a square. - - - Decoding image failed. - - - Image format is not the one in header. - - - Normal user can't change other's avatar. - - - User does not exist. - Unknown AvatarDataException.ErrorReason value. diff --git a/Timeline/Resources/Controllers/UserAvatarController.zh.resx b/Timeline/Resources/Controllers/UserAvatarController.zh.resx deleted file mode 100644 index 94de1606..00000000 --- a/Timeline/Resources/Controllers/UserAvatarController.zh.resx +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 普通用户不能删除其他用户的头像。 - - - 用户不存在。 - - - 用户不存在。 - - - 图片不是正方形。 - - - 解码图片失败。 - - - 图片格式与请求头中指示的不一样。 - - - 普通用户不能修改其他用户的头像。 - - - 用户不存在。 - - \ No newline at end of file diff --git a/Timeline/Resources/Controllers/UserController.Designer.cs b/Timeline/Resources/Controllers/UserController.Designer.cs index 0c9ac0d7..c8067614 100644 --- a/Timeline/Resources/Controllers/UserController.Designer.cs +++ b/Timeline/Resources/Controllers/UserController.Designer.cs @@ -61,56 +61,11 @@ namespace Timeline.Resources.Controllers { } /// - /// Looks up a localized string similar to Old password is wrong.. + /// Looks up a localized string similar to Unknown PutResult.. /// - internal static string ErrorChangePasswordBadPassword { + internal static string ExceptionUnknownPutResult { get { - return ResourceManager.GetString("ErrorChangePasswordBadPassword", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The new username {0} already exists.. - /// - internal static string ErrorChangeUsernameAlreadyExist { - get { - return ResourceManager.GetString("ErrorChangeUsernameAlreadyExist", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The old username {0} does not exist.. - /// - internal static string ErrorChangeUsernameNotExist { - get { - return ResourceManager.GetString("ErrorChangeUsernameNotExist", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The user does not exist.. - /// - internal static string ErrorGetUserNotExist { - get { - return ResourceManager.GetString("ErrorGetUserNotExist", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Can't patch a user that does not exist.. - /// - internal static string ErrorPatchUserNotExist { - get { - return ResourceManager.GetString("ErrorPatchUserNotExist", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Username is of bad format.. - /// - internal static string ErrorPutBadUsername { - get { - return ResourceManager.GetString("ErrorPutBadUsername", resourceCulture); + return ResourceManager.GetString("ExceptionUnknownPutResult", resourceCulture); } } @@ -123,21 +78,12 @@ namespace Timeline.Resources.Controllers { } } - /// - /// Looks up a localized string similar to A user has changed password.. - /// - internal static string LogChangePasswordSuccess { - get { - return ResourceManager.GetString("LogChangePasswordSuccess", resourceCulture); - } - } - /// /// Looks up a localized string similar to Attempt to change a user's username to a existent one failed.. /// - internal static string LogChangeUsernameAlreadyExist { + internal static string LogChangeUsernameConflict { get { - return ResourceManager.GetString("LogChangeUsernameAlreadyExist", resourceCulture); + return ResourceManager.GetString("LogChangeUsernameConflict", resourceCulture); } } @@ -150,33 +96,6 @@ namespace Timeline.Resources.Controllers { } } - /// - /// Looks up a localized string similar to A user has changed username.. - /// - internal static string LogChangeUsernameSuccess { - get { - return ResourceManager.GetString("LogChangeUsernameSuccess", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A user has been deleted.. - /// - internal static string LogDeleteDelete { - get { - return ResourceManager.GetString("LogDeleteDelete", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Attempt to delete a user that does not exist.. - /// - internal static string LogDeleteNotExist { - get { - return ResourceManager.GetString("LogDeleteNotExist", resourceCulture); - } - } - /// /// Looks up a localized string similar to Attempt to retrieve info of a user that does not exist failed.. /// @@ -194,32 +113,5 @@ namespace Timeline.Resources.Controllers { return ResourceManager.GetString("LogPatchUserNotExist", resourceCulture); } } - - /// - /// Looks up a localized string similar to Attempt to create a user with bad username failed.. - /// - internal static string LogPutBadUsername { - get { - return ResourceManager.GetString("LogPutBadUsername", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A user has been created.. - /// - internal static string LogPutCreate { - get { - return ResourceManager.GetString("LogPutCreate", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A user has been modified.. - /// - internal static string LogPutModify { - get { - return ResourceManager.GetString("LogPutModify", resourceCulture); - } - } } } diff --git a/Timeline/Resources/Controllers/UserController.resx b/Timeline/Resources/Controllers/UserController.resx index 50aa13d6..0bdf4845 100644 --- a/Timeline/Resources/Controllers/UserController.resx +++ b/Timeline/Resources/Controllers/UserController.resx @@ -117,58 +117,22 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Old password is wrong. - - - The new username {0} already exists. - - - The old username {0} does not exist. - - - The user does not exist. - - - Can't patch a user that does not exist. - - - Username is of bad format. + + Unknown PutResult. Attempt to change password with wrong old password failed. - - A user has changed password. - - + Attempt to change a user's username to a existent one failed. Attempt to change a username of a user that does not exist failed. - - A user has changed username. - - - A user has been deleted. - - - Attempt to delete a user that does not exist. - Attempt to retrieve info of a user that does not exist failed. Attempt to patch a user that does not exist failed. - - Attempt to create a user with bad username failed. - - - A user has been created. - - - A user has been modified. - \ No newline at end of file diff --git a/Timeline/Resources/Controllers/UserController.zh.resx b/Timeline/Resources/Controllers/UserController.zh.resx deleted file mode 100644 index 3556083e..00000000 --- a/Timeline/Resources/Controllers/UserController.zh.resx +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 旧密码错误。 - - - 新用户名{0}已经存在。 - - - 旧用户名{0}不存在。 - - - 用户不存在。 - - - 不能修改一个不存在的用户。 - - - 用户名格式错误。 - - \ No newline at end of file diff --git a/Timeline/Resources/Filters.Designer.cs b/Timeline/Resources/Filters.Designer.cs index 5576190d..dedfe498 100644 --- a/Timeline/Resources/Filters.Designer.cs +++ b/Timeline/Resources/Filters.Designer.cs @@ -86,68 +86,5 @@ namespace Timeline.Resources { return ResourceManager.GetString("LogSelfOrAdminUsernameNotString", resourceCulture); } } - - /// - /// Looks up a localized string similar to Header Content-Length is missing or of bad format.. - /// - internal static string MessageHeaderContentLengthMissing { - get { - return ResourceManager.GetString("MessageHeaderContentLengthMissing", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Header Content-Length must not be 0.. - /// - internal static string MessageHeaderContentLengthZero { - get { - return ResourceManager.GetString("MessageHeaderContentLengthZero", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Header Content-Type is required.. - /// - internal static string MessageHeaderContentTypeMissing { - get { - return ResourceManager.GetString("MessageHeaderContentTypeMissing", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to You can't access the resource unless you are the owner or administrator.. - /// - internal static string MessageSelfOrAdminForbid { - get { - return ResourceManager.GetString("MessageSelfOrAdminForbid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The requested timeline does not exist.. - /// - internal static string MessageTimelineNotExist { - get { - return ResourceManager.GetString("MessageTimelineNotExist", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The requested personal timeline does not exist because the user does not exist.. - /// - internal static string MessageTimelineNotExistUser { - get { - return ResourceManager.GetString("MessageTimelineNotExistUser", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to The user does not exist.. - /// - internal static string MessageUserNotExist { - get { - return ResourceManager.GetString("MessageUserNotExist", resourceCulture); - } - } } } diff --git a/Timeline/Resources/Filters.resx b/Timeline/Resources/Filters.resx index 7bfbc703..22620889 100644 --- a/Timeline/Resources/Filters.resx +++ b/Timeline/Resources/Filters.resx @@ -126,25 +126,4 @@ You apply a SelfOrAdminAttribute on an action, found a model named username, but it is not string. - - Header Content-Length is missing or of bad format. - - - Header Content-Length must not be 0. - - - Header Content-Type is required. - - - You can't access the resource unless you are the owner or administrator. - - - The requested timeline does not exist. - - - The requested personal timeline does not exist because the user does not exist. - - - The user does not exist. - \ No newline at end of file diff --git a/Timeline/Resources/Filters.zh.resx b/Timeline/Resources/Filters.zh.resx deleted file mode 100644 index 36aac788..00000000 --- a/Timeline/Resources/Filters.zh.resx +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 请求头Content-Length缺失或者格式不对。 - - - 请求头Content-Length不能为0。 - - - 缺少必需的请求头Content-Type。 - - - 你无权访问该资源除非你是资源的拥有者或者管理员。 - - - 请求的时间线不存在。 - - - 请求的个人时间线不存在因为该用户不存在。 - - - 用户不存在。 - - \ No newline at end of file diff --git a/Timeline/Resources/Messages.Designer.cs b/Timeline/Resources/Messages.Designer.cs new file mode 100644 index 00000000..8c13374f --- /dev/null +++ b/Timeline/Resources/Messages.Designer.cs @@ -0,0 +1,270 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Timeline.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Messages { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Messages() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Messages", typeof(Messages).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Body is too big. It can't be bigger than {0}.. + /// + internal static string Common_Content_TooBig { + get { + return ResourceManager.GetString("Common_Content_TooBig", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Actual body length is bigger than it in header.. + /// + internal static string Common_Content_UnmatchedLength_Bigger { + get { + return ResourceManager.GetString("Common_Content_UnmatchedLength_Bigger", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Actual body length is smaller than it in header.. + /// + internal static string Common_Content_UnmatchedLength_Smaller { + get { + return ResourceManager.GetString("Common_Content_UnmatchedLength_Smaller", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You have no permission to do the operation.. + /// + internal static string Common_Forbid { + get { + return ResourceManager.GetString("Common_Forbid", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Header Content-Length is missing or of bad format.. + /// + internal static string Common_Header_ContentLength_Missing { + get { + return ResourceManager.GetString("Common_Header_ContentLength_Missing", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Header Content-Length must not be 0.. + /// + internal static string Common_Header_ContentLength_Zero { + get { + return ResourceManager.GetString("Common_Header_ContentLength_Zero", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Header Content-Type is missing.. + /// + internal static string Common_Header_ContentType_Missing { + get { + return ResourceManager.GetString("Common_Header_ContentType_Missing", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Header If-Non-Match is of bad format.. + /// + internal static string Common_Header_IfNonMatch_BadFormat { + get { + return ResourceManager.GetString("Common_Header_IfNonMatch_BadFormat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Model is of bad format.. + /// + internal static string Common_InvalidModel { + get { + return ResourceManager.GetString("Common_InvalidModel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The {0}-st username to do operation {1} on is of bad format.. + /// + internal static string TimelineController_ChangeMember_UsernameBadFormat { + get { + return ResourceManager.GetString("TimelineController_ChangeMember_UsernameBadFormat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The {0}-st user to do operation {1} on does not exist.. + /// + internal static string TimelineController_ChangeMember_UserNotExist { + get { + return ResourceManager.GetString("TimelineController_ChangeMember_UserNotExist", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The post to delete does not exist.. + /// + internal static string TimelineController_PostOperationDelete_NotExist { + get { + return ResourceManager.GetString("TimelineController_PostOperationDelete_NotExist", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Username or password is invalid.. + /// + internal static string TokenController_Create_BadCredential { + get { + return ResourceManager.GetString("TokenController_Create_BadCredential", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The token is of bad format. It might not be created by the server.. + /// + internal static string TokenController_Verify_BadFormat { + get { + return ResourceManager.GetString("TokenController_Verify_BadFormat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Token has an old version. User might have update some info.. + /// + internal static string TokenController_Verify_OldVersion { + get { + return ResourceManager.GetString("TokenController_Verify_OldVersion", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The token is expired.. + /// + internal static string TokenController_Verify_TimeExpired { + get { + return ResourceManager.GetString("TokenController_Verify_TimeExpired", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to User does not exist. Administrator might have deleted this user.. + /// + internal static string TokenController_Verify_UserNotExist { + get { + return ResourceManager.GetString("TokenController_Verify_UserNotExist", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Image is not a square.. + /// + internal static string UserAvatar_BadFormat_BadSize { + get { + return ResourceManager.GetString("UserAvatar_BadFormat_BadSize", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Image decode failed.. + /// + internal static string UserAvatar_BadFormat_CantDecode { + get { + return ResourceManager.GetString("UserAvatar_BadFormat_CantDecode", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Image format does not match the one in header.. + /// + internal static string UserAvatar_BadFormat_UnmatchedFormat { + get { + return ResourceManager.GetString("UserAvatar_BadFormat_UnmatchedFormat", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The user to operate on does not exist.. + /// + internal static string UserCommon_NotExist { + get { + return ResourceManager.GetString("UserCommon_NotExist", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Old password is wrong.. + /// + internal static string UserController_ChangePassword_BadOldPassword { + get { + return ResourceManager.GetString("UserController_ChangePassword_BadOldPassword", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The new username already exists.. + /// + internal static string UserController_ChangeUsername_Conflict { + get { + return ResourceManager.GetString("UserController_ChangeUsername_Conflict", resourceCulture); + } + } + } +} diff --git a/Timeline/Resources/Messages.resx b/Timeline/Resources/Messages.resx new file mode 100644 index 00000000..c5228ed5 --- /dev/null +++ b/Timeline/Resources/Messages.resx @@ -0,0 +1,189 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Body is too big. It can't be bigger than {0}. + + + Actual body length is bigger than it in header. + + + Actual body length is smaller than it in header. + + + You have no permission to do the operation. + + + Header Content-Length is missing or of bad format. + + + Header Content-Length must not be 0. + + + Header Content-Type is missing. + + + Header If-Non-Match is of bad format. + + + Model is of bad format. + + + The {0}-st username to do operation {1} on is of bad format. + + + The {0}-st user to do operation {1} on does not exist. + + + The post to delete does not exist. + + + Username or password is invalid. + + + The token is of bad format. It might not be created by the server. + + + Token has an old version. User might have update some info. + + + The token is expired. + + + User does not exist. Administrator might have deleted this user. + + + Image is not a square. + + + Image decode failed. + + + Image format does not match the one in header. + + + The user to operate on does not exist. + + + Old password is wrong. + + + The new username already exists. + + \ No newline at end of file diff --git a/Timeline/Resources/Messages.zh.resx b/Timeline/Resources/Messages.zh.resx new file mode 100644 index 00000000..6e52befd --- /dev/null +++ b/Timeline/Resources/Messages.zh.resx @@ -0,0 +1,189 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 请求体太大。它不能超过{0}. + + + 实际的请求体长度比头中指示的大。 + + + 实际的请求体长度比头中指示的小。 + + + 你没有权限做此操作。 + + + 请求头Content-Length缺失或者格式不对。 + + + 请求头Content-Length不能为0。 + + + 请求头Content-Type缺失。 + + + 请求头If-Non-Match格式不对。 + + + 请求模型格式不对。 + + + 第{0}个做{1}操作的用户名格式错误。 + + + 第{0}个做{1}操作的用户不存在。 + + + 要删除的消息不存在。 + + + 用户名或密码错误。 + + + 符号格式错误。这个符号可能不是这个服务器创建的。 + + + 符号是一个旧版本。用户可能已经更新了信息。 + + + 符号过期了。 + + + 用户不存在。管理员可能已经删除了这个用户。 + + + 图片不是正方形。 + + + 解码图片失败。 + + + 图片格式与请求头中指示的不一样。 + + + 要操作的用户不存在。 + + + 旧密码错误。 + + + 新用户名已经存在。 + + \ No newline at end of file diff --git a/Timeline/Resources/Models/Http/Common.Designer.cs b/Timeline/Resources/Models/Http/Common.Designer.cs index 4eebd2bc..5165463e 100644 --- a/Timeline/Resources/Models/Http/Common.Designer.cs +++ b/Timeline/Resources/Models/Http/Common.Designer.cs @@ -60,33 +60,6 @@ namespace Timeline.Resources.Models.Http { } } - /// - /// Looks up a localized string similar to Body is too big. It can't be bigger than {0}.. - /// - internal static string MessageContentTooBig { - get { - return ResourceManager.GetString("MessageContentTooBig", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Actual body length is bigger than it in header.. - /// - internal static string MessageContentUnmatchedLengthBigger { - get { - return ResourceManager.GetString("MessageContentUnmatchedLengthBigger", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Actual body length is smaller than it in header.. - /// - internal static string MessageContentUnmatchedLengthSmaller { - get { - return ResourceManager.GetString("MessageContentUnmatchedLengthSmaller", resourceCulture); - } - } - /// /// Looks up a localized string similar to An existent item is deleted.. /// @@ -105,15 +78,6 @@ namespace Timeline.Resources.Models.Http { } } - /// - /// Looks up a localized string similar to Header If-Non-Match is of bad format.. - /// - internal static string MessageHeaderIfNonMatchBad { - get { - return ResourceManager.GetString("MessageHeaderIfNonMatchBad", resourceCulture); - } - } - /// /// Looks up a localized string similar to A new item is created.. /// diff --git a/Timeline/Resources/Models/Http/Common.resx b/Timeline/Resources/Models/Http/Common.resx index 540c6c58..85ec4d32 100644 --- a/Timeline/Resources/Models/Http/Common.resx +++ b/Timeline/Resources/Models/Http/Common.resx @@ -117,24 +117,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Body is too big. It can't be bigger than {0}. - - - Actual body length is bigger than it in header. - - - Actual body length is smaller than it in header. - An existent item is deleted. The item does not exist, so nothing is changed. - - Header If-Non-Match is of bad format. - A new item is created. diff --git a/Timeline/Resources/Models/Http/Common.zh.resx b/Timeline/Resources/Models/Http/Common.zh.resx index 467916a2..de74ac3b 100644 --- a/Timeline/Resources/Models/Http/Common.zh.resx +++ b/Timeline/Resources/Models/Http/Common.zh.resx @@ -117,24 +117,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 请求体太大。它不能超过{0}. - - - 实际的请求体长度比头中指示的大。 - - - 实际的请求体长度比头中指示的小。 - 删除了一个项目。 要删除的项目不存在,什么都没有修改。 - - 请求头If-Non-Match格式不对。 - 创建了一个新项目。 diff --git a/Timeline/Timeline.csproj b/Timeline/Timeline.csproj index 681f49cb..27897177 100644 --- a/Timeline/Timeline.csproj +++ b/Timeline/Timeline.csproj @@ -32,17 +32,16 @@ + + + + True True AuthHandler.resx - - True - True - Common.resx - True True @@ -73,6 +72,11 @@ True Filters.resx + + True + True + Messages.resx + True True @@ -115,10 +119,6 @@ ResXFileCodeGenerator AuthHandler.Designer.cs - - ResXFileCodeGenerator - Common.Designer.cs - ResXFileCodeGenerator TestingI18nController.Designer.cs @@ -144,6 +144,10 @@ ResXFileCodeGenerator Filters.Designer.cs + + ResXFileCodeGenerator + Messages.Designer.cs + ResXFileCodeGenerator Common.Designer.cs -- cgit v1.2.3