$PBExportHeader$eaf_n_cst_xmlproviderservice.sru forward global type eaf_n_cst_xmlproviderservice from n_cst_contentproviderservice end type end forward global type eaf_n_cst_xmlproviderservice from n_cst_contentproviderservice end type global eaf_n_cst_xmlproviderservice eaf_n_cst_xmlproviderservice forward prototypes public function long createcontentmain (ref n_cst_datasetattrib anv_datasetattrib, ref s_mimedataset astr_mimedataset) public function long prepareupdatemain (ref n_cst_datasetattrib anv_datasetattrib, ref s_mimedataset astr_mimedataset, ref n_cst_dataset anv_dataset) end prototypes public function long createcontentmain (ref n_cst_datasetattrib anv_datasetattrib, ref s_mimedataset astr_mimedataset);//////////////////////////////////////////////////////////////// // Description: // Create an XML version of a DataSet // Limited to creating data in server operating system's character set // Revisions // 3.0 - Initial version // Arguments: // n_cst_datasetattrib - REF // s_mimerequest - REF // Returns: // 1 - Success // -1 - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft, Inc. All rights reserved. // Any distribution of the Youngsoft, Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft, Inc. is prohibited. //////////////////////////////////////////////////////////////// constant string METHOD_NAME = "createContentMain (REF n_cst_datasetattrib, REF s_mimedataset)" long ll_rowcount long ll_rowindex long ll_columncount long ll_columnindex string ls_columnnames[] string ls_dbcolumnnames[] string ls_columntypes[] string ls_columnvalue string ls_rootelementname Boolean lb_showcolumndetail n_cst_xmlparser lnv_parser n_cst_stringservice lnv_string try //whether show column detail in XML, column detail XML will not parser successfully in ajax lb_showcolumndetail = false ll_rowcount = anv_datasetattrib.ids_working.rowCount() ll_columncount = long( anv_datasetattrib.ids_working.describe( "Datawindow.Column.Count" ) ) //loop through the columns gathering metadata for ll_columnindex = 1 to ll_columncount ls_columnnames[ll_columnindex] = anv_datasetattrib.ids_working.describe( "#" + string( ll_columnindex) + ".Name" ) ls_dbcolumnnames[ll_columnindex] = anv_datasetattrib.ids_working.describe( "#" + string( ll_columnindex) + ".dbName" ) ls_columntypes[ll_columnindex] = lower( anv_datasetattrib.ids_working.describe( "#" + string( ll_columnindex) + ".ColType" ) ) next lnv_parser = create n_cst_xmlparser lnv_string = create n_cst_stringservice ls_rootelementname = lnv_string.globalReplace( anv_datasetattrib.is_name, " " , "", false ) //Root element of the XML document is the DataSet name lnv_parser.addElement( ls_rootelementname ) //Create the XML document for ll_rowindex = 1 to ll_rowcount lnv_parser.addElement( ls_rootelementname + "Row" ) lnv_parser.addElement( "RowStatus", string(anv_datasetattrib.ids_working.getItemStatus(ll_rowindex, 0, Primary! )), false, true ) for ll_columnindex = 1 to ll_columncount Choose Case left( ls_columntypes[ll_columnindex], 3 ) Case "cha" ls_columnvalue = anv_datasetattrib.ids_working.getItemString( ll_rowindex, ls_columnnames[ll_columnindex] ) Case "dat" if ls_columntypes[ll_columnindex] = "date" then ls_columnvalue = string( anv_datasetattrib.ids_working.getItemDate( ll_rowindex, ls_columnnames[ll_columnindex] ) ) else ls_columnvalue = string( anv_datasetattrib.ids_working.getItemDateTime( ll_rowindex, ls_columnnames[ll_columnindex] ) ) end if Case "dec" ls_columnvalue = string( anv_datasetattrib.ids_working.getItemNumber( ll_rowindex, ls_columnnames[ll_columnindex] ) ) Case "int" ls_columnvalue = string( anv_datasetattrib.ids_working.getItemNumber( ll_rowindex, ls_columnnames[ll_columnindex] ) ) Case "lon" ls_columnvalue = string( anv_datasetattrib.ids_working.getItemNumber( ll_rowindex, ls_columnnames[ll_columnindex] ) ) Case "num" ls_columnvalue = string( anv_datasetattrib.ids_working.getItemNumber( ll_rowindex, ls_columnnames[ll_columnindex] ) ) Case "rea" ls_columnvalue = string( anv_datasetattrib.ids_working.getItemNumber( ll_rowindex, ls_columnnames[ll_columnindex] ) ) Case "tim" if ls_columntypes[ll_columnindex] = "time" then ls_columnvalue = string( anv_datasetattrib.ids_working.getItemTime( ll_rowindex, ls_columnnames[ll_columnindex] ) ) else ls_columnvalue = string( anv_datasetattrib.ids_working.getItemDateTime( ll_rowindex, ls_columnnames[ll_columnindex] ) ) end if Case "ulong" ls_columnvalue = string( anv_datasetattrib.ids_working.getItemNumber( ll_rowindex, ls_columnnames[ll_columnindex] ) ) End Choose //Add the element to the XML document if lb_showcolumndetail then lnv_parser.addElement( ls_columnnames[ll_columnindex] ) lnv_parser.addElement( "Value", ls_columnvalue, false, true ) lnv_parser.addElement( "ColumnStatus", string(anv_datasetattrib.ids_working.getItemStatus(ll_rowindex, ls_columnnames[ll_columnindex], Primary! )), false, true ) lnv_parser.closeElement( ls_columnnames[ll_columnindex] ) else lnv_parser.addElement( ls_columnnames[ll_columnindex], ls_columnvalue ) end if next lnv_parser.closeElement( ls_rootelementname + "Row" ) next lnv_parser.closeElement( anv_datasetattrib.is_name ) //Get the resulting XML document and place it on the reference structure for return to the client if lnv_parser.getDocument( astr_mimedataset.data.text ) = -1 then addError( METHOD_NAME, "Failed to generate the XML document" ) return -1 end if finally if isValid( lnv_parser ) then destroy lnv_parser end if end try return 1 end function public function long prepareupdatemain (ref n_cst_datasetattrib anv_datasetattrib, ref s_mimedataset astr_mimedataset, ref n_cst_dataset anv_dataset);constant string METHOD_NAME = "prepareUpdateMain (REF n_cst_datasetattrib, REF s_mimedataset, REF n_cst_dataset)" //////////////////////////////////////////////////////////////// // Description: // Main method in prepareUpdate process to accept XML resultset of changes // Revisions // 3.0 - Initial version // Arguments: // n_cst_datasetattrib - REF // s_mimerequest - REF // anv_dataset - REF // Returns: // 1 - Success // -1 - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft, Inc. All rights reserved. // Any distribution of the Youngsoft, Inc. Enterprise Application Framework // source code in whole or part by other than Youngsoft, Inc. is prohibited. //////////////////////////////////////////////////////////////// long ll_rowcount long ll_rowindex long ll_columncount long ll_columnindex string ls_columnnames[] string ls_dbcolumnnames[] string ls_columntypes[] string ls_columnvalue string ls_rootelementname string ls_rows[] string ls_column[] string ls_rowstatuses[] string ls_columnstatuses[] string ls_columnvalues[] boolean lb_checkcolumnstatus n_cst_xmlparser lnv_parser n_cst_stringservice lnv_string try ll_rowcount = anv_datasetattrib.ids_working.rowCount() ll_columncount = long( anv_datasetattrib.ids_working.describe( "Datawindow.Column.Count" ) ) //loop through the columns gathering metadata for ll_columnindex = 1 to ll_columncount ls_columnnames[ll_columnindex] = anv_datasetattrib.ids_working.describe( "#" + string( ll_columnindex) + ".Name" ) ls_dbcolumnnames[ll_columnindex] = anv_datasetattrib.ids_working.describe( "#" + string( ll_columnindex) + ".dbName" ) ls_columntypes[ll_columnindex] = lower( anv_datasetattrib.ids_working.describe( "#" + string( ll_columnindex) + ".ColType" ) ) next lnv_parser = create n_cst_xmlparser lnv_string = create n_cst_stringservice inv_log.propagateSettings( lnv_parser ) ls_rootelementname = lnv_string.globalReplace( anv_datasetattrib.is_name, " " , "", false ) //get arguments in string array lnv_parser.getElementList( astr_mimedataset.data.text, ls_rootelementname + "Row", ls_rows) ll_rowcount = upperBound( ls_rows ) //Loop through the rows for ll_rowindex = 1 to ll_rowcount //Get the Row Status lnv_parser.getElementList( ls_rows[ll_rowindex], "RowStatus", ls_rowstatuses) //Create the row anv_datasetattrib.ids_working.insertRow( anv_datasetattrib.ids_working.rowCount() ) Choose Case ls_rowstatuses[1] Case "NotModified!" lb_checkcolumnstatus = false Case "DataModified!" lb_checkcolumnstatus = true Case "NewModified!" lb_checkcolumnstatus = true End Choose for ll_columnindex = 1 to ll_columncount //Check to see if the column exists lnv_parser.getElementList( ls_rows[ll_rowindex], ls_columnnames[ll_columnindex], ls_column) if upperBound( ls_column ) > 0 then //Column exists in the Row //Set the value lnv_parser.getElementList( ls_column[1], "Value", ls_columnvalues) Choose Case left( ls_columntypes[ll_columnindex], 3 ) Case "cha" anv_datasetattrib.ids_working.setItem( ll_rowindex, ls_columnnames[ll_columnindex], ls_columnvalues[1] ) Case "dat" if ls_columntypes[ll_columnindex] = "date" then anv_datasetattrib.ids_working.setItem( ll_rowindex, ls_columnnames[ll_columnindex], Date(ls_columnvalues[1]) ) else anv_datasetattrib.ids_working.setItem( ll_rowindex, ls_columnnames[ll_columnindex], DateTime(ls_columnvalues[1]) ) end if Case "dec" anv_datasetattrib.ids_working.setItem( ll_rowindex, ls_columnnames[ll_columnindex], Dec(ls_columnvalues[1]) ) Case "int" anv_datasetattrib.ids_working.setItem( ll_rowindex, ls_columnnames[ll_columnindex], Integer(ls_columnvalues[1]) ) Case "lon" anv_datasetattrib.ids_working.setItem( ll_rowindex, ls_columnnames[ll_columnindex], Long(ls_columnvalues[1]) ) Case "num" anv_datasetattrib.ids_working.setItem( ll_rowindex, ls_columnnames[ll_columnindex], Dec(ls_columnvalues[1]) ) Case "rea" anv_datasetattrib.ids_working.setItem( ll_rowindex, ls_columnnames[ll_columnindex], Real(ls_columnvalues[1]) ) Case "tim" if ls_columntypes[ll_columnindex] = "time" then anv_datasetattrib.ids_working.setItem( ll_rowindex, ls_columnnames[ll_columnindex], Time(ls_columnvalues[1]) ) else anv_datasetattrib.ids_working.setItem( ll_rowindex, ls_columnnames[ll_columnindex], DateTime(ls_columnvalues[1]) ) end if Case "ulong" anv_datasetattrib.ids_working.setItem( ll_rowindex, ls_columnnames[ll_columnindex], Long(ls_columnvalues[1]) ) End Choose if lb_checkcolumnstatus then lnv_parser.getElementList( ls_column[1], "ColumnStatus", ls_columnstatuses) Choose Case ls_columnstatuses[1] Case "NotModified!" anv_datasetattrib.ids_working.setItemStatus( ll_rowindex, ls_columnnames[ll_columnindex], Primary!, NotModified! ) Case "DataModified!" anv_datasetattrib.ids_working.setItemStatus( ll_rowindex, ls_columnnames[ll_columnindex], Primary!, DataModified! ) Case "NewModified!" anv_datasetattrib.ids_working.setItemStatus( ll_rowindex, ls_columnnames[ll_columnindex], Primary!, NewModified! ) End Choose else anv_datasetattrib.ids_working.setItemStatus( ll_rowindex, ls_columnnames[ll_columnindex], Primary!, NotModified! ) end if end if next //Set the row status Choose Case ls_rowstatuses[1] Case "NotModified!" anv_datasetattrib.ids_working.setItemStatus( ll_rowindex, 0, Primary!, NotModified! ) Case "DataModified!" anv_datasetattrib.ids_working.setItemStatus( ll_rowindex, 0, Primary!, DataModified! ) Case "NewModified!" anv_datasetattrib.ids_working.setItemStatus( ll_rowindex, 0, Primary!, NewModified! ) End Choose next finally if isValid( lnv_parser ) then destroy lnv_parser end if end try return 1 end function on eaf_n_cst_xmlproviderservice.create call super::create end on on eaf_n_cst_xmlproviderservice.destroy call super::destroy end on
File: eaf_n_cst_xmlproviderservice.sru
Size: 12644
Date: Tue, 22 Jan 2008 23:40:21 +0100
Size: 12644
Date: Tue, 22 Jan 2008 23:40:21 +0100
- n_cst_contentproviderservice eaf_n_cst_xmlproviderservice(sru)