-1

控制台--日志[http://i.stack.imgur.com/pIWvV.png] 大家好,

我们完全是这项技术的初学者 我们创建了一个名为 flight details 的 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 .. 即已连接,但未检索数据.. 控制台中的状态已附加到此处。请检查这一点并为我们找到解决方案..

4

1 回答 1

0

If you get a 103 and the sync completes correctly, the problem lies in the data source you are using behind the SUP server.

Use the Sybase Mobile Workspace to preview your MBOs (MBO properties -> preview), and if it does indeed return some records, you need to check the Synchronization section of your MBO properties for the "customized download data" section, which is probably filtering your results.

于 2013-01-11T10:49:31.803 回答