即使显示已连接状态,也不会访问数据库

时间:2012-11-26 06:20:01

标签: objective-c xcode sap sup

Console--log [http://i.stack.imgur.com/pIWvV.png]大家好,

我们完全是这个技术的初学者 我们创建了一个名为航班详情的MBO,它有3个输入参数(airlineid,connectionid.flightdate)。并生成相应的objective-c代码。现在我们按照以下步骤连接到服务器:

#import "ConnectionController.h"
#import "SUPApplication.h"
#import "flightDetailsTest_Flightdetails_v1DB.h"
#import "CallbackHandler.h"
#import "SUPConnectionStatus.h"
#import "SUPConnectionProfile.h"

@interface ConnectionController()

@property (nonatomic, retain) CallbackHandler *callbackHandler;

@end

@implementation ConnectionController

@synthesize callbackHandler;

static ConnectionController *appConnectionController;

+(void)beginApplicationSetup
{
    NSLog(@"inside controller");

    if(!appConnectionController)
    {
        NSLog(@"inside appconnectioncontroller");

        appConnectionController = [[[ConnectionController alloc] init] retain];

        appConnectionController.callbackHandler = [[CallbackHandler getInstance] retain];

        NSLog(@"end of it");
    }

    if([SUPApplication connectionStatus] == SUPConnectionStatus_DISCONNECTED)
    {
        NSLog(@"comparision method");

        [appConnectionController setupApplicationConnection];

        NSLog(@"end of comparision method");
    }

    else {
        NSLog(@"Already Connected");
    }
}

//end of beginApplication

-(BOOL)setupApplicationConnection{

    NSLog(@"inside bool1");

    SUPApplication *app = [SUPApplication getInstance];

    [app setApplicationIdentifier:@"HWC"];

    [app setApplicationCallback:self.callbackHandler];

    NSLog(@"inside bool2");

    SUPConnectionProperties *properties = [app connectionProperties];

    NSLog(@"servername");

    [properties setServerName:@"sapeccehp5.xxx.com"];  

    NSLog(@"inside bool2+line1");   

    [properties setPortNumber:5001];

    NSLog(@"middle bool2");

    [properties setFarmId:0];

    NSLog(@"inside bool2+line3");

    [properties setUrlSuffix:@"/tm/?cid=%cid%"];

    NSLog(@"inside bool2+line4"); 

    [properties setNetworkProtocol:@"http"];

    NSLog(@"inside bool3");

    SUPLoginCredentials *loginCred =[SUPLoginCredentials getInstance];

    [loginCred setUsername:@"ourmac"];

    [loginCred setPassword:nil];

    [properties setLoginCredentials:loginCred];

    [properties setActivationCode:@"1234"];

    NSLog(@"end of bool3");

    if(![flightDetailsTest_Flightdetails_v1DB databaseExists])
    {
        NSLog(@"inside dbif");

        [flightDetailsTest_Flightdetails_v1DB createDatabase];
    }

    NSLog(@"profile start out if");

    SUPConnectionProfile *connProfile = [flightDetailsTest_Flightdetails_v1DB getSynchronizationProfile];

    NSLog(@"start connection profile");

    [connProfile setClientId:@"0" ];

    NSLog(@"clientid");

    [connProfile setDomainName:@"Development"];

    NSLog(@"domain");

    [connProfile setUser:@"ourmac"];

    NSLog(@"user");

    [connProfile setPassword:@"password"];

    NSLog(@"pass");

   //  [connProfile setNetworkProtocol:@"http"];

    NSLog(@"netowrk");

    //  [connProfile setPortNumber:2480];

    NSLog(@"port");

    // [connProfile setServerName:@"sapeccehp5.xxx.com"];

    //  [connProfile setAsyncReplay:YES];

    [flightDetailsTest_Flightdetails_v1DB registerCallbackHandler:self.callbackHandler];

    [flightDetailsTest_Flightdetails_v1DB setApplication:app];

    if([SUPApplication registrationStatus] == SUPRegistrationStatus_REGISTERED)
    {
        [app startConnection:0];
    }
    else{

        [app registerApplication:0];
    }
}
@end

// and we have wrote the viewcontroller.m file as follows

-(IBAction)SearchAction:(id)sender{

    @try{
        [ConnectionController beginApplicationSetup];

        NSLog(@"inside applicationsetup");
    } 

    @catch (NSException *exception) {

        //[MessagingClientLib resetMessagingState];

        NSLog (@"Error-ConnectionAborted");
    }

    @try {
        [flightDetailsTest_Flightdetails_v1DB synchronize];

        NSLog(@"inside synchronise");
    }

    @catch (NSException *exception) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Synchronisation error"

message:@"Error-Please make sure that u r connected"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil ];

        [alert show];
        [alert release];
    }

    SUPObjectList *list =[flightDetailsSessionPersonalization findAll];

    NSLog(@"inside the list");

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"number of leaves" message:[NSString stringWithFormat:@"%d lines syncd",[list length]] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

    [alert show];

    [alert release];

    NSDateFormatter *temp = [[NSDateFormatter alloc] init];

    [temp setDateFormat:@"dd.mm.yyyy"];

    NSDate *date = [temp dateFromString:flightDate.text];

flightDetailsPersonalizationParameters *pp = [flightDetailsTest_Flightdetails_v1DB getPersonalizationParameters];

    [pp setPK_AIRLINEID:airlineID.text] ;

    [pp setPK_CONNECTIONID:connID.text];

    [pp setPK_FLIGHTDATE:date];

    [pp save];

    while([flightDetailsTest_Flightdetails_v1DB hasPendingOperations]){

        [NSThread sleepForTimeInterval:2];

    }

    [flightDetailsTest_Flightdetails_v1DB beginSynchronize];
 SUPObjectList *details = [flightDetailsflightdetails findAll];

    NSLog(@"flights on date %d",[details length]);

}

它显示状态为103 ..即,已连接,但它没有检索数据..控制台中的状态已附加到此处。请检查一下并为我们找到解决方案..

1 个答案:

答案 0 :(得分:0)

如果您获得103并且同步正确完成,则问题在于您在SUP服务器后面使用的数据源。

使用Sybase Mobile Workspace预览您的MBO(MBO属性 - >预览),如果它确实返回了一些记录,您需要检查MBO属性的“同步”部分以获取“自定义下载数据”部分,这可能会过滤你的结果。