| | |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Core.Attributes; |
| | | using WIDESEAWCS_Core.Const; |
| | | using WIDESEAWCS_Core.DB; |
| | | using WIDESEAWCS_Core.Helper; |
| | |
| | | |
| | | string seedData = FileHelper.ReadFile(string.Format(SeedDataFolder, t.Name), Encoding.UTF8); |
| | | |
| | | #region Sys_User |
| | | #region AddSeedData |
| | | if (seedData != "不存在相应的目录") |
| | | { |
| | | List<Dictionary<string, object>> dicFile = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(seedData); |
| | |
| | | for (int i = 0; i < propertyInfos.Count; i++) |
| | | { |
| | | PropertyInfo propertyInfo = propertyInfos[i]; |
| | | SugarColumn sugarColumn = propertyInfo.GetCustomAttribute<SugarColumn>(); |
| | | |
| | | SequenceAttribute? sequenceAttirbute = propertyInfo.GetCustomAttribute<SequenceAttribute>(); |
| | | if (sequenceAttirbute != null) |
| | | { |
| | | int count = dbContext.Db.Ado.GetScalar($"SELECT COUNT(*) FROM sys.sequences WHERE name = '{sequenceAttirbute.SequenceName}'").ObjToInt(); |
| | | if (count == 0) |
| | | { |
| | | string sql = $"CREATE SEQUENCE {sequenceAttirbute.SequenceName} AS [int] START WITH {sequenceAttirbute.StartWith} INCREMENT BY {sequenceAttirbute.Increment} MINVALUE {sequenceAttirbute.SeqMinValue} MAXVALUE {sequenceAttirbute.SeqMaxValue} {(sequenceAttirbute.IsCycle ? "CYCLE" : "")} CACHE"; |
| | | dbContext.Db.Ado.ExecuteCommand(sql); |
| | | } |
| | | } |
| | | |
| | | SugarColumn? sugarColumn = propertyInfo.GetCustomAttribute<SugarColumn>(); |
| | | if (sugarColumn != null) |
| | | { |
| | | if (!sugarColumn.IsIgnore) |
| | |
| | | } |
| | | dic.Add(keyValuePairs); |
| | | } |
| | | |
| | | |
| | | if (dic.Count > 0) |
| | | { |
| | |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | for (int i = 0; i < propertyInfos.Count; i++) |
| | | { |
| | | PropertyInfo propertyInfo = propertyInfos[i]; |
| | | SugarColumn sugarColumn = propertyInfo.GetCustomAttribute<SugarColumn>(); |
| | | |
| | | SequenceAttribute? sequenceAttirbute = propertyInfo.GetCustomAttribute<SequenceAttribute>(); |
| | | if (sequenceAttirbute != null) |
| | | { |
| | | int count = dbContext.Db.Ado.GetScalar($"SELECT COUNT(*) FROM sys.sequences WHERE name = '{sequenceAttirbute.SequenceName}'").ObjToInt(); |
| | | if (count == 0) |
| | | { |
| | | string sql = $"CREATE SEQUENCE {sequenceAttirbute.SequenceName} AS [int] START WITH {sequenceAttirbute.StartWith} INCREMENT BY {sequenceAttirbute.Increment} MINVALUE {sequenceAttirbute.SeqMinValue} MAXVALUE {sequenceAttirbute.SeqMaxValue} {(sequenceAttirbute.IsCycle ? "CYCLE" : "")} CACHE"; |
| | | dbContext.Db.Ado.ExecuteCommand(sql); |
| | | } |
| | | } |
| | | SugarColumn? sugarColumn = propertyInfo.GetCustomAttribute<SugarColumn>(); |
| | | if (sugarColumn != null) |
| | | { |
| | | if (!sugarColumn.IsIgnore) |