public int GetRevertCityMapping(int id) { string start_node = city_mapping_list[id].start_node; string end_node = city_mapping_list[id].end_node; foreach (KeyValuePair <int, CityMapping> pair in city_mapping_list) { CityMapping m = pair.Value; if (m.start_node == end_node && m.end_node == start_node) { return(m.edge_num); } } return(-1); }
public List <int> DelayTickets(DateTime accident_happen_time, int city_id, int duration, AccidentType type) { List <int> affected_routine_ids = new List <int>(); if (type == AccidentType.rail) { CityMapping nodes = CityUtil.Instance.GetEdgeCity(city_id); string start_node = nodes.start_node; string end_node = nodes.end_node; try { operation.InitConnection(data_resource); string sql = "select * from routine where ((start_node like \"%" + start_node + "%\"" + " and end_node like \"%" + end_node + "%\"" + ") or " + "(start_node like \"%" + end_node + "%\"" + " and end_node like \"%" + start_node + "%\")" + " ) and type = 0 order by start_time"; Lucky.LuckyUtils.Log("select all the start node sql " + sql); SqliteDataReader reader = operation.ExecuteQuery(sql); List <Routine> res = RoutineOperation.GetRoutinInfo(reader); operation.CloseConnection(); Lucky.LuckyUtils.Log("res result " + res.Count); List <Routine> delay_routine = new List <Routine>(); UInt64 accident_happen_time_seconds = RoutineOperation.GetSeconds(accident_happen_time); //Lucky.LuckyUtils.Log("accident_happen_time_seconds " + accident_happen_time_seconds); //Lucky.LuckyUtils.Log("accident_happen_time_seconds " + accident_happen_time_seconds); foreach (Routine t in res) { UInt64 begin_time = RoutineOperation.GetSeconds(t.GetBeginTime()); //Lucky.LuckyUtils.Log("begin time " + begin_time); UInt64 end_time = RoutineOperation.GetSeconds(t.GetEndTime()); if (begin_time >= accident_happen_time_seconds) { int routine_id = t.GetRoutineId(); //Lucky.LuckyUtils.Log("lucky routine_id "+ routine_id); UInt64 actual_begin_time = begin_time + (UInt32)duration * 60; UInt64 actual_end_time = end_time + (UInt32)duration * 60; sql = "update routine set actual_start_time = " + actual_begin_time + ", actual_end_time = " + actual_end_time + ", event_happen_time = " + accident_happen_time_seconds + " where routine_id = " + routine_id; operation.InitConnection(data_resource); reader = operation.ExecuteQuery(sql);// if (reader.RecordsAffected == 1) { affected_routine_ids.Add(routine_id); operation.CloseConnection(); } } } } finally { operation.CloseConnection(); } return(affected_routine_ids); } if (type == AccidentType.airport) { string city_name = CityUtil.Instance.GetCityName(city_id); Lucky.LuckyUtils.Log("city name " + city_name); try { operation.InitConnection(data_resource); string sql = "select * from routine where (start_node like \"%" + city_name + "%\" or end_node like \"%" + city_name + "%\")" + " and type = 1 order by start_time"; Lucky.LuckyUtils.Log("select all the start node sql " + sql); SqliteDataReader reader = operation.ExecuteQuery(sql); List <Routine> res = RoutineOperation.GetRoutinInfo(reader); operation.CloseConnection(); Lucky.LuckyUtils.Log("res result " + res.Count); List <Routine> delay_routine = new List <Routine>(); UInt64 accident_happen_time_seconds = RoutineOperation.GetSeconds(accident_happen_time); Lucky.LuckyUtils.Log("accident_happen_time_seconds " + accident_happen_time_seconds); foreach (Routine t in res) { UInt64 begin_time = RoutineOperation.GetSeconds(t.GetBeginTime()); UInt64 end_time = RoutineOperation.GetSeconds(t.GetEndTime()); if (begin_time >= accident_happen_time_seconds) { int routine_id = t.GetRoutineId(); UInt64 actual_begin_time = begin_time + (UInt32)duration * 60; UInt64 actual_end_time = end_time + (UInt32)duration * 60; sql = "update routine set actual_start_time = " + actual_begin_time + ", actual_end_time = " + actual_end_time + ", event_happen_time = " + accident_happen_time_seconds + " where routine_id = " + routine_id; operation.InitConnection(data_resource); reader = operation.ExecuteQuery(sql);// if (reader.RecordsAffected == 1) { affected_routine_ids.Add(routine_id); operation.CloseConnection(); } } } } finally { operation.CloseConnection(); } return(affected_routine_ids); } return(affected_routine_ids); }
private void SetDate(BaseAccident data) { callback = null; if (data.GetType() == typeof(Accident)) { string city = ""; Accident accident = data as Accident; if (accident.type == AccidentType.airport) { city = CityUtil.Instance.GetCityName(accident.location); RectTransform cityrt = MapTrafficView.instance.FindPlace(city); Vector3 pos = cityrt.anchoredPosition3D + new Vector3(cityrt.rect.width / 2, 0, 0); Lucky.LuckyUtils.Log("city warning" + city); rt.anchoredPosition3D = pos; } else { RectTransform railwayrt = MapTrafficView.instance.FindRailway(accident.location); Vector3 pos = railwayrt.anchoredPosition3D; rt.anchoredPosition3D = pos; } rt.localScale = new Vector3(1.5f, 1.5f, 0); //news = city + "灾害持续时间: "+accident.duration+"分钟"; news = accident.text.description; Lucky.LuckyUtils.Log("add listener"); callback = delegate() { InfoView.Show(new InfoMessage(news, "寒潮已经到达!")); }; } else if (data.GetType() == typeof(AccidentWarning)) { string city = ""; AccidentWarning warning = data as AccidentWarning; if (warning.type == AccidentType.airport) { Lucky.LuckyUtils.Log("location number " + warning.location); city = CityUtil.Instance.GetCityName(warning.location); RectTransform cityrt = MapTrafficView.instance.FindPlace(city); Vector3 pos = cityrt.anchoredPosition3D + new Vector3(cityrt.rect.width / 2, 0, 0); rt.anchoredPosition3D = pos; news = "寒潮即将到达" + city + ",请注意出行安全\n\n" + "<size=45>寒潮预计到达时间: " + warning.Accidentstarttime.ToString("HH:mm") + "</size>\n\n" + "<size=45>寒潮预计持续时间: " + warning.min + "分钟 ~ " + warning.max + "分钟</size>"; } else { RectTransform railwayrt = MapTrafficView.instance.FindRailway(warning.location); Vector3 pos = railwayrt.anchoredPosition3D; rt.anchoredPosition3D = pos; CityMapping edge = CityUtil.Instance.GetEdgeCity(warning.location); news = "寒潮即将到达" + edge.start_node + "-" + edge.end_node + ",请注意出行安全\n\n" + "<size=45>寒潮预计到达时间: " + warning.Accidentstarttime.ToString("HH:mm") + "</size>\n\n" + "<size=45>寒潮预计持续时间: " + warning.min + "分钟 ~ " + warning.max + "分钟</size>"; } rt.localScale = new Vector3(1.5f, 1.5f, 0); //news = ""+ city +"寒潮即将到达此处,请注意出行安全\n\n" // + "<size=45>寒潮预计到达时间: " + warning.Accidentstarttime.ToString("HH:mm") + "</size>\n\n" // + "<size=45>寒潮预计持续时间: " + warning.min + "分钟 ~ " + warning.max + "分钟</size>"; callback = delegate() { InfoView.Show(new InfoMessage(news, "【寒潮天气预警】")); }; } }
public CityUtil() { city_dict.Add(0, "沈阳"); city_dict.Add(1, "北京"); city_dict.Add(2, "天津"); city_dict.Add(3, "石家庄"); city_dict.Add(4, "济南"); city_dict.Add(5, "郑州"); city_dict.Add(6, "南京"); city_dict.Add(7, "杭州"); city_dict.Add(8, "上海"); city_dict.Add(9, "合肥"); city_list.AddVertex("沈阳"); city_list.AddVertex("北京"); city_list.AddVertex("天津"); city_list.AddVertex("石家庄"); city_list.AddVertex("济南"); city_list.AddVertex("郑州"); city_list.AddVertex("南京"); city_list.AddVertex("杭州"); city_list.AddVertex("上海"); city_list.AddVertex("合肥"); city_list.AddEdge("合肥", "杭州"); city_mapping_list[0] = new CityMapping(0, "合肥", "杭州"); city_list.AddEdge("合肥", "郑州"); city_mapping_list[1] = new CityMapping(1, "合肥", "郑州"); city_list.AddEdge("杭州", "郑州"); city_mapping_list[2] = new CityMapping(2, "杭州", "郑州"); city_list.AddEdge("杭州", "南京"); city_mapping_list[3] = new CityMapping(3, "杭州", "南京"); city_list.AddEdge("杭州", "上海"); city_mapping_list[4] = new CityMapping(4, "杭州", "上海"); city_list.AddEdge("郑州", "南京"); city_mapping_list[5] = new CityMapping(5, "郑州", "南京"); city_list.AddEdge("郑州", "石家庄"); city_mapping_list[6] = new CityMapping(6, "郑州", "石家庄"); city_list.AddEdge("南京", "石家庄"); city_mapping_list[7] = new CityMapping(7, "南京", "石家庄"); city_list.AddEdge("南京", "天津"); city_mapping_list[8] = new CityMapping(8, "南京", "天津"); city_list.AddEdge("南京", "济南"); city_mapping_list[9] = new CityMapping(9, "南京", "济南"); city_list.AddEdge("南京", "上海"); city_mapping_list[10] = new CityMapping(10, "南京", "上海"); city_list.AddEdge("上海", "济南"); city_mapping_list[11] = new CityMapping(11, "上海", "济南"); city_list.AddEdge("石家庄", "济南"); city_mapping_list[12] = new CityMapping(12, "石家庄", "济南"); city_list.AddEdge("石家庄", "北京"); city_mapping_list[13] = new CityMapping(13, "石家庄", "北京"); city_list.AddEdge("济南", "天津"); city_mapping_list[14] = new CityMapping(14, "济南", "天津"); city_list.AddEdge("北京", "沈阳"); city_mapping_list[15] = new CityMapping(15, "北京", "沈阳"); city_list.AddEdge("天津", "沈阳"); city_mapping_list[16] = new CityMapping(16, "天津", "沈阳"); city_list.AddEdge("合肥", "济南"); city_mapping_list[17] = new CityMapping(17, "合肥", "济南"); city_list.AddEdge("郑州", "济南"); city_mapping_list[18] = new CityMapping(18, "郑州", "济南"); city_tikcet_mapping["上海"] = new List <string>(); city_tikcet_mapping["上海"].Add("杭州"); city_tikcet_mapping["杭州"] = new List <String>(); city_tikcet_mapping["杭州"].Add("南京"); city_tikcet_mapping["南京"] = new List <string>(); city_tikcet_mapping["南京"].Add("合肥"); city_tikcet_mapping["南京"].Add("郑州"); city_tikcet_mapping["合肥"] = new List <String>(); city_tikcet_mapping["合肥"].Add("郑州"); city_tikcet_mapping["合肥"].Add("济南"); city_tikcet_mapping["郑州"] = new List <String>(); city_tikcet_mapping["郑州"].Add("石家庄"); city_tikcet_mapping["郑州"].Add("济南"); city_tikcet_mapping["济南"] = new List <String>(); city_tikcet_mapping["济南"].Add("石家庄"); city_tikcet_mapping["济南"].Add("天津"); city_tikcet_mapping["石家庄"] = new List <String>(); city_tikcet_mapping["石家庄"].Add("北京"); city_tikcet_mapping["北京"] = new List <String>(); city_tikcet_mapping["北京"].Add("沈阳"); city_tikcet_mapping["天津"] = new List <String>(); city_tikcet_mapping["天津"].Add("北京"); city_tikcet_mapping["天津"].Add("沈阳"); }