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

#include <cstdio>


#include <epm/epm.h>
#include <ict/ict_userservice.h>
#include <tccore/item.h>
#include <ae/ae.h>
#include <tc/folder.h>
#include <tccore/aom.h>
#include <sa/sa.h>
#include <tccore/aom_prop.h>
#include <tccore/workspaceobject.h>
#include <tccore//grm.h>
#include <tccore/grmtype.h>
#include <bom/bom.h>
#include <fclasses/tc_date.h>
// #include <stdio.h>
// #include <string.h>
#include <vector>
#include "error_handling.h"
#include "common_itk_util.h"
#include "epm_handler_common.h"
#include <epm/signoff.h>
#include <iostream>
#include "tc_util.h"
#include "string_utils.h"
using namespace std;
//流程节点信息
struct TXFLOWNODEINFOS
{
	char taskname[128];
	char username[128];
	char timeinfo[128];
	//2019.12.2新增注释，注意只有天信有，金卡没有
	char commentsinfo[256];
	char group[128];
}flownode_s[64];

//参数人员信息
struct TXUSERINFOS
{
	char taskname[128];
	char propertyname[128];
	char group[128];
}userinfo_s[64];
//参数已经啊信息
struct TXCOMMENTSINFOS
{
	char taskname[128];
	char propertyname[128];
	char group[128];
}commentsinfo_s[64];
//参数日期信息
struct TXTIMEINFOS
{
	char taskname[128];
	char propertyname[128];
	char group[128];
}timeinfo_s[64];



int txnodecount = 0;
int txuserinfoscount = 0;
int txtimeinfoscount = 0;
int txcommentsinfoscount = 0;

