#include <origin.h>
#include <GetNBox.h>
#include <xfutils.h>
//put additional include files here
#include <GetNbox.h>
#include <..\OriginLab\fu_utils.h>
//#include <..\OriginLab\tdmfile.h>	
#include <..\OriginLab\diademimport.h>	// Hong 01/19/07 NEW_CODE_USE_DLL

///////////////////////////////////////////////////////////////////////
//////// modification log
/// Hong 03/28/07 v8.0591 CENTRALIZE_CHECK_CALID_RANGE
/// Hong 04/10/07 v8.0597b IGNORE_FNAME$_WHEN_FROM_MENU
/// Sim 06-25-2007 UPDATE_ORGANIZER
/// Hong 09/06/07 v8.0697 ALLOW_EMPTY_CHANNEL_GROUP
/// Hong 09/26/07 8.0709 CLEAN_OPEN_SAVE_DIALOG_TITLE_TO_DEFAULT
/// Hong 10/24/07 QA80-10541 FIX_FILEPATH_CONTAIL_ALL_FILES_PATH
/// Hong 03/13/08 QA80-10343 CUSTOMER_WANT_CHECK_UNCHECK_FOR_GROUPS_LEVEL
/// Hong 11/11/09 FIX_TDM_RUNTIME_ERROR
/// Sim 02-01-2010 QA81-15050-P1 ADD_CUSTOM_PROPERTIES_INTO_COL_PARAMETERS
/// Hong 02/02/10 QA80-15051 IMPRORT_SUPPORT_PROGRESSBAR
///////////////////////////////////////////////////////////////////////

///---Sim 02-01-2010 QA81-15050-P1 ADD_CUSTOM_PROPERTIES_INTO_COL_PARAMETERS
#define STR_CUSTOM_PROP_CHANNEL	"CustomPropertiesChannel"
#define CUSTOM_PROP_CHANNEL 	CustomPropertiesChannel
///---END QA81-15050-P1 ADD_CUSTOM_PROPERTIES_INTO_COL_PARAMETERS

static bool s_bFileValid = true;
static bool s_bRangeValid = true;
#define OK_SURE(_OK_ENABLE) _OK_ENABLE = (s_bFileValid && s_bRangeValid);

static void _shift_error_code(int& nRet)
{
	switch ( nRet )
	{
	case IMPERR_INVALID_FILE:
		break;
	case FAIL_GET_CHANNEL_GROUP_NUM:
		nRet = XFERR_TDM_FAIL_GET_CG_NUM;
		return;
	case FAIL_GET_CHANNEL_GROUPS:
		nRet = XFERR_TDM_FAIL_GET_CG;
		return;
	case FAIL_GET_CHANNEL_NUM:
		nRet = XFERR_TDM_FAIL_GET_CHANNEL_NUM;
		return;
	case FAIL_GET_CHANNEL:
		nRet = XFERR_TDM_FAIL_GET_CHANNEL;
		break;
	case FAIL_GET_DATA_NUM:
		nRet = XFERR_TDM_FAIL_GET_DATA_NUM;
		break;
	case FAIL_GET_DATA_TYPE:
		nRet = XFERR_TDM_FAIL_GET_DATA_TYPE;
		break;
	case FAIL_GET_DATA:
		nRet = IMPERR_FAILED_READ;
		break;
	/// Hong 02/02/10 QA80-15051 IMPRORT_SUPPORT_PROGRESSBAR
	case FAIL_USER_CANCEL:
		nRet = XFERR_UI_USER_CANCEL;
		break;
	/// end IMPRORT_SUPPORT_PROGRESSBAR
	default:
		nRet = CER_UNKNOWN_ERROR;
	}
}

