public int Delete(LinkageData entityToInsert) { using (Conn) { return(Conn.Delete(entityToInsert)); } }
public int Update(LinkageData entityToInsert) { using (Conn) { return(Conn.Update(entityToInsert)); } }
public Guid Insert(LinkageData entityToInsert) { using (Conn) { return(Conn.Insert <Guid>(entityToInsert)); } }
public override void ExecuteCommand(AppSession session, StringRequestInfo requestInfo) { LinkageDataRepository linkage = new LinkageDataRepository(); LinkageData data = linkage.GetEntityById(Guid.Parse(requestInfo[1])); string str = JsonConvert.SerializeObject(data); session.Send(str.Length.ToString()); session.Send(str); }
public override void ExecuteCommand(AppSession session, StringRequestInfo requestInfo) { PlanData data = new PlanData(); AlarmMessageForAll dataForOne = new AlarmMessageForAll(); switch (requestInfo[0]) { case "Add": //添加 { string str = requestInfo.Body.Substring(4); dataForOne = JsonConvert.DeserializeObject <AlarmMessageForAll>(str); try { //插入预案数据 Pre_arrangedPlanning temp_Pre_arrangedPlanning = new Pre_arrangedPlanning(); temp_Pre_arrangedPlanning.PlanDeviceID = new Guid(dataForOne.PlanDeviceID); temp_Pre_arrangedPlanning.PlanType = dataForOne.PlanType; temp_Pre_arrangedPlanning.PlanTypeID = dataForOne.PlanTypeID; temp_Pre_arrangedPlanning.DeviceID = dataForOne.DeviceID; temp_Pre_arrangedPlanning.DeviceType = int.Parse(dataForOne.DeviceType); temp_Pre_arrangedPlanning.StartDate = dataForOne.StartDate; temp_Pre_arrangedPlanning.StartTime = dataForOne.StartTime; temp_Pre_arrangedPlanning.StartWeek = dataForOne.StartWeek; temp_Pre_arrangedPlanning.TimeType = dataForOne.TimeType; temp_Pre_arrangedPlanning.EndDate = dataForOne.EndDate; temp_Pre_arrangedPlanning.EndTime = dataForOne.EndTime; temp_Pre_arrangedPlanning.EndWeek = dataForOne.EndWeek; temp_Pre_arrangedPlanning.Description = dataForOne.Description; temp_Pre_arrangedPlanning.Mark = dataForOne.Mark; Pre_arrangedPlanning.Insert(temp_Pre_arrangedPlanning); //插入联动数据 LinkageData Trigger_LinkageData = dataForOne.Trigger_LinkageData; //联动数据 if (Trigger_LinkageData != null) { LinkageDataComand.Insert(Trigger_LinkageData); } LinkageData Disposal_LinkageData = dataForOne.Disposal_LinkageData; //处置数据 if (Disposal_LinkageData != null) { LinkageDataComand.Insert(Disposal_LinkageData); } LinkageData Untreated_LinkageData = dataForOne.Untreated_LinkageData; //未处置数据 if (Untreated_LinkageData != null) { LinkageDataComand.Insert(Untreated_LinkageData); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } break; case "Del": //删除 { string str = requestInfo.Body.Substring(4); dataForOne = JsonConvert.DeserializeObject <AlarmMessageForAll>(str); try { Pre_arrangedPlanning.Delete(new Guid(dataForOne.PlanDeviceID)); LinkageData Trigger_LinkageData = dataForOne.Trigger_LinkageData; //联动数据 if (Trigger_LinkageData != null) { LinkageDataComand.Delete(Trigger_LinkageData); } LinkageData Disposal_LinkageData = dataForOne.Disposal_LinkageData; //处置数据 if (Disposal_LinkageData != null) { LinkageDataComand.Delete(Disposal_LinkageData); } LinkageData Untreated_LinkageData = dataForOne.Untreated_LinkageData; //未处置数据 if (Untreated_LinkageData != null) { LinkageDataComand.Delete(Untreated_LinkageData); } } catch (Exception) { throw; } } break; case "Revise": //修改 { string str = requestInfo.Body.Substring(7); dataForOne = JsonConvert.DeserializeObject <AlarmMessageForAll>(str); try { //插入预案数据 Pre_arrangedPlanning temp_Pre_arrangedPlanning = new Pre_arrangedPlanning(); temp_Pre_arrangedPlanning.PlanDeviceID = new Guid(dataForOne.PlanDeviceID); temp_Pre_arrangedPlanning.PlanType = dataForOne.PlanType; temp_Pre_arrangedPlanning.PlanTypeID = dataForOne.PlanTypeID; temp_Pre_arrangedPlanning.DeviceID = dataForOne.DeviceID; temp_Pre_arrangedPlanning.DeviceType = int.Parse(dataForOne.DeviceType); temp_Pre_arrangedPlanning.StartDate = dataForOne.StartDate; temp_Pre_arrangedPlanning.StartTime = dataForOne.StartTime; temp_Pre_arrangedPlanning.StartWeek = dataForOne.StartWeek; temp_Pre_arrangedPlanning.TimeType = dataForOne.TimeType; temp_Pre_arrangedPlanning.EndDate = dataForOne.EndDate; temp_Pre_arrangedPlanning.EndTime = dataForOne.EndTime; temp_Pre_arrangedPlanning.EndWeek = dataForOne.EndWeek; temp_Pre_arrangedPlanning.Description = dataForOne.Description; temp_Pre_arrangedPlanning.Mark = dataForOne.Mark; Pre_arrangedPlanning.Update(temp_Pre_arrangedPlanning); //插入联动数据 LinkageData Trigger_LinkageData = dataForOne.Trigger_LinkageData; //联动数据 if (Trigger_LinkageData != null) { LinkageDataComand.Update(Trigger_LinkageData); } LinkageData Disposal_LinkageData = dataForOne.Disposal_LinkageData; //处置数据 if (Disposal_LinkageData != null) { LinkageDataComand.Update(Disposal_LinkageData); } LinkageData Untreated_LinkageData = dataForOne.Untreated_LinkageData; //未处置数据 if (Untreated_LinkageData != null) { LinkageDataComand.Update(Untreated_LinkageData); } } catch (Exception) { throw; } } break; case "Query": //查询 { List <Pre_arrangedPlanning> pre_arrangedPlanning; List <ArmAndDisarmList> armAndDisarmList; List <LinkageData> linkageData; List <CameraList> cameraList; List <StreamMediaList> streamMediaList; List <StreamServerList> streamServerList; //获取数据库的所有设备信息 pre_arrangedPlanning = Pre_arrangedPlanning.GetList(); armAndDisarmList = ArmAndDisArm.GetList(); linkageData = LinkageDataComand.GetList(); cameraList = CameraList.GetList(); streamMediaList = StreamMediaList.GetList(); streamServerList = StreamServerList.GetList(); //组装数据 data.pre_arrangedPlanning = pre_arrangedPlanning; data.armAndDisarmList = armAndDisarmList; data.linkageData = linkageData; data.cameraList = cameraList; data.streamMediaList = streamMediaList; data.streamServerList = streamServerList; //转json string str = JsonConvert.SerializeObject(data); session.Send(str); } break; case "Query1": List <Pre_arrangedPlanning> pre_arrangedPlanning1; pre_arrangedPlanning1 = Pre_arrangedPlanning.GetList(); for (int i = 0; i < pre_arrangedPlanning1.Count; i++) { if (pre_arrangedPlanning1[i].PlanType != 2) { pre_arrangedPlanning1.Remove(pre_arrangedPlanning1[i]); } } //转json string str1 = JsonConvert.SerializeObject(pre_arrangedPlanning1); session.Send(str1); break; } }
private void AssemblePlan(PlanData plandata) { pre_arrangedPlanning = plandata.pre_arrangedPlanning; armAndDisarmList = plandata.armAndDisarmList; linkageData = plandata.linkageData; cameraList = plandata.cameraList; streamMediaList = plandata.streamMediaList; streamServerList = plandata.streamServerList; for (int i = 0; i < armAndDisarmList.Count; i++) { for (int j = 0; j < pre_arrangedPlanning.Count; j++) { if (armAndDisarmList[i].AlarmDeviceID.ToString() == pre_arrangedPlanning[j].PlanTypeID.ToString()) { AlarmMessageForAll temp_AlarmMessageForAll = new AlarmMessageForAll(); //--------------------------------对报警器结构体赋值①------------------------------------ temp_AlarmMessageForAll.AlarmDeviceID = armAndDisarmList[i].AlarmDeviceID.ToString(); temp_AlarmMessageForAll.AlarmName = armAndDisarmList[i].AlarmName; //---------------------------------------------------------------------------------------- //----------------------若在预案表单中找出ID一致,对进行赋值------------------- temp_AlarmMessageForAll.PlanDeviceID = pre_arrangedPlanning[j].PlanDeviceID.ToString(); temp_AlarmMessageForAll.PlanType = pre_arrangedPlanning[j].PlanType;//报警预案:1 if (temp_AlarmMessageForAll.PlanType != 1) { return; } temp_AlarmMessageForAll.PlanTypeID = pre_arrangedPlanning[j].PlanTypeID; temp_AlarmMessageForAll.DeviceID = pre_arrangedPlanning[j].DeviceID; temp_AlarmMessageForAll.DeviceType = pre_arrangedPlanning[j].DeviceType.ToString(); temp_AlarmMessageForAll.TimeType = pre_arrangedPlanning[j].TimeType; //(时间类型:星期---1;日期---2;定时---3;全时段---4) temp_AlarmMessageForAll.StartTime = pre_arrangedPlanning[j].StartTime; //起始时间 temp_AlarmMessageForAll.StartDate = pre_arrangedPlanning[j].StartDate; //起始日期 temp_AlarmMessageForAll.StartWeek = pre_arrangedPlanning[j].StartWeek; //起始星期 temp_AlarmMessageForAll.EndDate = pre_arrangedPlanning[j].EndDate; //结束日期 temp_AlarmMessageForAll.EndWeek = pre_arrangedPlanning[j].EndWeek; //结束星期 temp_AlarmMessageForAll.EndTime = pre_arrangedPlanning[j].EndTime; //结束时间 temp_AlarmMessageForAll.Description = pre_arrangedPlanning[j].Description; //描述 temp_AlarmMessageForAll.Mark = pre_arrangedPlanning[j].Mark; //--------------------赋值完毕,下一步进行联动数据赋值-------------------------- LinkageData temp_LinkageData_1 = new LinkageData(); temp_LinkageData_1 = linkageData.Find(_ => _.PlanDeviceID.ToString() == temp_AlarmMessageForAll.PlanDeviceID && _.LinakgeStage == 1); LinkageData temp_LinkageData_2 = new LinkageData(); temp_LinkageData_2 = linkageData.Find(_ => _.PlanDeviceID.ToString() == temp_AlarmMessageForAll.PlanDeviceID && _.LinakgeStage == 2); LinkageData temp_LinkageData_3 = new LinkageData(); temp_LinkageData_3 = linkageData.Find(_ => _.PlanDeviceID.ToString() == temp_AlarmMessageForAll.PlanDeviceID && _.LinakgeStage == 3); if (temp_LinkageData_1 != null) { temp_AlarmMessageForAll.Trigger_LinkageData = temp_LinkageData_1; } if (temp_LinkageData_2 != null) { temp_AlarmMessageForAll.Disposal_LinkageData = temp_LinkageData_2; } if (temp_LinkageData_3 != null) { temp_AlarmMessageForAll.Untreated_LinkageData = temp_LinkageData_3; } if (!temp_PlanDataforAll.ContainsKey(temp_AlarmMessageForAll.PlanDeviceID)) { temp_PlanDataforAll.Add(temp_AlarmMessageForAll.PlanDeviceID, temp_AlarmMessageForAll); } } } } }