0

我想做的是创建一个实体,我们称之为Entity1

Enitity1 { 
  globalId: string;
}

然后使用GlobalIdfrom 最近创建Entity1的来创建Entity2

Enitity2 {
   globalId: string;
   entity1Id: string;
}

这是一个 Angular 应用程序,我使用的是esri-loader2.14.0 和esri-service2.6.0

然后我有一个esri-service-extension.ts像这样的片段:

export class EsriServiceExtension {

    public static async createQuery(
      props: __esri.QueryProperties
    ): Promise<__esri.Query> {
        const [Query] = await loadModules([
          "esri/tasks/support/Query"
        ]);
        const query: __esri.Query =new Query(props);
        return query;
    }
    
}

然后是我有这个的服务:

export class MyService {
    // A whole bunch of code
    
    applyEditsWithUrl = (record: any, editMode: string, url: string) => {
        let fData: FormData = new FormData;
        fData.append("f", 'json');
        fData.append("gdbVersion", "admin.Editable");
        fData.append('token', <token>);

        if (editMode === 'updates') {
            // bunch of code
        } else if (editMode === 'adds') {
            // simplified version of the code
            fData.append("adds", JSON.stringify([{"attributes": record}]));
        } else if (editMode === 'deletes') {
            // bunch of code
        }
        
        return this.httpClient.post(url, fData)
          .pipe(map((response: Response) => {
            return response;
          }))
          .pipe(catchError(error => {
            // handling of error
          }));
    }

    // A whole bunch of code
}

最后,我有一个像这样的组件(我使用上面的服务):

export class MyComponent {
    // a whole bunch of code
    let applyEdits = this.contactsService.applyEdits(obj.entity1, "entity1", "adds"); 
    
    applyEdits.subscribe(async (response: any) => {
        // code to process the response
    }

    // a whole bunch of code

    let applyEdits = this.bulkUploadService.applyEdits(applyEdits_Adds, applyEdit_Update, applyEdits_Deletes, "entity2");

    applyEdits.subscribe(async (response: any) => {
        // code to process the response
    }
}

执行此代码时,两个相互尊重的请求将如下所示

URL: {url for entity1}/applyEdits
Status code: 200
Response: {"addResults":[{"globalId":"{GUID}","success":true}],"updateResults":[],"deleteResults":[]}

所以这个请求是成功的,它为创建的 Entity1 返回 {GUID}。

URL: {url for entity2}/applyEdits (using {GUID} as part of the payload
Status code: 200
Response: {"error":{"code":500,"extendedCode":-2147467261,"message":"Unable to complete operation.","details":["Unable to perform applyEdits operation.","Error: This operation is not allowed while editing [Editable].  This operation is not allowed while editing [Editable]."]}}

我对这个错误的理解是:发送第二个请求时,Entity1 表中似乎不存在 {GUID},就好像第二个请求正在与不同版本的数据库进行交互一样。

有谁知道如何解决这个问题?

4

0 回答 0