File: eaf_n_cst_textproviderservice.sru
Size: 3429
Date: Tue, 22 Jan 2008 23:40:22 +0100
$PBExportHeader$eaf_n_cst_textproviderservice.sru
forward
global type eaf_n_cst_textproviderservice from n_cst_contentproviderservice
end type
end forward

global type eaf_n_cst_textproviderservice from n_cst_contentproviderservice
end type
global eaf_n_cst_textproviderservice eaf_n_cst_textproviderservice

forward prototypes
public function long createcontentmain (ref n_cst_datasetattrib anv_datasetattrib, ref s_mimedataset astr_mimedataset)
end prototypes

public function long createcontentmain (ref n_cst_datasetattrib anv_datasetattrib, ref s_mimedataset astr_mimedataset);////////////////////////////////////////////////////////////////
// Description:
//    Main method for the text createContent process
// 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.
//////////////////////////////////////////////////////////////// 

string                           METHOD_NAME = "createContentMain( REF n_cst_datasetattrib, REF s_mimedataset )"

string                           ls_value
string                           ls_filename
string                           ls_directory
string                           ls_data, ls_separator
long                             ll_row
string                           ls_cname, ls_labelsource

try
   //Generate the temporary file name
   if generateTempFileName( ls_directory, ls_filename ) = -1 then
      addError( METHOD_NAME, "Text generation failed.  Could not generate temporary filename." )
      return -1
   end if
   
   //Print the content
   if anv_datasetattrib.inv_argumentservice.GetArgument("SeparatorCharacter", ls_separator) = 1 then
      if anv_datasetattrib.inv_argumentservice.GetArgument("LabelSource", ls_labelsource) = 1 then
         if ls_labelsource = "ColumnName" then
            for ll_row = 1 to Integer(anv_datasetattrib.ids_working.Describe("DataWindow.Column.Count"))
                ls_cname = anv_datasetattrib.ids_working.Describe("#" + String(ll_row) + ".Name")
                anv_datasetattrib.ids_working.Modify(ls_cname + "_t.Text=" + ls_cname)
                if anv_datasetattrib.ids_working.Describe(ls_cname + ".coltype") = "datetime" then
                end if
            next
         end if
      end if
      if anv_datasetattrib.ids_working.saveAsFormattedText( ls_directory + ls_filename, EncodingUTF16LE! , ls_separator, "" ) = -1 then
         addError( METHOD_NAME, "Text generation failed.  SaveAsFormattedText " + ls_directory + ls_filename + " failed." )
         return -1
      end if      
   else
      if anv_datasetattrib.ids_working.saveAs( ls_directory + ls_filename,Text!, true, EncodingUTF16LE!) = -1 then
         addError( METHOD_NAME, "Text generation failed.  SaveAs " + ls_directory + ls_filename + " failed." )
         return -1
      end if
   end if
   
   //Set the file contents of the Text file on the dataset structure
   if readFile( ls_filename, ls_data, true ) = -1 then
      addError( METHOD_NAME, "Text generation failed.  Could not read the file." )
      return -1
   end if
   
   astr_mimedataset.data.text = ls_data
   
finally

end try

return 1

end function

on eaf_n_cst_textproviderservice.create
call super::create
end on

on eaf_n_cst_textproviderservice.destroy
call super::destroy
end on