#include "util.h"

int jd_check_wlms_len(EPM_rule_message_t msg)
{
	POM_AM__set_application_bypass(true);
	tag_t root_task, *attachments;
	int att_cnt;
	EPM_ask_root_task(msg.task, &root_task);
	//获得根任务下的组件
	EPM_ask_attachments(root_task, EPM_target_attachment, &att_cnt,&attachments);
	for (int i = 0; i < att_cnt; i++)
	{
		if (isTypeOf(attachments[i],"ItemRevision"))
		{
			int form_att;
			tag_t *forms;
			AOM_ask_value_tags(attachments[i], "IMAN_master_form_rev", &form_att, &forms);
			if (form_att==0)
			{
				continue;
			}
			char *wlms;
			AOM_ask_value_string(forms[0], "jd2_wlms", &wlms);
			cout << "jd2_wlms" << wlms << endl;
			int length=0;
			for (int i = 0; wlms[i]!=0; i++)
			{
				if (wlms[i]<128&& wlms[i]>0)
				{
					length++;
				}
				else 
				{
					i += 2;
					length++;
				}
			}
			cout << "length: " << length << endl;
			if (length>40)
			{
				POM_AM__set_application_bypass(false);
				return EMH_store_error_s1(EMH_severity_error, EMH_IDGENERATION_ERROR_BASE, "字符不能超过40!!!");
			}
		}
		POM_AM__set_application_bypass(false);
		return EPM_go;
	}
}