Handling SUDZC's response result-NSMutableArray - sudzc

I am using SUDZC with a web service that responds with several different arrays: E_ANT, EFULLNAME, E_RULE, E_VACDAYS. But when I take a look into the request result there are only the values for the E_ANT visible. How can I access the other items or is this not possible with sudzc?
<n0:Z_COM_URL_GETRECORDSResponse xmlns:n0="urn:sap-com:document:sap:rfc:functions">
<E_ANT>
<item>
<MANDT>010</MANDT>
<USERID>00000016</USERID>
<VAC_DATE>2012-01-09</VAC_DATE>
</item>
<item>
<MANDT>010</MANDT>
<USERID>00000016</USERID>
<VAC_DATE>2012-02-01</VAC_DATE>
</item>
....
<item>
<MANDT>010</MANDT>
<USERID>00000016</USERID>
<VAC_DATE>2012-03-15</VAC_DATE>
</item>
</E_ANT>
<E_FULLNAME>Vanessa Martinez</E_FULLNAME>
<E_RULE>
<item>
<MANDT>010</MANDT>
<USERID>00000016</USERID>
<DATE_FROM>2008-01-07</DATE_FROM>
<DATE_TO>9999-12-31</DATE_TO>
<VAC_ENTITLE>30.0</VAC_ENTITLE>
<ERNAM_ID>00004001</ERNAM_ID>
<ERDAT>2008-01-15</ERDAT>
</item>
</E_RULE>
<E_VACDAYS>
<MANDT>010</MANDT>
<USERID>00000016</USERID>
<KJAHR>2012</KJAHR>
<VAC_THIS_YEAR>30.0</VAC_THIS_YEAR>
</E_VACDAYS>
<E_VACPAID/>
</n0:Z_COM_URL_GETRECORDSResponse>

