代码同步

This commit is contained in:
木鱼(iFish) 2014-12-14 23:17:15 +08:00
parent 458357778f
commit e6c9c8027d
10 changed files with 116 additions and 36 deletions

View File

@ -33,7 +33,7 @@ namespace TrainInfomationProviderService
if (ConfigurationManager.AppSettings["local_disable_train_provider"] == "1")
return;
RouteTable.Routes.MapRoute("traintransit", "tt/{action}/{id}", new { area = "", controller = "Transit", id = UrlParameter.Optional }, new { action = "(keepalive|ls|ss|tor|dt|ls2)" }, new[] { "TrainInfomationProviderService.Web" });
RouteTable.Routes.MapRoute("traintransit", "tt/{action}/{id}", new { area = "", controller = "Transit", id = UrlParameter.Optional }, new { action = "(keepalive|ls|ss|tor|dt|ls2|ssa)" }, new[] { "TrainInfomationProviderService.Web" });
Task.Run(() =>
{
try

View File

@ -18,7 +18,7 @@ namespace TrainInfomationProviderService.StationInfo
public static Dictionary<string, HashSet<string>> SameStationMap { get; private set; }
private static Timer _timer;
private static string _cacheUrl;
internal static string _cacheUrl;
public static void Init()
{

View File

@ -13,6 +13,8 @@ namespace TrainInfomationProviderService.Web.Controllers
{
using System.IO;
using FSLib.MvcWeb.ActionResults;
public class TransitController : Controller
{
#region Overrides of Controller
@ -85,6 +87,12 @@ namespace TrainInfomationProviderService.Web.Controllers
}, JsonRequestBehavior.AllowGet);
}
[OutputCache(Duration = 3600), ActionName("ssa")]
public ActionResult GetSameStationAll()
{
return Content(System.IO.File.ReadAllText(SameStationManager._cacheUrl), "application/json", Encoding.UTF8);
}
public ActionResult KeepAlive()
{
return Json(new { ret = true, time = DateTime.Now.ToString() }, JsonRequestBehavior.AllowGet);

View File

@ -11,6 +11,35 @@ using Newtonsoft.Json.Serialization;
namespace Web12306
{
using System.IO;
using System.Text;
using System.Web.Hosting;
public class TrainSuggestionCommonData
{
public static readonly Dictionary<string, string> FrequencyTrainCodeMap = new Dictionary<string, string>
{
{"任意车次", ".*"},
{"任意高铁", "G.*"},
{"任意动车", "D.*"},
{"任意城铁", "C.*"},
{"任意直达", "Z.*"},
{"任意特快", "T.*"},
{"任意快车", "K.*"},
{"任意普客", @"\d*"},
{"任意临客", "L.*"},
{"任意G/D/C", "[GDC].*"},
{"任意直达特快", "[TZ].*"},
{"动车或高铁或城铁", @"[DGC].*"},
{"特快或直达", @"[TZ].*"},
{"快车", @"K.*"},
{"高铁", @"G.*"},
{"动车", @"D.*"},
{"城铁", @"C.*"},
{"直达", @"Z.*"},
{"特快", @"T.*"}
};
}
public class TrainSuggestion : IHttpHandler
{
#region Implementation of IHttpHandler
@ -58,7 +87,7 @@ namespace Web12306
return;
}
context.Response.ContentType = string.IsNullOrEmpty(callback) ? "application/json" : "application/javascript";
context.Response.BufferOutput = false;
context.Response.BufferOutput = true;
context.Response.StatusCode = 200;
try
@ -78,8 +107,21 @@ namespace Web12306
}
catch (Exception ex)
{
throw ex;
return;
//log error
var sb = new StringBuilder();
sb.AppendLine(string.Format("请求URL {0}", context.Request.Url));
sb.AppendLine("数据:");
sb.AppendLine(data);
sb.AppendLine();
sb.AppendLine("错误信息:");
sb.AppendLine(ex.ToString());
var log = DateTime.Now.Ticks + ".log";
var path = HostingEnvironment.MapPath("~/errors/tr/");
path = PathUtility.Combine(path, log);
Directory.CreateDirectory(Path.GetDirectoryName(path));
File.WriteAllText(path, sb.ToString());
}
}
@ -671,7 +713,7 @@ namespace Web12306
/// <returns></returns>
public bool CheckIllegal()
{
if (Key != "stupid360")
if (Key != "stupid360" || Stops == null)
return true;
if (Stops.Values.Any(s => (s.TrainInfo.code == s.TrainInfo.from.code && s.TrainInfo.to.code == s.TrainInfo.end.code)))
return true;
@ -688,7 +730,7 @@ namespace Web12306
//added 2014-9-9 检测非法车次
if (SelectedTrain != null && SelectedTrain.Length > 0)
{
var reg = new Regex("^(" + string.Join("|", SelectedTrain) + ")$", RegexOptions.IgnoreCase);
var reg = new Regex("^(" + string.Join("|", SelectedTrain.Select(s => TrainSuggestionCommonData.FrequencyTrainCodeMap.GetValue(s).DefaultForEmpty(s))) + ")$", RegexOptions.IgnoreCase);
if (Stops.Keys.Any(s => !reg.IsMatch(s)))
return true;
}
@ -698,9 +740,16 @@ namespace Web12306
public void PreprocessData()
{
foreach (var trainInfoItem in Stops.Values)
foreach (var trainInfoItem in Stops.ToArray())
{
trainInfoItem.PreprocessData(Date);
if (trainInfoItem.Value.StopInfos == null)
{
Stops.Remove(trainInfoItem.Key);
}
else
{
trainInfoItem.Value.PreprocessData(Date);
}
}
}
}
@ -887,7 +936,6 @@ namespace Web12306
public string supportCard { get; set; }
public string saleTime { get; set; }
public string secureStr { get; set; }
public DateTime? selltime { get; set; }
public string date { get; set; }
public string limitSellInfo { get; set; }

View File

@ -56,14 +56,26 @@
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="4.0.0.0-4.0.0.1" newVersion="4.0.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -24,6 +24,7 @@
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<TypeScriptToolsVersion>1.0</TypeScriptToolsVersion>
<NuGetPackageImportStamp>16ae31ba</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -69,6 +70,7 @@
</Reference>
<Reference Include="System.Net.Http.Primitives">
<HintPath>..\packages\Microsoft.Net.Http.2.2.28\lib\net45\System.Net.Http.Primitives.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
@ -76,9 +78,9 @@
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.Helpers.dll</HintPath>
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.Helpers.dll</HintPath>
</Reference>
<Reference Include="System.Web.Http, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@ -88,9 +90,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebApi.WebHost.5.2.2\lib\net45\System.Web.Http.WebHost.dll</HintPath>
</Reference>
<Reference Include="System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.Mvc.4.0.40804.0\lib\net40\System.Web.Mvc.dll</HintPath>
<Reference Include="System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.2\lib\net45\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@ -100,17 +102,17 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.2\lib\net45\System.Web.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.dll</HintPath>
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Deployment.dll</HintPath>
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll</HintPath>
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.2\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Web" />
@ -283,6 +285,10 @@
<TypeScriptCompile Include="Scripts\typings\underscore.d.ts" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Private\iFishOs\FSLib.Extension\src\FSLib.Extension.csproj">
<Project>{6d4588aa-a0fd-4364-972c-22b0ab7938f9}</Project>
<Name>FSLib.Extension</Name>
</ProjectReference>
<ProjectReference Include="..\TrainInfomationProviderService\TrainInfomationProviderService.csproj">
<Project>{c385d043-316a-4f05-a6b9-e70bf0ed8db6}</Project>
<Name>TrainInfomationProviderService</Name>
@ -323,12 +329,14 @@
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
</Target>
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@ -2,6 +2,9 @@
var citydata = require("./station/station_data.js");
var utility = require("./utility.js");
exports.stationReportApi = "http://12306.fishlee.net/tt/ls2";
exports.trainSuggestApi = "http://srv.12306.liebao.cn/ts";
exports.onceTransitApi = "http://12306.fishlee.net/tt/tor";
exports.chatServerGetAddressApi = "http://12306.liebao.cn/index.php?r=Api/GetRoomKey";
exports.sysNoticeUrl = "http://12306.liebao.cn/index.php?r=Api/GetNotificationList";
exports.sysNoticeLoadInterval = 30 * 60 * 1800;

View File

@ -67,7 +67,7 @@
data: _w.v
};
$.ajax({
url: "http://srv.12306.liebao.cn/ts?key=stupid360&r=" + Math.random(),
url: data.trainSuggestApi + "?key=stupid360&r=" + Math.random(),
dataType: "json",
method: "POST",
data: requestData
@ -233,7 +233,7 @@
TSS.constructor = TSS;
//相同车站切换
var sameStation = {};
var sameStation = JSON.parse(localStorage["ss_report"] || "{}");
var registerSameStation = function (result) {
var checkCpKey = result.query.fromName + result.query.toName;
if (sameStation[checkCpKey])
@ -252,6 +252,7 @@
return;
sameStation[checkCpKey] = [fromStations, toStations];
localStorage["ss_report"] = JSON.stringify(sameStation);
//upload
var rptData = [];
@ -259,7 +260,7 @@
rptData.push(_.pluck(fromStations, "code"));
if (toStations)
rptData.push(_.pluck(toStations, "code"));
$.post("http://12306.fishlee.net/tt/ls2", {
$.post(data.stationReportApi, {
data: btoa(escape(JSON.stringify(rptData)))
});
};

View File

@ -75,7 +75,7 @@
//1-自动检测换乘要求车次在4趟以下无始发终到
//2-不建议换乘,在上述条件以外
var url = "http://12306.fishlee.net/tt/tor?date=" + cp.depDate + "&from=" + cp.fromCode + "&to=" + cp.toCode + "&maxAge=" + getCalcBasedTime();
var url = data.onceTransitApi + "?date=" + cp.depDate + "&from=" + cp.fromCode + "&to=" + cp.toCode + "&maxAge=" + getCalcBasedTime();
var dlg = forceShowSuggestion ? mp.showMessagePopup("loading", "查询换乘中,请稍等...", { closeAfter: null }) : null;
$.get(url).done(function (resp) {
if (!resp || !resp.ret) {

View File

@ -1,16 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="4.0.40804.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="2.0.30506.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.2" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net45" />
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.6" targetFramework="net45" />