| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- using System.Linq;
- using IwbZero.ToolCommon.StringModel;
- using WeOnlineApp.Basic;
- using WeOnlineApp.Configuration;
- using WeOnlineApp.EF;
- namespace WeOnlineApp.SeedData
- {
- public class DefaultDataCreator
- {
- private readonly WeOnlineAppDbContext _context;
- public DefaultDataCreator(WeOnlineAppDbContext context)
- {
- _context = context;
- }
- public void Create()
- {
- SubjectCategory();
- }
- private int Index { get; set; }
- private string GetNo(DataLibType type, bool flag = false, bool flag2 = false)
- {
- if (flag)
- {
- while (Index % 10 != 0)
- {
- Index++;
- }
- }
- if (flag2)
- {
- while (Index % 50 != 0)
- {
- Index++;
- }
- }
- Index++;
- var no = $"JY{type.ToInt().LeftPad(3)}{Index.LeftPad(9)}";
- return no;
- }
- #region SCENECATEGORY
- private string scYl { get; set; }
- private string scHz { get; set; }
- private string scTd { get; set; }
- private string scGj { get; set; }
- private string scFx { get; set; }
- private string scPj { get; set; }
- private string scWhp { get; set; }
- public void SubjectCategory()
- {
- _context.Sql("DELETE FROM [dbo].[Base_SubjectCategories]");
- scYl = GetNo(DataLibType.SubjectCategoryInfo);
- scHz = GetNo(DataLibType.SubjectCategoryInfo);
- scTd = GetNo(DataLibType.SubjectCategoryInfo);
- scGj = GetNo(DataLibType.SubjectCategoryInfo);
- scFx = GetNo(DataLibType.SubjectCategoryInfo);
- scPj = GetNo(DataLibType.SubjectCategoryInfo);
- scWhp = GetNo(DataLibType.SubjectCategoryInfo);//index=107
- var path = $"{IwbConsts.SubjectCategoryRootNo},{scYl}";
- SubjectCategoryCreate(IwbConsts.SubjectCategoryRootNo, IwbConsts.TreeRootParentNo, "根节点", null);
- SubjectCategoryCreate(scYl, IwbConsts.SubjectCategoryRootNo, "综合演练", path);
- SubjectCategoryCreate(scHz, scYl, "高层火灾", $"{path},{scHz}");
- SubjectCategoryCreate(scTd, scYl, "大面积停电", $"{path},{scTd}");
- SubjectCategoryCreate(scGj, scYl, "轨交大客流", $"{path},{scGj}");
- SubjectCategoryCreate(scFx, scYl, "防台防汛", $"{path},{scFx}");
- SubjectCategoryCreate(scPj, scYl, "飞机迫降", $"{path},{scPj}");
- SubjectCategoryCreate(scWhp, scYl, "危化品事故", $"{path},{scWhp}");
- }
- /// <summary>
- /// 场景类别
- /// </summary>
- private void SubjectCategoryCreate(string id, string pId, string name, string pPath)
- {
- if (_context.SubjectCategoryInfos.Any(s => s.Id == id))
- {
- return;
- }
- _context.SubjectCategoryInfos.Add(new SubjectCategoryInfo()
- {
- Id = id,
- ParentNo = pId,
- CategoryName = name,
- CategoryPath = $"{(pPath.IsNotEmpty() ? $"{pPath}," : "")}{id}",
- Sort = 0,
- Description = name
- });
- _context.SaveChanges();
- }
- #endregion
- }
- }
|