|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
|
#include "epm_handler_common.h"
|
|
|
|
|
|
boolean IsRelease(tag_t topLine, char resultString[], vector<char *> referenceValues, char releaseStatus[1024]);
|
|
|
|
|
|
int ML_ChildIsRelease(EPM_action_message_t msg){
|
|
|
printf("=========================判断子件是否全部发布 Start===================\n");
|
|
|
auto startTime = std::chrono::high_resolution_clock::now();
|
|
|
//POM_AM__set_application_bypass(true);
|
|
|
int ifail = ITK_ok;
|
|
|
int attachments_num = 0;
|
|
|
tag_t rootTask = NULLTAG, *attachments = NULLTAG,user_tag = 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, *user_name = NULL;
|
|
|
char releaseStatus[1024] = "", arg1value[1024] = "";
|
|
|
int arg_cnt = TC_number_of_arguments(msg.arguments);
|
|
|
printf("参数个数为:%d\n", arg_cnt);
|
|
|
ITKCALL(POM_get_user(&user_name,&user_tag));
|
|
|
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, "releaseStatus") == 0)
|
|
|
{
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(releaseStatus, argvalue);
|
|
|
}
|
|
|
}
|
|
|
else if(stricmp(argflag, "itemType") == 0)
|
|
|
{
|
|
|
//strcmp("","");
|
|
|
if (argvalue != NULL)
|
|
|
{
|
|
|
strcpy(arg1value, argvalue);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
DOFREE(argflag);
|
|
|
DOFREE(argvalue);
|
|
|
DOFREE(arg);
|
|
|
}
|
|
|
|
|
|
vector<char *> itemTypeValues;
|
|
|
|
|
|
if (strstr(arg1value, ",") != NULL)
|
|
|
{
|
|
|
int vectorValueCount = 0;
|
|
|
char ** vectorValueChar = new char *[64];
|
|
|
split(arg1value, ",", vectorValueChar, &vectorValueCount);
|
|
|
for (int i = 0; i < vectorValueCount; i++)
|
|
|
{
|
|
|
itemTypeValues.push_back(vectorValueChar[i]);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
itemTypeValues.push_back(arg1value);
|
|
|
}
|
|
|
|
|
|
vector<char *> referenceValues;
|
|
|
|
|
|
if (strstr(releaseStatus, ",") != NULL)
|
|
|
{
|
|
|
int vectorValueCount = 0;
|
|
|
char ** vectorValueChar = new char *[64];
|
|
|
split(releaseStatus, ",", vectorValueChar, &vectorValueCount);
|
|
|
for (int i = 0; i < vectorValueCount; i++)
|
|
|
{
|
|
|
referenceValues.push_back(vectorValueChar[i]);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
referenceValues.push_back(releaseStatus);
|
|
|
}
|
|
|
|
|
|
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 (!count(itemTypeValues, itemType))
|
|
|
{
|
|
|
DOFREE(itemType);
|
|
|
continue;
|
|
|
}
|
|
|
int viewNum = 0;
|
|
|
tag_t * viewTag = NULL_TAG;
|
|
|
//判断是否包含BOM视图
|
|
|
ITKCALL(AOM_ask_value_tags(attachments[i], "structure_revisions", &viewNum, &viewTag));
|
|
|
if (viewNum <= 0)
|
|
|
{
|
|
|
DOFREE(itemType);
|
|
|
DOFREE(viewTag);
|
|
|
continue;
|
|
|
}
|
|
|
//创建BOMWindow
|
|
|
tag_t top_line = NULLTAG, window = NULLTAG;
|
|
|
printf("创建BOMWindow\n");
|
|
|
ITKCALL(BOM_create_window(&window));
|
|
|
//设置顶层BOM
|
|
|
printf("设置顶层BOM\n");
|
|
|
ITKCALL(BOM_set_window_top_line(window, NULLTAG, attachments[i], NULLTAG, &top_line));
|
|
|
|
|
|
int count;
|
|
|
tag_t *children_line = NULLTAG;
|
|
|
printf("获取子列BOM\n");
|
|
|
ITKCALL(BOM_line_ask_all_child_lines(top_line, &count, &children_line));
|
|
|
|
|
|
for (int j = 0; j < count; j++)
|
|
|
{
|
|
|
|
|
|
tag_t revisions = NULLTAG;
|
|
|
logical hasPrivilege = false;
|
|
|
char * item_id = NULL;
|
|
|
//判断当前用户是否有权限
|
|
|
printf("获取子列对应的版本\n");
|
|
|
ITKCALL(AOM_ask_value_tag(children_line[j], "bl_line_object", &revisions));
|
|
|
//ITKCALL(AM_check_users_privilege(user_tag, children_line[j], "READ", &hasPrivilege));
|
|
|
ITKCALL(AOM_ask_value_string(revisions,"item_id",&item_id));
|
|
|
printf("item_id=%s",item_id);
|
|
|
printf("获取当前对象对于版本的读权限\n");
|
|
|
ITKCALL(AM_check_users_privilege(user_tag, revisions, "READ", &hasPrivilege));
|
|
|
|
|
|
printf("user_name=%s,hasPrivilege=%d\n", user_name, hasPrivilege);
|
|
|
if (!hasPrivilege)
|
|
|
{
|
|
|
char * item_id = NULL;
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
ITKCALL(AOM_ask_value_string(revisions, "item_id", &item_id));
|
|
|
|
|
|
strcat(resultString, item_id);
|
|
|
strcat(resultString, "没有权限!\n");
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
DOFREE(item_id);
|
|
|
ifail = 1;
|
|
|
continue;
|
|
|
}
|
|
|
//AOM_ask_value_tag(children_line[j], "bl_line_object", &revisions);
|
|
|
|
|
|
tag_t item = NULLTAG;
|
|
|
|
|
|
ITEM_ask_item_of_rev(revisions, &item);
|
|
|
|
|
|
ITEM_ask_latest_rev(item, &revisions);
|
|
|
|
|
|
char * revisionId = NULL;
|
|
|
AOM_ask_value_string(revisions, "item_revision_id", &revisionId);
|
|
|
if (strcmp(revisionId, "A") != 0)
|
|
|
{
|
|
|
DOFREE(revisionId);
|
|
|
continue;
|
|
|
}
|
|
|
char * releaseString = NULL;
|
|
|
//判断子件是否发布
|
|
|
AOM_ask_value_string(children_line[j], "bl_rev_release_status_list", &releaseString);
|
|
|
|
|
|
|
|
|
char *itemString = NULL;
|
|
|
|
|
|
AOM_ask_value_string(children_line[j], "bl_rev_object_string", &itemString);
|
|
|
|
|
|
printf("发布状态%s====================\n", releaseString);
|
|
|
|
|
|
|
|
|
if (releaseString == NULL || strcmp(releaseString, "") == 0)
|
|
|
{
|
|
|
strcat(resultString, itemString);
|
|
|
strcat(resultString, "\n");
|
|
|
ifail = 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
bool isHave = false;
|
|
|
for (auto referencedValue : referenceValues) {
|
|
|
|
|
|
if (strstr(releaseString, referencedValue) != NULL)
|
|
|
{
|
|
|
isHave = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (!isHave)
|
|
|
{
|
|
|
strcat(resultString, itemString);
|
|
|
strcat(resultString, "发布状态不为");
|
|
|
strcat(resultString, releaseStatus);
|
|
|
strcat(resultString, "\n");
|
|
|
ifail = 1;
|
|
|
}
|
|
|
}
|
|
|
/*if (!IsRelease(children_line[j], resultString, referenceValues, releaseStatus))
|
|
|
{
|
|
|
ifail = 1;
|
|
|
}*/
|
|
|
DOFREE(releaseString);
|
|
|
DOFREE(itemString);
|
|
|
DOFREE(item_id);
|
|
|
}
|
|
|
|
|
|
BOM_close_window(window);
|
|
|
DOFREE(itemType);
|
|
|
DOFREE(children_line);
|
|
|
}
|
|
|
DOFREE(attachments);
|
|
|
DOFREE(user_name);
|
|
|
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_ChildIsRelease用时:" << duration.count() / 1000 << std::endl;
|
|
|
string usetime = "ML_ChildIsRelease用时:";
|
|
|
usetime.append(std::to_string(duration.count() / 1000));
|
|
|
WriteLog(true, usetime.c_str());
|
|
|
printf("=========================判断子件是否全部发布 End====================\n");
|
|
|
return ifail;
|
|
|
}
|
|
|
|
|
|
boolean IsRelease(tag_t topLine,char resultString[], vector<char *> referenceValues, char releaseStatus[1024])
|
|
|
{
|
|
|
bool reault = true;
|
|
|
int count;
|
|
|
tag_t *children_line = NULLTAG;
|
|
|
|
|
|
BOM_line_ask_all_child_lines(topLine, &count, &children_line);
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
{
|
|
|
char * releaseString = NULL;
|
|
|
//判断子件是否发布
|
|
|
AOM_ask_value_string(children_line[i], "bl_rev_release_status_list", &releaseString);
|
|
|
|
|
|
char *itemString = NULL;
|
|
|
|
|
|
AOM_ask_value_string(children_line[i], "bl_rev_object_string", &itemString);
|
|
|
|
|
|
printf("发布状态%s====================\n", releaseString);
|
|
|
|
|
|
if (releaseString == NULL || strcmp(releaseString, "") == 0)
|
|
|
{
|
|
|
strcat(resultString, itemString);
|
|
|
strcat(resultString, "\n");
|
|
|
reault = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
bool isHave = false;
|
|
|
for (auto referencedValue : referenceValues) {
|
|
|
|
|
|
if (strstr(releaseString, referencedValue) != NULL)
|
|
|
{
|
|
|
isHave = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (!isHave)
|
|
|
{
|
|
|
strcat(resultString, itemString);
|
|
|
strcat(resultString, "发布状态不为");
|
|
|
strcat(resultString, releaseStatus);
|
|
|
strcat(resultString, "\n");
|
|
|
reault = false;
|
|
|
}
|
|
|
}
|
|
|
if (!IsRelease(children_line[i], resultString, referenceValues, releaseStatus))
|
|
|
{
|
|
|
reault = false;
|
|
|
}
|
|
|
|
|
|
DOFREE(releaseString);
|
|
|
DOFREE(itemString);
|
|
|
}
|
|
|
DOFREE(children_line);
|
|
|
//POM_AM__set_application_bypass(false);
|
|
|
return reault;
|
|
|
} |