static bool construct_tree_setting(StringArray& vsFileNames, TreeNode& trSetting)
{
	/// Hong 01/19/07 NEW_CODE_USE_DLL
	/*
	OCTDMFile tdmFile;
	vector<int> vn;
	if( !tdmFile.GetGroupChannelNum(strFileName, vn) )
		return false;
	*/
	int nCount = vsFileNames.GetSize();
	trSetting.RemoveChildrenWithPrefix(); 
	
	for ( int nIndex = 0; nIndex < vsFileNames.GetSize(); nIndex++ )
	{	
		TreeNode trFileSetting = trSetting.AddNumericNode(1, "FileSetting", TRGP_CHECK);
		trFileSetting.SetAttribute(STR_LABEL_ATTRIB, GetFileName(vsFileNames[nIndex]));
		/// Hong 02/14/07 REMOVE_FILE_BRANCH_CHECKBOX
		//trFileSetting.Use = 1;
		//trFileSetting.SetAttribute(STR_ATTRIB_DISPFMT, DISPLAY_EDITOR_CHECK_ON_LEFT);
		/// end REMOVE_FILE_BRANCH_CHECKBOX
		TreeNode trFileInfo = trFileSetting.AddNode("FileInfo");
		trFileInfo.SetAttribute(STR_LABEL_ATTRIB, STR_FILE_INFO);	///Sophy 9/21/2009 SET_LABEL_ON_GUI_FOR_TRANSLATION
		GETN_USE(trFileInfo)
		string strTag, strInfo;
		strTag.Format("file%d", nIndex+1);
		strInfo.Format("File Size: %s ", GetFileSize(vsFileNames[nIndex]));
		GETN_STR(strTag, GetFileName(vsFileNames[nIndex], false), strInfo )
		GETN_READ_ONLY
		
		DIADemImport tdmFile(vsFileNames[nIndex]);	
		vector<int> vn;
		vector<string> vsNames;
		if( tdmFile.GetGroupChannelNum(vn, vsNames) )
			return false;
		/// end NEW_CODE_USE_DLL
		
		TreeNode trGroups = trFileSetting.AddNode("Groups");
		/// Hong 03/13/08 QA80-10343 CUSTOMER_WANT_CHECK_UNCHECK_FOR_GROUPS_LEVEL
		trGroups.SetAttribute(STR_ATTRIB_BRANCH, GETNBRANCH_CHECK_CONTROL | GETNBRANCH_CHECK_CONTROL_ONE_EVENT);
		/// end CUSTOMER_WANT_CHECK_UNCHECK_FOR_GROUPS_LEVEL
		string strGroup;
		int nIndex = 0;
		for(int ii=0; ii < vn.GetSize(); ii++)
		{			
			//TreeNode trGroup = trGroups.AddNumericNode(1, "ChannelGroup", TRGP_CHECK);
			TreeNode trGroup = trGroups.AddNode("ChannelGroup"); /// Hong 09/06/07 v8.0697 ALLOW_EMPTY_CHANNEL_GROUP
			trGroup.SetAttribute(STR_LABEL_ATTRIB, vsNames[nIndex++]);
			//trGroup.SetAttribute(STR_ATTRIB_DISPFMT, DISPLAY_EDITOR_CHECK_ON_LEFT); // Hong 03/13/07 AVOID_LABEL_TRUNCATED
			trGroup.SetAttribute(STR_ATTRIB_BRANCH, GETNBRANCH_CHECK_CONTROL | GETNBRANCH_CHECK_CONTROL_ONE_EVENT); // Hong 01/19/07 ADD_CHECK_UNCHECK_ALL
			
			string strChannel;
			for(int jj=0; jj < vn[ii]; jj++)
			{
				TreeNode trChannel = trGroup.AddNumericNode(1, "Channel", TRGP_CHECK);
				trChannel.SetAttribute(STR_LABEL_ATTRIB, vsNames[nIndex++]);
			}
			/// Hong 09/06/07 v8.0697 ALLOW_EMPTY_CHANNEL_GROUP
			if ( 0 == vn.GetSize() )
				trGroup.Show = 0;
			/// end ALLOW_EMPTY_CHANNEL_GROUP
		}
	}
	return true;
}

