first commit

main
李建辉 1 month ago
commit dfea385dd5

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "meling_itk", "connor_signature\connor_signature.vcxproj", "{87A8539F-972D-4E90-844B-DABEE71C1D40}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{87A8539F-972D-4E90-844B-DABEE71C1D40}.Debug|Win32.ActiveCfg = Debug|Win32
{87A8539F-972D-4E90-844B-DABEE71C1D40}.Debug|Win32.Build.0 = Debug|Win32
{87A8539F-972D-4E90-844B-DABEE71C1D40}.Debug|x64.ActiveCfg = Debug|x64
{87A8539F-972D-4E90-844B-DABEE71C1D40}.Debug|x64.Build.0 = Debug|x64
{87A8539F-972D-4E90-844B-DABEE71C1D40}.Release|Win32.ActiveCfg = Release|Win32
{87A8539F-972D-4E90-844B-DABEE71C1D40}.Release|Win32.Build.0 = Release|Win32
{87A8539F-972D-4E90-844B-DABEE71C1D40}.Release|x64.ActiveCfg = Release|x64
{87A8539F-972D-4E90-844B-DABEE71C1D40}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Binary file not shown.

@ -0,0 +1,8 @@
#pragma once
#include <iostream>
#include <Windows.h>
#include <curl\curl.h>
using namespace std;
void callHttpserver(string signinfoJsonString, char* HTTP_HOST);
void callHttpserverDwgtopdf(string signinfoJsonString, char* HTTP_HOST);
void callHttpserverMail(string signinfoJsonString, char* HTTP_HOST);

@ -0,0 +1,61 @@
/*==============================================================================
Copyright (c) 2008-2018 Connor Corporation
Unpublished - All Rights Reserved
==============================================================================*/
#include "kutil.h"
int LD_ElevateTask(EPM_action_message_t msg)
{
printf("=========================提升流程节点 Start===================\n");
int ifail = ITK_ok, att_cnt = 0, i = 0, arg_cnt = 0;
tag_t task_tag = NULL_TAG, rootTask_tag = NULL_TAG;
task_tag = msg.task;
if (task_tag == NULLTAG)
{
return -1;
}
ITKCALL(EPM_ask_root_task(task_tag, &rootTask_tag));
char* taskname = NULL, * type = NULL;
ITKCALL(EPM_ask_name2(task_tag, &taskname));
ITKCALL(AOM_ask_value_string(task_tag, "object_type", &type));
printf("name=%s\n", taskname);
printf("type=%s\n", type);
if (strcmp(type, "EPMReviewTask") == 0 || strcmp(type, "EPMAcknowledgeTask") == 0)
{
int num = 0;
tag_t* sub_tags = NULL;
ITKCALL(EPM_ask_sub_tasks(task_tag, &num, &sub_tags));
for (int j = 0; j < num; j++)
{
char* taskname2 = NULL, * type2 = NULL;
ITKCALL(EPM_ask_name2(sub_tags[j], &taskname2));
ITKCALL(AOM_ask_value_string(sub_tags[j], "object_type", &type2));
if (strcmp(type2, "EPMPerformSignoffTask") == 0)
{
printf("name2=%s,type2=%s\n", taskname2, type2);
int valid_num = 0;
tag_t* valid_tags = NULL;
ITKCALL(AOM_ask_value_tags(sub_tags[j], "valid_signoffs", &valid_num, &valid_tags));
printf("valid_num=%d\n", valid_num);
if (valid_num == 0)
{
printf("未选人执行提升\n");
POM_AM__set_application_bypass(true);
ITKCALL(EPM_promote_task(task_tag, ""));
POM_AM__set_application_bypass(false);
}
DOFREE(valid_tags);
}
DOFREE(taskname2);
DOFREE(type2);
}
DOFREE(sub_tags);
}
DOFREE(taskname);
DOFREE(type);
printf("=========================提升流程节点 End===================\n");
return ITK_ok;
}

@ -0,0 +1,244 @@
#include"kutil.h"
#define debug true
#define ITK_err 919012
int Connor_Review_Person(EPM_action_message_t msg) {
int ifail = ITK_ok, arg_cnt = 0, att_cnt = 0, task_count = 0, ifTabel = 0;//0不是table属性1是table属性
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
string type, proName;
string processNameRel;
vector<string> types;
vector<string> proNames;
tag_t* attachments = NULLTAG, task_tag = NULLTAG, rootTask_tag = NULLTAG, * task_tags = NULLTAG;
set<string> sh_set;
WriteLog(debug, "开始执行提取table属性作为审核节点的审核人(Connor_Review_Person) ...");
arg_cnt = TC_number_of_arguments(msg.arguments);
if (arg_cnt > 0) {
for (int i = 0; i < arg_cnt; i++) {
arg = TC_next_argument(msg.arguments);
ITKCALL(ifail = ITK_ask_argument_named_value(arg, &argflag, &argvalue));
if (strcmp(argflag, "From") == 0) {
type.assign(argvalue);
}
else if (strcmp(argflag, "Person") == 0) {
proName.assign(argvalue);
}
MEM_free(argflag);
MEM_free(argvalue);
}
}
else {
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数");
ifail = 1;
goto end;
}
{
Split(type, ";", types);
if (types.size() == 0) {
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数:-From");
goto end;
}
if (strstr(proName.c_str(), ".") != NULL) {
ifTabel = 1;
Split(proName, ".", proNames);
if (proNames.size() == 0) {
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数:-Person");
goto end;
}
}
}
//拿到当前节点
task_tag = msg.task;
if (task_tag == NULLTAG) {
goto end;
}
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
//获取目标下所有对象
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
if (att_cnt == 0) {
goto end;
}
char* task_type = NULL;
WSOM_ask_object_type2(task_tag, &task_type);
printf("当前节点的类型为:%s\n", task_type);
char* processName;
EPM_ask_name2(task_tag, &processName);
printf("获取的流程节点名称 ==== %s \n", processName);
int ifPromote = 0;
if (strcmp("EPMReviewTask", task_type) == 0) {
vector<string> ans;
Split(processName, "_", ans);
processNameRel.append(ans[0]);
}
else if (strcmp("EPMAcknowledgeTask", task_type) == 0) {
processNameRel.append(processName);
}
for (int i = 0; i < att_cnt; i++)
{
tag_t attachment = attachments[i];
for each (string type in types)
{
if (!isTypeOf(attachment, type.c_str()))
{
continue;
}
if (ifTabel == 0) {
char** values = NULL;
int value_count = 0;
AOM_ask_value_strings(attachment, proName.c_str(), &value_count, &values);
for (int j = 0; j < value_count; j++) {
if (sh_set.insert(values[j]).second == false) {
continue;
}
}
}
else if (ifTabel == 1) {
printf("取表的内容=====\n");
tag_t* tags = NULL, * rows = NULLTAG;
int value_count = 0;
int tags_count = 0;
//得到表
printf("表名为:%s====表行为:%s=====表列为:%s\n", proNames[0].c_str(), proNames[1].c_str(), proNames[2].c_str());
AOM_ask_value_tags(attachment, proNames[0].c_str(), &tags_count, &tags);
//得到行
printf("取行的数据===\n");
for (int j = 0; j < tags_count; j++) {
char* cellValue = NULL;
char* isFlag = NULL, * changeName;
AOM_ask_value_string(tags[j], proNames[2].c_str(), &cellValue);
AOM_ask_value_string(tags[j], "ld6_YNChange", &isFlag);
AOM_ask_value_string(tags[j], "ld6_ChangeTaskName", &changeName);
//printf("得到的更改项为:%s\n", changeName);
if (strcmp(changeName, processNameRel.c_str()) != 0) {
continue;
}
printf("isFlag为:%s\n", isFlag);
printf("得到的用户名ID为:%s\n", cellValue);
if (strcmp(changeName, processNameRel.c_str()) == 0 && (strcmp("", isFlag) == 0)) {
ifPromote++;
continue;
}
if (strcmp("", isFlag) != 0) {
continue;
}
if (strcmp("", cellValue) == 0 || strcmp(" ", cellValue) == 0) {
continue;
}
string userID = cellValue;
if (strstr(cellValue, "") != NULL) {
vector<string> vec1;
Split(cellValue, "", vec1);
if (strstr(vec1[1].c_str(), "") != NULL) {
vector<string> vec2;
Split(vec1[1], "", vec2);
userID = vec2[0];
}
}
if (strstr(cellValue, "(") != NULL) {
vector<string> vec1;
Split(cellValue, "(", vec1);
if (strstr(vec1[1].c_str(), ")") != NULL) {
vector<string> vec2;
Split(vec1[1], ")", vec2);
userID = vec2[0];
}
}
printf("最终用户名ID为:%s\n", userID.c_str());
if (sh_set.insert(userID).second == false) {
continue;
}
}
//AOM_ask_table_rows(tags[0], proNames[2].c_str(), &value_count, &rows);
/*for (int j = 0; j < value_count; j++) {
char* cellValue = NULL;
AOM_ask_value_string(rows[j], proNames[2].c_str(), &cellValue);
if (sh_set.insert(cellValue).second == false) {
continue;
}
}*/
}
}
}
//EPM_ask_sub_tasks(rootTask_tag, &task_count, &task_tags);
//printf("子任务数量:%d\n", task_count);
//printf("审核人数:%d\n", sh_set.size());
//for (int i = 0; i < task_count; i++) {
// char* task_type = NULL;
// WSOM_ask_object_type2(task_tags[i], &task_type);
// printf("当前节点的类型为:%s\n", task_type);
// if (strcmp("EPMReviewTask", task_type) == 0) {
// char* object_name = NULL;
// int mem_cnt = 0, signoff_cnt = 0;
// tag_t user_tag = NULLTAG, login_group = NULLTAG, * members = NULLTAG, * signoffs = NULLTAG, select_signoff_tag = NULLTAG;
// AOM_ask_value_string(task_tags[i], "object_name", &object_name);//对象名称
// EPM_ask_sub_task(task_tags[i], "select-signoff-team", &select_signoff_tag);
// printf("当前节点的名称为:%s\n", object_name);
// if (strcmp("审核", object_name) == 0) {
// for (set<string>::iterator it = sh_set.begin(); it != sh_set.end(); it++) {
// printf("添加:%s\n", it->c_str());
// ITKCALL(SA_find_user2(it->c_str(), &user_tag));
// ITKCALL(SA_ask_user_login_group(user_tag, &login_group));
// ITKCALL(SA_find_groupmembers(user_tag, login_group, &mem_cnt, &members));
// ITKCALL(EPM_create_adhoc_signoff(select_signoff_tag, members[0], &signoff_cnt, &signoffs));
// }
// if (sh_set.size() > 0) {
// ITKCALL(EPM_set_adhoc_signoff_selection_done(select_signoff_tag, true));
// }
// }
// DOFREE(object_name);
// DOFREE(members);
// DOFREE(signoffs);
// }
//}
printf("审核人的数量为:%d======ifPromote为%d\n", sh_set.size(), ifPromote);
if (strcmp("EPMAcknowledgeTask", task_type) == 0) {
int mem_cnt = 0, signoff_cnt = 0,signmem_count = 0, * attach_type;
tag_t user_tag = NULLTAG, login_group = NULLTAG, * members = NULLTAG, * signoffs = NULLTAG, select_signoff_tag = NULLTAG, *attachmentTags = NULLTAG;
EPM_ask_sub_task(task_tag, "select-signoff-team", &select_signoff_tag);
//EPM_ask_sub_task(task_tags[i], "select-signoff-team", &cur_perform_task);
EPM_ask_all_attachments(select_signoff_tag, &signmem_count, &attachmentTags, &attach_type);
if (signmem_count == 0) {
for (set<string>::iterator it = sh_set.begin(); it != sh_set.end(); it++) {
printf("添加:%s\n", it->c_str());
ITKCALL(SA_find_user2(it->c_str(), &user_tag));
ITKCALL(SA_ask_user_login_group(user_tag, &login_group));
ITKCALL(SA_find_groupmembers(user_tag, login_group, &mem_cnt, &members));
ITKCALL(EPM_create_adhoc_signoff(select_signoff_tag, members[0], &signoff_cnt, &signoffs));
}
if (sh_set.size() > 0) {
ITKCALL(EPM_set_adhoc_signoff_selection_done(select_signoff_tag, true));
}
if (sh_set.size() == 0 && ifPromote != 0) {
POM_AM__set_application_bypass(true);
ITKCALL(EPM_promote_task(task_tag, ""));
POM_AM__set_application_bypass(false);
}
}
DOFREE(members);
DOFREE(signoffs);
}
else if (strcmp("EPMReviewTask", task_type) == 0) {
if (sh_set.size() == 0 && ifPromote != 0) {
POM_AM__set_application_bypass(true);
ITKCALL(EPM_promote_task(task_tag, ""));
POM_AM__set_application_bypass(false);
}
}
end:
DOFREE(attachments);
types.clear();
sh_set.clear();
set<string>().swap(sh_set);
WriteLog(debug, "执行结束提取table属性作为审核节点的审核人(Connor_Review_Person)...");
return ifail;
}

@ -0,0 +1,92 @@
#include"kutil.h"
#define ITK_err 919012
int Connor_allow_Workflow(EPM_action_message_t msg) {
int ifail = ITK_ok, att_cnt = 0, arg_cnt = 0;
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
tag_t* attachments = NULLTAG, task_tag = NULLTAG, rootTask_tag;
string type, grant_value;
vector<string> types;
arg_cnt = TC_number_of_arguments(msg.arguments);
if (arg_cnt > 0) {
for (int i = 0; i < arg_cnt; i++) {
arg = TC_next_argument(msg.arguments);
ITKCALL(ifail = ITK_ask_argument_named_value(arg, &argflag, &argvalue));
if (strcmp(argflag, "type") == 0) {
type.assign(argvalue);
printf("%s\n", argvalue);
}
else if (strcmp(argflag, "grant") == 0) {
grant_value.assign(argvalue);
printf("%s\n", argvalue);
}
MEM_free(argflag);
MEM_free(argvalue);
}
}
else {
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数");
ifail = 1;
goto end;
}
{
if (grant_value.empty()) {
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数:-grant");
ifail = 1;
goto end;
}
Split(type, ";", types);
if (types.size() == 0) {
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数:-type");
ifail = 1;
goto end;
}
}
task_tag = msg.task;
if (task_tag == NULLTAG) {
ifail = 1;
goto end;
}
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
//获取目标下所有对象
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
if (att_cnt == 0) {
goto end;
}
printf("types的长度为%d\n", types.size());
for (int i = 0; i < att_cnt; i++)
{
tag_t target_tag = attachments[i];
char* object_type = NULL;
AOM_ask_value_string(target_tag,"object_type",&object_type);
printf("当前对象的类型为:%s\n",object_type);
int sum = 0;
for each (string type in types)
{
if (isTypeOf(target_tag, type.c_str()))
{
sum++;
//EMH_store_error_s1(EMH_severity_error, ITK_err, "对象类型在流程参数-type中不存在");
//ifail = 1;
//goto end;
}
}
printf("sum的长度为%d\n", sum);
if (sum == 0) {
EMH_store_error_s1(EMH_severity_error, ITK_err, "对象类型在流程参数-type中不存在");
ifail = 1;
goto end;
}
logical verdict = false;
ITKCALL(ifail = AM_check_privilege(target_tag, grant_value.c_str(), &verdict));
if (!verdict) {
EMH_store_error_s1(EMH_severity_error, ITK_err, "对象权限不符合!");
ifail = 1;
goto end;
}
}
end:
DOFREE(attachments);
return ifail;
}

@ -0,0 +1,265 @@
#include"kutil.h"
#include "ado.h"
#define debug true
#define ITK_err 919012
//导出数据集文件
int export_dataset_file_to_dir(tag_t dataset, const char *ref_name, const char* temp_path, char *ext, char **filename, char **original_name)
{
int ifail = ITK_ok;
tag_t ref_object = NULLTAG,
datasettype = NULLTAG,
new_ds = NULLTAG,
tool = NULLTAG,
folder_tag = NULLTAG,
spec_dataset_rev = NULLTAG;
AE_reference_type_t reference_type;
tag_t new_file_tag = NULLTAG;
IMF_file_t file_descriptor;
char *target_ds_name = NULL;
char *new_file_name;
WSOM_ask_name2(dataset, &target_ds_name);
WriteLog(debug, "开始从数据集<%s>下载文件", target_ds_name);
DOFREE(target_ds_name);
*filename = (char *)MEM_alloc(sizeof(char) * 512);
*original_name = (char *)MEM_alloc(sizeof(char) * 512);
strcpy(*filename, "");
AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev);
AE_ask_dataset_named_ref2(dataset, ref_name, &reference_type, &ref_object);
if (ref_object == NULLTAG)
{
WriteLog(debug, "文件引用为空");
return 1;
}
if (reference_type == AE_PART_OF)
{
char *pathname2 = NULL;
IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname2);
DOFREE(pathname2);
char *origin_file_name2 = NULL;
IMF_ask_original_file_name2(ref_object, &origin_file_name2);
strcpy(*original_name, origin_file_name2);
DOFREE(origin_file_name2);
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_file[SS_MAXPATHLEN] = "";
strcpy(temp_file, temp_path);
strcat(temp_file, "\\");
strcat(temp_file, new_file_name);
WriteLog(debug, "临时文件路径:%s", temp_file);
if ((_access(temp_file, 0)) != -1) {
if (!remove(temp_file)) {
remove(temp_file);
}
}
ITKCALL(ifail = IMF_export_file(ref_object, temp_file));
strcpy(*filename, temp_file);
return ifail;
}
return -1;
}
int uploadFile(void* returnValue) {
int ifail = ITK_ok;
char *datasetUid,*refName,*ext, *dataset_file_path, *dataset_file_name;
ITKCALL(ifail = USERARG_get_string_argument(&datasetUid));
ITKCALL(ifail = USERARG_get_string_argument(&refName));
ITKCALL(ifail = USERARG_get_string_argument(&ext));
tag_t dataset;
ITK__convert_uid_to_tag(datasetUid, &dataset);
export_dataset_file_to_dir(debug, dataset, refName, "D:\\Siemens\\IIS\\web\\file", ext, &dataset_file_path, &dataset_file_name);
string buff = dataset_file_path;
*((char**)returnValue) = (char*)MEM_alloc((strlen(buff.c_str()) + 1) * sizeof(char));
tc_strcpy(*((char**)returnValue), buff.c_str());
return ifail;
}
int LD_AutoAssign(EPM_action_message_t msg) {
int ifail = ITK_ok, arg_cnt = 0, att_cnt = 0, task_count = 0;
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
tag_t* attachments = NULLTAG, task_tag = NULLTAG, rootTask_tag = NULLTAG, * task_tags = NULLTAG;
vector<string> values;
set<string> sh_set;
getPrefStrings("Connor_PRType_Person_Mapping", TC_preference_site,values);
//拿到当前节点
task_tag = msg.task;
if (task_tag == NULLTAG) {
goto end;
}
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
//获取目标下所有对象
ITKCALL(ifail = EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attachments));
if (att_cnt == 0) {
goto end;
}
for (int i = 0; i < att_cnt; i++)
{
char* object_type = NULL;
AOM_ask_value_string(attachments[i],"object_type",&object_type);
if (strcmp("LD6_PRRevision",object_type) == 0) {
char* problem_type = NULL;
char* company_value = NULL;
AOM_ask_value_string(attachments[i], "ld6_company", &company_value);
AOM_ask_value_string(attachments[i], "ld6_problemType", &problem_type);
/*for each (string problem in values)
{
vector<string> split;
Split(problem.c_str(), "=", split);
if (split.size() == 2 && strcmp(split[0].c_str(),problem_type) == 0) {
if (sh_set.insert(split[1]).second == false) {
continue;
}
}
}*/
for each (string company in values)
{
vector<string> split;
vector<string> split2;
Split(company.c_str(), ":", split);
if (split[0].empty()) {
EMH_store_error_s2(EMH_severity_error, ITK_err, "首选项配置错误", company.c_str());
goto end;
}
//公司属性相同
if (split.size() == 2 && strcmp(split[0].c_str(), company_value) == 0) {
Split(split[1].c_str(), "=", split2);
if (split2.size() == 2) {
//问题类型为空
if (split2[0].empty()) {
if (sh_set.insert(split2[1]).second == false) {
continue;
}
}
//问题类型不为空,且相同
else if (strcmp(split2[0].c_str(), problem_type) == 0) {
if (sh_set.insert(split2[1]).second == false) {
continue;
}
}
}
}
}
}
}
char* task_type = NULL;
WSOM_ask_object_type2(task_tag, &task_type);
printf("当前节点的类型为:%s\n", task_type);
if (strcmp("EPMReviewTask", task_type) == 0 || strcmp("EPMAcknowledgeTask", task_type) == 0) {
char* object_name = NULL;
int mem_cnt = 0, signoff_cnt = 0;
tag_t user_tag = NULLTAG, login_group = NULLTAG, * members = NULLTAG, * signoffs = NULLTAG, select_signoff_tag = NULLTAG;
AOM_ask_value_string(task_tag, "object_name", &object_name);//对象名称
EPM_ask_sub_task(task_tag, "select-signoff-team", &select_signoff_tag);
printf("当前节点的名称为:%s\n", object_name);
int attachments_num = 0,* attach_type; tag_t* attachmentTags;
EPM_ask_all_attachments(select_signoff_tag, &attachments_num, &attachmentTags, &attach_type);
if (attachments_num > 0) {
goto end;
}
for (set<string>::iterator it = sh_set.begin(); it != sh_set.end(); it++) {
printf("添加:%s\n", it->c_str());
ITKCALL(SA_find_user2(it->c_str(), &user_tag));
ITKCALL(SA_ask_user_login_group(user_tag, &login_group));
ITKCALL(SA_find_groupmembers(user_tag, login_group, &mem_cnt, &members));
ITKCALL(EPM_create_adhoc_signoff(select_signoff_tag, members[0], &signoff_cnt, &signoffs));
}
if (sh_set.size() > 0) {
ITKCALL(EPM_set_adhoc_signoff_selection_done(select_signoff_tag, true));
}
DOFREE(object_name);
DOFREE(members);
DOFREE(signoffs);
}
if (strcmp("EPMDoTask", task_type) == 0 || strcmp("EPMConditionTask", task_type) == 0) {
tag_t user_tag = NULLTAG;
for (set<string>::iterator it = sh_set.begin(); it != sh_set.end(); it++) {
ITKCALL(SA_find_user2(it->c_str(), &user_tag));
ITKCALL(EPM_assign_responsible_party(task_tag, user_tag));//设置编制节点的责任方
}
}
end:
DOFREE(attachments);
return ifail;
}
int ML_ItemRevSave(METHOD_message_t* msg, va_list args)
{
printf("=========================创建后操作 Start===================\n");
int ifail = ITK_ok;
tag_t new_rev = va_arg(args, tag_t);
if (isTypeOf(new_rev, "Part Revision")) {
printf("类型为Part Revision 检查物料描述\n");
char* ld6_materialDesc, * item_id;
AOM_ask_value_string(new_rev, "ld6_materialDesc", &ld6_materialDesc);
AOM_ask_value_string(new_rev, "item_id", &item_id);
tag_t query;
int n_found;
ITKCALL(ifail = QRY_find2("6LD_Om_PartRevision", &query));
tag_t* tags;
boolean saveFlag = true;
char* qry_entries[2] = { "materialDesc" ,"id01" },
* qry_values[2] = { ld6_materialDesc ,item_id }, * errorId = "";
ITKCALL(ifail = QRY_execute(query, 2, qry_entries, qry_values, &n_found, &tags));
if (n_found == 0) {
saveFlag = true;
}
else {
for (int i = 0; i < n_found; i++) {
char* itemId;
AOM_ask_value_string(tags[i], "item_id", &itemId);
printf("查询到的itemId==> %s\n", itemId);
}
ifail = 1;
saveFlag = false;
EMH_store_error_s2(EMH_severity_error,
ITK_err,
"提示",
"已存在相同物料描述的对象,无需重复创建!");
}
}
va_end(args);
return ifail;
}
//
//
//int LD6_CusProdFolderSave(METHOD_message_t* msg, va_list args)
//{
//
// char* log_file = NULL;
//
// printf("创建日志文件\n");
// char* TO_SRM = (char*)malloc(sizeof("LD6_CusProdFolderSave"));
// strcpy(TO_SRM, "emp_register_handler");
// CreateLogFile(TO_SRM,"", &log_file);
//
// WriteLog(true, "=========================文件夹后操作 Start===================\n");
// int ifail = ITK_ok;
// tag_t folder = va_arg(args, tag_t);
//
// if (isTypeOf(folder, "LD6_CusProdFolder")) {
// //连接数据库保存当前名称到数据库
// char* folder_uid;
// ITK__convert_tag_to_uid(folder,&folder_uid);//获取文件夹uid
// bool conn = open("infodba", "infodba", "TC13", "10.10.22.39");
// if (conn != NULL && conn) {
// WriteLog(true, "=========================连接成功===================\n");
// }
// else {
// WriteLog(true, "=========================连接失败==================\n");
// }
//
//
// }
//
// va_end(args);
// WriteLog(true, "=========================文件夹后操作 End===================\n");
// CloseLog();
// return ifail;
//}

@ -0,0 +1,128 @@
#include"kutil.h"
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include "libxl.h"
#include <io.h>
#include <direct.h>
#include <cfm/cfm.h>
#include <wchar.h>
#include <locale>
#include <codecvt>
#include <chrono>
#include <Windows.h>
#include <thread>
#include <regex>
#include <res\reservation.h>
#include "libxl.h"
#include <map>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <filesystem>
#include <sys/stat.h>
#include <iostream>
#include "ado.h"
using namespace libxl;
using namespace std::chrono_literals;
using namespace std;
#define debug true
#define ITK_err 919012
int LD_CompletionDate(EPM_action_message_t msg) {
printf("=========================开始===================\n");
int cnt = 0;
char** vals = NULL;
//获取首选项的值
PREF_ask_char_values("LD_dbinfo2", &cnt, &vals);
//获取当前时间
time_t now = time(0);
tm* p = localtime(&now);
char dateNow[128] = "";
sprintf_s(dateNow, "%04d%02d%02d%02d%02d%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
string dateString = dateNow;
int ifail = ITK_ok;
int attachments_num = 0;
tag_t rootTask = NULLTAG, * attachments = NULLTAG;
//获取任务对象
EPM_ask_root_task(msg.task, &rootTask);
//获取任务目标对象
EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments);
for (int r = 0; r < attachments_num; r++) {
char* itemObjId;
char* objectType;
char* revision_id;
AOM_ask_value_string(attachments[r], "object_type", &objectType);
printf("objectType===%s\n", objectType);
if (strcmp(objectType, "LD6_CusProdFolder") == 0) {
//获取前面condition节点的值
tag_t* fnd0ActuatedInteractiveTsks_val;
int fnd0ActuatedInteractiveTsks_num = 0;
AOM_ask_value_tags(attachments[r], "fnd0ActuatedInteractiveTsks", &fnd0ActuatedInteractiveTsks_num, &fnd0ActuatedInteractiveTsks_val);
if (fnd0ActuatedInteractiveTsks_num > 0) {
for (int i = 0; i < fnd0ActuatedInteractiveTsks_num; i++)
{
char* task_type;
AOM_ask_value_string(fnd0ActuatedInteractiveTsks_val[i], "task_type", &task_type);
printf("task_type===%s\n", task_type);
if (strcmp(task_type, "EPMConditionTask") == 0) {
char* task_result;
AOM_ask_value_string(fnd0ActuatedInteractiveTsks_val[i], "task_result", &task_result);
printf("task_result===%s\n", task_result);
//连接数据库保存当前名称到数据库
char* folder_uid;
ITK__convert_tag_to_uid(attachments[r], &folder_uid);//获取文件夹uid
if (open("infodba", "infodba", vals[1], vals[0])) {
printf("=========================连接失败===================\n");
}
else {
//获取当前时间
auto now = std::chrono::system_clock::now();
std::time_t time = std::chrono::system_clock::to_time_t(now);
std::tm* ptm = std::localtime(&time);
char buf[128];
strftime(buf, sizeof(buf), "%Y-%m-%d", ptm);
printf("time===%s\n", buf);
//update语句
char sql[200] = "";
sprintf(sql, "UPDATE LD6_NewProdForm_VALUES SET CompletionDate = '%s' WHERE ClientProductFolderPUID = '%s' AND NewProductTaskItem = '%s'", buf, folder_uid, task_result);
printf("sql===%s\n", sql);
if (ExecuteSQLNoInputParam(sql) == 0)
{
printf("=========================修改成功===================\n");
}
else
{
printf("=========================修改失败===================\n");
}
}
break;
}
}
}
}
}
printf("=========================结束===================\n");
return 0;
}

@ -0,0 +1,534 @@
#include"kutil.h"
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include "libxl.h"
#include <io.h>
#include <direct.h>
#include <cstring>
#include <ctime>
#include <cfm/cfm.h>
#include <wchar.h>
#include <locale>
#include <ctime>
#include <iostream>
#include <codecvt>
#include <chrono>
#include <Windows.h>
#include <thread>
#include <regex>
#include <res\reservation.h>
#include "libxl.h"
#include <map>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
using namespace libxl;
using namespace std::chrono_literals;
using namespace std;
#define debug true
#define ITK_err 919012
int is_in(char* wenben, char* search_word)
{
int i = 0, j = 0, flag = -1;
while (i < strlen(wenben) && j < strlen(search_word))
{
if (wenben[i] == search_word[j])
{ //如果字符相同则两个字符都增加
i++;
j++;
}
else
{
i = i - j + 1; //主串字符回到比较最开始比较的后一个字符
j = 0; //字串字符重新开始
}
if (j == strlen(search_word))
{ //如果匹配成功
flag = 1; //字串出现
break;
}
}
return flag;
}
int LD_ECN01_SetCICNFormProperty(EPM_action_message_t msg) {
printf("================================================开始执行LD_ECN01_SetCICNFormProperty================================================\n");
//开旁路
POM_AM__set_application_bypass(true);
int att_cnt = 0;
int doc_num = 0;
tag_t rootTask_tag = NULLTAG;
tag_t task = NULLTAG;
tag_t* attachments = NULLTAG;
tag_t* doc_tags = NULLTAG;
string error;
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
int arg_cnt = TC_number_of_arguments(msg.arguments);
char* property = NULL, * value = NULL, * type = NULL;
task = msg.task;
string erro2 = "";
string erro = "";
int send1 = 0;
int send2 = 0;
ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
if (arg_cnt > 0)
{
for (int i = 0; i < arg_cnt; i++)
{
arg = TC_next_argument(msg.arguments);
ITKCALL(ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue));
if (strcmp(argflag, "property") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:\n", argvalue);
property = argvalue;
}
}
if (strcmp(argflag, "value") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:\n", argvalue);
value = argvalue;
}
}
}
//获取流程下目标关系下的对象
printf("获取流程下目标关系下的对象\n");
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &doc_num, &doc_tags));
for (int i = 0; i < doc_num; i++) {
char* objtype = NULL;
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &objtype));
if (strcmp("LD6_CNRevision", objtype) == 0) {
int relnum; tag_t* reltags;
ITKCALL(AOM_ask_value_tags(doc_tags[i], "LD6_WorkFRelation", &relnum, &reltags));
for (int j = 0; j < relnum; j++) {
//获取表单
printf("获取表单\n");
char* formtype;
tag_t form = NULL;
ITKCALL(AOM_ask_value_string(reltags[j], "object_type", &formtype));
if (strcmp(formtype, "LD6_CIForm") == 0 || strcmp(formtype, "LD6_CNForm") == 0) {
printf("开始修改属性值\n");
//开始修改属性值
AOM_lock(reltags[j]);
//获取当前流程节点名称
printf("获取当前流程节点名称\n");
char* taskName, * getValue;
ITKCALL(AOM_ask_value_string(task, "object_name", &taskName));
printf("当前流程节点名称为:%s\n",taskName);
//遍历表格
int num;//表格行数
tag_t* rows = NULL;//表格对象
ITKCALL(AOM_ask_table_rows(reltags[j], "ld6_ChangeTable", &num, &rows));
printf("获取表格\n");
for (int b = 0; b < num; b++) {
ITKCALL(AOM_ask_value_string(rows[b], "ld6_ChangeTaskName", &getValue));
printf("获取到的行:%s\n", getValue);
if (strstr(taskName, getValue)!=NULL) {
printf("获取到了同名的行\n");
char* flag;
ITKCALL(AOM_ask_value_string(rows[b], "ld6_YNChange", &flag));
printf("获取到ld6_YNChange的属性为%s\n", flag);
if (strcmp(flag, "") == 0) {
printf("可以修改\n");
vector<string> pripers;
Split(property, ";", pripers);
vector<string> values;
Split(value, ";", values);
if (pripers.size() == values.size()) {
for (int a = 0; a < pripers.size(); a++) {
AOM_lock(rows[b]);
vector<string> atts;
Split(pripers[a], ".", atts);
if (strcmp(atts[1].c_str(), "date") == 0) {
printf("获取到了时间\n");
date_t vadate;
if (strcmp(values[a].c_str(), "SysDate") == 0) {
// 获取当前时间
auto timeNow = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
// 转换为本地时间
tm localTime;
localtime_s(&localTime, &timeNow);
// 初始化date_t对象
vadate.year = localTime.tm_year + 1900;
vadate.month = static_cast<byte>(localTime.tm_mon) + 1;
vadate.day = static_cast<byte>(localTime.tm_mday);
vadate.hour = static_cast<byte>(localTime.tm_hour);
vadate.minute = static_cast<byte>(localTime.tm_min);
vadate.second = static_cast<byte>(localTime.tm_sec);
}
else {
printf("开始转换时间\n");
//ITKCALL(ITK_string_to_date(values[a].c_str(), &vadate));
/*vector<string> dataList;
Split(values[a].c_str(), "-", dataList);*/
// 创建tm对象用于存储转换后的日期
std::tm date = {};
// 使用std::istringstream解析日期字符串
std::istringstream iss(values[a].c_str());
iss >> std::get_time(&date, "%Y-%m-%d %H:%M:%S");
// 检查日期是否解析成功
if (iss.fail())
{
std::cout << "转换失败!" << std::endl;
return 1;
}
else {
// 初始化date_t对象
vadate.year = date.tm_year + 1900;
vadate.month = static_cast<byte>(date.tm_mon) + 1;
vadate.day = static_cast<byte>(date.tm_mday);
vadate.hour = static_cast<byte>(date.tm_hour);
vadate.minute = static_cast<byte>(date.tm_min);
vadate.second = static_cast<byte>(date.tm_sec);
}
}
printf("属性%s=%s\n", atts[0].c_str(), values[a].c_str());
// 打印转换后的日期
std::cout << "年:" << vadate.year << std::endl;
std::cout << "月:" << static_cast<int>(vadate.month) << std::endl;
std::cout << "日:" << static_cast<int>(vadate.day) << std::endl;
std::cout << "时:" << static_cast<int>(vadate.hour) << std::endl;
std::cout << "分:" << static_cast<int>(vadate.minute) << std::endl;
std::cout << "秒:" << static_cast<int>(vadate.second) << std::endl;
ITKCALL(AOM_set_value_date(rows[b], atts[0].c_str(), vadate));
}
else if (strcmp(atts[1].c_str(), "string") == 0) {
printf("获取到了字符串\n");
printf("属性%s=%s\n", atts[0].c_str(), values[a].c_str());
ITKCALL(AOM_set_value_string(rows[b], atts[0].c_str(), values[a].c_str()));
ITKCALL(AOM_UIF_set_value(rows[b], atts[0].c_str(), values[a].c_str()));
}
AOM_save(rows[b]);
AOM_unlock(rows[b]);
AOM_refresh(rows[b], true);
}
}
else {
char* error = "流程参数配置有误";
EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", error);
return 1;
}
}
break;
}
}
AOM_save(reltags[j]);
AOM_unlock(reltags[j]);
AOM_refresh(reltags[j], true);
}
}
}
}
}
//关旁路
POM_AM__set_application_bypass(false);
printf("================================================执行LD_ECN01_SetCICNFormProperty结束================================================\n");
return 0;
}
int LD_515_SetCICNFormProperty(EPM_action_message_t msg) {
printf("开始执行");
//开旁路
POM_AM__set_application_bypass(true);
int att_cnt = 0;
int doc_num = 0;
tag_t rootTask_tag = NULLTAG;
tag_t getfatag = NULLTAG;
tag_t task = NULLTAG;
tag_t* attachments = NULLTAG;
tag_t* doc_tags = NULLTAG;
string error;
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
int arg_cnt = TC_number_of_arguments(msg.arguments);
char* property = NULL, * value = NULL, * type = NULL,* parentwfname = NULL;
task = msg.task;
string erro2 = "";
string erro = "";
int send1 = 0;
int send2 = 0;
ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
if (arg_cnt > 0)
{
for (int i = 0; i < arg_cnt; i++)
{
arg = TC_next_argument(msg.arguments);
ITKCALL(ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue));
if (strcmp(argflag, "parentwfname") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:\n", argvalue);
parentwfname = argvalue;
int doc_num1 = 0; tag_t* doc_tags1 = NULLTAG;
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &doc_num1, &doc_tags1));
if (doc_num1>0) {
int fatagint; tag_t* fatasks;
ITKCALL(AOM_ask_value_tags(doc_tags1[0], "fnd0AllWorkflows", &fatagint,&fatasks));
int falgnum = 0;
for (int j = 0; j < fatagint;j++) {
char* fataskName;
ITKCALL(AOM_ask_value_string(fatasks[j], "object_name", &fataskName));
printf("fataskName:%s\n", fataskName);
if (strcmp(fataskName, parentwfname) == 0) {
getfatag = fatasks[j];
break;
}
else {
falgnum++;
}
}
if (falgnum == fatagint) {
return 0;
}
}
}
}
if (strcmp(argflag, "property") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:\n", argvalue);
property = argvalue;
}
}
if (strcmp(argflag, "value") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:\n", argvalue);
value = argvalue;
}
}
}
//获取流程下目标关系下的对象
printf("获取流程下目标关系下的对象\n");
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &doc_num, &doc_tags));
for (int i = 0; i < doc_num; i++) {
char* objtype = NULL;
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &objtype));
if (strcmp("LD6_CNRevision", objtype) == 0) {
int relnum; tag_t* reltags;
ITKCALL(AOM_ask_value_tags(doc_tags[i], "LD6_WorkFRelation", &relnum, &reltags));
for (int j = 0; j < relnum; j++) {
//获取表单
printf("获取表单\n");
char* formtype;
tag_t form = NULL;
ITKCALL(AOM_ask_value_string(reltags[j], "object_type", &formtype));
if (strcmp(formtype, "LD6_CIForm") == 0 || strcmp(formtype, "LD6_CNForm") == 0) {
printf("开始修改属性值\n");
//开始修改属性值
AOM_lock(reltags[j]);
//获取当前流程节点名称
printf("获取当前流程节点名称\n");
char * getValue;
string taskName = "";
char* taguid;
ITK__convert_tag_to_uid(rootTask_tag, &taguid);
int fathnum;
printf("获取当前流程的跟节点\n");
char* testUid;
ITK__convert_tag_to_uid(rootTask_tag, &testUid);
printf("testUid:%s\n", testUid);
////获取对象rootTask_tag引用关系下的所有对象
//int *getrenums,referNum;
//tag_t* renum;
//char** retags;
//WSOM_where_referenced(rootTask_tag,1, &referNum,&getrenums, &renum, &retags);
//for (int g = 0; g < referNum;g++) {
// char* faname;
// ITKCALL(AOM_ask_value_string(renum[g], "object_name", &faname));
//
//
//}
//ITKCALL(AOM_ask_value_tags(rootTask_tag, "parent_processes", &fathnum, &fathtag));
//printf("fathnum:%d\n", fathnum);
/*int allstartnum = 0; tag_t* allstart;
printf("获取跟节点的所有流程任务\n");
ITKCALL(AOM_ask_value_tags(getfatag, "fnd0StartedTasks",&allstartnum, &allstart));
for (int n = 0; n < allstartnum;n++) {
int statesnum; tag_t* statesName;
printf("获取流程任务的uid\n");
ITKCALL(AOM_ask_value_tags(allstart[n], "interprocess_task_dependencies",&statesnum, &statesName));
for (int m = 0; m < statesnum;m++) {
char* gettaguid;
ITK__convert_tag_to_uid(statesName[m], &gettaguid);
printf("判断uid\n");
printf("anssart:%s%s\n", gettaguid, taguid);
if (strcmp(gettaguid,taguid)==0) {
ITKCALL(AOM_ask_value_string(allstart[n], "object_name", &taskName));
break;
}
}
}*/
//查询数据库获取父任务的流程对象
//调用java查询sqlserver数据库
printf("开始执行cmd方法");
char cmd[1024] = "";
strcpy(cmd, "java -jar D:\\Siemens\\Teamcenter13\\bin\\sapjco3.jar");
strcat(cmd, " ");
strcat(cmd, " ");
strcat(cmd, "\"SELECT pw.pobject_name from PWORKSPACEOBJECT pw, (SELECT rprimary_objectu from PIMANRELATION where rsecondary_objectu = '?') p WHERE pw.puid = p.rprimary_objectu\"");
strcat(cmd, " ");
strcat(cmd, taguid);
strcat(cmd, " ");
strcat(cmd, "sql");
printf("\n%s\n", cmd);
system(cmd);
//读取本地的result文件SAP
string SAPfile = "D:\\TCSELECT\\sqlresult.txt";
std::ifstream file(SAPfile);
if (!file.is_open()) {
std::cerr << "Failed to open file!" << std::endl;
char* error = "数据库查询出错";
EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", error);
return 1;
}
else {
std::stringstream buffer1;
buffer1 << file.rdbuf();
std::string resultStr = buffer1.str();
printf("返回的值%s:\n", resultStr.c_str());
//taskName = (char *)resultStr.c_str();
taskName.append(resultStr);
printf("taskName%s\n", taskName.c_str());
}
printf("当前流程节点名称为:%s\n", taskName.c_str());
//遍历表格
int num;//表格行数
tag_t* rows = NULL;//表格对象
ITKCALL(AOM_ask_table_rows(reltags[j], "ld6_ChangeTable", &num, &rows));
printf("获取表格\n");
for (int b = 0; b < num; b++) {
ITKCALL(AOM_ask_value_string(rows[b], "ld6_ChangeTaskName", &getValue));
printf("获取到的行:%s\n", getValue);
if (strstr(taskName.c_str(), getValue) != NULL) {
printf("获取到了同名的行\n");
char* flag;
ITKCALL(AOM_ask_value_string(rows[b], "ld6_YNChange", &flag));
printf("获取到ld6_YNChange的属性为%s\n", flag);
if (strcmp(flag, "") == 0) {
printf("可以修改\n");
vector<string> pripers;
Split(property, ";", pripers);
vector<string> values;
Split(value, ";", values);
if (pripers.size() == values.size()) {
for (int a = 0; a < pripers.size(); a++) {
AOM_lock(rows[b]);
vector<string> atts;
Split(pripers[a], ".", atts);
if (strcmp(atts[1].c_str(), "date") == 0) {
printf("获取到了时间\n");
date_t vadate;
if (strcmp(values[a].c_str(), "SysDate") == 0) {
// 获取当前时间
auto timeNow = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
// 转换为本地时间
tm localTime;
localtime_s(&localTime, &timeNow);
// 初始化date_t对象
vadate.year = localTime.tm_year + 1900;
vadate.month = static_cast<byte>(localTime.tm_mon) + 1;
vadate.day = static_cast<byte>(localTime.tm_mday);
vadate.hour = static_cast<byte>(localTime.tm_hour);
vadate.minute = static_cast<byte>(localTime.tm_min);
vadate.second = static_cast<byte>(localTime.tm_sec);
}
else {
printf("开始转换时间\n");
//ITKCALL(ITK_string_to_date(values[a].c_str(), &vadate));
/*vector<string> dataList;
Split(values[a].c_str(), "-", dataList);*/
// 创建tm对象用于存储转换后的日期
std::tm date = {};
// 使用std::istringstream解析日期字符串
std::istringstream iss(values[a].c_str());
iss >> std::get_time(&date, "%Y-%m-%d %H:%M:%S");
// 检查日期是否解析成功
if (iss.fail())
{
std::cout << "转换失败!" << std::endl;
return 1;
}
else {
// 初始化date_t对象
vadate.year = date.tm_year + 1900;
vadate.month = static_cast<byte>(date.tm_mon) + 1;
vadate.day = static_cast<byte>(date.tm_mday);
vadate.hour = static_cast<byte>(date.tm_hour);
vadate.minute = static_cast<byte>(date.tm_min);
vadate.second = static_cast<byte>(date.tm_sec);
}
}
printf("属性%s=%s\n", atts[0].c_str(), values[a].c_str());
// 打印转换后的日期
std::cout << "年:" << vadate.year << std::endl;
std::cout << "月:" << static_cast<int>(vadate.month) << std::endl;
std::cout << "日:" << static_cast<int>(vadate.day) << std::endl;
std::cout << "时:" << static_cast<int>(vadate.hour) << std::endl;
std::cout << "分:" << static_cast<int>(vadate.minute) << std::endl;
std::cout << "秒:" << static_cast<int>(vadate.second) << std::endl;
ITKCALL(AOM_set_value_date(rows[b], atts[0].c_str(), vadate));
}
else if (strcmp(atts[1].c_str(), "string") == 0) {
printf("获取到了字符串\n");
printf("属性%s=%s\n", atts[0].c_str(), values[a].c_str());
ITKCALL(AOM_set_value_string(rows[b], atts[0].c_str(), values[a].c_str()));
ITKCALL(AOM_UIF_set_value(rows[b], atts[0].c_str(), values[a].c_str()));
}
AOM_save(rows[b]);
AOM_unlock(rows[b]);
AOM_refresh(rows[b], true);
}
}
else {
char* error = "流程参数配置有误";
EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", error);
return 1;
}
}
break;
}
}
AOM_save(reltags[j]);
AOM_unlock(reltags[j]);
AOM_refresh(reltags[j], true);
}
}
}
}
//关旁路
POM_AM__set_application_bypass(false);
}
return 0;
}

@ -0,0 +1,365 @@
#include"kutil.h"
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include "libxl.h"
#include <io.h>
#include <direct.h>
#include <cfm/cfm.h>
#include <wchar.h>
#include <locale>
#include <codecvt>
#include <chrono>
#include <Windows.h>
#include <thread>
#include <regex>
#include <res\reservation.h>
#include "libxl.h"
#include <map>
#include <fstream>
#include <iostream>
using namespace libxl;
using namespace std::chrono_literals;
using namespace std;
#define debug true
#define ITK_err 919012
string get_value(const map<string, string>& value_map, const string& key) {
auto iter = value_map.find(key);
if (iter != value_map.end()) {
return iter->second;
}
else {
return "";
}
}
bool isSubstring(char* str1, char* str2) {
int len1 = strlen(str1);
int len2 = strlen(str2);
int i = 0, j = 0;
while (i < len1 && j < len2) {
if (str1[i] == ',') {
i++;
continue;
}
if (str1[i] == str2[j]) {
i++;
j++;
}
else {
i = i - j + 1;
j = 0;
}
}
if (j == len2) {
return true;
}
else {
return false;
}
}
int flag = 0;
void insertDataToExcel2(char temp_file[SS_MAXPATHLEN], map<string, string> dataList) {
printf("----------------开始执行插入数据操作---------------------\n");
//将数据写入本地使用Java插入数据
string json = "{";
for (auto it = dataList.begin(); it != dataList.end(); ++it) {
json += "\"" + it->first + "\":\"" + it->second + "\",";
}
json.pop_back(); // 删除最后一个逗号
json += "}";
printf("json:%s", json.c_str());
// 将JSON格式的字符串写入文件
ofstream ofs("D:\\ldexcel\\output.txt");
ofs << json;
ofs.close();
printf("开始执行cmd方法");
char cmd[1024] = "";
strcpy(cmd, "java -jar D:\\Siemens\\Teamcenter13\\bin\\writeAsExcel.jar");
strcat(cmd, " ");
strcat(cmd, temp_file);
strcat(cmd, " ");
strcat(cmd, "D:\\ldexcel\\output.txt");
printf("\n%s\n", cmd);
system(cmd);
printf("cmd方法执行完毕");
for (auto it = dataList.begin(); it != dataList.end(); ++it) {
cout << it->first << ": " << it->second << endl;
}
/*libxl::Book* book = xlCreateXMLBook();
printf("设置产品密匙\n");
book->setKey(L"Halil Kural", L"windows-2723210a07c4e90162b26966a8jcdboe");//设置密钥
if (book) {
printf("开始\n");
printf("path%s\n", temp_file);
int len = strlen(temp_file);
int size = MultiByteToWideChar(CP_ACP, 0, temp_file, len, NULL, 0); // 获取所需空间大小
wstring wstr(size, 0);
MultiByteToWideChar(CP_ACP, 0, temp_file, len, &wstr[0], size); // 转换为wchar_t数组
wprintf(L"path2%s", wstr.c_str()); // 使用wprintf输出
if (book->load(wstr.c_str())) {
printf("加载Excel文件成功\n");
printf("获取sheet页\n");
libxl::Sheet* sheet = book->getSheet(0);
if (sheet) {
map<string, string> dataList; // 定义一个map对象
dataList["A1"] = "Hello";
dataList["B2"] = "world!";
for (auto& data : dataList) { // 遍历map中的数据
string cellName = data.first; // 获取单元格的名称
string cellValue = data.second; // 获取单元格的值
int row = sheet->nameToRow(cellName.c_str()); // 获取行号
int col = sheet->nameToColumn(cellName.c_str()); // 获取列号
sheet->writeStr(row, col, cellValue.c_str(), 0); // 在单元格中写入数据
}
}
}
else {
printf("加载Excel文件失败错误码%d\n", book->errorMessage());
}
book->release();
}*/
}
int LD_FormAttrToExcel(EPM_action_message_t msg) {
printf("开始执行");
int att_cnt = 0;
int doc_num = 0;
tag_t rootTask_tag = NULLTAG;
tag_t task = NULLTAG;
tag_t *attachments = NULLTAG;
tag_t *doc_tags = NULLTAG;
string error;
char *arg = NULL, *argflag = NULL, *argvalue = NULL;
int arg_cnt = TC_number_of_arguments(msg.arguments);
char *include_type = NULL, *relation = NULL, *formtype = NULL, *option = NULL;
task = msg.task;
ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
if (arg_cnt > 0)
{
for (int i = 0; i < arg_cnt; i++)
{
arg = TC_next_argument(msg.arguments);
ITKCALL(ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue));
if (strcmp(argflag, "include_type") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:", argvalue);
include_type = argvalue;
}
}
if (strcmp(argflag, "relation") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:", argvalue);
relation = argvalue;
}
}
if (strcmp(argflag, "formtype") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:", argvalue);
formtype = argvalue;
}
}
if (strcmp(argflag, "Option") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:", argvalue);
option = argvalue;
}
}
}
//获取流程下目标关系下的对象
printf("获取流程下目标关系下的对象");
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &doc_num, &doc_tags));
for (int i = 0; i < doc_num; i++) {
char *type = NULL;
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &type));
if (strcmp(type, include_type) == 0) {
//查找指定关系
printf("查找指定关系");
int gx_num; tag_t *gx_obj; map<string, string> rowsvalue;
ITKCALL(AOM_ask_value_tags(doc_tags[i], relation, &gx_num, &gx_obj));
for (int j = 0; j < gx_num; j++) {
char *form = NULL;
ITKCALL(AOM_ask_value_string(gx_obj[i], "object_type", &form));
printf("判断是否属于配置类型");
//判断是否属于配置类型
printf("formtype&s\n", formtype);
printf("form&s\n", form);
if (isSubstring(formtype, form)) {
printf("获取表格属性");
//获取表格属性
int rownum; tag_t *tableRownum = NULL;
ITKCALL(AOM_ask_table_rows(gx_obj[i], "ld6_ChangeTable", &rownum, &tableRownum));
printf("读取首选项的值");
int op_nums; char ** op_values = NULL;
PREF_ask_char_values(option, &op_nums, &op_values);
printf("获取表格数据");
printf("表格行数为%d\n", rownum);
printf("首选项行数为%d\n", op_nums);
for (int z = 0; z < rownum; z++) {
printf("1");
string new_str;
printf("2");
for (int a = 0; a < op_nums; a++) {
printf("3");
char *getVal = op_values[a];
printf("4");
int serial_num; tag_t *tableRow = NULL;
printf("5");
if (a == 0) {
printf("6");
printf("表单中的序号属性,获取表单表格的序号");
vector<string> ans;
Split(getVal, ".", ans);
if (ans.size() > 0) {
tag_t rowTag = tableRownum[z];
char *xuhao;
ITKCALL(AOM_ask_value_string(rowTag, ans[2].c_str(), &xuhao));
string pattern = "0(\\d)";
string replacement = "$1";
new_str = regex_replace(xuhao, regex(pattern), replacement);
}
}
else {
printf("后续行格式");
vector<string> ans;
Split(getVal, ".", ans);
if (ans.size() > 1) {
printf("将属性按照=分割");
vector<string> getnas;
Split(ans[2].c_str(), "=", getnas);
tag_t rowTag = tableRownum[z];
char *value;
if (strstr(getnas[0].c_str(), "Time")) {
date_t getdate;
ITKCALL(AOM_ask_value_date(rowTag, getnas[0].c_str(), &getdate));
char fileDate[128] = "";
sprintf_s(fileDate, "%04d-%02d-%02d 00:00", getdate.year, getdate.month + 1, getdate.day);
value = fileDate;
}
else {
ITKCALL(AOM_ask_value_string(rowTag, getnas[0].c_str(), &value));
}
if (value == NULL) {
value = "";
}
if (strcmp(value, "0000-01-00 00:00") == 0) {
value = "";
}
string key = getnas[1] + new_str;
std::string valueStr = value;
std::size_t pos = valueStr.find('\n');
while (pos != std::string::npos) {
valueStr.erase(pos, 1);
pos = valueStr.find('\n', pos);
}
rowsvalue[key.c_str()] = valueStr;
}
else {
//当外层循环走最后一遍的时候,获取表单上的属性
if (z == rownum - 1) {
printf("获取表单属性");
vector<string> getnas;
Split(getVal, "=", getnas);
char *value;
ITKCALL(AOM_ask_value_string(gx_obj[i], getnas[0].c_str(), &value));
if (value == NULL) {
value = "";
}
std::string valueStr = value;
std::size_t pos = valueStr.find('\n');
while (pos != std::string::npos) {
valueStr.erase(pos, 1);
pos = valueStr.find('\n', pos);
}
rowsvalue[getnas[1].c_str()] = valueStr;
}
}
}
}
}
printf("表格数据获取完毕。开始反填excel");
//表格数据获取完毕。开始反填excel
printf("获取规范关系下的excel数据集");
int gf_num; tag_t *gf_obj;
ITKCALL(AOM_ask_value_tags(doc_tags[i], "IMAN_specification", &gf_num, &gf_obj));
printf("获取到了%d个数据集", gf_num);
for (int s = 0; s < gf_num; s++) {
tag_t gettag = gf_obj[s]; char * objtype; char * objname;
ITKCALL(AOM_ask_value_string(gettag, "object_type", &objtype));
ITKCALL(AOM_ask_value_string(gettag, "object_name", &objname));
printf("获取到了%s类型的数据集", objtype);
if (strcmp(objtype, "MSExcelX") == 0) {
printf("获取到了excel数据集");
tag_t ref_object = NULLTAG;
printf("1");
AE_reference_type_t reference_type;
printf("2");
char ref_name[WSO_name_size_c + 1] = "excel";
ITKCALL(AE_ask_dataset_named_ref2(gettag, ref_name, &reference_type, &ref_object));
printf("3");
//printf("reference_type%s", reference_type);
if (reference_type == AE_PART_OF)
{
char *pathname = "";
ITKCALL(IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname));
printf("4");
char *origin_file_name = "";
ITKCALL(IMF_ask_original_file_name2(ref_object, &origin_file_name));
printf("5");
char new_ds_name[WSO_name_size_c + 1] = "";
char *new_file_name = USER_new_file_name(new_ds_name, ref_name, "xlsx", 0);
printf("6");
char *temp_dir = getenv("temp");
printf("7");
char temp_file[SS_MAXPATHLEN] = "";
strcpy(temp_file, "D:\\ldexcel");
strcat(temp_file, "\\");
strcat(temp_file, new_file_name);
printf("temp_file%s", temp_file);
ITKCALL(IMF_export_file(ref_object, temp_file));
printf("8");
printf("开始插入数据");
//string str(temp_file);
insertDataToExcel2(temp_file, rowsvalue);
//挂载数据集
printf("数据插入完成,开始挂载数据集");
ITKCALL(import_dataset_file_binary(gettag, temp_dir, "excel", "xlsx", temp_file, objname));
printf("执行结束");
}
}
}
}
}
}
}
}
return 0;
}

@ -0,0 +1,194 @@
#include"kutil.h"
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include "libxl.h"
#include <io.h>
#include <direct.h>
#include <cfm/cfm.h>
#include <wchar.h>
#include <locale>
#include <codecvt>
#include <chrono>
#include <Windows.h>
#include <thread>
#include <regex>
#include <res\reservation.h>
#include "libxl.h"
#include <map>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <filesystem>
#include <sys/stat.h>
#include <iostream>
using namespace libxl;
using namespace std::chrono_literals;
using namespace std;
#define debug true
#define ITK_err 919012
int LD_GYLXFrozen(EPM_action_message_t msg) {
printf("《《《《《《《《《《《《《《《《《《《开始执行LD_GYLXFrozen处理程序》》》》》》》》》》》》》》》》");
tag_t rootTask_tag = NULLTAG;
tag_t task = NULLTAG;
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
int arg_cnt = TC_number_of_arguments(msg.arguments);
//流程参数
char* ZBS = NULL;
char* type = NULL;
//目标对象参数
int doc_num = 0;
tag_t* doc_tags = NULLTAG;
task = msg.task;
ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
if (arg_cnt > 0)
{
for (int i = 0; i < arg_cnt; i++)
{
arg = TC_next_argument(msg.arguments);
ITKCALL(ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue));
if (strcmp(argflag, "ZBS") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:\n", argvalue);
ZBS = argvalue;
}
}
if (strcmp(argflag, "type") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:\n", argvalue);
type = argvalue;
}
}
}
//获取流程目标对象版本
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &doc_num, &doc_tags));
auto file = std::make_unique<std::ofstream>("D:\\TCTOSAP\\jsonStr.txt");
//std::ofstream file("D:\\MESTOTC\\example.txt", std::ios_base::trunc); // 打开文件,并清空内容
file->is_open();
for (int i = 0; i < doc_num;i++) {
string jsonStr = "";
string douhao = ",";
string ate = "@";
string fenhao = ";";
char* mbtype;
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &mbtype));
printf("类型为%s\n",mbtype);
if (strstr(type,mbtype)!= nullptr) {
printf("匹配到了类型\n");
char* id;
ITKCALL(AOM_ask_value_string(doc_tags[i], "item_id", &id));
jsonStr = jsonStr + ZBS + douhao + id + douhao + mbtype + douhao;
printf("JSONStr = %s\n",jsonStr.c_str());
printf("开始获取表格属性\n");
printf("获取关系\n");
//关系参数
int gx_num = 0;
tag_t* gx_tags = NULLTAG;
ITKCALL(AOM_ask_value_tags(doc_tags[i], "LD6_GYLXCompanyFormRelation", &gx_num,&gx_tags));
printf("获取表单\n");
for (int j = 0; j < gx_num;j++) {
char* gxtype;
ITKCALL(AOM_ask_value_string(gx_tags[j], "object_type", &gxtype));
printf("类型为%s\n", gxtype);
if (strcmp(gxtype,"LD6_GYLXCompanyForm") == 0) {
printf("匹配到了表单\n");
printf("获取表格属性\n");
//遍历表格
int num;//表格行数
tag_t* rows = NULL;//表格对象
ITKCALL(AOM_ask_table_rows(gx_tags[j], "ld6_GYLXCompanyTable", &num, &rows));
printf("获取表格\n");
for (int a = 0; a < num; a++) {
char* WERKS, * MATNR, * PLNNR, * PLNAL;
ITKCALL(AOM_ask_value_string(rows[a], "ld6_company", &WERKS));
ITKCALL(AOM_ask_value_string(rows[a], "ld6_partid", &MATNR));
ITKCALL(AOM_ask_value_string(rows[a], "ld6_groupNum", &PLNNR));
ITKCALL(AOM_ask_value_string(rows[a], "ld6_groupCounter", &PLNAL));
if (a == num-1) {
jsonStr = jsonStr + WERKS + ate + MATNR + ate + PLNNR + ate + PLNAL;
}
else {
jsonStr = jsonStr + WERKS + ate + MATNR + ate + PLNNR + ate + PLNAL + fenhao;
}
}
printf("jsonStr = %s\n", jsonStr.c_str());
//将数据写入文件
*file << jsonStr.c_str() << std::endl;
//退出当前循环
break;
}
}
}
}
//执行jar包给SAP发送请求
//获取当前流程uid
char* flowId;
ITK__convert_tag_to_uid(rootTask_tag, &flowId);
//调用cmd执行jar包将数据传递到MES和SAP中
char cmd[8192] = "";
strcpy(cmd, "java -jar D:\\Siemens\\Teamcenter13\\bin\\sapjco3.jar");
strcat(cmd, " ");
strcat(cmd, "SendSAP");
strcat(cmd, " ");
strcat(cmd, flowId);
system(cmd);
//读取本地的result文件SAP
string fileid = flowId;
string SAPfile = "D:\\TCTOSAP\\" + fileid + "result.txt";
std::ifstream file1(SAPfile);
if (!file1.is_open()) {
std::cerr << "Failed to open file!" << std::endl;
char* error = "服务未响应";
EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", error);
return 1;
}
else {
std::stringstream buffer1;
buffer1 << file1.rdbuf();
std::string resultStr = buffer1.str();
printf("返回的值%s:\n", resultStr.c_str());
if (strcmp(resultStr.c_str(), "成功") == 0) {
for (int i = 0; i < doc_num; i++) {
char* mbtype;
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &mbtype));
if (strcmp(mbtype, argflag) == 0) {
//修改属性值
AOM_lock(doc_tags[i]);
ITKCALL(AOM_set_value_string(doc_tags[i], "ld6_gylxiffrozentosap", "成功"));
AOM_save(doc_tags[i]);
AOM_unlock(doc_tags[i]);
AOM_refresh(doc_tags[i], true);
}
}
return 0;
}
else {
for (int i = 0; i < doc_num; i++) {
char* mbtype;
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &mbtype));
if (strcmp(mbtype, argflag) == 0) {
//修改属性值
AOM_lock(doc_tags[i]);
ITKCALL(AOM_set_value_string(doc_tags[i], "ld6_gylxiffrozentosap", "失败"));
AOM_save(doc_tags[i]);
AOM_unlock(doc_tags[i]);
AOM_refresh(doc_tags[i], true);
}
}
EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", resultStr.c_str());
return 1;
}
}
return 1;
}
}

@ -0,0 +1,279 @@
#include"kutil.h"
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include "libxl.h"
#include <io.h>
#include <direct.h>
#include <cfm/cfm.h>
#include <wchar.h>
#include <locale>
#include <codecvt>
#include <chrono>
#include <Windows.h>
#include <thread>
#include <regex>
#include <res\reservation.h>
#include "libxl.h"
#include <map>
#include <fstream>
#include <iostream>
#include <cstdio>
using namespace libxl;
using namespace std::chrono_literals;
using namespace std;
#define debug true
#define ITK_err 919012
std::string generateJsonString2(char* MATNR, char* FLAG,char * MATEREV,char * ZXPLC) {
// 拼接JSON字符串
std::string jsonString = "[\n";
jsonString += " {\n";
jsonString += " \"MATNR\":\"";
jsonString += MATNR;
jsonString += "\",\n";
jsonString += " \"MATEREV\":\"";
jsonString += MATEREV;
jsonString += "\",\n";
jsonString += " \"ZXPLC\":\"";
jsonString += ZXPLC;
jsonString += "\",\n";
jsonString += " \"FLAG\":\"";
jsonString += FLAG;
jsonString += "\"\n";
jsonString += " }\n";
jsonString += "]";
// 返回JSON字符串
return jsonString;
}
// 转义json字符串
void escapeJson1(std::string& str) {
int len = str.length();
int newLen = len;
for (int i = 0; i < len; i++) {
if (str[i] == '"' || str[i] == '\\') {
newLen++;
}
}
std::string escapedStr;
escapedStr.reserve(newLen);
for (int i = 0; i < len; i++) {
if (str[i] == '"' || str[i] == '\\') {
escapedStr.push_back('\\');
}
escapedStr.push_back(str[i]);
}
str = escapedStr;
}
/**
*
* @handlerName: LD_PartChange
* @Description: \1. \MESSAP
* @change MATEREV-typeitem_revision_id
ZXPLC-typeld6_ifNewProduct,"
* @changeDate 2024/1/23
* @author hcj
*/
int LD_PartChange(EPM_action_message_t msg) {
printf("开始执行");
int att_cnt = 0;
int doc_num = 0;
tag_t rootTask_tag = NULLTAG;
tag_t task = NULLTAG;
tag_t* attachments = NULLTAG;
tag_t* doc_tags = NULLTAG;
string error;
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
int arg_cnt = TC_number_of_arguments(msg.arguments);
char * FLAG = NULL, * type = NULL;
task = msg.task;
string erro2 = "";
string erro = "";
int send1 = 0;
int send2 = 0;
ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
if (arg_cnt > 0)
{
for (int i = 0; i < arg_cnt; i++)
{
arg = TC_next_argument(msg.arguments);
ITKCALL(ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue));
if (strcmp(argflag, "FLAG") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:\n", argvalue);
FLAG = argvalue;
}
}
if (strcmp(argflag, "type") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:\n", argvalue);
type = argvalue;
}
}
}
//获取流程下目标关系下的对象
printf("获取流程下目标关系下的对象");
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &doc_num, &doc_tags));
for (int i = 0; i < doc_num; i++) {
char* objtype = NULL;
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &objtype));
if (strstr(type, objtype) != nullptr) {
//获取物料编码
char* MATNR = NULL;
char* MATEREV = NULL;
char* ZXPLC = "常规";
ITKCALL(AOM_ask_value_string(doc_tags[i], "item_id", &MATNR));
ITKCALL(AOM_ask_value_string(doc_tags[i], "item_revision_id", &MATEREV));
try {
AOM_ask_value_string(doc_tags[i], "ld6_ifNewProduct", &ZXPLC);
}
catch (const std::exception& e) {
printf("没有获取到属性值ld6_ifNewProduct\n");
}
//获取首选项的值
char* url = NULL;
PREF_ask_char_value("LD_PLM2MES_PartChange_Config", 0, &url);
//获取要发送的json字符串
std::string jsonString = generateJsonString2(MATNR, FLAG, MATEREV, ZXPLC);
printf("jsonString:%s\n", jsonString.c_str());
std::regex regex("\\s+");
std::string result = std::regex_replace(jsonString, regex, "");
// 转义处理后的json字符串
escapeJson1(result);
//调用jar包向接口发送数据
printf("开始执行cmd方法");
char cmd[1024] = "";
strcpy(cmd, "java -jar D:\\Siemens\\Teamcenter13\\bin\\sapjco3.jar");
strcat(cmd, " ");
strcat(cmd, " ");
strcat(cmd, url);
strcat(cmd, " ");
strcat(cmd, result.c_str());
strcat(cmd, " ");
strcat(cmd, "2");
printf("\n%s\n", cmd);
system(cmd);
//读取本地文件获取执行结果
//读取本地的result文件SAP
string id = MATNR;
string SAPfile = "D:\\TCTOSAP\\" + id + "result.txt";
std::ifstream file(SAPfile);
if (!file.is_open()) {
std::cerr << "Failed to open file!" << std::endl;
char* error = "SAP服务未响应";
EMH_store_error_s1(EMH_severity_error, EMH_AE_error_base,error);
//EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", error);
return 1;
}
else {
std::stringstream buffer1;
buffer1 << file.rdbuf();
std::string resultStr = buffer1.str();
printf("返回的值%s:\n", resultStr.c_str());
AOM_lock(doc_tags[i]);
if (strcmp(resultStr.c_str(), "同步成功") == 0) {
ITKCALL(AOM_set_value_string(doc_tags[i], "ld6_partiffrozentosap", "成功"));
}
else {
//EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", resultStr.c_str());
ITKCALL(AOM_set_value_string(doc_tags[i], "ld6_partiffrozentosap", "失败"));
erro = erro + resultStr;
}
AOM_save(doc_tags[i]);
AOM_unlock(doc_tags[i]);
AOM_refresh(doc_tags[i], true);
}
//清空result文件的信息
std::ofstream file8(SAPfile, std::ios::trunc); // 打开文件并设置为写入模式,使用 trunc 模式会清空文件内容
if (!file8) {
//删除result文件C:\TCTOLIMS
remove(SAPfile.c_str());
}
else {
//删除result文件C:\TCTOLIMS
remove(SAPfile.c_str());
file8.close(); // 关闭文件流
}
//读取本地的result文件MAS
string MASpath = "D:\\TCTOMAS\\" + id + "result.txt";
std::ifstream file1(MASpath);
if (!file1.is_open()) {
std::cerr << "Failed to open file!" << std::endl;
char* error = "MES服务未响应";
EMH_store_error_s1(EMH_severity_error, EMH_AE_error_base, error);
//EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", error);
return 1;
}
else {
std::stringstream buffer1;
buffer1 << file1.rdbuf();
std::string resultStr = buffer1.str();
printf("返回的值%s:\n", resultStr.c_str());
if (strcmp(resultStr.c_str(), "保存成功") == 0) {
ITKCALL(AOM_set_value_string(doc_tags[i], "ld6_partiffrozentomes", "成功"));
}
else{
erro2 = erro2 + resultStr;
ITKCALL(AOM_set_value_string(doc_tags[i], "ld6_partiffrozentomes", "失败"));
send2++;
}
AOM_save(doc_tags[i]);
AOM_unlock(doc_tags[i]);
AOM_refresh(doc_tags[i], true);
//清空删除文件
//清空result文件的信息
std::ofstream file2(MASpath, std::ios::trunc); // 打开文件并设置为写入模式,使用 trunc 模式会清空文件内容
if (!file2) {
//删除result文件C:\TCTOLIMS
remove(MASpath.c_str());
}
else {
//删除result文件C:\TCTOLIMS
remove(MASpath.c_str());
file2.close(); // 关闭文件流
}
}
}
}
//去掉最后一个逗号
if (!strcmp(erro.c_str(), "") == 0) {
size_t lastCommaPos = erro.find_last_of(',');
if (lastCommaPos != std::string::npos) {
erro = erro.substr(0, lastCommaPos);
}
}
if (send1 > 0 && send2 > 0) {
string senderror = "错误信息发送SAP" + erro + "发送MES" + erro2;
EMH_store_error_s1(EMH_severity_error, EMH_AE_error_base, senderror.c_str());
//EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", senderror.c_str());
return 1;
}
else if (send1 > 0 && send2 == 0) {
string senderror = "错误信息发送SAP" + erro;
EMH_store_error_s1(EMH_severity_error, EMH_AE_error_base, senderror.c_str());
//EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", senderror.c_str());
return 1;
}
else if (send1 == 0 && send2 > 0) {
string senderror = "错误信息发送MES" + erro2;
EMH_store_error_s1(EMH_severity_error, EMH_AE_error_base, senderror.c_str());
//EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", senderror.c_str());
return 1;
}
}
return 0;
}

@ -0,0 +1,356 @@
#include"kutil.h"
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include "libxl.h"
#include <io.h>
#include <direct.h>
#include <cfm/cfm.h>
#include <wchar.h>
#include <locale>
#include <codecvt>
#include <chrono>
#include <Windows.h>
#include <thread>
#include <regex>
#include <res\reservation.h>
#include "libxl.h"
#include <map>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace libxl;
using namespace std::chrono_literals;
using namespace std;
#define debug true
#define ITK_err 919012
std::string generateJsonString(const char* MATNR, const char* FLAG, const char* WERKS, const char* MATEREV, const char* ZXPLC) {
std::string jsonStr = "[\n";
jsonStr += " {\n";
jsonStr += " \"MATNR\":\"" + std::string(MATNR) + "\",\n";
jsonStr += " \"MATEREV\":\"" + std::string(MATEREV) + "\",\n";
jsonStr += " \"ZXPLC\":\"" + std::string(ZXPLC) + "\",\n";
jsonStr += " \"FLAG\":\"" + std::string(FLAG) + "\",\n";
jsonStr += " \"I_MARC\":\n";
jsonStr += " [\n";
std::vector<std::string> werksVec;
std::string werksStr(WERKS);
size_t pos = werksStr.find(";");
if (pos != std::string::npos) {
// WERKS contains comma, split it
size_t startPos = 0;
while (pos != std::string::npos) {
std::string werksValue = werksStr.substr(startPos, pos - startPos);
startPos = pos + 1;
pos = werksStr.find(";", startPos);
werksVec.push_back(werksValue);
}
werksVec.push_back(werksStr.substr(startPos));
}
else {
// WERKS does not contain comma
werksVec.push_back(werksStr);
}
for (size_t i = 0; i < werksVec.size(); ++i) {
jsonStr += " {\n";
jsonStr += " \"WERKS\":\"" + werksVec[i] + "\"\n";
jsonStr += (i == werksVec.size() - 1) ? " }\n" : " },\n";
}
jsonStr += " ]\n";
jsonStr += " }\n";
jsonStr += "]\n";
return jsonStr;
}
// 转义json字符串
void escapeJson(std::string& str) {
int len = str.length();
int newLen = len;
for (int i = 0; i < len; i++) {
if (str[i] == '"' || str[i] == '\\') {
newLen++;
}
}
std::string escapedStr;
escapedStr.reserve(newLen);
for (int i = 0; i < len; i++) {
if (str[i] == '"' || str[i] == '\\') {
escapedStr.push_back('\\');
}
escapedStr.push_back(str[i]);
}
str = escapedStr;
}
/**
*
* @handlerName: LD_PartCompFLAG
* @Description: SAPMES
* @change MATEREV-typeitem_revision_id
ZXPLC-typeld6_ifNewProduct,"
* @changeDate 2024/1/23
* @author hcj
*/
int LD_PartCompFLAG(EPM_action_message_t msg) {
printf("开始执行");
int att_cnt = 0;
int doc_num = 0;
tag_t rootTask_tag = NULLTAG;
tag_t task = NULLTAG;
tag_t* attachments = NULLTAG;
tag_t* doc_tags = NULLTAG;
string error;
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
int arg_cnt = TC_number_of_arguments(msg.arguments);
char* WERKS = NULL, * FLAG = NULL, * type = NULL;
task = msg.task;
string erro2 = "";
string erro = "";
int send1 = 0;
int send2 = 0;
ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
if (arg_cnt > 0)
{
for (int i = 0; i < arg_cnt; i++)
{
arg = TC_next_argument(msg.arguments);
ITKCALL(ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue));
if (strcmp(argflag, "WERKS") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:\n", argvalue);
WERKS = argvalue;
}
}
if (strcmp(argflag, "FLAG") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:\n", argvalue);
FLAG = argvalue;
}
}
if (strcmp(argflag, "type") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:\n", argvalue);
type = argvalue;
}
}
}
//获取流程下目标关系下的对象
printf("获取流程下目标关系下的对象");
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &doc_num, &doc_tags));
for (int i = 0; i < doc_num; i++) {
char* objtype = NULL;
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &objtype));
if (strstr(type, objtype) != nullptr) {
//获取物料编码
char* MATNR = NULL;
char* MATEREV = NULL;
char* ZXPLC = "常规";
ITKCALL(AOM_ask_value_string(doc_tags[i], "item_id", &MATNR));
ITKCALL(AOM_ask_value_string(doc_tags[i], "item_revision_id", &MATEREV));
try {
AOM_ask_value_string(doc_tags[i], "ld6_ifNewProduct", &ZXPLC);
}
catch (const std::exception& e) {
printf("没有获取到属性值ld6_ifNewProduct\n");
}
//获取首选项的值
char* url = NULL;
PREF_ask_char_value("LD_PLM2MES_PartCompFLAG_Config",0,&url);
printf("url:%s\n", url);
//获取要发送的json字符串
std::string jsonString = generateJsonString(MATNR, FLAG, WERKS,MATEREV,ZXPLC);
printf("jsonString:%s\n", jsonString.c_str());
std::regex regex("\\s+");
std::string result = std::regex_replace(jsonString, regex, "");
// 转义处理后的json字符串
escapeJson(result);
//调用jar包向接口发送数据
printf("开始执行cmd方法");
char cmd[1024] = "";
strcpy(cmd, "java -jar D:\\Siemens\\Teamcenter13\\bin\\sapjco3.jar");
strcat(cmd, " ");
strcat(cmd, url);
strcat(cmd, " ");
strcat(cmd, result.c_str());
strcat(cmd, " ");
strcat(cmd, "1");
printf("\n%s\n", cmd);
system(cmd);
//读取本地文件获取执行结果
//读取本地的result文件SAP
string id = MATNR;
string SAPfile = "D:\\TCTOSAP\\"+ id +"result.txt";
std::ifstream file(SAPfile);
if (!file.is_open()) {
std::cerr << "Failed to open file!" << std::endl;
char* error = "SAP服务未响应";
EMH_store_error_s1(EMH_severity_error, EMH_AE_error_base, error);
//EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", error);
return 1;
}
else {
std::map<std::string, std::vector<std::string>> resultMap;
std::string line;
while (std::getline(file, line)) {
std::istringstream iss(line);
std::string key;
std::string value;
if (std::getline(iss, key, ':') && std::getline(iss, value)) {
// 去除首尾的空格
key = key.substr(key.find_first_not_of(' '));
key = key.substr(0, key.find_last_not_of(' ') + 1);
value = value.substr(value.find_first_not_of(' '));
value = value.substr(0, value.find_last_not_of(' ') + 1);
// 将value字符串转换为vector<string>
std::vector<std::string> valueVec;
std::istringstream issValue(value);
std::string singleValue;
while (std::getline(issValue, singleValue, ',')) {
valueVec.push_back(singleValue);
}
resultMap[key] = valueVec;
}
}
file.close();
//获取表单
int tagnum; tag_t* tags = NULL;
tag_t form = NULL;
ITKCALL(AOM_ask_value_tags(doc_tags[i], "LD6_CompanyFormRelation", &tagnum, &tags));
if (tagnum>0) {
for (int h = 0; h < tagnum;h++) {
char* type;
ITKCALL(AOM_ask_value_string(tags[h], "object_type", &type));
if (strcmp(type,"LD6_CompanyForm") == 0) {
form = tags[h];
break;
}
}
}
else {
printf("LD6_CompanyTable关系错误");
}
//开始填充表格数据
for (const auto& entry : resultMap) {
std::cout << "Key: " << entry.first << std::endl;
int num;
tag_t* rows;
ITKCALL(AOM_ask_table_rows(form, "ld6_CompanyTable", &num, &rows));
int flnum = 0;
for (int a = 0; a < num; a++) {
char* getValue;
ITKCALL(AOM_ask_value_string(rows[a], "ld6_company", &getValue));
if (strcmp(entry.first.c_str(), getValue) == 0) {
std::vector<std::string> valueMap = resultMap[entry.first];
AOM_lock(rows[a]);
printf("FLAG:%s\n", FLAG);
printf("valueMap[0]:%s\n", valueMap[0].c_str());
ITKCALL(AOM_set_value_string(rows[a], "ld6_partcompifdel", FLAG));
ITKCALL(AOM_set_value_string(rows[a], "ld6_partstatussyncsap", valueMap[0].c_str()));
AOM_save(rows[a]);
AOM_unlock(rows[a]);
if (strcmp(valueMap[0].c_str(), "E") == 0) {
erro = erro + entry.first + valueMap[1] +",";
send1++;
}
}
}
}
}
//清空result文件的信息
std::ofstream file8(SAPfile, std::ios::trunc); // 打开文件并设置为写入模式,使用 trunc 模式会清空文件内容
if (!file8) {
//删除result文件C:\TCTOLIMS
remove(SAPfile.c_str());
}
else {
//删除result文件C:\TCTOLIMS
remove(SAPfile.c_str());
file8.close(); // 关闭文件流
}
//读取本地的result文件MAS
string MASpath = "D:\\TCTOMAS\\" + id + "result.txt";
std::ifstream file1(MASpath);
if (!file1.is_open()) {
std::cerr << "Failed to open file!" << std::endl;
char* error = "MES服务未响应";
EMH_store_error_s1(EMH_severity_error, EMH_AE_error_base, error);
//EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", error);
return 1;
}
else {
std::stringstream buffer1;
buffer1 << file1.rdbuf();
std::string resultStr = buffer1.str();
printf("返回的值%s:\n", resultStr.c_str());
AOM_lock(doc_tags[i]);
if (strcmp(resultStr.c_str(),"保存成功") == 0) {
ITKCALL(AOM_set_value_string(doc_tags[i], "ld6_partstatusSyncMES", "成功"));
}
else{
erro2 = erro2 + resultStr;
//EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", resultStr.c_str());
ITKCALL(AOM_set_value_string(doc_tags[i], "ld6_partstatusSyncMES", "失败"));
send2++;
}
AOM_save(doc_tags[i]);
AOM_unlock(doc_tags[i]);
AOM_refresh(doc_tags[i], true);
}
//清空删除文件
//清空result文件的信息
std::ofstream file2(MASpath, std::ios::trunc); // 打开文件并设置为写入模式,使用 trunc 模式会清空文件内容
if (!file2) {
//删除result文件C:\TCTOLIMS
remove(MASpath.c_str());
}
else {
//删除result文件C:\TCTOLIMS
remove(MASpath.c_str());
file2.close(); // 关闭文件流
}
}
}
//去掉最后一个逗号
if (!strcmp(erro.c_str(), "") == 0) {
size_t lastCommaPos = erro.find_last_of(',');
if (lastCommaPos != std::string::npos) {
erro = erro.substr(0, lastCommaPos);
}
}
if (send1>0 && send2>0) {
string senderror = "错误信息发送SAP" + erro + "发送MES" + erro2;
EMH_store_error_s1(EMH_severity_error, EMH_AE_error_base, senderror.c_str());
//EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", );
return 1;
}else if(send1 > 0 && send2 == 0) {
string senderror = "错误信息发送SAP" + erro;
EMH_store_error_s1(EMH_severity_error, EMH_AE_error_base, senderror.c_str());
//EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", senderror.c_str());
return 1;
}
else if (send1 == 0 && send2 > 0) {
string senderror = "错误信息发送MES" + erro2;
EMH_store_error_s1(EMH_severity_error, EMH_AE_error_base, senderror.c_str());
//EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", senderror.c_str());
return 1;
}
}
return 0;
}

@ -0,0 +1,297 @@
#include"kutil.h"
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include "libxl.h"
#include <io.h>
#include <direct.h>
#include <cfm/cfm.h>
#include <wchar.h>
#include <locale>
#include <codecvt>
#include <chrono>
#include <Windows.h>
#include <thread>
#include <regex>
#include <res\reservation.h>
#include "libxl.h"
#include <map>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <filesystem>
#include <sys/stat.h>
#include <iostream>
using namespace libxl;
using namespace std::chrono_literals;
using namespace std;
#define debug true
#define ITK_err 919012
std::string generateJsonString2(char *folwId, vector<string> id, vector<string> version, vector<string> fileName) {
std::string jsonStr = "{\n";
jsonStr += " \"flowId\":\"" + std::string(folwId) + "\",\n";
jsonStr += " \"file\":\n";
jsonStr += " [\n";
for (int i = 0; i < id.size();i++) {
jsonStr += " {\n";
if (i == id.size()-1) {
jsonStr += " \"id\":\"" + std::string(id[i]) + "\",\n";
jsonStr += " \"version\":\"" + std::string(version[i]) + "\",\n";
jsonStr += " \"url\":\"" + std::string(fileName[i]) + "\"\n";
jsonStr += " }\n";
break;
}
jsonStr += " \"id\":\"" + std::string(id[i]) + "\",\n";
jsonStr += " \"version\":\"" + std::string(version[i]) + "\",\n";
jsonStr += " \"type\":\"" + std::string(fileName[i]) + "\"\n";
jsonStr += " },\n";
}
jsonStr += " ]\n";
jsonStr += " }\n";
return jsonStr;
}
// 转义json字符串
void escapeJson2(std::string& str) {
int len = str.length();
int newLen = len;
for (int i = 0; i < len; i++) {
if (str[i] == '"' || str[i] == '\\') {
newLen++;
}
}
std::string escapedStr;
escapedStr.reserve(newLen);
for (int i = 0; i < len; i++) {
if (str[i] == '"' || str[i] == '\\') {
escapedStr.push_back('\\');
}
escapedStr.push_back(str[i]);
}
str = escapedStr;
}
bool copyFileToFolder(const std::string& filePath, const std::string& folderPath) {
// 打开源文件
std::ifstream sourceFile(filePath, std::ios::binary);
if (!sourceFile) {
std::cout << "文件不存在或无法打开" << std::endl;
return false;
}
// 获取文件名
size_t lastSlashIndex = filePath.find_last_of("/\\");
std::string fileName = filePath.substr(lastSlashIndex + 1);
// 构造目标路径
std::string destinationPath = folderPath + "/" + fileName;
// 打开目标文件
std::ofstream destinationFile(destinationPath, std::ios::binary);
if (!destinationFile) {
std::cout << "无法创建目标文件" << std::endl;
return false;
}
// 复制文件
destinationFile << sourceFile.rdbuf();
// 关闭文件
sourceFile.close();
destinationFile.close();
std::cout << "文件已成功复制到目标文件夹" << std::endl;
return true;
}
int LD_SendDJJDD_To_MES(EPM_action_message_t msg) {
printf("开始执行");
int att_cnt = 0;
int doc_num = 0;
tag_t rootTask_tag = NULLTAG;
tag_t task = NULLTAG;
tag_t* doc_tags = NULLTAG;
string error;
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
int arg_cnt = TC_number_of_arguments(msg.arguments);
char* types = NULL;
string erro2 = "";
string erro = "";
int send1 = 0;
int send2 = 0;
task = msg.task;
ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
if (arg_cnt > 0)
{
for (int i = 0; i < arg_cnt; i++)
{
arg = TC_next_argument(msg.arguments);
ITKCALL(ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue));
if (strcmp(argflag, "type") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:\n", argvalue);
types = argvalue;
}
}
}
printf("获取UID");
char* flowId;
ITK__convert_tag_to_uid(rootTask_tag, &flowId);
printf("%s\n", flowId);
//获取流程下目标关系下的对象
printf("8888888888888888888888888888888888888888888\n");
printf("获取流程下目标关系下的对象\n");
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &doc_num, &doc_tags));
printf("开始循环获取的目标对象%d\n", doc_num);
vector<string>ids;
vector<string> revisions;
vector<string> fileNames;
//获取首选项的值
printf("获取首选项的值\n");
char* url = NULL, *sendfilepath = NULL,*fileURL = NULL;
PREF_ask_char_value("LD_PLM2MES_DJJDD_Config", 0, &url);
PREF_ask_char_value("LD_PLM2MES_DJJDD_Config", 1, &sendfilepath);
PREF_ask_char_value("LD_PLM2MES_DJJDD_Config", 2, &fileURL);
printf("url:%s\n", url);
printf("sendfilepath:%s\n", sendfilepath);
printf("fileURL:%s\n", fileURL);
for (int i = 0; i < doc_num; i++) {
char* objtype = NULL;
printf("获取类型\n");
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &objtype));
vector<string> ans;
Split(types, ";", ans);
for (int n = 0; n < ans.size(); n++) {
string gettype = ans[n];
printf("与流程参数type对比%s=%s\n",gettype.c_str(), objtype);
if (strcmp(gettype.c_str(), objtype) == 0) {
//获取id
printf("获取id\n");
char* id = NULL;
ITKCALL(AOM_ask_value_string(doc_tags[i], "item_id", &id));
ids.push_back(id);
//获取revision
printf("获取revision\n");
char* version = NULL;
ITKCALL(AOM_ask_value_string(doc_tags[i], "item_revision_id", &version));
revisions.push_back(version);
//获取数据集文件
printf("获取数据集文件\n");
int das_num = 0;
tag_t* das_tags;
ITKCALL(AOM_ask_value_tags(doc_tags[i], "IMAN_specification", &das_num, &das_tags));
string files;
for (int m = 0; m < das_num;m++) {
char* fileName = NULL;
ITKCALL(AOM_ask_value_string(das_tags[m], "object_name", &fileName));
time_t nowtime;
time(&nowtime); //获取1970年1月1日0点0分0秒到现在经过的秒数
tm p;
localtime_s(&p, &nowtime); //将秒数转换为本地时间,年从1900算起,需要+1900,月为0-11,所以要+1
char fileDate[128] = "";
char buffer[80];
sprintf_s(buffer, "%04d%d%02d%02d%02d%02d", 1900 + p.tm_year, p.tm_mon + 1, p.tm_mday,p.tm_hour,p.tm_min,p.tm_sec);
printf("获取的时间:%s\n",buffer);
char sendname[SS_MAXPATHLEN] = "";
strcat(sendname, buffer);
strcat(sendname, "-");
strcat(sendname, fileName);
printf("合并后的字符串: % s\n", sendname);
printf("开始复制文件到file空间\n");
tag_t ref_object = NULLTAG;
printf("1");
AE_reference_type_t reference_type;
printf("2");
char ref_name[WSO_name_size_c + 1] = "excel";
ITKCALL(AE_ask_dataset_named_ref2(das_tags[m], ref_name, &reference_type, &ref_object));
printf("3");
if (reference_type == AE_PART_OF)
{
printf("7");
char temp_file[SS_MAXPATHLEN] = "";
strcpy(temp_file, sendfilepath);
strcat(temp_file, "\\");
strcat(temp_file, sendname);
printf("temp_file%s", temp_file);
ITKCALL(IMF_export_file(ref_object, temp_file));
}
char temp_fileurl[SS_MAXPATHLEN] = "";
strcpy(temp_fileurl, fileURL);
strcat(temp_fileurl, sendname);
files = files + temp_fileurl + ",";
}
if (!files.empty()) {
files = files.substr(0, files.length() - 1);
fileNames.push_back(files);
}
else {
fileNames.push_back("");
}
}
}
}
printf("获取要发送的json字符串\n");
printf("flowId:%s\n", flowId);
//获取要发送的json字符串
std::string jsonString = generateJsonString2(flowId, ids, revisions,fileNames);
printf("jsonString:%s\n", jsonString.c_str());
std::regex regex("\\s+");
std::string result = std::regex_replace(jsonString, regex, "");
// 转义处理后的json字符串
printf("转义处理后的json字符串\n");
escapeJson2(result);
printf("jsonString:%s\n", result.c_str());
//调用jar包向接口发送数据
printf("开始执行cmd方法");
char cmd[1024] = "";
strcpy(cmd, "java -jar D:\\Siemens\\Teamcenter13\\bin\\sapjco3.jar");
strcat(cmd, " ");
strcat(cmd, url);
strcat(cmd, " ");
strcat(cmd, result.c_str());
strcat(cmd, " ");
strcat(cmd, "3");
printf("\n%s\n", cmd);
system(cmd);
//读取本地文件获取执行结果
//读取本地的result文件SAP
string fileid = flowId;
string MESfile = "D:\\TCTOMES\\" + fileid + "result.txt";
std::ifstream file(MESfile);
if (!file.is_open()) {
std::cerr << "Failed to open file!" << std::endl;
char* error = "MES服务未响应";
EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", error);
return 1;
}
else {
std::stringstream buffer1;
buffer1 << file.rdbuf();
std::string resultStr = buffer1.str();
printf("返回的值%s:\n", resultStr.c_str());
if (strcmp(resultStr.c_str(), "成功") == 0) {
return 0;
}
else {
EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", resultStr.c_str());
return 1;
}
}
return 0;
}
}

@ -0,0 +1,839 @@
#include"kutil.h"
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include "libxl.h"
#include <io.h>
#include <direct.h>
#include <cfm/cfm.h>
#include <wchar.h>
#include <locale>
#include <codecvt>
#include <chrono>
#include <Windows.h>
#include <thread>
#include <regex>
#include <res\reservation.h>
#include "libxl.h"
#include <map>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <filesystem>
#include <sys/stat.h>
#include <iostream>
#include <random>
#include <windows.h>
#include <objbase.h>
#include <iostream>
using namespace libxl;
using namespace std::chrono_literals;
using namespace std;
#define debug true
#define ITK_err 919012
// 创建一个函数来写入数据
void writeDataToFile(const std::string& fileName, const std::string& data) {
// 创建一个输出文件流对象
std::ofstream outputFile(fileName);
// 检查文件是否成功打开
if (outputFile.is_open()) {
// 写入数据
outputFile << data;
// 关闭文件
outputFile.close();
std::cout << "Data written to file successfully." << std::endl;
}
else {
std::cerr << "Unable to open file for writing: " << fileName << std::endl;
}
}
// 生成UUID
char* generateRandomEightDigitNumberAsCharArray() {
GUID guid;
if (S_OK == CoCreateGuid(&guid)) {
// 动态分配足够的内存来存储GUID字符串包括'\0'
char* guidStr = new char[37];
sprintf(guidStr, "%08lX-%04hX-%04hX-%02hhX%02hhX-%02hhX%02hhX%02hhX%02hhX%02hhX%02hhX",
guid.Data1, guid.Data2, guid.Data3,
guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3],
guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
std::cout << "Generated GUID: " << guidStr << std::endl;
// 返回指向新创建字符串的指针
return guidStr;
}
else {
std::cerr << "Failed to create a GUID." << std::endl;
return nullptr; // 出错时返回nullptr
}
}
int LD_SendECRECN_ToSAPMES(EPM_action_message_t msg) {
printf("《《《《《《《《《《《《《《《《《《《开始执行LD_SendECRECN_ToSAPMES处理程序》》》》》》》》》》》》》》》》");
tag_t rootTask_tag = NULLTAG;
tag_t task = NULLTAG;
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
int arg_cnt = TC_number_of_arguments(msg.arguments);
//流程参数
char* type = NULL;
char* relation = NULL;
char* secondarytype = NULL;
//目标对象参数
int doc_num = 0;
tag_t* doc_tags = NULLTAG;
//错误信息参数
string erro2 = "";
string erro = "";
//发送信息参数
int send1 = 0;
int send2 = 0;
task = msg.task;
ITKCALL(EPM_ask_root_task(task, &rootTask_tag));
if (arg_cnt > 0)
{
for (int i = 0; i < arg_cnt; i++)
{
arg = TC_next_argument(msg.arguments);
ITKCALL(ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue));
if (strcmp(argflag, "primarytype") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:\n", argvalue);
type = argvalue;
}
}
if (strcmp(argflag, "relation") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:\n", argvalue);
relation = argvalue;
}
}
if (strcmp(argflag, "secondarytype") == 0) {
if (argvalue != NULL)
{
printf("获取的值%s:\n", argvalue);
secondarytype = argvalue;
}
}
}
if (strcmp(type, "") == 0 || strcmp(relation, "") == 0 || strcmp(secondarytype, "") == 0) {
//返回信息报错提示
char* error = "请检查流程参数是否有为空或未定义的情况";
EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", error);
return 1;
}
//获取MES的传递地址
char* url;
PREF_ask_char_value("LD_PLM2MES_ECRECN_Config", 0, &url);
//获取文件传输地址
char* sendfilepath, *fileURL;
PREF_ask_char_value("LD_SendECRECN_FileURL", 0, &sendfilepath);
PREF_ask_char_value("LD_SendECRECN_FileURL", 1, &fileURL);
//获取流程目标对象版本
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &doc_num, &doc_tags));
char* flowId = "";
//获取当前时间
time_t nowtime;
time(&nowtime); //获取1970年1月1日0点0分0秒到现在经过的秒数
tm p;
localtime_s(&p, &nowtime); //将秒数转换为本地时间,年从1900算起,需要+1900,月为0-11,所以要+1
char buffer[80];
//sprintf_s(buffer, "%04d%d%02d%02d%02d%02d", 1900 + p.tm_year, p.tm_mon + 1, p.tm_mday, p.tm_hour, p.tm_min, p.tm_sec);
sprintf_s(buffer, "%04d-%02d-%02d %02d:%02d:%2d", 1900 + p.tm_year, p.tm_mon + 1, p.tm_mday, p.tm_hour, p.tm_min,p.tm_sec);
printf("获取的时间:%s\n", buffer);
if (doc_num>0) {
//开始循环获取对象传递
std::stringstream jsonStr;
jsonStr << "[";
for (int i = 0; i < doc_num;i++) {
char* objtype = NULL;
printf("获取类型\n");
ITKCALL(AOM_ask_value_string(doc_tags[i], "object_type", &objtype));
printf("比较%s和%s是否相同\n",type, objtype);
if (strcmp(type, objtype) == 0) {
printf("获取到了匹配的类型");
//判断-primarytype参数中值的对象类型检查版本上的ld6_ifeffectProds属性值是否包含“无影响”如包含则跳过此数据传递
char* isbaohan;
ITKCALL(AOM_ask_value_string(doc_tags[i], "item_id", &flowId));
ITKCALL(AOM_ask_value_string(doc_tags[i], "ld6_ifeffectProd", &isbaohan));
if (strstr(isbaohan,"无影响")!=NULL) {
printf("当前匹配类型包含无影响,跳过该对象");
continue;
}
//获取指定关系下的对象
int das_num = 0;
tag_t* das_tags;
ITKCALL(AOM_ask_value_tags(doc_tags[i], relation, &das_num, &das_tags));
if (das_num>0) {
//获取类型匹配次对象类型
char* cdxtype = NULL;
for (int j = 0; j < das_num;j++) {
//开始拼接字符串组成json数据
char* MATNR = "", * ZVERSION = "", * ECNDOCU = "", * ECNSTATE = "", * ECRDOCU = "", * ECRSTATE = "", * ZSFYXSC = "", * ZDATE = "", * URLADD = " ";
ITKCALL(AOM_ask_value_string(das_tags[j], "object_type", &cdxtype));
if (strstr(secondarytype, cdxtype) != NULL) {
//获取MATNR物料号
printf("获取MATNR物料号\n");
ITKCALL(AOM_ask_value_string(das_tags[j], "item_id", &MATNR));
printf("获取ZVERSION零件版本\n");
ITKCALL(AOM_ask_value_string(das_tags[j], "ld6_clientPartRev", &ZVERSION));
//获取ECNDOCU单号
/*
* LD6_ECRRevisionLD6_ECRRevisionitem_id
* LD6_ECNRevisionLD6_ECNRevisionitem_id
*/
if (strcmp(type, "LD6_CNRevision") == 0) {
ITKCALL(AOM_ask_value_string(doc_tags[i], "item_id", &ECNDOCU));
date_t time1;
ITKCALL(AOM_ask_value_date(doc_tags[i], "date_released", &time1));
if (time1.year == 0) {
//日期为空
ECNSTATE = "未关闭";
}
else {
//日期不为空
ECNSTATE = "已关闭";
}
int gx = 0;
tag_t* gxtag;
ITKCALL(AOM_ask_value_tags(doc_tags[i], "CMImplements", &gx, &gxtag));
if (gx > 0)
{
for (int b = 0; b < gx; b++) {
char* ty;
ITKCALL(AOM_ask_value_string(gxtag[b], "object_type", &ty));
if (strcmp("LD6_CRRevision", ty) == 0) {
ITKCALL(AOM_ask_value_string(gxtag[b], "item_id", &ECRDOCU));
date_t time;
ITKCALL(AOM_ask_value_date(gxtag[b], "date_released", &time));
if (time.year == 0) {
//日期为空
ECRSTATE = "未关闭";
}
else {
//日期不为空
ECRSTATE = "已关闭";
}
}
//获取ZSFYXSC
ITKCALL(AOM_ask_value_string(doc_tags[i], "ld6_ifeffectProd", &ZSFYXSC));
//获取时间ZDATE
ZDATE = buffer;
//获取URLADD 将规范关系IMAN_specification的数据集传递到ftp中传递URL地址
int gfnum = 0;
tag_t* gftag = NULL;
printf("开始获取规范关系文件\n");
ITKCALL(AOM_ask_value_tags(doc_tags[i], "IMAN_specification", &gfnum, &gftag));
//获取数据集的引用对象
string files = "";
for (int a = 0; a < gfnum; a++) {
printf("获取到了规范关系文件,开始遍历\n");
char* fileName = NULL;
ITKCALL(AOM_ask_value_string(gftag[a], "object_name", &fileName));
time_t nowtime;
time(&nowtime); //获取1970年1月1日0点0分0秒到现在经过的秒数
tm p;
localtime_s(&p, &nowtime); //将秒数转换为本地时间,年从1900算起,需要+1900,月为0-11,所以要+1
char fileDate[128] = "";
char getbuffer[80];
sprintf_s(getbuffer, "%04d%d%02d%02d%02d%02d", 1900 + p.tm_year, p.tm_mon + 1, p.tm_mday, p.tm_hour, p.tm_min, p.tm_sec);
//sprintf_s(getbuffer, "%04d年%d月%02d日 %02d:%02d", 1900 + p.tm_year, p.tm_mon + 1, p.tm_mday, p.tm_hour, p.tm_min);
printf("获取的时间:%s\n", getbuffer);
char sendname[SS_MAXPATHLEN] = "";
strcat(sendname, getbuffer);
strcat(sendname, "-");
char* random = generateRandomEightDigitNumberAsCharArray();
strcat(sendname, random);
strcat(sendname, "-");
strcat(sendname, fileName);
printf("合并后的字符串: % s\n", sendname);
printf("开始复制文件到file空间\n");
tag_t ref_object = NULLTAG;
printf("1");
AE_reference_type_t reference_type;
printf("2");
char ref_name[WSO_name_size_c + 1] = "excel";
ITKCALL(AE_ask_dataset_named_ref2(gftag[a], ref_name, &reference_type, &ref_object));
printf("3");
if (reference_type == AE_PART_OF)
{
printf("7");
char temp_file[SS_MAXPATHLEN] = "";
strcpy(temp_file, sendfilepath);
strcat(temp_file, "\\");
strcat(temp_file, sendname);
printf("temp_file%s", temp_file);
ITKCALL(IMF_export_file(ref_object, temp_file));
}
char temp_fileurl[SS_MAXPATHLEN] = "";
strcpy(temp_fileurl, fileURL);
strcat(temp_fileurl, sendname);
files = files + temp_fileurl + ",";
}
if (!files.empty()) {
files = files.substr(0, files.length() - 1);
}
URLADD = const_cast<char*>(files.c_str());
//开始拼接字符串MATNR,ZVERSION,ECNDOCU,ECNSTATE,ECRDOCU,ECRSTATE,ZSFYXSC,DATE,URLADD;
jsonStr << "{";
jsonStr << "\"matnr\":\"" << MATNR << "\",";
jsonStr << "\"zversion\":\"" << ZVERSION << "\",";
jsonStr << "\"ecndocu\":\"" << ECNDOCU << "\",";
jsonStr << "\"ecnstate\":\"" << ECNSTATE << "\",";
jsonStr << "\"ecrdocu\":\"" << ECRDOCU << "\",";
jsonStr << "\"ecrstate\":\"" << ECRSTATE << "\",";
jsonStr << "\"zsfyxsc\":\"" << ZSFYXSC << "\",";
jsonStr << "\"zdate\":\"" << ZDATE << "\",";
jsonStr << "\"urladd\":\"" << URLADD << "\"},";
}
}
else
{
//获取ZSFYXSC
ITKCALL(AOM_ask_value_string(doc_tags[i], "ld6_ifeffectProd", &ZSFYXSC));
//获取时间ZDATE
ZDATE = buffer;
//获取URLADD 将规范关系IMAN_specification的数据集传递到ftp中传递URL地址
int gfnum = 0;
tag_t* gftag = NULL;
printf("开始获取规范关系文件\n");
ITKCALL(AOM_ask_value_tags(doc_tags[i], "IMAN_specification", &gfnum, &gftag));
//获取数据集的引用对象
string files = "";
for (int a = 0; a < gfnum; a++) {
printf("获取到了规范关系文件,开始遍历\n");
char* fileName = NULL;
ITKCALL(AOM_ask_value_string(gftag[a], "object_name", &fileName));
time_t nowtime;
time(&nowtime); //获取1970年1月1日0点0分0秒到现在经过的秒数
tm p;
localtime_s(&p, &nowtime); //将秒数转换为本地时间,年从1900算起,需要+1900,月为0-11,所以要+1
char fileDate[128] = "";
char getbuffer[80];
sprintf_s(getbuffer, "%04d%d%02d%02d%02d%02d", 1900 + p.tm_year, p.tm_mon + 1, p.tm_mday, p.tm_hour, p.tm_min, p.tm_sec);
//sprintf_s(getbuffer, "%04d年%d月%02d日 %02d:%02d", 1900 + p.tm_year, p.tm_mon + 1, p.tm_mday, p.tm_hour, p.tm_min);
printf("获取的时间:%s\n", getbuffer);
char sendname[SS_MAXPATHLEN] = "";
strcat(sendname, getbuffer);
strcat(sendname, "-");
char* random = generateRandomEightDigitNumberAsCharArray();
strcat(sendname, random);
strcat(sendname, "-");
strcat(sendname, fileName);
printf("合并后的字符串: % s\n", sendname);
printf("开始复制文件到file空间\n");
tag_t ref_object = NULLTAG;
printf("1");
AE_reference_type_t reference_type;
printf("2");
char ref_name[WSO_name_size_c + 1] = "excel";
ITKCALL(AE_ask_dataset_named_ref2(gftag[a], ref_name, &reference_type, &ref_object));
printf("3");
if (reference_type == AE_PART_OF)
{
printf("7");
char temp_file[SS_MAXPATHLEN] = "";
strcpy(temp_file, sendfilepath);
strcat(temp_file, "\\");
strcat(temp_file, sendname);
printf("temp_file%s", temp_file);
ITKCALL(IMF_export_file(ref_object, temp_file));
}
char temp_fileurl[SS_MAXPATHLEN] = "";
strcpy(temp_fileurl, fileURL);
strcat(temp_fileurl, sendname);
files = files + temp_fileurl + ",";
}
if (!files.empty()) {
files = files.substr(0, files.length() - 1);
}
URLADD = const_cast<char*>(files.c_str());
//开始拼接字符串MATNR,ZVERSION,ECNDOCU,ECNSTATE,ECRDOCU,ECRSTATE,ZSFYXSC,DATE,URLADD;
jsonStr << "{";
jsonStr << "\"matnr\":\"" << MATNR << "\",";
jsonStr << "\"zversion\":\"" << ZVERSION << "\",";
jsonStr << "\"ecndocu\":\"" << ECNDOCU << "\",";
jsonStr << "\"ecnstate\":\"" << ECNSTATE << "\",";
jsonStr << "\"ecrdocu\":\"" << ECRDOCU << "\",";
jsonStr << "\"ecrstate\":\"" << ECRSTATE << "\",";
jsonStr << "\"zsfyxsc\":\"" << ZSFYXSC << "\",";
jsonStr << "\"zdate\":\"" << ZDATE << "\",";
jsonStr << "\"urladd\":\"" << URLADD << "\"},";
}
}
else if (strcmp(type, "LD6_CRRevision") == 0) {
int gx = 0;
tag_t *gxtag;
ITKCALL(AOM_ask_value_tags(doc_tags[i], "CMImplementedBy", &gx, &gxtag));
ITKCALL(AOM_ask_value_string(doc_tags[i], "item_id", &ECRDOCU));
date_t time1;
ITKCALL(AOM_ask_value_date(doc_tags[i], "date_released", &time1));
if (time1.year == 0) {
//日期为空
ECRSTATE = "未关闭";
}
else {
//日期不为空
ECRSTATE = "已关闭";
}
for (int b = 0; b < gx;b++) {
char* ty;
ITKCALL(AOM_ask_value_string(gxtag[b], "object_type", &ty));
if (strcmp("LD6_CNRevision",ty) == 0) {
ITKCALL(AOM_ask_value_string(gxtag[b], "item_id", &ECNDOCU));
date_t time;
ITKCALL(AOM_ask_value_date(gxtag[b], "date_released", &time));
if (time.year == 0) {
//日期为空
ECNSTATE = "未关闭";
}
else {
//日期不为空
ECNSTATE = "已关闭";
}
}
//获取ZSFYXSC
ITKCALL(AOM_ask_value_string(doc_tags[i], "ld6_ifeffectProd", &ZSFYXSC));
//获取时间ZDATE
ZDATE = buffer;
//获取URLADD 将规范关系IMAN_specification的数据集传递到ftp中传递URL地址
int gfnum = 0;
tag_t* gftag = NULL;
printf("开始获取规范关系文件\n");
ITKCALL(AOM_ask_value_tags(doc_tags[i], "IMAN_specification", &gfnum, &gftag));
//获取数据集的引用对象
string files = "";
for (int a = 0; a < gfnum; a++) {
printf("获取到了规范关系文件,开始遍历\n");
char* fileName = NULL;
ITKCALL(AOM_ask_value_string(gftag[a], "object_name", &fileName));
time_t nowtime;
time(&nowtime); //获取1970年1月1日0点0分0秒到现在经过的秒数
tm p;
localtime_s(&p, &nowtime); //将秒数转换为本地时间,年从1900算起,需要+1900,月为0-11,所以要+1
char fileDate[128] = "";
char getbuffer[80];
sprintf_s(getbuffer, "%04d%d%02d%02d%02d%02d", 1900 + p.tm_year, p.tm_mon + 1, p.tm_mday, p.tm_hour, p.tm_min, p.tm_sec);
//sprintf_s(getbuffer, "%04d年%d月%02d日 %02d:%02d", 1900 + p.tm_year, p.tm_mon + 1, p.tm_mday, p.tm_hour, p.tm_min);
printf("获取的时间:%s\n", getbuffer);
char sendname[SS_MAXPATHLEN] = "";
strcat(sendname, getbuffer);
strcat(sendname, "-");
char* random = generateRandomEightDigitNumberAsCharArray();
strcat(sendname, random);
strcat(sendname, "-");
strcat(sendname, fileName);
printf("合并后的字符串: % s\n", sendname);
printf("开始复制文件到file空间\n");
tag_t ref_object = NULLTAG;
printf("1");
AE_reference_type_t reference_type;
printf("2");
char ref_name[WSO_name_size_c + 1] = "excel";
ITKCALL(AE_ask_dataset_named_ref2(gftag[a], ref_name, &reference_type, &ref_object));
printf("3");
if (reference_type == AE_PART_OF)
{
printf("7");
char temp_file[SS_MAXPATHLEN] = "";
strcpy(temp_file, sendfilepath);
strcat(temp_file, "\\");
strcat(temp_file, sendname);
printf("temp_file%s", temp_file);
ITKCALL(IMF_export_file(ref_object, temp_file));
}
char temp_fileurl[SS_MAXPATHLEN] = "";
strcpy(temp_fileurl, fileURL);
strcat(temp_fileurl, sendname);
files = files + temp_fileurl + ",";
}
if (!files.empty()) {
files = files.substr(0, files.length() - 1);
}
URLADD = const_cast<char*>(files.c_str());
//开始拼接字符串MATNR,ZVERSION,ECNDOCU,ECNSTATE,ECRDOCU,ECRSTATE,ZSFYXSC,DATE,URLADD;
jsonStr << "{";
jsonStr << "\"matnr\":\"" << MATNR << "\",";
jsonStr << "\"zversion\":\"" << ZVERSION << "\",";
jsonStr << "\"ecndocu\":\"" << ECNDOCU << "\",";
jsonStr << "\"ecnstate\":\"" << ECNSTATE << "\",";
jsonStr << "\"ecrdocu\":\"" << ECRDOCU << "\",";
jsonStr << "\"ecrstate\":\"" << ECRSTATE << "\",";
jsonStr << "\"zsfyxsc\":\"" << ZSFYXSC << "\",";
jsonStr << "\"zdate\":\"" << ZDATE << "\",";
jsonStr << "\"urladd\":\"" << URLADD << "\"},";
}
}
}
}
}
else {
/*
* -primarytypeLD6_CNRevision,LD6_CNRevision-relation
LD6_CNRevisionCMImplementsLD6_CRRevision-relation
-secondarytype
*/
if (strcmp(type,"LD6_CNRevision") == 0) {
int das_num2 = 0;
tag_t* das_tags2;
ITKCALL(AOM_ask_value_tags(doc_tags[i], "CMImplements", &das_num2, &das_tags2));
if (das_num2 > 0) {
//获取类型匹配次对象类型
char* cdxtype = NULL;
for (int j = 0; j < das_num2; j++) {
//开始拼接字符串组成json数据
char* MATNR = "", * ZVERSION = "", * ECNDOCU = "", * ECNSTATE = "", * ECRDOCU = "", * ECRSTATE = "", * ZSFYXSC = "", * ZDATE = "", * URLADD = " ";
ITKCALL(AOM_ask_value_string(das_tags2[j], "object_type", &cdxtype));
if (strstr(secondarytype, cdxtype) != NULL) {
//获取MATNR物料号
printf("获取MATNR物料号\n");
ITKCALL(AOM_ask_value_string(das_tags2[j], "item_id", &MATNR));
printf("获取ZVERSION零件版本\n");
ITKCALL(AOM_ask_value_string(das_tags2[j], "ld6_clientPartRev", &ZVERSION));
//获取ECNDOCU单号
/*
* LD6_ECRRevisionLD6_ECRRevisionitem_id
* LD6_ECNRevisionLD6_ECNRevisionitem_id
*/
if (strcmp(type, "LD6_CNRevision") == 0) {
ITKCALL(AOM_ask_value_string(doc_tags[i], "item_id", &ECNDOCU));
date_t time;
ITKCALL(AOM_ask_value_date(doc_tags[i], "date_released", &time));
if (time.year == 0) {
//日期为空
ECNSTATE = "未关闭";
}
else {
//日期不为空
ECNSTATE = "已关闭";
}
}
else if (strcmp(type, "LD6_CRRevision") == 0) {
ITKCALL(AOM_ask_value_string(doc_tags[i], "item_id", &ECRDOCU));
date_t time;
ITKCALL(AOM_ask_value_date(doc_tags[i], "date_released", &time));
if (time.year == 0) {
//日期为空
ECRSTATE = "未关闭";
}
else {
//日期不为空
ECRSTATE = "已关闭";
}
}
//获取ZSFYXSC
ITKCALL(AOM_ask_value_string(doc_tags[i], "ld6_ifeffectProd", &ZSFYXSC));
//获取时间ZDATE
ZDATE = buffer;
//获取URLADD 将规范关系IMAN_specification的数据集传递到ftp中传递URL地址
int gfnum = 0;
tag_t* gftag;
ITKCALL(AOM_ask_value_tags(doc_tags[i], "IMAN_specification", &gfnum, &gftag));
//获取数据集的引用对象
string files = "";
for (int a = 0; a < gfnum; a++) {
char* fileName = NULL;
ITKCALL(AOM_ask_value_string(gftag[a], "object_name", &fileName));
time_t nowtime;
time(&nowtime); //获取1970年1月1日0点0分0秒到现在经过的秒数
tm p;
localtime_s(&p, &nowtime); //将秒数转换为本地时间,年从1900算起,需要+1900,月为0-11,所以要+1
char fileDate[128] = "";
char getbuffer[80];
sprintf_s(getbuffer, "%04d%02d%02d%02d%02d%02d", 1900 + p.tm_year, p.tm_mon + 1, p.tm_mday, p.tm_hour, p.tm_min, p.tm_sec);
printf("获取的时间:%s\n", getbuffer);
char sendname[SS_MAXPATHLEN] = "";
strcat(sendname, getbuffer);
strcat(sendname, "-");
char* random = generateRandomEightDigitNumberAsCharArray();
strcat(sendname, random);
strcat(sendname, "-");
strcat(sendname, fileName);
printf("合并后的字符串: % s\n", sendname);
printf("开始复制文件到file空间\n");
tag_t ref_object = NULLTAG;
printf("1");
AE_reference_type_t reference_type;
printf("2");
char ref_name[WSO_name_size_c + 1] = "excel";
ITKCALL(AE_ask_dataset_named_ref2(gftag[a], ref_name, &reference_type, &ref_object));
printf("3");
if (reference_type == AE_PART_OF)
{
printf("7");
char temp_file[SS_MAXPATHLEN] = "";
strcpy(temp_file, sendfilepath);
strcat(temp_file, "\\");
strcat(temp_file, sendname);
printf("temp_file%s", temp_file);
ITKCALL(IMF_export_file(ref_object, temp_file));
}
char temp_fileurl[SS_MAXPATHLEN] = "";
strcpy(temp_fileurl, fileURL);
strcat(temp_fileurl, sendname);
files = files + temp_fileurl + ",";
}
if (!files.empty()) {
files = files.substr(0, files.length() - 1);
}
URLADD = const_cast<char*>(files.c_str());
//开始拼接字符串MATNR,ZVERSION,ECNDOCU,ECNSTATE,ECRDOCU,ECRSTATE,ZSFYXSC,DATE,URLADD;
jsonStr << "{";
jsonStr << "\"matnr\":\"" << MATNR << "\",";
jsonStr << "\"zversion\":\"" << ZVERSION << "\",";
jsonStr << "\"ecndocu\":\"" << ECNDOCU << "\",";
jsonStr << "\"ecnstate\":\"" << ECNSTATE << "\",";
jsonStr << "\"ecrdocu\":\"" << ECRDOCU << "\",";
jsonStr << "\"ecrstate\":\"" << ECRSTATE << "\",";
jsonStr << "\"zsfyxsc\":\"" << ZSFYXSC << "\",";
jsonStr << "\"zdate\":\"" << ZDATE << "\",";
jsonStr << "\"urladd\":\"" << URLADD << "\"},";
}
}
}
}
else {
char* MATNR = "", * ZVERSION = "", * ECNDOCU = "", * ECNSTATE = "", * ECRDOCU = "", * ECRSTATE = "", * ZSFYXSC = "", * ZDATE = "", * URLADD = " ";
//获取MATNR物料号
printf("获取MATNR物料号\n");
MATNR = " ";
printf("获取ZVERSION零件版本\n");
ZVERSION = " ";
//获取ECNDOCU单号
/*
* LD6_ECRRevisionLD6_ECRRevisionitem_id
* LD6_ECNRevisionLD6_ECNRevisionitem_id
*/
if (strcmp(type, "LD6_CNRevision") == 0) {
ITKCALL(AOM_ask_value_string(doc_tags[i], "item_id", &ECNDOCU));
date_t time;
ITKCALL(AOM_ask_value_date(doc_tags[i], "date_released", &time));
if (time.year == 0) {
//日期为空
ECNSTATE = "未关闭";
}
else {
//日期不为空
ECNSTATE = "已关闭";
}
}
else if (strcmp(type, "LD6_CRRevision") == 0) {
ITKCALL(AOM_ask_value_string(doc_tags[i], "item_id", &ECRDOCU));
date_t time;
ITKCALL(AOM_ask_value_date(doc_tags[i], "date_released", &time));
if (time.year == 0) {
//日期为空
ECRSTATE = "未关闭";
}
else {
//日期不为空
ECRSTATE = "已关闭";
}
}
//获取ZSFYXSC
ITKCALL(AOM_ask_value_string(doc_tags[i], "ld6_ifeffectProd", &ZSFYXSC));
//获取时间ZDATE
ZDATE = buffer;
//获取URLADD 将规范关系IMAN_specification的数据集传递到ftp中传递URL地址
int gfnum = 0;
tag_t* gftag;
ITKCALL(AOM_ask_value_tags(doc_tags[i], "IMAN_specification", &gfnum, &gftag));
//获取数据集的引用对象
string files = "";
if (gfnum>0)
{
for (int a = 0; a < gfnum; a++) {
char* fileName = NULL;
ITKCALL(AOM_ask_value_string(gftag[a], "object_name", &fileName));
time_t nowtime;
time(&nowtime); //获取1970年1月1日0点0分0秒到现在经过的秒数
tm p;
localtime_s(&p, &nowtime); //将秒数转换为本地时间,年从1900算起,需要+1900,月为0-11,所以要+1
char fileDate[128] = "";
char getbuffer[80];
sprintf_s(getbuffer, "%04d%02d%02d%02d%02d%02d", 1900 + p.tm_year, p.tm_mon + 1, p.tm_mday, p.tm_hour, p.tm_min, p.tm_sec);
printf("获取的时间:%s\n", getbuffer);
char sendname[SS_MAXPATHLEN] = "";
strcat(sendname, getbuffer);
strcat(sendname, "-");
char* random = generateRandomEightDigitNumberAsCharArray();
strcat(sendname, random);
strcat(sendname, "-");
strcat(sendname, fileName);
printf("合并后的字符串: % s\n", sendname);
printf("开始复制文件到file空间\n");
tag_t ref_object = NULLTAG;
printf("1");
AE_reference_type_t reference_type;
printf("2");
char ref_name[WSO_name_size_c + 1] = "excel";
ITKCALL(AE_ask_dataset_named_ref2(gftag[a], ref_name, &reference_type, &ref_object));
printf("3");
if (reference_type == AE_PART_OF)
{
printf("7");
char temp_file[SS_MAXPATHLEN] = "";
strcpy(temp_file, sendfilepath);
strcat(temp_file, "\\");
strcat(temp_file, sendname);
printf("temp_file%s", temp_file);
ITKCALL(IMF_export_file(ref_object, temp_file));
}
char temp_fileurl[SS_MAXPATHLEN] = "";
strcpy(temp_fileurl, fileURL);
strcat(temp_fileurl, sendname);
files = files + temp_fileurl + ",";
}
}
if (!files.empty()) {
files = files.substr(0, files.length() - 1);
}
URLADD = const_cast<char*>(files.c_str());
//开始拼接字符串MATNR,ZVERSION,ECNDOCU,ECNSTATE,ECRDOCU,ECRSTATE,ZSFYXSC,DATE,URLADD;
jsonStr << "{";
jsonStr << "\"matnr\":\"" << MATNR << "\",";
jsonStr << "\"zversion\":\"" << ZVERSION << "\",";
jsonStr << "\"ecndocu\":\"" << ECNDOCU << "\",";
jsonStr << "\"ecnstate\":\"" << ECNSTATE << "\",";
jsonStr << "\"ecrdocu\":\"" << ECRDOCU << "\",";
jsonStr << "\"ecrstate\":\"" << ECRSTATE << "\",";
jsonStr << "\"zsfyxsc\":\"" << ZSFYXSC << "\",";
jsonStr << "\"zdate\":\"" << ZDATE << "\",";
jsonStr << "\"urladd\":\"" << URLADD << "\"},";
}
}
break;
}
}
//删除最后一位逗号
// 获取当前的字符串内容
std::string str = jsonStr.str();
// 检查并移除结尾的逗号(如果存在)
if (!str.empty() && str.back() == ',') {
str.pop_back();
}
// 在字符串末尾添加一个中括号
str += "]";
printf("获取的值数组:%s\n", str.c_str());
if (strcmp(str.c_str(),"[]") == 0) {
//没有获取到数据 跳过检查
return 0;
}
char* taguid;
ITK__convert_tag_to_uid(rootTask_tag, &taguid);
string taguidstring = taguid;
string inputFile = "D:\\TCTOMAS\\" + taguidstring + "input.txt";
//将值数组写入本地
writeDataToFile(inputFile, str.c_str());
//调用cmd执行jar包将数据传递到MES和SAP中
char cmd[4196] = "";
strcpy(cmd, "java -jar D:\\Siemens\\Teamcenter13\\bin\\sapjco3.jar");
printf("\n1%s\n", cmd);
strcat(cmd, " ");
printf("\n2%s\n", cmd);
strcat(cmd, url);
printf("\n3%s\n", cmd);
strcat(cmd, " ");
printf("\n4%s\n", cmd);
strcat(cmd, taguid);
printf("\n5%s\n", cmd);
strcat(cmd, " ");
printf("\n6%s\n", cmd);
strcat(cmd, "ECNECR");
printf("\n7%s\n", cmd);
strcat(cmd, " ");
printf("\n8%s\n", cmd);
strcat(cmd, flowId);
printf("\n9%s\n", cmd);
system(cmd);
//读取本地文件获取执行结果
//读取本地的result文件SAP
string fileid = flowId;
string MESfile = "D:\\TCTOMAS\\" + fileid + "result.txt";
std::ifstream file(MESfile);
if (!file.is_open()) {
std::cerr << "Failed to open file!" << std::endl;
char* error = "服务未响应";
EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", error);
return 1;
}
else {
std::stringstream buffer1;
buffer1 << file.rdbuf();
std::string resultStr = buffer1.str();
printf("返回的值%s:\n", resultStr.c_str());
if (strcmp(resultStr.c_str(), "SAP:成功,MES:成功") == 0) {
return 0;
}
else {
EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", resultStr.c_str());
return 1;
}
}
return 0;
}
}
else {
//返回信息报错提示
char* error = "流程目标下没有对象";
EMH_store_error_s2(EMH_severity_error, ITK_err, "提示", error);
return 1;
}
}

@ -0,0 +1,125 @@
#include"kutil.h"
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include "libxl.h"
#include <io.h>
#include <direct.h>
#include <cfm/cfm.h>
#include <wchar.h>
#include <locale>
#include <codecvt>
#include <chrono>
#include <Windows.h>
#include <thread>
#include <regex>
#include <res\reservation.h>
#include "libxl.h"
#include <map>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <filesystem>
#include <sys/stat.h>
#include <iostream>
#include "ado.h"
using namespace libxl;
using namespace std::chrono_literals;
using namespace std;
#define debug true
#define ITK_err 919012
int LD_TaskAssignmentDate(EPM_action_message_t msg) {
printf("=========================开始===================\n");
int cnt = 0;
char** vals = NULL;
//获取首选项的值
PREF_ask_char_values("LD_dbinfo2", &cnt, &vals);
//获取当前时间
time_t now = time(0);
tm* p = localtime(&now);
char dateNow[128] = "";
sprintf_s(dateNow, "%04d%02d%02d%02d%02d%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
string dateString = dateNow;
int ifail = ITK_ok;
int attachments_num = 0;
tag_t rootTask = NULLTAG, * attachments = NULLTAG;
//获取任务对象
EPM_ask_root_task(msg.task, &rootTask);
//获取任务目标对象
EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments);
for (int r = 0; r < attachments_num; r++) {
char* itemObjId;
char* objectType;
char* revision_id;
AOM_ask_value_string(attachments[r], "object_type", &objectType);
printf("objectType===%s\n", objectType);
if (strcmp(objectType, "LD6_CusProdFolder") == 0) {
//获取前面condition节点的值
tag_t* fnd0ActuatedInteractiveTsks_val;
int fnd0ActuatedInteractiveTsks_num = 0;
AOM_ask_value_tags(attachments[r], "fnd0ActuatedInteractiveTsks", &fnd0ActuatedInteractiveTsks_num, &fnd0ActuatedInteractiveTsks_val);
if (fnd0ActuatedInteractiveTsks_num > 0) {
for (int i = 0; i < fnd0ActuatedInteractiveTsks_num; i++)
{
char* task_type;
AOM_ask_value_string(fnd0ActuatedInteractiveTsks_val[i], "task_type", &task_type);
printf("task_type===%s\n", task_type);
if (strcmp(task_type, "EPMConditionTask") == 0) {
char* task_result;
AOM_ask_value_string(fnd0ActuatedInteractiveTsks_val[i], "task_result", &task_result);
printf("task_result===%s\n", task_result);
//连接数据库保存当前名称到数据库
char* folder_uid;
ITK__convert_tag_to_uid(attachments[r], &folder_uid);//获取文件夹uid
if (open("infodba", "infodba", vals[1], vals[0])) {
printf("=========================连接失败===================\n");
}
else {
//获取当前时间
auto now = std::chrono::system_clock::now();
std::time_t time = std::chrono::system_clock::to_time_t(now);
std::tm* ptm = std::localtime(&time);
char buf[128];
strftime(buf, sizeof(buf), "%Y-%m-%d", ptm);
printf("time===%s\n", buf);
//update语句
char sql[200] = "";
sprintf(sql, "UPDATE LD6_NewProdForm_VALUES SET TaskAssignmentDate = '%s' WHERE ClientProductFolderPUID = '%s' AND NewProductTaskItem = '%s'", buf, folder_uid, task_result);
printf("sql===%s\n", sql);
if (ExecuteSQLNoInputParam(sql) == 0)
{
printf("=========================修改成功===================\n");
}
else
{
printf("=========================修改失败===================\n");
}
}
break;
}
}
}
}
}
printf("=========================结束===================\n");
return 0;
}

@ -0,0 +1,30 @@
========================================================================
动态链接库connor_signature 项目概述
========================================================================
表单签名
action handler: CONNOR_AVIC_Signature_master
参数
-node_type: 配置要提取签名信息的节点名称
-node_type_clear: 配置要清空签名信息的节点名称(因为无法确定已储存签名是从哪个节点提取的,清空指定节点信息实现困难,需要配置重新签名)
-date_format: 日期格式,默认%Y-%m-%d
首选项
Connor_AVIC_Signature_master: 详见规格书
Connor_AVIC_Department: 详见规格书
CATIA签名
action handler: Connor_AVIC_CATIASign
参数
-ModelSignMod: 配置后运行3D反签
-DrwSignMod: 配置后运行二维反签
-bypass: 配置后
执行
-TempPath: 配置下载路径
-SignInfo: 反签信息,格式“标识名=属性位置.属性名称”属性位置包含ITEM, REV, ITEMMASTER, REVMASTER注意大写
-donotdeletefile: 不删除签名中间文件
首选项
Connor_AVIC_ModelSignMod: 单值站点。配置3D反签命令即批处理文件内容并将临时文件路径替换为“%s”
Connor_AVIC_DrwSignMod: 单值,站点。配置二维反签命令,即批处理文件内容,并将临时文件路径替换为“%s”

@ -0,0 +1,143 @@
#include"kutil.h"
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include "libxl.h"
#include <io.h>
#include <direct.h>
#include <cstring>
#include <ctime>
#include <cfm/cfm.h>
#include <wchar.h>
#include <locale>
#include <ctime>
#include <iostream>
#include <codecvt>
#include <chrono>
#include <Windows.h>
#include <thread>
#include <regex>
#include <res\reservation.h>
#include "libxl.h"
#include <map>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
extern "C" int POM_AM__set_application_bypass(logical bypass);
int SH_PLM_Email(EPM_action_message_t msg) {
bool debug = false;
int ifail = ITK_ok, arg_cnt = 0, att_cnt = 0, task_count = 0, user_cnt = 0;
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
char* user_name = NULL, * job_name = NULL, * object_string,*username = "";
tag_t owning_user = NULL;
tag_t task_tag = NULLTAG, rootTask_tag = NULLTAG, user_tag = NULLTAG;
tag_t* attachments = NULL, * task_tags = NULL;
arg_cnt = TC_number_of_arguments(msg.arguments);
vector<tag_t> all_user_tags;
vector<string> mail_addrs;
char* outPersonMailAddress = NULL;
char* content = NULL;
ITKCALL(POM_get_user(&user_name, &user_tag));
printf("=============================================================\n");
printf("开始执行SH_PLM_Email\n");
printf("=============================================================\n");
printf("开超级权限\n");
POM_AM__set_application_bypass(true);
task_tag = msg.task;
if (task_tag == NULLTAG) {
goto end;
}
if (arg_cnt > 0)
{
for (int i = 0; i < arg_cnt; i++) {
arg = TC_next_argument(msg.arguments);
ITKCALL(ifail = ITK_ask_argument_named_value(arg, &argflag, &argvalue));
if (strcmp(argflag, "recipient") == 0) {
outPersonMailAddress = argvalue;
printf("outPersonMailAddress:%s\n",outPersonMailAddress);
}
if (strcmp(argflag, "content") == 0) {
content = argvalue;
printf("content:%s\n", content);
}
MEM_free(argflag);
MEM_free(argvalue);
}
}
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
ITKCALL(ifail = AOM_ask_value_string(rootTask_tag, "job_name", &job_name));
ITKCALL(ifail = AOM_ask_value_tag(rootTask_tag, "owning_user", &owning_user));
ITKCALL(ifail = AOM_ask_value_string(owning_user, "user_name", &username));
ITKCALL(ifail = AOM_ask_value_string(rootTask_tag, "object_string", &object_string));
printf("流程名称:%s\n", job_name);
printf("发起人:%s\n", user_name);
//解析外部邮箱人员地址
if (outPersonMailAddress != NULL) {
vector<string> mailaddressVector;
Split(outPersonMailAddress, ";", mailaddressVector);
for (int i = 0; i < mailaddressVector.size(); i++) {
mail_addrs.push_back(mailaddressVector[i]);
}
}
user_cnt = mail_addrs.size();
printf("发送邮件个数:%d\n", user_cnt);
printf("发送邮件人员:%s\n", mail_addrs[0].c_str());
char zt[128] = "";
strcat(zt, "【TeamCenter】-");
strcat(zt, object_string);
printf("发送邮件主题:%s\n", zt);
char nr[512] = "";
strcat(nr, "收到");
strcat(nr, username);
strcat(nr, "发起的");
strcat(nr, job_name);
strcat(nr, "任务,");
strcat(nr, content);
printf("发送邮件内容:%s\n", nr);
char jarfile[512] = "";
sprintf(jarfile, "%s\\bin\\EMailSender.jar", getenv("TC_ROOT"));
for (int i = 0; i < user_cnt; i++) {
char cmd[1024] = "";
string mail_addr = mail_addrs[i];
strcpy(cmd, "java -jar ");
strcat(cmd, jarfile);
strcat(cmd, " \"");
strcat(cmd, mail_addr.c_str());
strcat(cmd, "\" \"");
strcat(cmd, zt);
strcat(cmd, "\" \"");
strcat(cmd, nr);
strcat(cmd, "\"");
printf("CMD%s", cmd);
system(cmd);
printf("执行完成");
}
printf("关超级权限\n");
POM_AM__set_application_bypass(false);
end:
DOFREE(job_name);
DOFREE(attachments);
all_user_tags.clear();
printf("=============================================================\n");
printf("执行结束SH_PLM_Email\n");
printf("=============================================================\n");
return ITK_ok;
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,482 @@
#include"kutil.h"
#include <string>
int PLM_TO_SAP_NEW(EPM_action_message_t msg) {
int ifail = ITK_ok;
int attachments_num = 0;
int valueNum = 0;
tag_t rootTask = NULLTAG;
tag_t* attachments = NULLTAG;
char* object_type;
char* tc_root_file = getenv("tc_root"); //C:\Siemens\Teamcenter12
char* parameters = (char*)malloc(1000000 * sizeof(char)); //存放发送到SAP的数据
memset(parameters, 0, sizeof(char));
char** server_address;
char* item_rev_value = NULL;
//获取任务对象
EPM_ask_root_task(msg.task, &rootTask);
//获取任务目标对象
EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments);
for (int i = 0; i < attachments_num; i++)
{
//获取topline
ITKCALL(AOM_ask_value_string(attachments[i], "object_type", &object_type));
printf("object_type=%s \n", object_type);
//过滤掉非版本的对象
if ((strstr(object_type, "Revision") == NULL) || (strstr(object_type, "Master") != NULL)
|| (strstr(object_type, "master") != NULL) || (strstr(object_type, "BOM") != NULL) || (strstr(object_type, "bom") != NULL) || (strstr(object_type, "Bom") != NULL))
{
continue;
}
//得到是否已经下发sap是则不下发
char* if_Send_Sap = NULL;
AOM_ask_value_string(attachments[i], "r9_ISTOSAP", &if_Send_Sap);
if (strstr(object_type, "") != NULL) {
continue;
}
ITKCALL(PREF_ask_char_values("RK_SendSapMasterData", &valueNum, &server_address)); //获得首选项
//获取物料的puid
char* puid = NULL;
ITK__convert_tag_to_uid(attachments[i], &puid);
strcat(parameters, "getMasterDataPropertys}}");
strcat(parameters, puid);
strcat(parameters, "}}");
char* revbuf[32] = { 0 }; //存放分割后的子字符串
//得到首选项中配置的属性
for (int ii = 0; ii < valueNum; ii++)
{
int num = 0;//分割后子字符串的个数
//split(server_address[ii], "=", revbuf, &num);
strcat(parameters, revbuf[0] == NULL || strlen(revbuf[0]) == 0 ? "" : revbuf[0]);
strcat(parameters, "=");
AOM_ask_value_string(attachments[i], revbuf[1], &item_rev_value);
strcat(parameters, item_rev_value);
strcat(parameters, "");
}
//特殊属性(不可配置的属性或者定死的属性)
strcat(parameters, "BERID=1000_01¥");
strcat(parameters, "@@");
MEM_free(object_type);
object_type = NULL;
MEM_free(puid);
puid = NULL;
}
//把数据用写入文件
char data_file[SS_MAXPATHLEN] = "";
strcat(data_file, tc_root_file);
strcat(data_file, "\\data.txt");
FILE* fptr;
fptr = fopen(data_file, "w");
fprintf(fptr, "%s", parameters);
fclose(fptr);
//cmd指令
string strResult;
char cmd[256] = "";
strcpy(cmd, "java -jar \"");
//strcat(cmd, jar_file);
strcat(cmd, tc_root_file);
strcat(cmd, "\\portal\\plugins\\");
strcat(cmd, "callSap.jar");
//传参
strcat(cmd, data_file);
printf("路径:\n%s\n", cmd);
char buf[8000] = { 0 };
FILE* pf = NULL;
if ((pf = _popen(cmd, "r")) == NULL) {
printf("接口返回:\n%s", "1");
}
while (pf != NULL && fgets(buf, sizeof buf, pf)) {
strResult += buf;
}
_pclose(pf);
if (strlen(parameters) == 0) {
POM_AM__set_application_bypass(true);
//获取流程作业
tag_t job = NULLTAG;
EPM_ask_job(rootTask, &job);
//设置描述属性值
//先lock
AOM_lock(job);
//再set
AOM_set_value_string(job, "object_desc", "下发SAP信息失败没有需要下发的零件");
//再save
AOM_save(job);
//最后unlock
AOM_unlock(job);
AOM_refresh(job, FALSE);
//AOM_refresh( rootTask,FALSE );
POM_AM__set_application_bypass(false);
}
unsigned int iSize = strResult.size();
if (iSize > 0 && strResult[iSize - 1] == '\n' && strlen(parameters) > 0)
{
strResult = strResult.substr(0, iSize - 1);
printf("下发失败\n");
printf("返回消息:%s\n", strResult);
printf("目标的数量:%d\n", attachments_num);
for (int i = 0; i < attachments_num; i++)
{
//获取object_type
AOM_ask_value_string(attachments[i], "object_type", &object_type);
printf("object_type=%s \n", object_type);
if ((strstr(object_type, "Revision") == NULL) || (strstr(object_type, "Master") != NULL)
|| (strstr(object_type, "master") != NULL) || (strstr(object_type, "BOM") != NULL) || (strstr(object_type, "bom") != NULL) || (strstr(object_type, "Bom") != NULL))
{
continue;
}
char* item_id_value = NULL;
//获取item_id
AOM_ask_value_string(attachments[i], "item_id", &item_id_value);
strcat(item_id_value, "");
if (strstr(strResult.c_str(), item_id_value) == NULL)
{
//更改版本表单中是否以下发为“是”
POM_AM__set_application_bypass(true);
//先lock
AOM_lock(attachments[i]);
//再set
AOM_set_value_string(attachments[i], "r9_ISTOSAP", "");
//再save
AOM_save(attachments[i]);
//最后unlock
AOM_unlock(attachments[i]);
AOM_refresh(attachments[i], FALSE);
POM_AM__set_application_bypass(false);
}
}
printf("开始更新流程描述\n");
POM_AM__set_application_bypass(true);
//获取流程作业
tag_t job = NULLTAG;
EPM_ask_job(rootTask, &job);
//设置描述属性值
//先lock
AOM_lock(job);
//再set
AOM_set_value_string(job, "object_desc", "发送SAP信息失败具体失败原因请查看更新日志");
//再save
AOM_save(job);
//最后unlock
AOM_unlock(job);
AOM_refresh(job, FALSE);
//AOM_refresh( rootTask,FALSE );
POM_AM__set_application_bypass(false);
//EMH_store_error_s1( EMH_severity_user_error, EMH_USER_error_base,strResult.c_str());
//ifail = 1;
}
else
{
printf("成功下发sap");
for (int i = 0; i < attachments_num; i++)
{
//获取object_type
AOM_ask_value_string(attachments[i], "object_type", &object_type);
printf("object_type=%s \n", object_type);
if ((strstr(object_type, "Revision") == NULL) || (strstr(object_type, "Master") != NULL)
|| (strstr(object_type, "master") != NULL) || (strstr(object_type, "BOM") != NULL) || (strstr(object_type, "bom") != NULL) || (strstr(object_type, "Bom") != NULL))
{
continue;
}
//更改版本表单中是否以下发为“是”
POM_AM__set_application_bypass(true);
//先lock
AOM_lock(attachments[i]);
//再set
AOM_set_value_string(attachments[i], "r9_ISTOSAP", "");
//再save
AOM_save(attachments[i]);
//最后unlock
AOM_unlock(attachments[i]);
AOM_refresh(attachments[i], FALSE);
POM_AM__set_application_bypass(false);
MEM_free(object_type);
object_type = NULL;
}
POM_AM__set_application_bypass(true);
//获取流程作业
tag_t job = NULLTAG;
EPM_ask_job(rootTask, &job);
//设置描述属性值
//先lock
AOM_lock(job);
//再set
AOM_set_value_string(job, "object_desc", "成功下发!!");
//再save
AOM_save(job);
//最后unlock
AOM_unlock(job);
AOM_refresh(job, FALSE);
//AOM_refresh( rootTask,FALSE );
POM_AM__set_application_bypass(false);
}
//释放内存
tc_root_file = NULL;
MEM_free(item_rev_value);
item_rev_value = NULL;
return ifail;
}
int PLM_TO_SAP_Revise(EPM_action_message_t msg) {
int ifail = ITK_ok;
int attachments_num = 0;
int valueNum = 0;
tag_t rootTask = NULLTAG;
tag_t* attachments = NULLTAG;
char* object_type;
char* tc_root_file = getenv("tc_root"); //C:\Siemens\Teamcenter12
char* parameters = (char*)malloc(1000000 * sizeof(char)); //存放更新到SAP的数据
memset(parameters, 0, sizeof(char));
char** server_address;
char* item_rev_value = NULL;
//获取任务对象
EPM_ask_root_task(msg.task, &rootTask);
//获取任务目标对象
EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments);
for (int i = 0; i < attachments_num; i++)
{
//获取topline
ITKCALL(AOM_ask_value_string(attachments[i], "object_type", &object_type));
printf("object_type=%s \n", object_type);
//过滤掉非版本的对象
if ((strstr(object_type, "Revision") == NULL) || (strstr(object_type, "Master") != NULL)
|| (strstr(object_type, "master") != NULL) || (strstr(object_type, "BOM") != NULL) || (strstr(object_type, "bom") != NULL) || (strstr(object_type, "Bom") != NULL))
{
continue;
}
//得到是否已经下发sap是则不更新
char* if_Send_Sap = NULL;
AOM_ask_value_string(attachments[i], "", &if_Send_Sap);
//得到该对象的版本数量
tag_t item = NULLTAG, * revisions;
ITEM_ask_item_of_rev(attachments[i], &item);
int rev_count = 0;
ITEM_find_revisions(item, "*", &rev_count, &revisions);
printf("版本数量为:%d", rev_count);
if (strstr(object_type, "") != NULL || rev_count < 2) {
continue;
}
ITKCALL(PREF_ask_char_values("RK_SendSapMasterData", &valueNum, &server_address)); //获得首选项
//获取物料的puid
char* puid = NULL;
ITK__convert_tag_to_uid(attachments[i], &puid);
strcat(parameters, "getMasterDataPropertys}}");
strcat(parameters, puid);
strcat(parameters, "}}");
char* revbuf[32] = { 0 }; //存放分割后的子字符串
//得到首选项中配置的属性
for (int ii = 0; ii < valueNum; ii++)
{
int num = 0;//分割后子字符串的个数
//split(server_address[ii], "=", revbuf, &num);
strcat(parameters, revbuf[0] == NULL || strlen(revbuf[0]) == 0 ? "" : revbuf[0]);
strcat(parameters, "=");
AOM_ask_value_string(attachments[i], revbuf[1], &item_rev_value);
strcat(parameters, item_rev_value);
strcat(parameters, "");
}
//特殊属性(不可配置的属性或者定死的属性)
//strcat(parameters, "BERID=\"\"¥DEL_FLAG=\"\"¥");
strcat(parameters, "@@");
MEM_free(object_type);
object_type = NULL;
MEM_free(puid);
puid = NULL;
}
//把数据用写入文件
char data_file[SS_MAXPATHLEN] = "";
strcat(data_file, tc_root_file);
strcat(data_file, "\\data.txt");
FILE* fptr;
fptr = fopen(data_file, "w");
fprintf(fptr, "%s", parameters);
fclose(fptr);
//cmd指令
string strResult;
char cmd[256] = "";
strcpy(cmd, "java -jar \"");
//strcat(cmd, jar_file);
strcat(cmd, tc_root_file);
strcat(cmd, "\\portal\\plugins\\");
strcat(cmd, "callSap.jar");
//传参
strcat(cmd, data_file);
printf("路径:\n%s\n", cmd);
char buf[8000] = { 0 };
FILE* pf = NULL;
if ((pf = _popen(cmd, "r")) == NULL) {
printf("接口返回:\n%s", "1");
}
while (pf != NULL && fgets(buf, sizeof buf, pf)) {
strResult += buf;
}
_pclose(pf);
if (strlen(parameters) == 0) {
POM_AM__set_application_bypass(true);
//获取流程作业
tag_t job = NULLTAG;
EPM_ask_job(rootTask, &job);
//设置描述属性值
//先lock
AOM_lock(job);
//再set
AOM_set_value_string(job, "object_desc", "更新SAP信息失败没有需要下发的零件");
//再save
AOM_save(job);
//最后unlock
AOM_unlock(job);
AOM_refresh(job, FALSE);
//AOM_refresh( rootTask,FALSE );
POM_AM__set_application_bypass(false);
}
unsigned int iSize = strResult.size();
if (iSize > 0 && strResult[iSize - 1] == '\n' && strlen(parameters) > 0)
{
strResult = strResult.substr(0, iSize - 1);
printf("更新失败\n");
printf("返回消息:%s\n", strResult);
printf("目标的数量:%d\n", attachments_num);
for (int i = 0; i < attachments_num; i++)
{
//获取object_type
AOM_ask_value_string(attachments[i], "object_type", &object_type);
printf("object_type=%s \n", object_type);
if ((strstr(object_type, "Revision") == NULL) || (strstr(object_type, "Master") != NULL)
|| (strstr(object_type, "master") != NULL) || (strstr(object_type, "BOM") != NULL) || (strstr(object_type, "bom") != NULL) || (strstr(object_type, "Bom") != NULL))
{
continue;
}
char* item_id_value = NULL;
//获取item_id
AOM_ask_value_string(attachments[i], "item_id", &item_id_value);
strcat(item_id_value, "");
if (strstr(strResult.c_str(), item_id_value) == NULL)
{
//更改版本表单中是否以下发为“是”
POM_AM__set_application_bypass(true);
//先lock
AOM_lock(attachments[i]);
//再set
AOM_set_value_string(attachments[i], "r9_ISTOSAP", "");
//再save
AOM_save(attachments[i]);
//最后unlock
AOM_unlock(attachments[i]);
AOM_refresh(attachments[i], FALSE);
POM_AM__set_application_bypass(false);
}
}
printf("开始更新流程描述\n");
POM_AM__set_application_bypass(true);
//获取流程作业
tag_t job = NULLTAG;
EPM_ask_job(rootTask, &job);
//设置描述属性值
//先lock
AOM_lock(job);
//再set
AOM_set_value_string(job, "object_desc", "更新SAP信息失败具体失败原因请查看更新日志");
//再save
AOM_save(job);
//最后unlock
AOM_unlock(job);
AOM_refresh(job, FALSE);
//AOM_refresh( rootTask,FALSE );
POM_AM__set_application_bypass(false);
//EMH_store_error_s1( EMH_severity_user_error, EMH_USER_error_base,strResult.c_str());
//ifail = 1;
}
else
{
printf("成功更新sap");
for (int i = 0; i < attachments_num; i++)
{
//获取object_type
AOM_ask_value_string(attachments[i], "object_type", &object_type);
printf("object_type=%s \n", object_type);
if ((strstr(object_type, "Revision") == NULL) || (strstr(object_type, "Master") != NULL)
|| (strstr(object_type, "master") != NULL) || (strstr(object_type, "BOM") != NULL) || (strstr(object_type, "bom") != NULL) || (strstr(object_type, "Bom") != NULL))
{
continue;
}
//更改版本表单中是否以下发为“是”
POM_AM__set_application_bypass(true);
//先lock
AOM_lock(attachments[i]);
//再set
AOM_set_value_string(attachments[i], "r9_ISTOSAP", "");
//再save
AOM_save(attachments[i]);
//最后unlock
AOM_unlock(attachments[i]);
AOM_refresh(attachments[i], FALSE);
POM_AM__set_application_bypass(false);
MEM_free(object_type);
object_type = NULL;
}
POM_AM__set_application_bypass(true);
//获取流程作业
tag_t job = NULLTAG;
EPM_ask_job(rootTask, &job);
//设置描述属性值
//先lock
AOM_lock(job);
//再set
AOM_set_value_string(job, "object_desc", "成功更新!!");
//再save
AOM_save(job);
//最后unlock
AOM_unlock(job);
AOM_refresh(job, FALSE);
//AOM_refresh( rootTask,FALSE );
POM_AM__set_application_bypass(false);
}
//释放内存
tc_root_file = NULL;
MEM_free(item_rev_value);
item_rev_value = NULL;
return ifail;
}
int PLM_TO_SAP_Disuse(EPM_action_message_t msg) {
int ifail = ITK_ok;
return ifail;
}

@ -0,0 +1,177 @@
#include"kutil.h"
#include <tc/envelope.h>
#define ITK_err 919012
void sendTCMail(char* title, int ifail, string contents, tag_t rootTask_tag) {
//发送TC邮件
tag_t envelope, owning_user, envelope2, user2;
char* userId;
AOM_ask_owner(rootTask_tag, &owning_user);
AOM_ask_value_string(owning_user, "user_id", &userId);
ITKCALL(ifail = MAIL_create_envelope(title, contents.c_str(), &envelope));
ITKCALL(ifail = MAIL_initialize_envelope2(envelope, title, contents.c_str()));
ITKCALL(ifail = MAIL_add_envelope_receiver(envelope, owning_user));
ITKCALL(ifail = MAIL_send_envelope(envelope));
//发给殷工
SA_find_user2("two", &user2);
ITKCALL(ifail = MAIL_create_envelope(title, contents.c_str(), &envelope2));
ITKCALL(ifail = MAIL_initialize_envelope2(envelope2, title, contents.c_str()));
ITKCALL(ifail = MAIL_add_envelope_receiver(envelope2, user2));
ITKCALL(ifail = MAIL_send_envelope(envelope2));
printf("tc邮寄发送成功");
}
int TEST(EPM_action_message_t msg) {
int ifail = ITK_ok, task_count = 0;
int attachments_num = 0, * attach_type;
tag_t rootTask = NULLTAG, cur_perform_task, memberTag;
tag_t* attachments = NULLTAG, *task_tags = NULLTAG;
//获取任务对象
EPM_ask_root_task(msg.task, &rootTask);
//获取任务目标对象
//EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments);
char* puid = NULL;
ITK__convert_tag_to_uid(rootTask, &puid);
printf("当前根节点的puid为%s\n", puid);
EPM_ask_sub_tasks(rootTask, &task_count, &task_tags);
for (int i = 0; i < task_count; i++) {
char* task_type = NULL;
WSOM_ask_object_type2(task_tags[i], &task_type);
printf("当前节点的类型为:%s\n", task_type);
if (strcmp("EPMReviewTask", task_type) == 0 || strcmp("EPMAcknowledgeTask", task_type) == 0) {
EPM_ask_sub_task(task_tags[i], "select-signoff-team", &cur_perform_task);
EPM_ask_all_attachments(cur_perform_task, &attachments_num, &attachments, &attach_type);
if (attachments > 0) {
for (int j = 0; j < attachments_num; j++) {
char* comment = NULL;
date_t decision_date_temp;
tag_t aUserTag = NULLTAG;
EPM_signoff_decision_t dec;
SIGNOFF_TYPE_t memberType;
ITKCALL(EPM_ask_signoff_decision(attachments[j], &dec, &comment, &decision_date_temp));
ITKCALL(EPM_ask_signoff_member(attachments[j], &memberTag, &memberType));
printf("用户标签为:%d\n", memberTag);
ITKCALL(SA_ask_groupmember_user(memberTag, &aUserTag));
char* name;
ITKCALL(SA_ask_user_person_name2(aUserTag, &name));
printf("用户名称为:%s\n", name);
}
}
}
}
//sendTCMail("题目...", ifail, "内容ceshi", rootTask);
return ifail;
}
int TEST3(EPM_action_message_t msg) {
int ifail = ITK_ok, att_cnt = 0, arg_cnt = 0;
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
tag_t* attachments = NULLTAG, task_tag = NULLTAG, rootTask_tag;
string type,grant_value;
vector<string> types;
arg_cnt = TC_number_of_arguments(msg.arguments);
if (arg_cnt > 0) {
for (int i = 0; i < arg_cnt; i++) {
arg = TC_next_argument(msg.arguments);
ITKCALL(ifail = ITK_ask_argument_named_value(arg, &argflag, &argvalue));
if (strcmp(argflag, "type") == 0) {
type.assign(argvalue);
printf("%s\n", argvalue);
}
else if (strcmp(argflag, "grant") == 0) {
grant_value.assign(argvalue);
printf("%s\n", argvalue);
}
MEM_free(argflag);
MEM_free(argvalue);
}
}
else {
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数");
ifail = 1;
goto end;
}
{
if (grant_value.empty()) {
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数:-grant");
ifail = 1;
goto end;
}
Split(type, ";", types);
if (types.size() == 0) {
EMH_store_error_s1(EMH_severity_error, ITK_err, "未配置流程参数:-type");
ifail = 1;
goto end;
}
}
end:
DOFREE(attachments);
return ifail;
}
int TEST2(EPM_action_message_t msg) {
int ifail = ITK_ok;
int attachments_num = 0;
tag_t rootTask = NULLTAG;
tag_t* attachments = NULLTAG;
//获取任务对象
EPM_ask_root_task(msg.task, &rootTask);
//获取任务目标对象
EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments);
for (int i = 0; i < attachments_num; i++) {
//新建pdf数据集
tag_t item = NULLTAG,rev = attachments[i], spec_relation;
const char name[AE_datasettype_name_size_c + 1] = "Text";
char ref_name[WSO_name_size_c + 1] = "Text";
tag_t datasetType = NULLTAG, tool = NULLTAG;
tag_t newDatasetTag = NULLTAG; //新数据集的tag
tag_t relation = NULLTAG;
AE_find_datasettype2(name, &datasetType);
AE_create_dataset_with_id(datasetType, "数据集名称蛇皮", "数据集描述", "", "", &newDatasetTag);
AOM_lock(newDatasetTag);
AE_ask_datasettype_def_tool(datasetType, &tool);
AE_set_dataset_tool(newDatasetTag, tool);
AE_set_dataset_format2(newDatasetTag, name);
AOM_save(newDatasetTag);
AOM_unlock(newDatasetTag);
AOM_refresh(newDatasetTag, TRUE);
//ITEM_attach_rev_object2(rev, newDatasetTag, ITEM_specification_atth);
GRM_find_relation_type("IMAN_specification", &spec_relation); //关联变更件(变更相关附件)
GRM_create_relation(rev, newDatasetTag, spec_relation, NULLTAG,&relation);
GRM_save_relation(relation);
//添加命名的引用
import_dataset_file(newDatasetTag,ref_name,"txt", "C:\\Users\\Administrator\\Desktop\\新建文件夹\\2.txt", "命名的引用名字");
//tag_t new_file_tag = NULLTAG;
//IMF_file_t file_descriptor;
//char new_ds_name[WSO_name_size_c + 1] = "";
//char* new_file_name = USER_new_file_name(new_ds_name, ref_name, "txt", 0);//方法为数据集生成文件名。
//IMF_import_file("C:\\Users\\Administrator\\Desktop\\新建文件夹\\2.txt", new_file_name, SS_TEXT, &new_file_tag, &file_descriptor);
//AOM_lock(new_file_tag);
//IMF_set_original_file_name2(new_file_tag, "命名的引用名字");
//IMF_close_file(file_descriptor);
//AOM_save(new_file_tag);
//AOM_unlock(new_file_tag);
//AOM_refresh(new_file_tag, TRUE);
//AOM_lock(newDatasetTag);
//AE_add_dataset_named_ref2(newDatasetTag, ref_name, AE_PART_OF, new_file_tag);
//AE_save_myself(newDatasetTag);
//AOM_unlock(newDatasetTag);
//AOM_refresh(newDatasetTag, TRUE);
}
return ifail;
}

@ -0,0 +1,77 @@
#include"kutil.h"
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include "libxl.h"
#include <io.h>
#include <direct.h>
#include <cfm/cfm.h>
#include <wchar.h>
#include <locale>
#include <codecvt>
#include <chrono>
#include <Windows.h>
#include <thread>
#include <regex>
#include <res\reservation.h>
#include "libxl.h"
#include <map>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <filesystem>
using namespace libxl;
using namespace std::chrono_literals;
using namespace std;
#define debug true
#define ITK_err 919012
int UpgradeTask(EPM_action_message_t msg) {
printf("++++++++++++++++++开始提升流程节点++++++++++++++++++++\n");
POM_AM__set_application_bypass(true);
int ifail = ITK_ok, att_cnt = 0, i = 0, arg_cnt = 0;
tag_t task_tag = NULL_TAG, rootTask_tag = NULL_TAG;
task_tag = msg.task;
if (task_tag == NULLTAG)
{
return -1;
}
ITKCALL(EPM_ask_root_task(task_tag, &rootTask_tag));
char* uid;
ITK__convert_tag_to_uid(rootTask_tag, &uid);
printf("uid:%s\n", uid);
int allstartnum = 0; tag_t* allstart;
ITKCALL(AOM_ask_value_tags(rootTask_tag, "child_tasks", &allstartnum, &allstart));
for (int i = 0; i < allstartnum;i++) {
char* taskName;
ITKCALL(AOM_ask_value_string(allstart[i], "object_name", &taskName));
printf("子任务%d:%s\n",i,taskName);
}
char* taskname = NULL, * type = NULL;
ITKCALL(EPM_ask_name2(task_tag, &taskname));
ITKCALL(AOM_ask_value_string(task_tag, "object_type", &type));
printf("name=%s\n", taskname);
printf("type=%s\n", type);
if (strcmp(type, "EPMDoTask") == 0)
{
EPM_remove_task_hold(task_tag);
printf("开始提升节点\n");
ITKCALL(EPM_promote_task(task_tag, ""));
printf("提升节点结束\n");
}
DOFREE(taskname);
DOFREE(type);
POM_AM__set_application_bypass(false);
printf("++++++++++++++++++提升流程节点结束++++++++++++++++++++\n");
return ITK_ok;
}

@ -0,0 +1,223 @@
//#include "kutil.h"
//
////流程自动指派审批人
//int HS2_AutoAssign(EPM_action_message_t msg) {
//
// printf("===================================\n");
// printf("流程自动指派审批人 开始\n");
// printf("===================================\n");
// int ifail = ITK_ok;
// printf("开超级权限\n");
// POM_AM__set_application_bypass(true);
// int att_cnt = 0;
// tag_t task_tag = NULL_TAG,
// root_task_tag = NULLTAG,
// * attachments;
// char* argflag = NULL, * argvalue = NULL, * arg = NULL;
// int arg_cnt = 0;
// char task_name[1024] = "";
// vector<string> vec;
// char* message;
// //获取handler的参数的个数
// arg_cnt = TC_number_of_arguments(msg.arguments);
// ECHO("参数个数为:%d\n", arg_cnt);
//
// if (arg_cnt > 0)
// {
// for (int i = 0; i < arg_cnt; i++)
// {
// //获取下一个参数从0开始
// arg = TC_next_argument(msg.arguments);
// //获取参数的名称和值
// ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
// if (strcmp(argflag, "task") == 0)
// {
// if (argvalue != NULL)
// {
// strcpy(task_name, argvalue);
// }
// }
//
// }
// MEM_free(argflag);
// MEM_free(argvalue);
// }
// task_tag = msg.task;
// EPM_ask_root_task(task_tag, &root_task_tag);
// int cnt_task = 0; tag_t* tasks = NULLTAG;
// EPM_ask_sub_tasks(root_task_tag, &cnt_task, &tasks);
// //ITKCALL(EPM_ask_tasks(root_task_tag, EPM_started, &cnt_task, &tasks));
// EPM_ask_attachments(root_task_tag, EPM_target_attachment, &att_cnt, &attachments);
// if (att_cnt > 0) {
// for (int i = 0; i < att_cnt; i++)
// {
// tag_t rev_tag = attachments[i];
// char* tag_type;
// ITKCALL(AOM_ask_value_string(rev_tag, "object_type", &tag_type));
//
// if (strcmp("HS2_ChangeTaskRevision", tag_type) == 0) {
// int doc_num = 0;
// tag_t* doc_tags = NULL;
// tag_t* pathFile = NULLTAG;
// int Num = 0;
// char* excel_path;
// ITKCALL(AOM_ask_value_tags(rev_tag, "IMAN_specification", &doc_num, &doc_tags));
// char user[1024] = "\0";
// for (int j = 0; j < cnt_task; j++)
// {
// tag_t subtask = tasks[j];
// char* sub_task_object_type = NULL;
// char* sub_task_object_name = NULL;
// ITKCALL(AOM_ask_value_string(subtask, "object_name", &sub_task_object_name));
// cout << "名称--------" << sub_task_object_name << endl;
// ITKCALL(AOM_ask_value_string(subtask, "object_type", &sub_task_object_type));
// cout << "类型--------" << sub_task_object_type << endl;
// if (strcmp(task_name, sub_task_object_name) == 0)
// {
// cout << "bingo0" << endl;
// // ITKCALL( SA_find_user( "0120160006", &user_tag ));
// // ITKCALL( EPM_assign_responsible_party( task, user_tag));//设置编制节点的责任方
// tag_t tmp_select_signoff_task = NULLTAG;
// ITKCALL(EPM_ask_sub_task(subtask, EPM_select_signoff_team_task, &tmp_select_signoff_task));
// for (int k = 0; k < vec.size(); k++)
// {
// //构建器
// tag_t* results;
// const char query_name_product[1][QRY_name_size_c + 1] = { "管理 - 员工信息" };
// tag_t query_tag1 = NULLTAG;
// int entry_count1 = 0;
// char** entries1;
// char** values1;
// char* other_values1[1];
// char* other_entrys1[1];
// other_values1[0] = (char*)calloc(48, sizeof(char));
// other_entrys1[0] = (char*)calloc(48, sizeof(char));
// int num_found1 = 0;
// ITKCALL(QRY_find2(query_name_product[0], &query_tag1));
// if (query_tag1 == NULLTAG)
// {
// WriteLog("query_tag=NULLTAG,没找到 [%s]查询构建器!\n", query_name_product[0]);
// ITK_exit_module(1);
// return 0;
// }
// else
// {
// WriteLog("找到查询构建器\n");
// }
//
// ITKCALL(QRY_find_user_entries(query_tag1, &entry_count1, &entries1, &values1));//entries1查询条件表达式values1查询条件值MEM_free释放
// if (entry_count1 == 0)
// {
// WriteLog("entry_count1=0,查询构建器中没有配置查询条件!\n");
// //ITK_exit_module(1);
// if (entries1 != NULL) {
// MEM_free(entries1);
// entries1 = NULL;
// }
// if (values1 != NULL) {
// MEM_free(values1);
// values1 = NULL;
// }
// return 0;
// }
//
// //date_tag.second = p->tm_sec ;
//
// for (int n = 0; n < entry_count1; n++)
// {
// printf("entries1[%d]=%s\n", n, entries1[n]);
// if (tc_strcmp(entries1[n], "人员姓名") == 0) {
// //strcpy(values[n],nowtime1);
// tc_strcpy(other_entrys1[0], "人员姓名");
// tc_strcpy(other_values1[0], vec[k].c_str());//* 2012-05 NBJF16025 Test001 NBJF16046 16C104
// printf("other_values1[0] %s\n", other_values1[0]);
//
// }
//
// printf("values[%d]=%s\n", n, values1[n]);
//
// }
//
// ITKCALL(ifail = QRY_execute(query_tag1, 1, other_entrys1, other_values1, &num_found1, &results));
//
// if (ifail != ITK_ok) {
// EMH_ask_error_text(ifail, &message);
// WriteLog("程序异常 : \"%d\",\"%s\"\n", ifail, message);
// MEM_free(message);
// if (entries1 != NULL) {
// MEM_free(entries1);
// entries1 = NULL;
// }
// if (values1 != NULL) {
// MEM_free(values1);
// values1 = NULL;
// }
// return 0;
// }
// if (num_found1 == 0)
// {
// printf("num_found=0,查询构建器中没找到满足条件的数据!\n");
// //ITK_exit_module(1);
// if (entries1 != NULL) {
// MEM_free(entries1);
// entries1 = NULL;
// }
// if (values1 != NULL) {
// MEM_free(values1);
// values1 = NULL;
// }
// }
// //开始获取产品信息
// printf("查询构建器得到ITEM数num_found1: \"%d\" \n", num_found1);
//
// if (num_found1 != 0) {
// tag_t login_group = NULLTAG;
// printf("111\n");
// tag_t user = results[0];
// /* char* user_id;
// tag_t user_tag = NULLTAG;
// printf("222\n");
// int mem_cnt = 0;
// tag_t* members = NULL;*/
// int signoff_cnt = 0;
// tag_t* signoffs = NULL;
// /* ITKCALL(AOM_ask_value_string(user, "user_id", &user_id));
// printf("user_id=%s\n", user_id);
// ITKCALL(SA_find_user2(user_id, &user_tag));
// ITKCALL(SA_ask_user_login_group(user_tag, &login_group));
// printf("333\n");
// ITKCALL(SA_find_groupmembers(user_tag, login_group, &mem_cnt, &members));
// printf("mem_cnt=%d\n", mem_cnt);
// printf("444\n");
// ITKCALL(EPM_create_adhoc_signoff(tmp_select_signoff_task, members[0], &signoff_cnt, &signoffs));*/
// ITKCALL(EPM_create_adhoc_signoff(tmp_select_signoff_task, user, &signoff_cnt, &signoffs));
// printf("555\n");
// ITKCALL(EPM_set_adhoc_signoff_selection_done(tmp_select_signoff_task, true));
// printf("666\n");
// if (signoffs)
// {
// MEM_free(signoffs);
// signoffs = NULL;
// }
// }
//
// }
//
// // ITKCALL(EPM_trigger_action(tmp_select_signoff_task,EPM_complete_action, ""));
// break;
// }
// //}
// //}
// }
// }
// }
//
// }
//
// printf("关超级权限\n");
// POM_AM__set_application_bypass(false);
// printf("===================================\n");
// printf("流程自动指派审批人 结束\n");
// printf("===================================\n");
// return ifail;
//}

@ -0,0 +1,244 @@
#include "handler.h"
#define ARGS_LENGTH 200
#define MAX_PRINTLINE_LENGTH 2000
#define MAX_PATH_LENGTH 2000
#define MAX_ARGUMENT_LENGTH 400
#define MAX_PARAMNAME_LENGTH 50
#define MAX_FILE_EXT_LENGTH 10
#define TRUE_FLAG 1
#define FALSE_FLAG 0
#define DETAILLOG 1
#define DOFREE(obj) \
{ \
if(obj) \
{ \
MEM_free(obj); \
obj = NULL; \
} \
}
int delete_release_status(EPM_action_message_t msg) {
int ifail = ITK_ok, att_cnt = 0, rel_cnt = 0;
EPM_target_attachment;
tag_t task = NULLTAG, rootTask_tag = NULLTAG, *attchments = NULL, *releases = NULL, release_status = NULL;
ITKCALL(EPM_ask_root_task(msg.task, &rootTask_tag));
ITKCALL(EPM_ask_attachments(rootTask_tag, EPM_target_attachment, &att_cnt, &attchments));
POM_AM__set_application_bypass(true);
for (int i = 0; i < att_cnt; i++)
{
ITKCALL(AOM_ask_value_tags(attchments[i], "release_status_list", &rel_cnt, &releases));
for (int j = rel_cnt - 1; j > -1; j--)
{
EPM_remove_status_from_targets(releases[j], rootTask_tag);
}
}
POM_AM__set_application_bypass(false);
return ifail;
}
//发布对象
int set_release_status(tag_t item, char release_name[]) {
int ifail = ITK_ok;
tag_t release_status = NULL;
ITKCALL(ifail = RELSTAT_create_release_status(release_name, &release_status));
ITKCALL(ifail = RELSTAT_add_release_status(release_status, 1, &item, TRUE));
return ifail;
}
int reviseDesignPost(METHOD_message_t* msg, va_list va)
{
int ifail = ITK_ok, rev_cnt = 0;
tag_t new_rev = va_arg(va, tag_t);
tag_t item = NULLTAG;
tag_t *rev_list;
POM_AM__set_application_bypass(true);
printf("图纸升版后操作\n");
ITKCALL(ITEM_ask_item_of_rev(new_rev, &item));
ITKCALL(AOM_ask_value_tags(item, "revision_list", &rev_cnt, &rev_list));
if (rev_cnt > 1)
{
int wl_cnt = 0;
tag_t *wl_list;
tag_t pre_rev = rev_list[rev_cnt - 2],wlobj,newwlrev;
char * revtype,* wltype;
int wlcount = 0; tag_t *wltags;
ITKCALL(AOM_ask_value_string(pre_rev, "object_type", &revtype));
if (strcmp("LD6_2DdesignRevision", revtype)==0) {
printf("2D升版后操\n");
ITKCALL(AOM_ask_value_tags(pre_rev, "LD6_ProductInfo", &wlcount, &wltags));
for (int i = 0; i < wlcount;i++) {
ITKCALL(AOM_ask_value_string(wltags[i], "object_type", &wltype));
if (strcmp("LD6_ProductRevision", wltype)==0 || strcmp("LD6_MachinesPRevision", wltype) == 0) {
ITKCALL(ITEM_ask_item_of_rev(wltags[i], &wlobj));
if (wlobj!=NULL) {
int status = ITEM_ask_latest_rev(wlobj, &newwlrev);
if (status == ITK_ok)
{
printf("start 开始删除关系\n");
tag_t gx_gx_type = NULLTAG; tag_t gx_relation = NULLTAG;
ITKCALL(GRM_find_relation_type("LD6_ProductInfo", &gx_gx_type));
GRM_find_relation(new_rev, wltags[i], gx_gx_type, &gx_relation);
GRM_delete_relation(gx_relation);
printf("end 删除关系完毕\n");
printf("start 开始添加关系\n");
tag_t relation = NULLTAG;
ITKCALL(GRM_create_relation(new_rev, newwlrev, gx_gx_type, NULLTAG, &relation));
ITKCALL(GRM_save_relation(relation));
printf("end 添加关系完毕\n");
//ITKCALL(AOM_set_value_tag(new_rev, "LD6_ProductInfo",newwlrev));
}
}
}
}
}
else if (strcmp("LD6_MEProcessCrRevision", revtype) == 0 || strcmp("LD6_LSMEProcessRevision", revtype) == 0) {
printf("工艺路线升版后操\n");
ITKCALL(AOM_ask_value_tags(pre_rev, "IMAN_METarget", &wlcount, &wltags));
for (int i = 0; i < wlcount; i++) {
ITKCALL(AOM_ask_value_string(wltags[i], "object_type", &wltype));
if (strcmp("LD6_ProductRevision", wltype) == 0 || strcmp("LD6_MachinesPRevision", wltype) == 0) {
ITKCALL(ITEM_ask_item_of_rev(wltags[i], &wlobj));
if (wlobj != NULL) {
int status = ITEM_ask_latest_rev(wlobj, &newwlrev);
if (status == ITK_ok)
{
printf("start 开始删除关系\n");
tag_t gx_gx_type = NULLTAG; tag_t gx_relation = NULLTAG;
ITKCALL(GRM_find_relation_type("IMAN_METarget", &gx_gx_type));
GRM_find_relation(new_rev, wltags[i], gx_gx_type, &gx_relation);
GRM_delete_relation(gx_relation);
printf("end 删除关系完毕\n");
printf("start 开始添加关系\n");
tag_t relation = NULLTAG;
ITKCALL(GRM_create_relation(new_rev, newwlrev, gx_gx_type, NULLTAG, &relation));
ITKCALL(GRM_save_relation(relation));
printf("end 添加关系完毕\n");
//ITKCALL(AOM_set_value_tag(new_rev, "IMAN_METarget", newwlrev));
}
}
//修改属性
printf("开始修改属性\n");
char *getnum, *part;
ITKCALL(AOM_ask_value_string(newwlrev, "ld6_clientPartNum",&getnum));
ITKCALL(AOM_ask_value_string(newwlrev, "ld6_clientPartRev", &part));
AOM_lock(new_rev);
ITKCALL(AOM_set_value_string(new_rev, "ld6_clientPartNum", getnum));
ITKCALL(AOM_set_value_string(new_rev, "ld6_clientPartRev", part));
AOM_save(new_rev);
AOM_unlock(new_rev);
AOM_refresh(new_rev,true);
}
}
}
else if (strcmp("LD6_TecDOCRevision", revtype) == 0) {
printf("技术文档\n");
ITKCALL(AOM_ask_value_tags(pre_rev, "LD6_ProductInfo", &wlcount, &wltags));
for (int i = 0; i < wlcount; i++) {
ITKCALL(AOM_ask_value_string(wltags[i], "object_type", &wltype));
if (strcmp("LD6_ProductRevision", wltype) == 0 || strcmp("LD6_MachinesPRevision", wltype) == 0) {
ITKCALL(ITEM_ask_item_of_rev(wltags[i], &wlobj));
if (wlobj != NULL) {
int status = ITEM_ask_latest_rev(wlobj, &newwlrev);
if (status == ITK_ok)
{
printf("start 开始删除关系\n");
tag_t gx_gx_type = NULLTAG; tag_t gx_relation = NULLTAG;
ITKCALL(GRM_find_relation_type("LD6_ProductInfo", &gx_gx_type));
GRM_find_relation(new_rev, wltags[i], gx_gx_type, &gx_relation);
GRM_delete_relation(gx_relation);
printf("end 删除关系完毕\n");
printf("start 开始添加关系\n");
tag_t relation = NULLTAG;
ITKCALL(GRM_create_relation(new_rev, newwlrev, gx_gx_type, NULLTAG, &relation));
ITKCALL(GRM_save_relation(relation));
printf("end 添加关系完毕\n");
//ITKCALL(AOM_set_value_tag(new_rev, "LD6_ProductInfo", newwlrev));
}
}
}
}
}
else if (strcmp("LD6_3DdesignRevision", revtype)==0) {
ITKCALL(AOM_ask_value_tags(pre_rev, "representation_for", &wl_cnt, &wl_list));
map<string, tag_t> wl_map;
for (int i = 0; i < wl_cnt; i++)
{
char *wl_id;
ITKCALL(AOM_ask_value_string(wl_list[i], "item_id", &wl_id));
wl_map.find(wl_id);
if (wl_map.find(wl_id) == wl_map.end())
{
tag_t wl_item;
ITKCALL(ITEM_ask_item_of_rev(wl_list[i], &wl_item));
wl_map[wl_id] = wl_item;
}
}
list<tag_t> wl_add;
map<string, tag_t>::iterator it;
for (map<string, tag_t>::iterator it = wl_map.begin(); it != wl_map.end(); it++)
{
tag_t wl_item = it->second;
//int wl_rev_cnt = 0;
//tag_t *wl_rev_list;
tag_t wl_rev;
//ITKCALL(AOM_ask_value_tags(wl_item, "revision_list", &wl_rev_cnt, &wl_rev_list));
int status = ITEM_ask_latest_rev(wl_item, &wl_rev);
if (status == ITK_ok)
{
// 获取最新版本成功,可以使用 revision 变量进行后续操作
wl_add.push_back(wl_rev);
}
//if (wl_rev_cnt > 0)
//{
// wl_add.push_back(wl_rev_list[wl_rev_cnt - 1]);
//}
}
for (list<tag_t>::iterator it = wl_add.begin(); it != wl_add.end(); it++)
{
char *obj_str;
tag_t relation_type = NULLTAG, relation = NULLTAG;
ITKCALL(AOM_ask_value_string(*it, "object_string", &obj_str));
printf("object_string = %s\n", obj_str);
ITKCALL(AOM_lock(*it));
GRM_find_relation_type("TC_Is_Represented_By", &relation_type);
if (relation_type != NULLTAG)
{
GRM_create_relation(*it, new_rev, relation_type, NULLTAG, &relation);
GRM_save_relation(relation);
}
ITKCALL(AOM_save(*it));
ITKCALL(AOM_unlock(*it));
ITKCALL(AOM_refresh(*it, true));
}
/*int n = 0;
tag_t *value = (tag_t*)MEM_alloc(sizeof(tag_t)*(wl_add.size()));
for (list<tag_t>::iterator it = wl_add.begin(); it != wl_add.end(); it++)
{
char *obj_str;
ITKCALL(AOM_ask_value_string(*it, "object_string", &obj_str));
printf("object_string = %s\n", obj_str);
value[n] = *it;
n++;
}
ITKCALL(AOM_set_value_tags(new_rev, "representation_for", wl_add.size(), value));*/
}
}
POM_AM__set_application_bypass(false);
return ifail;
}

@ -0,0 +1,107 @@
#include "ado.h"
_ConnectionPtr m_pConnection;
_RecordsetPtr m_pRecordset;
HRESULT hr;
bool open(char* username, char* password, char* dbname, char* ip)
{
try
{
::CoInitialize(NULL); //初始化COM环境
m_pConnection.CreateInstance(__uuidof(Connection)); //创建连接对象
char connStr[200] = "";
sprintf(connStr, "Provider=SQLOLEDB;Data Source=%s;Initial Catalog=%s;", ip, dbname);
hr = m_pConnection->Open(connStr, username, password, -1);
if (hr != S_OK)
return true;
}
catch (_com_error e)
{
return true;
}
return false;
}
// 有输入参数的查询
int QuerySQL(char *SQL, int inputValueCount, int * outputColumn, int * outputValueCount, char **** outputValue)
{
Fields * fields = NULL;
long ColCount = 0;
*outputColumn = 0;
*outputValueCount = 0;
m_pRecordset.CreateInstance(__uuidof(Recordset));
m_pRecordset->Open(SQL, m_pConnection.GetInterfacePtr(), adOpenStatic, adLockOptimistic, adCmdText);
hr = m_pRecordset->get_Fields(&fields); //得到记录集的字段集和
if (SUCCEEDED(hr))
{
fields->get_Count(&ColCount);
*outputValueCount = (int)ColCount;
}
if (*outputValueCount == 0)
return 0;
int index = 0;
// 开始分配内存并且存储
*outputValue = (char ***)calloc((*outputValueCount) + 1, sizeof(char**));
while (!m_pRecordset->adoEOF)
{
(*outputValue)[index] = (char **)calloc((*outputColumn) + 1, sizeof(char *));
for (long i = 0; i < ColCount; i++)
{
BSTR bstrColName=NULL;
fields->Item[i]->get_Name(&bstrColName);
(*outputValue)[index][i] = (char *)calloc(1000, sizeof(char));
_variant_t taskStyle = NULL;
taskStyle = m_pRecordset->GetCollect(bstrColName);
const char* str;
_bstr_t bst_t = (_bstr_t)taskStyle;
str = (const char*)bst_t;
strcpy((*outputValue)[index][i], str);
}
m_pRecordset->MoveNext();///移到下一条记录
index++;
}
return 0;
}
// 执行查询
int QuerySQLNoInputParam(char *SQL, int * outputColumn, int * outputValueCount, char **** outputValue)
{
return QuerySQL(SQL, 0, outputColumn, outputValueCount, outputValue);
}
// 执行删除更新
int ExecuteSQLNoInputParam(char *SQL)
{
return ExecuteSQL(SQL, 0, NULL);
}
int ExecuteSQL(char *SQL, int valueCount, char **value)
{
try
{
m_pConnection->Execute(_bstr_t(SQL), 0, adCmdText);
}
catch (_com_error e)
{
printf("插入失败\n");
printf(e.Description());
return -1;
}
return 0;
}
void close(void)
{
if (m_pRecordset != NULL) {
//m_pRecordset->MoveFirst();
m_pRecordset->Close();
m_pConnection->Close();
}
::CoUninitialize(); //释放环境
}

@ -0,0 +1,35 @@
#import "C:/Program Files/Common Files/System/ado/msado15.dll" no_namespace rename("EOF", "adoEOF")
bool open(char* username, char* password, char* dbname, char* ip);
_RecordsetPtr& execute(_bstr_t SQL);
/**
* SQL.
* @param SQL - <I> SQL
* @param inputValueCount - <I>
* @param inputValue - <I>
* @param outputColumn - <O>
* @param outputValueCount - <O>
* @param outputValue - <O>
* @return - OCI_OK or error code
*
* ORACLE
*/
int QuerySQL(char *SQL, int inputValueCount, char ** inputValue, int * outputColumn, int * outputValueCount, char **** outputValue);
int QuerySQLNoInputParam(char *SQL, int * outputColumn, int * outputValueCount, char **** outputValue);
// 执行类操作
int ExecuteSQL(char *SQL, int valueCount, char **value);
/**
* SQL.
* @param SQL - <I> SQL
* @return - OCI_OK or error code
*
* ORACLE
*/
int ExecuteSQLNoInputParam(char *SQL);
/**
* .
*
* ORACLE
*/
void close();

@ -0,0 +1,19 @@
#ifndef JSON_AUTOLINK_H_INCLUDED
# define JSON_AUTOLINK_H_INCLUDED
# include "config.h"
# ifdef JSON_IN_CPPTL
# include <cpptl/cpptl_autolink.h>
# endif
# if !defined(JSON_NO_AUTOLINK) && !defined(JSON_DLL_BUILD) && !defined(JSON_IN_CPPTL)
# define CPPTL_AUTOLINK_NAME "json"
# undef CPPTL_AUTOLINK_DLL
# ifdef JSON_DLL
# define CPPTL_AUTOLINK_DLL
# endif
# include "autolink.h"
# endif
#endif // JSON_AUTOLINK_H_INCLUDED

@ -0,0 +1,43 @@
#ifndef JSON_CONFIG_H_INCLUDED
# define JSON_CONFIG_H_INCLUDED
/// If defined, indicates that json library is embedded in CppTL library.
//# define JSON_IN_CPPTL 1
/// If defined, indicates that json may leverage CppTL library
//# define JSON_USE_CPPTL 1
/// If defined, indicates that cpptl vector based map should be used instead of std::map
/// as Value container.
//# define JSON_USE_CPPTL_SMALLMAP 1
/// If defined, indicates that Json specific container should be used
/// (hash table & simple deque container with customizable allocator).
/// THIS FEATURE IS STILL EXPERIMENTAL!
//# define JSON_VALUE_USE_INTERNAL_MAP 1
/// Force usage of standard new/malloc based allocator instead of memory pool based allocator.
/// The memory pools allocator used optimization (initializing Value and ValueInternalLink
/// as if it was a POD) that may cause some validation tool to report errors.
/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined.
//# define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1
/// If defined, indicates that Json use exception to report invalid type manipulation
/// instead of C assert macro.
# define JSON_USE_EXCEPTION 1
# ifdef JSON_IN_CPPTL
# include <cpptl/config.h>
# ifndef JSON_USE_CPPTL
# define JSON_USE_CPPTL 1
# endif
# endif
# ifdef JSON_IN_CPPTL
# define JSON_API CPPTL_API
# elif defined(JSON_DLL_BUILD)
# define JSON_API __declspec(dllexport)
# elif defined(JSON_DLL)
# define JSON_API __declspec(dllimport)
# else
# define JSON_API
# endif
#endif // JSON_CONFIG_H_INCLUDED

@ -0,0 +1,212 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{87A8539F-972D-4E90-844B-DABEE71C1D40}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>connor_signature</RootNamespace>
<ProjectName>ld_itk_c</ProjectName>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CONNOR_SIGNATURE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CONNOR_SIGNATURE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CONNOR_SIGNATURE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CONNOR_SIGNATURE_EXPORTS;IPLIB=none;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>D:\include13\13\include;D:\include13\13\include_cpp;D:\dflittk\oci\include;D:\WorkEnvironment\tc13ITK\include;D:\WorkEnvironment\tc13ITK\include_cpp;D:\WorkEnvironment\tc13ITK\oci\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<MultiProcessorCompilation>false</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>D:\include13\13\lib\*.lib;D:\WorkEnvironment\tc13ITK\lib\*.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>libuser_exits.ar.lib</IgnoreSpecificDefaultLibraries>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="a.cpp" />
<ClCompile Include="addLb.cpp" />
<ClCompile Include="ado.cxx" />
<ClCompile Include="Connor_allow_Workflow.cpp" />
<ClCompile Include="Connor_Review_Person.cpp" />
<ClCompile Include="json_reader.cpp" />
<ClCompile Include="json_value.cpp" />
<ClCompile Include="json_writer.cpp" />
<ClCompile Include="Connor_ElevateTask.cpp" />
<ClCompile Include="LD_AutoAssign.cpp" />
<ClCompile Include="LD_ECN01_SetCICNFormProperty.cpp" />
<ClCompile Include="LD_CompletionDate.cpp" />
<ClCompile Include="LD_FormAttrToExcel.cpp" />
<ClCompile Include="LD_GYLXFrozen.cpp" />
<ClCompile Include="LD_PartChange.cpp" />
<ClCompile Include="LD_PartCompFLAG.cpp" />
<ClCompile Include="LD_SendDJJDD_To_MES.cpp" />
<ClCompile Include="LD_SendECRECN_ToSAPMES.cpp" />
<ClCompile Include="LD_TaskAssignmentDate.cpp" />
<ClCompile Include="ocilib.cpp" />
<ClCompile Include="raycus_itk.cpp" />
<ClCompile Include="kutil.cpp" />
<ClCompile Include="Send_Sap_Bom.cpp" />
<ClCompile Include="Send_Sap_material.cpp.cpp" />
<ClCompile Include="SH_PLM_Email.cpp" />
<ClCompile Include="TEST.cpp" />
<ClCompile Include="UpgradeTask.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="ado.h" />
<ClInclude Include="autolink.h" />
<ClInclude Include="config.h" />
<ClInclude Include="CRUL_server_call_httpserver2.h" />
<ClInclude Include="features.h" />
<ClInclude Include="forwards.h" />
<ClInclude Include="json.h" />
<ClInclude Include="json_batchallocator.h" />
<ClInclude Include="ocilib.h" />
<ClInclude Include="raycus_itk.h" />
<ClInclude Include="handler.h" />
<ClInclude Include="kutil.h" />
<ClInclude Include="reader.h" />
<ClInclude Include="value.h" />
<ClInclude Include="writer.h" />
</ItemGroup>
<ItemGroup>
<None Include="json_internalarray.inl" />
<None Include="json_internalmap.inl" />
<None Include="json_valueiterator.inl" />
<None Include="sconscript" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="json">
<UniqueIdentifier>{5a9d0713-46ed-4d01-9976-96843444adb3}</UniqueIdentifier>
</Filter>
<Filter Include="lib_json">
<UniqueIdentifier>{a3b918fb-f652-44f5-ade5-7d72f29a86e1}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="kutil.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="ado.cxx">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="json_reader.cpp">
<Filter>lib_json</Filter>
</ClCompile>
<ClCompile Include="json_value.cpp">
<Filter>lib_json</Filter>
</ClCompile>
<ClCompile Include="json_writer.cpp">
<Filter>lib_json</Filter>
</ClCompile>
<ClCompile Include="raycus_itk.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="Send_Sap_material.cpp.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="Send_Sap_Bom.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="TEST.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="ocilib.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="Connor_Review_Person.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="a.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="Connor_allow_Workflow.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="Connor_ElevateTask.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="LD_AutoAssign.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="addLb.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="LD_FormAttrToExcel.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="LD_PartCompFLAG.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="LD_PartChange.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="LD_SendDJJDD_To_MES.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="LD_ECN01_SetCICNFormProperty.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="UpgradeTask.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="LD_SendECRECN_ToSAPMES.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="LD_GYLXFrozen.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="SH_PLM_Email.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="LD_CompletionDate.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="LD_TaskAssignmentDate.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="handler.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="kutil.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="ado.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="autolink.h">
<Filter>json</Filter>
</ClInclude>
<ClInclude Include="config.h">
<Filter>json</Filter>
</ClInclude>
<ClInclude Include="features.h">
<Filter>json</Filter>
</ClInclude>
<ClInclude Include="forwards.h">
<Filter>json</Filter>
</ClInclude>
<ClInclude Include="json.h">
<Filter>json</Filter>
</ClInclude>
<ClInclude Include="reader.h">
<Filter>json</Filter>
</ClInclude>
<ClInclude Include="value.h">
<Filter>json</Filter>
</ClInclude>
<ClInclude Include="writer.h">
<Filter>json</Filter>
</ClInclude>
<ClInclude Include="json_batchallocator.h">
<Filter>lib_json</Filter>
</ClInclude>
<ClInclude Include="raycus_itk.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="CRUL_server_call_httpserver2.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="ocilib.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="json_internalarray.inl">
<Filter>lib_json</Filter>
</None>
<None Include="json_internalmap.inl">
<Filter>lib_json</Filter>
</None>
<None Include="json_valueiterator.inl">
<Filter>lib_json</Filter>
</None>
<None Include="sconscript">
<Filter>lib_json</Filter>
</None>
</ItemGroup>
</Project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ShowAllFiles>true</ShowAllFiles>
</PropertyGroup>
</Project>

@ -0,0 +1,42 @@
#ifndef CPPTL_JSON_FEATURES_H_INCLUDED
# define CPPTL_JSON_FEATURES_H_INCLUDED
# include "forwards.h"
namespace Json {
/** \brief Configuration passed to reader and writer.
* This configuration object can be used to force the Reader or Writer
* to behave in a standard conforming way.
*/
class JSON_API Features
{
public:
/** \brief A configuration that allows all features and assumes all strings are UTF-8.
* - C & C++ comments are allowed
* - Root object can be any JSON value
* - Assumes Value strings are encoded in UTF-8
*/
static Features all();
/** \brief A configuration that is strictly compatible with the JSON specification.
* - Comments are forbidden.
* - Root object must be either an array or an object value.
* - Assumes Value strings are encoded in UTF-8
*/
static Features strictMode();
/** \brief Initialize the configuration like JsonConfig::allFeatures;
*/
Features();
/// \c true if comments are allowed. Default: \c true.
bool allowComments_;
/// \c true if root must be either an array or an object value. Default: \c false.
bool strictRoot_;
};
} // namespace Json
#endif // CPPTL_JSON_FEATURES_H_INCLUDED

@ -0,0 +1,39 @@
#ifndef JSON_FORWARDS_H_INCLUDED
# define JSON_FORWARDS_H_INCLUDED
# include "config.h"
namespace Json {
// writer.h
class FastWriter;
class StyledWriter;
// reader.h
class Reader;
// features.h
class Features;
// value.h
typedef int Int;
typedef unsigned int UInt;
class StaticString;
class Path;
class PathArgument;
class Value;
class ValueIteratorBase;
class ValueIterator;
class ValueConstIterator;
#ifdef JSON_VALUE_USE_INTERNAL_MAP
class ValueAllocator;
class ValueMapAllocator;
class ValueInternalLink;
class ValueInternalArray;
class ValueInternalMap;
#endif // #ifdef JSON_VALUE_USE_INTERNAL_MAP
} // namespace Json
#endif // JSON_FORWARDS_H_INCLUDED

@ -0,0 +1,110 @@
#include "kutil.h"
#pragma once
#include <ae\dataset.h>
#include <bom\bom.h>
#include <epm\signoff.h>
#include <fclasses/tc_date.h>
#include <form/form.h>
#include <map>
#include <list>
#include <ict\ict_userservice.h>
#include <qry/qry.h>
#include <sa/sa.h>
#include <sa\person.h>
#include <sa\user.h>
#include <sa\group.h>
#include <sa\role.h>
#include <schmgt/schmgt_bridge_itk.h>
#include <set>
#include <string>
#include <string.h>
#include <tccore\item.h>
#include <tc\folder.h>
#include <tc/preferences.h>
#include <tc/tc_arguments.h>
#include <tc/tc_startup.h>
#include <tccore\aom.h>
#include <tccore\aom_prop.h>
#include <tccore\grm.h>
#include <tccore\grmtype.h>
#include <tccore/tctype.h>
#include <tccore/releasestatus.h>
#include <tccore/workspaceobject.h>
#include <tccore\item_msg.h>
#include <time.h>
#include <user_exits\user_exit_msg.h>
#include <vector>
#include <fstream>
#include <ae\ae.h>
#include "ocilib.h"
int ML_append_code(EPM_action_message_t msg);
int CONNOR_SIGN_MASTER(EPM_action_message_t msg);
int CONNOR_CLEAR_MASTER(EPM_action_message_t msg);
int CONNOR_REVISE_CLEAR_FORM(METHOD_message_t msg,va_list args);
int CONNOR_Signature_WORD(EPM_action_message_t msg);
int CONNOR_AVIC_CATIASIGN(EPM_action_message_t msg);
extern int K_add_release_status(void * return_data);
int CONNOR_SIGN_PRE_REVISION(EPM_action_message_t msg);
int QF8_WGJ_check(EPM_action_message_t msg);
int connor_set_prop_value(void *returnValue);
int ML_update_currentState(EPM_action_message_t msg);
int ML_WBS(EPM_action_message_t msg);
int ML_ProductCode(EPM_action_message_t msg);
int ML_nowtime(EPM_action_message_t msg);
int ML_sendToWeixin(EPM_action_message_t msg);
int ML_sendToPutinfo(EPM_action_message_t msg);
int ML_update_CChosenRevision(EPM_action_message_t msg);
int ML_sendByProposer(EPM_action_message_t msg);
int ML_sendChangeOrder(EPM_action_message_t msg);
int ML_createProjectForm(EPM_action_message_t msg);
int ML_handler266(EPM_action_message_t msg);
int ML_1106(EPM_action_message_t msg);
int ML_sendToQMS(EPM_action_message_t msg);
int ML_1128(EPM_action_message_t msg);
int ML_1207(EPM_action_message_t msg);
int ML_1214(EPM_action_message_t msg);
int ML_1215(EPM_action_message_t msg);
int ML_1216(EPM_action_message_t msg);
int ML_loginCheck(EPM_action_message_t msg);
int ML_1217(EPM_action_message_t msg);
int ML_checkState(EPM_action_message_t msg);
int ML_1227(EPM_action_message_t msg);
int ML_ItemRevPreUpdate(METHOD_message_t* msg, va_list args);
int ML_ChildGeneralIdentify(EPM_action_message_t msg);
int PLM_TO_OA(EPM_action_message_t msg);
int PLM_TO_SAP_NEW(EPM_action_message_t msg);
int PLM_TO_SAP_Revise(EPM_action_message_t msg);
int PLM_TO_SAP_Disuse(EPM_action_message_t msg);
int PLM_MBOM_TO_SAP_NEW(EPM_action_message_t msg);
int PLM_MBOM_TO_SAP_Revise(EPM_action_message_t msg);
int PLM_FBMBOM_TO_SAP(EPM_action_message_t msg);
int PLM_BZGX_TO_SAP(EPM_action_message_t msg);
int TEST(EPM_action_message_t msg);
int RK_getProjectData(void* returnValue);
int RK_getProjectAssignId(void* returnValue);
int RK_getProjectIdAndName(void* returnValue);
int Raycus_auto_TBYWL(EPM_action_message_t msg);
int RK_attach_assembly_components(EPM_action_message_t msg);
int RK_Assign_Inform(EPM_action_message_t msg);
int Connor_Review_Person(EPM_action_message_t msg);
int Connor_allow_Workflow(EPM_action_message_t msg);
int LD_FormAttrToExcel(EPM_action_message_t msg);
int LD_PartCompFLAG(EPM_action_message_t msg);
int LD_SendDJJDD_To_MES(EPM_action_message_t msg);
int UpgradeTask(EPM_action_message_t msg);
int LD_PartChange(EPM_action_message_t msg);
int ML_ItemRevSave(METHOD_message_t* msg, va_list args);
int LD_ElevateTask(EPM_action_message_t msg);
int LD_AutoAssign(EPM_action_message_t msg);
int reviseDesignPost(METHOD_message_t* msg, va_list va);
int uploadFile(void* returnValue);
int LD_ECN01_SetCICNFormProperty(EPM_action_message_t msg);
int LD_515_SetCICNFormProperty(EPM_action_message_t msg);
int LD_SendECRECN_ToSAPMES(EPM_action_message_t msg);
int LD_GYLXFrozen(EPM_action_message_t msg);
int LD_CompletionDate(EPM_action_message_t msg);
int LD_TaskAssignmentDate(EPM_action_message_t msg);
int SH_PLM_Email(EPM_action_message_t msg);
//int LD6_CusProdFolderSave(METHOD_message_t* msg, va_list args);

@ -0,0 +1,10 @@
#ifndef JSON_JSON_H_INCLUDED
# define JSON_JSON_H_INCLUDED
# include "autolink.h"
# include "value.h"
# include "reader.h"
# include "writer.h"
# include "features.h"
#endif // JSON_JSON_H_INCLUDED

@ -0,0 +1,125 @@
#ifndef JSONCPP_BATCHALLOCATOR_H_INCLUDED
# define JSONCPP_BATCHALLOCATOR_H_INCLUDED
# include <stdlib.h>
# include <assert.h>
# ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
namespace Json {
/* Fast memory allocator.
*
* This memory allocator allocates memory for a batch of object (specified by
* the page size, the number of object in each page).
*
* It does not allow the destruction of a single object. All the allocated objects
* can be destroyed at once. The memory can be either released or reused for future
* allocation.
*
* The in-place new operator must be used to construct the object using the pointer
* returned by allocate.
*/
template<typename AllocatedType
,const unsigned int objectPerAllocation>
class BatchAllocator
{
public:
typedef AllocatedType Type;
BatchAllocator( unsigned int objectsPerPage = 255 )
: freeHead_( 0 )
, objectsPerPage_( objectsPerPage )
{
// printf( "Size: %d => %s\n", sizeof(AllocatedType), typeid(AllocatedType).name() );
assert( sizeof(AllocatedType) * objectPerAllocation >= sizeof(AllocatedType *) ); // We must be able to store a slist in the object free space.
assert( objectsPerPage >= 16 );
batches_ = allocateBatch( 0 ); // allocated a dummy page
currentBatch_ = batches_;
}
~BatchAllocator()
{
for ( BatchInfo *batch = batches_; batch; )
{
BatchInfo *nextBatch = batch->next_;
free( batch );
batch = nextBatch;
}
}
/// allocate space for an array of objectPerAllocation object.
/// @warning it is the responsability of the caller to call objects constructors.
AllocatedType *allocate()
{
if ( freeHead_ ) // returns node from free list.
{
AllocatedType *object = freeHead_;
freeHead_ = *(AllocatedType **)object;
return object;
}
if ( currentBatch_->used_ == currentBatch_->end_ )
{
currentBatch_ = currentBatch_->next_;
while ( currentBatch_ && currentBatch_->used_ == currentBatch_->end_ )
currentBatch_ = currentBatch_->next_;
if ( !currentBatch_ ) // no free batch found, allocate a new one
{
currentBatch_ = allocateBatch( objectsPerPage_ );
currentBatch_->next_ = batches_; // insert at the head of the list
batches_ = currentBatch_;
}
}
AllocatedType *allocated = currentBatch_->used_;
currentBatch_->used_ += objectPerAllocation;
return allocated;
}
/// Release the object.
/// @warning it is the responsability of the caller to actually destruct the object.
void release( AllocatedType *object )
{
assert( object != 0 );
*(AllocatedType **)object = freeHead_;
freeHead_ = object;
}
private:
struct BatchInfo
{
BatchInfo *next_;
AllocatedType *used_;
AllocatedType *end_;
AllocatedType buffer_[objectPerAllocation];
};
// disabled copy constructor and assignement operator.
BatchAllocator( const BatchAllocator & );
void operator =( const BatchAllocator &);
static BatchInfo *allocateBatch( unsigned int objectsPerPage )
{
const unsigned int mallocSize = sizeof(BatchInfo) - sizeof(AllocatedType)* objectPerAllocation
+ sizeof(AllocatedType) * objectPerAllocation * objectsPerPage;
BatchInfo *batch = static_cast<BatchInfo*>( malloc( mallocSize ) );
batch->next_ = 0;
batch->used_ = batch->buffer_;
batch->end_ = batch->buffer_ + objectsPerPage;
return batch;
}
BatchInfo *batches_;
BatchInfo *currentBatch_;
/// Head of a single linked list within the allocated space of freeed object
AllocatedType *freeHead_;
unsigned int objectsPerPage_;
};
} // namespace Json
# endif // ifndef JSONCPP_DOC_INCLUDE_IMPLEMENTATION
#endif // JSONCPP_BATCHALLOCATOR_H_INCLUDED

@ -0,0 +1,448 @@
// included by json_value.cpp
// everything is within Json namespace
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// class ValueInternalArray
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
ValueArrayAllocator::~ValueArrayAllocator()
{
}
// //////////////////////////////////////////////////////////////////
// class DefaultValueArrayAllocator
// //////////////////////////////////////////////////////////////////
#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
class DefaultValueArrayAllocator : public ValueArrayAllocator
{
public: // overridden from ValueArrayAllocator
virtual ~DefaultValueArrayAllocator()
{
}
virtual ValueInternalArray *newArray()
{
return new ValueInternalArray();
}
virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )
{
return new ValueInternalArray( other );
}
virtual void destructArray( ValueInternalArray *array )
{
delete array;
}
virtual void reallocateArrayPageIndex( Value **&indexes,
ValueInternalArray::PageIndex &indexCount,
ValueInternalArray::PageIndex minNewIndexCount )
{
ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;
if ( minNewIndexCount > newIndexCount )
newIndexCount = minNewIndexCount;
void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );
if ( !newIndexes )
throw std::bad_alloc();
indexCount = newIndexCount;
indexes = static_cast<Value **>( newIndexes );
}
virtual void releaseArrayPageIndex( Value **indexes,
ValueInternalArray::PageIndex indexCount )
{
if ( indexes )
free( indexes );
}
virtual Value *allocateArrayPage()
{
return static_cast<Value *>( malloc( sizeof(Value) * ValueInternalArray::itemsPerPage ) );
}
virtual void releaseArrayPage( Value *value )
{
if ( value )
free( value );
}
};
#else // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
/// @todo make this thread-safe (lock when accessign batch allocator)
class DefaultValueArrayAllocator : public ValueArrayAllocator
{
public: // overridden from ValueArrayAllocator
virtual ~DefaultValueArrayAllocator()
{
}
virtual ValueInternalArray *newArray()
{
ValueInternalArray *array = arraysAllocator_.allocate();
new (array) ValueInternalArray(); // placement new
return array;
}
virtual ValueInternalArray *newArrayCopy( const ValueInternalArray &other )
{
ValueInternalArray *array = arraysAllocator_.allocate();
new (array) ValueInternalArray( other ); // placement new
return array;
}
virtual void destructArray( ValueInternalArray *array )
{
if ( array )
{
array->~ValueInternalArray();
arraysAllocator_.release( array );
}
}
virtual void reallocateArrayPageIndex( Value **&indexes,
ValueInternalArray::PageIndex &indexCount,
ValueInternalArray::PageIndex minNewIndexCount )
{
ValueInternalArray::PageIndex newIndexCount = (indexCount*3)/2 + 1;
if ( minNewIndexCount > newIndexCount )
newIndexCount = minNewIndexCount;
void *newIndexes = realloc( indexes, sizeof(Value*) * newIndexCount );
if ( !newIndexes )
throw std::bad_alloc();
indexCount = newIndexCount;
indexes = static_cast<Value **>( newIndexes );
}
virtual void releaseArrayPageIndex( Value **indexes,
ValueInternalArray::PageIndex indexCount )
{
if ( indexes )
free( indexes );
}
virtual Value *allocateArrayPage()
{
return static_cast<Value *>( pagesAllocator_.allocate() );
}
virtual void releaseArrayPage( Value *value )
{
if ( value )
pagesAllocator_.release( value );
}
private:
BatchAllocator<ValueInternalArray,1> arraysAllocator_;
BatchAllocator<Value,ValueInternalArray::itemsPerPage> pagesAllocator_;
};
#endif // #ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
static ValueArrayAllocator *&arrayAllocator()
{
static DefaultValueArrayAllocator defaultAllocator;
static ValueArrayAllocator *arrayAllocator = &defaultAllocator;
return arrayAllocator;
}
static struct DummyArrayAllocatorInitializer {
DummyArrayAllocatorInitializer()
{
arrayAllocator(); // ensure arrayAllocator() statics are initialized before main().
}
} dummyArrayAllocatorInitializer;
// //////////////////////////////////////////////////////////////////
// class ValueInternalArray
// //////////////////////////////////////////////////////////////////
bool
ValueInternalArray::equals( const IteratorState &x,
const IteratorState &other )
{
return x.array_ == other.array_
&& x.currentItemIndex_ == other.currentItemIndex_
&& x.currentPageIndex_ == other.currentPageIndex_;
}
void
ValueInternalArray::increment( IteratorState &it )
{
JSON_ASSERT_MESSAGE( it.array_ &&
(it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_
!= it.array_->size_,
"ValueInternalArray::increment(): moving iterator beyond end" );
++(it.currentItemIndex_);
if ( it.currentItemIndex_ == itemsPerPage )
{
it.currentItemIndex_ = 0;
++(it.currentPageIndex_);
}
}
void
ValueInternalArray::decrement( IteratorState &it )
{
JSON_ASSERT_MESSAGE( it.array_ && it.currentPageIndex_ == it.array_->pages_
&& it.currentItemIndex_ == 0,
"ValueInternalArray::decrement(): moving iterator beyond end" );
if ( it.currentItemIndex_ == 0 )
{
it.currentItemIndex_ = itemsPerPage-1;
--(it.currentPageIndex_);
}
else
{
--(it.currentItemIndex_);
}
}
Value &
ValueInternalArray::unsafeDereference( const IteratorState &it )
{
return (*(it.currentPageIndex_))[it.currentItemIndex_];
}
Value &
ValueInternalArray::dereference( const IteratorState &it )
{
JSON_ASSERT_MESSAGE( it.array_ &&
(it.currentPageIndex_ - it.array_->pages_)*itemsPerPage + it.currentItemIndex_
< it.array_->size_,
"ValueInternalArray::dereference(): dereferencing invalid iterator" );
return unsafeDereference( it );
}
void
ValueInternalArray::makeBeginIterator( IteratorState &it ) const
{
it.array_ = const_cast<ValueInternalArray *>( this );
it.currentItemIndex_ = 0;
it.currentPageIndex_ = pages_;
}
void
ValueInternalArray::makeIterator( IteratorState &it, ArrayIndex index ) const
{
it.array_ = const_cast<ValueInternalArray *>( this );
it.currentItemIndex_ = index % itemsPerPage;
it.currentPageIndex_ = pages_ + index / itemsPerPage;
}
void
ValueInternalArray::makeEndIterator( IteratorState &it ) const
{
makeIterator( it, size_ );
}
ValueInternalArray::ValueInternalArray()
: pages_( 0 )
, size_( 0 )
, pageCount_( 0 )
{
}
ValueInternalArray::ValueInternalArray( const ValueInternalArray &other )
: pages_( 0 )
, pageCount_( 0 )
, size_( other.size_ )
{
PageIndex minNewPages = other.size_ / itemsPerPage;
arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages );
JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages,
"ValueInternalArray::reserve(): bad reallocation" );
IteratorState itOther;
other.makeBeginIterator( itOther );
Value *value;
for ( ArrayIndex index = 0; index < size_; ++index, increment(itOther) )
{
if ( index % itemsPerPage == 0 )
{
PageIndex pageIndex = index / itemsPerPage;
value = arrayAllocator()->allocateArrayPage();
pages_[pageIndex] = value;
}
new (value) Value( dereference( itOther ) );
}
}
ValueInternalArray &
ValueInternalArray::operator =( const ValueInternalArray &other )
{
ValueInternalArray temp( other );
swap( temp );
return *this;
}
ValueInternalArray::~ValueInternalArray()
{
// destroy all constructed items
IteratorState it;
IteratorState itEnd;
makeBeginIterator( it);
makeEndIterator( itEnd );
for ( ; !equals(it,itEnd); increment(it) )
{
Value *value = &dereference(it);
value->~Value();
}
// release all pages
PageIndex lastPageIndex = size_ / itemsPerPage;
for ( PageIndex pageIndex = 0; pageIndex < lastPageIndex; ++pageIndex )
arrayAllocator()->releaseArrayPage( pages_[pageIndex] );
// release pages index
arrayAllocator()->releaseArrayPageIndex( pages_, pageCount_ );
}
void
ValueInternalArray::swap( ValueInternalArray &other )
{
Value **tempPages = pages_;
pages_ = other.pages_;
other.pages_ = tempPages;
ArrayIndex tempSize = size_;
size_ = other.size_;
other.size_ = tempSize;
PageIndex tempPageCount = pageCount_;
pageCount_ = other.pageCount_;
other.pageCount_ = tempPageCount;
}
void
ValueInternalArray::clear()
{
ValueInternalArray dummy;
swap( dummy );
}
void
ValueInternalArray::resize( ArrayIndex newSize )
{
if ( newSize == 0 )
clear();
else if ( newSize < size_ )
{
IteratorState it;
IteratorState itEnd;
makeIterator( it, newSize );
makeIterator( itEnd, size_ );
for ( ; !equals(it,itEnd); increment(it) )
{
Value *value = &dereference(it);
value->~Value();
}
PageIndex pageIndex = (newSize + itemsPerPage - 1) / itemsPerPage;
PageIndex lastPageIndex = size_ / itemsPerPage;
for ( ; pageIndex < lastPageIndex; ++pageIndex )
arrayAllocator()->releaseArrayPage( pages_[pageIndex] );
size_ = newSize;
}
else if ( newSize > size_ )
resolveReference( newSize );
}
void
ValueInternalArray::makeIndexValid( ArrayIndex index )
{
// Need to enlarge page index ?
if ( index >= pageCount_ * itemsPerPage )
{
PageIndex minNewPages = (index + 1) / itemsPerPage;
arrayAllocator()->reallocateArrayPageIndex( pages_, pageCount_, minNewPages );
JSON_ASSERT_MESSAGE( pageCount_ >= minNewPages, "ValueInternalArray::reserve(): bad reallocation" );
}
// Need to allocate new pages ?
ArrayIndex nextPageIndex =
(size_ % itemsPerPage) != 0 ? size_ - (size_%itemsPerPage) + itemsPerPage
: size_;
if ( nextPageIndex <= index )
{
PageIndex pageIndex = nextPageIndex / itemsPerPage;
PageIndex pageToAllocate = (index - nextPageIndex) / itemsPerPage + 1;
for ( ; pageToAllocate-- > 0; ++pageIndex )
pages_[pageIndex] = arrayAllocator()->allocateArrayPage();
}
// Initialize all new entries
IteratorState it;
IteratorState itEnd;
makeIterator( it, size_ );
size_ = index + 1;
makeIterator( itEnd, size_ );
for ( ; !equals(it,itEnd); increment(it) )
{
Value *value = &dereference(it);
new (value) Value(); // Construct a default value using placement new
}
}
Value &
ValueInternalArray::resolveReference( ArrayIndex index )
{
if ( index >= size_ )
makeIndexValid( index );
return pages_[index/itemsPerPage][index%itemsPerPage];
}
Value *
ValueInternalArray::find( ArrayIndex index ) const
{
if ( index >= size_ )
return 0;
return &(pages_[index/itemsPerPage][index%itemsPerPage]);
}
ValueInternalArray::ArrayIndex
ValueInternalArray::size() const
{
return size_;
}
int
ValueInternalArray::distance( const IteratorState &x, const IteratorState &y )
{
return indexOf(y) - indexOf(x);
}
ValueInternalArray::ArrayIndex
ValueInternalArray::indexOf( const IteratorState &iterator )
{
if ( !iterator.array_ )
return ArrayIndex(-1);
return ArrayIndex(
(iterator.currentPageIndex_ - iterator.array_->pages_) * itemsPerPage
+ iterator.currentItemIndex_ );
}
int
ValueInternalArray::compare( const ValueInternalArray &other ) const
{
int sizeDiff( size_ - other.size_ );
if ( sizeDiff != 0 )
return sizeDiff;
for ( ArrayIndex index =0; index < size_; ++index )
{
int diff = pages_[index/itemsPerPage][index%itemsPerPage].compare(
other.pages_[index/itemsPerPage][index%itemsPerPage] );
if ( diff != 0 )
return diff;
}
return 0;
}

@ -0,0 +1,607 @@
// included by json_value.cpp
// everything is within Json namespace
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// class ValueInternalMap
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
/** \internal MUST be safely initialized using memset( this, 0, sizeof(ValueInternalLink) );
* This optimization is used by the fast allocator.
*/
ValueInternalLink::ValueInternalLink()
: previous_( 0 )
, next_( 0 )
{
}
ValueInternalLink::~ValueInternalLink()
{
for ( int index =0; index < itemPerLink; ++index )
{
if ( !items_[index].isItemAvailable() )
{
if ( !items_[index].isMemberNameStatic() )
free( keys_[index] );
}
else
break;
}
}
ValueMapAllocator::~ValueMapAllocator()
{
}
#ifdef JSON_USE_SIMPLE_INTERNAL_ALLOCATOR
class DefaultValueMapAllocator : public ValueMapAllocator
{
public: // overridden from ValueMapAllocator
virtual ValueInternalMap *newMap()
{
return new ValueInternalMap();
}
virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )
{
return new ValueInternalMap( other );
}
virtual void destructMap( ValueInternalMap *map )
{
delete map;
}
virtual ValueInternalLink *allocateMapBuckets( unsigned int size )
{
return new ValueInternalLink[size];
}
virtual void releaseMapBuckets( ValueInternalLink *links )
{
delete [] links;
}
virtual ValueInternalLink *allocateMapLink()
{
return new ValueInternalLink();
}
virtual void releaseMapLink( ValueInternalLink *link )
{
delete link;
}
};
#else
/// @todo make this thread-safe (lock when accessign batch allocator)
class DefaultValueMapAllocator : public ValueMapAllocator
{
public: // overridden from ValueMapAllocator
virtual ValueInternalMap *newMap()
{
ValueInternalMap *map = mapsAllocator_.allocate();
new (map) ValueInternalMap(); // placement new
return map;
}
virtual ValueInternalMap *newMapCopy( const ValueInternalMap &other )
{
ValueInternalMap *map = mapsAllocator_.allocate();
new (map) ValueInternalMap( other ); // placement new
return map;
}
virtual void destructMap( ValueInternalMap *map )
{
if ( map )
{
map->~ValueInternalMap();
mapsAllocator_.release( map );
}
}
virtual ValueInternalLink *allocateMapBuckets( unsigned int size )
{
return new ValueInternalLink[size];
}
virtual void releaseMapBuckets( ValueInternalLink *links )
{
delete [] links;
}
virtual ValueInternalLink *allocateMapLink()
{
ValueInternalLink *link = linksAllocator_.allocate();
memset( link, 0, sizeof(ValueInternalLink) );
return link;
}
virtual void releaseMapLink( ValueInternalLink *link )
{
link->~ValueInternalLink();
linksAllocator_.release( link );
}
private:
BatchAllocator<ValueInternalMap,1> mapsAllocator_;
BatchAllocator<ValueInternalLink,1> linksAllocator_;
};
#endif
static ValueMapAllocator *&mapAllocator()
{
static DefaultValueMapAllocator defaultAllocator;
static ValueMapAllocator *mapAllocator = &defaultAllocator;
return mapAllocator;
}
static struct DummyMapAllocatorInitializer {
DummyMapAllocatorInitializer()
{
mapAllocator(); // ensure mapAllocator() statics are initialized before main().
}
} dummyMapAllocatorInitializer;
// h(K) = value * K >> w ; with w = 32 & K prime w.r.t. 2^32.
/*
use linked list hash map.
buckets array is a container.
linked list element contains 6 key/values. (memory = (16+4) * 6 + 4 = 124)
value have extra state: valid, available, deleted
*/
ValueInternalMap::ValueInternalMap()
: buckets_( 0 )
, tailLink_( 0 )
, bucketsSize_( 0 )
, itemCount_( 0 )
{
}
ValueInternalMap::ValueInternalMap( const ValueInternalMap &other )
: buckets_( 0 )
, tailLink_( 0 )
, bucketsSize_( 0 )
, itemCount_( 0 )
{
reserve( other.itemCount_ );
IteratorState it;
IteratorState itEnd;
other.makeBeginIterator( it );
other.makeEndIterator( itEnd );
for ( ; !equals(it,itEnd); increment(it) )
{
bool isStatic;
const char *memberName = key( it, isStatic );
const Value &aValue = value( it );
resolveReference(memberName, isStatic) = aValue;
}
}
ValueInternalMap &
ValueInternalMap::operator =( const ValueInternalMap &other )
{
ValueInternalMap dummy( other );
swap( dummy );
return *this;
}
ValueInternalMap::~ValueInternalMap()
{
if ( buckets_ )
{
for ( BucketIndex bucketIndex =0; bucketIndex < bucketsSize_; ++bucketIndex )
{
ValueInternalLink *link = buckets_[bucketIndex].next_;
while ( link )
{
ValueInternalLink *linkToRelease = link;
link = link->next_;
mapAllocator()->releaseMapLink( linkToRelease );
}
}
mapAllocator()->releaseMapBuckets( buckets_ );
}
}
void
ValueInternalMap::swap( ValueInternalMap &other )
{
ValueInternalLink *tempBuckets = buckets_;
buckets_ = other.buckets_;
other.buckets_ = tempBuckets;
ValueInternalLink *tempTailLink = tailLink_;
tailLink_ = other.tailLink_;
other.tailLink_ = tempTailLink;
BucketIndex tempBucketsSize = bucketsSize_;
bucketsSize_ = other.bucketsSize_;
other.bucketsSize_ = tempBucketsSize;
BucketIndex tempItemCount = itemCount_;
itemCount_ = other.itemCount_;
other.itemCount_ = tempItemCount;
}
void
ValueInternalMap::clear()
{
ValueInternalMap dummy;
swap( dummy );
}
ValueInternalMap::BucketIndex
ValueInternalMap::size() const
{
return itemCount_;
}
bool
ValueInternalMap::reserveDelta( BucketIndex growth )
{
return reserve( itemCount_ + growth );
}
bool
ValueInternalMap::reserve( BucketIndex newItemCount )
{
if ( !buckets_ && newItemCount > 0 )
{
buckets_ = mapAllocator()->allocateMapBuckets( 1 );
bucketsSize_ = 1;
tailLink_ = &buckets_[0];
}
// BucketIndex idealBucketCount = (newItemCount + ValueInternalLink::itemPerLink) / ValueInternalLink::itemPerLink;
return true;
}
const Value *
ValueInternalMap::find( const char *key ) const
{
if ( !bucketsSize_ )
return 0;
HashKey hashedKey = hash( key );
BucketIndex bucketIndex = hashedKey % bucketsSize_;
for ( const ValueInternalLink *current = &buckets_[bucketIndex];
current != 0;
current = current->next_ )
{
for ( BucketIndex index=0; index < ValueInternalLink::itemPerLink; ++index )
{
if ( current->items_[index].isItemAvailable() )
return 0;
if ( strcmp( key, current->keys_[index] ) == 0 )
return &current->items_[index];
}
}
return 0;
}
Value *
ValueInternalMap::find( const char *key )
{
const ValueInternalMap *constThis = this;
return const_cast<Value *>( constThis->find( key ) );
}
Value &
ValueInternalMap::resolveReference( const char *key,
bool isStatic )
{
HashKey hashedKey = hash( key );
if ( bucketsSize_ )
{
BucketIndex bucketIndex = hashedKey % bucketsSize_;
ValueInternalLink **previous = 0;
BucketIndex index;
for ( ValueInternalLink *current = &buckets_[bucketIndex];
current != 0;
previous = &current->next_, current = current->next_ )
{
for ( index=0; index < ValueInternalLink::itemPerLink; ++index )
{
if ( current->items_[index].isItemAvailable() )
return setNewItem( key, isStatic, current, index );
if ( strcmp( key, current->keys_[index] ) == 0 )
return current->items_[index];
}
}
}
reserveDelta( 1 );
return unsafeAdd( key, isStatic, hashedKey );
}
void
ValueInternalMap::remove( const char *key )
{
HashKey hashedKey = hash( key );
if ( !bucketsSize_ )
return;
BucketIndex bucketIndex = hashedKey % bucketsSize_;
for ( ValueInternalLink *link = &buckets_[bucketIndex];
link != 0;
link = link->next_ )
{
BucketIndex index;
for ( index =0; index < ValueInternalLink::itemPerLink; ++index )
{
if ( link->items_[index].isItemAvailable() )
return;
if ( strcmp( key, link->keys_[index] ) == 0 )
{
doActualRemove( link, index, bucketIndex );
return;
}
}
}
}
void
ValueInternalMap::doActualRemove( ValueInternalLink *link,
BucketIndex index,
BucketIndex bucketIndex )
{
// find last item of the bucket and swap it with the 'removed' one.
// set removed items flags to 'available'.
// if last page only contains 'available' items, then desallocate it (it's empty)
ValueInternalLink *&lastLink = getLastLinkInBucket( index );
BucketIndex lastItemIndex = 1; // a link can never be empty, so start at 1
for ( ;
lastItemIndex < ValueInternalLink::itemPerLink;
++lastItemIndex ) // may be optimized with dicotomic search
{
if ( lastLink->items_[lastItemIndex].isItemAvailable() )
break;
}
BucketIndex lastUsedIndex = lastItemIndex - 1;
Value *valueToDelete = &link->items_[index];
Value *valueToPreserve = &lastLink->items_[lastUsedIndex];
if ( valueToDelete != valueToPreserve )
valueToDelete->swap( *valueToPreserve );
if ( lastUsedIndex == 0 ) // page is now empty
{ // remove it from bucket linked list and delete it.
ValueInternalLink *linkPreviousToLast = lastLink->previous_;
if ( linkPreviousToLast != 0 ) // can not deleted bucket link.
{
mapAllocator()->releaseMapLink( lastLink );
linkPreviousToLast->next_ = 0;
lastLink = linkPreviousToLast;
}
}
else
{
Value dummy;
valueToPreserve->swap( dummy ); // restore deleted to default Value.
valueToPreserve->setItemUsed( false );
}
--itemCount_;
}
ValueInternalLink *&
ValueInternalMap::getLastLinkInBucket( BucketIndex bucketIndex )
{
if ( bucketIndex == bucketsSize_ - 1 )
return tailLink_;
ValueInternalLink *&previous = buckets_[bucketIndex+1].previous_;
if ( !previous )
previous = &buckets_[bucketIndex];
return previous;
}
Value &
ValueInternalMap::setNewItem( const char *key,
bool isStatic,
ValueInternalLink *link,
BucketIndex index )
{
char *duplicatedKey = valueAllocator()->makeMemberName( key );
++itemCount_;
link->keys_[index] = duplicatedKey;
link->items_[index].setItemUsed();
link->items_[index].setMemberNameIsStatic( isStatic );
return link->items_[index]; // items already default constructed.
}
Value &
ValueInternalMap::unsafeAdd( const char *key,
bool isStatic,
HashKey hashedKey )
{
JSON_ASSERT_MESSAGE( bucketsSize_ > 0, "ValueInternalMap::unsafeAdd(): internal logic error." );
BucketIndex bucketIndex = hashedKey % bucketsSize_;
ValueInternalLink *&previousLink = getLastLinkInBucket( bucketIndex );
ValueInternalLink *link = previousLink;
BucketIndex index;
for ( index =0; index < ValueInternalLink::itemPerLink; ++index )
{
if ( link->items_[index].isItemAvailable() )
break;
}
if ( index == ValueInternalLink::itemPerLink ) // need to add a new page
{
ValueInternalLink *newLink = mapAllocator()->allocateMapLink();
index = 0;
link->next_ = newLink;
previousLink = newLink;
link = newLink;
}
return setNewItem( key, isStatic, link, index );
}
ValueInternalMap::HashKey
ValueInternalMap::hash( const char *key ) const
{
HashKey hash = 0;
while ( *key )
hash += *key++ * 37;
return hash;
}
int
ValueInternalMap::compare( const ValueInternalMap &other ) const
{
int sizeDiff( itemCount_ - other.itemCount_ );
if ( sizeDiff != 0 )
return sizeDiff;
// Strict order guaranty is required. Compare all keys FIRST, then compare values.
IteratorState it;
IteratorState itEnd;
makeBeginIterator( it );
makeEndIterator( itEnd );
for ( ; !equals(it,itEnd); increment(it) )
{
if ( !other.find( key( it ) ) )
return 1;
}
// All keys are equals, let's compare values
makeBeginIterator( it );
for ( ; !equals(it,itEnd); increment(it) )
{
const Value *otherValue = other.find( key( it ) );
int valueDiff = value(it).compare( *otherValue );
if ( valueDiff != 0 )
return valueDiff;
}
return 0;
}
void
ValueInternalMap::makeBeginIterator( IteratorState &it ) const
{
it.map_ = const_cast<ValueInternalMap *>( this );
it.bucketIndex_ = 0;
it.itemIndex_ = 0;
it.link_ = buckets_;
}
void
ValueInternalMap::makeEndIterator( IteratorState &it ) const
{
it.map_ = const_cast<ValueInternalMap *>( this );
it.bucketIndex_ = bucketsSize_;
it.itemIndex_ = 0;
it.link_ = 0;
}
bool
ValueInternalMap::equals( const IteratorState &x, const IteratorState &other )
{
return x.map_ == other.map_
&& x.bucketIndex_ == other.bucketIndex_
&& x.link_ == other.link_
&& x.itemIndex_ == other.itemIndex_;
}
void
ValueInternalMap::incrementBucket( IteratorState &iterator )
{
++iterator.bucketIndex_;
JSON_ASSERT_MESSAGE( iterator.bucketIndex_ <= iterator.map_->bucketsSize_,
"ValueInternalMap::increment(): attempting to iterate beyond end." );
if ( iterator.bucketIndex_ == iterator.map_->bucketsSize_ )
iterator.link_ = 0;
else
iterator.link_ = &(iterator.map_->buckets_[iterator.bucketIndex_]);
iterator.itemIndex_ = 0;
}
void
ValueInternalMap::increment( IteratorState &iterator )
{
JSON_ASSERT_MESSAGE( iterator.map_, "Attempting to iterator using invalid iterator." );
++iterator.itemIndex_;
if ( iterator.itemIndex_ == ValueInternalLink::itemPerLink )
{
JSON_ASSERT_MESSAGE( iterator.link_ != 0,
"ValueInternalMap::increment(): attempting to iterate beyond end." );
iterator.link_ = iterator.link_->next_;
if ( iterator.link_ == 0 )
incrementBucket( iterator );
}
else if ( iterator.link_->items_[iterator.itemIndex_].isItemAvailable() )
{
incrementBucket( iterator );
}
}
void
ValueInternalMap::decrement( IteratorState &iterator )
{
if ( iterator.itemIndex_ == 0 )
{
JSON_ASSERT_MESSAGE( iterator.map_, "Attempting to iterate using invalid iterator." );
if ( iterator.link_ == &iterator.map_->buckets_[iterator.bucketIndex_] )
{
JSON_ASSERT_MESSAGE( iterator.bucketIndex_ > 0, "Attempting to iterate beyond beginning." );
--(iterator.bucketIndex_);
}
iterator.link_ = iterator.link_->previous_;
iterator.itemIndex_ = ValueInternalLink::itemPerLink - 1;
}
}
const char *
ValueInternalMap::key( const IteratorState &iterator )
{
JSON_ASSERT_MESSAGE( iterator.link_, "Attempting to iterate using invalid iterator." );
return iterator.link_->keys_[iterator.itemIndex_];
}
const char *
ValueInternalMap::key( const IteratorState &iterator, bool &isStatic )
{
JSON_ASSERT_MESSAGE( iterator.link_, "Attempting to iterate using invalid iterator." );
isStatic = iterator.link_->items_[iterator.itemIndex_].isMemberNameStatic();
return iterator.link_->keys_[iterator.itemIndex_];
}
Value &
ValueInternalMap::value( const IteratorState &iterator )
{
JSON_ASSERT_MESSAGE( iterator.link_, "Attempting to iterate using invalid iterator." );
return iterator.link_->items_[iterator.itemIndex_];
}
int
ValueInternalMap::distance( const IteratorState &x, const IteratorState &y )
{
int offset = 0;
IteratorState it = x;
while ( !equals( it, y ) )
increment( it );
return offset;
}

@ -0,0 +1,885 @@
#include "reader.h"
#include "value.h"
#include <utility>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <iostream>
#include <stdexcept>
#if _MSC_VER >= 1400 // VC++ 8.0
#pragma warning( disable : 4996 ) // disable warning about strdup being deprecated.
#endif
namespace Json {
// Implementation of class Features
// ////////////////////////////////
Features::Features()
: allowComments_( true )
, strictRoot_( false )
{
}
Features
Features::all()
{
return Features();
}
Features
Features::strictMode()
{
Features features;
features.allowComments_ = false;
features.strictRoot_ = true;
return features;
}
// Implementation of class Reader
// ////////////////////////////////
static inline bool
in( Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4 )
{
return c == c1 || c == c2 || c == c3 || c == c4;
}
static inline bool
in( Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4, Reader::Char c5 )
{
return c == c1 || c == c2 || c == c3 || c == c4 || c == c5;
}
static bool
containsNewLine( Reader::Location begin,
Reader::Location end )
{
for ( ;begin < end; ++begin )
if ( *begin == '\n' || *begin == '\r' )
return true;
return false;
}
static std::string codePointToUTF8(unsigned int cp)
{
std::string result;
// based on description from http://en.wikipedia.org/wiki/UTF-8
if (cp <= 0x7f)
{
result.resize(1);
result[0] = static_cast<char>(cp);
}
else if (cp <= 0x7FF)
{
result.resize(2);
result[1] = static_cast<char>(0x80 | (0x3f & cp));
result[0] = static_cast<char>(0xC0 | (0x1f & (cp >> 6)));
}
else if (cp <= 0xFFFF)
{
result.resize(3);
result[2] = static_cast<char>(0x80 | (0x3f & cp));
result[1] = 0x80 | static_cast<char>((0x3f & (cp >> 6)));
result[0] = 0xE0 | static_cast<char>((0xf & (cp >> 12)));
}
else if (cp <= 0x10FFFF)
{
result.resize(4);
result[3] = static_cast<char>(0x80 | (0x3f & cp));
result[2] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 12)));
result[0] = static_cast<char>(0xF0 | (0x7 & (cp >> 18)));
}
return result;
}
// Class Reader
// //////////////////////////////////////////////////////////////////
Reader::Reader()
: features_( Features::all() )
{
}
Reader::Reader( const Features &features )
: features_( features )
{
}
bool
Reader::parse( const std::string &document,
Value &root,
bool collectComments )
{
document_ = document;
const char *begin = document_.c_str();
const char *end = begin + document_.length();
return parse( begin, end, root, collectComments );
}
bool
Reader::parse( std::istream& sin,
Value &root,
bool collectComments )
{
//std::istream_iterator<char> begin(sin);
//std::istream_iterator<char> end;
// Those would allow streamed input from a file, if parse() were a
// template function.
// Since std::string is reference-counted, this at least does not
// create an extra copy.
std::string doc;
std::getline(sin, doc, (char)EOF);
return parse( doc, root, collectComments );
}
bool
Reader::parse( const char *beginDoc, const char *endDoc,
Value &root,
bool collectComments )
{
if ( !features_.allowComments_ )
{
collectComments = false;
}
begin_ = beginDoc;
end_ = endDoc;
collectComments_ = collectComments;
current_ = begin_;
lastValueEnd_ = 0;
lastValue_ = 0;
commentsBefore_ = "";
errors_.clear();
while ( !nodes_.empty() )
nodes_.pop();
nodes_.push( &root );
bool successful = readValue();
Token token;
skipCommentTokens( token );
if ( collectComments_ && !commentsBefore_.empty() )
root.setComment( commentsBefore_, commentAfter );
if ( features_.strictRoot_ )
{
if ( !root.isArray() && !root.isObject() )
{
// Set error location to start of doc, ideally should be first token found in doc
token.type_ = tokenError;
token.start_ = beginDoc;
token.end_ = endDoc;
addError( "A valid JSON document must be either an array or an object value.",
token );
return false;
}
}
return successful;
}
bool
Reader::readValue()
{
Token token;
skipCommentTokens( token );
bool successful = true;
if ( collectComments_ && !commentsBefore_.empty() )
{
currentValue().setComment( commentsBefore_, commentBefore );
commentsBefore_ = "";
}
switch ( token.type_ )
{
case tokenObjectBegin:
successful = readObject( token );
break;
case tokenArrayBegin:
successful = readArray( token );
break;
case tokenNumber:
successful = decodeNumber( token );
break;
case tokenString:
successful = decodeString( token );
break;
case tokenTrue:
currentValue() = true;
break;
case tokenFalse:
currentValue() = false;
break;
case tokenNull:
currentValue() = Value();
break;
default:
return addError( "Syntax error: value, object or array expected.", token );
}
if ( collectComments_ )
{
lastValueEnd_ = current_;
lastValue_ = &currentValue();
}
return successful;
}
void
Reader::skipCommentTokens( Token &token )
{
if ( features_.allowComments_ )
{
do
{
readToken( token );
}
while ( token.type_ == tokenComment );
}
else
{
readToken( token );
}
}
bool
Reader::expectToken( TokenType type, Token &token, const char *message )
{
readToken( token );
if ( token.type_ != type )
return addError( message, token );
return true;
}
bool
Reader::readToken( Token &token )
{
skipSpaces();
token.start_ = current_;
Char c = getNextChar();
bool ok = true;
switch ( c )
{
case '{':
token.type_ = tokenObjectBegin;
break;
case '}':
token.type_ = tokenObjectEnd;
break;
case '[':
token.type_ = tokenArrayBegin;
break;
case ']':
token.type_ = tokenArrayEnd;
break;
case '"':
token.type_ = tokenString;
ok = readString();
break;
case '/':
token.type_ = tokenComment;
ok = readComment();
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '-':
token.type_ = tokenNumber;
readNumber();
break;
case 't':
token.type_ = tokenTrue;
ok = match( "rue", 3 );
break;
case 'f':
token.type_ = tokenFalse;
ok = match( "alse", 4 );
break;
case 'n':
token.type_ = tokenNull;
ok = match( "ull", 3 );
break;
case ',':
token.type_ = tokenArraySeparator;
break;
case ':':
token.type_ = tokenMemberSeparator;
break;
case 0:
token.type_ = tokenEndOfStream;
break;
default:
ok = false;
break;
}
if ( !ok )
token.type_ = tokenError;
token.end_ = current_;
return true;
}
void
Reader::skipSpaces()
{
while ( current_ != end_ )
{
Char c = *current_;
if ( c == ' ' || c == '\t' || c == '\r' || c == '\n' )
++current_;
else
break;
}
}
bool
Reader::match( Location pattern,
int patternLength )
{
if ( end_ - current_ < patternLength )
return false;
int index = patternLength;
while ( index-- )
if ( current_[index] != pattern[index] )
return false;
current_ += patternLength;
return true;
}
bool
Reader::readComment()
{
Location commentBegin = current_ - 1;
Char c = getNextChar();
bool successful = false;
if ( c == '*' )
successful = readCStyleComment();
else if ( c == '/' )
successful = readCppStyleComment();
if ( !successful )
return false;
if ( collectComments_ )
{
CommentPlacement placement = commentBefore;
if ( lastValueEnd_ && !containsNewLine( lastValueEnd_, commentBegin ) )
{
if ( c != '*' || !containsNewLine( commentBegin, current_ ) )
placement = commentAfterOnSameLine;
}
addComment( commentBegin, current_, placement );
}
return true;
}
void
Reader::addComment( Location begin,
Location end,
CommentPlacement placement )
{
assert( collectComments_ );
if ( placement == commentAfterOnSameLine )
{
assert( lastValue_ != 0 );
lastValue_->setComment( std::string( begin, end ), placement );
}
else
{
if ( !commentsBefore_.empty() )
commentsBefore_ += "\n";
commentsBefore_ += std::string( begin, end );
}
}
bool
Reader::readCStyleComment()
{
while ( current_ != end_ )
{
Char c = getNextChar();
if ( c == '*' && *current_ == '/' )
break;
}
return getNextChar() == '/';
}
bool
Reader::readCppStyleComment()
{
while ( current_ != end_ )
{
Char c = getNextChar();
if ( c == '\r' || c == '\n' )
break;
}
return true;
}
void
Reader::readNumber()
{
while ( current_ != end_ )
{
if ( !(*current_ >= '0' && *current_ <= '9') &&
!in( *current_, '.', 'e', 'E', '+', '-' ) )
break;
++current_;
}
}
bool
Reader::readString()
{
Char c = 0;
while ( current_ != end_ )
{
c = getNextChar();
if ( c == '\\' )
getNextChar();
else if ( c == '"' )
break;
}
return c == '"';
}
bool
Reader::readObject( Token &tokenStart )
{
Token tokenName;
std::string name;
currentValue() = Value( objectValue );
while ( readToken( tokenName ) )
{
bool initialTokenOk = true;
while ( tokenName.type_ == tokenComment && initialTokenOk )
initialTokenOk = readToken( tokenName );
if ( !initialTokenOk )
break;
if ( tokenName.type_ == tokenObjectEnd && name.empty() ) // empty object
return true;
if ( tokenName.type_ != tokenString )
break;
name = "";
if ( !decodeString( tokenName, name ) )
return recoverFromError( tokenObjectEnd );
Token colon;
if ( !readToken( colon ) || colon.type_ != tokenMemberSeparator )
{
return addErrorAndRecover( "Missing ':' after object member name",
colon,
tokenObjectEnd );
}
Value &value = currentValue()[ name ];
nodes_.push( &value );
bool ok = readValue();
nodes_.pop();
if ( !ok ) // error already set
return recoverFromError( tokenObjectEnd );
Token comma;
if ( !readToken( comma )
|| ( comma.type_ != tokenObjectEnd &&
comma.type_ != tokenArraySeparator &&
comma.type_ != tokenComment ) )
{
return addErrorAndRecover( "Missing ',' or '}' in object declaration",
comma,
tokenObjectEnd );
}
bool finalizeTokenOk = true;
while ( comma.type_ == tokenComment &&
finalizeTokenOk )
finalizeTokenOk = readToken( comma );
if ( comma.type_ == tokenObjectEnd )
return true;
}
return addErrorAndRecover( "Missing '}' or object member name",
tokenName,
tokenObjectEnd );
}
bool
Reader::readArray( Token &tokenStart )
{
currentValue() = Value( arrayValue );
skipSpaces();
if ( *current_ == ']' ) // empty array
{
Token endArray;
readToken( endArray );
return true;
}
int index = 0;
while ( true )
{
Value &value = currentValue()[ index++ ];
nodes_.push( &value );
bool ok = readValue();
nodes_.pop();
if ( !ok ) // error already set
return recoverFromError( tokenArrayEnd );
Token token;
// Accept Comment after last item in the array.
ok = readToken( token );
while ( token.type_ == tokenComment && ok )
{
ok = readToken( token );
}
bool badTokenType = ( token.type_ == tokenArraySeparator &&
token.type_ == tokenArrayEnd );
if ( !ok || badTokenType )
{
return addErrorAndRecover( "Missing ',' or ']' in array declaration",
token,
tokenArrayEnd );
}
if ( token.type_ == tokenArrayEnd )
break;
}
return true;
}
bool
Reader::decodeNumber( Token &token )
{
bool isDouble = false;
for ( Location inspect = token.start_; inspect != token.end_; ++inspect )
{
isDouble = isDouble
|| in( *inspect, '.', 'e', 'E', '+' )
|| ( *inspect == '-' && inspect != token.start_ );
}
if ( isDouble )
return decodeDouble( token );
Location current = token.start_;
bool isNegative = *current == '-';
if ( isNegative )
++current;
Value::UInt threshold = (isNegative ? Value::UInt(-Value::minInt)
: Value::maxUInt) / 10;
Value::UInt value = 0;
while ( current < token.end_ )
{
Char c = *current++;
if ( c < '0' || c > '9' )
return addError( "'" + std::string( token.start_, token.end_ ) + "' is not a number.", token );
if ( value >= threshold )
return decodeDouble( token );
value = value * 10 + Value::UInt(c - '0');
}
if ( isNegative )
currentValue() = -Value::Int( value );
else if ( value <= Value::UInt(Value::maxInt) )
currentValue() = Value::Int( value );
else
currentValue() = value;
return true;
}
bool
Reader::decodeDouble( Token &token )
{
double value = 0;
const int bufferSize = 32;
int count;
int length = int(token.end_ - token.start_);
if ( length <= bufferSize )
{
Char buffer[bufferSize];
memcpy( buffer, token.start_, length );
buffer[length] = 0;
count = sscanf( buffer, "%lf", &value );
}
else
{
std::string buffer( token.start_, token.end_ );
count = sscanf( buffer.c_str(), "%lf", &value );
}
if ( count != 1 )
return addError( "'" + std::string( token.start_, token.end_ ) + "' is not a number.", token );
currentValue() = value;
return true;
}
bool
Reader::decodeString( Token &token )
{
std::string decoded;
if ( !decodeString( token, decoded ) )
return false;
currentValue() = decoded;
return true;
}
bool
Reader::decodeString( Token &token, std::string &decoded )
{
decoded.reserve( token.end_ - token.start_ - 2 );
Location current = token.start_ + 1; // skip '"'
Location end = token.end_ - 1; // do not include '"'
while ( current != end )
{
Char c = *current++;
if ( c == '"' )
break;
else if ( c == '\\' )
{
if ( current == end )
return addError( "Empty escape sequence in string", token, current );
Char escape = *current++;
switch ( escape )
{
case '"': decoded += '"'; break;
case '/': decoded += '/'; break;
case '\\': decoded += '\\'; break;
case 'b': decoded += '\b'; break;
case 'f': decoded += '\f'; break;
case 'n': decoded += '\n'; break;
case 'r': decoded += '\r'; break;
case 't': decoded += '\t'; break;
case 'u':
{
unsigned int unicode;
if ( !decodeUnicodeCodePoint( token, current, end, unicode ) )
return false;
decoded += codePointToUTF8(unicode);
}
break;
default:
return addError( "Bad escape sequence in string", token, current );
}
}
else
{
decoded += c;
}
}
return true;
}
bool
Reader::decodeUnicodeCodePoint( Token &token,
Location &current,
Location end,
unsigned int &unicode )
{
if ( !decodeUnicodeEscapeSequence( token, current, end, unicode ) )
return false;
if (unicode >= 0xD800 && unicode <= 0xDBFF)
{
// surrogate pairs
if (end - current < 6)
return addError( "additional six characters expected to parse unicode surrogate pair.", token, current );
unsigned int surrogatePair;
if (*(current++) == '\\' && *(current++)== 'u')
{
if (decodeUnicodeEscapeSequence( token, current, end, surrogatePair ))
{
unicode = 0x10000 + ((unicode & 0x3FF) << 10) + (surrogatePair & 0x3FF);
}
else
return false;
}
else
return addError( "expecting another \\u token to begin the second half of a unicode surrogate pair", token, current );
}
return true;
}
bool
Reader::decodeUnicodeEscapeSequence( Token &token,
Location &current,
Location end,
unsigned int &unicode )
{
if ( end - current < 4 )
return addError( "Bad unicode escape sequence in string: four digits expected.", token, current );
unicode = 0;
for ( int index =0; index < 4; ++index )
{
Char c = *current++;
unicode *= 16;
if ( c >= '0' && c <= '9' )
unicode += c - '0';
else if ( c >= 'a' && c <= 'f' )
unicode += c - 'a' + 10;
else if ( c >= 'A' && c <= 'F' )
unicode += c - 'A' + 10;
else
return addError( "Bad unicode escape sequence in string: hexadecimal digit expected.", token, current );
}
return true;
}
bool
Reader::addError( const std::string &message,
Token &token,
Location extra )
{
ErrorInfo info;
info.token_ = token;
info.message_ = message;
info.extra_ = extra;
errors_.push_back( info );
return false;
}
bool
Reader::recoverFromError( TokenType skipUntilToken )
{
int errorCount = int(errors_.size());
Token skip;
while ( true )
{
if ( !readToken(skip) )
errors_.resize( errorCount ); // discard errors caused by recovery
if ( skip.type_ == skipUntilToken || skip.type_ == tokenEndOfStream )
break;
}
errors_.resize( errorCount );
return false;
}
bool
Reader::addErrorAndRecover( const std::string &message,
Token &token,
TokenType skipUntilToken )
{
addError( message, token );
return recoverFromError( skipUntilToken );
}
Value &
Reader::currentValue()
{
return *(nodes_.top());
}
Reader::Char
Reader::getNextChar()
{
if ( current_ == end_ )
return 0;
return *current_++;
}
void
Reader::getLocationLineAndColumn( Location location,
int &line,
int &column ) const
{
Location current = begin_;
Location lastLineStart = current;
line = 0;
while ( current < location && current != end_ )
{
Char c = *current++;
if ( c == '\r' )
{
if ( *current == '\n' )
++current;
lastLineStart = current;
++line;
}
else if ( c == '\n' )
{
lastLineStart = current;
++line;
}
}
// column & line start at 1
column = int(location - lastLineStart) + 1;
++line;
}
std::string
Reader::getLocationLineAndColumn( Location location ) const
{
int line, column;
getLocationLineAndColumn( location, line, column );
char buffer[18+16+16+1];
sprintf( buffer, "Line %d, Column %d", line, column );
return buffer;
}
std::string
Reader::getFormatedErrorMessages() const
{
std::string formattedMessage;
for ( Errors::const_iterator itError = errors_.begin();
itError != errors_.end();
++itError )
{
const ErrorInfo &error = *itError;
formattedMessage += "* " + getLocationLineAndColumn( error.token_.start_ ) + "\n";
formattedMessage += " " + error.message_ + "\n";
if ( error.extra_ )
formattedMessage += "See " + getLocationLineAndColumn( error.extra_ ) + " for detail.\n";
}
return formattedMessage;
}
std::istream& operator>>( std::istream &sin, Value &root )
{
Json::Reader reader;
bool ok = reader.parse(sin, root, true);
//JSON_ASSERT( ok );
if (!ok) throw std::runtime_error(reader.getFormatedErrorMessages());
return sin;
}
} // namespace Json

File diff suppressed because it is too large Load Diff

@ -0,0 +1,292 @@
// included by json_value.cpp
// everything is within Json namespace
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// class ValueIteratorBase
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
ValueIteratorBase::ValueIteratorBase()
#ifndef JSON_VALUE_USE_INTERNAL_MAP
: current_()
, isNull_( true )
{
}
#else
: isArray_( true )
, isNull_( true )
{
iterator_.array_ = ValueInternalArray::IteratorState();
}
#endif
#ifndef JSON_VALUE_USE_INTERNAL_MAP
ValueIteratorBase::ValueIteratorBase( const Value::ObjectValues::iterator &current )
: current_( current )
, isNull_( false )
{
}
#else
ValueIteratorBase::ValueIteratorBase( const ValueInternalArray::IteratorState &state )
: isArray_( true )
{
iterator_.array_ = state;
}
ValueIteratorBase::ValueIteratorBase( const ValueInternalMap::IteratorState &state )
: isArray_( false )
{
iterator_.map_ = state;
}
#endif
Value &
ValueIteratorBase::deref() const
{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
return current_->second;
#else
if ( isArray_ )
return ValueInternalArray::dereference( iterator_.array_ );
return ValueInternalMap::value( iterator_.map_ );
#endif
}
void
ValueIteratorBase::increment()
{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
++current_;
#else
if ( isArray_ )
ValueInternalArray::increment( iterator_.array_ );
ValueInternalMap::increment( iterator_.map_ );
#endif
}
void
ValueIteratorBase::decrement()
{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
--current_;
#else
if ( isArray_ )
ValueInternalArray::decrement( iterator_.array_ );
ValueInternalMap::decrement( iterator_.map_ );
#endif
}
ValueIteratorBase::difference_type
ValueIteratorBase::computeDistance( const SelfType &other ) const
{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
# ifdef JSON_USE_CPPTL_SMALLMAP
return current_ - other.current_;
# else
// Iterator for null value are initialized using the default
// constructor, which initialize current_ to the default
// std::map::iterator. As begin() and end() are two instance
// of the default std::map::iterator, they can not be compared.
// To allow this, we handle this comparison specifically.
if ( isNull_ && other.isNull_ )
{
return 0;
}
// Usage of std::distance is not portable (does not compile with Sun Studio 12 RogueWave STL,
// which is the one used by default).
// Using a portable hand-made version for non random iterator instead:
// return difference_type( std::distance( current_, other.current_ ) );
difference_type myDistance = 0;
for ( Value::ObjectValues::iterator it = current_; it != other.current_; ++it )
{
++myDistance;
}
return myDistance;
# endif
#else
if ( isArray_ )
return ValueInternalArray::distance( iterator_.array_, other.iterator_.array_ );
return ValueInternalMap::distance( iterator_.map_, other.iterator_.map_ );
#endif
}
bool
ValueIteratorBase::isEqual( const SelfType &other ) const
{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
if ( isNull_ )
{
return other.isNull_;
}
return current_ == other.current_;
#else
if ( isArray_ )
return ValueInternalArray::equals( iterator_.array_, other.iterator_.array_ );
return ValueInternalMap::equals( iterator_.map_, other.iterator_.map_ );
#endif
}
void
ValueIteratorBase::copy( const SelfType &other )
{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
current_ = other.current_;
#else
if ( isArray_ )
iterator_.array_ = other.iterator_.array_;
iterator_.map_ = other.iterator_.map_;
#endif
}
Value
ValueIteratorBase::key() const
{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
const Value::CZString czstring = (*current_).first;
if ( czstring.c_str() )
{
if ( czstring.isStaticString() )
return Value( StaticString( czstring.c_str() ) );
return Value( czstring.c_str() );
}
return Value( czstring.index() );
#else
if ( isArray_ )
return Value( ValueInternalArray::indexOf( iterator_.array_ ) );
bool isStatic;
const char *memberName = ValueInternalMap::key( iterator_.map_, isStatic );
if ( isStatic )
return Value( StaticString( memberName ) );
return Value( memberName );
#endif
}
UInt
ValueIteratorBase::index() const
{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
const Value::CZString czstring = (*current_).first;
if ( !czstring.c_str() )
return czstring.index();
return Value::UInt( -1 );
#else
if ( isArray_ )
return Value::UInt( ValueInternalArray::indexOf( iterator_.array_ ) );
return Value::UInt( -1 );
#endif
}
const char *
ValueIteratorBase::memberName() const
{
#ifndef JSON_VALUE_USE_INTERNAL_MAP
const char *name = (*current_).first.c_str();
return name ? name : "";
#else
if ( !isArray_ )
return ValueInternalMap::key( iterator_.map_ );
return "";
#endif
}
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// class ValueConstIterator
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
ValueConstIterator::ValueConstIterator()
{
}
#ifndef JSON_VALUE_USE_INTERNAL_MAP
ValueConstIterator::ValueConstIterator( const Value::ObjectValues::iterator &current )
: ValueIteratorBase( current )
{
}
#else
ValueConstIterator::ValueConstIterator( const ValueInternalArray::IteratorState &state )
: ValueIteratorBase( state )
{
}
ValueConstIterator::ValueConstIterator( const ValueInternalMap::IteratorState &state )
: ValueIteratorBase( state )
{
}
#endif
ValueConstIterator &
ValueConstIterator::operator =( const ValueIteratorBase &other )
{
copy( other );
return *this;
}
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// class ValueIterator
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
// //////////////////////////////////////////////////////////////////
ValueIterator::ValueIterator()
{
}
#ifndef JSON_VALUE_USE_INTERNAL_MAP
ValueIterator::ValueIterator( const Value::ObjectValues::iterator &current )
: ValueIteratorBase( current )
{
}
#else
ValueIterator::ValueIterator( const ValueInternalArray::IteratorState &state )
: ValueIteratorBase( state )
{
}
ValueIterator::ValueIterator( const ValueInternalMap::IteratorState &state )
: ValueIteratorBase( state )
{
}
#endif
ValueIterator::ValueIterator( const ValueConstIterator &other )
: ValueIteratorBase( other )
{
}
ValueIterator::ValueIterator( const ValueIterator &other )
: ValueIteratorBase( other )
{
}
ValueIterator &
ValueIterator::operator =( const SelfType &other )
{
copy( other );
return *this;
}

@ -0,0 +1,829 @@
#include "writer.h"
#include <utility>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <sstream>
#include <iomanip>
#if _MSC_VER >= 1400 // VC++ 8.0
#pragma warning( disable : 4996 ) // disable warning about strdup being deprecated.
#endif
namespace Json {
static bool isControlCharacter(char ch)
{
return ch > 0 && ch <= 0x1F;
}
static bool containsControlCharacter( const char* str )
{
while ( *str )
{
if ( isControlCharacter( *(str++) ) )
return true;
}
return false;
}
static void uintToString( unsigned int value,
char *&current )
{
*--current = 0;
do
{
*--current = (value % 10) + '0';
value /= 10;
}
while ( value != 0 );
}
std::string valueToString( Int value )
{
char buffer[32];
char *current = buffer + sizeof(buffer);
bool isNegative = value < 0;
if ( isNegative )
value = -value;
uintToString( UInt(value), current );
if ( isNegative )
*--current = '-';
assert( current >= buffer );
return current;
}
std::string valueToString( UInt value )
{
char buffer[32];
char *current = buffer + sizeof(buffer);
uintToString( value, current );
assert( current >= buffer );
return current;
}
std::string valueToString( double value )
{
char buffer[32];
#if defined(_MSC_VER) && defined(__STDC_SECURE_LIB__) // Use secure version with visual studio 2005 to avoid warning.
sprintf_s(buffer, sizeof(buffer), "%#.16g", value);
#else
sprintf(buffer, "%#.16g", value);
#endif
char* ch = buffer + strlen(buffer) - 1;
if (*ch != '0') return buffer; // nothing to truncate, so save time
while(ch > buffer && *ch == '0'){
--ch;
}
char* last_nonzero = ch;
while(ch >= buffer){
switch(*ch){
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
--ch;
continue;
case '.':
// Truncate zeroes to save bytes in output, but keep one.
*(last_nonzero+2) = '\0';
return buffer;
default:
return buffer;
}
}
return buffer;
}
std::string valueToString( bool value )
{
return value ? "true" : "false";
}
std::string valueToQuotedString( const char *value )
{
// Not sure how to handle unicode...
if (strpbrk(value, "\"\\\b\f\n\r\t") == NULL && !containsControlCharacter( value ))
return std::string("\"") + value + "\"";
// We have to walk value and escape any special characters.
// Appending to std::string is not efficient, but this should be rare.
// (Note: forward slashes are *not* rare, but I am not escaping them.)
unsigned maxsize = strlen(value)*2 + 3; // allescaped+quotes+NULL
std::string result;
result.reserve(maxsize); // to avoid lots of mallocs
result += "\"";
for (const char* c=value; *c != 0; ++c)
{
switch(*c)
{
case '\"':
result += "\\\"";
break;
case '\\':
result += "\\\\";
break;
case '\b':
result += "\\b";
break;
case '\f':
result += "\\f";
break;
case '\n':
result += "\\n";
break;
case '\r':
result += "\\r";
break;
case '\t':
result += "\\t";
break;
//case '/':
// Even though \/ is considered a legal escape in JSON, a bare
// slash is also legal, so I see no reason to escape it.
// (I hope I am not misunderstanding something.
// blep notes: actually escaping \/ may be useful in javascript to avoid </
// sequence.
// Should add a flag to allow this compatibility mode and prevent this
// sequence from occurring.
default:
if ( isControlCharacter( *c ) )
{
std::ostringstream oss;
oss << "\\u" << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << static_cast<int>(*c);
result += oss.str();
}
else
{
result += *c;
}
break;
}
}
result += "\"";
return result;
}
// Class Writer
// //////////////////////////////////////////////////////////////////
Writer::~Writer()
{
}
// Class FastWriter
// //////////////////////////////////////////////////////////////////
FastWriter::FastWriter()
: yamlCompatiblityEnabled_( false )
{
}
void
FastWriter::enableYAMLCompatibility()
{
yamlCompatiblityEnabled_ = true;
}
std::string
FastWriter::write( const Value &root )
{
document_ = "";
writeValue( root );
document_ += "\n";
return document_;
}
void
FastWriter::writeValue( const Value &value )
{
switch ( value.type() )
{
case nullValue:
document_ += "null";
break;
case intValue:
document_ += valueToString( value.asInt() );
break;
case uintValue:
document_ += valueToString( value.asUInt() );
break;
case realValue:
document_ += valueToString( value.asDouble() );
break;
case stringValue:
document_ += valueToQuotedString( value.asCString() );
break;
case booleanValue:
document_ += valueToString( value.asBool() );
break;
case arrayValue:
{
document_ += "[";
int size = value.size();
for ( int index =0; index < size; ++index )
{
if ( index > 0 )
document_ += ",";
writeValue( value[index] );
}
document_ += "]";
}
break;
case objectValue:
{
Value::Members members( value.getMemberNames() );
document_ += "{";
for ( Value::Members::iterator it = members.begin();
it != members.end();
++it )
{
const std::string &name = *it;
if ( it != members.begin() )
document_ += ",";
document_ += valueToQuotedString( name.c_str() );
document_ += yamlCompatiblityEnabled_ ? ": "
: ":";
writeValue( value[name] );
}
document_ += "}";
}
break;
}
}
// Class StyledWriter
// //////////////////////////////////////////////////////////////////
StyledWriter::StyledWriter()
: rightMargin_( 74 )
, indentSize_( 3 )
{
}
std::string
StyledWriter::write( const Value &root )
{
document_ = "";
addChildValues_ = false;
indentString_ = "";
writeCommentBeforeValue( root );
writeValue( root );
writeCommentAfterValueOnSameLine( root );
document_ += "\n";
return document_;
}
void
StyledWriter::writeValue( const Value &value )
{
switch ( value.type() )
{
case nullValue:
pushValue( "null" );
break;
case intValue:
pushValue( valueToString( value.asInt() ) );
break;
case uintValue:
pushValue( valueToString( value.asUInt() ) );
break;
case realValue:
pushValue( valueToString( value.asDouble() ) );
break;
case stringValue:
pushValue( valueToQuotedString( value.asCString() ) );
break;
case booleanValue:
pushValue( valueToString( value.asBool() ) );
break;
case arrayValue:
writeArrayValue( value);
break;
case objectValue:
{
Value::Members members( value.getMemberNames() );
if ( members.empty() )
pushValue( "{}" );
else
{
writeWithIndent( "{" );
indent();
Value::Members::iterator it = members.begin();
while ( true )
{
const std::string &name = *it;
const Value &childValue = value[name];
writeCommentBeforeValue( childValue );
writeWithIndent( valueToQuotedString( name.c_str() ) );
document_ += " : ";
writeValue( childValue );
if ( ++it == members.end() )
{
writeCommentAfterValueOnSameLine( childValue );
break;
}
document_ += ",";
writeCommentAfterValueOnSameLine( childValue );
}
unindent();
writeWithIndent( "}" );
}
}
break;
}
}
void
StyledWriter::writeArrayValue( const Value &value )
{
unsigned size = value.size();
if ( size == 0 )
pushValue( "[]" );
else
{
bool isArrayMultiLine = isMultineArray( value );
if ( isArrayMultiLine )
{
writeWithIndent( "[" );
indent();
bool hasChildValue = !childValues_.empty();
unsigned index =0;
while ( true )
{
const Value &childValue = value[index];
writeCommentBeforeValue( childValue );
if ( hasChildValue )
writeWithIndent( childValues_[index] );
else
{
writeIndent();
writeValue( childValue );
}
if ( ++index == size )
{
writeCommentAfterValueOnSameLine( childValue );
break;
}
document_ += ",";
writeCommentAfterValueOnSameLine( childValue );
}
unindent();
writeWithIndent( "]" );
}
else // output on a single line
{
assert( childValues_.size() == size );
document_ += "[ ";
for ( unsigned index =0; index < size; ++index )
{
if ( index > 0 )
document_ += ", ";
document_ += childValues_[index];
}
document_ += " ]";
}
}
}
bool
StyledWriter::isMultineArray( const Value &value )
{
int size = value.size();
bool isMultiLine = size*3 >= rightMargin_ ;
childValues_.clear();
for ( int index =0; index < size && !isMultiLine; ++index )
{
const Value &childValue = value[index];
isMultiLine = isMultiLine ||
( (childValue.isArray() || childValue.isObject()) &&
childValue.size() > 0 );
}
if ( !isMultiLine ) // check if line length > max line length
{
childValues_.reserve( size );
addChildValues_ = true;
int lineLength = 4 + (size-1)*2; // '[ ' + ', '*n + ' ]'
for ( int index =0; index < size && !isMultiLine; ++index )
{
writeValue( value[index] );
lineLength += int( childValues_[index].length() );
isMultiLine = isMultiLine && hasCommentForValue( value[index] );
}
addChildValues_ = false;
isMultiLine = isMultiLine || lineLength >= rightMargin_;
}
return isMultiLine;
}
void
StyledWriter::pushValue( const std::string &value )
{
if ( addChildValues_ )
childValues_.push_back( value );
else
document_ += value;
}
void
StyledWriter::writeIndent()
{
if ( !document_.empty() )
{
char last = document_[document_.length()-1];
if ( last == ' ' ) // already indented
return;
if ( last != '\n' ) // Comments may add new-line
document_ += '\n';
}
document_ += indentString_;
}
void
StyledWriter::writeWithIndent( const std::string &value )
{
writeIndent();
document_ += value;
}
void
StyledWriter::indent()
{
indentString_ += std::string( indentSize_, ' ' );
}
void
StyledWriter::unindent()
{
assert( int(indentString_.size()) >= indentSize_ );
indentString_.resize( indentString_.size() - indentSize_ );
}
void
StyledWriter::writeCommentBeforeValue( const Value &root )
{
if ( !root.hasComment( commentBefore ) )
return;
document_ += normalizeEOL( root.getComment( commentBefore ) );
document_ += "\n";
}
void
StyledWriter::writeCommentAfterValueOnSameLine( const Value &root )
{
if ( root.hasComment( commentAfterOnSameLine ) )
document_ += " " + normalizeEOL( root.getComment( commentAfterOnSameLine ) );
if ( root.hasComment( commentAfter ) )
{
document_ += "\n";
document_ += normalizeEOL( root.getComment( commentAfter ) );
document_ += "\n";
}
}
bool
StyledWriter::hasCommentForValue( const Value &value )
{
return value.hasComment( commentBefore )
|| value.hasComment( commentAfterOnSameLine )
|| value.hasComment( commentAfter );
}
std::string
StyledWriter::normalizeEOL( const std::string &text )
{
std::string normalized;
normalized.reserve( text.length() );
const char *begin = text.c_str();
const char *end = begin + text.length();
const char *current = begin;
while ( current != end )
{
char c = *current++;
if ( c == '\r' ) // mac or dos EOL
{
if ( *current == '\n' ) // convert dos EOL
++current;
normalized += '\n';
}
else // handle unix EOL & other char
normalized += c;
}
return normalized;
}
// Class StyledStreamWriter
// //////////////////////////////////////////////////////////////////
StyledStreamWriter::StyledStreamWriter( std::string indentation )
: document_(NULL)
, rightMargin_( 74 )
, indentation_( indentation )
{
}
void
StyledStreamWriter::write( std::ostream &out, const Value &root )
{
document_ = &out;
addChildValues_ = false;
indentString_ = "";
writeCommentBeforeValue( root );
writeValue( root );
writeCommentAfterValueOnSameLine( root );
*document_ << "\n";
document_ = NULL; // Forget the stream, for safety.
}
void
StyledStreamWriter::writeValue( const Value &value )
{
switch ( value.type() )
{
case nullValue:
pushValue( "null" );
break;
case intValue:
pushValue( valueToString( value.asInt() ) );
break;
case uintValue:
pushValue( valueToString( value.asUInt() ) );
break;
case realValue:
pushValue( valueToString( value.asDouble() ) );
break;
case stringValue:
pushValue( valueToQuotedString( value.asCString() ) );
break;
case booleanValue:
pushValue( valueToString( value.asBool() ) );
break;
case arrayValue:
writeArrayValue( value);
break;
case objectValue:
{
Value::Members members( value.getMemberNames() );
if ( members.empty() )
pushValue( "{}" );
else
{
writeWithIndent( "{" );
indent();
Value::Members::iterator it = members.begin();
while ( true )
{
const std::string &name = *it;
const Value &childValue = value[name];
writeCommentBeforeValue( childValue );
writeWithIndent( valueToQuotedString( name.c_str() ) );
*document_ << " : ";
writeValue( childValue );
if ( ++it == members.end() )
{
writeCommentAfterValueOnSameLine( childValue );
break;
}
*document_ << ",";
writeCommentAfterValueOnSameLine( childValue );
}
unindent();
writeWithIndent( "}" );
}
}
break;
}
}
void
StyledStreamWriter::writeArrayValue( const Value &value )
{
unsigned size = value.size();
if ( size == 0 )
pushValue( "[]" );
else
{
bool isArrayMultiLine = isMultineArray( value );
if ( isArrayMultiLine )
{
writeWithIndent( "[" );
indent();
bool hasChildValue = !childValues_.empty();
unsigned index =0;
while ( true )
{
const Value &childValue = value[index];
writeCommentBeforeValue( childValue );
if ( hasChildValue )
writeWithIndent( childValues_[index] );
else
{
writeIndent();
writeValue( childValue );
}
if ( ++index == size )
{
writeCommentAfterValueOnSameLine( childValue );
break;
}
*document_ << ",";
writeCommentAfterValueOnSameLine( childValue );
}
unindent();
writeWithIndent( "]" );
}
else // output on a single line
{
assert( childValues_.size() == size );
*document_ << "[ ";
for ( unsigned index =0; index < size; ++index )
{
if ( index > 0 )
*document_ << ", ";
*document_ << childValues_[index];
}
*document_ << " ]";
}
}
}
bool
StyledStreamWriter::isMultineArray( const Value &value )
{
int size = value.size();
bool isMultiLine = size*3 >= rightMargin_ ;
childValues_.clear();
for ( int index =0; index < size && !isMultiLine; ++index )
{
const Value &childValue = value[index];
isMultiLine = isMultiLine ||
( (childValue.isArray() || childValue.isObject()) &&
childValue.size() > 0 );
}
if ( !isMultiLine ) // check if line length > max line length
{
childValues_.reserve( size );
addChildValues_ = true;
int lineLength = 4 + (size-1)*2; // '[ ' + ', '*n + ' ]'
for ( int index =0; index < size && !isMultiLine; ++index )
{
writeValue( value[index] );
lineLength += int( childValues_[index].length() );
isMultiLine = isMultiLine && hasCommentForValue( value[index] );
}
addChildValues_ = false;
isMultiLine = isMultiLine || lineLength >= rightMargin_;
}
return isMultiLine;
}
void
StyledStreamWriter::pushValue( const std::string &value )
{
if ( addChildValues_ )
childValues_.push_back( value );
else
*document_ << value;
}
void
StyledStreamWriter::writeIndent()
{
/*
Some comments in this method would have been nice. ;-)
if ( !document_.empty() )
{
char last = document_[document_.length()-1];
if ( last == ' ' ) // already indented
return;
if ( last != '\n' ) // Comments may add new-line
*document_ << '\n';
}
*/
*document_ << '\n' << indentString_;
}
void
StyledStreamWriter::writeWithIndent( const std::string &value )
{
writeIndent();
*document_ << value;
}
void
StyledStreamWriter::indent()
{
indentString_ += indentation_;
}
void
StyledStreamWriter::unindent()
{
assert( indentString_.size() >= indentation_.size() );
indentString_.resize( indentString_.size() - indentation_.size() );
}
void
StyledStreamWriter::writeCommentBeforeValue( const Value &root )
{
if ( !root.hasComment( commentBefore ) )
return;
*document_ << normalizeEOL( root.getComment( commentBefore ) );
*document_ << "\n";
}
void
StyledStreamWriter::writeCommentAfterValueOnSameLine( const Value &root )
{
if ( root.hasComment( commentAfterOnSameLine ) )
*document_ << " " + normalizeEOL( root.getComment( commentAfterOnSameLine ) );
if ( root.hasComment( commentAfter ) )
{
*document_ << "\n";
*document_ << normalizeEOL( root.getComment( commentAfter ) );
*document_ << "\n";
}
}
bool
StyledStreamWriter::hasCommentForValue( const Value &value )
{
return value.hasComment( commentBefore )
|| value.hasComment( commentAfterOnSameLine )
|| value.hasComment( commentAfter );
}
std::string
StyledStreamWriter::normalizeEOL( const std::string &text )
{
std::string normalized;
normalized.reserve( text.length() );
const char *begin = text.c_str();
const char *end = begin + text.length();
const char *current = begin;
while ( current != end )
{
char c = *current++;
if ( c == '\r' ) // mac or dos EOL
{
if ( *current == '\n' ) // convert dos EOL
++current;
normalized += '\n';
}
else // handle unix EOL & other char
normalized += c;
}
return normalized;
}
std::ostream& operator<<( std::ostream &sout, const Value &root )
{
Json::StyledStreamWriter writer;
writer.write(sout, root);
return sout;
}
} // namespace Json

File diff suppressed because it is too large Load Diff

@ -0,0 +1,130 @@
//#include <windows.h>
//#include <winsock2.h>
//ws2_32.lib·¢ËÍhttpÇëÇóÀà¿â
#pragma comment(lib,"ws2_32.lib")
#include "autolink.h"
#include "config.h"
#include "features.h"
#include "forwards.h"
#include "json.h"
#include "reader.h"
#include "value.h"
#include "writer.h"
#include <lov\lov.h>
#include <ics\ics.h>
#include <ict/ict_userservice.h>
#include <atlstr.h>
#include <ATLComTime.h>
#include <iostream>
#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 <tchar.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 <time.h>
#include <ae/ae.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <string>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <vector>
#include <sstream>
#include <fstream>
#include <res\reservation.h>
#ifdef WIN32
#include <io.h>
#include <direct.h>
#else
#include <unistd.h>
#endif
#define DOFREE(obj) \
{ \
if(obj) \
{ \
MEM_free(obj); \
obj = NULL; \
} \
}
extern "C" int POM_AM__set_application_bypass(logical bypass);
using namespace std;
bool copyFile(const char *SRC, const char* DEST);
void initUserDir(char *userId);
int export_dataset_file_to_dir(bool debug,tag_t dataset, const char *ref_name,const char* temp_path, char *ext, char **filename, char **original_name);
void CreateLogFile(char* FunctionName, char *userId, char **fullname);
int CreateTempFile(logical debug,const char* temp_path, char *file_name, char* ext, char **fullname,FILE **file);
int CreateTempFile(logical debug,const char* temp_path, char *file_name, char* user_id, char* ext, char **fullname,FILE **file);
void CloseLog(void);
void WriteLog2(logical debug, const char* format, ...);
void WriteLog(logical debug, const char* format, ...);
void set_bypass(logical bypass);
char* G2U(const char* gb2312);
char* U2G(const char* utf8);
int getPrefStrings(const char *preference, TC_preference_search_scope_t scope, vector<string> &pref_vec);
int export_dataset_file(bool debug, tag_t dataset,const char *ref_name,char *userId, char *ext, char **filename, char **original_name);
int GetBomView(tag_t rev_tag, char* viewtype, tag_t *bomView, tag_t *bomBVR, bool debug);
int GetBomLinePropString(bool debug, tag_t line, char* propName, int errCode, char** attr_val);
void Split(string strArg, char spliter, vector<string> &ans);
void Split(string strArg, string spliter, vector<string> &ans);
int getPrefStrings2(const char *preference, TC_preference_search_scope_t scope, char splitter, vector<string> &pref_vec);
int import_dataset_file(tag_t dataset, const char *ref_name, char *ext, char *fullfilename, char *original_name);
int import_dataset_file_binary(tag_t dataset, const char* temp_path, const char *ref_name, char *ext, char *fullfilename, char *original_name);
int readError(bool debug, char *errFilePath, int errCode);
void deleteFile(bool debug, char *path);
bool CheckType(string config, char* type, char spliter);
bool propExist(bool debug, tag_t obj, const char *propName);
bool isRev(char* object_type);
int GetProcessTargets(bool debug, int att_cnt, tag_t *attachments, vector<tag_t> &targets,char* formType,char splitter);
bool inArray(vector<string> types, string type);
int getIndexInArray(vector<string> types, string type);
int findUser(bool debug,string userStr,tag_t *user_tag);
bool isType(tag_t item,char* type);
int CreateUserFile(logical debug,char* FunctionName, char *userId, char **fullname,FILE **file);
int WriteToFile(logical debug,FILE* file, const char* format, ...);
bool isTypeOf(tag_t objtag, const char * type_name);
int connor_set_prop_value(char* propname, const char* propvalue, tag_t &tag_instance);
int getLast2Year(char* &year);
void getCurrentTime(date_t * now);
bool find_prop(int prop_cnt, char** props, const char* prop);
string readFileIntoString(char * filename);
map<string, string> jsonstr2map(const string& json);
bool exists_test0(const std::string& name);
int export_dataset_file(tag_t dataset, char *ref_name, char *ext, char **filename, char **original_name);
bool is_str_utf8(const char* str);
int write_string_to_file_append(const std::string & file_string, const std::string str);
char* getfileall(const char* fname);
//BOOL GetIpByDomainName(char *szHost, char* szIp);
//void sendGetRequest();

@ -0,0 +1,441 @@
/*=====================================================================================================================
Copyright(c) 2012 ORIGIN.
Unpublished - All rights reserved
=======================================================================================================================
File description:
Filename: ocilib.cxx
Module : OCI
This file describes OCI library Package.
=======================================================================================================================
Date Name Description of Change
1-Feb-2015 Ray li Initialize creation
$HISTORY$
=====================================================================================================================*/
#include "ocilib.h"
#include <stdlib.h>
#define NUM 100
#define USERNAME "MES"
#define PASSWORD "infodba"
#define DBNAME "TCPORD"
// 定义句柄结构
typedef struct {
OCIEnv* p_env; //OCI environment handle 环境句柄
OCIError* p_err; //OCI error handle 错误句柄
OCISvcCtx* p_svc; //OCI service context handel 服务上下文句柄
OCIServer* p_ser; //OCI server handle 服务器句柄
OCISession* p_usr; //OCI user session handle 用户会话句柄
OCIStmt* p_sql; //OCI statement handle 语句句柄
OCIDefine* p_dfn; //OCI define handle 定义句柄
OCIBind* p_bnd; //OCI bind handle 绑定句柄
}OCIHandleInfo;
// 定义错误句柄结构
typedef struct {
OCIEnv* p_env;
OCIError* p_err;
OCISvcCtx* p_svc;
OCIStmt* p_sql;
OCIDefine* p_dfn;
OCIBind* p_bnd;
}OCIDATA;
// 定义执行语句时候的输入参数
typedef struct {
char value[NUM][NUM];
char type[NUM][NUM];
}SqlField;
// 定义查询语句时候的输入,输出参数
typedef struct {
int naIntValue[NUM];
int nIntNum;
char caCharValue[500][500];
int nCharNum;
}SqlSelField;
OCIHandleInfo* ociHandle = NULL;
OCIHandleInfo ociHand;
int InitHandle();
int _ExeSQL(char* SQL, char** inputValue, int inputValueCount);
int _QuerySQL(char* SQL, SqlSelField* pOutField, SqlSelField* pSelField);
int GetDataFromQuery(int* pRc, SqlSelField* pOutField);
void QuitFreeHandle();
/****************************************************************************************************************************************
*****************************************************************************************************************************************/
// 初始化Handler
int InitHandle()
{
int swResult;
ociHandle = &ociHand;
/*create OCI environment*/
if (swResult = OCIEnvCreate(&ociHandle->p_env, OCI_DEFAULT, NULL, NULL, NULL, NULL, 0, NULL)) //环境句柄
{
printf("environment create error!\n\n");
return -1;
}
else
{
printf("environment create success!\n\n");
//return 0;
}
/*init handle*/
if (swResult = OCIHandleAlloc(ociHandle->p_env, (dvoid**)&ociHandle->p_ser, OCI_HTYPE_SERVER, 0, NULL)) //服务器句柄
{
printf("init server handle error!\n\n");
return -1;
}
if (swResult = OCIHandleAlloc(ociHandle->p_env, (dvoid**)&ociHandle->p_err, OCI_HTYPE_ERROR, 0, NULL)) //错误句柄
{
printf("init error handle error!\n\n");
return -1;
}
if (swResult = OCIHandleAlloc(ociHandle->p_env, (dvoid**)&ociHandle->p_usr, OCI_HTYPE_SESSION, 0, NULL)) //事务句柄
{
printf("init session handle error!\n\n");
return -1;
}
if (swResult = OCIHandleAlloc(ociHandle->p_env, (dvoid**)&ociHandle->p_svc, OCI_HTYPE_SVCCTX, 0, NULL)) //上下文句柄
{
printf("init service context handle error!\n\n");
return -1;
}
if (swResult = OCIHandleAlloc(ociHandle->p_env, (dvoid**)&ociHandle->p_sql, OCI_HTYPE_STMT, 0, NULL)) //SQL语句句柄
{
printf("init statement handle error!\n\n");
return -1;
}
printf("init handle success!\n\n");
return 0;
}
// 连接数据库服务器
int ConnServer(char* username, char* password, char* dbname)
{
int swResult;
char errbuf[100] = { 0 };
int errcode;
if (InitHandle() == -1)//初始化句柄
return -1;
if (swResult = OCILogon(ociHandle->p_env, ociHandle->p_err, &ociHandle->p_svc, (text*)username, strlen(username), (text*)password, strlen(password), (text*)dbname, strlen(dbname)))
{
OCIErrorGet((dvoid*)ociHandle->p_err, (ub4)1, (text*)NULL, &errcode, (ub1*)errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR);
printf("Error - %.*s/n", 512, errbuf);
return -1;
}
else
printf("数据库连接成功!\n\n");
return 0;
}
// SQL语句的陈述(执行SQL语句)
int _ExeSQL(char* SQL, char** inputValue, int inputValueCount)
{
int swResult, i;
int errcode;
//设置绑定变量
OCIBind* p_bndp[100];
//准备SQL语句
if (swResult = OCIStmtPrepare(ociHandle->p_sql, ociHandle->p_err, (text*)SQL, strlen(SQL), OCI_NTV_SYNTAX, OCI_DEFAULT))
{
printf("prepare SQL statements error!\n\n");
}
else
{
printf("prepare SQL statements success!\n\n");
}
// 绑定输入变量
for (i = 0; i < inputValueCount; i++)
{
char errbuf[100] = { 0 };
if (swResult = OCIBindByPos(ociHandle->p_sql, &p_bndp[i], ociHandle->p_err, i + 1, (dvoid*)inputValue[i], (sb4)strlen(inputValue[i]) + 1, SQLT_STR, (dvoid*)0, (ub2*)0, (ub2*)0, (ub4)0, (ub4*)0, OCI_DEFAULT))
{
OCIErrorGet((dvoid*)ociHandle->p_err, (ub4)1, (text*)NULL, &errcode, (ub1*)errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR);
printf("Bind Error - %.*s/n", 512, errbuf);
return -1;
}
}
//执行SQL statements
if (swResult = OCIStmtExecute(ociHandle->p_svc, ociHandle->p_sql, ociHandle->p_err, 1, 0, NULL, NULL, OCI_DEFAULT))
{
char errbuf[100] = { 0 };
OCIErrorGet((dvoid*)ociHandle->p_err, (ub4)1, (text*)NULL, &errcode, (ub1*)errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR);
printf("execute SQL statement Error - %.*s\n", 512, errbuf);
return -1;
}
else
{
printf("execute SQL statement success!\n\n");
}
return 0;
}
// 查询SQL
int _QuerySQL(char* SQL, SqlSelField* pOutField, SqlSelField* pSelField)
{
sword status;
int rc = 0, ret = 0;
char errbuf[100] = { 0 };
int maxNum = 2048;
char chTag[8];
int iIndex = 0;
int outputColumn = 0;
int errcode = 0;
char nullValue = '\0'; //
sb2 sb2aInd[30] = { '\0' };
// 准备SQL语句
status = OCIStmtPrepare(ociHandle->p_sql, ociHandle->p_err, (text*)SQL, (ub4)strlen(SQL), (ub4)OCI_NTV_SYNTAX, (ub4)OCI_DEFAULT);
if (status != OCI_SUCCESS)
{
printf("SQL Preparing failed/n");
return -1;
}
// 绑定int类型的, 定义SQL语句时 :1,:2, 定义输入变量
for (iIndex = 0; iIndex < pSelField->nIntNum; iIndex++)
{
memset(chTag, 0, 8);
sprintf(chTag, ":%d", iIndex + 1);
if (rc = OCIBindByName(ociHandle->p_sql, (OCIBind**)&ociHandle->p_dfn, ociHandle->p_err, (text*)chTag, (sb4)strlen((char*)chTag), (dvoid*)&pSelField->naIntValue[iIndex], sizeof(int), SQLT_INT, (dvoid*)0, (ub2*)0, (ub2*)0, (ub4)0, (ub4*)0, OCI_DEFAULT))
{
OCIErrorGet((dvoid*)ociHandle->p_err, (ub4)1, (text*)NULL, &errcode, (ub1*)errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR);
printf("BindByPos Error of ociHandle->p_sql - %.*s\n", 512, errbuf);
return -1;
}
}
// 绑定char *类型的, 定义SQL语句时 :3,:4, 定义输入变量
for (iIndex = 0; iIndex < pSelField->nCharNum; iIndex++)
{
int n = 0;
memset(chTag, 0, 8);
n = pSelField->nIntNum + iIndex + 1;
sprintf(chTag, ":%d", n);
if (rc = OCIBindByName(ociHandle->p_sql, (OCIBind**)&ociHandle->p_dfn, ociHandle->p_err, (text*)chTag, (sb4)strlen((char*)chTag), (dvoid*)&pSelField->caCharValue[iIndex], NUM, SQLT_STR, (dvoid*)0, (ub2*)0, (ub2*)0, (ub4)0, (ub4*)0, OCI_DEFAULT))
{
OCIErrorGet((dvoid*)ociHandle->p_err, (ub4)1, (text*)NULL, &errcode, (ub1*)errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR);
printf("BindByPos Error of ociHandle->p_sql - %.*s\n", 512, errbuf);
return -1;
}
}
// 执行SQL语句
if (rc = OCIStmtExecute(ociHandle->p_svc, ociHandle->p_sql, ociHandle->p_err, (ub4)0, (ub4)0, (CONST OCISnapshot*) NULL, (OCISnapshot*)NULL, OCI_STMT_SCROLLABLE_READONLY))
{
OCIErrorGet((dvoid*)ociHandle->p_err, (ub4)1, (text*)NULL, &errcode, (ub1*)errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR);
printf("execute SQL Error - %.*s\n", 512, errbuf);
return -1;
}
else
{
printf("execute SQL success!\n\n");
}
if (ret = OCIAttrGet(ociHandle->p_sql, (ub4)OCI_HTYPE_STMT, (dvoid*)&outputColumn, (ub4*)0, (ub4)OCI_ATTR_PARAM_COUNT, ociHandle->p_err))
{
OCIErrorGet((dvoid*)ociHandle->p_err, (ub4)1, (text*)NULL, &errcode, (ub1*)errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR);
printf("Get OCIAttr Error of ociHandle->p_sql - %.*s\n", 512, errbuf);
return -1;
}
// 绑定int类型的, 定义SQL语句时 :1,:2, 定义输出变量
for (iIndex = 0; iIndex < pOutField->nIntNum; iIndex++)
{
if (rc = OCIDefineByPos(ociHandle->p_sql, &ociHandle->p_dfn, ociHandle->p_err, iIndex + 1, (dvoid*)&pOutField->naIntValue[iIndex], sizeof(int), SQLT_INT, (dvoid*)0, (ub2*)0, (ub2*)0, OCI_DEFAULT))
{
OCIErrorGet((dvoid*)ociHandle->p_err, (ub4)1, (text*)NULL, &errcode, (ub1*)errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR);
printf("DefineByPos Error of ociHandle->p_sql - %.*s\n", 512, errbuf);
return -1;
}
}
// 绑定char *类型的, 定义SQL语句时 :1,:2, 定义输出变量
for (iIndex = 0; iIndex < outputColumn; iIndex++)
{
int n = iIndex + 1;
if (rc = OCIDefineByPos(ociHandle->p_sql, &ociHandle->p_dfn, ociHandle->p_err, n, (dvoid*)&pOutField->caCharValue[iIndex], 1000 * sizeof(char), SQLT_STR, (dvoid*)0, (ub2*)0, (ub2*)0, OCI_DEFAULT))
{
OCIErrorGet((dvoid*)ociHandle->p_err, (ub4)1, (text*)NULL, &errcode, (ub1*)errbuf, (ub4)sizeof(errbuf), OCI_HTYPE_ERROR);
printf("DefineByPos Error of ociHandle->p_sql - %.*s\n", 512, errbuf);
return -1;
}
}
return 0;
}
// 释放Handler
void QuitFreeHandle()
{
// 退出服务器
OCILogoff(ociHandle->p_svc, ociHandle->p_err);
printf("Quit success!\n");
// 释放句柄
OCIHandleFree(ociHandle->p_ser, OCI_HTYPE_SERVER); //释放服务器句柄
OCIHandleFree(ociHandle->p_err, OCI_HTYPE_ERROR); //释放错误句柄
OCIHandleFree(ociHandle->p_usr, OCI_HTYPE_SESSION); //释放事务句柄
OCIHandleFree(ociHandle->p_svc, OCI_HTYPE_SVCCTX); //释放上下文句柄
OCIHandleFree(ociHandle->p_sql, OCI_HTYPE_STMT); //释放SQL语句句柄
}
// 执行类操作
int ExecuteSQL(char* SQL, int valueCount, char** value)
{
int i = 0;
if (i = _ExeSQL(SQL, value, valueCount))
{
printf("继续操作1\n");
QuitFreeHandle();
return -1;
}
printf("继续操作2\n");
return 0;
}
// 有输入参数的查询
int QuerySQL(char* SQL, int inputValueCount, char** inputValue, int* outputColumn, int* outputValueCount, char**** outputValue)
{
int i = 0, j = 0, ret = 0;
int times = 0, temp = 0;
SqlSelField infield;
SqlSelField outField;
// 初始化参数结构
infield.nCharNum = inputValueCount;
infield.nIntNum = 0;
outField.nCharNum = 0;
outField.nIntNum = 0;
*outputColumn = 0;
*outputValueCount = 0;
for (i = 0; i < inputValueCount; i++)
{
strcpy(infield.caCharValue[i], inputValue[i]);
}
// 执行查询语句
if (ret = _QuerySQL(SQL, &outField, &infield))
{
printf("SQL查询失败!\n");
QuitFreeHandle();
return -1;
}
// 获取结果列数
ret = OCIAttrGet(ociHandle->p_sql, (ub4)OCI_HTYPE_STMT, (dvoid*)outputColumn, (ub4*)0, (ub4)OCI_ATTR_PARAM_COUNT, ociHandle->p_err);
// 提取最后一行,便于去行数
ret = OCIStmtFetch2(ociHandle->p_sql, ociHandle->p_err, 1, OCI_FETCH_LAST, 0, OCI_DEFAULT);
// 获取结果行数
ret = OCIAttrGet(ociHandle->p_sql, (ub4)OCI_HTYPE_STMT, (dvoid*)outputValueCount, (ub4*)0, (ub4)OCI_ATTR_ROW_COUNT, ociHandle->p_err);
if (*outputValueCount == 0)
return 0;
// 开始分配内存并且存储
ret = OCIStmtFetch2(ociHandle->p_sql, ociHandle->p_err, 1, OCI_FETCH_FIRST, 0, OCI_DEFAULT);
*outputValue = (char***)calloc((*outputValueCount) + 1, sizeof(char**));
do
{
(*outputValue)[i] = (char**)calloc((*outputColumn) + 1, sizeof(char*));
for (j = 0; j < (*outputColumn); j++)
{
(*outputValue)[i][j] = (char*)calloc(1000, sizeof(char));
strcpy((*outputValue)[i][j], outField.caCharValue[j]);
//printf("outValue[%d][%d] = %s , 地址=%d, 所指向地址= %d\n ",i,j,(*outputValue)[i][j],&(*outputValue)[i][j],(*outputValue)[i][j]);
}
i++;
} while ((ret = OCIStmtFetch2(ociHandle->p_sql, ociHandle->p_err, 1, OCI_FETCH_NEXT, 1, OCI_DEFAULT) != OCI_NO_DATA));
return 0;
}
// 无输入参数的查询
int QuerySQLNoInputParam(char* SQL, int* outputColumn, int* outputValueCount, char**** outputValue)
{
return QuerySQL(SQL, 0, NULL, outputColumn, outputValueCount, outputValue);
}
// 无参数操作
int ExecuteSQLNoInputParam(char* SQL)
{
printf("开始操作\n");
return ExecuteSQL(SQL, 0, NULL);
}
// 断开连接
void DisConnServer()
{
if (ociHandle != NULL)
QuitFreeHandle();
}

@ -0,0 +1,99 @@
#pragma once
/*=====================================================================================================================
Copyright(c) 2012 ORIGIN.
Unpublished - All rights reserved
=======================================================================================================================
File description:
Filename: ocilib.h
Module : OCI
This Header file of OCI library Package.
=======================================================================================================================
Date Name Description of Change
1-Feb-2015 Ray Initialize creation
$HISTORY$
=====================================================================================================================*/
#include <oci.h>
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include <malloc.h>
//#include <limits.h>
#define OCI_FAIL 1
#define OCI_OK 0
#ifdef __cplusplus
extern "C"
{
#endif
/**
* .
* @param username - <I>
* @param password - <I>
* @param dbname - <I> SID
* @return - OCI_OK or error code
*
* ORACLE
*/
extern int ConnServer(char* username, char* password, char* dbname);
/**
* SQL.
* @param SQL - <I> SQL
* @return - OCI_OK or error code
*
* ORACLE
*/
extern int ExecuteSQLNoInputParam(char* SQL);
/**
* SQL.
* @param SQL - <I> SQL
* @param inputValueCount - <I>
* @param inputValue - <I>
* @return - OCI_OK or error code
*
* ORACLE
*/
extern int ExecuteSQL(char* SQL, int inputValueCount, char** inputValue);
/**
* SQL.
* @param SQL - <I> SQL
* @param outputColumn - <O>
* @param outputValueCount - <O>
* @param outputValue - <O>
* @return - OCI_OK or error code
*
* ORACLE
*/
extern int QuerySQLNoInputParam(char* SQL, int* outputColumn, int* outputValueCount, char**** outputValue);
/**
* SQL.
* @param SQL - <I> SQL
* @param inputValueCount - <I>
* @param inputValue - <I>
* @param outputColumn - <O>
* @param outputValueCount - <O>
* @param outputValue - <O>
* @return - OCI_OK or error code
*
* ORACLE
*/
extern int QuerySQL(char* SQL, int inputValueCount, char** inputValue, int* outputColumn, int* outputValueCount, char**** outputValue);
/**
* .
*
* ORACLE
*/
extern void DisConnServer();
#ifdef __cplusplus
}
#endif

@ -0,0 +1,412 @@
#include "raycus_itk.h"
#include "handler.h"
#ifdef __cplusplus
/*
handler
*/
extern "C" {
#endif
//此函数必须有规范的写法必须以dll的名称加上"_"开头
DLLAPI int ld_itk_c_register_callbacks()
{
int ifail = ITK_ok;
ITKCALL(ifail = CUSTOM_register_exit("ld_itk_c", "USERSERVICE_register_methods",
(CUSTOM_EXIT_ftn_t)K_register_methods));
fprintf(stdout, "ld_itk_c register USERSERVICE_custom_register_methods complete\n");
ITKCALL(ifail = CUSTOM_register_exit("ld_itk_c", "USER_gs_shell_init_module",
(CUSTOM_EXIT_ftn_t)K_register_handlers));
fprintf(stdout, "ld_itk_c register USERSERVICE_custom_register_handlers complete\n");
return ifail;
}
#ifdef __cplusplus
}
#endif
extern DLLAPI int K_register_handlers(int *decision, va_list args)
{
int ifail = ITK_ok;
//根据问题类别指派责任人
ifail = EPM_register_action_handler("LD_AutoAssign", "LD_AutoAssign",
(EPM_action_handler_t)LD_AutoAssign);
if (ifail == ITK_ok)
{
fprintf(stdout, "Registering action handler LD_AutoAssign completed!\n");
}
else
{
fprintf(stdout, "Registering action handler LD_AutoAssign failed %d!\n", ifail);
}
//流程不包含责任人就提升
ifail = EPM_register_action_handler("LD_ElevateTask", "LD_ElevateTask",
(EPM_action_handler_t)LD_ElevateTask);
if (ifail == ITK_ok)
{
fprintf(stdout, "Registering action handler LD_ElevateTask completed!\n");
}
else
{
fprintf(stdout, "Registering action handler LD_ElevateTask failed %d!\n", ifail);
}
//Connor_Review_Person
ITKCALL(ifail = EPM_register_action_handler("Connor_Review_Person", "", (EPM_action_handler_t)Connor_Review_Person));
if (ifail == 0) {
printf("注册操作处理程序成功Connor_Review_Person\n");
}
else {
printf("注册操作处理程序失败[%d]Connor_Review_Person\n", ifail);
}
//Connor_allow_Workflow
ITKCALL(ifail = EPM_register_action_handler("Connor_allow_Workflow", "", (EPM_action_handler_t)Connor_allow_Workflow));
if (ifail == 0) {
printf("注册操作处理程序成功Connor_allow_Workflow\n");
}
else {
printf("注册操作处理程序失败[%d]Connor_allow_Workflow\n", ifail);
}
//LD_FormAttrToExcel
ifail = EPM_register_action_handler("LD_FormAttrToExcel", "", (EPM_action_handler_t)LD_FormAttrToExcel);
if (ifail == 0) {
printf("注册操作处理程序成功LD_FormAttrToExcel\n");
}
else {
printf("注册操作处理程序失败[%d]LD_FormAttrToExcel\n", ifail);
}
//LD_ECN01_SetCICNFormProperty
ifail = EPM_register_action_handler("LD_ECN01_SetCICNFormProperty", "", (EPM_action_handler_t)LD_ECN01_SetCICNFormProperty);
if (ifail == 0) {
printf("注册操作处理程序成功LD_ECN01_SetCICNFormProperty\n");
}
else {
printf("注册操作处理程序失败[%d]LD_ECN01_SetCICNFormProperty\n", ifail);
}
//LD_515_SetCICNFormProperty
ifail = EPM_register_action_handler("LD_515_SetCICNFormProperty", "", (EPM_action_handler_t)LD_515_SetCICNFormProperty);
if (ifail == 0) {
printf("注册操作处理程序成功LD_515_SetCICNFormProperty\n");
}
else {
printf("注册操作处理程序失败[%d]LD_515_SetCICNFormProperty\n", ifail);
}
//LD_PartCompFLAG
ifail = EPM_register_action_handler("LD_PartCompFLAG", "", (EPM_action_handler_t)LD_PartCompFLAG);
if (ifail == 0) {
printf("注册操作处理程序成功LD_PartCompFLAG\n");
}
else {
printf("注册操作处理程序失败[%d]LD_PartCompFLAG\n", ifail);
}
//LD_SendDJJDD_To_MES
ifail = EPM_register_action_handler("LD_SendDJJDD_To_MES", "", (EPM_action_handler_t)LD_SendDJJDD_To_MES);
if (ifail == 0) {
printf("注册操作处理程序成功LD_SendDJJDD_To_MES\n");
}
else {
printf("注册操作处理程序失败[%d]LD_SendDJJDD_To_MES\n", ifail);
}
//UpgradeTask
ifail = EPM_register_action_handler("UpgradeTask", "", (EPM_action_handler_t)UpgradeTask);
if (ifail == 0) {
printf("注册操作处理程序成功UpgradeTask\n");
}
else {
printf("注册操作处理程序失败[%d]UpgradeTask\n", ifail);
}
//LD_PartChange
ifail = EPM_register_action_handler("LD_PartChange", "", (EPM_action_handler_t)LD_PartChange);
if (ifail == 0) {
printf("注册操作处理程序成功LD_PartChange\n");
}
else {
printf("注册操作处理程序失败[%d]LD_PartChange\n", ifail);
}
//LD_SendECRECN_ToSAPMES
ifail = EPM_register_action_handler("LD_SendECRECN_ToSAPMES", "", (EPM_action_handler_t)LD_SendECRECN_ToSAPMES);
if (ifail == 0) {
printf("注册操作处理程序成功LD_SendECRECN_ToSAPMES\n");
}
else {
printf("注册操作处理程序失败[%d]LD_SendECRECN_ToSAPMES\n", ifail);
}
//LD_GYLXFrozen
ifail = EPM_register_action_handler("LD_GYLXFrozen", "", (EPM_action_handler_t)LD_GYLXFrozen);
if (ifail == 0) {
printf("注册操作处理程序成功LD_GYLXFrozen\n");
}
else {
printf("注册操作处理程序失败[%d]LD_GYLXFrozen\n", ifail);
}
//填写完成时间
ifail = EPM_register_action_handler("LD_CompletionDate", "", (EPM_action_handler_t)LD_CompletionDate);
if (ifail == 0) {
printf("注册操作处理程序成功LD_CompletionDate\n");
}
else {
printf("注册操作处理程序失败[%d]LD_CompletionDate\n", ifail);
}
//填写任务分派时间
ifail = EPM_register_action_handler("LD_TaskAssignmentDate", "", (EPM_action_handler_t)LD_TaskAssignmentDate);
if (ifail == 0) {
printf("注册操作处理程序成功LD_TaskAssignmentDate\n");
}
else {
printf("注册操作处理程序失败[%d]LD_TaskAssignmentDate\n", ifail);
}
//(ifail = EPM_register_action_handler("Supor_signoff_rev", "将审签信息记录到表单上", (EPM_action_handler_t)Connor_signoff_rev));
//if (ifail == 0)
//{
// printf("Registering action handler Supor_signoff_rev success\n");
//}
//else
//{
// printf("Registering action handler Supor_signoff_rev failed\n");
//}
//测试handler
ITKCALL(ifail = EPM_register_action_handler("TEST", "TEST", (EPM_action_handler_t)TEST));
if (ifail == ITK_ok)
{
printf("register TEST success \n");
}
else
{
printf("register TEST failed \n");
}
//自动发邮件
(ifail = EPM_register_action_handler("SH_PLM_Email", "SH_PLM_Email", (EPM_action_handler_t)SH_PLM_Email));
if (ifail == 0) {
printf("Registering action handler SH_PLM_Email successful\n");
}
else {
printf("Registering action handler SH_PLM_Email failed %d\n", ifail);
}
//创建后操
METHOD_id_t mth_tag;
ifail = METHOD_find_method("ItemRevision", ITEM_deep_copy_msg, &mth_tag);//参数1类型支持原生和客制化的参数2操作类型
if (mth_tag.id != 0) {
ifail = METHOD_add_action(mth_tag, METHOD_post_action_type, reviseDesignPost, NULL);//参数2执行操作的时刻支持前操作和后操作
fprintf(stdout, "regist reviseDesignPost post_action successfully \n");
}
else {
fprintf(stdout, "regist reviseDesignPost post_action failed \n");
}
return ifail;
}
int Connor_open_bypass(void* returnValue)
{
POM_AM__set_application_bypass(true);
return 0;
}
int Connor_close_bypass(void* returnValue)
{
POM_AM__set_application_bypass(false);
return 0;
}
extern DLLAPI int K_register_methods()
{
int ifail = ITK_ok;
METHOD_id_t mth_tag;
int
status = ITK_ok,
numberOfArguments = 0,
returnValueType = USERARG_STRING_TYPE,
*argumentList = NULL;
USER_function_t functionPtr;
//修订
//{
// ifail = METHOD_find_method("ItemRevision", ITEM_deep_copy_msg, &mth_tag);
// if (mth_tag.id != 0) {
// METHOD_add_action(mth_tag, METHOD_pre_action_type, ML_ItemRevPreUpdate, NULL);
// printf("注册ItemRevision函数成功\n");
// }
//}
//ifail = METHOD_find_method("ItemRevision", "ITEM_deep_copy", &mth_tag);
//if (mth_tag.id != 0) {
// ifail = METHOD_add_action(mth_tag, METHOD_post_action_type, (METHOD_function_t)CONNOR_REVISE_CLEAR_FORM, NULL);
// if (ifail == 0) {
// printf("Registering method CONNOR_REVISE_CLEAR_FORM successful\n");
// }
// else {
// printf("Registering method CONNOR_REVISE_CLEAR_FORM failed %d\n", ifail);
// }
//}
//开旁路
{
numberOfArguments = 1;
functionPtr = Connor_open_bypass;
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int));
argumentList[0] = USERARG_STRING_TYPE;
returnValueType = USERARG_VOID_TYPE;
char* mth_name = (char*)malloc(1 + sizeof(char) * strlen("CONNOR_open_bypass"));
tc_strcpy(mth_name, "CONNOR_open_bypass");
ITKCALL(status = USERSERVICE_register_method(mth_name, functionPtr, numberOfArguments,
argumentList, returnValueType));
MEM_free(argumentList);
if (status == ITK_ok)
{
printf("Method: %s\n", mth_name);
}
else
{
printf("Method register failed [%d]: %s\n", status, mth_name);
}
}
{
ifail = METHOD_find_method("ItemRevision", TC_save_msg, &mth_tag);
if (mth_tag.id != 0) {
METHOD_add_action(mth_tag, METHOD_post_action_type, (METHOD_function_t)ML_ItemRevSave, NULL);
printf("注册ItemRevision函数成功\n");
}
}
////文件夹后操作
//{
// ifail = METHOD_find_method("Folder", TC_save_msg, &mth_tag);
// if (mth_tag.id != 0) {
// METHOD_add_action(mth_tag, METHOD_post_action_type, (METHOD_function_t)LD6_CusProdFolderSave, NULL);
// printf("注册LD6_CusProdFolderSave函数成功\n");
// }
//}
//关旁路
{
numberOfArguments = 1;
functionPtr = Connor_close_bypass;
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int));
argumentList[0] = USERARG_STRING_TYPE;
returnValueType = USERARG_VOID_TYPE;
char* mth_name = (char*)malloc(1 + sizeof(char) * strlen("CONNOR_close_bypass"));
tc_strcpy(mth_name, "CONNOR_close_bypass");
ITKCALL(status = USERSERVICE_register_method(mth_name, functionPtr, numberOfArguments,
argumentList, returnValueType));
MEM_free(argumentList);
if (status == ITK_ok)
{
printf("Method: %s\n", mth_name);
}
else
{
printf("Method register failed [%d]: %s\n", status, mth_name);
}
}
//设置只读属性的值
{
numberOfArguments = 3;
functionPtr = connor_set_prop_value;
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int));
argumentList[0] = USERARG_STRING_TYPE;
argumentList[1] = USERARG_STRING_TYPE;
argumentList[2] = USERARG_TAG_TYPE;
returnValueType = USERARG_STRING_TYPE;
char* mth_name = (char*)malloc(1 + sizeof(char) * strlen("Connor_Set_Prop_Value"));
tc_strcpy(mth_name, "Connor_Set_Prop_Value");
ITKCALL(status = USERSERVICE_register_method(mth_name, functionPtr, numberOfArguments,
argumentList, returnValueType));
MEM_free(argumentList);
if (status == ITK_ok)
{
printf("Method: %s\n", mth_name);
}
else
{
printf("Method register failed [%d]: %s\n", status, mth_name);
}
}
{
numberOfArguments = 3;
returnValueType = USERARG_STRING_TYPE;
functionPtr = uploadFile;
argumentList = (int*)MEM_alloc(numberOfArguments * sizeof(int));
argumentList[0] = USERARG_STRING_TYPE;
argumentList[1] = USERARG_STRING_TYPE;
argumentList[2] = USERARG_STRING_TYPE;
status = USERSERVICE_register_method("uploadFile", functionPtr, numberOfArguments, argumentList, returnValueType);
if (status == ITK_ok)
{
printf("Registering uploadFile finished\n");
}
else
{
printf("Registering uploadFile failed %d\n", status);
}
MEM_free(argumentList);
}
/*int
status = ITK_ok,
numberOfArguments = 0,
returnValueType = USERARG_STRING_TYPE,
*argumentList = NULL;
USER_function_t functionPtr;
METHOD_id_t mth_tag;
ITKCALL(ifail = METHOD_find_method ( "Schedule", TC_save_msg, &mth_tag ) );
if ( mth_tag.id != NULLTAG )
{
ITKCALL(ifail = METHOD_add_action( mth_tag, METHOD_post_action_type, (METHOD_function_t)Save_Schedule_Post_Action, NULL ) );
if(ifail==0) {
printf("Register method Save_Schedule_Post_Action success\n");
} else {
printf("Register method Save_Schedule_Post_Action failed %d\n", ifail);
}
}*/
return ITK_ok;
}
//extern DLLAPI int F_register_handlers(int *decision, va_list args)
// {
// int ifail = ITK_ok;
//
// //创建后操
// METHOD_id_t mth_tag;
// ifail = METHOD_find_method("Design Revision", ITEM_deep_copy_msg, &mth_tag);//参数1类型支持原生和客制化的参数2操作类型
// if (mth_tag.id != 0) {
// ifail = METHOD_add_action(mth_tag, METHOD_post_action_type, reviseDesignPost, NULL);//参数2执行操作的时刻支持前操作和后操作
// fprintf(stdout, "regist reviseDesignPost post_action successfully \n");
// }
// else {
// fprintf(stdout, "regist reviseDesignPost post_action failed \n");
// }
// return ifail;
// }

@ -0,0 +1,8 @@
#include <server_exits/user_server_exits.h>
#include <tccore/custom.h>
#include <tc/tc_macros.h>
#include <tccore/tc_msg.h>
#include <epm\epm.h>
extern DLLAPI int K_register_handlers(int *, va_list);
extern DLLAPI int K_register_methods();

@ -0,0 +1,196 @@
#ifndef CPPTL_JSON_READER_H_INCLUDED
# define CPPTL_JSON_READER_H_INCLUDED
# include "features.h"
# include "value.h"
# include <deque>
# include <stack>
# include <string>
# include <iostream>
namespace Json {
/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a Value.
*
*/
class JSON_API Reader
{
public:
typedef char Char;
typedef const Char *Location;
/** \brief Constructs a Reader allowing all features
* for parsing.
*/
Reader();
/** \brief Constructs a Reader allowing the specified feature set
* for parsing.
*/
Reader( const Features &features );
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document.
* \param document UTF-8 encoded string containing the document to read.
* \param root [out] Contains the root value of the document if it was
* successfully parsed.
* \param collectComments \c true to collect comment and allow writing them back during
* serialization, \c false to discard comments.
* This parameter is ignored if Features::allowComments_
* is \c false.
* \return \c true if the document was successfully parsed, \c false if an error occurred.
*/
bool parse( const std::string &document,
Value &root,
bool collectComments = true );
/** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a> document.
* \param document UTF-8 encoded string containing the document to read.
* \param root [out] Contains the root value of the document if it was
* successfully parsed.
* \param collectComments \c true to collect comment and allow writing them back during
* serialization, \c false to discard comments.
* This parameter is ignored if Features::allowComments_
* is \c false.
* \return \c true if the document was successfully parsed, \c false if an error occurred.
*/
bool parse( const char *beginDoc, const char *endDoc,
Value &root,
bool collectComments = true );
/// \brief Parse from input stream.
/// \see Json::operator>>(std::istream&, Json::Value&).
bool parse( std::istream &is,
Value &root,
bool collectComments = true );
/** \brief Returns a user friendly string that list errors in the parsed document.
* \return Formatted error message with the list of errors with their location in
* the parsed document. An empty string is returned if no error occurred
* during parsing.
*/
std::string getFormatedErrorMessages() const;
private:
enum TokenType
{
tokenEndOfStream = 0,
tokenObjectBegin,
tokenObjectEnd,
tokenArrayBegin,
tokenArrayEnd,
tokenString,
tokenNumber,
tokenTrue,
tokenFalse,
tokenNull,
tokenArraySeparator,
tokenMemberSeparator,
tokenComment,
tokenError
};
class Token
{
public:
TokenType type_;
Location start_;
Location end_;
};
class ErrorInfo
{
public:
Token token_;
std::string message_;
Location extra_;
};
typedef std::deque<ErrorInfo> Errors;
bool expectToken( TokenType type, Token &token, const char *message );
bool readToken( Token &token );
void skipSpaces();
bool match( Location pattern,
int patternLength );
bool readComment();
bool readCStyleComment();
bool readCppStyleComment();
bool readString();
void readNumber();
bool readValue();
bool readObject( Token &token );
bool readArray( Token &token );
bool decodeNumber( Token &token );
bool decodeString( Token &token );
bool decodeString( Token &token, std::string &decoded );
bool decodeDouble( Token &token );
bool decodeUnicodeCodePoint( Token &token,
Location &current,
Location end,
unsigned int &unicode );
bool decodeUnicodeEscapeSequence( Token &token,
Location &current,
Location end,
unsigned int &unicode );
bool addError( const std::string &message,
Token &token,
Location extra = 0 );
bool recoverFromError( TokenType skipUntilToken );
bool addErrorAndRecover( const std::string &message,
Token &token,
TokenType skipUntilToken );
void skipUntilSpace();
Value &currentValue();
Char getNextChar();
void getLocationLineAndColumn( Location location,
int &line,
int &column ) const;
std::string getLocationLineAndColumn( Location location ) const;
void addComment( Location begin,
Location end,
CommentPlacement placement );
void skipCommentTokens( Token &token );
typedef std::stack<Value *> Nodes;
Nodes nodes_;
Errors errors_;
std::string document_;
Location begin_;
Location end_;
Location current_;
Location lastValueEnd_;
Value *lastValue_;
std::string commentsBefore_;
Features features_;
bool collectComments_;
};
/** \brief Read from 'sin' into 'root'.
Always keep comments from the input JSON.
This can be used to read a file into a particular sub-object.
For example:
\code
Json::Value root;
cin >> root["dir"]["file"];
cout << root;
\endcode
Result:
\verbatim
{
"dir": {
"file": {
// The input stream JSON would be nested here.
}
}
}
\endverbatim
\throw std::exception on parse error.
\see Json::operator<<()
*/
std::istream& operator>>( std::istream&, Value& );
} // namespace Json
#endif // CPPTL_JSON_READER_H_INCLUDED

@ -0,0 +1,8 @@
Import( 'env buildLibrary' )
buildLibrary( env, Split( """
json_reader.cpp
json_value.cpp
json_writer.cpp
""" ),
'json' )

File diff suppressed because it is too large Load Diff

@ -0,0 +1,174 @@
#ifndef JSON_WRITER_H_INCLUDED
# define JSON_WRITER_H_INCLUDED
# include "value.h"
# include <vector>
# include <string>
# include <iostream>
namespace Json {
class Value;
/** \brief Abstract class for writers.
*/
class JSON_API Writer
{
public:
virtual ~Writer();
virtual std::string write( const Value &root ) = 0;
};
/** \brief Outputs a Value in <a HREF="http://www.json.org">JSON</a> format without formatting (not human friendly).
*
* The JSON document is written in a single line. It is not intended for 'human' consumption,
* but may be usefull to support feature such as RPC where bandwith is limited.
* \sa Reader, Value
*/
class JSON_API FastWriter : public Writer
{
public:
FastWriter();
virtual ~FastWriter(){}
void enableYAMLCompatibility();
public: // overridden from Writer
virtual std::string write( const Value &root );
private:
void writeValue( const Value &value );
std::string document_;
bool yamlCompatiblityEnabled_;
};
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a human friendly way.
*
* The rules for line break and indent are as follow:
* - Object value:
* - if empty then print {} without indent and line break
* - if not empty the print '{', line break & indent, print one value per line
* and then unindent and line break and print '}'.
* - Array value:
* - if empty then print [] without indent and line break
* - if the array contains no object value, empty array or some other value types,
* and all the values fit on one lines, then print the array on a single line.
* - otherwise, it the values do not fit on one line, or the array contains
* object or non empty array, then print one value per line.
*
* If the Value have comments then they are outputed according to their #CommentPlacement.
*
* \sa Reader, Value, Value::setComment()
*/
class JSON_API StyledWriter: public Writer
{
public:
StyledWriter();
virtual ~StyledWriter(){}
public: // overridden from Writer
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
* \param root Value to serialize.
* \return String containing the JSON document that represents the root value.
*/
virtual std::string write( const Value &root );
private:
void writeValue( const Value &value );
void writeArrayValue( const Value &value );
bool isMultineArray( const Value &value );
void pushValue( const std::string &value );
void writeIndent();
void writeWithIndent( const std::string &value );
void indent();
void unindent();
void writeCommentBeforeValue( const Value &root );
void writeCommentAfterValueOnSameLine( const Value &root );
bool hasCommentForValue( const Value &value );
static std::string normalizeEOL( const std::string &text );
typedef std::vector<std::string> ChildValues;
ChildValues childValues_;
std::string document_;
std::string indentString_;
int rightMargin_;
int indentSize_;
bool addChildValues_;
};
/** \brief Writes a Value in <a HREF="http://www.json.org">JSON</a> format in a human friendly way,
to a stream rather than to a string.
*
* The rules for line break and indent are as follow:
* - Object value:
* - if empty then print {} without indent and line break
* - if not empty the print '{', line break & indent, print one value per line
* and then unindent and line break and print '}'.
* - Array value:
* - if empty then print [] without indent and line break
* - if the array contains no object value, empty array or some other value types,
* and all the values fit on one lines, then print the array on a single line.
* - otherwise, it the values do not fit on one line, or the array contains
* object or non empty array, then print one value per line.
*
* If the Value have comments then they are outputed according to their #CommentPlacement.
*
* \param indentation Each level will be indented by this amount extra.
* \sa Reader, Value, Value::setComment()
*/
class JSON_API StyledStreamWriter
{
public:
StyledStreamWriter( std::string indentation="\t" );
~StyledStreamWriter(){}
public:
/** \brief Serialize a Value in <a HREF="http://www.json.org">JSON</a> format.
* \param out Stream to write to. (Can be ostringstream, e.g.)
* \param root Value to serialize.
* \note There is no point in deriving from Writer, since write() should not return a value.
*/
void write( std::ostream &out, const Value &root );
private:
void writeValue( const Value &value );
void writeArrayValue( const Value &value );
bool isMultineArray( const Value &value );
void pushValue( const std::string &value );
void writeIndent();
void writeWithIndent( const std::string &value );
void indent();
void unindent();
void writeCommentBeforeValue( const Value &root );
void writeCommentAfterValueOnSameLine( const Value &root );
bool hasCommentForValue( const Value &value );
static std::string normalizeEOL( const std::string &text );
typedef std::vector<std::string> ChildValues;
ChildValues childValues_;
std::ostream* document_;
std::string indentString_;
int rightMargin_;
std::string indentation_;
bool addChildValues_;
};
std::string JSON_API valueToString( Int value );
std::string JSON_API valueToString( UInt value );
std::string JSON_API valueToString( double value );
std::string JSON_API valueToString( bool value );
std::string JSON_API valueToQuotedString( const char *value );
/// \brief Output using the StyledStreamWriter.
/// \see Json::operator>>()
std::ostream& operator<<( std::ostream&, const Value &root );
} // namespace Json
#endif // JSON_WRITER_H_INCLUDED

@ -0,0 +1,19 @@
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\vc140.pdb
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\qf8_handlers.obj
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\kutil.obj
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\connor_sign_pre_revision.obj
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\connor_sign_master.obj
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\connor_sign_dataset.obj
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\connor_signature.obj
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\connor_revise_clear_master.obj
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\connor_avic_catiasign.obj
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\connor_add_release_status.obj
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\ado.obj
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\msado15.tli
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\msado15.tlh
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\connor_signature.tlog\cl.command.1.tlog
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\connor_signature.tlog\cl.read.1.tlog
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\connor_signature.tlog\cl.write.1.tlog
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\connor_signature.tlog\link.command.1.tlog
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\connor_signature.tlog\link.read.1.tlog
c:\users\89512\desktop\美菱\meling_itk\connor_signature\x64\release\connor_signature.tlog\link.write.1.tlog

@ -0,0 +1,2 @@
#v4.0:v110:false
Release|x64|C:\code\connor_signature\|

@ -0,0 +1,195 @@
C:\VS2019\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(513,5): warning MSB8028: 中间目录(x64\Release\)包含从另一个项目(connor_signature.vcxproj, meling_itk.vcxproj, raycus_itk.vcxproj, raycus_itk2.vcxproj, raycus_itk_c.vcxproj)共享的文件。 这会导致错误的清除和重新生成行为。
a.cpp
addLb.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\source\联德\itk\ld_itk(1)\connor_signature\addLb.cpp(179,11): warning C4834: 放弃具有 "nodiscard" 属性的函数的返回值
D:\source\联德\itk\ld_itk(1)\connor_signature\addLb.cpp(138,6): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\addLb.cpp(222,5): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
ado.cxx
Connor_allow_Workflow.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\source\联德\itk\ld_itk(1)\connor_signature\Connor_allow_Workflow.cpp(56,9): warning C4477: “printf”: 格式字符串“%d”需要类型“int”的参数但可变参数 1 拥有了类型“unsigned __int64”
D:\source\联德\itk\ld_itk(1)\connor_signature\Connor_allow_Workflow.cpp(56,9): message : 请考虑在格式字符串中使用“%zd”
Connor_Review_Person.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\source\联德\itk\ld_itk(1)\connor_signature\Connor_Review_Person.cpp(199,9): warning C4477: “printf”: 格式字符串“%d”需要类型“int”的参数但可变参数 1 拥有了类型“unsigned __int64”
D:\source\联德\itk\ld_itk(1)\connor_signature\Connor_Review_Person.cpp(199,9): message : 请考虑在格式字符串中使用“%zd”
json_reader.cpp
json_value.cpp
json_writer.cpp
D:\source\联德\itk\ld_itk(1)\connor_signature\json_writer.cpp(119,42): warning C4267: “初始化”: 从“size_t”转换到“unsigned int”可能丢失数据
Connor_ElevateTask.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
LD_AutoAssign.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_AutoAssign.cpp(18,13): warning C4101: “file_descriptor”: 未引用的局部变量
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_AutoAssign.cpp(20,8): warning C4101: “new_file_name”: 未引用的局部变量
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_AutoAssign.cpp(71,85): warning C4267: “参数”: 从“size_t”转换到“int”可能丢失数据
LD_ECN01_SetCICNFormProperty.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_ECN01_SetCICNFormProperty.cpp(215,12): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_ECN01_SetCICNFormProperty.cpp(230,7): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_ECN01_SetCICNFormProperty.cpp(505,12): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_ECN01_SetCICNFormProperty.cpp(520,7): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_ECN01_SetCICNFormProperty.cpp(347,11): warning C4101: “fathnum”: 未引用的局部变量
LD_CompletionDate.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
The contents of <filesystem> are available only with C++17 or later.
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_CompletionDate.cpp(61,10): warning C4101: “itemObjId”: 未引用的局部变量
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_CompletionDate.cpp(63,10): warning C4101: “revision_id”: 未引用的局部变量
LD_FormAttrToExcel.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_FormAttrToExcel.cpp(49,25): warning C4267: “初始化”: 从“size_t”转换到“int”可能丢失数据
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_FormAttrToExcel.cpp(50,25): warning C4267: “初始化”: 从“size_t”转换到“int”可能丢失数据
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_FormAttrToExcel.cpp(207,29): warning C4474: printf: 格式字符串中传递的参数太多
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_FormAttrToExcel.cpp(207,29): message : 占位符和其参数预计 0 可变参数,但提供的却是 1 参数
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_FormAttrToExcel.cpp(208,25): warning C4474: printf: 格式字符串中传递的参数太多
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_FormAttrToExcel.cpp(208,25): message : 占位符和其参数预计 0 可变参数,但提供的却是 1 参数
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_FormAttrToExcel.cpp(229,13): warning C4101: “serial_num”: 未引用的局部变量
LD_GYLXFrozen.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
The contents of <filesystem> are available only with C++17 or later.
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_GYLXFrozen.cpp(76,16): warning C4834: 放弃具有 "nodiscard" 属性的函数的返回值
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_GYLXFrozen.cpp(167,7): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_GYLXFrozen.cpp(182,7): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
LD_PartChange.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_PartChange.cpp(57,24): warning C4267: “初始化”: 从“size_t”转换到“int”可能丢失数据
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_PartChange.cpp(194,6): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_PartChange.cpp(233,6): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_PartChange.cpp(140,34): warning C4101: “e”: 未引用的局部变量
LD_PartCompFLAG.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_PartCompFLAG.cpp(73,24): warning C4267: “初始化”: 从“size_t”转换到“int”可能丢失数据
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_PartCompFLAG.cpp(263,9): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_PartCompFLAG.cpp(311,6): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_PartCompFLAG.cpp(166,34): warning C4101: “e”: 未引用的局部变量
LD_SendDJJDD_To_MES.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
The contents of <filesystem> are available only with C++17 or later.
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_SendDJJDD_To_MES.cpp(63,24): warning C4267: “初始化”: 从“size_t”转换到“int”可能丢失数据
LD_SendECRECN_ToSAPMES.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
The contents of <filesystem> are available only with C++17 or later.
LD_TaskAssignmentDate.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
The contents of <filesystem> are available only with C++17 or later.
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_TaskAssignmentDate.cpp(58,10): warning C4101: “itemObjId”: 未引用的局部变量
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_TaskAssignmentDate.cpp(60,10): warning C4101: “revision_id”: 未引用的局部变量
ocilib.cpp
D:\source\联德\itk\ld_itk(1)\connor_signature\ocilib.cpp(158,5): warning C4267: “参数”: 从“size_t”转换到“ub4”可能丢失数据
D:\source\联德\itk\ld_itk(1)\connor_signature\ocilib.cpp(181,5): warning C4267: “参数”: 从“size_t”转换到“ub4”可能丢失数据
正在编译...
raycus_itk.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
kutil.cpp
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(118,3): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(130,3): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(142,3): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(154,3): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(405,88): warning C4267: “参数”: 从“size_t”转换到“int”可能丢失数据
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(436,6): warning C4996: 'chdir': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _chdir. See online help for details.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(438,3): warning C4996: 'mkdir': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _mkdir. See online help for details.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(480,9): warning C4101: “now”: 未引用的局部变量
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(479,7): warning C4101: “date_string”: 未引用的局部变量
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(481,13): warning C4101: “p”: 未引用的局部变量
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(546,6): warning C4996: 'chdir': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _chdir. See online help for details.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(548,3): warning C4996: 'mkdir': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _mkdir. See online help for details.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(609,6): warning C4996: 'chdir': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _chdir. See online help for details.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(611,3): warning C4996: 'mkdir': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _mkdir. See online help for details.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(682,6): warning C4996: 'chdir': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _chdir. See online help for details.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(690,7): warning C4996: 'chdir': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _chdir. See online help for details.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(767,6): warning C4996: 'chdir': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _chdir. See online help for details.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(774,7): warning C4996: 'chdir': The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: _chdir. See online help for details.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(904,2): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(913,2): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(916,2): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(942,2): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(952,2): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(954,2): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(1011,24): warning C4267: “初始化”: 从“size_t”转换到“int”可能丢失数据
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(1021,24): warning C4267: “初始化”: 从“size_t”转换到“int”可能丢失数据
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(1033,24): warning C4267: “初始化”: 从“size_t”转换到“int”可能丢失数据
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(1061,39): warning C4267: “初始化”: 从“size_t”转换到“int”可能丢失数据
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(1062,39): warning C4267: “初始化”: 从“size_t”转换到“int”可能丢失数据
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(1250,31): warning C4101: “old_scope”: 未引用的局部变量
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(1271,31): warning C4101: “old_scope”: 未引用的局部变量
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(1306,13): warning C4101: “file_descriptor”: 未引用的局部变量
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(1308,8): warning C4101: “new_file_name”: 未引用的局部变量
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(1367,13): warning C4101: “file_descriptor”: 未引用的局部变量
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(1369,8): warning C4101: “new_file_name”: 未引用的局部变量
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(1417,13): warning C4101: “file_descriptor”: 未引用的局部变量
D:\source\联德\itk\ld_itk(1)\connor_signature\kutil.cpp(1419,8): warning C4101: “new_file_name”: 未引用的局部变量
Send_Sap_Bom.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_Bom.cpp(232,4): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_Bom.cpp(263,6): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_Bom.cpp(276,5): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_Bom.cpp(657,4): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_Bom.cpp(688,6): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_Bom.cpp(701,5): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_Bom.cpp(895,4): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_Bom.cpp(926,6): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_Bom.cpp(939,5): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_Bom.cpp(807,28): warning C4101: “revisions”: 未引用的局部变量
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_Bom.cpp(1127,4): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_Bom.cpp(1158,6): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_Bom.cpp(1171,5): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_Bom.cpp(958,88): warning C4101: “bom_window_tag”: 未引用的局部变量
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_Bom.cpp(1250,43): warning C4267: “初始化”: 从“size_t”转换到“int”可能丢失数据
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_Bom.cpp(1343,17): warning C4244: “=”: 从“double”转换到“float”可能丢失数据
Send_Sap_material.cpp.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_material.cpp.cpp(120,39): warning C4267: “初始化”: 从“size_t”转换到“unsigned int”可能丢失数据
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_material.cpp.cpp(125,10): warning C4477: “printf”: 格式字符串“%s”需要类型“char *”的参数,但可变参数 1 拥有了类型“std::string”
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_material.cpp.cpp(112,3): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_material.cpp.cpp(152,5): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_material.cpp.cpp(172,3): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_material.cpp.cpp(204,4): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_material.cpp.cpp(225,3): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_material.cpp.cpp(359,39): warning C4267: “初始化”: 从“size_t”转换到“unsigned int”可能丢失数据
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_material.cpp.cpp(364,10): warning C4477: “printf”: 格式字符串“%s”需要类型“char *”的参数,但可变参数 1 拥有了类型“std::string”
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_material.cpp.cpp(351,3): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_material.cpp.cpp(391,5): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_material.cpp.cpp(411,3): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_material.cpp.cpp(443,4): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
D:\source\联德\itk\ld_itk(1)\connor_signature\Send_Sap_material.cpp.cpp(464,3): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
SH_PLM_Email.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\source\联德\itk\ld_itk(1)\connor_signature\SH_PLM_Email.cpp(95,30): warning C4267: “=”: 从“size_t”转换到“int”可能丢失数据
TEST.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\source\联德\itk\ld_itk(1)\connor_signature\TEST.cpp(76,52): warning C4101: “rootTask_tag”: 未引用的局部变量
D:\source\联德\itk\ld_itk(1)\connor_signature\TEST.cpp(147,3): warning C4996: 'AOM_save': "AOM_save" deprecated in Teamcenter "11.2"; Use "AOM_save_with_extensions or AOM_save_without_extensions" instead.
UpgradeTask.cpp
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(806,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
D:\WorkEnvironment\tc13ITK\include\pom\pom\pom.h(5417,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
The contents of <filesystem> are available only with C++17 or later.
正在创建库 D:\source\联德\itk\ld_itk(1)\x64\Release\ld_itk_c.lib 和对象 D:\source\联德\itk\ld_itk(1)\x64\Release\ld_itk_c.exp
正在生成代码
Previous IPDB not found, fall back to full compilation.
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_GYLXFrozen.cpp(194): warning C4715: “LD_GYLXFrozen”: 不是所有的控件路径都返回值
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_SendECRECN_ToSAPMES.cpp(839): warning C4715: “LD_SendECRECN_ToSAPMES”: 不是所有的控件路径都返回值
D:\source\联德\itk\ld_itk(1)\connor_signature\LD_SendDJJDD_To_MES.cpp(297): warning C4715: “LD_SendDJJDD_To_MES”: 不是所有的控件路径都返回值
All 1967 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
已完成代码的生成
connor_signature.vcxproj -> D:\source\联德\itk\ld_itk(1)\x64\Release\ld_itk_c.dll

@ -0,0 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
Release|x64|C:\Users\89512\Desktop\美菱\meling_itk\|

@ -0,0 +1,43 @@
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\vc142.pdb
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ocilib.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_taskassignmentdate.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_sendecrecn_tosapmes.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_senddjjdd_to_mes.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_partcompflag.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_partchange.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_gylxfrozen.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_formattrtoexcel.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_completiondate.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_ecn01_setcicnformproperty.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_autoassign.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\connor_elevatetask.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\json_writer.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\json_value.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\json_reader.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\connor_review_person.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\connor_allow_workflow.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ado.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\addlb.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\a.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\upgradetask.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\test.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\sh_plm_email.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\send_sap_material.cpp.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\send_sap_bom.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\kutil.obj
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\raycus_itk.obj
d:\source\联德\itk\ld_itk(1)\x64\release\ld_itk_c.lib
d:\source\联德\itk\ld_itk(1)\x64\release\ld_itk_c.exp
d:\source\联德\itk\ld_itk(1)\x64\release\ld_itk_c.dll
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_itk_c.ipdb
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_itk_c.iobj
d:\source\联德\itk\ld_itk(1)\x64\release\ld_itk_c.pdb
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\msado15.tli
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\msado15.tlh
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_itk_c.tlog\cl.command.1.tlog
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_itk_c.tlog\cl.read.1.tlog
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_itk_c.tlog\cl.write.1.tlog
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_itk_c.tlog\ld_itk_c.write.1u.tlog
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_itk_c.tlog\link.command.1.tlog
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_itk_c.tlog\link.read.1.tlog
d:\source\联德\itk\ld_itk(1)\connor_signature\x64\release\ld_itk_c.tlog\link.write.1.tlog

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<ProjectOutputs>
<ProjectOutput>
<FullPath>D:\source\联德\itk\ld_itk(1)\x64\Release\ld_itk_c.dll</FullPath>
</ProjectOutput>
</ProjectOutputs>
<ContentFiles />
<SatelliteDlls />
<NonRecipeFileRefs />
</Project>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save