还原
This commit is contained in:
1 parent
280ccf4de8
commit
032f048a16
25 files changed
+2673
-718
No files matched your search
@@ -59,7 +59,7 @@ namespace CloudBuilder.Core.DatabaseAccessor
|
||||
//public byte[] RowVersion { get; set; }
|
||||
if (ex.Message.Contains("data may have been modified or deleted since entities were loaded."))
|
||||
{
|
||||
throw new ValidatedException(CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.THE_DATA_HAS_BEEN_MODIFIED));
|
||||
throw new ValidatedException(CoreMessagePolicy.GetInstance(_serviceProvider).ComposeMessage(CoreMessagePolicy.THE_DATA_HAS_BEEN_MODIFIED));
|
||||
}
|
||||
throw new ValidatedException(ex.InnerException?.Message ?? ex.Message);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using CloudBuilder.Core.Service;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.IdentityModel.JsonWebTokens;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -45,7 +46,7 @@ namespace CloudBuilder.Core.DatabaseAccessor
|
||||
{
|
||||
if (ex.Message.Contains("data may have been modified or deleted since entities were loaded."))
|
||||
{
|
||||
throw new ValidatedException(CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.THE_DATA_HAS_BEEN_MODIFIED));
|
||||
throw new ValidatedException(CoreMessagePolicy.GetInstance(_serviceProvider).ComposeMessage(CoreMessagePolicy.THE_DATA_HAS_BEEN_MODIFIED));
|
||||
}
|
||||
throw new ValidatedException(ex.InnerException?.Message ?? ex.Message);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using CloudBuilder.Core.DependencyInjection.Form;
|
||||
using CloudBuilder.Core.DatabaseAccessor.Entity;
|
||||
using CloudBuilder.Core.DependencyInjection.Form;
|
||||
using CloudBuilder.Core.DependencyInjection.Policy;
|
||||
using CloudBuilder.Core.DependencyInjection.Request;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -22,9 +23,9 @@ namespace CloudBuilder.Core.Policy
|
||||
this.values = new string[] { THE_DATA_HAS_BEEN_MODIFIED, NO_PERMISSION };
|
||||
}
|
||||
|
||||
public static CoreMessagePolicy GetInstance()
|
||||
public static CoreMessagePolicy GetInstance(IServiceProvider serviceProvider)
|
||||
{
|
||||
instance = ApplicationServiceContext.ServiceProvider.GetKeyedService<CoreMessagePolicy>(typeof(CoreMessagePolicy).Name);
|
||||
instance = serviceProvider.GetKeyedService<CoreMessagePolicy>(typeof(CoreMessagePolicy).Name);
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using CloudBuilder.Core.DependencyInjection.Form;
|
||||
using CloudBuilder.Core.DependencyInjection.Policy;
|
||||
using CloudBuilder.Core.DependencyInjection.Request;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
@@ -9,7 +10,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace System
|
||||
{
|
||||
public class SearchFilterOperatorPolicy : AbstractPolicy
|
||||
public class SearchFilterOperatorPolicy : AbstractPolicy, IPolicy
|
||||
{
|
||||
public const string EQUAL_TO = "equal_to";//='value'
|
||||
public const string CONTAIN = "contain";//like '%value%'
|
||||
@@ -71,9 +72,9 @@ namespace System
|
||||
};
|
||||
}
|
||||
|
||||
public static SearchFilterOperatorPolicy GetInstance()
|
||||
public static SearchFilterOperatorPolicy GetInstance(IServiceProvider serviceProvider)
|
||||
{
|
||||
instance = ApplicationServiceContext.ServiceProvider.GetKeyedService<SearchFilterOperatorPolicy>(typeof(SearchFilterOperatorPolicy).Name);
|
||||
instance = serviceProvider.GetKeyedService<SearchFilterOperatorPolicy>(typeof(SearchFilterOperatorPolicy).Name);
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using CloudBuilder.Core.DependencyInjection.Form;
|
||||
using CloudBuilder.Core.DependencyInjection.Policy;
|
||||
using CloudBuilder.Core.DependencyInjection.Request;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
@@ -9,7 +10,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace System
|
||||
{
|
||||
public class SearchFilterTypePolicy : AbstractPolicy
|
||||
public class SearchFilterTypePolicy : AbstractPolicy, IPolicy
|
||||
{
|
||||
public const string TEXT = "Text";
|
||||
public const string TEXT_CONTAIN = "TextContain";
|
||||
@@ -31,9 +32,9 @@ namespace System
|
||||
this.values = new string[] { TEXT, TEXT_CONTAIN, NUMBER, DATE, DATETIME, MULTIPLE_SELECTION, SINGLE_SELECTION };
|
||||
}
|
||||
|
||||
public static SearchFilterTypePolicy GetInstance()
|
||||
public static SearchFilterTypePolicy GetInstance(IServiceProvider serviceProvider)
|
||||
{
|
||||
instance = ApplicationServiceContext.ServiceProvider.GetKeyedService<SearchFilterTypePolicy>(typeof(SearchFilterTypePolicy).Name);
|
||||
instance = serviceProvider.GetKeyedService<SearchFilterTypePolicy>(typeof(SearchFilterTypePolicy).Name);
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ namespace System
|
||||
this.values = new string[] { YES, NO };
|
||||
}
|
||||
|
||||
public static YesNoPolicy GetInstance()
|
||||
public static YesNoPolicy GetInstance(IServiceProvider serviceProvider)
|
||||
{
|
||||
instance = ApplicationServiceContext.ServiceProvider.GetKeyedService<YesNoPolicy>(typeof(YesNoPolicy).Name);
|
||||
instance = serviceProvider.GetKeyedService<YesNoPolicy>(typeof(YesNoPolicy).Name);
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Net.Http.Json;
|
||||
using System.Text;
|
||||
@@ -138,7 +139,7 @@ namespace CloudBuilder.Core.Request
|
||||
if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11);
|
||||
|
||||
if (response.ReasonPhrase == "Forbidden")
|
||||
throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION)));
|
||||
throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance(provider).ComposeMessage(CoreMessagePolicy.NO_PERMISSION)));
|
||||
|
||||
throw new Exception(string.Format("{0}{1}", response.ReasonPhrase, string.IsNullOrEmpty(errors) ? "" : "\r\n" + errors));
|
||||
}
|
||||
@@ -188,7 +189,7 @@ namespace CloudBuilder.Core.Request
|
||||
if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11);
|
||||
|
||||
if (response.ReasonPhrase == "Forbidden")
|
||||
throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION)));
|
||||
throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance(provider).ComposeMessage(CoreMessagePolicy.NO_PERMISSION)));
|
||||
|
||||
throw new Exception(string.Format("{0}{1}", response.ReasonPhrase, string.IsNullOrEmpty(errors) ? "" : "\r\n" + errors));
|
||||
}
|
||||
@@ -244,7 +245,7 @@ namespace CloudBuilder.Core.Request
|
||||
if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11);
|
||||
|
||||
if (response.ReasonPhrase == "Forbidden")
|
||||
throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION)));
|
||||
throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance(provider).ComposeMessage(CoreMessagePolicy.NO_PERMISSION)));
|
||||
|
||||
throw new Exception(string.Format("{0}{1}", response.ReasonPhrase, string.IsNullOrEmpty(errors) ? "" : "\r\n" + errors));
|
||||
}
|
||||
@@ -275,7 +276,7 @@ namespace CloudBuilder.Core.Request
|
||||
if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11);
|
||||
|
||||
if (response.ReasonPhrase == "Forbidden")
|
||||
throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION)));
|
||||
throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance(provider).ComposeMessage(CoreMessagePolicy.NO_PERMISSION)));
|
||||
|
||||
throw new Exception(string.Format("{0}{1}", response.ReasonPhrase, string.IsNullOrEmpty(errors) ? "" : "\r\n" + errors));
|
||||
}
|
||||
@@ -306,7 +307,7 @@ namespace CloudBuilder.Core.Request
|
||||
if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11);
|
||||
|
||||
if (response.ReasonPhrase == "Forbidden")
|
||||
throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION)));
|
||||
throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance(provider).ComposeMessage(CoreMessagePolicy.NO_PERMISSION)));
|
||||
|
||||
throw new Exception(string.Format("{0}{1}", response.ReasonPhrase, string.IsNullOrEmpty(errors) ? "" : "\r\n" + errors));
|
||||
}
|
||||
@@ -335,7 +336,7 @@ namespace CloudBuilder.Core.Request
|
||||
if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11);
|
||||
|
||||
if (response.ReasonPhrase == "Forbidden")
|
||||
throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION)));
|
||||
throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance(provider).ComposeMessage(CoreMessagePolicy.NO_PERMISSION)));
|
||||
|
||||
throw new Exception(string.Format("{0}{1}", response.ReasonPhrase, string.IsNullOrEmpty(errors) ? "" : "\r\n" + errors));
|
||||
}
|
||||
@@ -395,7 +396,7 @@ namespace CloudBuilder.Core.Request
|
||||
if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11);
|
||||
|
||||
if (response.ReasonPhrase == "Forbidden")
|
||||
throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION)));
|
||||
throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance(provider).ComposeMessage(CoreMessagePolicy.NO_PERMISSION)));
|
||||
|
||||
throw new Exception(string.Format("{0}{1}", response.ReasonPhrase, string.IsNullOrEmpty(errors) ? "" : "\r\n" + errors));
|
||||
}
|
||||
@@ -429,7 +430,7 @@ namespace CloudBuilder.Core.Request
|
||||
if (responseContext != null && responseContext.StartsWith("{\"errors\"")) errors = responseContext.Substring(11, responseContext.IndexOf("}") - 11);
|
||||
|
||||
if (response.ReasonPhrase == "Forbidden")
|
||||
throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance().ComposeMessage(CoreMessagePolicy.NO_PERMISSION)));
|
||||
throw new Exception(string.Format("{0}", CoreMessagePolicy.GetInstance(provider).ComposeMessage(CoreMessagePolicy.NO_PERMISSION)));
|
||||
|
||||
throw new Exception(string.Format("{0}{1}", response.ReasonPhrase, string.IsNullOrEmpty(errors) ? "" : "\r\n" + errors));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -12,16 +13,16 @@ namespace CloudBuilder.Core.Service
|
||||
public const string KEY_FILTER_OPERATOR = "filter_operator";
|
||||
public const string KEY_FILTER_TYPE = "filter_type";
|
||||
|
||||
public SearchCriteria()
|
||||
public SearchCriteria(IServiceProvider serviceProvider)
|
||||
{
|
||||
Add(KEY_FILTER_OPERATOR, SearchFilterOperatorPolicy.GetInstance().GetBindOptions());
|
||||
Add(KEY_FILTER_TYPE, SearchFilterTypePolicy.GetInstance().GetBindOptions());
|
||||
Add(KEY_FILTER_OPERATOR, SearchFilterOperatorPolicy.GetInstance(serviceProvider).GetBindOptions());
|
||||
Add(KEY_FILTER_TYPE, SearchFilterTypePolicy.GetInstance(serviceProvider).GetBindOptions());
|
||||
}
|
||||
public SearchCriteria(Selection[] selections)
|
||||
public SearchCriteria(IServiceProvider serviceProvider,Selection[] selections)
|
||||
{
|
||||
Selections = selections;
|
||||
Add(KEY_FILTER_OPERATOR, SearchFilterOperatorPolicy.GetInstance().GetBindOptions());
|
||||
Add(KEY_FILTER_TYPE, SearchFilterTypePolicy.GetInstance().GetBindOptions());
|
||||
Add(KEY_FILTER_OPERATOR, SearchFilterOperatorPolicy.GetInstance(serviceProvider).GetBindOptions());
|
||||
Add(KEY_FILTER_TYPE, SearchFilterTypePolicy.GetInstance(serviceProvider).GetBindOptions());
|
||||
}
|
||||
public Selection[] Selections { get; set; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user