|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
|
#include "epm_handler_common.h"
|
|
|
|
|
|
int ML_ChangeItemFolder(EPM_action_message_t msg)
|
|
|
{
|
|
|
printf("=========================更改对象文件夹 Start===================\n");
|
|
|
auto startTime = std::chrono::high_resolution_clock::now();
|
|
|
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);
|
|
|
|
|
|
char *argflag = NULL, *argvalue = NULL, *arg = NULL;
|
|
|
char arg1value[1024] = "", arg2value[1024] = "";
|
|
|
//获取参数
|
|
|
int arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
printf("参数个数为:%d\n", arg_cnt);
|
|
|
if (arg_cnt > 0)
|
|
|
{
|
|
|
for (int i = 0; i<arg_cnt; i++)
|
|
|
{
|
|
|
//获取下一个参数(从0开始)
|
|
|
arg = TC_next_argument(msg.arguments);
|
|
|
//获取参数的名称和值
|
|
|
ifail = ITK_ask_argument_named_value((const char*)arg, &argflag, &argvalue);
|
|
|
if (stricmp(argflag, "from") == 0)
|
|
|
{
|
|
|
//strcmp("","");
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(arg1value, argvalue);
|
|
|
}
|
|
|
}
|
|
|
else if (stricmp(argflag, "to") == 0)
|
|
|
{
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(arg2value, argvalue);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < attachments_num; i++)
|
|
|
{
|
|
|
char *itemType = NULL;
|
|
|
|
|
|
AOM_ask_value_string(attachments[i], "object_type", &itemType);
|
|
|
printf("type_class : %s \r\n", itemType);
|
|
|
//过滤掉非版本的对象
|
|
|
if ((strstr(itemType, "Revision") == NULL) || (strstr(itemType, "Master") != NULL)
|
|
|
|| (strstr(itemType, "master") != NULL) || (strstr(itemType, "BOM") != NULL) || (strstr(itemType, "bom") != NULL) || (strstr(itemType, "Bom") != NULL))
|
|
|
{
|
|
|
DOFREE(itemType);
|
|
|
continue;
|
|
|
}
|
|
|
int num = 0;
|
|
|
tag_t * value = NULLTAG;
|
|
|
int folderNum = 0;
|
|
|
tag_t * folderValue = NULLTAG;
|
|
|
AOM_ask_value_tags(attachments[i], arg1value, &num, &value);
|
|
|
//获取文件夹
|
|
|
AOM_ask_value_tags(attachments[i], arg2value, &folderNum, &folderValue);
|
|
|
if (num > 0 && folderNum > 0)
|
|
|
{
|
|
|
for (int j = 0; j < num; j++)
|
|
|
{
|
|
|
FL_insert(folderValue[0], value[j], 999);
|
|
|
}
|
|
|
AOM_save_with_extensions(folderValue[0]);
|
|
|
AOM_refresh(folderValue[0], TRUE);
|
|
|
}
|
|
|
DOFREE(value);
|
|
|
DOFREE(folderValue);
|
|
|
DOFREE(itemType);
|
|
|
}
|
|
|
DOFREE(attachments);
|
|
|
|
|
|
auto stopTime = std::chrono::high_resolution_clock::now();
|
|
|
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stopTime - startTime);
|
|
|
//std::cout << "ML_ChangeItemFolder用时:" << duration.count() / 1000 << std::endl;
|
|
|
string usetime = "ML_ChangeItemFolder用时:";
|
|
|
usetime.append(std::to_string(duration.count() / 1000));
|
|
|
WriteLog(true, usetime.c_str());
|
|
|
printf("=========================更改对象文件夹 End===================\n");
|
|
|
return ifail;
|
|
|
} |