This commit is contained in:
owenchen committed 2026-05-12 15:00:08 +08:00
1 parent 4521deaf78
commit 647a1c38ab
18 files changed
+279 -103

No files matched your search

@@ -13,12 +13,13 @@ namespace CloudBuilder.Core.Policy
public class CoreMessagePolicy : AbstractPolicy, IPolicy
{
public const string THE_DATA_HAS_BEEN_MODIFIED = "the_data_has_been_modified";
public const string NO_PERMISSION = "no_permission";
public static CoreMessagePolicy instance = null;
public CoreMessagePolicy(IContext context) : base(context)
{
this.values = new string[] { THE_DATA_HAS_BEEN_MODIFIED};
this.values = new string[] { THE_DATA_HAS_BEEN_MODIFIED, NO_PERMISSION };
}
public static CoreMessagePolicy GetInstance()
@@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="no_permission" xml:space="preserve">
<value>No permission has been assigned.</value>
</data>
<data name="the_data_has_been_modified" xml:space="preserve">
<value>The data has been modified by another user. Please refresh and try again.</value>
</data>
@@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="no_permission" xml:space="preserve">
<value>没有分配权限.</value>
</data>
<data name="the_data_has_been_modified" xml:space="preserve">
<value>数据已被其他用户修改,请刷新后重试.</value>
</data>
@@ -136,6 +136,10 @@ namespace CloudBuilder.Core.Request
var responseContext = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
string errors = string.Empty;
if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11);
if (response.ReasonPhrase == "Forbidden")
throw new Exception(string.Format("{0}\r\n{1}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION), errors));
throw new Exception(string.Format("{0}\r\n{1}", response.ReasonPhrase, errors));
}
@@ -182,6 +186,10 @@ namespace CloudBuilder.Core.Request
var responseContext = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
string errors = string.Empty;
if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11);
if (response.ReasonPhrase == "Forbidden")
throw new Exception(string.Format("{0}\r\n{1}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION), errors));
throw new Exception(string.Format("{0}\r\n{1}", response.ReasonPhrase, errors));
}
@@ -234,6 +242,10 @@ namespace CloudBuilder.Core.Request
var responseContext = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
string errors = string.Empty;
if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11);
if (response.ReasonPhrase == "Forbidden")
throw new Exception(string.Format("{0}\r\n{1}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION), errors));
throw new Exception(string.Format("{0}\r\n{1}", response.ReasonPhrase, errors));
}
@@ -261,6 +273,10 @@ namespace CloudBuilder.Core.Request
var responseContext = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
string errors = string.Empty;
if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11);
if (response.ReasonPhrase == "Forbidden")
throw new Exception(string.Format("{0}\r\n{1}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION), errors));
throw new Exception(string.Format("{0}\r\n{1}", response.ReasonPhrase, errors));
}
@@ -288,6 +304,10 @@ namespace CloudBuilder.Core.Request
var responseContext = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
string errors = string.Empty;
if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11);
if (response.ReasonPhrase == "Forbidden")
throw new Exception(string.Format("{0}\r\n{1}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION), errors));
throw new Exception(string.Format("{0}\r\n{1}", response.ReasonPhrase, errors));
}
@@ -313,6 +333,10 @@ namespace CloudBuilder.Core.Request
var responseContext = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
string errors = string.Empty;
if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11);
if (response.ReasonPhrase == "Forbidden")
throw new Exception(string.Format("{0}\r\n{1}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION), errors));
throw new Exception(string.Format("{0}\r\n{1}", response.ReasonPhrase, errors));
}
@@ -353,6 +377,10 @@ namespace CloudBuilder.Core.Request
var responseContext = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
string errors = string.Empty;
if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11);
if (response.ReasonPhrase == "Forbidden")
throw new Exception(string.Format("{0}\r\n{1}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION), errors));
throw new Exception(string.Format("{0}\r\n{1}", response.ReasonPhrase, errors));
}