保存GeographyPoint到JayStack数据库的JayData异常

时间:2013-06-15 19:41:40

标签: jaydata

以下代码在SaveChanges()上抛出以下异常:

System.Data.Services.Client.DataServiceRequestException was unhandled
  HResult=-2146233079
  Message=An error occurred while processing this request.
  Source=Microsoft.Data.Services.Client
  StackTrace:
       at System.Data.Services.Client.SaveResult.HandleResponse()
       at System.Data.Services.Client.BaseSaveResult.EndRequest()
       at System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options)
       at System.Data.Services.Client.DataServiceContext.SaveChanges()
       at AirportDataImporter.Program.Main(String[] args) in c:\Projects\Airport\Dev\AirportWeb\AirportDataImporter\Program.cs:line 23
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Data.Services.Client.DataServiceClientException
       HResult=-2146233079
       Message=Format Exception: Invalid 'Point' format!
    at Function.$data.GeographyBase.validateGeoJSON (/usr/lib/node_modules/jaydata/lib/TypeSystem/Types/Geography.js:75:29)
    at GeographyPoint.GeographyBase (/usr/lib/node_modules/jaydata/lib/TypeSystem/Types/Geography.js:6:25)
    at new GeographyPoint (/usr/lib/node_modules/jaydata/lib/TypeSystem/Types/Geography.js:94:29)
    at $data.oDataConverter.fromDb.$data.GeographyPoint (/usr/lib/node_modules/jaydata/lib/Types/StorageProviders/oData/oDataConverter.js:55:64)
    at Airport.$data.Entity.$data.Class.define.constructor (/usr/lib/node_modules/jaydata/lib/Types/Entity.js:189:41)
    at Airport.Entity (eval at <anonymous> (/usr/lib/node_modules/jaydata/lib/TypeSystem/TypeSystem.js:463:20))
    at new Airport (eval at <anonymous> (/usr/lib/node_modules/jaydata/lib/TypeSystem/TypeSystem.js:463:20))
    at EntitySetProcessor.$data.Class.define.invoke (/usr/lib/node_modules/jaydata/lib/JayService/OData/EntitySetProcessor.js:61:38)
    at JSObjectAdapter.$data.Class.define.processRequest (/usr/lib/node_modules/jaydata/lib/JayService/JSObjectAdapter.js:89:37)
    at JSObjectAdapter.$data.Class.define.handleRequest (/usr/lib/node_modules/jaydata/lib/JayService/JSObjectAdapter.js:165:26)
       StatusCode=500
       InnerException: 

它与将C#GeographyPoint转换为其json / javascript等效项有关。有人可以告诉我我需要做些什么来使这项工作?由于似乎没有JayStack数据导入器,我需要完成这项工作才能初始化我的数据:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Spatial;
using System.Text;
using System.Threading.Tasks;

namespace AirportDataImporter
{
    class Program
    {
        static void Main(string[] args)
        {
            var db = new AirportDB.mydatabaseService(new Uri("https://open.jaystack.net/c72e6c4b-27ba-49bb-9321-e167ed03d00b/6494690e-1d5f-418d-adca-0ac515b7b742/api/mydatabase/"));

            var airport = new AirportDB.Airport();
            airport.Abbrev = "Foo";
            airport.Name = "Bar";

            airport.GeoLocation = GeographyPoint.Create(51.87796, -176.64603);
            db.AddToAirport(airport);

            db.SaveChanges();

        }
    }
}

此外,Visual Studio生成的服务引用硬编码odata版本2,其中jaydata也会抛出不同的异常。我将生成的代理文件编辑到v3以解决此问题。这不是理想的方法。在这方面有什么指示?

Fiddler捕获的网络负载是:

    <?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml">
   <category term="mydatabase.Airport" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
   <id />
   <title />
   <updated>2013-06-16T12:16:11Z</updated>
   <author>
      <name />
   </author>
   <content type="application/xml">
      <m:properties>
         <d:Abbrev>Foo</d:Abbrev>
         <d:GeoLocation m:type="Edm.GeographyPoint">
            <gml:Point gml:srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
               <gml:pos>51.87796 -176.64603</gml:pos>
            </gml:Point>
         </d:GeoLocation>
         <d:id m:null="true" />
         <d:Name>Bar</d:Name>
      </m:properties>
   </content>
</entry>

由于 TJ

1 个答案:

答案 0 :(得分:0)

使用fiddler或burp捕获网络流量并将相关部分粘贴到此处。