-1

We have created an MBO named flight details which is having 3 input paramaters (airlineid, connectionid, flightdate). And generated the corresponding objective-c code. Now we have followed the steps for connecting to server as follows:

#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]);
}

It's showing the status as 103.. i.e., connected but it's not retrieving the data.. Status in console has been attached here. Please check this and find a solution for us..

Console--log

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
user1765037
  • 39
  • 2
  • 10
  • Please add the code to the question instead of linking to an external image that might go away any time. – vwegert Nov 26 '12 at 08:58

1 Answers1

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.

psychowood
  • 2,900
  • 1
  • 14
  • 14
  • Thank you Psychowood..I was using SUP 2.1.2 library files .I upgraded it to SUP 2.1.3 and used its library files.In 2.1.2 the problem was I was not getting the commented methods over here.Now the problem got solved.Anyway thank you for your reply. – user1765037 Jan 11 '13 at 11:25