#include "tc_util.h"
#pragma warning (disable: 4996) 
#include "lov\lov.h"
#include <tccore/item.h>
#include <tccore/tctype.h>
#include <tccore/aom_prop.h>
#include <tccore/aom.h>
#include <stdio.h>
#include <ctime> 
#include <io.h>
#include <ict/ict_userservice.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <tccore/aom.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <bom/bom.h>
#include <ict/ict_userservice.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <tccore/aom.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <bom/bom.h>/
#include "sstream"
#include <tccore/grm.h>
#include "epm/epm.h"
#include <map>
#include "epm/signoff.h"
#include <vector>
#include <locale>
#include <common/emh_const.h>
#include <iostream>
#include "ps/vrule.h"
#include "sstream"
#include <tccore/grm.h>
#include "epm/epm.h"
#include "sa/sa.h"
#include <map>
#include "epm/signoff.h"
#include <ctime>
#include <vector>
#include <locale>
#include <codecvt>
#include <tc/folder.h>
#include "ae/dataset.h"
#include "ae/datasettype.h"
#include <iostream>
#include "string_utils.h"
#include "ae/dataset.h"
#include <sa/tcfile.h>
#include <ae/dataset.h>
#include <tccore/aom.h>
#include <sa/tcfile_cache.h>
#include "tc_util.h"
#include <ict/ict_userservice.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <tccore/aom.h>
#include <tccore/aom_prop.h>
#include <tccore/item.h>
#include <bom/bom.h>
#include "ps/ps.h";
#include "ps/vrule.h"
#include "sstream"
#include <tccore/grm.h>
#include "epm/epm.h"
#include "sa/sa.h"
#include <map>
#include "epm/signoff.h"
#include <ctime>
#include <vector>
#include <locale>
#include <codecvt>
#include "ae/dataset.h"
#include <iostream>
#include <stdio.h>
#include <iostream>
#include "windows.h"
#include "string_utils.h"
#include <ics/ics2.h>
#include <map>
#include <ae/datasettype.h>
#include <sa/tcfile.h>
#include <tccore/aom.h>
#include <sa/tcfile_cache.h>


/*
*返回1表示不包含该元素
*返回0表示包含该元素
*/
int hasElement(vector<string> v, string element) {
	if (count(v.begin(), v.end(), element))
	{
		//cout << "Element"<< element<<" found" << endl;
		return 0;//包含
	}
	else
	{
		//cout << "Element "<< element<<"NOT found" << endl;
		return 1;//不包含
	}

}
void nowTime() {

	time_t now = time(NULL);
	tm* tm_t = localtime(&now);
	std::stringstream ss;
	ss << "now========" << tm_t->tm_year + 1900 << "-" << tm_t->tm_mon + 1 << "-" << tm_t->tm_mday
		<< "    " << tm_t->tm_hour << ":" << tm_t->tm_min << ":" << tm_t->tm_sec;

	std::cout << ss.str();
	string nowTime = ss.str();
	printf("\n");

}
bool isTypeOf(tag_t objtag, const char * type_name) {
	tag_t type = NULLTAG;
	TCTYPE_ask_object_type(objtag, &type);
	tag_t item_type = NULLTAG;
	TCTYPE_find_type(type_name, "", &item_type);
	bool is_type = false;
	if (item_type != NULLTAG) {
		logical isok = FALSE;
		TCTYPE_is_type_of(type, item_type, &isok);
		if (isok) {
			is_type = true;
		}
	}
	return is_type;
}

void ECHO(char *format, ...)
{
    char msg[2048];
    va_list args;

    va_start( args, format );
    vsprintf_s( msg, format, args );
    va_end( args );

    printf( msg );
    TC_write_syslog( msg );
}



/**
* 获取首选项
*/
int getPrefStrings1( const char *preference, TC_preference_search_scope_t scope, vector<string> &pref_vec  )
{
    int ifail = ITK_ok , i = 0, j = 0, k =0, num = 0;
	char **values;
    TC_preference_search_scope_t old_scope;
    ITKCALL( ifail = PREF_ask_protection_scope(preference ,&old_scope) );
    ITKCALL( ifail = PREF_set_protection_scope(preference ,scope ) );
    ITKCALL( ifail = PREF_ask_char_values( preference, &num, &values ) );
	//WriteLog("num=%d",num);
	for(i = 0; i < num; i++)
	{
		pref_vec.push_back(values[i]);
	}
	DOFREE(values);
    ITKCALL( ifail = PREF_set_protection_scope(preference, scope) );
    return ifail;
}
//attr1:A001  map<attr1,A001>




