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

106 lines
3.0 KiB

#define _CRT_SECURE_NO_WARNINGS
#include "epm_handler_common.h"
int ML_HaveDataSet(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 resultString[1024] = "";
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;
}
//判断表示下的对象是否包含三维图纸
bool result = true;
int itemNum = 0;
tag_t * itemTags = NULLTAG;
/*AOM_ask_value_tags(attachments[i], "representation_for", &itemNum, &itemTags);
if (itemNum <= 0)
{
result = false;
ifail = 1;
}
for (int j = 0; j < itemNum; j++)
{*/
char *itemString = NULL;
AOM_ask_value_string(attachments[i], "object_string", &itemString);
//获取数据集
int dataSetNum = 0;
tag_t dataTags = NULLTAG;
AOM_ask_value_tags(attachments[i], "IMAN_specification", &itemNum, &itemTags);
bool isOk = false;
for (int k = 0; k < itemNum; k++)
{
char *dataType = NULL;
AOM_ask_value_string(itemTags[k], "object_type", &dataType);
printf("dataType : %s \r\n", dataType);
if (strcmp(dataType, "UGMASTER") == 0)
{
//判断是否包含文件
tag_t spec_dataset_rev = NULLTAG;
AE_ask_dataset_latest_rev(itemTags[k], &spec_dataset_rev);
AE_reference_type_t reference_type;
tag_t ref_obj = NULLTAG;
AE_ask_dataset_named_ref2(spec_dataset_rev, "UGPART", &reference_type, &ref_obj);
if (ref_obj != NULLTAG)
{
isOk = true;
}
}
DOFREE(dataType);
}
if (!isOk)
{
strcat(resultString, itemString);
//strcat(resultString, "\n");
result = false;
ifail = 1;
}
DOFREE(itemString);
//}
DOFREE(itemType);
DOFREE(itemTags);
}
DOFREE(attachments);
if (ifail == 1)
{
strcat(resultString, "下不包含三维数据集!");
EMH_store_error_s1(EMH_severity_user_error, EMH_USER_error_base, resultString);
}
auto stopTime = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stopTime - startTime);
//std::cout << "ML_HaveDataSet用时:" << duration.count() / 1000 << std::endl;
string usetime = "ML_HaveDataSet用时:";
usetime.append(std::to_string(duration.count() / 1000));
WriteLog(true, usetime.c_str());
printf("=========================判断是否包含三维数据集 End===================\n");
return ifail;
}