ow
This commit is contained in:
commit
f05d2d215f
678 files changed
+73865
No files matched your search
@@ -0,0 +1,50 @@
|
||||
using CloudBuilder.Core.Application.Builders;
|
||||
using CloudBuilder.Core.Application.Packs;
|
||||
using CloudBuilder.Core.Authorization;
|
||||
using CloudBuilder.Core.DependencyInjection.Form;
|
||||
using CloudBuilder.Core.DependencyInjection.Request;
|
||||
using CloudBuilder.Core.Policy;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CloudBuilder.Gui.DependencyInjection
|
||||
{
|
||||
[PackLevel(100)]
|
||||
public class GuiPack : CloudBuilderPack
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取 模块级别
|
||||
/// </summary>
|
||||
public override PackLevel Level => PackLevel.Business;
|
||||
|
||||
/// <summary>
|
||||
/// 获取 模块启动顺序,模块启动的顺序先按级别启动,级别内部再按此顺序启动
|
||||
/// </summary>
|
||||
public override int Order => 2;
|
||||
|
||||
/// <summary>
|
||||
/// 将窗体和用户控件添加到依赖注入服务容器中
|
||||
/// </summary>
|
||||
/// <param name="services">依赖注入服务容器</param>
|
||||
/// <returns></returns>
|
||||
public override IServiceCollection AddServices(IServiceCollection services, CloudBuilderBuilder builder)
|
||||
{
|
||||
services.TryAddSingleton<ApplicationServiceContext>();
|
||||
|
||||
services.TryAddSingleton<ILocaleMessageManager, LocaleMessageManager>();
|
||||
|
||||
services.TryAddSingleton<ISecurityMasterManager, SecurityMasterManager>();
|
||||
|
||||
services.TryAddSingleton<BindingContextAttributeProvider>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using CloudBuilder.Core.DependencyInjection.Request;
|
||||
using CloudBuilder.Core.Policy;
|
||||
using CloudBuilder.Request.Security;
|
||||
using CloudBuilder.Security.Entity;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CloudBuilder.Gui.DependencyInjection
|
||||
{
|
||||
public class LocaleMessageManager : ILocaleMessageManager
|
||||
{
|
||||
public LocaleEntity[] LocaleEntities { get; set; } = null!;
|
||||
|
||||
public static string SYSTEM = "system";
|
||||
|
||||
public static string GUI_OK = "ok";
|
||||
public static string GUI_CANCEL = "cancel";
|
||||
public static string GUI_INFORMATION = "gui_information";
|
||||
public static string GUI_ERROR = "gui_error";
|
||||
private readonly IServiceProvider serviceProvider;
|
||||
private readonly IContext context;
|
||||
|
||||
public LocaleMessageManager(IServiceProvider serviceProvider, IContext context)
|
||||
{
|
||||
this.serviceProvider = serviceProvider;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void InitLocale()
|
||||
{
|
||||
LocaleRequest localeRequest = serviceProvider.GetRequiredKeyedService<LocaleRequest>(typeof(LocaleRequest).Name);
|
||||
|
||||
LocaleEntities = localeRequest.FindAll().OrderBy(x => x.OrderBy).ToArray();
|
||||
}
|
||||
|
||||
public string ComposeMessage(string groupName, string name)
|
||||
{
|
||||
if (LocaleEntities == null || LocaleEntities.Length == 0)
|
||||
{
|
||||
InitLocale();
|
||||
}
|
||||
|
||||
if (LocaleEntities == null || LocaleEntities.Length == 0) return null!;
|
||||
|
||||
return LocaleEntities.Where(x => x.GroupName == groupName && x.Name == name && x.Lang == context.GetCulture()).Select(x => x.Value).FirstOrDefault()!;
|
||||
}
|
||||
public TableName<string>[] GetDataSource(string groupName)
|
||||
{
|
||||
if (LocaleEntities == null || LocaleEntities.Length == 0)
|
||||
{
|
||||
InitLocale();
|
||||
}
|
||||
|
||||
if (LocaleEntities == null || LocaleEntities.Length == 0) return null!;
|
||||
|
||||
string[] values = LocaleEntities.Where(x => x.GroupName == groupName && x.Lang == context.GetCulture()).OrderBy(x => x.OrderBy).Select(x => x.Name).ToArray();
|
||||
|
||||
if (values == null || values.Length == 0) return null!;
|
||||
|
||||
return GetComposeMessages<string>(groupName, values);
|
||||
}
|
||||
|
||||
public TableName<T>[] GetComposeMessages<T>(string groupName, T[] values)
|
||||
{
|
||||
if (values == null || values.Length == 0) return null;
|
||||
TableName<T> tb = null;
|
||||
List<TableName<T>> list = new List<TableName<T>>();
|
||||
foreach (T v in values)
|
||||
{
|
||||
tb = new TableName<T>();
|
||||
tb.DisplayName = ComposeMessage(groupName, v.ToString());
|
||||
tb.Value = v;
|
||||
list.Add(tb);
|
||||
}
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
INSERT INTO [dbo].[locale]([created_datetime],[created_by],[updated_datetime],[updated_by],[group_name],[lang],[name],[value],[order]) VALUES
|
||||
(GETDATE(),'patch',GETDATE(),'patch','system','zh-cn','gui_error',N'出错信息',0),
|
||||
(GETDATE(),'patch',GETDATE(),'patch','system','en','gui_error',N'Error Message',0),
|
||||
(GETDATE(),'patch',GETDATE(),'patch','system','zh-cn','gui_information',N'验证信息',0),
|
||||
(GETDATE(),'patch',GETDATE(),'patch','system','en','gui_information',N'Verification Message',0)
|
||||
|
||||
="(GETDATE(),'patch',GETDATE(),'patch','"&$A$1&"','zh-cn','"&A2&"',N'"&B2&"',0),"
|
||||
="(GETDATE(),'patch',GETDATE(),'patch','"&$A$1&"','en','"&A2&"',N'"&B2&"',0),"
|
||||
*/
|
||||
@@ -0,0 +1,76 @@
|
||||
using CloudBuilder.Core.Policy;
|
||||
using CloudBuilder.Request.Security;
|
||||
using CloudBuilder.Security.Entity;
|
||||
using DocumentFormat.OpenXml.InkML;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CloudBuilder.Gui.DependencyInjection
|
||||
{
|
||||
public class SecurityMasterManager : ISecurityMasterManager
|
||||
{
|
||||
public SecurityMasterEntity[]? SecurityMasterEntities { get; set; }
|
||||
private readonly IServiceProvider serviceProvider;
|
||||
|
||||
public SecurityMasterManager(IServiceProvider serviceProvider)
|
||||
{
|
||||
this.serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public dynamic GetSecurityMaster(string category, string subcategory, string codeItem)
|
||||
{
|
||||
if (SecurityMasterEntities == null || SecurityMasterEntities.Length == 0)
|
||||
{
|
||||
InitSecurityMaster();
|
||||
}
|
||||
|
||||
if (SecurityMasterEntities == null || SecurityMasterEntities.Length == 0) return null!;
|
||||
|
||||
return SecurityMasterEntities.Where(x => x.MasterCategory == category && x.MasterSubcategory == subcategory && x.MasterCodeItem == codeItem).FirstOrDefault()!;
|
||||
}
|
||||
|
||||
public string GetValue(string category, string subcategory, string codeItem)
|
||||
{
|
||||
if (SecurityMasterEntities == null || SecurityMasterEntities.Length == 0)
|
||||
{
|
||||
InitSecurityMaster();
|
||||
}
|
||||
|
||||
if (SecurityMasterEntities == null || SecurityMasterEntities.Length == 0) return null!;
|
||||
|
||||
return SecurityMasterEntities.Where(x => x.MasterCategory == category && x.MasterSubcategory == subcategory && x.MasterCodeItem == codeItem).Select(x => x.Value).FirstOrDefault()!;
|
||||
}
|
||||
|
||||
public void InitSecurityMaster()
|
||||
{
|
||||
SecurityMasterRequest securityMasterRequest = serviceProvider.GetRequiredKeyedService<SecurityMasterRequest>(typeof(SecurityMasterRequest).Name);
|
||||
|
||||
SecurityMasterEntities = securityMasterRequest.FindAll().ToArray();
|
||||
}
|
||||
|
||||
public void SetSecurityMaster(string category, string subcategory, string codeItem, string value)
|
||||
{
|
||||
SecurityMasterRequest securityMasterRequest = serviceProvider.GetRequiredKeyedService<SecurityMasterRequest>(typeof(SecurityMasterRequest).Name);
|
||||
SecurityMasterEntity securityMasterEntity = new SecurityMasterEntity()
|
||||
{
|
||||
CreatedBy = string.Empty,
|
||||
UpdatedBy = string.Empty,
|
||||
CreatedDatetime = DateTime.Now,
|
||||
UpdatedDatetime = DateTime.Now
|
||||
};
|
||||
|
||||
securityMasterEntity.MasterCategory = category;
|
||||
securityMasterEntity.MasterSubcategory = subcategory;
|
||||
securityMasterEntity.MasterCodeItem = codeItem;
|
||||
securityMasterEntity.Value = value;
|
||||
securityMasterEntity.ValidIndc = YesNoPolicy.YES;
|
||||
|
||||
securityMasterRequest.Insert(securityMasterEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user