static bool file_name_event(TreeNode& trGetN, string& strErrMsg)
{
	string strFileName = trGetN.fname.strVal;
	TreeNode trNode = trGetN.trfiles;
	
	if ( !check_imported_file_name(strFileName, strErrMsg) )
		return false;
	
	// add code for construct trfiles
	StringArray vsFileNames;
	separate_multiline_files(strFileName, vsFileNames);
	if( !construct_tree_setting(vsFileNames, trNode) )
	{
		// clean the trFiles on GUI
		trNode.RemoveChildrenWithPrefix();
		strErrMsg = CER_INVALID_IMPORT_DATA_FILE;
		return false;
	}
	
	return true;
}



void impNITDM(const string& fname, const TreeNode& trfiles, const TreeNode& options, Range& orng, TreeNode& trheader)
{
	int c1,c2;
	Datasheet lyTarget;
	/// Hong 03/28/07 v8.0591 CENTRALIZE_CHECK_CALID_RANGE
	//orng.GetRange(lyTarget, c1, c2);
	WorksheetPage pgTarget;
	if ( !GetRangeInfo(orng, lyTarget, pgTarget, c1, c2) )
		XF_THROW(XFERR_INVALID_RANGE);
	/// end CENTRALIZE_CHECK_CALID_RANGE
	Worksheet wksTarget(lyTarget);
	if(!wksTarget.IsValid())
		XF_THROW(CER_INVALID_WKS);
	
	//WorksheetPage pgTarget; /// Hong 03/28/07 v8.0591 CENTRALIZE_CHECK_CALID_RANGE
	// Hong 01/27/07 REMOVE_TO_FILE_LOOP_BY_CHENEY
	//wksTarget.GetParent(pgTarget); /// Hong 03/28/07 v8.0591 CENTRALIZE_CHECK_CALID_RANGE
	//if( 1 != pgTarget.Layers.Count() || !is_sheet_empty(pgTarget.Layers()) )
		//pgTarget.Create("origin");
	/// end REMOVE_TO_FILE_LOOP_BY_CHENEY
	wksTarget = pgTarget.Layers();	
	
	Tree trBaseInfo; 
	/// Hong 01/10/06 FINFO_IS_ONLY_OUTPUT
	//if ( finfo )
		//trBaseInfo = finfo;
	/// end FINFO_IS_ONLY_OUTPUT
	
	///---Sim 02-01-2010 QA81-15050-P1 ADD_CUSTOM_PROPERTIES_INTO_COL_PARAMETERS
	//Tree tnUsingFilter; /// Hong 06/13/07 v8.0640c TEMP_ADD_FILTER_INFO_FOR_MAKE_FILTER
	//int nVer;
	//if ( fuGetDouble(trFilter, IDE_DISP_IMP_ORIGINVER, nVer) )
		//tnUsingFilter = trFilter;
	//
	///// Hong 06/13/07 v8.0640c TEMP_ADD_FILTER_INFO_FOR_MAKE_FILTER
	//if ( tnUsingFilter.GetNodeCount() <= 0 )
	//{
		//fuPrepareDefault(tnUsingFilter, FILTER_TYPE_XFUNC);
		//tree_set_attribute_to_all_nodes(tnUsingFilter, "Show", "0");
	//}
	//
	//fuSetXFunctionName(tnUsingFilter, "impNITDM");
	///// end TEMP_ADD_FILTER_INFO_FOR_MAKE_FILTER
	TreeNode tnUsingFilter;
	double dDefault = 0.;
	if ( fuGetDouble(options, IDE_DISP_IMP_ORIGINVER, dDefault) )
		tnUsingFilter = options;
	
	DWORD dwCustomPropertiesChannel = CUSTOM_PROP_CHANNEL_TO_COL_INFO_TREE;
	if ( options.CUSTOM_PROP_CHANNEL )
		dwCustomPropertiesChannel = options.CUSTOM_PROP_CHANNEL.nVal;
	
	///---END QA81-15050-P1 ADD_CUSTOM_PROPERTIES_INTO_COL_PARAMETERS
	
	StringArray vsFileNames;
	separate_multiline_files(fname, vsFileNames); 
	int nFileCount = vsFileNames.GetSize();
	if ( nFileCount <= 0 )
		XF_THROW(CER_INVALID_IMPORT_DATA_FILE);
	
	///Cheney 2007-1-17 CONSTRUCT_TREE_SETTING
	//should construc tree setting, because when D&D, if file is invalid, should also show Dlg
	/// Hong 05/30/07 v8.0629b MORE_CHECK_FOR_DATA_SELECTION_SETTING
	//if ( trfiles.IsEmpty())
	if ( trfiles.IsEmpty() || trfiles.GetNodeCount() == 0 )
	/// end MORE_CHECK_FOR_DATA_SELECTION_SETTING
	{
		if ( !construct_tree_setting(vsFileNames, trfiles) )
		{
			XF_THROW(CER_INVALID_IMPORT_DATA_FILE);
			return ;
		}
	}
	/// Hong 05/30/07 v8.0629b MORE_CHECK_FOR_DATA_SELECTION_SETTING
	//if( trfiles.IsEmpty())//trfiles was constructed by file
	if( trfiles.IsEmpty()  || trfiles.GetNodeCount() == 0 )
	/// end MORE_CHECK_FOR_DATA_SELECTION_SETTING
		XF_THROW(CER_INVALID_IMPORT_DATA_FILE);
	///end CONSTRUCT_TREE_SETTING
	/// Hong 01/19/07 NEW_CODE_USE_DLL
	/*
	int nRet;
	OCTDMFile tdmFile;
	if( nRet = tdmFile.Load(pgTarget, trSetting, trBaseInfo, fname) )
		XF_THROW_EX(nRet, fname);
	*/
	waitCursor wc;
	bool bEmptyPage = (pgTarget && 1 == pgTarget.Layers.Count() && is_sheet_empty(pgTarget.Layers(0)));
	
	int nImportFile = 0; //index for import file
	for ( int ii = 0; ii < nFileCount; ii++ )
	{
		TreeNode trFileSetting = trfiles.Children.Item(ii);
		/// Hong 02/14/07 REMOVE_FILE_BRANCH_CHECKBOX
		//if(trFileSetting.Use != 1)
		//{
		//	continue;
		//}
		/// end REMOVE_FILE_BRANCH_CHECKBOX
		WorksheetPage wp;	
		Worksheet wksTemp;
		if(nImportFile == 0 && bEmptyPage)
		{
			wp = pgTarget;
			
		}
		else
		{
			wksTemp.Create();
			wksTarget = wksTemp;
			wksTarget.GetParent(wp);
		}
		nImportFile++;
		
		string strFile;
		int nIndexLayer = wksTarget.GetIndex();
		strFile.Format("File%d", nIndexLayer + 1); // file index to be 1
		TreeNode trInfo = trBaseInfo.AddNode(strFile);
		int nRet;
		DIADemImport tdmFile(vsFileNames[ii]);	
		///---Sim 02-01-2010 QA81-15050-P1 ADD_CUSTOM_PROPERTIES_INTO_COL_PARAMETERS
		tdmFile.SetCustomPropertiesChannelBits(dwCustomPropertiesChannel);
		///---END QA81-15050-P1 ADD_CUSTOM_PROPERTIES_INTO_COL_PARAMETERS
		if( nRet = tdmFile.ReadFile(wp, trFileSetting.Groups, trInfo) )
		{
			_shift_error_code(nRet);
			//XF_THROW_EX(nRet, fname);
			XF_THROW_EX(nRet, vsFileNames[ii]); /// Hong 10/24/07 QA80-10541 FIX_FILEPATH_CONTAIL_ALL_FILES_PATH
		}
		/// end NEW_CODE_USE_DLL
		/// Hong 05/24/07 v8.0626 CLEAN_INFO
		// no need now, as reimport NOT open for this format
		//TreeNode trPlot, trSeclect;
		//trPlot = trBaseInfo.AddNode("Plot");
		//trSeclect = trPlot.AddNode("trSetting");
		//trSeclect.Replace(trfiles.Clone(), true, true);
		/// end CLEAN_INFO
		
		/// Hong 05/24/07 v8.0626 CLEAN_INFO
		//impinfo_AddFile(wksTarget, fname, trBaseInfo, ASCIMP_MODE_NEW_BOOKS, FILTER_TYPE_XFUNC, tnUsingFilter);
		/// Hong 10/24/07 QA80-10541 FIX_FILEPATH_CONTAIL_ALL_FILES_PATH
		//impinfo_AddFile(wksTarget, fname, trInfo, ASCIMP_MODE_NEW_BOOKS, FILTER_TYPE_XFUNC, tnUsingFilter);
		impinfo_AddFile(wksTarget, vsFileNames[ii], trInfo, ASCIMP_MODE_NEW_BOOKS, FILTER_TYPE_XFUNC, tnUsingFilter);
		/// end FIX_FILEPATH_CONTAIL_ALL_FILES_PATH
		/// end CLEAN_INFO
		//refresh_organizer_gui(wp); ///---Sim 06-25-2007 UPDATE_ORGANIZER
	}
	if( trheader )
		trheader.Replace(trBaseInfo.Clone(), true, true);/// Hong 01/10/06 FINFO_IS_ONLY_OUTPUT
}

