You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
3.9 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "epm_handler_common.h"
#include <tc\tc_macros.h>
#include <tc\emh.h>
#include <tc\preferences.h>
#include <property\propdesc.h>
#include <epm\epm.h>
#include <epm\epm_toolkit_tc_utils.h>
#include <tccore\item.h>
#include <tccore\grmtype.h>
#include <tccore\grm.h>
#include <tccore\imantype.h>
#include <sa\am.h>
#include <sa\sa.h>
#include <tccore\aom.h>
#include <tccore\aom_prop.h>
#include <property\prop_errors.h>
#include <tccore\workspaceobject.h>
#include <qry\qry.h>
#include <bom\bom_attr.h>
#include <bom\bom.h>
#include <epm\signoff.h>
#include <pom\pom\pom.h>
#include <pom\pom\pom_errors.h>
#include <fclasses\tc_date.h>
#include <epm\cr.h>
#include <cfm\cfm.h>
#include <sa\am.h>
#include "tc/envelope.h"
#include <stdio.h>
#include "ae/dataset.h"
#include <ctype.h>
#include <string.h>
#include <string>
#include <iostream>
#include <iterator>
#include <map>
#include <vector>
#include "ce/ce.h"
#include <time.h>
#include <windows.h>
#include <iostream>
#include <sql.h>
#include <sqlext.h>
#include "string"
#include "sstream"
#include <sa/tcfile.h>
#include <tccore/aom.h>
#include <sa/tcfile_cache.h>
#include <form/form.h>
#include "ctime"
#include "tchar.h"
using namespace std;
extern "C" int POM_AM__set_application_bypass(logical bypass);
//吉德表单签名
int jd_signoff(EPM_action_message_t msg) {
/*
-status:
编制1校对2审核3会签4批准5
*/
const char bz = '1', jd = '2', sh = '3', hq = '4', pz = '5';
int ifail = ITK_ok, att_count, objects_count;
tag_t rootTask, *attachments, user_tag;
char *user_name, step;
ITEM_attached_object_t *objects;
logical verdict;
//获取时间
time_t t;
time(&t);
tm* time = localtime(&t);
stringstream date;
date << time->tm_year + 1900 << "-";
date << time->tm_mon + 1 << "-";
date << time->tm_mday;
POM_AM__set_application_bypass(true);
//获取当前用户
POM_get_user(&user_name, &user_tag);
//获取选中的目标对象
TC_argument_list_t * arguments = msg.arguments;
int arg_cnt = TC_number_of_arguments(arguments), status = 0;
EPM_ask_root_task(msg.task, &rootTask);
EPM_ask_attachments(rootTask, EPM_target_attachment, &att_count, &attachments);
//获取流程中配置的handler属性
map<string, string> paras;
for (auto i = 0; i<arg_cnt; i++){
char *temp_key, *temp_val;
ITK_ask_argument_named_value(TC_next_argument(arguments), &temp_key, &temp_val);
paras[temp_key] = temp_val;
}
step = paras["step"].c_str()[0];
printf("%d\n", step);
printf("%s\n", user_name);
printf("%s\n", date.str().c_str());
for (auto ii = 0; ii < att_count; ii++) {
ITEM_list_rev_attachs_of_type(attachments[ii], ITEM_item_master_atth, &objects_count, &objects);
for (auto iii = 0; iii < objects_count; iii++) {
POM_modifiable(objects[iii].attachment, &verdict);
if (!verdict) {
AOM_refresh(objects[iii].attachment, TRUE);
switch (step) {
case bz:
FORM_set_value(objects[iii].attachment, "jd2_bz", user_name);
FORM_set_value(objects[iii].attachment, "jd2_bzrq", date.str().c_str());
break;
case jd:
FORM_set_value(objects[iii].attachment, "jd2_jd", user_name);
FORM_set_value(objects[iii].attachment, "jd2_jdrq", date.str().c_str());
break;
case sh:
FORM_set_value(objects[iii].attachment, "jd2_sh", user_name);
FORM_set_value(objects[iii].attachment, "jd2_shrq", date.str().c_str());
break;
case hq:
FORM_set_value(objects[iii].attachment, "jd2_hq", user_name);
FORM_set_value(objects[iii].attachment, "jd2_hqrq", date.str().c_str());
break;
case pz:
FORM_set_value(objects[iii].attachment, "jd2_pz", user_name);
FORM_set_value(objects[iii].attachment, "jd2_pzrq", date.str().c_str());
break;
default:
printf("%s\n", "error");
}
AOM_save(objects[iii].attachment);
AOM_unlock(objects[iii].attachment);
AOM_unload(objects[iii].attachment);
}
}
}
POM_AM__set_application_bypass(false);
return 0;
}