|
|
#include "SB_handler.h"
|
|
|
#include "string_helper.h"
|
|
|
using namespace std;
|
|
|
|
|
|
#include <iostream>
|
|
|
#include <fstream>
|
|
|
#include <string>
|
|
|
#include <ctime>
|
|
|
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
|
|
|
#include <experimental/filesystem>
|
|
|
namespace fs = std::experimental::filesystem;
|
|
|
|
|
|
void removeLogsFile() {
|
|
|
fs::path filePath("C:\\logs.txt");
|
|
|
if (fs::exists(filePath)) {
|
|
|
fs::remove(filePath);
|
|
|
std::cout << "文件已删除: " << filePath << std::endl;
|
|
|
}
|
|
|
else {
|
|
|
std::cout << "文件不存在: " << filePath << std::endl;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 获取当前时间的字符串表示
|
|
|
std::string getCurrentTime() {
|
|
|
std::time_t now = std::time(nullptr);
|
|
|
std::tm* now_tm = std::localtime(&now);
|
|
|
char buffer[20];
|
|
|
std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", now_tm);
|
|
|
return std::string(buffer);
|
|
|
}
|
|
|
|
|
|
// 写入日志信息到文件 writeLog("当前工时: "+ std::to_string(totalGs));
|
|
|
void writeLog(const std::string& message) {
|
|
|
std::ofstream logFile("C:\\logs.txt", std::ios_base::app); // 以追加模式打开文件
|
|
|
if (logFile.is_open()) {
|
|
|
std::string logEntry = "[" + getCurrentTime() + "] " + message + "\n";
|
|
|
logFile << logEntry;
|
|
|
logFile.close();
|
|
|
}
|
|
|
else {
|
|
|
std::cerr << "无法打开日志文件" << std::endl;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Lao(EPM_action_message_t msg)
|
|
|
{
|
|
|
int ifail = ITK_ok, sub_cnt = 0, perform_count = 0, *perform_type, attachment_cnt = 0, ds_cnt = 0, ref_cnt = 0;
|
|
|
tag_t root_task = NULLTAG, *sub_tasks = NULLTAG, sub_task = NULLTAG,
|
|
|
owner = NULLTAG, perform_task = NULLTAG, *perform_attaches = NULLTAG,
|
|
|
member_tag = NULLTAG, *attachments = NULLTAG, item = NULLTAG,
|
|
|
itemRev = NULLTAG, type_tag, relation_type, *secondary_objects = NULLTAG, *refs = NULLTAG;
|
|
|
char *type = NULL, *date_format = "%Y-%m-%d", *timeinfo = NULL, *name = NULL,
|
|
|
*person_name = NULL, *comments = NULL, *dir = NULL;
|
|
|
date_t mod_date = NULLDATE, decision_date = NULLDATE;
|
|
|
char content[512] = "", buf[64] = "", path[256] = "";
|
|
|
SIGNOFF_TYPE_t member_type;
|
|
|
EPM_signoff_decision_t signoff_decision;
|
|
|
time_t t = NULL;
|
|
|
size_t buffer_cnt = 32;
|
|
|
tm *local;
|
|
|
FILE *fw;
|
|
|
errno_t error;
|
|
|
|
|
|
ITKCALL(EPM_ask_root_task(msg.task, &root_task));
|
|
|
ITKCALL(EPM_ask_sub_tasks(root_task, &sub_cnt, &sub_tasks));
|
|
|
for (int i = 0; i < sub_cnt; i++)
|
|
|
{
|
|
|
sub_task = sub_tasks[i];
|
|
|
ITKCALL(WSOM_ask_name2(sub_task, &name));
|
|
|
ITKCALL(WSOM_ask_object_type2(sub_task, &type));
|
|
|
|
|
|
if (stricmp("EPMDoTask", type) == 0)
|
|
|
{
|
|
|
ITKCALL(AOM_ask_owner(sub_task, &owner));
|
|
|
ITKCALL(SA_ask_user_person_name2(owner, &person_name));
|
|
|
ITKCALL(AOM_ask_value_date(sub_task, "last_mod_date", &mod_date));
|
|
|
ITKCALL(DATE_date_to_string(mod_date, date_format, &timeinfo));
|
|
|
|
|
|
strcat_s(content, strlen(content) + strlen(name) + 1, name);
|
|
|
strcat_s(content, strlen(content) + strlen("=") + 1, "=");
|
|
|
strcat_s(content, strlen(content) + strlen(person_name) + 1, person_name);
|
|
|
strcat_s(content, strlen(content) + strlen("|") + 1, "|");
|
|
|
strcat_s(content, strlen(content) + strlen(name) + 1, name);
|
|
|
strcat_s(content, strlen(content) + strlen("日期") + 1, "日期");
|
|
|
strcat_s(content, strlen(content) + strlen("=") + 1, "=");
|
|
|
strcat_s(content, strlen(content) + strlen(timeinfo) + 1, timeinfo);
|
|
|
strcat_s(content, strlen(content) + strlen("|") + 1, "|");
|
|
|
}
|
|
|
else if (stricmp("EPMReviewTask", type) == 0)
|
|
|
{
|
|
|
|
|
|
ITKCALL(EPM_ask_sub_task(sub_task, "perform-signoffs", &perform_task));
|
|
|
ITKCALL(EPM_ask_all_attachments(perform_task, &perform_count, &perform_attaches, &perform_type));
|
|
|
for (int j = 0; j < perform_count; j++)
|
|
|
{
|
|
|
ITKCALL(EPM_ask_signoff_member(perform_attaches[j], &member_tag, &member_type));
|
|
|
ITKCALL(EPM_ask_signoff_decision(perform_attaches[j], &signoff_decision, &comments, &decision_date));
|
|
|
if (member_type == SIGNOFF_GROUPMEMBER)
|
|
|
{
|
|
|
ITKCALL(SA_ask_groupmember_user(member_tag, &owner));
|
|
|
ITKCALL(SA_ask_user_person_name2(owner, &person_name));
|
|
|
ITKCALL(DATE_date_to_string(decision_date, date_format, &timeinfo));
|
|
|
|
|
|
strcat_s(content, strlen(content) + strlen(name) + 1, name);
|
|
|
strcat_s(content, strlen(content) + strlen("=") + 1, "=");
|
|
|
strcat_s(content, strlen(content) + strlen(person_name) + 1, person_name);
|
|
|
strcat_s(content, strlen(content) + strlen("|") + 1, "|");
|
|
|
strcat_s(content, strlen(content) + strlen(name) + 1, name);
|
|
|
strcat_s(content, strlen(content) + strlen("日期") + 1, "日期");
|
|
|
strcat_s(content, strlen(content) + strlen("=") + 1, "=");
|
|
|
strcat_s(content, strlen(content) + strlen(timeinfo) + 1, timeinfo);
|
|
|
strcat_s(content, strlen(content) + strlen("|") + 1, "|");
|
|
|
}
|
|
|
}
|
|
|
if (perform_attaches) { MEM_free(perform_attaches); perform_attaches = NULL; }
|
|
|
if (perform_type) { MEM_free(perform_type); perform_type = NULL; }
|
|
|
if (comments) { MEM_free(comments); comments = NULL; }
|
|
|
}
|
|
|
|
|
|
if (person_name) { MEM_free(person_name); person_name = NULL; }
|
|
|
if (timeinfo) { MEM_free(timeinfo); timeinfo = NULL; }
|
|
|
if (name) { MEM_free(name); name = NULL; }
|
|
|
if (type) { MEM_free(type); type = NULL; }
|
|
|
}
|
|
|
|
|
|
if (sub_tasks) { MEM_free(sub_tasks); sub_tasks = NULL; }
|
|
|
printf("sign content: %s\n", content);
|
|
|
|
|
|
_dupenv_s(&dir, &buffer_cnt, "temp");
|
|
|
local = new tm();
|
|
|
t = time(NULL);
|
|
|
localtime_s(local, &t);
|
|
|
strftime(buf, 64, "%Y-%m-%d-%H-%M-%S.bat", local);
|
|
|
|
|
|
if (dir[strlen(dir) - 1] == '\\')
|
|
|
{
|
|
|
sprintf_s(path, "%s%s", dir, buf);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sprintf_s(path, "%s\\%s", dir, buf);
|
|
|
}
|
|
|
error = fopen_s(&fw, path, "a+");
|
|
|
if (error == 0)
|
|
|
{
|
|
|
fwrite(content, sizeof(char), strlen(content), fw);
|
|
|
fclose(fw);
|
|
|
}
|
|
|
if (local != NULL)
|
|
|
{
|
|
|
delete local;
|
|
|
local = NULL;
|
|
|
}
|
|
|
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
|
|
|
ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &attachment_cnt, &attachments));
|
|
|
for (int i = 0; i < attachment_cnt; i++)
|
|
|
{
|
|
|
itemRev = attachments[i];
|
|
|
ITKCALL(TCTYPE_ask_object_type(itemRev, &type_tag));
|
|
|
ITKCALL(TCTYPE_ask_class_name2(type_tag, &name));
|
|
|
|
|
|
if ((strstr(name, "Revision") != NULL) || (strstr(name, "revision") != NULL))
|
|
|
{
|
|
|
printf("1111\n");
|
|
|
ITKCALL(ITEM_ask_item_of_rev(itemRev, &item));
|
|
|
ITKCALL(GRM_find_relation_type(TC_specification_rtype, &relation_type));
|
|
|
ITKCALL(GRM_list_secondary_objects_only(itemRev, relation_type, &ds_cnt, &secondary_objects));
|
|
|
for (int j = 0; j < ds_cnt; j++)
|
|
|
{
|
|
|
ITKCALL(AOM_ask_value_string(secondary_objects[j], "object_type", &type));
|
|
|
if ((stricmp(type, "PDF") == 0) || (stricmp(type, "MSExcelX") == 0)) {
|
|
|
ITKCALL(AOM_ask_value_tags(secondary_objects[j], "ref_list", &ref_cnt, &refs));
|
|
|
if (ref_cnt < 1) {
|
|
|
printf("ref is error\n");
|
|
|
continue;
|
|
|
}
|
|
|
if (strcmp(type, "PDF") == 0)
|
|
|
{
|
|
|
printf("sign pdf start\n");
|
|
|
Lao_excute_pdf(secondary_objects[j], path, buf, "pdf");
|
|
|
printf("sign pdf end\n");
|
|
|
}
|
|
|
if (refs) { MEM_free(refs); type = NULL; }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
printf("type is not pdf, type: %s\n", type);
|
|
|
if (type) { MEM_free(type); type = NULL; }
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
int Lao_excute_pdf(tag_t dateset, char *file_path, char *file_name, char* ext)
|
|
|
{
|
|
|
int ifail = ITK_ok;
|
|
|
tag_t spec_dataset_rev = NULLTAG, ref_object = NULLTAG;
|
|
|
AE_reference_type_t ref_type;
|
|
|
char ref_name[WSO_name_size_c + 1] = "PDF_Reference";
|
|
|
ITKCALL(AE_ask_dataset_latest_rev(dateset, &spec_dataset_rev));
|
|
|
ITKCALL(AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &ref_type, &ref_object));
|
|
|
|
|
|
char *pathname = NULL;
|
|
|
char *origin_file_name = NULL;
|
|
|
ITKCALL(IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname));
|
|
|
ITKCALL(IMF_ask_original_file_name2(ref_object, &origin_file_name));
|
|
|
printf("pathname: %s, origin_file_name: %s\n", pathname, origin_file_name);
|
|
|
|
|
|
char new_ds_name[WSO_name_size_c + 1] = "";
|
|
|
char *new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
|
|
|
string newName = new_file_name;
|
|
|
if (newName.find(".PDF") == string::npos && newName.find(".pdf") == string::npos)
|
|
|
{
|
|
|
strcat(new_file_name, ".PDF");
|
|
|
}
|
|
|
printf("new_file_name: %s\n", new_file_name);
|
|
|
|
|
|
char *temp_dir = nullptr;
|
|
|
size_t s1 = 0;
|
|
|
_dupenv_s(&temp_dir, &s1, "temp");
|
|
|
|
|
|
char in_file[256] = "";
|
|
|
char out_file[256] = "";
|
|
|
strcpy_s(in_file, strlen(temp_dir) + 1, temp_dir);
|
|
|
strcpy_s(in_file, strlen("\\") + 1, "\\");
|
|
|
strcpy_s(in_file, strlen(new_file_name) + 1, new_file_name);
|
|
|
sprintf_s(out_file, 128, "%d-%s", 2, in_file);
|
|
|
IMF_export_file(ref_object, in_file);
|
|
|
|
|
|
char cmd[256] = "";
|
|
|
char *tc_root_dir = nullptr;
|
|
|
size_t s2 = 0;
|
|
|
_dupenv_s(&tc_root_dir, &s2, "tc_root");
|
|
|
strcpy_s(cmd, strlen("java -jar ") + 1, "java -jar ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(tc_root_dir) + 1, tc_root_dir);
|
|
|
strcat_s(cmd, strlen(cmd) + strlen("\\bin\\SignPdfLao.jar") + 1, "\\bin\\SignPdfLao.jar");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(" ") + 1, " ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(file_path) + 1, file_path);
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(" ") + 1, " ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(in_file) + 1, in_file);
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(" ") + 1, " ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(out_file) + 1, out_file);
|
|
|
printf("cmd: %s\n", cmd);
|
|
|
system(cmd);
|
|
|
|
|
|
tag_t new_file_tag = NULLTAG;
|
|
|
IMF_file_t file_descriptor;
|
|
|
ITKCALL(IMF_import_file(out_file, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor));
|
|
|
ITKCALL(IMF_set_original_file_name2(new_file_tag, origin_file_name));
|
|
|
ITKCALL(IMF_close_file(file_descriptor));
|
|
|
ITKCALL(AOM_save(new_file_tag));
|
|
|
ITKCALL(AOM_unlock(new_file_tag));
|
|
|
|
|
|
ITKCALL(AOM_lock(spec_dataset_rev));
|
|
|
ITKCALL(AE_remove_dataset_named_ref_by_tag2(spec_dataset_rev, ref_name, ref_object));
|
|
|
ITKCALL(AE_add_dataset_named_ref2(spec_dataset_rev, ref_name, AE_PART_OF, new_file_tag));
|
|
|
ITKCALL(AOM_save(spec_dataset_rev));
|
|
|
ITKCALL(AOM_unlock(spec_dataset_rev));
|
|
|
|
|
|
remove(in_file);
|
|
|
free(tc_root_dir);
|
|
|
free(temp_dir);
|
|
|
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
int Xin(EPM_action_message_t msg) {
|
|
|
int ifail = ITK_ok, sub_cnt = 0, perform_count = 0, *perform_type, attachment_cnt = 0, ds_cnt = 0, ref_cnt = 0;
|
|
|
tag_t root_task = NULLTAG, *sub_tasks = NULLTAG, sub_task = NULLTAG,
|
|
|
owner = NULLTAG, perform_task = NULLTAG, *perform_attaches = NULLTAG,
|
|
|
member_tag = NULLTAG, *attachments = NULLTAG, item = NULLTAG,
|
|
|
itemRev = NULLTAG, type_tag, relation_type, *secondary_objects = NULLTAG, *refs = NULLTAG;
|
|
|
char *type = NULL, *date_format = "%Y-%m-%d", *timeinfo = NULL, *name = NULL,
|
|
|
*person_name = NULL, *comments = NULL, *dir = NULL;
|
|
|
date_t mod_date = NULLDATE, decision_date = NULLDATE;
|
|
|
char content[512] = "", buf[64] = "", path[256] = "";
|
|
|
SIGNOFF_TYPE_t member_type;
|
|
|
EPM_signoff_decision_t signoff_decision;
|
|
|
time_t t = NULL;
|
|
|
size_t buffer_cnt = 32;
|
|
|
tm *local;
|
|
|
FILE *fw;
|
|
|
errno_t error;
|
|
|
|
|
|
ITKCALL(EPM_ask_root_task(msg.task, &root_task));
|
|
|
ITKCALL(EPM_ask_sub_tasks(root_task, &sub_cnt, &sub_tasks));
|
|
|
for (int i = 0; i < sub_cnt; i++)
|
|
|
{
|
|
|
sub_task = sub_tasks[i];
|
|
|
ITKCALL(WSOM_ask_name2(sub_task, &name));
|
|
|
ITKCALL(WSOM_ask_object_type2(sub_task, &type));
|
|
|
|
|
|
if (stricmp("EPMDoTask", type) == 0)
|
|
|
{
|
|
|
ITKCALL(AOM_ask_owner(sub_task, &owner));
|
|
|
ITKCALL(SA_ask_user_person_name2(owner, &person_name));
|
|
|
ITKCALL(AOM_ask_value_date(sub_task, "last_mod_date", &mod_date));
|
|
|
ITKCALL(DATE_date_to_string(mod_date, date_format, &timeinfo));
|
|
|
|
|
|
strcat_s(content, strlen(content) + strlen(name) + 1, name);
|
|
|
strcat_s(content, strlen(content) + strlen("=") + 1, "=");
|
|
|
strcat_s(content, strlen(content) + strlen(person_name) + 1, person_name);
|
|
|
strcat_s(content, strlen(content) + strlen("|") + 1, "|");
|
|
|
strcat_s(content, strlen(content) + strlen(name) + 1, name);
|
|
|
strcat_s(content, strlen(content) + strlen("日期") + 1, "日期");
|
|
|
strcat_s(content, strlen(content) + strlen("=") + 1, "=");
|
|
|
strcat_s(content, strlen(content) + strlen(timeinfo) + 1, timeinfo);
|
|
|
strcat_s(content, strlen(content) + strlen("|") + 1, "|");
|
|
|
}
|
|
|
else if (stricmp("EPMReviewTask", type) == 0)
|
|
|
{
|
|
|
|
|
|
ITKCALL(EPM_ask_sub_task(sub_task, "perform-signoffs", &perform_task));
|
|
|
ITKCALL(EPM_ask_all_attachments(perform_task, &perform_count, &perform_attaches, &perform_type));
|
|
|
for (int j = 0; j < perform_count; j++)
|
|
|
{
|
|
|
ITKCALL(EPM_ask_signoff_member(perform_attaches[j], &member_tag, &member_type));
|
|
|
ITKCALL(EPM_ask_signoff_decision(perform_attaches[j], &signoff_decision, &comments, &decision_date));
|
|
|
if (member_type == SIGNOFF_GROUPMEMBER)
|
|
|
{
|
|
|
ITKCALL(SA_ask_groupmember_user(member_tag, &owner));
|
|
|
ITKCALL(SA_ask_user_person_name2(owner, &person_name));
|
|
|
ITKCALL(DATE_date_to_string(decision_date, date_format, &timeinfo));
|
|
|
|
|
|
strcat_s(content, strlen(content) + strlen(name) + 1, name);
|
|
|
strcat_s(content, strlen(content) + strlen("=") + 1, "=");
|
|
|
strcat_s(content, strlen(content) + strlen(person_name) + 1, person_name);
|
|
|
strcat_s(content, strlen(content) + strlen("|") + 1, "|");
|
|
|
strcat_s(content, strlen(content) + strlen(name) + 1, name);
|
|
|
strcat_s(content, strlen(content) + strlen("日期") + 1, "日期");
|
|
|
strcat_s(content, strlen(content) + strlen("=") + 1, "=");
|
|
|
strcat_s(content, strlen(content) + strlen(timeinfo) + 1, timeinfo);
|
|
|
strcat_s(content, strlen(content) + strlen("|") + 1, "|");
|
|
|
}
|
|
|
}
|
|
|
if (perform_attaches) { MEM_free(perform_attaches); perform_attaches = NULL; }
|
|
|
if (perform_type) { MEM_free(perform_type); perform_type = NULL; }
|
|
|
if (comments) { MEM_free(comments); comments = NULL; }
|
|
|
}
|
|
|
|
|
|
if (person_name) { MEM_free(person_name); person_name = NULL; }
|
|
|
if (timeinfo) { MEM_free(timeinfo); timeinfo = NULL; }
|
|
|
if (name) { MEM_free(name); name = NULL; }
|
|
|
if (type) { MEM_free(type); type = NULL; }
|
|
|
}
|
|
|
|
|
|
if (sub_tasks) { MEM_free(sub_tasks); sub_tasks = NULL; }
|
|
|
printf("sign content: %s\n", content);
|
|
|
|
|
|
_dupenv_s(&dir, &buffer_cnt, "temp");
|
|
|
local = new tm();
|
|
|
t = time(NULL);
|
|
|
localtime_s(local, &t);
|
|
|
strftime(buf, 64, "%Y-%m-%d-%H-%M-%S.bat", local);
|
|
|
|
|
|
if (dir[strlen(dir) - 1] == '\\')
|
|
|
{
|
|
|
sprintf_s(path, "%s%s", dir, buf);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sprintf_s(path, "%s\\%s", dir, buf);
|
|
|
}
|
|
|
error = fopen_s(&fw, path, "a+");
|
|
|
if (error == 0)
|
|
|
{
|
|
|
fwrite(content, sizeof(char), strlen(content), fw);
|
|
|
fclose(fw);
|
|
|
}
|
|
|
if (local != NULL)
|
|
|
{
|
|
|
delete local;
|
|
|
local = NULL;
|
|
|
}
|
|
|
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
|
|
|
ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &attachment_cnt, &attachments));
|
|
|
for (int i = 0; i < attachment_cnt; i++)
|
|
|
{
|
|
|
itemRev = attachments[i];
|
|
|
ITKCALL(TCTYPE_ask_object_type(itemRev, &type_tag));
|
|
|
ITKCALL(TCTYPE_ask_class_name2(type_tag, &name));
|
|
|
|
|
|
if ((strstr(name, "Revision") != NULL) || (strstr(name, "revision") != NULL))
|
|
|
{
|
|
|
printf("1111\n");
|
|
|
ITKCALL(ITEM_ask_item_of_rev(itemRev, &item));
|
|
|
ITKCALL(GRM_find_relation_type(TC_specification_rtype, &relation_type));
|
|
|
ITKCALL(GRM_list_secondary_objects_only(itemRev, relation_type, &ds_cnt, &secondary_objects));
|
|
|
for (int j = 0; j < ds_cnt; j++)
|
|
|
{
|
|
|
ITKCALL(AOM_ask_value_string(secondary_objects[j], "object_type", &type));
|
|
|
if ((stricmp(type, "PDF") == 0) || (stricmp(type, "MSExcelX") == 0)) {
|
|
|
ITKCALL(AOM_ask_value_tags(secondary_objects[j], "ref_list", &ref_cnt, &refs));
|
|
|
if (ref_cnt < 1) {
|
|
|
printf("ref is error\n");
|
|
|
continue;
|
|
|
}
|
|
|
if (strcmp(type, "PDF") == 0)
|
|
|
{
|
|
|
printf("sign pdf start\n");
|
|
|
Xin_excute_pdf(secondary_objects[j], path, buf, "pdf");
|
|
|
printf("sign pdf end\n");
|
|
|
}
|
|
|
if (refs) { MEM_free(refs); type = NULL; }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
printf("type is not pdf, type: %s\n", type);
|
|
|
if (type) { MEM_free(type); type = NULL; }
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
int Xin_excute_pdf(tag_t dateset, char *file_path, char *file_name, char* ext)
|
|
|
{
|
|
|
int ifail = ITK_ok;
|
|
|
tag_t spec_dataset_rev = NULLTAG, ref_object = NULLTAG;
|
|
|
AE_reference_type_t ref_type;
|
|
|
char ref_name[WSO_name_size_c + 1] = "PDF_Reference";
|
|
|
ITKCALL(AE_ask_dataset_latest_rev(dateset, &spec_dataset_rev));
|
|
|
ITKCALL(AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &ref_type, &ref_object));
|
|
|
|
|
|
char *pathname = NULL;
|
|
|
char *origin_file_name = NULL;
|
|
|
ITKCALL(IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname));
|
|
|
ITKCALL(IMF_ask_original_file_name2(ref_object, &origin_file_name));
|
|
|
printf("pathname: %s, origin_file_name: %s\n", pathname, origin_file_name);
|
|
|
|
|
|
char new_ds_name[WSO_name_size_c + 1] = "";
|
|
|
char *new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
|
|
|
string newName = new_file_name;
|
|
|
if (newName.find(".PDF") == string::npos && newName.find(".pdf") == string::npos)
|
|
|
{
|
|
|
strcat(new_file_name, ".PDF");
|
|
|
}
|
|
|
printf("new_file_name: %s\n", new_file_name);
|
|
|
|
|
|
char *temp_dir = nullptr;
|
|
|
size_t s1 = 0;
|
|
|
_dupenv_s(&temp_dir, &s1, "temp");
|
|
|
|
|
|
char in_file[256] = "";
|
|
|
char out_file[256] = "";
|
|
|
strcpy_s(in_file, strlen(temp_dir) + 1, temp_dir);
|
|
|
strcpy_s(in_file, strlen("\\") + 1, "\\");
|
|
|
strcpy_s(in_file, strlen(new_file_name) + 1, new_file_name);
|
|
|
sprintf_s(out_file, 128, "%d-%s", 2, in_file);
|
|
|
IMF_export_file(ref_object, in_file);
|
|
|
|
|
|
char cmd[256] = "";
|
|
|
char *tc_root_dir = nullptr;
|
|
|
size_t s2 = 0;
|
|
|
_dupenv_s(&tc_root_dir, &s2, "tc_root");
|
|
|
strcpy_s(cmd, strlen("java -jar ") + 1, "java -jar ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(tc_root_dir) + 1, tc_root_dir);
|
|
|
strcat_s(cmd, strlen(cmd) + strlen("\\bin\\SignPdfXin.jar") + 1, "\\bin\\SignPdfXin.jar");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(" ") + 1, " ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(file_path) + 1, file_path);
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(" ") + 1, " ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(in_file) + 1, in_file);
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(" ") + 1, " ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(out_file) + 1, out_file);
|
|
|
printf("cmd: %s\n", cmd);
|
|
|
system(cmd);
|
|
|
|
|
|
tag_t new_file_tag = NULLTAG;
|
|
|
IMF_file_t file_descriptor;
|
|
|
ITKCALL(IMF_import_file(out_file, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor));
|
|
|
ITKCALL(IMF_set_original_file_name2(new_file_tag, origin_file_name));
|
|
|
ITKCALL(IMF_close_file(file_descriptor));
|
|
|
ITKCALL(AOM_save(new_file_tag));
|
|
|
ITKCALL(AOM_unlock(new_file_tag));
|
|
|
|
|
|
ITKCALL(AOM_lock(spec_dataset_rev));
|
|
|
ITKCALL(AE_remove_dataset_named_ref_by_tag2(spec_dataset_rev, ref_name, ref_object));
|
|
|
ITKCALL(AE_add_dataset_named_ref2(spec_dataset_rev, ref_name, AE_PART_OF, new_file_tag));
|
|
|
ITKCALL(AOM_save(spec_dataset_rev));
|
|
|
ITKCALL(AOM_unlock(spec_dataset_rev));
|
|
|
|
|
|
remove(in_file);
|
|
|
free(tc_root_dir);
|
|
|
free(temp_dir);
|
|
|
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
int convertToPDF(EPM_action_message_t msg)
|
|
|
{
|
|
|
int ifail = ITK_ok;
|
|
|
int attachments_cnt = 0;
|
|
|
tag_t root_task, *attachments;
|
|
|
ITKCALL(EPM_ask_root_task(msg.task, &root_task));
|
|
|
ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &attachments_cnt, &attachments));
|
|
|
if (attachments_cnt < 0)
|
|
|
{
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < attachments_cnt; i++)
|
|
|
{
|
|
|
char *name, *type;
|
|
|
int ds_cnt = 0, ref_cnt = 0;
|
|
|
tag_t type_tag, relation_type, *ds_tags, *refs;
|
|
|
|
|
|
ITKCALL(TCTYPE_ask_object_type(attachments[i], &type_tag));
|
|
|
ITKCALL(TCTYPE_ask_class_name2(type_tag, &name));
|
|
|
|
|
|
if ((strstr(name, "Revision") != NULL) || (strstr(name, "revision") != NULL))
|
|
|
{
|
|
|
ITKCALL(GRM_find_relation_type(TC_specification_rtype, &relation_type));
|
|
|
ITKCALL(GRM_list_secondary_objects_only(attachments[i], relation_type, &ds_cnt, &ds_tags));
|
|
|
for (int j = 0; j < ds_cnt; j++)
|
|
|
{
|
|
|
ITKCALL(AOM_ask_value_tags(ds_tags[j], "ref_list", &ref_cnt, &refs));
|
|
|
if (ref_cnt < 1)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
tag_t relation_type = NULLTAG;
|
|
|
ITKCALL(GRM_find_relation_type(TC_specification_rtype, &relation_type));
|
|
|
ITKCALL(AOM_ask_value_string(ds_tags[j], "object_type", &type));
|
|
|
if (stricmp(type, "MSWordX") == 0 || stricmp(type, "MSWord") == 0
|
|
|
|| stricmp(type, "MSExcelX") == 0 || stricmp(type, "MSExcel") == 0)
|
|
|
{
|
|
|
if (strcmp(type, "MSWordX") == 0)
|
|
|
{
|
|
|
startConversion(attachments[i], ds_tags[j], relation_type, "word", ".docx", "\\bin\\wordtopdf.jar");
|
|
|
}
|
|
|
else if (strcmp(type, "MSWord") == 0)
|
|
|
{
|
|
|
startConversion(attachments[i], ds_tags[j], relation_type, "word", ".doc", "\\bin\\exceltopdf.jar");
|
|
|
}
|
|
|
else if (strcmp(type, "MSExcelX") == 0)
|
|
|
{
|
|
|
startConversion(attachments[i], ds_tags[j], relation_type, "excel", ".xlsx", "\\bin\\exceltopdf.jar");
|
|
|
}
|
|
|
else if (strcmp(type, "MSExcel") == 0)
|
|
|
{
|
|
|
startConversion(attachments[i], ds_tags[j], relation_type, "excel", ".xls", "\\bin\\exceltopdf.jar");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (refs) { MEM_free(refs); type = NULL; }
|
|
|
if (type) { MEM_free(type); type = NULL; }
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void startConversion(tag_t item_rev_tag, tag_t dataset, tag_t rel_tag, char *ref_name, char *ext, char *jar_name)
|
|
|
{
|
|
|
tag_t spec_dataset_rev = NULLTAG, ref_object = NULLTAG, owner_user = NULLTAG;
|
|
|
char *ds_name = NULL;
|
|
|
AE_reference_type_t reference_type;
|
|
|
|
|
|
ITKCALL(AOM_ask_owner(dataset, &owner_user));
|
|
|
ITKCALL(AOM_ask_value_string(dataset, "object_name", &ds_name));
|
|
|
ITKCALL(AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev));
|
|
|
ITKCALL(AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object));
|
|
|
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
char *pathname = NULL;
|
|
|
char *origin_file_name = NULL;
|
|
|
ITKCALL(IMF_ask_original_file_name2(ref_object, &origin_file_name));
|
|
|
ITKCALL(IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname));
|
|
|
|
|
|
char new_ds_name[WSO_name_size_c + 1] = "";
|
|
|
char* new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
|
|
|
char* temp_dir = getenv("temp");
|
|
|
char temp_file[SS_MAXPATHLEN] = "";
|
|
|
char temp_file2[SS_MAXPATHLEN] = "\0";
|
|
|
strcpy(temp_file, temp_dir);
|
|
|
strcat(temp_file, "\\");
|
|
|
strcat(temp_file, ds_name);
|
|
|
|
|
|
if (strstr(temp_file, ".xlsx") != NULL || strstr(temp_file, ".xlsm") != NULL
|
|
|
|| strstr(temp_file, ".docx") != NULL || strstr(temp_file, ".docm") != NULL)
|
|
|
{
|
|
|
char temp_file_temp[SS_MAXPATHLEN] = "\0";
|
|
|
strncpy(temp_file_temp, temp_file, strlen(temp_file) - 5);
|
|
|
sprintf(temp_file2, "%s.pdf", temp_file_temp);
|
|
|
}
|
|
|
else if (strstr(temp_file, ".xls") != NULL || strstr(temp_file, ".doc") != NULL)
|
|
|
{
|
|
|
char temp_file_temp[SS_MAXPATHLEN] = "\0";
|
|
|
strncpy(temp_file_temp, temp_file, strlen(temp_file) - 4);
|
|
|
sprintf(temp_file2, "%s.pdf", temp_file_temp);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sprintf(temp_file2, "%s.pdf", temp_file);
|
|
|
}
|
|
|
|
|
|
IMF_export_file(ref_object, temp_file);
|
|
|
|
|
|
char cmd[256] = "";
|
|
|
char *tc_root_dir = nullptr;
|
|
|
size_t s2 = 0;
|
|
|
_dupenv_s(&tc_root_dir, &s2, "tc_root");
|
|
|
strcpy_s(cmd, strlen("java -jar ") + 1, "java -jar ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(tc_root_dir) + 1, tc_root_dir);
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(jar_name) + 1, jar_name);
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(" ") + 1, " ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(temp_file) + 1, temp_file);
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(" ") + 1, " ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(temp_file2) + 1, temp_file2);
|
|
|
printf("\n%s\n", cmd);
|
|
|
system(cmd);
|
|
|
|
|
|
for (int time_2_pdf = 0; time_2_pdf < 20; time_2_pdf++)
|
|
|
{
|
|
|
Sleep(1000);
|
|
|
if ((_access(temp_file2, 0)) != -1)
|
|
|
{
|
|
|
int size_ftp = 0;
|
|
|
struct stat buf;
|
|
|
if (stat(temp_file2, &buf) < 0)
|
|
|
{
|
|
|
printf("判断pdf大小失败\n");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
size_ftp = buf.st_size;
|
|
|
}
|
|
|
|
|
|
char new_file_temp[SS_MAXPATHLEN] = "\0";
|
|
|
if (strstr(ds_name, ".xlsx") != NULL || strstr(ds_name, ".xlsm") != NULL
|
|
|
|| strstr(ds_name, ".docx") != NULL || strstr(ds_name, ".docm") != NULL)
|
|
|
{
|
|
|
char temp_file_temp[SS_MAXPATHLEN] = "\0";
|
|
|
strncpy(temp_file_temp, ds_name, strlen(ds_name) - 5);
|
|
|
sprintf(new_file_temp, "%s.pdf", temp_file_temp);
|
|
|
sprintf(ds_name, "%s.pdf", temp_file_temp);
|
|
|
}
|
|
|
else if (strstr(ds_name, ".xls") != NULL || strstr(ds_name, ".doc") != NULL)
|
|
|
{
|
|
|
char temp_file_temp[SS_MAXPATHLEN] = "\0";
|
|
|
strncpy(temp_file_temp, ds_name, strlen(ds_name) - 4);
|
|
|
sprintf(new_file_temp, "%s.pdf", temp_file_temp);
|
|
|
sprintf(ds_name, "%s.pdf", temp_file_temp);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sprintf(new_file_temp, "%s.pdf", ds_name);
|
|
|
sprintf(ds_name, "%s.pdf", ds_name);
|
|
|
}
|
|
|
|
|
|
importPdf2(item_rev_tag, rel_tag, temp_file2, ds_name, new_file_temp, owner_user);
|
|
|
remove(temp_file);
|
|
|
remove(temp_file2);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void importPdf2(tag_t rev_tag, tag_t rel_tag, const char* pdfFile, char* datasetName, char* pdfName, tag_t owner_user) {
|
|
|
printf("---开始执行importPdf2---\n");
|
|
|
tag_t* rfTags, datasetTag = NULLTAG, relation = NULLTAG;
|
|
|
int ifail = ITK_ok, rfCount = 0;
|
|
|
char type_class[WSO_object_type_size_c + 1], *pdfDatasetName;
|
|
|
if (datasetTag == NULLTAG)
|
|
|
{
|
|
|
printf("没有找到PDF数据集%s,开始进行创建\n", datasetName);
|
|
|
tag_t pdfTypeTag = NULLTAG, tool = NULLTAG;
|
|
|
ITKCALL(AE_find_datasettype2("PDF", &pdfTypeTag));
|
|
|
ITKCALL(AE_create_dataset_with_id(pdfTypeTag, datasetName, "", "", "A", &datasetTag));
|
|
|
ITKCALL(AE_ask_datasettype_def_tool(pdfTypeTag, &tool));
|
|
|
ITKCALL(AE_set_dataset_tool(datasetTag, tool));
|
|
|
ITKCALL(AE_set_dataset_format2(datasetTag, "PDF_Reference"));
|
|
|
ITKCALL(POM_set_owning_user(datasetTag, owner_user));
|
|
|
ITKCALL(AOM_save(datasetTag));
|
|
|
if (datasetTag == NULLTAG) {
|
|
|
return;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ITKCALL(GRM_create_relation(rev_tag, datasetTag, rel_tag, NULLTAG, &relation));
|
|
|
ITKCALL(GRM_save_relation(relation));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
char* pdfFile2 = new char[255];
|
|
|
strcpy(pdfFile2, pdfFile);
|
|
|
import_dataset_file(datasetTag, "PDF_Reference", "pdf", pdfFile2, pdfName);
|
|
|
}
|
|
|
|
|
|
void import_dataset_file(tag_t dataset, char* ref_name, char* ext, char* fullfilename, char* original_name)
|
|
|
{
|
|
|
printf("---开始执行import_dataset_file---\n");
|
|
|
tag_t new_file_tag = NULLTAG;
|
|
|
IMF_file_t file_descriptor = NULL;
|
|
|
ITKCALL(AOM_refresh(dataset, FALSE));
|
|
|
|
|
|
char new_ds_name[WSO_name_size_c + 1] = "";
|
|
|
char *filename = strrchr(fullfilename, '\\') + 1;
|
|
|
char *new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
|
|
|
if (filename == NULL)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
ITKCALL(IMF_import_file(fullfilename, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor));
|
|
|
ITKCALL(IMF_set_original_file_name2(new_file_tag, original_name));
|
|
|
ITKCALL(IMF_close_file(file_descriptor));
|
|
|
ITKCALL(AOM_save(new_file_tag));
|
|
|
ITKCALL(AOM_unlock(new_file_tag));
|
|
|
ITKCALL(AOM_refresh(new_file_tag, FALSE));
|
|
|
|
|
|
ITKCALL(AOM_lock(dataset));
|
|
|
ITKCALL(AE_remove_dataset_named_ref2(dataset, ref_name));
|
|
|
ITKCALL(AE_add_dataset_named_ref2(dataset, ref_name, AE_PART_OF, new_file_tag));
|
|
|
ITKCALL(AOM_save(dataset));
|
|
|
ITKCALL(AOM_unlock(dataset));
|
|
|
ITKCALL(AOM_refresh(dataset, FALSE));
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
}
|
|
|
|
|
|
|
|
|
void singoff_picture_date(tag_t item_rev_tag, tag_t dataset, tag_t rel_tag, char* ref_name, char* ext, char* jar_name, char* dat_file, char* date, string method, string isSignDate)
|
|
|
{
|
|
|
printf("------> singoff_picture_date start......\n");
|
|
|
tag_t spec_dataset_rev = NULLTAG, ref_object = NULLTAG, owner_user = NULLTAG;
|
|
|
char* ds_name = NULL;
|
|
|
AE_reference_type_t reference_type;
|
|
|
|
|
|
ITKCALL(AOM_ask_owner(dataset, &owner_user));
|
|
|
ITKCALL(AOM_ask_value_string(dataset, "object_name", &ds_name));
|
|
|
ITKCALL(AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev));
|
|
|
ITKCALL(AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object));
|
|
|
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
char* pathname = NULL;
|
|
|
char* origin_file_name = NULL;
|
|
|
ITKCALL(IMF_ask_original_file_name2(ref_object, &origin_file_name));
|
|
|
ITKCALL(IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname));
|
|
|
|
|
|
char new_ds_name2[WSO_name_size_c + 1] = "";
|
|
|
char* new_file_name2 = USER_new_file_name(new_ds_name2, ref_name, ext, 0);
|
|
|
string newName = new_file_name2;
|
|
|
if (newName.find(".PDF") == string::npos && newName.find(".pdf") == string::npos)
|
|
|
{
|
|
|
strcat(new_file_name2, ".PDF");
|
|
|
}
|
|
|
printf("new_file_name: %s\n", new_file_name2);
|
|
|
|
|
|
char* temp_dir = getenv("temp");
|
|
|
char temp_file[SS_MAXPATHLEN + 1] = "";
|
|
|
char temp_file2[SS_MAXPATHLEN + 1] = "";
|
|
|
strcpy_s(temp_file, strlen(temp_file) + strlen(temp_dir) + 1, temp_dir);
|
|
|
strcat_s(temp_file, strlen(temp_file) + strlen("\\") + 1, "\\");
|
|
|
strcat_s(temp_file, strlen(temp_file) + strlen(new_file_name2) + 1, new_file_name2);
|
|
|
if (_access(temp_file, 0) != -1)
|
|
|
{
|
|
|
remove(temp_file);
|
|
|
}
|
|
|
printf("temp_file = %s\n", temp_file);
|
|
|
IMF_export_file(ref_object, temp_file);
|
|
|
|
|
|
char cmd[512] = "";
|
|
|
char* tc_root_dir = nullptr;
|
|
|
size_t s2 = 0;
|
|
|
_dupenv_s(&tc_root_dir, &s2, "tc_root");
|
|
|
// 先添加 "java -jar "
|
|
|
strcpy_s(cmd, strlen(cmd) + strlen("java -jar ") + 1, "java -jar ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(tc_root_dir) + 1, tc_root_dir);
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(jar_name) + 1, jar_name);
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(" ") + 1, " ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(temp_file) + 1, temp_file);
|
|
|
if (strcmp(ref_name, "PDF_Reference") == 0)
|
|
|
{
|
|
|
char out_file_name[128] = "";
|
|
|
sprintf_s(out_file_name, 128, "%d-%s", 2, new_file_name2);
|
|
|
|
|
|
char* tc_data_dir = getenv("temp");
|
|
|
strcpy_s(temp_file2, strlen(temp_file2) + strlen(tc_data_dir) + 1, tc_data_dir);
|
|
|
strcat_s(temp_file2, strlen(temp_file2) + strlen("\\") + 1, "\\");
|
|
|
strcat_s(temp_file2, strlen(temp_file2) + strlen(out_file_name) + 1, out_file_name);
|
|
|
printf("temp_file2 = %s\n", temp_file2);
|
|
|
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(" ") + 1, " ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(temp_file2) + 1, temp_file2);
|
|
|
if (_access(temp_file2, 0) != -1)
|
|
|
{
|
|
|
remove(temp_file2);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(" ") + 1, " ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(dat_file) + 1, dat_file);
|
|
|
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(" ") + 1, " ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(date) + 1, date);
|
|
|
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(" ") + 1, " ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(method.c_str()) + 1, method.c_str());
|
|
|
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(" ") + 1, " ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(isSignDate.c_str()) + 1, isSignDate.c_str());
|
|
|
printf("%s\n", cmd);
|
|
|
system(cmd);
|
|
|
|
|
|
char new_ds_name[WSO_name_size_c + 1] = "";
|
|
|
char* filename = strrchr(temp_file, '\\') + 1;
|
|
|
char* new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
|
|
|
tag_t new_file_tag = NULLTAG;
|
|
|
IMF_file_t file_descriptor = NULL;
|
|
|
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
if (strcmp(ref_name, "PDF_Reference") == 0)
|
|
|
{
|
|
|
ITKCALL(IMF_import_file(temp_file2, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ITKCALL(IMF_import_file(temp_file, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor));
|
|
|
}
|
|
|
|
|
|
string newDsName = ds_name;
|
|
|
if (newDsName.find(".PDF") == string::npos && newDsName.find(".pdf") == string::npos)
|
|
|
{
|
|
|
strcat(ds_name, ".PDF");
|
|
|
}
|
|
|
char fileName[128] = "";
|
|
|
if (newDsName.find("/") != string::npos)
|
|
|
{
|
|
|
string prefix = newDsName.substr(0, newDsName.find("/"));
|
|
|
string suffix = newDsName.substr(newDsName.find("/") + 1);
|
|
|
strcpy(fileName, prefix.c_str());
|
|
|
strcat(fileName, "_");
|
|
|
strcat(fileName, suffix.c_str());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strcpy(fileName, ds_name);
|
|
|
}
|
|
|
ITKCALL(IMF_set_original_file_name2(new_file_tag, fileName));
|
|
|
ITKCALL(IMF_close_file(file_descriptor));
|
|
|
ITKCALL(AOM_save(new_file_tag));
|
|
|
ITKCALL(AOM_unlock(new_file_tag));
|
|
|
ITKCALL(AOM_refresh(new_file_tag, FALSE));
|
|
|
|
|
|
ITKCALL(AOM_lock(dataset));
|
|
|
ITKCALL(AE_remove_dataset_named_ref2(dataset, ref_name));
|
|
|
ITKCALL(AE_add_dataset_named_ref2(dataset, ref_name, AE_PART_OF, new_file_tag));
|
|
|
ITKCALL(AOM_save(dataset));
|
|
|
ITKCALL(AOM_unlock(dataset));
|
|
|
ITKCALL(AOM_refresh(dataset, FALSE));
|
|
|
|
|
|
remove(temp_file);
|
|
|
if (strcmp(ref_name, "PDF_Reference") == 0)
|
|
|
{
|
|
|
remove(temp_file2);
|
|
|
}
|
|
|
printf("数据集路径 = %s\n", temp_file);
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int SB_controlled_Lao(EPM_action_message_t msg)
|
|
|
{
|
|
|
printf("SB_controlled_Lao start......\n");
|
|
|
int ifail = ITK_ok, args_num = 0, sub_task_cnt = 0, attachments_cnt = 0, pref_cnt=0;
|
|
|
tag_t root_task, *sub_tasks, *attachments;
|
|
|
char *task_name;
|
|
|
|
|
|
ITKCALL(EPM_ask_root_task(msg.task, &root_task));
|
|
|
ITKCALL(WSOM_ask_name2(msg.task, &task_name));
|
|
|
ITKCALL(EPM_ask_sub_tasks(root_task, &sub_task_cnt, &sub_tasks));
|
|
|
ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &attachments_cnt, &attachments));
|
|
|
args_num = TC_number_of_arguments(msg.arguments);
|
|
|
if (attachments_cnt < 0 || args_num < 1)
|
|
|
{
|
|
|
return ifail;
|
|
|
}
|
|
|
char *args_value, *para_name, *para_value;
|
|
|
TC_init_argument_list(msg.arguments);
|
|
|
args_value = TC_next_argument(msg.arguments);
|
|
|
ITKCALL(ITK_ask_argument_named_value(args_value, ¶_name, ¶_value));
|
|
|
if (tc_strcmp(para_name, "UID") != 0)
|
|
|
{
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
char** referList;
|
|
|
int num;
|
|
|
PREF_ask_char_values("SB6_controlled_Date", &num, &referList);
|
|
|
string method = "";
|
|
|
string isSignDate = "";
|
|
|
printf("当前配置的UID: %s\n", para_value);
|
|
|
for (int i = 0; i < num; i++)
|
|
|
{
|
|
|
std::vector<std::string> dateVector;
|
|
|
getVector(referList[i], dateVector, '=');
|
|
|
printf("====》%s\n", dateVector[0]);
|
|
|
if (dateVector.size() == 3 && tc_strcmp(dateVector[0].c_str(),para_value)== 0) {
|
|
|
method = dateVector[1];
|
|
|
isSignDate = dateVector[2];
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (method.empty() && isSignDate.empty()) {
|
|
|
printf("SB6_controlled_Date not found\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
tag_t dataset = NULLTAG,spec_dataset_rev = NULLTAG, ref_object = NULLTAG, owner_user = NULLTAG;
|
|
|
char *ds_name = NULL;
|
|
|
AE_reference_type_t reference_type;
|
|
|
ITK__convert_uid_to_tag(para_value, &dataset);
|
|
|
ITKCALL(AOM_ask_owner(dataset, &owner_user));
|
|
|
ITKCALL(AOM_ask_value_string(dataset, "object_name", &ds_name));
|
|
|
ITKCALL(AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev));
|
|
|
ITKCALL(AE_ask_dataset_named_ref2(spec_dataset_rev, "Image", &reference_type, &ref_object));
|
|
|
|
|
|
char* temp_dir = getenv("temp");
|
|
|
char pitcure_file[SS_MAXPATHLEN + 1] = "";
|
|
|
strcpy_s(pitcure_file, strlen(pitcure_file) + strlen(temp_dir) + 1, temp_dir);
|
|
|
strcat_s(pitcure_file, strlen(pitcure_file) + strlen("\\") + 1, "\\");
|
|
|
strcat_s(pitcure_file, strlen(pitcure_file) + strlen(ds_name) + 1, ds_name);
|
|
|
if (_access(pitcure_file, 0) != -1)
|
|
|
{
|
|
|
remove(pitcure_file);
|
|
|
}
|
|
|
ITKCALL(IMF_export_file(ref_object, pitcure_file));
|
|
|
printf("图片 = %s\n", pitcure_file);
|
|
|
|
|
|
char *dir = NULL;
|
|
|
char content[256] = "", buf[64] = "", info_path[256] = "";
|
|
|
time_t t = NULL;
|
|
|
size_t buffer_cnt = 32;
|
|
|
tm *local;
|
|
|
FILE *fw, *fw2;
|
|
|
|
|
|
_dupenv_s(&dir, &buffer_cnt, "temp");
|
|
|
local = new tm();
|
|
|
t = time(NULL);
|
|
|
localtime_s(local, &t);
|
|
|
strftime(buf, 64, "%Y-%m-%d-%H-%M-%S.dat", local);
|
|
|
|
|
|
if (dir[strlen(dir) - 1] == '\\')
|
|
|
{
|
|
|
sprintf_s(info_path, "%s%s", dir, buf);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sprintf_s(info_path, "%s\\%s", dir, buf);
|
|
|
}
|
|
|
if (_access(info_path, 0) != -1)
|
|
|
{
|
|
|
remove(info_path);
|
|
|
}
|
|
|
if (fopen_s(&fw, info_path, "a+") == 0)
|
|
|
{
|
|
|
//strcat_s(content, strlen(content) + strlen("受控章=") + 1, "受控章=");
|
|
|
strcat_s(content, strlen(content) + strlen(task_name) + 1, task_name);
|
|
|
strcat_s(content, strlen(content) + strlen("=") + 1, "=");
|
|
|
strcat_s(content, strlen(content) + strlen(pitcure_file) + 1, pitcure_file);
|
|
|
fwrite(content, sizeof(char), strlen(content), fw);
|
|
|
fclose(fw);
|
|
|
}
|
|
|
if (local != NULL)
|
|
|
{
|
|
|
delete local;
|
|
|
local = NULL;
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < attachments_cnt; i++)
|
|
|
{
|
|
|
char *name, *type;
|
|
|
int ds_cnt = 0, ref_cnt = 0, form_cnt =0 ;
|
|
|
tag_t type_tag, relation_type, *ds_tags, *refs, *forms;
|
|
|
|
|
|
ITKCALL(TCTYPE_ask_object_type(attachments[i], &type_tag));
|
|
|
ITKCALL(TCTYPE_ask_class_name2(type_tag, &name));
|
|
|
|
|
|
if ((strstr(name, "Revision") != NULL) || (strstr(name, "revision") != NULL))
|
|
|
{
|
|
|
|
|
|
ITKCALL(AOM_ask_value_tags(attachments[i], "IMAN_master_form_rev", &form_cnt, &forms));
|
|
|
date_t date_value;
|
|
|
char* date_str;
|
|
|
ITKCALL(ifail = AOM_ask_value_date(forms[0], "sb6_DRM25", &date_value));
|
|
|
ITKCALL(ifail = DATE_date_to_string(date_value, "%Y-%m-%d", &date_str));
|
|
|
printf("--date_str=%s\n", date_str);
|
|
|
|
|
|
ITKCALL(GRM_find_relation_type(TC_specification_rtype, &relation_type));
|
|
|
ITKCALL(GRM_list_secondary_objects_only(attachments[i], relation_type, &ds_cnt, &ds_tags));
|
|
|
for (int j = 0; j < ds_cnt; j++)
|
|
|
{
|
|
|
ITKCALL(AOM_ask_value_tags(ds_tags[j], "ref_list", &ref_cnt, &refs));
|
|
|
if (ref_cnt < 1)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
tag_t relation_type = NULLTAG;
|
|
|
ITKCALL(GRM_find_relation_type(TC_specification_rtype, &relation_type));
|
|
|
ITKCALL(AOM_ask_value_string(ds_tags[j], "object_type", &type));
|
|
|
if (stricmp(type, "MSWordX") == 0 || stricmp(type, "MSWord") == 0
|
|
|
|| stricmp(type, "MSExcelX") == 0 || stricmp(type, "MSExcel") == 0
|
|
|
|| stricmp(type, "PDF") == 0)
|
|
|
{
|
|
|
if (strcmp(type, "MSWordX") == 0)
|
|
|
{
|
|
|
printf("--MSWordX--\n");
|
|
|
singoff_picture(attachments[i], ds_tags[j], relation_type, "word", ".docx", "\\bin\\SBControlled\\SubstMacros-MSWord.wsf ", info_path);
|
|
|
}
|
|
|
else if (strcmp(type, "MSWord") == 0)
|
|
|
{
|
|
|
printf("--MSWord--\n");
|
|
|
singoff_picture(attachments[i], ds_tags[j], relation_type, "word", ".doc", "\\bin\\SBControlled\\SubstMacros-MSWord.wsf", info_path);
|
|
|
}
|
|
|
else if (strcmp(type, "MSExcelX") == 0)
|
|
|
{
|
|
|
printf("--MSExcelX--\n");
|
|
|
singoff_picture(attachments[i], ds_tags[j], relation_type, "excel", ".xlsx", "\\bin\\SBControlled\\SubstMacros-MSExcel.wsf ", info_path);
|
|
|
}
|
|
|
else if (strcmp(type, "MSExcel") == 0)
|
|
|
{
|
|
|
printf("--MSExcel--\n");
|
|
|
singoff_picture(attachments[i], ds_tags[j], relation_type, "excel", ".xls", "\\bin\\SBControlled\\SubstMacros-MSExcel.wsf ", info_path);
|
|
|
}
|
|
|
else if (strcmp(type, "PDF") == 0)
|
|
|
{
|
|
|
printf("--PDF--\n");
|
|
|
singoff_picture_date(attachments[i], ds_tags[j], relation_type, "PDF_Reference", ".pdf", "\\bin\\SignLaoImage.jar ", info_path, date_str, method, isSignDate);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (refs) { MEM_free(refs); type = NULL; }
|
|
|
if (type) { MEM_free(type); type = NULL; }
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
remove(pitcure_file);
|
|
|
remove(info_path);
|
|
|
printf("SB_controlled_Lao end......\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
|
|
|
int SB_controlled_Xin(EPM_action_message_t msg)
|
|
|
{
|
|
|
printf("SB_controlled_Xin start......\n");
|
|
|
int ifail = ITK_ok, args_num = 0, sub_task_cnt = 0, attachments_cnt = 0, pref_cnt = 0;
|
|
|
tag_t root_task, *sub_tasks, *attachments;
|
|
|
|
|
|
ITKCALL(EPM_ask_root_task(msg.task, &root_task));
|
|
|
ITKCALL(EPM_ask_sub_tasks(root_task, &sub_task_cnt, &sub_tasks));
|
|
|
ITKCALL(EPM_ask_attachments(root_task, EPM_target_attachment, &attachments_cnt, &attachments));
|
|
|
args_num = TC_number_of_arguments(msg.arguments);
|
|
|
if (attachments_cnt < 0 || args_num < 1)
|
|
|
{
|
|
|
return ifail;
|
|
|
}
|
|
|
char *args_value, *para_name, *para_value;
|
|
|
TC_init_argument_list(msg.arguments);
|
|
|
args_value = TC_next_argument(msg.arguments);
|
|
|
ITKCALL(ITK_ask_argument_named_value(args_value, ¶_name, ¶_value));
|
|
|
if (tc_strcmp(para_name, "UID") != 0)
|
|
|
{
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
char** referList;
|
|
|
int num;
|
|
|
PREF_ask_char_values("SB6_controlled_Date", &num, &referList);
|
|
|
string method = "";
|
|
|
string isSignDate = "";
|
|
|
for (int i = 0; i < num; i++)
|
|
|
{
|
|
|
std::vector<std::string> dateVector;
|
|
|
getVector(referList[i], dateVector, '=');
|
|
|
if (dateVector.size() == 3 && dateVector[0] == para_value) {
|
|
|
method = dateVector[1];
|
|
|
isSignDate = dateVector[2];
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
tag_t dataset = NULLTAG, spec_dataset_rev = NULLTAG, ref_object = NULLTAG, owner_user = NULLTAG;
|
|
|
char *ds_name = NULL;
|
|
|
AE_reference_type_t reference_type;
|
|
|
ITK__convert_uid_to_tag(para_value, &dataset);
|
|
|
ITKCALL(AOM_ask_owner(dataset, &owner_user));
|
|
|
ITKCALL(AOM_ask_value_string(dataset, "object_name", &ds_name));
|
|
|
ITKCALL(AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev));
|
|
|
ITKCALL(AE_ask_dataset_named_ref2(spec_dataset_rev, "Image", &reference_type, &ref_object));
|
|
|
|
|
|
char* temp_dir = getenv("temp");
|
|
|
char pitcure_file[SS_MAXPATHLEN + 1] = "";
|
|
|
strcpy_s(pitcure_file, strlen(pitcure_file) + strlen(temp_dir) + 1, temp_dir);
|
|
|
strcat_s(pitcure_file, strlen(pitcure_file) + strlen("\\") + 1, "\\");
|
|
|
strcat_s(pitcure_file, strlen(pitcure_file) + strlen(ds_name) + 1, ds_name);
|
|
|
if (_access(pitcure_file, 0) != -1)
|
|
|
{
|
|
|
remove(pitcure_file);
|
|
|
}
|
|
|
ITKCALL(IMF_export_file(ref_object, pitcure_file));
|
|
|
printf("图片 = %s\n", pitcure_file);
|
|
|
|
|
|
char *dir = NULL;
|
|
|
char content[256] = "", buf[64] = "", info_path[256] = "";
|
|
|
time_t t = NULL;
|
|
|
size_t buffer_cnt = 32;
|
|
|
tm *local;
|
|
|
FILE *fw, *fw2;
|
|
|
|
|
|
_dupenv_s(&dir, &buffer_cnt, "temp");
|
|
|
local = new tm();
|
|
|
t = time(NULL);
|
|
|
localtime_s(local, &t);
|
|
|
strftime(buf, 64, "%Y-%m-%d-%H-%M-%S.dat", local);
|
|
|
|
|
|
if (dir[strlen(dir) - 1] == '\\')
|
|
|
{
|
|
|
sprintf_s(info_path, "%s%s", dir, buf);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sprintf_s(info_path, "%s\\%s", dir, buf);
|
|
|
}
|
|
|
if (_access(info_path, 0) != -1)
|
|
|
{
|
|
|
remove(info_path);
|
|
|
}
|
|
|
if (fopen_s(&fw, info_path, "a+") == 0)
|
|
|
{
|
|
|
strcat_s(content, strlen(content) + strlen("受控章=") + 1, "受控章=");
|
|
|
strcat_s(content, strlen(content) + strlen(pitcure_file) + 1, pitcure_file);
|
|
|
fwrite(content, sizeof(char), strlen(content), fw);
|
|
|
fclose(fw);
|
|
|
}
|
|
|
if (local != NULL)
|
|
|
{
|
|
|
delete local;
|
|
|
local = NULL;
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < attachments_cnt; i++)
|
|
|
{
|
|
|
char *name, *type;
|
|
|
int ds_cnt = 0, ref_cnt = 0,form_cnt = 0;
|
|
|
tag_t type_tag, relation_type, *ds_tags, *refs, * forms;
|
|
|
|
|
|
ITKCALL(TCTYPE_ask_object_type(attachments[i], &type_tag));
|
|
|
ITKCALL(TCTYPE_ask_class_name2(type_tag, &name));
|
|
|
|
|
|
if ((strstr(name, "Revision") != NULL) || (strstr(name, "revision") != NULL))
|
|
|
{
|
|
|
|
|
|
ITKCALL(AOM_ask_value_tags(attachments[i], "IMAN_master_form_rev", &form_cnt, &forms));
|
|
|
date_t date_value;
|
|
|
char* date_str;
|
|
|
ITKCALL(ifail = AOM_ask_value_date(forms[0], "sb6_DRM25", &date_value));
|
|
|
ITKCALL(ifail = DATE_date_to_string(date_value, "%Y-%m-%d", &date_str));
|
|
|
printf("--date_str=%s\n", date_str);
|
|
|
|
|
|
ITKCALL(GRM_find_relation_type(TC_specification_rtype, &relation_type));
|
|
|
ITKCALL(GRM_list_secondary_objects_only(attachments[i], relation_type, &ds_cnt, &ds_tags));
|
|
|
for (int j = 0; j < ds_cnt; j++)
|
|
|
{
|
|
|
ITKCALL(AOM_ask_value_tags(ds_tags[j], "ref_list", &ref_cnt, &refs));
|
|
|
if (ref_cnt < 1)
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
tag_t relation_type = NULLTAG;
|
|
|
ITKCALL(GRM_find_relation_type(TC_specification_rtype, &relation_type));
|
|
|
ITKCALL(AOM_ask_value_string(ds_tags[j], "object_type", &type));
|
|
|
if (stricmp(type, "MSWordX") == 0 || stricmp(type, "MSWord") == 0
|
|
|
|| stricmp(type, "MSExcelX") == 0 || stricmp(type, "MSExcel") == 0
|
|
|
|| stricmp(type, "PDF") == 0)
|
|
|
{
|
|
|
if (strcmp(type, "MSWordX") == 0)
|
|
|
{
|
|
|
printf("--MSWordX--\n");
|
|
|
singoff_picture(attachments[i], ds_tags[j], relation_type, "word", ".docx", "\\bin\\SBControlled\\SubstMacros-MSWord.wsf ", info_path);
|
|
|
}
|
|
|
else if (strcmp(type, "MSWord") == 0)
|
|
|
{
|
|
|
singoff_picture(attachments[i], ds_tags[j], relation_type, "word", ".doc", "\\bin\\SBControlled\\SubstMacros-MSWord.wsf", info_path);
|
|
|
}
|
|
|
else if (strcmp(type, "MSExcelX") == 0)
|
|
|
{
|
|
|
printf("--MSExcelX--\n");
|
|
|
singoff_picture(attachments[i], ds_tags[j], relation_type, "excel", ".xlsx", "\\bin\\SBControlled\\SubstMacros-MSExcel.wsf ", info_path);
|
|
|
}
|
|
|
else if (strcmp(type, "MSExcel") == 0)
|
|
|
{
|
|
|
singoff_picture(attachments[i], ds_tags[j], relation_type, "excel", ".xls", "\\bin\\SBControlled\\SubstMacros-MSExcel.wsf ", info_path);
|
|
|
}
|
|
|
else if (strcmp(type, "PDF") == 0)
|
|
|
{
|
|
|
singoff_picture_date(attachments[i], ds_tags[j], relation_type, "PDF_Reference", ".pdf", "\\bin\\SignXinImage.jar ", info_path, date_str,method,isSignDate);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (refs) { MEM_free(refs); type = NULL; }
|
|
|
if (type) { MEM_free(type); type = NULL; }
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
remove(pitcure_file);
|
|
|
remove(info_path);
|
|
|
printf("SB_controlled_Xin end......\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
void singoff_picture(tag_t item_rev_tag, tag_t dataset, tag_t rel_tag, char *ref_name, char *ext, char *jar_name, char *dat_file)
|
|
|
{
|
|
|
printf("singoff_picture start......\n");
|
|
|
tag_t spec_dataset_rev = NULLTAG, ref_object = NULLTAG, owner_user = NULLTAG;
|
|
|
char *ds_name = NULL;
|
|
|
AE_reference_type_t reference_type;
|
|
|
|
|
|
ITKCALL(AOM_ask_owner(dataset, &owner_user));
|
|
|
ITKCALL(AOM_ask_value_string(dataset, "object_name", &ds_name));
|
|
|
ITKCALL(AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev));
|
|
|
ITKCALL(AE_ask_dataset_named_ref2(spec_dataset_rev, ref_name, &reference_type, &ref_object));
|
|
|
|
|
|
if (reference_type == AE_PART_OF)
|
|
|
{
|
|
|
char *pathname = NULL;
|
|
|
char *origin_file_name = NULL;
|
|
|
ITKCALL(IMF_ask_original_file_name2(ref_object, &origin_file_name));
|
|
|
ITKCALL(IMF_ask_file_pathname2(ref_object, SS_WNT_MACHINE, &pathname));
|
|
|
|
|
|
char new_ds_name2[WSO_name_size_c + 1] = "";
|
|
|
char *new_file_name2 = USER_new_file_name(new_ds_name2, ref_name, ext, 0);
|
|
|
string newName = new_file_name2;
|
|
|
if (newName.find(".PDF") == string::npos && newName.find(".pdf") == string::npos)
|
|
|
{
|
|
|
strcat(new_file_name2, ".PDF");
|
|
|
}
|
|
|
printf("new_file_name: %s\n", new_file_name2);
|
|
|
|
|
|
char* temp_dir = getenv("temp");
|
|
|
char temp_file[SS_MAXPATHLEN + 1] = "";
|
|
|
char temp_file2[SS_MAXPATHLEN + 1] = "";
|
|
|
strcpy_s(temp_file, strlen(temp_file) + strlen(temp_dir) + 1, temp_dir);
|
|
|
strcat_s(temp_file, strlen(temp_file) + strlen("\\") + 1, "\\");
|
|
|
strcat_s(temp_file, strlen(temp_file) + strlen(new_file_name2) + 1, new_file_name2);
|
|
|
if (_access(temp_file, 0) != -1)
|
|
|
{
|
|
|
remove(temp_file);
|
|
|
}
|
|
|
printf("temp_file = %s\n", temp_file);
|
|
|
IMF_export_file(ref_object, temp_file);
|
|
|
|
|
|
char cmd[512] = "";
|
|
|
char *tc_root_dir = nullptr;
|
|
|
size_t s2 = 0;
|
|
|
_dupenv_s(&tc_root_dir, &s2, "tc_root");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(tc_root_dir) + 1, tc_root_dir);
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(jar_name) + 1, jar_name);
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(" ") + 1, " ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(temp_file) + 1, temp_file);
|
|
|
if (strcmp(ref_name, "PDF_Reference") == 0)
|
|
|
{
|
|
|
char out_file_name[128] = "";
|
|
|
sprintf_s(out_file_name, 128, "%d-%s", 2, new_file_name2);
|
|
|
|
|
|
char *tc_data_dir = getenv("temp");
|
|
|
strcpy_s(temp_file2, strlen(temp_file2) + strlen(tc_data_dir) + 1, tc_data_dir);
|
|
|
strcat_s(temp_file2, strlen(temp_file2) + strlen("\\") + 1, "\\");
|
|
|
strcat_s(temp_file2, strlen(temp_file2) + strlen(out_file_name) + 1, out_file_name);
|
|
|
printf("temp_file2 = %s\n", temp_file2);
|
|
|
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(" ") + 1, " ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(temp_file2) + 1, temp_file2);
|
|
|
if (_access(temp_file2, 0) != -1)
|
|
|
{
|
|
|
remove(temp_file2);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(" ") + 1, " ");
|
|
|
strcat_s(cmd, strlen(cmd) + strlen(dat_file) + 1, dat_file);
|
|
|
printf("%s\n",cmd);
|
|
|
system(cmd);
|
|
|
|
|
|
char new_ds_name[WSO_name_size_c + 1] = "";
|
|
|
char *filename = strrchr(temp_file, '\\') + 1;
|
|
|
char *new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
|
|
|
tag_t new_file_tag = NULLTAG;
|
|
|
IMF_file_t file_descriptor = NULL;
|
|
|
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
if (strcmp(ref_name, "PDF_Reference") == 0)
|
|
|
{
|
|
|
ITKCALL(IMF_import_file(temp_file2, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ITKCALL(IMF_import_file(temp_file, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor));
|
|
|
}
|
|
|
|
|
|
string newDsName = ds_name;
|
|
|
if (newDsName.find(".PDF") == string::npos && newDsName.find(".pdf") == string::npos)
|
|
|
{
|
|
|
strcat(ds_name, ".PDF");
|
|
|
}
|
|
|
char fileName[128] = "";
|
|
|
if (newDsName.find("/") != string::npos)
|
|
|
{
|
|
|
string prefix = newDsName.substr(0, newDsName.find("/"));
|
|
|
string suffix = newDsName.substr(newDsName.find("/") + 1);
|
|
|
strcpy(fileName, prefix.c_str());
|
|
|
strcat(fileName, "_");
|
|
|
strcat(fileName, suffix.c_str());
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strcpy(fileName, ds_name);
|
|
|
}
|
|
|
ITKCALL(IMF_set_original_file_name2(new_file_tag, fileName));
|
|
|
ITKCALL(IMF_close_file(file_descriptor));
|
|
|
ITKCALL(AOM_save(new_file_tag));
|
|
|
ITKCALL(AOM_unlock(new_file_tag));
|
|
|
ITKCALL(AOM_refresh(new_file_tag, FALSE));
|
|
|
|
|
|
ITKCALL(AOM_lock(dataset));
|
|
|
ITKCALL(AE_remove_dataset_named_ref2(dataset, ref_name));
|
|
|
ITKCALL(AE_add_dataset_named_ref2(dataset, ref_name, AE_PART_OF, new_file_tag));
|
|
|
ITKCALL(AOM_save(dataset));
|
|
|
ITKCALL(AOM_unlock(dataset));
|
|
|
ITKCALL(AOM_refresh(dataset, FALSE));
|
|
|
|
|
|
remove(temp_file);
|
|
|
if (strcmp(ref_name, "PDF_Reference") == 0)
|
|
|
{
|
|
|
remove(temp_file2);
|
|
|
}
|
|
|
printf("数据集路径 = %s\n",temp_file);
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
|
|
|
}
|
|
|
}
|