typedef struct{
	string TaskUserName;
	string TaskTimeName;
	string UserName;
	string TimeStr;
	string GroupName;
	string PropUserName;
	string PropTimeName;
}TXNOTICE_NODE;
void txSplitUserInfo(char *userinfo)
{
	char* token = NULL, *ptr = NULL, temp[512] = "";

	token = strtok( userinfo, ";");
	while( token != NULL )
	{
		/* While there are tokens in "string" */
		strcpy(temp,token);
		ECHO( "token=%s\n", token );
		ptr = strstr(temp, "=");
		if (ptr != NULL)
		{	
			strcpy(userinfo_s[txuserinfoscount].propertyname, ptr +1);
			strcpy(ptr,"\0");
			strcpy(userinfo_s[txuserinfoscount].taskname ,temp);
			ECHO("\nuserinfo_s[userinfoscount].taskname=%s,userinfo_s[userinfoscount].propertyname=%s\n",
				userinfo_s[txuserinfoscount].taskname,userinfo_s[txuserinfoscount].propertyname);
		}
		txuserinfoscount ++;
		/* Get next token: */
		token = strtok( NULL, ";");
	}
}
void txSplitCommentsInfo(char *commentsInfo)
{
	char* token = NULL, *ptr = NULL, temp[512] = "";

	token = strtok( commentsInfo, ";");
	while( token != NULL )
	{
		/* While there are tokens in "string" */
		strcpy(temp,token);
		ECHO( "token=%s\n", token );
		ptr = strstr(temp, "=");
		if (ptr != NULL)
		{	
			strcpy(commentsinfo_s[txcommentsinfoscount].propertyname, ptr +1);
			strcpy(ptr,"\0");
			strcpy(commentsinfo_s[txcommentsinfoscount].taskname ,temp);
			ECHO("\ncommentsinfo_s[userinfoscount].taskname=%s,commentsinfo_s[userinfoscount].propertyname=%s\n",
				commentsinfo_s[txcommentsinfoscount].taskname,commentsinfo_s[txcommentsinfoscount].propertyname);
		}
		txcommentsinfoscount ++;
		/* Get next token: */
		token = strtok( NULL, ";");
	}
}
void txSplitTimeInfo(char *userinfo)
{
	char* token = NULL, *ptr = NULL, temp[512] = "";

	token = strtok( userinfo, ";");
	while( token != NULL )
	{
		/* While there are tokens in "string" */
		strcpy(temp,token);
		ECHO( "token=%s\n", token );
		ptr = strstr(temp, "=");
		if (ptr != NULL)
		{	
			strcpy(timeinfo_s[txtimeinfoscount].propertyname, ptr +1);
			strcpy(ptr,"\0");
			strcpy(timeinfo_s[txtimeinfoscount].taskname ,temp);
			ECHO("\ntimeinfo_s[txtimeinfoscount].taskname=%s,timeinfo_s[txtimeinfoscount].propertyname=%s\n",timeinfo_s[txtimeinfoscount].taskname,timeinfo_s[txtimeinfoscount].propertyname);

		}
		txtimeinfoscount ++;
		/* Get next token: */
		token = strtok( NULL, ";");
	}
}
int tx_ORIGIN_ask_sign_info(tag_t task_node, char *output_str,char *task_name,char *arg3value,char *arg4value)
{
	int ifail = ITK_ok;
	tag_t cur_perform_task = NULLTAG,tempTask = NULLTAG;
	char cur_task_name[WSO_name_size_c+1]="",buf[128] = "";
	//编制判断变量
	int s = 0;
	EPM_decision_t decision = EPM_nogo;
	char* userName;
	char *timeinfo1 = "",person_name[SA_name_size_c+1]="",*prop_name = "last_mod_date";
	tag_t aUserTag = NULLTAG,responsibleParty = NULLTAG;
	date_t decision_date;
	//其他节点相关
	int perform_count = 0;
	int *attach_type;
	tag_t *perform_attaches = NULLTAG;
	tag_t memberTag = NULLTAG;
	SIGNOFF_TYPE_t memberType;
	CR_signoff_decision_t signoff_decision;
	EPM_signoff_decision_t dec;
	char *timeinfo="",*group_full_name = NULL;
	tag_t user_tag=NULLTAG, group_tag = NULLTAG;
	//循环判断变量
	int i=0;

	EPM_ask_name( task_node, cur_task_name ) ; 
	ECHO("cur_task_name = %s\n",cur_task_name);
	if ( stricmp( cur_task_name, "perform-signoffs" ) == 0 )
	{
		cur_perform_task = task_node;
		//得到父节点
		EPM_ask_parent_task( cur_perform_task, &tempTask );
		EPM_ask_name( tempTask, cur_task_name );
	}
	else if( strcmp( cur_task_name, "编制" ) == 0 || strcmp( cur_task_name, "设计" ) == 0)
	{
		cur_perform_task = task_node;
	}else if(strcmp( cur_task_name, "会签" ) == 0)
	{
		//EPM_Review
		//tag_t reviem_task;
		//EPM_ask_sub_task(task_node, "Review Task", &reviem_task) ;
		//if(reviem_task!=NULLTAG)
		//{
		EPM_ask_sub_task(task_node, "perform-signoffs", &cur_perform_task) ;
		//}
		ECHO("获得会签审核节点");
		if (cur_perform_task != NULLTAG)
		{
			EPM_ask_name(task_node, cur_task_name);

			ECHO("--------->		cur_task_name = %s\n", cur_task_name);

		}
	}
	else
	{
		
		EPM_ask_sub_task(task_node, "perform-signoffs", &cur_perform_task) ;
		if ( cur_perform_task != NULLTAG )
		{
			EPM_ask_name( task_node, cur_task_name  );

			ECHO( "--------->		cur_task_name = %s\n" , cur_task_name );

		}
	}

	if(cur_perform_task != NULLTAG )
	{
		char type[WSO_name_size_c+1] = "";
		WSOM_ask_object_type(cur_perform_task,type);
		ECHO("current task type = %s\n", type);
		cout<<"type--------"<<type<<endl;
		if( strcmp( cur_task_name, "编制" ) == 0||strcmp( cur_task_name, "设计" ) == 0 )
		{
			tag_t owner = NULLTAG;
			ECHO("task_name=%s\n",task_name);
			cout<<"编制type--------"<<type<<endl;
			s = EPM_ask_responsible_party(cur_perform_task,&responsibleParty);
			//EPM_ask_reviewers();
			if(responsibleParty != NULLTAG)
			{
				decision = EPM_go;
			}
			AOM_ask_owner( cur_perform_task, &owner);
			//s = POM_get_user(&userName,&aUserTag);
			if( owner != NULLTAG )
				SA_ask_user_person_name(owner, person_name);
			ECHO("person_name=%s\n",person_name);
			strcat(output_str, cur_task_name);
			strcat(output_str, "=");
			strcat(output_str, person_name);
			strcat(output_str, "|");
			strcat(output_str, cur_task_name);
			strcat(output_str, "日期=");
			AOM_ask_value_date(cur_perform_task,prop_name,&decision_date);
			DATE_date_to_string(decision_date,arg3value,&timeinfo1);
			ECHO("\n-------\ntimeinfo 111 : %s\n------------\n",timeinfo1);
			//ITK_date_to_string (decision_date, &timeinfo1);  2017.11.23 编制时间覆盖掉了,注掉
			strcat( output_str, timeinfo1 );
			strcat(output_str,"|");
			char *comments=NULL;
			AOM_ask_value_string(cur_perform_task,"comments",&comments);
			strcat(output_str, cur_task_name);
			strcat(output_str, "注释");
			strcat(output_str, "=");
			strcat(output_str, comments);
			strcat(output_str, "|");
			ECHO("timeinfo : %s",timeinfo1);
			strcpy(flownode_s[txnodecount].taskname,cur_task_name);
			strcpy(flownode_s[txnodecount].username,person_name);
			strcpy(flownode_s[txnodecount].commentsinfo,comments);
			strcpy(flownode_s[txnodecount].timeinfo,timeinfo1);
			txnodecount = txnodecount + 1;
			if(comments!=	NULL)
			{
				MEM_free(comments);
				comments=NULL;
			}
			//MEM_free(userName);
		}
		else
		{
			//发起人即所有者
			tag_t owner = NULLTAG;
			date_t date;
			logical is_valid;
			char *d_value = NULL;
			AOM_ask_owner( cur_perform_task, &owner);
			if( owner != NULLTAG )
				SA_ask_user_person_name(owner, person_name);
			AOM_ask_value_date(cur_perform_task,"creation_date", &date);//fnd0StartDate
			DATE_date_to_string(date,arg3value,&d_value);
			//ITKCALL(AOM_UIF_ask_value( cur_perform_task, "fnd0StartDate", &d_value));
			ECHO("d_value : %s",d_value);
			/*	strcat(output_str, "设计");
			strcat(output_str, "=");
			strcat(output_str, person_name);
			strcat(output_str, "|");
			strcat(output_str, "设计日期=");
			//CALL(DATE_date_to_string(date,arg3value,&timeinfo));
			//ITKCALL(DATE_string_to_date_t(d_value, &is_valid,&date)); 
			//CALL(DATE_date_to_string(date,arg3value,&timeinfo));
			//ECHO("timeinfo : %s",timeinfo);
			//vector<string> ans;
			//if( d_value != NULL )
			//{
			//	Split(d_value, ' ', ans);
			//	if(ans.size() > 1)
			//		strcat(output_str,ans[0].c_str());
			//}
			strcat(output_str,d_value);
			//DOFREE(timeinfo);
			strcat(output_str, "|");
			strcpy(flownode_s[txnodecount].taskname,"设计");
			strcpy(flownode_s[txnodecount].username,person_name);
			//if(ans.size() > 1)
			strcpy(flownode_s[txnodecount].timeinfo,d_value);
			txnodecount = txnodecount + 1;*/
			ECHO("output_str=%s",output_str);
			EPM_ask_all_attachments(cur_perform_task,&perform_count,&perform_attaches,&attach_type);
			ECHO("EPM_signoff_attachment Counts = %d", perform_count);

			for(i=0;i<perform_count;i++)
			{
				EPM_ask_signoff_member(perform_attaches[i], &memberTag, &memberType);
				// CR_ask_signoff_decision(perform_attaches[i], &signoff_decision, comments, &decision_date);

				// cout<<"注释1-------------"<<comments<<endl;
				char *comments2=NULL;
				EPM_ask_signoff_decision(perform_attaches[i], &dec, &comments2, &decision_date);
				cout<<"注释2-------------"<<comments2<<endl;

				if(memberType == SIGNOFF_GROUPMEMBER)
				{
					ECHO("cur_task_name = %s",cur_task_name);
					SA_ask_groupmember_user(memberTag, &user_tag);
					SA_ask_user_person_name(user_tag, person_name);
					strcat(output_str, cur_task_name);
					strcat(output_str, "=");
					strcat(output_str, person_name);
					strcat(output_str, "|");
					strcat(output_str, cur_task_name);
					strcat(output_str, "日期=");
					char date_buf[128]="";
					DATE_date_to_string(decision_date,arg3value,&timeinfo);
					//ITKCALL(ITK_date_to_string(decision_date, &timeinfo));
					//sprintf( date_buf, "%4d-%02d-%02d", decision_date.year, decision_date.month+1, decision_date.day );
					ECHO("\n--------\ntimeinfo : %s\n---------\n",timeinfo);
					strcat(output_str,timeinfo);
					strcat(output_str, "|");
					if(arg4value!=NULL)
					{
						strcat(output_str, cur_task_name);
						strcat(output_str, "注释=");
						strcat(output_str, comments2);
						strcat(output_str, "|");
					}
					strcpy(flownode_s[txnodecount].taskname,cur_task_name);
					strcpy(flownode_s[txnodecount].username,person_name);
					strcpy(flownode_s[txnodecount].timeinfo,timeinfo);
					strcpy(flownode_s[txnodecount].commentsinfo,comments2);
					txnodecount = txnodecount + 1;
				}
				if(comments2!=NULL)
				{
					MEM_free(comments2);
					comments2=NULL;
				}
			}
		}
	}

	ECHO("output_str=%s",output_str);
	return ifail;
}
int chintProperty(EPM_action_message_t msg)
{
	//EPM_rule_message_t rul_msg;
	int ifail = ITK_ok, rcode = 0;
	//参数相关
	char arg1value[1024] = "",arg2value[1024] = "",arg3value[1024]="",arg4value[1024]="",
		signcounter_info[1024] = "";
	char *argflag =NULL,*argvalue=NULL ,*arg = NULL;
	BOOL bypass = FALSE,setboth = TRUE,signPic=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;
	char rev_id[ITEM_id_size_c+1]="";
	char item_id[ITEM_id_size_c+1]="";
	int form_count = 0;
	tag_t 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";
	////登录信息
	//char *user_name = NULL, *group_full_name = NULL;
	//tag_t user_tag = NULLTAG, group_tag = NULLTAG;

	//char *txtfile = NULL;
	//会签相关
	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;

	//得到触发此函数的节点
	current_task = msg.task;
	//CreateLogFile("PLA8_signoff",&txtfile);
	ECHO("=========================================================\n");
	ECHO("chintProperty 开始执行\n");
	ECHO("=========================================================\n");
	//获取handler的参数的个数
	arg_cnt = TC_number_of_arguments(msg.arguments);
	ECHO("参数个数为：%d\n",arg_cnt);
	if (arg_cnt > 0)
	{
		for (i=0;i<arg_cnt;i++)
		{
			//获取下一个参数（从0开始）
			arg = TC_next_argument(msg.arguments);
			//获取参数的名称和值
			ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
			if (stricmp(argflag, "SignUserName") == 0)
			{
				//strcmp("","");
				if(argvalue != NULL)
				{
					strcpy(arg1value,argvalue);
				}
			}
			else if(stricmp(argflag, "SignDate") == 0)
			{
				if(argvalue != NULL)
				{
					strcpy(arg2value,argvalue);
				}
			}
			else if(stricmp(argflag,"SignDateFormate") == 0)
			{
				if(argvalue != NULL)
				{
					strcpy(arg3value,argvalue);
				}
			}
			else if(stricmp(argflag,"bypass") == 0)
			{
				bypass = TRUE;
			}else if(stricmp(argflag,"setboth") == 0){
				setboth = FALSE;
			}
			


		}
		MEM_free(argflag);
		MEM_free(argvalue);
	}
	ITK_set_bypass(TRUE);
	ECHO("SignUserName : %s\n",arg1value);
	ECHO("SignDate : %s\n",arg2value);
	txSplitUserInfo(arg1value);
	ECHO("2222\n");
	txSplitTimeInfo(arg2value);
	// txSplitCommentsInfo(arg4value);
	//getCounterinfo(signcounter_info);
	ECHO("3333\n");
	vector<string> type_vec;

	//Split(exclude_type,";",type_vec);
	//20200522 首选项的形式
vector<string> pref_vec;
	getPrefStrings1("Chint_Object_Type",TC_preference_site, pref_vec);
	
	ECHO("参数1个数：%d\n",txuserinfoscount);
	cout<<endl;
	ECHO("参数2个数：%d\n",txtimeinfoscount);
	cout<<endl;
	// ECHO("参数3个数：%d\n",txcommentsinfoscount);
	// cout<<endl;
	//得到触发handler的节点
	msg.task;
	//通过节点获取根流程
	EPM_ask_root_task( msg.task, &root_task );
	//得到根流程下的所有的一级节点
	EPM_ask_sub_tasks( root_task, &sub_task_count, &sub_tasks); 
	//得到根流程的名称
	EPM_ask_name( root_task, root_task_name );
	//
	ECHO("root_task_name=%s\n",root_task_name);
	EPM_ask_name( current_task, task_name  );
	ECHO( "sub_task_count = %d\n", sub_task_count );

	cout<<"task_name======20200520===="<<task_name<<endl;

	//单独处理DO节点
	if(strcmp(task_name,"编制") == 0||strcmp(task_name,"设计") == 0)
	{
		cout<<"===========20200520disign============"<<endl;
		ECHO("task_name:%s",task_name);
		cout<<endl;
		//获取责任人
		s = EPM_ask_responsible_party(current_task,&responsibleParty);
		if(responsibleParty != NULLTAG)
		{
			decision = EPM_go;
		}
		//获取当前的用户
		s = POM_get_user(&userName,&aUserTag);
		//获取personname
		SA_ask_user_person_name(aUserTag,person_name);
		strcat(sign_info,task_name);
		strcat(sign_info,"=");
		strcat(sign_info,person_name);
		strcat(sign_info,"|");
		strcat(sign_info,task_name);
		strcat(sign_info,"日期=");
		//POM_ask_v
		//获取对象的时间属性，参数1，对象，参数2，属性名称，属性3，获取到的时间属性值
		AOM_ask_value_date(current_task,prop_name,&decision_date);
		//AOM_UIF_ask_value(current_task,prop_name, &timeinfo2);
		//将时间结构体转换成为某种时间格式的字符串
		DATE_date_to_string(decision_date,arg3value,&timeinfo2);
		ECHO("\n--------------\n timeinfo2=%s\n------------\n",timeinfo2);
		strcat(sign_info,timeinfo2);
		strcat(sign_info,"|");
		
		strcpy(flownode_s[txnodecount].taskname,task_name);
		strcpy(flownode_s[txnodecount].username,person_name);
		strcpy(flownode_s[txnodecount].timeinfo,timeinfo2);
		strcpy(flownode_s[txnodecount].commentsinfo,timeinfo2);
		txnodecount = txnodecount + 1;

	}
	else //perform节点
	{
		for(i=0;i<sub_task_count;i++)
		{
			cur_task = sub_tasks[i];
			WSOM_ask_object_type(cur_task,task_type);
			ECHO("current task type = %s\n", task_type);
			cout<<endl;
			tx_ORIGIN_ask_sign_info( cur_task, sign_info, task_name,arg3value,arg4value); 
		}
	}

	ECHO("sign_info = %s\n", sign_info);
	cout<<endl;
	ECHO("the node number is %d",txnodecount);
	cout<<endl;

	/*
	for(j=0; j<txuserinfoscount; j++)
	{
		char t_tt_name[1024] = "";
		cout<<"txnodecount-------------------------"<<txnodecount<<endl;
		for(k=0; k<txnodecount; k++)
		{
			ECHO("userinfo_s[%d].taskname=%s, flownode_s[%d].taskname=%s, flownode_s[%d].username=%s\n",j,userinfo_s[j].taskname,k,flownode_s[k].taskname,k,flownode_s[k].username);
		}
	}
	if(1==1)
		return ITK_ok;
	*/


	if(current_task != NULLTAG)
	{
		EPM_ask_attachments(root_task, EPM_target_attachment, &occur_of_counts, &taskAttches);
		ECHO("%d target attachment found",occur_of_counts);
		cout<<endl;
		for( count=0; count<occur_of_counts; count++ )
		{
			ECHO("the %dth work",count);
			cout<<endl;
			char *changeType=NULL;
			AOM_ask_value_string(taskAttches[count],"object_type",&changeType);
			cout<<changeType<<endl;
			logical  okSign=false;
			for(int i = 0 ;i < pref_vec.size();i++){
				if(strcmp(pref_vec[i].c_str(),changeType)==0)
				{
					okSign=true;
					break;
				}
				
			}
			// strcmp(changeType,"ZT2_Change")==0||strcmp(changeType,"DocumentRevision")==0
			if(okSign==true)
			{
				is_sign = true;
				master_form = taskAttches[count];//form_list[0]; //属性写到对象上

				cout<<"Begin set properties for name\n"<<endl;
				AOM_load (master_form);
				POM_AM__set_application_bypass(true);

				if(setboth){
					ECHO("Begin set both\n");
					cout<<endl;
					for(j=0; j<txuserinfoscount; j++)
					{
						char t_tt_name[1024] = "";
						cout<<"txnodecount-------------------------"<<txnodecount<<endl;
						for(k=0; k<txnodecount; k++)
						{
							ECHO("userinfo_s[%d].taskname=%s, flownode_s[%d].taskname=%s, flownode_s[%d].username=%s\n",j,userinfo_s[j].taskname,k,flownode_s[k].taskname,k,flownode_s[k].username);

							if(strcmp(userinfo_s[j].taskname,flownode_s[k].taskname) == 0)
							{
								char  t_name[512]="\0";
								sprintf(t_name,"%s",flownode_s[k].username);

								if(strcmp(t_tt_name,"\0")==0){
									strcat(t_tt_name,t_name);
								}else{
									strcat(t_tt_name,",");
									strcat(t_tt_name,t_name);
								}

							}
							
						}

						//POM_AM__set_application_bypass(true);
						//先lock
						if(strcmp(t_tt_name,"")!=0){
							ECHO("t_tt_name_________= %s\n",t_tt_name);
							AOM_lock(master_form);
							ECHO("set prop %s=%s\n",userinfo_s[j].propertyname,userinfo_s[j].taskname);
							//再set

							AOM_set_value_string( master_form, userinfo_s[j].propertyname, t_tt_name) ;
							//再save
							AOM_save( master_form ) ;
							//最后unlock
							AOM_unlock( master_form ) ;
							//break;
						}
					}
				
					ECHO("Begin set properties for time\n");
					POM_AM__set_application_bypass(true);

					for(j=0;j< txtimeinfoscount;j++)
					{

						//ECHO("%s : ",timeinfo_s[j].taskname);
						for(k=0;k<txnodecount;k++)
						{
							//printf("group_full_name =%s, timeinfo_s[j].taskname=%s\n",group_full_name,timeinfo_s[j].taskname);
							ECHO("timeinfo_s[%d].taskname=%s, flownode_s[%d].taskname=%s,flownode_s[%d].username=%s\n",j,timeinfo_s[j].taskname,k, flownode_s[k].taskname,k,flownode_s[k].username);
							if(strcmp(timeinfo_s[j].taskname,flownode_s[k].taskname) == 0)
							{
								ECHO("set time prop:%s value:%s\n",timeinfo_s[j].propertyname,flownode_s[k].timeinfo);
								//POM_AM__set_application_bypass(true);
								AOM_lock(master_form);
								PROP_value_type_t valtype;
								char *valtype_n = NULL;
								AOM_ask_value_type( master_form, timeinfo_s[j].propertyname, &valtype, &valtype_n);
								if( valtype == PROP_date )
								{
									date_t a_date;
									ITK_string_to_date(flownode_s[k].timeinfo, &a_date);
									EMH_clear_errors();
									AOM_set_value_date(master_form, timeinfo_s[j].propertyname, a_date);
									//ITKCALL(AOM_UIF_set_value(itemrevision, timeinfo_s[j].propertyname,flownode_s[k].timeinfo));
								}
								else
									AOM_set_value_string( master_form, timeinfo_s[j].propertyname, flownode_s[k].timeinfo);
								DOFREE(valtype_n);
								AOM_save( master_form );
								AOM_unlock( master_form );
								//break;
							}
							
						}
					}
				}
				
				/*else{
					ECHO("Begin not set both\n");
					for(j=0; j<txuserinfoscount; j++)
					{
						//ECHO("userinfo_s[j].taskname:%s",userinfo_s[j].taskname);
						for(k=0; k<txnodecount; k++)
						{
							ECHO("userinfo_s[%d].taskname=%s, flownode_s[%d].taskname=%s, flownode_s[%d].username=%s\n",j,userinfo_s[j].taskname,k,flownode_s[k].taskname,k,flownode_s[k].username);

							if(strcmp(userinfo_s[j].taskname,flownode_s[k].taskname) == 0)
							{
								char propbothvalue[600] ="\0"; 
								//POM_AM__set_application_bypass(true);
								AOM_lock(master_form);
								ECHO("set prop %s=%s\n",userinfo_s[j].propertyname,flownode_s[k].username);
								ECHO("set time prop:%s value:%s\n",timeinfo_s[j].propertyname,flownode_s[k].timeinfo);
								//特殊处理
								strcat(propbothvalue,flownode_s[k].username);
								strcat(propbothvalue,"/");
								strcat(propbothvalue,flownode_s[k].timeinfo);
								AOM_set_value_string( master_form, userinfo_s[j].propertyname, propbothvalue );
								//ITKCALL( AOM_set_value_string( master_form, userinfo_s[j].propertyname, flownode_s[k].username) );
								AOM_save( master_form );
								AOM_unlock( master_form  );
								//break;
							}
							else if (strcmp(userinfo_s[j].taskname,flownode_s[k].taskname) != 0 
								//&& strstr(flownode_s[k].taskname, userinfo_s[j].taskname) != NULL
								//&& strstr(userinfo_s[j].taskname,group_full_name) != NULL
								&& strstr(userinfo_s[j].taskname,flownode_s[k].group) != NULL)
							{
								//printf("flownode_s[k].username=%s\n",flownode_s[k].username);
								//set_bypass(true);
								char propbothvalue[600] ="\0";
								CALL(AOM_lock(master_form));
								ECHO("set prop %s=%s\n",userinfo_s[j].propertyname,flownode_s[k].username);
								ECHO("set time prop:%s value:%s\n",timeinfo_s[j].propertyname,flownode_s[k].timeinfo);
								//特殊处理
								strcat(propbothvalue,flownode_s[k].username);
								strcat(propbothvalue,"/");
								strcat(propbothvalue,flownode_s[k].timeinfo);
							}
						}
					}



				}*/
				ECHO("==================WORK  END====================\n");
			}
			if(changeType!=NULL)
			{
				MEM_free(changeType);
				changeType=NULL;
			}

		}
		ECHO("close bypass...\n");
		POM_AM__set_application_bypass(false);
	}
	EMH_clear_errors();
	//CloseLog();
	txnodecount = 0;
	txuserinfoscount = 0;
	txtimeinfoscount = 0;
	txcommentsinfoscount = 0;
	end_handler:
	//CloseLog();
	DOFREE(taskAttches);
	//DOFREE(pref_values);

	//if (debug)
	{
		printf("=========================================================\n");
		printf("hander chintProperty 执行完成\n");
		printf("=========================================================\n");
	}
	return rcode;
}

