1

我收到了这样的回复:

2012-12-19 19:04:39.253 SwimboardDemo[4507:f803] <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://tempuri.org/"><soap:Body><GetAtheletDetailByUserKey><UserProfileKey>3</UserProfileKey></GetAtheletDetailByUserKey></soap:Body></soap:Envelope>
2012-12-19 19:04:51.678 SwimboardDemo[4507:f803] <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetAtheletDetailByUserKeyResponse xmlns="http://tempuri.org/"><GetAtheletDetailByUserKeyResult><AtheletDetailList><WAthelet_Detail><AtheletDetail_PK>1</AtheletDetail_PK><Athelet_FK>2</Athelet_FK><Dist>50S</Dist><Stroke>Free</Stroke><PF>F</PF><Time>47.75</Time><place>0</place><Points>0</Points><Date>2011-04-29T00:00:00</Date><Meet>Luke Jeffrey Memorial Trophy 2</Meet><Course>S</Course><IsSyncronized>true</IsSyncronized><CreatedDate>2012-12-10T15:52:20.833</CreatedDate><UpdatedDate>2012-12-19T17:34:48.733</UpdatedDate><TeamMaster_FK>1</TeamMaster_FK><ResultID>4108</ResultID></WAthelet_Detail>

我在插入数据库时​​得到了响应:

2012-12-19 19:10:53.024 SwimboardDemo[4507:f803] GetAllAtheleteHandler returned the value: (
    "<WAthelet_Detail><AtheletDetail_PK>1</AtheletDetail_PK><Athelet_FK>2</Athelet_FK><Dist>50S</Dist><Stroke>Free</Stroke><PF>F</PF><Time>47.75</Time><place>0</place><Points>0</Points><Date>2011-04-29T00:00:00.000</Date><Meet>Luke Jeffrey Memorial Trophy 2</Meet><Course>S</Course><IsSyncronized>true</IsSyncronized><CreatedDate>2012-12-10T15:52:20.833</CreatedDate><UpdatedDate>2012-12-19T17:34:48.733</UpdatedDate><TeamMaster_FK>1</TeamMaster_FK><ResultID>4108</ResultID></WAthelet_Detail>",
    "<WAthelet_Detail><AtheletDetail_PK>0</AtheletDetail_PK><Athelet_FK>0</Athelet_FK><place>0</place><Points>0</Points><IsSyncronized>false</IsSyncronized><TeamMaster_FK>0</TeamMaster_FK><ResultID>0</ResultID></WAthelet_Detail>",
    "<WAthelet_Detail><AtheletDetail_PK>0</AtheletDetail_PK><Athelet_FK>0</Athelet_FK><place>0</place><Points>0</Points><IsSyncronized>false</IsSyncronized><TeamMaster_FK>0</TeamMaster_FK><ResultID>0</ResultID></WAthelet_Detail>"
)
2012-12-19 19:10:53.281 SwimboardDemo[4507:f803] Result Count :: 3
2012-12-19 19:11:03.785 SwimboardDemo[4507:f803] Athelet Handler Done 0
2012-12-19 19:11:05.272 SwimboardDemo[4507:f803] Insertion Failed

代码如下:

- (IBAction)btnSync:(id)sender {


//    if(![[NSUserDefaults standardUserDefaults] valueForKey:@"SychTeam"])
//    {

    SBSwimboardService* service = [SBSwimboardService service];
    service.logging = YES;
    [service GetAtheletDetailByUserKey:self action:@selector(GetAllAtheletDetailHandler:) UserProfileKey:3];
    //}
    //[service GetSplitDataByUserKey:self action:@selector(GetAllSplitDataHandler:) UserProfileKey:3];


}
#pragma mark - Delegate Methods

