#pragma warning (disable: 4996) 
#pragma warning (disable: 4819) 
#pragma warning (disable: 4995) 

#include <tc/tc.h>
#include "epm_handler_common.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 "libxl.h"
#include <map>
#include "epm/signoff.h"
#include <ctime>
#include <vector>
#include <locale>
#include "ae/dataset.h"
#include <stdlib.h>
#include <tccore/tctype.h>
#include <sa/tcfile.h>
#include <ss/ss_errors.h>
#include <ae/datasettype.h>
#include "chint_Handler.h"
#include "string_utils.h"
using namespace std;
typedef struct 
{
	string name;
	string value;
}CAD_ATTR_STRUCT;
int signoff_msexcel(tag_t dataset, char *dat_file, char *ext)
{
	tag_t spec_dataset_rev = NULLTAG,
		ref_object = NULLTAG;

	AE_reference_type_t reference_type;

	AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev);

	char ref_name[WSO_name_size_c + 1] = "excel";
	AE_ask_dataset_named_ref(spec_dataset_rev, ref_name, &reference_type, &ref_object);
	if(reference_type == AE_PART_OF)
	{
		char pathname[SS_MAXPATHLEN] = "";
		IMF_ask_file_pathname(ref_object, SS_WNT_MACHINE, pathname);
		char origin_file_name[IMF_filename_size_c + 1] = "";
		IMF_ask_original_file_name(ref_object, origin_file_name);

		char new_ds_name[WSO_name_size_c + 1] = "";
		char *new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
		char *temp_dir = getenv("temp");
		temp_dir="D:\\TEMP";
		char temp_file[SS_MAXPATHLEN] = "";
		strcpy(temp_file, temp_dir);
		strcat(temp_file, "\\");
		strcat(temp_file, new_file_name);

		IMF_export_file(ref_object, temp_file);


		int   iCnt;
		char *user_lib_env,pTempStr[500];
		char local_path[MAX_PATH] = "";
		char cmd[256] = "";
		/*user_lib_env = getenv("TC_USER_LIB"); 
		strcpy(local_path, user_lib_env);

		iCnt = strlen(user_lib_env);
		while( user_lib_env[iCnt] != '\\' )
		{
			iCnt--;
		}
		strcpy(pTempStr,"");
		strcpy(pTempStr,&user_lib_env[iCnt+1]);

		if( strcmp(pTempStr,"SubstMacros-MSExcel.wsf") != 0 )
		{
			strcat( user_lib_env, "\\SubstMacros-MSExcel.wsf" ); 
		}*/
		//strcpy( cmd, user_lib_env );
		strcpy( cmd, "SubstMacros-MSExcel.wsf" );
		strcat( cmd, " \"" ); 
		strcat( cmd, temp_file ); 
		strcat( cmd, "\" \"" );
		strcat( cmd, dat_file ); 
		strcat( cmd, "\"" );
		printf( "\n%s\n",cmd );
		system( cmd );

		//strcpy(user_lib_env, local_path);


		tag_t new_file_tag = NULLTAG;
		IMF_file_t file_descriptor;	
		IMF_import_file(temp_file, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor);
		IMF_set_original_file_name(new_file_tag, origin_file_name);
		IMF_close_file(file_descriptor);
		AOM_save(new_file_tag);
		AOM_unlock(new_file_tag);

		AOM_lock(spec_dataset_rev);
		//CALL(AOM_load (dataset));
		//CALL(AOM_load(spec_dataset_rev));
		AE_remove_dataset_named_ref_by_tag(spec_dataset_rev, ref_name, ref_object);
		AE_add_dataset_named_ref(spec_dataset_rev, ref_name, AE_PART_OF, new_file_tag);
		AOM_save(spec_dataset_rev);
		AOM_unlock(spec_dataset_rev);
	}

	return ITK_ok;
}
int create_signinfo_file(char *file_content,char *item_id, char **file_name)
{
	time_t now;
	struct tm *p;
	FILE *filePtr = NULL;

	char *temp_dir = getenv("TEMP");
	char local_path[MAX_PATH] = "";

	time(&now);
	p = localtime(&now);
	if(temp_dir[strlen(temp_dir) - 1] == '\\')
	{
		sprintf_s(local_path, "%s%s-%d-%d-%d-%d-%d-%d.dat", temp_dir,item_id,
			1900+p->tm_year,p->tm_mon+1 ,p->tm_mday+1 ,p->tm_hour,p->tm_min ,p->tm_sec);
	}
	else
	{
		sprintf_s(local_path, "%s\\%s-%d-%d-%d-%d-%d-%d.dat", temp_dir,item_id,
			1900+p->tm_year,p->tm_mon+1 ,p->tm_mday+1 ,p->tm_hour,p->tm_min ,p->tm_sec);
	}

	if((filePtr = fopen(local_path, "wt")) == NULL)
	{
		printf("Can not create the temp dat file!\n");
		return -1;
	}
	*file_name = (char *)MEM_alloc(sizeof(char)*512);
	strcpy((*file_name), local_path);

	fwrite(file_content, sizeof(char), strlen(file_content), filePtr);
	fclose(filePtr);

	return ITK_ok;
}
int signoff_msword(tag_t dataset, char *dat_file,char *ext)
{
	tag_t spec_dataset_rev = NULLTAG , ref_object = NULLTAG;
	AE_reference_type_t reference_type;
	//printf("\n111111111111\n");
	AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev);

	char ref_name[WSO_name_size_c + 1] = "word";
	//printf("\n22222222222\n");
	AE_ask_dataset_named_ref(spec_dataset_rev, ref_name, &reference_type, &ref_object);
	if(reference_type == AE_PART_OF)
	{
		//printf("\n3333333333333\n");
		char pathname[SS_MAXPATHLEN] = "";
		IMF_ask_file_pathname(ref_object, SS_WNT_MACHINE, pathname);
		char origin_file_name[IMF_filename_size_c + 1] = "";
		IMF_ask_original_file_name(ref_object, origin_file_name);
		//printf("\n44444444444444\n");
		char new_ds_name[WSO_name_size_c + 1] = "";
		char *new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
		char *temp_dir = getenv("temp");
		temp_dir="D:\\TEMP";
		//printf("\n555555555555\n");
		char temp_file[SS_MAXPATHLEN] = "";
		strcpy(temp_file, temp_dir);
		strcat(temp_file, "\\");
		strcat(temp_file, new_file_name);

		IMF_export_file(ref_object, temp_file);
		//printf("\n66666666666666\n");

		int   iCnt;
		char *user_lib_env,pTempStr[500];
		char local_path[MAX_PATH] = "";
		char cmd[256] = "";
		//user_lib_env = getenv("TC_USER_LIB"); 
		//strcpy(local_path, user_lib_env);

		//iCnt = strlen(user_lib_env);
		//while( user_lib_env[iCnt] != '\\' )
		//{
		//	iCnt--;
		//}

		//strcpy(pTempStr,"");
		//strcpy(pTempStr,&user_lib_env[iCnt+1]);

		//if( strcmp(pTempStr,"SubstMacros-MSWord.wsf") != 0 )
		//{
		//	strcat( user_lib_env, "\\SubstMacros-MSWord.wsf" ); 
		//}

		//strcpy( cmd, user_lib_env );
		strcpy( cmd, "SubstMacros-MSWord.wsf" );
		strcat( cmd, " \"" ); 
		strcat( cmd, temp_file ); 
		strcat( cmd, "\" \"" );
		strcat( cmd, dat_file ); 
		strcat( cmd, "\"" );
		printf( "\n%s\n",cmd );
		system( cmd );
//printf("\n777777777777\n");
		//strcpy(user_lib_env, local_path);


		tag_t new_file_tag = NULLTAG;
		IMF_file_t file_descriptor;	
		IMF_import_file(temp_file, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor);
		IMF_set_original_file_name(new_file_tag, origin_file_name);
		IMF_close_file(file_descriptor);
		AOM_save(new_file_tag);
		AOM_unlock(new_file_tag);

		AOM_lock(spec_dataset_rev);
		
		AE_remove_dataset_named_ref_by_tag(spec_dataset_rev, ref_name, ref_object);
		
		AE_add_dataset_named_ref(spec_dataset_rev, ref_name, AE_PART_OF, new_file_tag);
		AOM_save(spec_dataset_rev);
		AOM_unlock(spec_dataset_rev);
	}
	return ITK_ok;
}
int chint_signoff_dataset( EPM_action_message_t msg )
{
	int ifail = ITK_ok, rcode = 0;
	//参数相关
	char arg1value[1024] = "",arg2value[1024] = "",arg3value[1024]="",arg4value[1024]="",
		signcounter_info[1024] = "", *value = NULL;
	char *argflag =NULL,*argvalue=NULL ,*arg = NULL;
	BOOL bypass = FALSE;
	int arg_cnt = 0;
	//流程节点相关
	tag_t root_task = NULLTAG,*sub_tasks = NULL,current_task = NULLTAG,type_tag = NULLTAG;
	int sub_task_count = 0;
	char root_task_name[128]="",task_name[128] = "";
	int occur_of_counts = 0;
	tag_t *taskAttches = NULLTAG;
	char tgt_type[WSO_name_size_c+1]="",type_class[TCTYPE_class_name_size_c+1]="";
	////循环内部变量
	tag_t cur_task = NULLTAG;
	char task_type[WSO_name_size_c+1] = "";
	//循环变量
	int i=0, j=0, k=0, count = 0, n = 0;
	//节点信息变量
	char sign_info[2048]="";
	//节点循环处理变量
	tag_t itemrevision = NULLTAG,master_form_rel_type = NULLTAG;
	// char rev_id[ITEM_id_size_c+1]="";
	// char item_id[ITEM_id_size_c+1]="";
	char * uid=NULL;
	int form_count = 0;
	tag_t *form_list = NULL,master_form = NULLTAG;
	char local_path[128]="";
	//编制节点
	int s=0;
	char *timeinfo2="";
	EPM_decision_t decision = EPM_nogo;
	tag_t aUserTag,responsibleParty;
	char *userName;
	date_t decision_date;
	char person_name[SA_name_size_c + 1] = "";
	char *prop_name="last_mod_date";
	//会签相关
	int n_prop=0, q = 0;
	char **prop_names=NULL, hq_name[128] = "", hq_time_name[128] = "", *hq_value=NULL;
	char exclude_type[256]="", item_type[ITEM_type_size_c+ 1]= "";
	tag_t item = NULLTAG;
	logical is_sign = false;

	map<string,CAD_ATTR_STRUCT> sign_map;
	vector<string> prop_vec;
	current_task = msg.task;
	//CreateLogFile("PLA8_signoff",&txtfile);
	ECHO("=========================================================\n");
	ECHO("chint_signoff_dataset 开始执行\n");
	ECHO("=========================================================\n");
	vector<string> pref_vec;
	getPrefStrings1("Chint_Object_Type",TC_preference_site, pref_vec);
	
	arg_cnt = TC_number_of_arguments(msg.arguments);
	ECHO("参数个数为：%d\n",arg_cnt);
	POM_AM__set_application_bypass(true);
	if (arg_cnt > 0)
	{
		for (i=0;i<arg_cnt;i++)
		{
			arg = TC_next_argument(msg.arguments);
			ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
			if (stricmp(argflag, "SignName") == 0)
			{
				if(argvalue != NULL)
				{
					//strcpy(arg1value,argvalue);
					vector<string> ans,ans1;
					Split(argvalue,";",ans);
					for( j = 0; j <ans.size(); j++ )
					{
						CAD_ATTR_STRUCT	one_elem;
						Split(ans[j],"=",ans1);
						if( ans1.size() > 1 )
						{
							one_elem.name = ans1[1];
							sign_map.insert(pair<string,CAD_ATTR_STRUCT>(ans1[0],one_elem));
						}
					}
				}
			}
			else if(stricmp(argflag,"bypass") == 0)
			{
				bypass = TRUE;
			}
			
			//else if(stricmp(argflag,"exclude_type") == 0)
			//{
			//	if(argvalue != NULL)
			//	{
			//		strcpy(exclude_type,argvalue);
			//	}
			//} 

		}
		MEM_free(argflag);
		MEM_free(argvalue);
	}

	//获取属性
	 EPM_ask_root_task( msg.task, &root_task );
	 EPM_ask_sub_tasks( root_task, &sub_task_count, &sub_tasks); 
	EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches);
	ECHO("%d target attachment found",occur_of_counts);
		
	for( count=0; count<occur_of_counts; count++ )
	{
		ECHO("the %dth work",count);
		TCTYPE_ask_object_type(taskAttches[count], &type_tag);
		ifail = TCTYPE_ask_class_name(type_tag, type_class);
		ECHO("type_class : %s",type_class);
		logical  okSign=false;
		for(int i = 0 ;i < pref_vec.size();i++){
			if(strcmp(pref_vec[i].c_str(),type_class)==0)
			{
				okSign=true;
				break;
			}

		}
		if(okSign==true)
		{
		
			itemrevision = taskAttches[count];
			
			ITK__convert_tag_to_uid(itemrevision,&uid);
			
			master_form = itemrevision;// form_list[0]; 
			map<string,CAD_ATTR_STRUCT>::iterator it;
			for( it = sign_map.begin(); it != sign_map.end(); it ++ )
			{
				CAD_ATTR_STRUCT one_elem;
				AOM_ask_value_string( master_form, it->first.c_str(), &value);
				one_elem.name = it->second.name;
				one_elem.value.assign(value);
				it->second = one_elem;
			}
			DOFREE(form_list);
			//将form属性写入文本文件
			string info;
			map<string,CAD_ATTR_STRUCT>::iterator buf_it;
			for( it = sign_map.begin(); it != sign_map.end(); it ++ )
			{
				info.append(it->second.name);
				info.append("=");
				info.append(it->second.value);
				info.append("|");
			}
			ECHO("\n info: %s",info.c_str());
			char *data_file = NULL;
			create_signinfo_file((char*)info.c_str(),uid, &data_file);
			if( data_file == NULL )
			{

				continue;
			}
			ECHO("\n 创建文本文件%s\n",data_file);
			//获得数据集
			tag_t relation_type=NULLTAG;
			//tag_t attach_relation_type = NULLTAG;
			GRM_find_relation_type(TC_specification_rtype, &relation_type);
			tag_t *secondary_objects=NULLTAG;
			int ds_count = 0;
			char *dataset_type = NULL, *desc_value=NULL,*file_path = NULL,*desc_path;
			
			GRM_list_secondary_objects_only(itemrevision, relation_type, &ds_count, &secondary_objects);
			for (int j = 0; j < ds_count; j++)
			{
				printf("进1\n");
				AOM_ask_value_string(secondary_objects[j], "object_type", &dataset_type);
				int des_count=0;
				tag_t *dess=NULL;
				char  *name;
				if(!(strcmp(dataset_type, "JK8_AutoCAD") == 0||
					strcmp(dataset_type, "MSWord") ==0||
					strcmp(dataset_type, "MSWordX") ==0||
					strcmp(dataset_type, "MSExcel") ==0||
					strcmp(dataset_type, "MSExcelX") ==0||
					strcmp(dataset_type, "PDF") ==0)){
						if(dataset_type!=NULL){
							MEM_free(dataset_type);
							dataset_type =NULL;
						}
				
					continue;
				}




				AOM_ask_value_tags(secondary_objects[j], "ref_list", &des_count,&dess);
				if(des_count<1){
					printf("该数据集引用数量错误\n");
					continue;
				}
				
				printf("开始判断类型\n");
				if(strcmp(dataset_type, "JK8_AutoCAD") == 0) 
				{
					printf("cad类型\n");
				//	ECHO("导出dwg...\n");
				//	POM_AM__set_application_bypass(true);
				//	ifail = export_dataset_file(dataset_list[j], "PDF_Reference", "dwg", &filename,&original_name);
					// if( data_file != NULL )
					// signoff_acad(secondary_objects[j],data_file);
				}
				else if(strcmp(dataset_type, "MSWord") ==0 )
				{
					AOM_ask_value_string(dess[0], "original_file_name", &name);
					printf("name=%s\n",name);
					if ((strstr(name,"docx") != NULL)||(strstr(name,"xlsx") != NULL)){
						printf("后缀为docx或xlsx退出\n");
						continue;
					}
					signoff_msword(secondary_objects[j],data_file,"doc");
				}
				else if(strcmp(dataset_type, "MSWordX") ==0)
				{
					AOM_ask_value_string(dess[0], "original_file_name", &name);
					printf("name=%s\n",name);
					/*if ((strstr(name,"docx") != NULL)||(strstr(name,"xlsx") != NULL)){
						printf("后缀为docx或xlsx退出\n");
						continue;
					}*/
					signoff_msword(secondary_objects[j],data_file,"docx");
				}
				else if(strcmp(dataset_type, "MSExcel") ==0 )
				{
					AOM_ask_value_string(dess[0], "original_file_name", &name);
					printf("name=%s\n",name);
					if ((strstr(name,"docx") != NULL)||(strstr(name,"xlsx") != NULL)){
						printf("后缀为docx或xlsx退出\n");
						continue;
					}
					signoff_msexcel(secondary_objects[j],data_file,"xls");
				}
				else if(strcmp(dataset_type, "MSExcelX") ==0)
				{
					AOM_ask_value_string(dess[0], "original_file_name", &name);
					printf("name=%s\n",name);
					/*if ((strstr(name,"docx") != NULL)||(strstr(name,"xlsx") != NULL)){
						printf("后缀为docx或xlsx退出\n");
						continue;
					}*/
					signoff_msexcel(secondary_objects[j],data_file,"xlsx");
				}else if(strcmp(dataset_type, "PDF") ==0){
					// signoff_pdf(secondary_objects[j],data_file,"pdf");
				}
				MEM_free(dataset_type);

			}
			DOFREE(secondary_objects);

			GRM_find_relation_type(TC_attaches_rtype, &relation_type);//文档在版本上

			GRM_list_secondary_objects_only(itemrevision, relation_type, &ds_count, &secondary_objects);
			for (int j = 0; j < ds_count; j++)
			{
				printf("进2\n");
				AOM_ask_value_string(secondary_objects[j], "object_type", &dataset_type);
				int des_count=0;
				tag_t *dess=NULL;
				char  *name;

				if(!(strcmp(dataset_type, "JK8_AutoCAD") == 0||
					strcmp(dataset_type, "MSWord") ==0||
					strcmp(dataset_type, "MSWordX") ==0||
					strcmp(dataset_type, "MSExcel") ==0||
					strcmp(dataset_type, "MSExcelX") ==0||
					strcmp(dataset_type, "PDF") ==0)){
						if(dataset_type!=NULL){
							MEM_free(dataset_type);
							dataset_type =NULL;
						}
				
					continue;
				}
				AOM_ask_value_tags(secondary_objects[j], "ref_list", &des_count,&dess);
				if(des_count<1){
					printf("该数据集引用数量错误\n");
					continue;
				}
				
				if(strcmp(dataset_type, "JK8_AutoCAD") == 0) 
				{
				//	ECHO("导出dwg...\n");
				//	POM_AM__set_application_bypass(true);
				//	ifail = export_dataset_file(dataset_list[j], "PDF_Reference", "dwg", &filename,&original_name);
					// if( data_file != NULL )
					// signoff_acad(secondary_objects[j],data_file);
				}
				else if(strcmp(dataset_type, "MSWord") ==0 )
				{
					AOM_ask_value_string(dess[0], "original_file_name", &name);
					printf("name=%s\n",name);
					if ((strstr(name,"docx") != NULL)||(strstr(name,"xlsx") != NULL)){
						printf("后缀为docx或xlsx退出\n");
						continue;
					}
					signoff_msword(secondary_objects[j],data_file,"doc");
				}
				else if(strcmp(dataset_type, "MSWordX") ==0)
				{
					AOM_ask_value_string(dess[0], "original_file_name", &name);
					printf("name=%s\n",name);
					if ((strstr(name,"docm") != NULL)||(strstr(name,"xlsm") != NULL)){
						printf("后缀为docx或xlsx退出\n");
						continue;
					}
					signoff_msword(secondary_objects[j],data_file,"docx");
				}
				else if(strcmp(dataset_type, "MSExcel") ==0 )
				{
					AOM_ask_value_string(dess[0], "original_file_name", &name);
					printf("name=%s\n",name);
					if ((strstr(name,"docx") != NULL)||(strstr(name,"xlsx") != NULL)){
						printf("后缀为docx或xlsx退出\n");
						continue;
					}
					signoff_msexcel(secondary_objects[j],data_file,"xls");
				}
				else if(strcmp(dataset_type, "MSExcelX") ==0)
				{
					AOM_ask_value_string(dess[0], "original_file_name", &name);
					printf("name=%s\n",name);
					if ((strstr(name,"docm") != NULL)||(strstr(name,"xlsm") != NULL)){
						printf("后缀为docx或xlsx退出\n");
						continue;
					}
					signoff_msexcel(secondary_objects[j],data_file,"xlsx");
				}else if(strcmp(dataset_type, "PDF") ==0){
					// signoff_pdf(secondary_objects[j],data_file,"pdf");
				}
				MEM_free(dataset_type);
			}

			DOFREE(secondary_objects);

			GRM_find_relation_type("IMAN_reference", &relation_type);//文档在对象上

			GRM_list_secondary_objects_only(itemrevision, relation_type, &ds_count, &secondary_objects);
			for (int j = 0; j < ds_count; j++)
			{
				printf("进3\n");
				AOM_ask_value_string(secondary_objects[j], "object_type", &dataset_type);
				int des_count=0;
				tag_t *dess=NULL;
				char  *name;

				if(!(strcmp(dataset_type, "JK8_AutoCAD") == 0||
					strcmp(dataset_type, "MSWord") ==0||
					strcmp(dataset_type, "MSWordX") ==0||
					strcmp(dataset_type, "MSExcel") ==0||
					strcmp(dataset_type, "MSExcelX") ==0||
					strcmp(dataset_type, "PDF") ==0)){
						if(dataset_type!=NULL){
							MEM_free(dataset_type);
							dataset_type =NULL;
						}
				
					continue;
				}
				AOM_ask_value_tags(secondary_objects[j], "ref_list", &des_count,&dess);
				if(des_count<1){
					printf("该数据集引用数量错误\n");
					continue;
				}
				if(strcmp(dataset_type, "MSWord") ==0 )
				{
					AOM_ask_value_string(dess[0], "original_file_name", &name);
					printf("name=%s\n",name);
					if ((strstr(name,"docx") != NULL)||(strstr(name,"xlsx") != NULL)){
						printf("后缀为docx或xlsx退出\n");
						continue;
					}
					signoff_msword(secondary_objects[j],data_file,"doc");
				}
				else if(strcmp(dataset_type, "MSWordX") ==0)
				{
					AOM_ask_value_string(dess[0], "original_file_name", &name);
					printf("name=%s\n",name);
					if ((strstr(name,"docm") != NULL)||(strstr(name,"xlsm") != NULL)){
						printf("后缀为docx或xlsx退出\n");
						continue;
					}
					signoff_msword(secondary_objects[j],data_file,"docx");
				}
				else if(strcmp(dataset_type, "MSExcel") ==0 )
				{
					AOM_ask_value_string(dess[0], "original_file_name", &name);
					printf("name=%s\n",name);
					if ((strstr(name,"docx") != NULL)||(strstr(name,"xlsx") != NULL)){
						printf("后缀为docx或xlsx退出\n");
						continue;
					}
					signoff_msexcel(secondary_objects[j],data_file,"xls");
				}
				else if(strcmp(dataset_type, "MSExcelX") ==0)
				{
					AOM_ask_value_string(dess[0], "original_file_name", &name);
					printf("name=%s\n",name);
					if ((strstr(name,"docm") != NULL)||(strstr(name,"xlsm") != NULL)){
						printf("后缀为docx或xlsx退出\n");
						continue;
					}
					signoff_msexcel(secondary_objects[j],data_file,"xlsx");
				}else if(strcmp(dataset_type, "PDF") ==0){
					// signoff_pdf(secondary_objects[j],data_file,"pdf");
				}
				MEM_free(dataset_type);
			}
			DOFREE(secondary_objects);
			DOFREE(uid);

		}
	}
	POM_AM__set_application_bypass(false);
	DOFREE(taskAttches);
	ECHO("=========================================================\n");
	ECHO("chint_signoff_dataset 执行结束\n");
	ECHO("=========================================================\n");
	return rcode;
}