//nEventID < 0 on event, like GETNE_ON_INIT, GETNE_ON_OK etc, >0 on change from control
//return 0 to do nothing, return PEVENT_GETN_RET_TO_CLOSE to close dialog
//dwEnables = bOKEnable, bBTN1Enable, bBTN2Enable, bBTN3Enable, , can set to false to disable OK/Apply buttons
//lpcszNodeName = the trGetN TreeNode tag name that generates the event, or is  if GETNE_ON_OK etc
//strAux = optional string for XF Wizard Bar, like DLG_NEED_CHANGE_GRID etc, it will be invalid if from internal node value change event
//strErrMsg = allowing messages to be shown
int impNITDM_event1(TreeNode& trGetN, int nRow, int nEventID, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& DynaCntrlContainer, string& strAux, string& strErrMsg)
{
	if( xf_is_extended_event(nEventID) )
		return impNITDM_event1_ex(trGetN, nRow, nEventID, dwEnables, lpcszNodeName, DynaCntrlContainer, strAux, strErrMsg);
	DECLARE_BUTTON_ENABLES
	OK_SURE(bOKEnable);
	
	///support D&D show Dlg, if trFiles no child, should construct it
	/// Hong 11/11/09 FIX_TDM_RUNTIME_ERROR
	//if ( (GETNE_ON_INIT == nEventID && trGetN.info.Children.Count() == 0) || GETNE_ON_THEME == nEventID )
	if ( GETNE_ON_INIT == nEventID || GETNE_ON_THEME == nEventID )
	/// end FIX_TDM_RUNTIME_ERROR
	{
		s_bFileValid = file_name_event(trGetN, strErrMsg);
		s_bRangeValid = !trGetN.orng.strVal.IsEmpty();
		if(!s_bRangeValid)
			strErrMsg = CER_INVALID_PAGE;
		
		OK_SURE(bOKEnable);	
		return true;
	}
	
	if( 0 == lstrcmp(lpcszNodeName, "fname") )
	{
		s_bFileValid = file_name_event(trGetN, strErrMsg);
		OK_SURE(bOKEnable);
		return true;
	}
	///Cheney 2006-12-9 PREPARE_ERR_MESSAGE
	//check range if is invalid
	if( 0 == lstrcmp(lpcszNodeName, "orng") )
	{
		s_bRangeValid = !trGetN.orng.strVal.IsEmpty();
		OK_SURE(bOKEnable);
		if(!s_bRangeValid)
			strErrMsg = CER_INVALID_PAGE;
		
		return true;
	}
	///end PREPARE_ERR_MESSAGE
	return false;

}

