public async Task <JsonResult> DoEdit([FromBody] SysDictionary entity) { var jm = new AdminUiCallBack(); var oldModel = await _sysDictionaryServices.QueryByIdAsync(entity.id); if (oldModel == null) { jm.msg = "不存在此信息"; return(new JsonResult(jm)); } //事物处理过程开始 oldModel.dictCode = entity.dictCode; oldModel.dictName = entity.dictName; oldModel.comments = entity.comments; oldModel.sortNumber = entity.sortNumber; oldModel.updateTime = DateTime.Now; //事物处理过程结束 var bl = await _sysDictionaryServices.UpdateAsync(oldModel); jm.code = bl ? 0 : 1; jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure; return(new JsonResult(jm)); }
public ActionResult Del(SysDictionary model) { var currentUser = HttpContext.Session[Constants.USER_KEY] as USP.Models.POCO.User; var result = sysDictionaryBll.Delete(model.ID); return(Json(result)); }
public ProcResult Edit(SysDictionary model, long currentOperator) { ProcResult result = new ProcResult(); try { var entity = GetModelById(model.ID); if (entity != null) { entity.Name = model.Name; entity.Type = model.Type; entity.Reserve = model.Reserve; entity.Auditor = model.Auditor; entity.AuditTime = model.AuditTime; entity.Canceler = model.Canceler; entity.CancelTime = model.CancelTime; entity.Remark = model.Remark; entity.Creator = currentOperator; entity.CreateTime = DateTime.Now; } db.Entry <SysDictionary>((SysDictionary)entity).State = System.Data.Entity.EntityState.Modified; result.IsSuccess = db.SaveChanges() > 0; } catch (Exception ex) { result.ProcMsg = ex.InnerException.Message; LogUtil.Exception("ExceptionLogger", ex); } return(result); }
/// <summary> /// 保存数据字典(添加 修改) /// </summary> /// <returns></returns> public JsonResult SaveDictionary(string Type, string Member) { try { SysDictionary model = dbContext.SysDictionary.FirstOrDefault(s => s.Type == Type && s.Member == Member); if (model == null) { model = new SysDictionary(); this.ToModel(model); dbContext.SysDictionary.Add(model); } else { this.ToModel(model); } dbContext.SaveChanges(); return(Json(new { Code = 0, Msg = "保存成功" })); } catch (Exception ex) { LogHelper.SaveLog(ex); return(Json(new { Code = 1, Msg = "服务器异常,请联系管理员!" })); } }
/// <summary> /// 修改 /// </summary> private void updateDictionary() { try { SysDictionary Dictionary = new SysDictionary(); Dictionary.D_Code = D_Code.Text; Dictionary.D_Name = D_Name.Text; Dictionary.D_Type = D_Type.SelectedItem.ToString(); Dictionary.D_Seq = int.Parse(D_Seq.Value.ToString()); Dictionary.D_CreateBy = D_CreateBy.Text; Dictionary.D_CreateDate = D_CreateDate.Value; Dictionary.D_UpdateBy = D_UpdateBy.Text; Dictionary.D_UpdateDate = D_UpdateDate.Value; SysDictionaryBLL Dictionarybll = new SysDictionaryBLL(); if (Dictionarybll.Edit(Dictionary) > 0) { untCommon.InfoMsg("修改成功!"); frmParent.loadData(); } else { untCommon.InfoMsg("修改失败!"); } } catch (Exception ex) { untCommon.ErrorMsg("常规信息管理更新数据异常:" + ex.Message); } }
public async Task <IActionResult> List(string searchContent, string seniorQueryJson, int page = 1, int limit = 10, string sidx = "CreateDt", string sord = "desc") { try { SysDictionary query = null; if (!string.IsNullOrEmpty(seniorQueryJson)) { query = Newtonsoft.Json.JsonConvert.DeserializeObject <SysDictionary>(seniorQueryJson); } System.Linq.Expressions.Expression <Func <SysDictionary, bool> > predicate = ExpressionBuilder.True <SysDictionary>(); predicate = predicate.And(b => b.Id > 0); if (searchContent != null) { predicate = predicate.And(b => b.DictNo.IndexOf(searchContent) != -1 || b.DictName.IndexOf(searchContent) != -1); } if (query.ParentID != null) { predicate = predicate.And(b => b.ParentID == query.ParentID); } PageInfo pageinfo = new PageInfo { }; (List <SysDictionary> list, long count)datas = await SysDictionaryDAL.QueryAsync(predicate, null, pageinfo); var lists = datas.list; return(lists.GetJson <SysDictionary>(sidx, sord, page, limit, SysTool.GetPropertyNameArray <SysDictionary>())); } catch (Exception ex) { throw ex; } }
public HttpResponseMessage Post([FromBody] SysDictionary sysDictionaryInfo) { return(ActionWarpper.Process(sysDictionaryInfo, OperationCodes.ASYSDICT, () => { var repo = RepositoryManager.GetRepository <ISysDictionaryRepository>(); repo.Insert(sysDictionaryInfo); return Request.CreateResponse(HttpStatusCode.OK, sysDictionaryInfo); }, this)); }
public HttpResponseMessage Put(int id, [FromBody] SysDictionary sysDictionaryInfo) { return(ActionWarpper.Process(sysDictionaryInfo, OperationCodes.MSYSDICT, () => { sysDictionaryInfo.DictionaryID = id; var repo = RepositoryManager.GetRepository <ISysDictionaryRepository>(); repo.Update(sysDictionaryInfo); return Request.CreateResponse(HttpStatusCode.OK); }, this)); }
public async Task <JsonResult> DoCreate([FromBody] SysDictionary entity) { var jm = new AdminUiCallBack(); entity.createTime = DateTime.Now; var bl = await _sysDictionaryServices.InsertAsync(entity) > 0; jm.code = bl ? 0 : 1; jm.msg = bl ? GlobalConstVars.CreateSuccess : GlobalConstVars.CreateFailure; return(new JsonResult(jm)); }
public ActionResult Add(SysDictionary model) { var currentUser = HttpContext.Session[Constants.USER_KEY] as USP.Models.POCO.User; model.CreateTime = DateTime.Now; model.Creator = currentUser.SysOperator.ID; AjaxResult result = new AjaxResult(); if (ModelState.IsValid) { result = sysDictionaryBll.Add(model); } return(Json(result)); }
public async Task <IActionResult> Save(SysDictionary model, string columns = "") { var errMsg = GetModelErrMsg(); if (!string.IsNullOrEmpty(errMsg)) { return(ErrRes(errMsg)); } model.Status = model.Status ?? 2; if (string.IsNullOrEmpty(model.SysDictionaryId) || !_unitOfWork.SysDictionaryRepository.Any(o => o.SysDictionaryId == model.SysDictionaryId)) { model.CreateTime = DateTime.Now; model.CreateUser = Id; result = await _unitOfWork.SysDictionaryRepository.InsertAsync(model); if (result) { _logger.LogInformation($"添加{_entityName}{model.SysDictionaryName}"); } } else { //定义可以修改的列 var lstColumn = new List <string>() { nameof(SysDictionary.Remark), nameof(SysDictionary.Sort), nameof(SysDictionary.Status), nameof(SysDictionary.SysDictionaryGroup), nameof(SysDictionary.SysDictionaryName) }; if (!string.IsNullOrEmpty(columns))//固定过滤只修改某字段 { if (lstColumn.Count == 0) { lstColumn = columns.Split(',').ToList(); } else { lstColumn = lstColumn.Where(o => columns.Split(',').Contains(o)).ToList(); } } result = await _unitOfWork.SysDictionaryRepository.UpdateAsync(model, true, lstColumn); if (result) { _logger.LogInformation($"修改{_entityName}{model.SysDictionaryName}"); } } return(result ? SuccessRes() : ErrRes()); }
public ProcResult Add(SysDictionary model) { ProcResult result = new ProcResult(); try { db.SysDictionary.Add(model); result.IsSuccess = db.SaveChanges() > 0; } catch (Exception ex) { result.ProcMsg = ex.InnerException.Message; LogUtil.Exception("ExceptionLogger", ex); } return(result); }
public AjaxResult Edit(SysDictionary model, long @operator) { AjaxResult result = new AjaxResult(); var procResult = dal.Edit(model, @operator); result.flag = procResult.IsSuccess; if (result.flag) { result.message = "修改成功!"; } else { result.message = procResult.ProcMsg; } return(result); }
public AjaxResult Add(SysDictionary model) { AjaxResult result = new AjaxResult(); var procResult = dal.Add(model); result.flag = procResult.IsSuccess; if (result.flag) { result.message = "新增成功!"; } else { result.message = procResult.ProcMsg; } return(result); }
public virtual IHttpActionResult Disable(SysDictionaryDisableRequest request) { var entity = new SysDictionary { Id = request.Id, }; var result = _sysDictionaryService.Disable(request.Id); if (result > 0) { return(Succeed("禁用成功")); } else { return(Fail("禁用失败")); } }
public async Task <ActionResult> Update([FromBody] SysDictionary model) { var resdata = await AutoException.Excute <SysDictionary>(async (result) => { model.UpdateBy = "admin"; model.UpdateDt = DateTime.Now; model.Status = 1; var res = await SysDictionaryDAL.UpdateAsync(model); result.Data = model; if (!res) { throw new Exception("数据修改异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model)); } }, false); return(Json(resdata)); }
public async Task <ActionResult> Create([FromBody] SysDictionary model) { var resdata = await AutoException.Excute <long>(async (result) => { model.CreateBy = "admin"; model.CreateDt = DateTime.Now; model.Status = 1; model.ParentID = model.ParentID == null ? 0 : model.ParentID; result.Data = await SysDictionaryDAL.InsertAsync(model); if (result.Data == 0) { throw new Exception("数据新增异常,JSON:" + Newtonsoft.Json.JsonConvert.SerializeObject(model)); } }, false); return(Json(resdata)); }
public async Task <ActionResult> CreateModule(string id, string parentid = "") { (List <SysDictionary> list, long count)dictionary = await new SysDictionaryDAL().QueryAsync(w => w.Status == 1); ViewBag.SysDictionaryList = dictionary.list.Select(s => new SelectListItem { Text = s.DictName, Value = s.Id.ToString() }).ToList(); SysDictionary model = new SysDictionary() { Status = 1 }; if (!string.IsNullOrEmpty(parentid)) { model.ParentID = Convert.ToInt32(parentid); } return(View(model)); }
public async Task <ActionResult> UpdateModule(string id) { (List <SysDictionary> list, long count)dictionary = await new SysDictionaryDAL().QueryAsync(w => w.Status == 1); ViewBag.SysDictionaryList = dictionary.list.Select(s => new SelectListItem { Text = s.DictName, Value = s.Id.ToString() }).ToList(); SysDictionary model = new SysDictionary() { }; if (!string.IsNullOrEmpty(id) && id != "0") { int _id = Convert.ToInt32(id); model = await SysDictionaryDAL.GetByOneAsync(w => w.Id == _id); } return(View(model)); }
public virtual IHttpActionResult Add(SysDictionaryAddRequest request) { var entity = new SysDictionary { }; var result = _sysDictionaryService.Add(entity); if (result > 0) { return(Succeed(new SysDictionaryAddResponse { Id = entity.Id }, "新增成功")); } else { return(Fail("新增失败")); } }
/// <summary> /// 添加 /// </summary> private void addDictionary() { try { if (checkInput()) { SysDictionary Dictionary = new SysDictionary(); Dictionary.D_Code = D_Code.Text; Dictionary.D_Name = D_Name.Text; Dictionary.D_Type = D_Type.SelectedItem.ToString(); Dictionary.D_Seq = int.Parse(D_Seq.Value.ToString()); Dictionary.D_CreateBy = D_CreateBy.Text; Dictionary.D_CreateDate = D_CreateDate.Value; Dictionary.D_UpdateBy = null; Dictionary.D_UpdateDate = null; SysDictionaryBLL Dictionarybll = new SysDictionaryBLL(); if (Dictionarybll.Exists(Dictionary.D_Code)) { untCommon.InfoMsg("信息编码已存在!"); } else { if (Dictionarybll.Add(Dictionary) > 0) { untCommon.InfoMsg("添加成功!"); frmParent.loadData(); } else { untCommon.InfoMsg("添加失败!"); } } } } catch (Exception ex) { untCommon.ErrorMsg("常规信息管理添加数据异常:" + ex.Message); } }
public ActionResultVM SaveSysDictionary(SysDictionary mo, string savetype) { var vm = new ActionResultVM(); if (savetype == "add") { mo.SdId = Guid.NewGuid().ToString(); mo.SdPid = Guid.Empty.ToString(); db.SysDictionary.Add(mo); } else { db.SysDictionary.Update(mo); } int num = db.SaveChanges(); vm.Set(num > 0); return(vm); }
private void getDetail() { try { SysDictionaryBLL Dictionarybll = new SysDictionaryBLL(); SysDictionary Dictionary = Dictionarybll.getDetail(PrimaryKey); D_Code.Text = Dictionary.D_Code; D_Name.Text = Dictionary.D_Name; D_Type.SelectedItem = Dictionary.D_Type; D_Seq.Value = Dictionary.D_Seq; D_CreateBy.Text = Dictionary.D_CreateBy; D_UpdateBy.Text = Dictionary.D_UpdateBy; if (Dictionary.D_CreateDate.HasValue) { D_CreateDate.Value = Dictionary.D_CreateDate.Value; } else { D_CreateDate.Value = DateTime.Now; } if (Dictionary.D_UpdateDate.HasValue) { D_UpdateDate.Value = Dictionary.D_UpdateDate.Value; } else { D_UpdateDate.Value = DateTime.Now; ; } } catch (Exception ex) { untCommon.ErrorMsg("信息管理加载数据异常:" + ex.Message); } }
public ProcResult Auditor(SysDictionary model, long auditor) { ProcResult result = new ProcResult(); try { var entity = GetModelById(model.ID); if (entity != null) { entity.Auditor = auditor; entity.AuditTime = DateTime.Now; entity.Creator = auditor; } db.Entry <SysDictionary>((SysDictionary)entity).State = System.Data.Entity.EntityState.Modified; result.IsSuccess = db.SaveChanges() > 0; } catch (Exception ex) { result.ProcMsg = ex.InnerException.Message; LogUtil.Exception("ExceptionLogger", ex); } return(result); }
public string RealAmountForWeekToLine(string id) { DataSet ds = new DataSet(); var data = FindSqlToJson(string.Format(@"SET DATEFIRST 1 SELECT datename(weekday, SettlementTime) as SettlementTime,SUM(RealAmount) as count FROM Fin_Info WHERE IsSettlement=1 and MemberId='{0}' and (DATEPART(week, SettlementTime) = DATEPART(week, GETDATE())) AND(DATEPART(yy, SettlementTime) = DATEPART(yy, GETDATE())) group by datename(weekday, SettlementTime) order by SettlementTime desc", id)); DataTable dt = Common.JsonConverter.JsonToDataTable(data); if (dt != null) { dt.TableName = "本周收益统计图"; ds.Tables.Add(dt.Copy()); return(EchartsHelp.EchartJsonToMultipleBar(ds, SysDictionary.GetWeek(), "SettlementTime", "count")); } DataColumn dc3 = new DataColumn("count", Type.GetType("System.Int16")); DataColumn dc5 = new DataColumn("SettlementTime", Type.GetType("System.String")); DataTable dt1 = new DataTable(); dt1.Columns.Add(dc3); dt1.Columns.Add(dc5); dt1.TableName = "本周收益统计图"; ds.Tables.Add(dt1.Copy()); return(EchartsHelp.EchartJsonToMultipleBar(ds, SysDictionary.GetWeek(), "SettlementTime", "count")); }
public int Add(SysDictionary Dictionary) { try { string sql = @"INSERT INTO [Sys_Dictionary] ([D_Code] ,[D_Name] ,[D_Type] ,[D_Seq] ,[D_CreateBy] ,[D_CreateDate] ,[D_UpdateBy] ,[D_UpdateDate]) VALUES (@D_Code ,@D_Name ,@D_Type ,@D_Seq ,@D_CreateBy ,@D_CreateDate ,@D_UpdateBy ,@D_UpdateDate)"; List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(new SqlParameter("@D_Code", Dictionary.D_Code)); parameters.Add(new SqlParameter("@D_Name", Dictionary.D_Name)); parameters.Add(new SqlParameter("@D_Type", Dictionary.D_Type)); parameters.Add(new SqlParameter("@D_Seq", Dictionary.D_Seq)); if (!string.IsNullOrEmpty(Dictionary.D_CreateBy)) { parameters.Add(new SqlParameter("@D_CreateBy", Dictionary.D_CreateBy)); } else { parameters.Add(new SqlParameter("@D_CreateBy", DBNull.Value)); } if (!string.IsNullOrEmpty(Dictionary.D_UpdateBy)) { parameters.Add(new SqlParameter("@D_UpdateBy", Dictionary.D_UpdateBy)); } else { parameters.Add(new SqlParameter("@D_UpdateBy", DBNull.Value)); } if (Dictionary.D_CreateDate.HasValue) { parameters.Add(new SqlParameter("@D_CreateDate", Dictionary.D_CreateDate)); } else { parameters.Add(new SqlParameter("@D_CreateDate", DBNull.Value)); } if (!Dictionary.D_UpdateDate.HasValue) { parameters.Add(new SqlParameter("@D_UpdateDate", Dictionary.D_UpdateDate)); } else { parameters.Add(new SqlParameter("@D_UpdateDate", DBNull.Value)); } SqlHelper db = new SqlHelper(); var row = db.ExecuteNonQuery(sql, parameters.ToArray()); return(row); } catch (Exception) { throw; } }
protected override void Seed(RepositoryDbContext dbContext) { var domain = new Domain { Id = Guid.Parse("DB07AB5E-A23F-4238-94CE-D52411199C18"), DomainName = "Root", DomianType = DomainType.RootDomain, CreateDateTime = DateTime.Now, DomainStatus = DomainStatus.Enabled, IsEnabled = true }; var user = new WdUser { Id = Guid.Parse("77F05B52-AE62-4225-9F09-153C5634031F"), UserName = "******", LoginName = "Root", Password = "******", Email = "*****@*****.**", Telephone = "18679361687", Status = UserStatus.Enabled, CreateDateTime = DateTime.Now, DomainId = domain.Id, Roles = new List <WdRole>(), IsEnabled = true }; var commUser = new WdUser() { Id = Guid.Parse("c8c95a88-5d5d-4e80-a2d6-3ff32d472bde"), UserName = "******", LoginName = "CommnicationServer", Password = "******", Email = "*****@*****.**", Telephone = "18679361687", Status = UserStatus.Enabled, CreateDateTime = DateTime.Now, DomainId = domain.Id, Roles = new List <WdRole>(), IsEnabled = true }; var role = new WdRole { Id = Guid.Parse("650BFB4C-7277-484A-812E-6052F6DB71C7"), RoleName = "Root", Users = new List <WdUser>(), CreateDateTime = DateTime.Now, Status = RoleStatus.Enabled, CreateUserId = user.Id, DomainId = domain.Id, IsEnabled = true }; var adminRole = new WdRole() { Id = Guid.Parse("fce321ca-8761-44c4-8204-546dfa6134e1"), RoleName = "Admin", Users = new List <WdUser>(), CreateDateTime = DateTime.Now, Status = RoleStatus.Enabled, CreateUserId = user.Id, DomainId = domain.Id, IsEnabled = true }; var serverRole = new WdRole() { Id = Guid.Parse("a45ae4cd-d0ad-4cea-b666-6787a42b2b4d"), RoleName = "Server", Users = new List <WdUser>(), CreateDateTime = DateTime.Now, Status = RoleStatus.Enabled, CreateUserId = user.Id, DomainId = domain.Id, IsEnabled = true }; user.CreateUserId = user.Id; user.LastUpdateUserId = user.Id; user.LastUpdateDateTime = DateTime.Now; user.LastLoginDateTime = DateTime.Now; commUser.CreateUserId = user.Id; commUser.LastUpdateUserId = user.Id; commUser.LastUpdateDateTime = DateTime.Now; commUser.LastLoginDateTime = DateTime.Now; domain.CreateUserId = user.Id; domain.LastUpdateUserId = user.Id; domain.LastUpdateDateTime = DateTime.Now; role.CreateUserId = user.Id; role.LastUpdateUserId = user.Id; role.LastUpdateDateTime = DateTime.Now; adminRole.CreateUserId = user.Id; adminRole.LastUpdateUserId = user.Id; adminRole.LastUpdateDateTime = DateTime.Now; serverRole.CreateUserId = user.Id; serverRole.LastUpdateUserId = user.Id; serverRole.LastUpdateDateTime = DateTime.Now; user.Roles.Add(role); role.Users.Add(user); commUser.Roles.Add(serverRole); serverRole.Users.Add(commUser); dbContext.Users.Add(user); dbContext.Users.Add(commUser); dbContext.Roles.Add(role); dbContext.Roles.Add(adminRole); dbContext.Roles.Add(serverRole); dbContext.SysDomains.Add(domain); var field = new SysDictionary { Id = Guid.Parse("7402cdb5-1e1e-4633-a7e9-7d6d15634fc0"), ItemName = "Field", ItemKey = "7E0384B37CFJ", ItemValue = "GpsCommunication", ItemLevel = 1, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true }; var subfield = new SysDictionary { Id = Guid.Parse("24ae6ee7-a024-4052-a1de-3cc0d542d908"), ParentDictionaryId = field.Id, ItemName = "Subield", ItemKey = "7E0384B37CFL", ItemValue = "GeneralFunction", ItemLevel = 1, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true }; dbContext.SysDictionaries.Add(field); dbContext.SysDictionaries.Add(subfield); var deviceType = new DeviceType { Id = Guid.Parse("31b9ae77-6f5b-4c70-b180-d80ecb7df12b"), Field = field, SubField = subfield, Version = "2016-03-17", ReleaseDateTime = DateTime.Now, DeviceTypeCode = "WD_YC_Classic", CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true }; var firma = new Firmware { Id = Guid.Parse("648892a9-bf37-4490-a947-e1c0a529bba1"), FirmwareName = "firma", CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateUserId = user.Id, LastUpdateDateTime = DateTime.Now, Protocols = new List <Protocol>() }; dbContext.Firmwares.Add(firma); var firmSet = new FirmwareSet { Id = Guid.Parse("6c36fddf-d3d9-416b-84df-cd849006eef1"), FirmwareSetName = "扬尘第三版", CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true }; firmSet.Firmwares.Add(firma); dbContext.FirmwareSets.Add(firmSet); dbContext.DeviceTypes.Add(deviceType); var nep = new Protocol { Id = Guid.Parse("f59022bc-6f8c-4ced-954f-3a6d7dd29335"), FieldId = field.Id, SubFieldId = subfield.Id, CustomerInfo = "1", ProtocolName = "Nep", ProtocolModule = "Nep", Version = "HT212", ReleaseDateTime = DateTime.Now, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, CheckType = ProtocolCheckType.CrcModBus, Head = new byte[] { 0x23, 0x23 }, Tail = new byte[] { 0x0D, 0x0A } }; firma.Protocols.Add(nep); var head = new ProtocolStructure { Id = Guid.Parse("2bb54221-f036-48ff-babc-22358bdf50e2"), ProtocolId = nep.Id, StructureName = "Head", StructureIndex = 0, StructureDataLength = 2, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.AsciiString, DefaultBytes = new byte[] { 0x23, 0x23 } }; var contentLength = new ProtocolStructure { Id = Guid.Parse("277211ee-4ee9-4ef3-ab95-c43fce4c395b"), ProtocolId = nep.Id, StructureName = "ContentLength", StructureIndex = 1, StructureDataLength = 4, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.AsciiString, DefaultBytes = new byte[0] }; var requestNumber = new ProtocolStructure { Id = Guid.Parse("e64862bb-1427-45e6-9dda-ec7925963573"), ProtocolId = nep.Id, StructureName = "RequestNumber", StructureIndex = 2, StructureDataLength = 21, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.AsciiString, DefaultBytes = new byte[0] }; var cmdtype = new ProtocolStructure { Id = Guid.Parse("dcdb914f-62ec-42dc-bece-04124cfd61fa"), ProtocolId = nep.Id, StructureName = "CmdType", StructureIndex = 3, StructureDataLength = 6, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.AsciiString, DefaultBytes = new byte[0] }; var cmdbyte = new ProtocolStructure { Id = Guid.Parse("fa009ac1-8a08-4243-a143-eb7cb8942660"), ProtocolId = nep.Id, StructureName = "CmdByte", StructureIndex = 4, StructureDataLength = 8, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.AsciiString, DefaultBytes = new byte[0] }; var password = new ProtocolStructure() { Id = Guid.Parse("eddaa794-088a-4cc0-8c8e-b09635ba249a"), ProtocolId = nep.Id, StructureName = "Password", StructureIndex = 5, StructureDataLength = 10, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.AsciiString, DefaultBytes = new byte[] { 0x50, 0x57, 0x3D, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x3B } }; var nodeid = new ProtocolStructure() { Id = Guid.Parse("ff20af2c-8f93-4755-889f-e8943c023e7d"), ProtocolId = nep.Id, StructureName = "NodeId", StructureIndex = 6, StructureDataLength = 18, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.AsciiString, DefaultBytes = new byte[0] }; var data = new ProtocolStructure() { Id = Guid.Parse("4cde87be-468c-46cf-a1f9-0172f21761ca"), ProtocolId = nep.Id, StructureName = "Data", StructureIndex = 7, StructureDataLength = 0, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.Data, DefaultBytes = new byte[0] }; var crcModBus = new ProtocolStructure() { Id = Guid.Parse("1bd5725a-0408-4c4a-b7ad-f2c92dd830e2"), ProtocolId = nep.Id, StructureName = "CrcModBus", StructureIndex = 8, StructureDataLength = 4, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.CrcModBus, DefaultBytes = new byte[] { 0x00, 0x00, 0x00, 0x00 } }; var tail = new ProtocolStructure() { Id = Guid.Parse("6aea3080-bb97-4e50-8140-7c31728b1637"), ProtocolId = nep.Id, StructureName = "Tail", StructureIndex = 9, StructureDataLength = 2, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.AsciiString, DefaultBytes = new byte[] { 0x0D, 0x0A } }; dbContext.ProtocolStructures.Add(head); dbContext.ProtocolStructures.Add(cmdtype); dbContext.ProtocolStructures.Add(cmdbyte); dbContext.ProtocolStructures.Add(password); dbContext.ProtocolStructures.Add(nodeid); dbContext.ProtocolStructures.Add(contentLength); dbContext.ProtocolStructures.Add(requestNumber); dbContext.ProtocolStructures.Add(data); dbContext.ProtocolStructures.Add(crcModBus); dbContext.ProtocolStructures.Add(tail); var commandReplyA = new SysConfig() { Id = Guid.Parse("b06c49c1-f9f7-4e69-92df-04fa55f95045"), SysConfigName = ProtocolDeliveryParam.StoreData, SysConfigType = SysConfigType.ProtocolDeliveryParam, SysConfigValue = ProtocolDeliveryParam.StoreData, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; dbContext.SysConfigs.Add(commandReplyA); var command = new ProtocolCommand { Id = Guid.Parse("d2ccf8b0-ed68-48ef-b185-f94b504944ca"), CommandTypeCode = new byte[] { 0x32, 0x32 }, CommandCode = new byte[] { 0x32, 0x30, 0x31, 0x31 }, ReceiveBytesLength = 0, CommandCategory = CommandCategory.TimingAutoReport, DataOrderType = DataOrderType.Random, ProtocolId = nep.Id, CommandDeliverParamConfigs = new List <SysConfig> { commandReplyA }, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var commandA = new ProtocolCommand { Id = Guid.Parse("ec4260ba-b36d-40ab-b357-15345590f516"), CommandTypeCode = new byte[] { 0x32, 0x32 }, CommandCode = new byte[] { 0x32, 0x30, 0x31, 0x31 }, ReceiveBytesLength = 0, CommandCategory = CommandCategory.TimingAutoReport, DataOrderType = DataOrderType.Random, ProtocolId = nep.Id, CommandDeliverParamConfigs = new List <SysConfig> { commandReplyA }, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var commandB = new ProtocolCommand { Id = Guid.Parse("9fbc1163-abf1-4f49-9bb6-64bec7946670"), CommandTypeCode = new byte[] { 0x32, 0x32 }, CommandCode = new byte[] { 0x32, 0x30, 0x31, 0x31 }, ReceiveBytesLength = 0, CommandCategory = CommandCategory.TimingAutoReport, DataOrderType = DataOrderType.Random, ProtocolId = nep.Id, CommandDeliverParamConfigs = new List <SysConfig> { commandReplyA }, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var tsp = new CommandData { Id = Guid.NewGuid(), DataIndex = 0, DataLength = 0, DataName = "a34001-Avg", DataDisplayName = "粉尘", DataConvertType = "DoubleString", DataValueType = DataValueType.Double, DataFlag = 0x00, ValidFlagIndex = 0, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var pm25 = new CommandData { Id = Guid.NewGuid(), DataIndex = 0, DataLength = 0, DataName = "a34004-Avg", DataDisplayName = "PM2.5", DataConvertType = "DoubleString", DataValueType = DataValueType.Double, DataFlag = 0x00, ValidFlagIndex = 0, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var pm100 = new CommandData { Id = Guid.NewGuid(), DataIndex = 0, DataLength = 0, DataName = "a34005-Avg", DataDisplayName = "PM10", DataConvertType = "DoubleString", DataValueType = DataValueType.Double, DataFlag = 0x00, ValidFlagIndex = 0, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var noise = new CommandData { Id = Guid.NewGuid(), DataIndex = 0, DataLength = 0, DataName = "a50001-Avg", DataDisplayName = "噪音", DataConvertType = "DoubleString", DataValueType = DataValueType.Double, DataFlag = 0x00, ValidFlagIndex = 0, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var temp = new CommandData { Id = Guid.NewGuid(), DataIndex = 0, DataLength = 0, DataName = "a01001-Avg", DataDisplayName = "温度", DataConvertType = "DoubleString", DataValueType = DataValueType.Double, DataFlag = 0x00, ValidFlagIndex = 0, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var huma = new CommandData { Id = Guid.NewGuid(), DataIndex = 0, DataLength = 0, DataName = "a01002-Avg", DataDisplayName = "湿度", DataConvertType = "DoubleString", DataValueType = DataValueType.Double, DataFlag = 0x00, ValidFlagIndex = 0, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var windspeed = new CommandData { Id = Guid.NewGuid(), DataIndex = 0, DataLength = 0, DataName = "a01007-Avg", DataDisplayName = "风速", DataConvertType = "DoubleString", DataValueType = DataValueType.Double, DataFlag = 0x00, ValidFlagIndex = 0, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var winddir = new CommandData { Id = Guid.NewGuid(), DataIndex = 0, DataLength = 0, DataName = "a01008-Avg", DataDisplayName = "风向", DataConvertType = "DoubleString", DataValueType = DataValueType.Double, DataFlag = 0x00, ValidFlagIndex = 0, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; command.CommandDatas = new List <CommandData> { tsp, pm25, pm100, noise, temp, huma, windspeed, winddir }; commandA.CommandDatas = new List <CommandData> { tsp, pm25, pm100, noise, temp, huma, windspeed, winddir }; commandB.CommandDatas = new List <CommandData> { tsp, pm25, pm100, noise, temp, huma, windspeed, winddir }; dbContext.ProtocolCommands.Add(command); dbContext.ProtocolCommands.Add(commandA); dbContext.ProtocolCommands.Add(commandB); var dev = new Device() { Id = Guid.NewGuid(), DeviceTypeId = deviceType.Id, DeviceCode = "扬尘硬件第三版测试一号", DevicePassword = string.Empty, DeviceModuleGuid = Guid.NewGuid(), DeviceNodeId = "KSHBZBWCOM0001", FirmwareSetId = firmSet.Id, StartTime = DateTime.Now, PreEndTime = DateTime.Now, EndTime = DateTime.Now, Status = DeviceStatus.Enabled, DomainId = domain.Id, CreateUserId = user.Id, CreateDateTime = DateTime.Now, IsEnabled = true }; dbContext.Devices.Add(dev); }
protected override void Seed(RepositoryDbContext dbContext) { var domain = new Domain { Id = Guid.Parse("DB07AB5E-A23F-4238-94CE-D52411199C18"), DomainName = "Root", DomianType = DomainType.RootDomain, CreateDateTime = DateTime.Now, DomainStatus = DomainStatus.Enabled, IsEnabled = true }; var user = new WdUser { Id = Guid.Parse("77F05B52-AE62-4225-9F09-153C5634031F"), UserName = "******", LoginName = "Root", Password = "******", Email = "*****@*****.**", Telephone = "18679361687", Status = UserStatus.Enabled, CreateDateTime = DateTime.Now, DomainId = domain.Id, Roles = new List <WdRole>(), IsEnabled = true }; var commUser = new WdUser() { Id = Guid.Parse("c8c95a88-5d5d-4e80-a2d6-3ff32d472bde"), UserName = "******", LoginName = "CommnicationServer", Password = "******", Email = "*****@*****.**", Telephone = "18679361687", Status = UserStatus.Enabled, CreateDateTime = DateTime.Now, DomainId = domain.Id, Roles = new List <WdRole>(), IsEnabled = true }; var role = new WdRole { Id = Guid.Parse("650BFB4C-7277-484A-812E-6052F6DB71C7"), RoleName = "Root", Users = new List <WdUser>(), CreateDateTime = DateTime.Now, Status = RoleStatus.Enabled, CreateUserId = user.Id, DomainId = domain.Id, IsEnabled = true }; var adminRole = new WdRole() { Id = Guid.Parse("fce321ca-8761-44c4-8204-546dfa6134e1"), RoleName = "Admin", Users = new List <WdUser>(), CreateDateTime = DateTime.Now, Status = RoleStatus.Enabled, CreateUserId = user.Id, DomainId = domain.Id, IsEnabled = true }; var serverRole = new WdRole() { Id = Guid.Parse("a45ae4cd-d0ad-4cea-b666-6787a42b2b4d"), RoleName = "Server", Users = new List <WdUser>(), CreateDateTime = DateTime.Now, Status = RoleStatus.Enabled, CreateUserId = user.Id, DomainId = domain.Id, IsEnabled = true }; user.CreateUserId = user.Id; user.LastUpdateUserId = user.Id; user.LastUpdateDateTime = DateTime.Now; user.LastLoginDateTime = DateTime.Now; commUser.CreateUserId = user.Id; commUser.LastUpdateUserId = user.Id; commUser.LastUpdateDateTime = DateTime.Now; commUser.LastLoginDateTime = DateTime.Now; domain.CreateUserId = user.Id; domain.LastUpdateUserId = user.Id; domain.LastUpdateDateTime = DateTime.Now; role.CreateUserId = user.Id; role.LastUpdateUserId = user.Id; role.LastUpdateDateTime = DateTime.Now; adminRole.CreateUserId = user.Id; adminRole.LastUpdateUserId = user.Id; adminRole.LastUpdateDateTime = DateTime.Now; serverRole.CreateUserId = user.Id; serverRole.LastUpdateUserId = user.Id; serverRole.LastUpdateDateTime = DateTime.Now; user.Roles.Add(role); role.Users.Add(user); commUser.Roles.Add(serverRole); serverRole.Users.Add(commUser); dbContext.Users.Add(user); dbContext.Users.Add(commUser); dbContext.Roles.Add(role); dbContext.Roles.Add(adminRole); dbContext.Roles.Add(serverRole); dbContext.SysDomains.Add(domain); var field = new SysDictionary { Id = Guid.Parse("7402cdb5-1e1e-4633-a7e9-7d6d15634fc0"), ItemName = "Field", ItemKey = "7E0384B37CFJ", ItemValue = "GpsCommunication", ItemLevel = 1, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true }; var subfield = new SysDictionary { Id = Guid.Parse("24ae6ee7-a024-4052-a1de-3cc0d542d908"), ParentDictionaryId = field.Id, ItemName = "Subield", ItemKey = "7E0384B37CFL", ItemValue = "GeneralFunction", ItemLevel = 1, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true }; dbContext.SysDictionaries.Add(field); dbContext.SysDictionaries.Add(subfield); var deviceType = new DeviceType { Id = Guid.Parse("31b9ae77-6f5b-4c70-b180-d80ecb7df12b"), Field = field, SubField = subfield, Version = "2016-03-17", ReleaseDateTime = DateTime.Now, DeviceTypeCode = "WD_YC_Classic", CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true }; var firma = new Firmware { Id = Guid.Parse("648892a9-bf37-4490-a947-e1c0a529bba1"), FirmwareName = "firma", CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateUserId = user.Id, LastUpdateDateTime = DateTime.Now, Protocols = new List <Protocol>() }; dbContext.Firmwares.Add(firma); var firmSet = new FirmwareSet { Id = Guid.Parse("6c36fddf-d3d9-416b-84df-cd849006eef1"), FirmwareSetName = "扬尘第三版", CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true }; firmSet.Firmwares.Add(firma); dbContext.FirmwareSets.Add(firmSet); dbContext.DeviceTypes.Add(deviceType); var classic = new Protocol { Id = Guid.Parse("f59022bc-6f8c-4ced-954f-3a6d7dd29335"), FieldId = field.Id, SubFieldId = subfield.Id, CustomerInfo = "1", ProtocolName = "Classic", ProtocolModule = "Classic", Version = "Dust Protocol Brief V0017", ReleaseDateTime = DateTime.Now, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, CheckType = ProtocolCheckType.Crc16, Head = new byte[] { 0xAA }, Tail = new byte[] { 0xDD } }; firma.Protocols.Add(classic); var head = new ProtocolStructure { Id = Guid.Parse("2bb54221-f036-48ff-babc-22358bdf50e2"), ProtocolId = classic.Id, StructureName = "Head", StructureIndex = 0, StructureDataLength = 1, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.SingleByte, DefaultBytes = new byte[] { 0xAA } }; var cmdtype = new ProtocolStructure { Id = Guid.Parse("dcdb914f-62ec-42dc-bece-04124cfd61fa"), ProtocolId = classic.Id, StructureName = "CmdType", StructureIndex = 1, StructureDataLength = 1, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.SingleByte, DefaultBytes = new byte[0] }; var cmdbyte = new ProtocolStructure { Id = Guid.Parse("fa009ac1-8a08-4243-a143-eb7cb8942660"), ProtocolId = classic.Id, StructureName = "CmdByte", StructureIndex = 2, StructureDataLength = 1, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.SingleByte, DefaultBytes = new byte[0] }; var password = new ProtocolStructure() { Id = Guid.Parse("eddaa794-088a-4cc0-8c8e-b09635ba249a"), ProtocolId = classic.Id, StructureName = "Password", StructureIndex = 3, StructureDataLength = 8, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.NumPassword, DefaultBytes = new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38 } }; var nodeid = new ProtocolStructure() { Id = Guid.Parse("ff20af2c-8f93-4755-889f-e8943c023e7d"), ProtocolId = classic.Id, StructureName = "NodeId", StructureIndex = 4, StructureDataLength = 4, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.NodeId, DefaultBytes = new byte[0] }; var descrip = new ProtocolStructure() { Id = Guid.Parse("92006a07-3726-4cdc-99a4-7b3fdf7ef03d"), ProtocolId = classic.Id, StructureName = "Description", StructureIndex = 5, StructureDataLength = 12, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.Description, DefaultBytes = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }; var sourceaddr = new ProtocolStructure() { Id = Guid.Parse("9ccdffd7-7d22-43d1-9185-a58541ce87f8"), ProtocolId = classic.Id, StructureName = "SourceAddr", StructureIndex = 6, StructureDataLength = 1, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.SourceAddr, DefaultBytes = new byte[] { 0x01 } }; var destination = new ProtocolStructure() { Id = Guid.Parse("20ddc634-6ce6-47cc-82e1-c3df8f68abaa"), ProtocolId = classic.Id, StructureName = "DestinationAddr", StructureIndex = 7, StructureDataLength = 1, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.Destination, DefaultBytes = new byte[] { 0x01 } }; var datalength = new ProtocolStructure() { Id = Guid.Parse("ad465018-24d3-400d-b7d5-712abf54ceeb"), ProtocolId = classic.Id, StructureName = "PayloadLength", StructureIndex = 8, StructureDataLength = 2, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.DataLength, DefaultBytes = new byte[] { 0x00, 0x00 } }; var data = new ProtocolStructure() { Id = Guid.Parse("4cde87be-468c-46cf-a1f9-0172f21761ca"), ProtocolId = classic.Id, StructureName = "Data", StructureIndex = 9, StructureDataLength = 0, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.Data, DefaultBytes = new byte[0] }; var crc = new ProtocolStructure() { Id = Guid.Parse("1bd5725a-0408-4c4a-b7ad-f2c92dd830e2"), ProtocolId = classic.Id, StructureName = "CRCValue", StructureIndex = 10, StructureDataLength = 2, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.CRC, DefaultBytes = new byte[] { 0x00, 0x00 } }; var tail = new ProtocolStructure() { Id = Guid.Parse("6aea3080-bb97-4e50-8140-7c31728b1637"), ProtocolId = classic.Id, StructureName = "Tail", StructureIndex = 11, StructureDataLength = 1, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.SingleByte, DefaultBytes = new byte[] { 0xDD } }; dbContext.ProtocolStructures.Add(head); dbContext.ProtocolStructures.Add(cmdtype); dbContext.ProtocolStructures.Add(cmdbyte); dbContext.ProtocolStructures.Add(password); dbContext.ProtocolStructures.Add(nodeid); dbContext.ProtocolStructures.Add(descrip); dbContext.ProtocolStructures.Add(sourceaddr); dbContext.ProtocolStructures.Add(destination); dbContext.ProtocolStructures.Add(datalength); dbContext.ProtocolStructures.Add(data); dbContext.ProtocolStructures.Add(crc); dbContext.ProtocolStructures.Add(tail); var commandReply = new SysConfig() { Id = Guid.Parse("6ca98eba-47df-45c3-9bfb-1b56865b0a11"), SysConfigName = ProtocolDeliveryParam.ReplyOriginal, SysConfigType = SysConfigType.ProtocolDeliveryParam, SysConfigValue = ProtocolDeliveryParam.ReplyOriginal, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var commandReplyA = new SysConfig() { Id = Guid.Parse("b06c49c1-f9f7-4e69-92df-04fa55f95045"), SysConfigName = ProtocolDeliveryParam.StoreData, SysConfigType = SysConfigType.ProtocolDeliveryParam, SysConfigValue = ProtocolDeliveryParam.StoreData, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var messageSource = new SysConfig { Id = Guid.Parse("34EDC4EC-F046-418E-A9DC-9EA3EA284F84"), SysConfigName = "CommandMessageQueueName", SysConfigType = SysConfigType.ProtocolAdminTools, SysConfigValue = @"FormatName:Direct=TCP:121.40.49.97\private$\protocolcommand", CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; dbContext.SysConfigs.Add(commandReply); dbContext.SysConfigs.Add(commandReplyA); dbContext.SysConfigs.Add(messageSource); var commandDataA = new CommandData() { Id = Guid.Parse("46225dc9-ffe2-43af-bba4-7b45bbb55af2"), DataIndex = 0, DataLength = 2, DataName = ProtocolDataName.DataValidFlag, DataConvertType = ProtocolDataType.TwoBytesToUShort, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var commandDataB = new CommandData() { Id = Guid.Parse("489287c6-e179-4864-bd02-7f8962d5e81c"), DataIndex = 1, DataLength = 4, DataName = "PM2.5", DataConvertType = ProtocolDataType.FourBytesToUInt32, ValidFlagIndex = 1, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var commandDataC = new CommandData() { Id = Guid.Parse("b69c75a5-c813-42a6-a3a6-5eeef561c068"), DataIndex = 2, DataLength = 4, DataName = "PM10", DataConvertType = ProtocolDataType.FourBytesToUInt32, ValidFlagIndex = 1, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var commandDataD = new CommandData() { Id = Guid.Parse("36b4d5eb-b141-4cfd-9df5-d4508103fbbf"), DataIndex = 3, DataLength = 4, DataName = "CPM", DataConvertType = ProtocolDataType.FourBytesToUInt32, ValidFlagIndex = 2, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var commandDataE = new CommandData() { Id = Guid.Parse("57874a4a-9a91-42dd-86de-e8940ad92c10"), DataIndex = 4, DataLength = 2, DataName = "噪音值", DataConvertType = ProtocolDataType.TwoBytesToDoubleSeparate, ValidFlagIndex = 3, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var commandDataF = new CommandData() { Id = Guid.Parse("7e175d64-be72-48ed-baf2-549f80c27319"), DataIndex = 5, DataLength = 3, DataName = "风向", DataConvertType = ProtocolDataType.ThreeBytesToUShort, ValidFlagIndex = 4, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var commandDataG = new CommandData() { Id = Guid.Parse("0c9124b1-168d-4510-bd8b-1acd183895a3"), DataIndex = 6, DataLength = 3, DataName = "风速", DataConvertType = ProtocolDataType.ThreeBytesToUShort, ValidFlagIndex = 5, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var commandDataH = new CommandData() { Id = Guid.Parse("dc8815aa-0203-4c82-a09a-73521bcf208b"), DataIndex = 7, DataLength = 2, DataName = "温度", DataConvertType = ProtocolDataType.TwoBytesToDoubleSeparate, ValidFlagIndex = 6, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var commandDataI = new CommandData() { Id = Guid.Parse("1ff2c99a-e0af-4419-80f6-53e69574d2c4"), DataIndex = 8, DataLength = 2, DataName = "湿度", DataConvertType = ProtocolDataType.TwoBytesToDoubleSeparate, ValidFlagIndex = 6, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var commandDataJ = new CommandData() { Id = Guid.Parse("d24a7c0b-05f1-4a3f-b82c-6a5615ccdfc5"), DataIndex = 9, DataLength = 4, DataName = "挥发性有机物", DataConvertType = ProtocolDataType.FourBytesToUInt32, ValidFlagIndex = 7, CreateDateTime = DateTime.Now, CreateUserId = user.Id, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var command = new ProtocolCommand { Id = Guid.Parse("d2ccf8b0-ed68-48ef-b185-f94b504944ca"), CommandTypeCode = new byte[] { 0xF9 }, CommandCode = new byte[] { 0x1F }, ReceiveBytesLength = 0, CommandCategory = CommandCategory.HeartBeat, ProtocolId = classic.Id, CommandDeliverParamConfigs = new List <SysConfig> { commandReply }, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id }; var commandA = new ProtocolCommand { Id = Guid.Parse("29b2f9c1-a79b-4598-bc33-2b4c20488159"), CommandTypeCode = new byte[] { 0xFD }, CommandCode = new byte[] { 0x27 }, ReceiveBytesLength = 30, CommandCategory = CommandCategory.TimingAutoReport, ProtocolId = classic.Id, CommandDeliverParamConfigs = new List <SysConfig> { commandReplyA }, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, CommandDatas = new List <CommandData>() }; var commandB = new ProtocolCommand { Id = Guid.Parse("52FD2857-1607-4AD6-86C9-AC6B2B75BBB6"), CommandTypeCode = new byte[] { 0xFC }, CommandCode = new byte[] { 0x1F }, ReceiveBytesLength = 0, CommandCategory = CommandCategory.DeviceControl, ProtocolId = classic.Id, CommandDeliverParamConfigs = new List <SysConfig>(), CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, CommandDatas = new List <CommandData>() }; commandA.CommandDatas.Add(commandDataA); commandA.CommandDatas.Add(commandDataB); commandA.CommandDatas.Add(commandDataC); commandA.CommandDatas.Add(commandDataD); commandA.CommandDatas.Add(commandDataE); commandA.CommandDatas.Add(commandDataF); commandA.CommandDatas.Add(commandDataG); commandA.CommandDatas.Add(commandDataH); commandA.CommandDatas.Add(commandDataI); commandA.CommandDatas.Add(commandDataJ); dbContext.ProtocolCommands.Add(command); dbContext.ProtocolCommands.Add(commandA); dbContext.ProtocolCommands.Add(commandB); var lampblack = new Protocol { Id = Guid.Parse("ea38e48c-1df2-4bfb-8917-7f736795bdc3"), FieldId = field.Id, SubFieldId = subfield.Id, CustomerInfo = "1", ProtocolName = "Lampblack", ProtocolModule = "Lampblack", Version = "Lampblack_Protocol_V0001", ReleaseDateTime = DateTime.Now, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, CheckType = ProtocolCheckType.Lrc, Head = new byte[] { 0x3A }, Tail = new byte[] { 0x0D, 0x0A } }; dbContext.Protocols.Add(lampblack); var lbHead = new ProtocolStructure() { Id = Guid.Parse("a47ffc76-30ed-4d94-84d7-74540c51d9c4"), ProtocolId = lampblack.Id, StructureName = "Head", StructureIndex = 0, StructureDataLength = 1, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.SingleByte, DefaultBytes = new byte[] { 0x3A } }; var lbFunctionCode = new ProtocolStructure() { Id = Guid.Parse("b9c7a5ef-d6ec-43e8-bdec-edcddbc8d4bb"), ProtocolId = lampblack.Id, StructureName = "FunctionCode", StructureIndex = 1, StructureDataLength = 2, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.FunctionCode, DefaultBytes = new byte[0] }; var lbDeviceNodeId = new ProtocolStructure() { Id = Guid.Parse("a98f5e06-5093-4ab9-9762-5dacc4bdaf73"), ProtocolId = lampblack.Id, StructureName = "DeviceNodeId", StructureIndex = 2, StructureDataLength = 7, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.NodeId, DefaultBytes = new byte[0] }; var lbData = new ProtocolStructure() { Id = Guid.Parse("c3ec8746-7c23-43bd-9cf8-a0db19c29655"), ProtocolId = lampblack.Id, StructureName = "Data", StructureIndex = 3, StructureDataLength = 0, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.Data, DefaultBytes = new byte[0] }; var lbAscTime = new ProtocolStructure() { Id = Guid.Parse("d9c5172a-233b-4ea8-b064-297bc9c8fb75"), ProtocolId = lampblack.Id, StructureName = "ASCTime", StructureIndex = 4, StructureDataLength = 14, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.ASCTime, DefaultBytes = new byte[0] }; var lbLrc = new ProtocolStructure() { Id = Guid.Parse("3e8b6176-19b0-4b0b-8635-a9a995799da4"), ProtocolId = lampblack.Id, StructureName = "LRCValue", StructureIndex = 5, StructureDataLength = 3, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.LRC, DefaultBytes = new byte[0] }; var lbTail = new ProtocolStructure() { Id = Guid.Parse("56d4150a-7a22-4c74-8a22-9bc6b3bb70f7"), ProtocolId = lampblack.Id, StructureName = "Tail", StructureIndex = 6, StructureDataLength = 2, CreateUserId = user.Id, CreateDateTime = DateTime.Now, LastUpdateDateTime = DateTime.Now, LastUpdateUserId = user.Id, IsEnabled = true, DataType = ProtocolDataType.Bytes, DefaultBytes = new byte[] { 0x0D, 0x0A } }; dbContext.ProtocolStructures.Add(lbHead); dbContext.ProtocolStructures.Add(lbFunctionCode); dbContext.ProtocolStructures.Add(lbDeviceNodeId); dbContext.ProtocolStructures.Add(lbData); dbContext.ProtocolStructures.Add(lbAscTime); dbContext.ProtocolStructures.Add(lbLrc); dbContext.ProtocolStructures.Add(lbTail); //var devices = new List<Device>(); //for (var i = 0; i < 1000; i++) //{ // var dev = new Device() // { // Id = Guid.NewGuid(), // DeviceTypeId = deviceType.Id, // DeviceCode = "扬尘硬件第三版测试一号", // DevicePassword = string.Empty, // DeviceModuleGuid = Guid.NewGuid(), // DeviceNodeId = (i + 1000).ToString("X8"), // FirmwareSetId = firmSet.Id, // StartTime = DateTime.Now, // PreEndTime = DateTime.Now, // EndTime = DateTime.Now, // Status = DeviceStatus.Enabled, // DomainId = domain.Id, // CreateUserId = user.Id, // CreateDateTime = DateTime.Now, // IsEnabled = true // }; // dbContext.Devices.Add(dev); //} }