/// <summary> /// Получить id станции по коду станции /// </summary> /// <param name="code_cs"></param> /// <returns></returns> public int DefinitionIDStation(int code_cs) { ReferenceStation station = g_ref.GetReferenceStationOfCode(code_cs); if (station != null) { return(station.IDStation); } Code_Station code_station = rw_ref.GetStationsOfCodeCS(code_cs); if (code_station == null) { return(0); } Code_InternalRailroad code_ir = rw_ref.GetInternalRailroads(code_station.IDInternalRailroad != null? (int)code_station.IDInternalRailroad:0); Code_State code_st = rw_ref.GetState(code_ir != null ? code_ir.IDState: 0); int res = g_ref.SaveReferenceStation(new ReferenceStation() { IDStation = 0, Name = code_station.Station + (code_ir != null ? " " + code_ir.Abbr + " ж/д" : "") + (code_st != null ? " " + code_st.ABB_RUS : ""), Station = code_station.Station, InternalRailroad = code_ir != null ? code_ir.InternalRailroad : "-", IR_Abbr = code_ir != null ? code_ir.Abbr : "-", NameNetwork = code_st != null ? code_st.NameNetwork : "-", NN_Abbr = code_st != null ? code_st.ABB_RUS : "-", CodeCS = code_cs }); if (res > 0) { return(res); } return(0); }
/// <summary> /// Записать код ж.д. в указаный диапазон станций Code_InternalRailroad.StationsCodes /// </summary> /// <param name="cir"></param> private void SetInternalRailroad(Code_InternalRailroad cir) { string[] arrayCodes = cir.StationsCodes.Split(';'); foreach (string Codes in arrayCodes) { if (!String.IsNullOrWhiteSpace(Codes)) { string[] arraywhere = Codes.Replace("–", "-").Split('-'); switch (arraywhere.Count()) { case 0: break; case 1: SetIRToStation(cir.IDInternalRailroad, int.Parse(arraywhere[0])); break; case 2: SetIRToStation(cir.IDInternalRailroad, int.Parse(arraywhere[0]), int.Parse(arraywhere[1])); break; default: break; } } } }