-(void)GetAllAtheletDetailHandler:(id)value
{
    int j;
    if([value isKindOfClass:[NSError class]]) {
        NSLog(@"%@", value);
        return;
    }

    // Handle faults
    if([value isKindOfClass:[SoapFault class]]) {
        NSLog(@"%@", value);
        return;
    }
    NSMutableArray* result = (NSMutableArray*)value;
    NSLog(@"GetAllAtheleteHandler returned the value: %@", result );
//    if([[NSString stringWithFormat:@"%@",result] isEqualToString:@"1"]){

         NSLog(@"Result Count :: %d",[result count]);
        for (int i =0; i<[result count]; i++) {


        NSMutableDictionary *dic=[[NSMutableDictionary alloc]init];

        [dic setValue:[[result objectAtIndex:i] valueForKey:@"AtheletDetail_PK"] forKey:@"AtheletDetail_PK"];
        [dic setValue:[[result objectAtIndex:i] valueForKey:@"Athelet_FK"] forKey:@"Athelet_FK"];

        DAL *objDAL=[[DAL alloc]initDatabase:@"Abc.sqlite"];
      j    = [objDAL insertRecord1:dic inTable:@"Abc"];

              NSLog(@"Athelet Handler Done %d",i);
            if (j == 0) {
                NSLog(@"Inserted Successfully");

            }
            else if(j == -1)
            {
                 NSLog(@"Insertion Failed");
            }
          }
    [[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"SychTeam"];
    [[NSUserDefaults standardUserDefaults]synchronize];

}
-(int)insertRecord1:(NSDictionary *)record inTable:(NSString *)table {

    NSString *query = [NSString stringWithFormat:@"INSERT INTO %@ (", table];
    NSString *values = @"(";

    int ctr = 1;
    int totalKeys = [[record allKeys] count];
    for (NSString *key in [record allKeys]) {

        //NSObject *object = [record objectForKey:key];

        NSString *value1 = [record valueForKey:key];

        NSObject *object = value1;
        NSString *value = [self getValueOfObject:object];


        query = [query stringByAppendingFormat:@"%@", key];
        values = [values stringByAppendingFormat:@"%@", value];

        if (ctr != totalKeys) {
            query = [query stringByAppendingString:@", "];
            values = [values stringByAppendingString:@", "];
        }
        else {
            query = [query stringByAppendingString:@") VALUES "];
            values = [values stringByAppendingString:@");"];
        }

        ctr++;
    }

    query = [query stringByAppendingString:values];
    //  NSLog(@"%@",query);
    return [self executeScalar:query];
}


    - (SoapRequest*) GetAtheletDetailByUserKey: (id) _target action: (SEL) _action Abc: (int) Abc
    {
        NSMutableArray* _params = [NSMutableArray array];

        [_params addObject: [[[SoapParameter alloc] initWithValue: [NSNumber numberWithInt: Abc] forName: @"Abc"] autorelease]];
        NSString* _envelope = [Soap createEnvelope: @"Abc" forNamespace: self.namespace withParameters: _params withHeaders: self.headers];
        SoapRequest* _request = [SoapRequest create: _target action: _action service: self soapAction: @"http://tempuri.org/Abc" postData: _envelope deserializeTo: [[SBArrayOfWAthelet_Detail alloc] autorelease]];
        [_request send];
        return _request;
    }

问题:

在数据库中插入数据失败。

你能帮忙吗?

执行此查询时出现错误:

INSERT INTO Athelet_Detail (AtheletDetail_PK, Athelet_FK, CreatedDate, TeamMaster_FK, Date, UpdatedDate, Meet, place, Time, IsSyncronized, Points, Stroke, PF, ResultID, Course, Dist) 值 (1, 2, '2012-12-10 10: 22:20 +0000', 1, '2011-04-28 18:30:00 +0000', '2012-12-19 12:04:48 +0000', '卢克杰弗里纪念奖杯 2', 0, ' 47.75', 1, 0, '免费', 'F', 4108, 'S', '50S');

错误:

* 断言失败 -[Settings GetAllAtheletDetailHandler:], /Users/romaudernani/Documents/All my Stuffs/Roma/Swimboard Sqlite/Projects/SB Project/SwimboardDemo/../SwimboardSettings/Settings.m:127 2012-12-20 10 :51:23.782 SwimboardDemo [660:f803] *由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'插入失败'(null)'。

4

0 回答 0