My output was not in xml. Are you showing us the output from sudzc or the actual xml data?
This is how I extracted my sudzc data
if( [value isKindOfClass:[NSError class]] || [value isKindOfClass:[SoapFault class]] )
{
NSLog(#"%#", [value description]);
return;
}
// Verify we're a dictionary
if( ![value isKindOfClass:[NSDictionary class]] ) {
NSLog(#"ERROR: Response not a dictionary");
return;
}
NSDictionary* dict = (NSDictionary*)value;
NSDictionary* resp = [dict objectForKey:#"E_AN"];
if( ( resp == nil ) || ![resp isKindOfClass:[NSDictionary class]] ) {
NSLog(#"ERROR: E_AN not a dictionary");
return;
}
dict = [resp objectForKey:#"item"];
if( ( dict == nil ) || ![dict isKindOfClass:[NSDictionary class]] ) {
NSLog(#"ERROR: item not a dictionary");
return;
}
resp = [dict objectForKey:#"MANDT"];
if( ( resp == nil ) || ![resp isKindOfClass:[NSDictionary class]] ) {
NSLog(#"ERROR: MANDT not a dictionary");
return;
}
...

Related

Laravel pagination with raw query

When I put pagination(50); it shows WhereNull does not exist. and then I go make the whereNull into ctrl + /
and it show the next line which is OrderBy not exist. I seriously dont know where the problem is.. because I want to make pagination without using datatable from a DB::raw query.....
public function searchParticipation(Request $request){
ini_set('memory_limit','2G');
if ($request->method() != 'POST') {
return redirect()->route('ticketparticipation.view');
}
$replaceStartDate = $this->remove_string($request['start_date']);
$replaceEndDate = $this->remove_string($request['end_date']);
$valStartDate = strtotime($replaceStartDate) + (60*60*8);
$valEndDate = strtotime($replaceEndDate) + (60*60*24) + (60*60*8) - 1;
$event_id = $request['event_id'];
$category_id = $request['category_id'];
$ticket_number = $request['ticket_number'];
$full_name = $request['full_name'];
$dataEvent = array(
'event_id' => $event_id,
'category_id' => $category_id,
'ticket_number' => $ticket_number
);
$superadmins = User::UserOrganizer()->get();
$user_id = Session::get('user_id');
$roles = Session::get('roles');
if(empty(Session::get('roles'))){
auth()->logout();
return redirect('/admin/logout2');
}
$eventx = Event::query();
$eventx = $eventx->select('id', 'name');
if ($roles == 'Organizer-Admin') {
$eventx->Where('admin_id','=',$user_id);
$event = $eventx->Where('is_deleted','=','0')->get(); //->Where('is_active','=','1')
}elseif($roles == 'Organizer-Project'){
$eventx->Where('project_manager_id','=',$user_id);
$event = $eventx->Where('is_deleted','=','0')->get(); //->Where('is_active','=','1')
}elseif($roles == 'Organizer-Super-Admin'){
$eventx->Where('superadmin_id','=',$user_id);
$event = $eventx->Where('is_deleted','=','0')->get(); //->Where('is_active','=','1')
}elseif($roles == 'Superadmin-Organizer'){
$event = $eventx->Where('is_deleted','=','0')->get(); //->Where('is_active','=','1')
}
$data = array(
'user_id' => $user_id,
'roles' => $roles,
'date_start' => $request['start_date'],
'date_end' => $request['end_date']
);
if($data['roles'] == 'Organizer-Admin'){
$field = "event.admin_id";
}elseif($data['roles'] == 'Organizer-Project'){
$field = "event.project_manager_id";
}else{
$field = "event.superadmin_id";
}
$tCount = EventParticipation::Select('event_participation.id')
->join('event', 'event.id', '=', 'event_participation.event_id')
->join('categories', 'categories.id', 'event_participation.run_id');
if($event_id != ''){
$tCount = $tCount->Where("event_participation.event_id", "=", $event_id);
}
if($category_id != ''){
$tCount = $tCount->Where("event_participation.run_id", "=", $category_id);
}
if($ticket_number != ''){
$tCount = $tCount->Where(DB::raw('concat(event.ticket_number_prepend,"",event_participation.queue_id)') , '=' , $ticket_number);
}
if($full_name != ''){
$tCount = $tCount->Where("event_participation.full_name", 'LIKE' , '%'.$full_name.'%');
}
$tCount = $tCount->Where("event_participation.acceptance_date", "<>", 0)
->Where("event_participation.is_participating", "=", 1)
->Where("event_participation.is_deleted", "=", 0)
->OrderBy('event_participation.creation_date','ASC')
->get();
$eventDetail = Event::Select('name', 'registration_end', 'type','primary_currency')->Where('id', '=', $event_id)->first();
if($tCount->count() < 10000) {
$ticketParticipation = EventParticipation::Select(
DB::raw("if(epu.full_name is not null, epu.full_name, event_participation.full_name) as full_name"),
DB::raw("if(epu.address is not null, epu.address, event_participation.address) as address"),
DB::raw("if(epu.city is not null, epu.city, event_participation.city) as city"),
DB::raw("if(epu.postcode is not null, epu.postcode, event_participation.postcode) as postcode"),
DB::raw("if(epu.state is not null, epu.state, event_participation.state) as state"),
DB::raw("if(epu.country is not null, epu.country, event_participation.country) as country"),
DB::raw("if(epu.additional_info is not null, epu.additional_info, event_participation.additional_info) as additional_info"),
'event_participation.id', 'event_participation.delivery_company', 'event_participation.tracking_number', 'event_participation.run_id','event_participation.event_id', 'event_participation.local_transaction_number', 'event_participation.user_id',
'event_participation.nric_passport', 'event_participation.gender', 'event_participation.tshirt_size', 'event_participation.nationality',
'event_participation.email', 'event_participation.contact_number', 'event_participation.emergency_contact_name', 'event_participation.emergency_contact_number', 'event_participation.medical_conditions', 'event_participation.amount',
'event_participation.after_discount', 'event_participation.discount_id', 'event_participation.payment_type', 'event_participation.remarks',
'event.name AS eventname', 'event.ticket_number_prepend', 'categories.title AS run_title', 'event_participation.date_of_birth', 'event_participation.creation_date', 'event_participation.acceptance_date',
DB::raw("FROM_UNIXTIME(`event_participation`.`creation_date`,\"%d-%m-%Y %h:%i:%s %p\") AS `register_date`"),
DB::raw("CONCAT(event.`ticket_number_prepend`, '', event_participation.`queue_id`) AS `ticket_number`"),
'virtual_parcel_shipping_order.awb_id','virtual_parcel_shipping_order.awb_url','virtual_parcel_shipping_order.tracking_url','virtual_parcel_shipping_order.shipping_status',
'virtual_parcel_shipping_order.pick_up_date','virtual_parcel_shipping_order.parcel_content',
'virtual_parcel_shipping_order.status','virtual_parcel_shipping_order.response')//DB::raw("FROM_UNIXTIME(`event_participation`.`date_of_birth`,\"%d-%m-%Y\") AS `dob`"),
->join('event', 'event.id', '=', 'event_participation.event_id')
->join('categories', 'categories.id', 'event_participation.run_id')
->leftjoin('event_participation_report_status','participation_id','event_participation.id')
->leftjoin('virtual_parcel_shipping_order','participant_id','event_participation.id')
->leftjoin('event_participation_utf8 as epu', 'event_participation.id', 'epu.participation_id')->paginate(50); <<<<<<<< got problem when I add in paginate(50)
if($event_id != ''){
$ticketParticipation = $ticketParticipation->Where("event_participation.event_id", "=", $event_id);
}
if($category_id != ''){
$ticketParticipation = $ticketParticipation->Where("event_participation.run_id", "=", $category_id);
}
if($ticket_number != ''){
$ticketParticipation = $ticketParticipation->Where(DB::raw('concat(event.ticket_number_prepend,"",event_participation.queue_id)') , '=' , $ticket_number);
}
if($full_name != ''){
$ticketParticipation = $ticketParticipation->Where("event_participation.full_name", 'LIKE' , '%'.$full_name.'%');
}
$ticketParticipation = $ticketParticipation->Where("event_participation.acceptance_date", "<>", 0)
->Where("event_participation.is_participating", "=", 1)
->Where("event_participation.is_deleted", "=", 0)
->WhereNull("event_participation_report_status.participation_id")
->OrderBy('event_participation.queue_id', 'DESC')
->get()->chunk(1000);
$eventDiscount = EventDiscountCode::Select('id', 'event_id', 'amount', 'code')->Where('event_id', $event_id)->get();
return view('admin.organizer.participant_summary',['ticketParticipation'=>$ticketParticipation], compact('event', 'ticketParticipation', 'eventDiscount', 'dataEvent', 'eventDetail'));
}else{
return view('admin.organizer.participant_summaryv2', compact('event','data', 'dataEvent', 'eventDetail'));
}
}
I am seriously not sure where is the problem.....

treemodel + skype-bots Cannot read property 'model' of undefined

I'm working on skype bot app. I have issue with read the node from tree-model.
Tree-model example follow the children node but my node has diff tab to read by system.
XML example-
<?xml version="1.0" encoding="UTF-8" ?>
<rootmenu id="1" title="menu" description="What scenario would you like to run?">
<MenuOption id="1.1" title="Company Data" response="You entered company data" description="What action would you like to perform">
<HierarchyMenuItem id="1.1.1.1" title="Select new data " response="You entered select new filter">
<action>Filter</action>
</HierarchyMenuItem>
<HierarchyMenuItem id="1.1.1.2" title="Navigate node" response="You entered select node">
<action description="Current Filter is ">Hierarchy</action>
<HierarchyLevel level="1" name="One" navigateHierarchy="true">
<action>RootAction</action>
<Option title="Select a Country">
<OptionChoices id="1" title="One1" refNode="ForOne1" />
<OptionChoices id="2" title="One2" refNode="ForOne2" />
<OptionChoices id="3" title="One3" refNode="ForOne3" />
<OptionChoices id="4" title="One4" refNode="ForOne4" />
</Option>
</HierarchyLevel>
</HierarchyMenuItem>
</MenuOption>
<MenuOption id="1.2" title="Adhoc Data">
<Option>
<OptionChoices id="1" title="Ad1" refNode="ForAdOne1" />
<OptionChoices id="2" title="Ad2" refNode="ForAdOne2" />
<OptionChoices id="3" title="Ad3" refNode="ForAdOne3" />
<OptionChoices id="4" title="Ad4" refNode="ForAdOne4" />
</Option>
</MenuOption>
<MenuOption id="1.3" title="(quit)">
</MenuOption>
</rootmenu>
Read the xml from server-
function getXMLData(callback) {
var request = require('request');
var DOMParser = require('xmldom').DOMParser;
var simpleconvertxml = require('simpleconvert-xml');
request('http://demo.in/RefactoredXML.xml', function (error, response, body) {
if (!error && response.statusCode == 200) {
var xmlnode = new DOMParser().parseFromString([body].join('\n'), 'text/xml');
var myNumber = simpleconvertxml.getXMLAsObj(xmlnode);
treeRoot = tree.parse(myNumber.rootmenu);
callback(treeRoot);
}
})
}
My first bot call
bot.dialog('/menu', [
function (session, args) {
getXMLData(function (treeRoot) {
//session.send('node place:'+treeRoot.model.title);
var firstChild = [];
for (var i = 0; i < treeRoot.model.MenuOption.length; i++) {
if(treeRoot.model.MenuOption[i].title !='' && treeRoot.model.MenuOption[i].title != undefined && treeRoot.model.MenuOption[i].title != null) {
firstChild.push(treeRoot.model.MenuOption[i].title);
}
}
if(firstChild.length > 0) {
builder.Prompts.choice(session, treeRoot.model.description,firstChild );
// it shows builder.Prompts.choice(session, "What scenario would you like to run? ", "company data|adhoc data|(quit)");
} else {
session.send('Something went wrong. You can use the back or top command.');
}
});
},
function (session, results) {
if (results.response && results.response.entity != '(quit)') {
session.userData.profile.treeSelectdNodeTitle = results.response.entity;
getXMLData(function (treeRoot) {
for (var i = 0; i < treeRoot.model.MenuOption.length; i++) {
if(treeRoot.model.MenuOption[i].title == session.userData.profile.treeSelectdNodeTitle) {
session.userData.profile.treeSelectdNodeId = treeRoot.model.MenuOption[i].id;
session.userData.profile.treeSelectdResponse = treeRoot.model.MenuOption[i].response;
}
}
session.send('resp ' + session.userData.profile.treeSelectdResponse);
if(treeRoot.hasChildren()) {
session.send('in the children');
session.beginDialog('/get Tree Node');
} else {
session.send('in the title');
session.beginDialog('/'+ treeRoot.model.title);
}
});
} else {
// Exit the menu
session.endDialog();
}
},
function (session, results) {
// The menu runs a loop until the user chooses to (quit).
session.replaceDialog('/menu');
}
]).reloadAction('reloadMenu', null, {matches: /^menu|show menu|top|top menu/i});
Menu dialog call should display 1.company data 2. adhoc data 3. (quit) but its showing only 1.company data 2.adhoc data and Issue in the menu is if user select the 1 option as Company Data it will not goes to treeRoot.hasChildren() condition.
bot.dialog('/get Tree Node', [
function(session,agrs) {
getTreeNode(session);
}
]);
function getTreeNode(session) {
session.send("in tree "+ session.userData.profile.treeSelectdNodeId);
getXMLData(function(treeRoot) {
var nextLevel = treeRoot.first(function (node) {
return node.model.id === session.userData.profile.treeSelectdNodeId;
});
session.send('selected title '+ nextLevel.model.HierarchyMenuItem[0].title);
/* var secondListChild = [];
for(var i = 0; i < nextLevel.model.HierarchyMenuItem.length; i++) {
if(nextLevel.model.HierarchyMenuItem[i].title !='' && nextLevel.model.HierarchyMenuItem[i].title != undefined && nextLevel.model.HierarchyMenuItem[i].title != null) {
secondListChild.push(nextLevel.model.HierarchyMenuItem[i].title);
}
}
if(secondListChild.length > 0) {
builder.Prompts.choice(session, nextLevel.model.description,secondListChild);
} else {
session.send('Something went wrong. You can use the back or top command.');
} */
});
}
issue with the getTreeNode is
session.send('selected title '+ nextLevel.model.HierarchyMenuItem[0].title);
^
TypeError: Cannot read property 'model' of undefined
Got Solution....
I have change the XML parse NPM and its working for me..
var parse = require('xml-parser');
var inspect = require('util').inspect;
function getXMLData(callback) {
var request = require('request');
request('http://ztdemo.headfitted.in/RefactoredXML.xml', function (error, response, body) {
if (!error && response.statusCode == 200) {
var obj = parse(body);
//console.log(inspect(obj, { colors: true, depth: Infinity }));
//callback(treeRoot);
treeRoot = tree.parse(obj.root);
callback(treeRoot);
}
})
}

How to select multiple items in treewidget and delete those items?

When I am selecting items in treewidget and then clicked on delete button then is is just deleting top most item only from treewidget
Can you correct this code?
This function is calling in connect statement while clicking on button
void TableDockWidget::deleteGroup() {
QTreeWidgetItem *item = treeWidget->currentItem();
QTreeWidgetItem* nextItem = treeWidget->itemBelow(item);
if ( item == NULL ) return;
PeakGroup* group = getSelectedGroup(); //this function is using to //select items from treewidget
if ( group == NULL ) return;
PeakGroup* parentGroup = group->parent;
if ( parentGroup == NULL ) { //top level item
deleteGroup(group); //this is using to delete group
} else if ( parentGroup && parentGroup->childCount() ) { //this a child item
if ( parentGroup->deleteChild(group) ) {
QTreeWidgetItem* parentItem = item->parent();
if ( parentItem ) {
parentItem->removeChild(item);
delete(item);
}
}
}
//show NextItem
if(nextItem) treeWidget->setCurrentItem(nextItem,0);
return;
}
//here, code of function which is selecting items.
PeakGroup* TableDockWidget::getSelectedGroup() {
QTreeWidgetItem *item = treeWidget->currentItem();
if (!item) return NULL;
QVariant v = item->data(0,Qt::UserRole);
PeakGroup* group = v.value<PeakGroup*>();
if ( group != NULL ) { return group; }
return NULL;
}
// code of function which is deleting group
void TableDockWidget::deleteGroup(PeakGroup *groupX) {
qDebug() << "TableDockWidget::deleteGroup()";
if(!groupX) return;
int pos=-1;
for(int i=0; i < allgroups.size(); i++) {
if ( &allgroups[i] == groupX ) {
pos=i; break;
}
}
if (pos == -1) return;
//qDebug() << "Delete pos=" << pos;
QTreeWidgetItemIterator it(treeWidget);
while (*it) {
QTreeWidgetItem* item = (*it);
if (item->isHidden()) { ++it; continue; }
QVariant v = item->data(0,Qt::UserRole);
PeakGroup* group = v.value<PeakGroup*>();
if ( group != NULL and group == groupX) {
item->setHidden(true);
//Deleteing
allgroups.erase(allgroups.begin()+pos);
int posTree = treeWidget->indexOfTopLevelItem(item);
if (posTree != -1) treeWidget->takeTopLevelItem(posTree);
break;
}
++it;
}
for(unsigned int i = 0; i < allgroups.size(); i++) {
allgroups[i].groupId = i + 1;
}
updateTable();
_mainwindow->getEicWidget()->replotForced();
}
PeakGroup* TableDockWidget::getSelectedGroup() {
PeakGroup* group;
QList<QTreeWidgetItem*>selected = treeWidget->selectedItems();
if(selected.size() == 0) return NULL;
Q_FOREACH (QTreeWidgetItem* item, selected) {
QVariant v = item->data(0,Qt::UserRole);
group = v.value<PeakGroup*>();
item->setHidden(true);
}
if ( group != NULL ) { return group; }
else
return NULL;
}

Conflict in a FileDownload control in Notes 9 XPage

I am using this code placed in beforeRenderResponse event of an XPage in a notes 8.5.3 application:
function overrideFileDownloadAction( fDownload ){
if( fDownload === null )
return;
rekOverrideFileDownloadAction( fDownload, fDownload );
}
function rekOverrideFileDownloadAction( component:javax.faces.component.UIOutput, fDownload:com.ibm.xsp.component.UIFileDownload ){
try{
var children:java.util.List = component.getChildren();
var it:java.util.Iterator = children.iterator();
var curChild:javax.faces.component.UIOutput;
while( it.hasNext() ){
curChild = it.next();
if( typeof( curChild ) === 'com.ibm.xsp.component.xp.XspEventHandler' ){
var group = new com.ibm.xsp.actions.ActionGroup();
var list = new java.util.ArrayList();
group.setComponent( fDownload );
list.add( curChild.getAction() );
list.add( mBinding );
group.setActions( list );
curChild.setAction(group);
}
rekOverrideFileDownloadAction( curChild , fDownload );
}
}catch(e){}
}
viewScope.flag_remove = false;
var code = "#{javascript:var fileDownload1:com.ibm.xsp.component.xp.XspFileDownload = getComponent('fileDownload1');var index = fileDownload1.getRowIndex(); if(viewScope.flag_remove == false){viewScope.types.removeElementAt(index); viewScope.flag_remove = true}}";
var mBinding = facesContext.getApplication().createMethodBinding(code, null );
overrideFileDownloadAction( getComponent( 'fileDownload1' ) );
I use this in order to save some info together with the file (i.e i have a drop down to select the type of file that i upload). So i want this info to be deleted and added together with the uploaded file.
I found the code above by googling and it works normally.
Now i installed Notes 9 and i want to test my app for potential issues.
I get this error:
com.ibm.xsp.actions.ActionGroup incompatible with
com.ibm.xsp.actions.DeleteAttachmentsAction
when switching a document to edit mode.
Does anyone have the same problem? Any solutions?

Sharepoint client object model: How to get all the fields in a list

I have a list named "Discussions List". I want to bring all columns from the list.
I want to know how to do it SharePoint Client Object Model.
OK. Found the solution. Answer Here using a list I'm getting by title, but will work with any method:
// Get your ClientContext for your site in 'clientContext'
SP.List oList = clientContext.Web.Lists.GetByTitle("List Title Here");
SP.FieldCollection fieldColl = oList.Fields;
clientContext.Load(fieldColl);
clientContext.ExecuteQuery();
foreach (SP.Field fieldTemp in fieldColl)
{
MessageBox.Show(fieldTemp.InternalName.ToString()); //I used MessageBox to show, but you can do whatever you like with it here.
}
Bingo. You're going to love this. Thank goodness for generics and Linq!
// return all rows and (selected) fields of a list--fields are included dynamically
private Dictionary<string,Dictionary<string,object>> getListData( ClientContext ctx )
{
Log.LogMessage( "Fetching {0}{1}", ctx.Url, ListName );
var list = ctx.Web.Lists.GetByTitle( ListName );
// fetch the fields from this list
FieldCollection fields = list.Fields;
ctx.Load( fields );
ctx.ExecuteQuery();
// dynamically build a list of fields to get from this list
var columns = new List<string> { "ID" }; // always include the ID field
foreach( var f in fields )
{
// Log.LogMessage( "\t\t{0}: {1} of type {2}", f.Title, f.InternalName, f.FieldTypeKind );
if( f.InternalName.StartsWith( "_" ) || f.InternalName.StartsWith( "ows" ) ) continue; // skip these
if( f.FieldTypeKind == FieldType.Text ) // get Text fields only... but you can get other types too by uncommenting below
// || f.FieldTypeKind == FieldType.Counter
// || f.FieldTypeKind == FieldType.User
// || f.FieldTypeKind == FieldType.Integer
// || f.FieldTypeKind == FieldType.Number
// || f.FieldTypeKind == FieldType.DateTime
// || f.FieldTypeKind == FieldType.Lookup
// || f.FieldTypeKind == FieldType.Computed
// || f.FieldTypeKind == FieldType.Boolean )
{
columns.Add( f.InternalName );
}
}
// build the include expression of which fields to fetch
List<Expression<Func<ListItemCollection, object>>> allIncludes = new List<Expression<Func<ListItemCollection, object>>>();
foreach( var c in columns )
{
// Log.LogMessage( "Fetching column {0}", c );
allIncludes.Add( items => items.Include( item => item[ c ] ) );
}
// get all the items in the list with the fields
ListItemCollection listItems = list.GetItems( CamlQuery.CreateAllItemsQuery() );
ctx.Load( listItems, allIncludes.ToArray() );
ctx.ExecuteQuery();
var sd = listItems.ToDictionary( k => k["Title"] as string, v => v.FieldValues ); // FieldValues is a Dictionary<string,object>
// show the fields
foreach( var i in sd.Keys )
{
Log.LogMessage( "\tItem: {0}", i );
foreach( var c in columns )
{
Log.LogMessage( "\t\t{0}: {1}", c, sd[ i ][ c ] );
}
}
return sd;
}

Resources