int impNITDM_make_tree(TreeNode& tr, LPCSTR lpcszVarName)
{
	///---Sim 02-01-2010 QA81-15050-P1 ADD_CUSTOM_PROPERTIES_INTO_COL_PARAMETERS
	if ( 0 == strcmp(lpcszVarName, "options") )
	{
		constructOptionsForXF(tr, (DWORD)0);
		
		TreeNode trCustomPropertiesChannel;
		trCustomPropertiesChannel = tr.AddNode(STR_CUSTOM_PROP_CHANNEL);
		trCustomPropertiesChannel.ID = TRGP_ENUM_LIST;
		trCustomPropertiesChannel.SetAttribute(STR_COMBO_ATTRIB, _L("Column Info Tree|User-Defined Parameter Row"));
		vector vMapping = {CUSTOM_PROP_CHANNEL_TO_COL_INFO_TREE, CUSTOM_PROP_CHANNEL_TO_COL_USER_PARAM};
		string strMapping;
		vector_to_str_list(vMapping, strMapping, false, false, '|');
		trCustomPropertiesChannel.SetAttribute(STR_INTMAP_ATTRIB, strMapping);
		trCustomPropertiesChannel.SetAttribute(STR_LABEL_ATTRIB, _L("Import Custom Properties of Channel to"));
		trCustomPropertiesChannel.DataID = GET_FILTER_USER_DATAID(1);
		trCustomPropertiesChannel.nVal = CUSTOM_PROP_CHANNEL_TO_COL_INFO_TREE;
		
		fuSetXFunctionName(tr, "impNITDM");
	
		return 0;
	}
	///---END QA81-15050-P1 ADD_CUSTOM_PROPERTIES_INTO_COL_PARAMETERS
	if ( 0 == lstrcmp(lpcszVarName, "trfiles") )
		return 0;
	
	return false;
}
//nGetNDialog = 0,1,2, corresponding to the XF GetN dropdown, 0 = dialog is not used
//you can change nRet to be one of XFEVT_PROCEED (defualt), XFEVT_ABORT, XFEVT_PROCEED_NO_DLG or XFEVT_PROCEED_WITH_DLG(when nGetNDialog = 0)
//nGetNDialog = -1 when Ok on GetN dialog to allow handler to preocess <auto> etc variables
//dwCntrl is combination of bits
//LTXF_FROM_GUI_MENU, LTXF_FROM_GUI_PROMPT, LTXF_FROM_AUTO_UPDATE, LTXF_FROM_FUNCTION, LTXF_THEME_USED, LTXF_CHANGE_PARAM
void impNITDM_before_execute(TreeNode& trGetN, int nGetNDialog, int& nRet, int dwCntrl)
{
	if ( nGetNDialog > 0 )
	{
		trGetN.trheader.Show = 0;
		trGetN.trFilter.Show = 0;
	}
	if(nGetNDialog > -1)
	{
		bool bResetFileInfo = false; ///---Sim 03-24-2009 QA80-13342 SUPPORT_OC_ACCESS_IMP_FILE_DATA_SELECTION
		
		string strFileName = trGetN.fname.strVal;
		
		/// Hong 04/10/07 v8.0597b IGNORE_FNAME$_WHEN_FROM_MENU
		if ( LTXF_FROM_GUI_MENU & dwCntrl ) // if from menu, ignore default value fname$
			strFileName = "";
		/// end IGNORE_FNAME$_WHEN_FROM_MENU
		
		if(is_empty_or_unassigned(strFileName))
		{			
			/// Hong 05/31/07 v8.0630 MORE_ON_ACCESS_TO_FDLOG
			//int nFilesRet = get_open_box_by_file_group(strFileName, "TDMFiles", "TDMFiles", true);
			int nFilesRet;
			if ( 0 != nGetNDialog )
			{
				int nShowOptionsDlg = 1;
				/// Hong 09/26/07 8.0709 CLEAN_OPEN_SAVE_DIALOG_TITLE_TO_DEFAULT
				//nFilesRet = get_open_box_by_file_group(strFileName, "TDMFiles", _L("TDMFiles"),
				//	OPENBOX_FLAG_MULTIFILES, NULL, NULL, _L("Show Options Dialog"), &nShowOptionsDlg);
				nFilesRet = get_open_box_by_file_group(strFileName, "TDMFiles", NULL,
					OPENBOX_FLAG_MULTIFILES, NULL, NULL, STR_SHOW_OPT_DLG, &nShowOptionsDlg);
				/// end CLEAN_OPEN_SAVE_DIALOG_TITLE_TO_DEFAULT
				nRet = (nShowOptionsDlg ? XFEVT_PROCEED : XFEVT_PROCEED_NO_DLG);
			}
			else
			{
				/// Hong 09/26/07 8.0709 CLEAN_OPEN_SAVE_DIALOG_TITLE_TO_DEFAULT
				//nFilesRet = get_open_box_by_file_group(strFileName, "TDMFiles", _L("TDMFiles"), true);
				nFilesRet = get_open_box_by_file_group(strFileName, "TDMFiles", NULL, true);
				/// end CLEAN_OPEN_SAVE_DIALOG_TITLE_TO_DEFAULT
			}
			/// end MORE_ON_ACCESS_TO_FDLOG
			/// end THEME_FILENAME_WORKBOOK_AND_WORKSHEET
			if ( 0 == nFilesRet )
			{
				nRet = XFEVT_ABORT;
				//warning_msg_box(XFERR_UI_USER_CANCEL, false);
				return;
			}
			///---END HANDLE_USER_CANCEL_OPEN_FILE_BOX
			trGetN.fname.strVal = strFileName;
			bResetFileInfo = true; ///---Sim 03-24-2009 QA80-13342 SUPPORT_OC_ACCESS_IMP_FILE_DATA_SELECTION
		} ///---Sim 03-24-2009 QA80-13342 SUPPORT_OC_ACCESS_IMP_FILE_DATA_SELECTION			
		
		string strErrMsg;
		///---Sim 03-24-2009 QA80-13342 SUPPORT_OC_ACCESS_IMP_FILE_DATA_SELECTION
		//if( !file_name_event(trGetN, strErrMsg) )
		if( !file_name_event(trGetN, strErrMsg) ) // why no reset bit?
		///---END QA80-13342 SUPPORT_OC_ACCESS_IMP_FILE_DATA_SELECTION
		{
			/// Hong 03/21/07 v8.0586 FIX_FAIL_DUMP_CORRECT_ERROR_STRING
			//nRet = XFEVT_ABORT;
			//warning_msg_box(strErrMsg, false);
			int nErrMsg = atoi(strErrMsg);
			nRet = XFEVT_ABORT;
			warning_msg_box(nErrMsg, false, 'E'); // should pass an int ///---Sim 06-19-2007 IMPROVE_WARNING_MESSAGE_POST_FUNCTION
			/// end FIX_FAIL_DUMP_CORRECT_ERROR_STRING
			return;
		}
		///---Sim 03-24-2009 QA80-13342 SUPPORT_OC_ACCESS_IMP_FILE_DATA_SELECTION			
		//}
		///---END QA80-13342 SUPPORT_OC_ACCESS_IMP_FILE_DATA_SELECTION
	}
}
//nEventID < 0 on event, like GETNE_ON_INIT, GETNE_ON_OK etc, >0 on change from control
//return 0 to do nothing, return PEVENT_GETN_RET_TO_CLOSE to close dialog
//dwEnables = bOKEnable, bBTN1Enable, bBTN2Enable, bBTN3Enable, , can set to false to disable OK/Apply buttons
//lpcszNodeName = the trGetN TreeNode tag name that generates the event, or is  if GETNE_ON_OK etc
//strAux = optional string for XF Wizard Bar, like DLG_NEED_CHANGE_GRID etc, it will be invalid if from internal node value change event
//strErrMsg = allowing messages to be shown
int impNITDM_event1_ex(TreeNode& trGetN, int nRow, int nEventID, DWORD& dwEnables, LPCSTR lpcszNodeName, WndContainer& DynaCntrlContainer, string& strAux, string& strErrMsg)
{
	return false;
}
