胖子天骄的MES系统
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

51 řádky
1.7 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reflection;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace BPA.MES.Base.Application.Services
  8. {
  9. /// <summary>
  10. /// 名 称 :
  11. /// 创 建 人 :yangxiao
  12. /// 创建时间 : 2023/7/17 16:13:10
  13. /// 描 述 :
  14. /// </summary>
  15. public class BaseService: ITransient, IDynamicApiController
  16. {
  17. private readonly ISqlSugarClient _dbContext;
  18. public BaseService(ISqlSugarClient db)
  19. {
  20. _dbContext = db;
  21. }
  22. /// <summary>
  23. /// 初始化数据库
  24. /// </summary>
  25. /// <returns></returns>
  26. public string CreateDB()
  27. {
  28. var types = Assembly.Load("BPA.MES.Base.Application").GetTypes()
  29. .Where(x => x.GetCustomAttribute<SugarTable>() != null
  30. && x.Namespace == "BPA.MES.Base.Application.Entitys").ToArray();
  31. _dbContext.CodeFirst.InitTables(types);
  32. return "成功";
  33. }
  34. /// <summary>
  35. /// 测试
  36. /// </summary>
  37. [AllowAnonymous]
  38. public void Test()
  39. {
  40. //Type personType = Type.GetType("BPA.MES.Base.Application, DictDataAddInput");
  41. //object person = Activator.CreateInstance(personType);
  42. Type type = Type.GetType("BPA.MES.Base.Application.Services.DictService.Dtos");
  43. string fullName = "BPA.MES.Base.Application.Services.DictDataAddInput";
  44. Type? instanceClass = Assembly.Load("BPA.MES.Base.Application").GetType(fullName);
  45. var myInstance = instanceClass?.Assembly.CreateInstance(fullName);
  46. }
  47. }
  48. }