parent
ffede8be10
commit
7630162419
Binary file not shown.
@ -0,0 +1,79 @@
|
||||
#include "util.h"
|
||||
|
||||
boolean judge(tag_t top,string &status,string &name)
|
||||
{
|
||||
int line_cnt;
|
||||
tag_t *lines;
|
||||
char *val;
|
||||
BOM_line_ask_child_lines(top, &line_cnt, &lines);
|
||||
for (int j = 0; j < line_cnt; j++)
|
||||
{
|
||||
AOM_UIF_ask_value(lines[j], "jd2_last_release_status", &val);
|
||||
printf("status:%s\n", val);
|
||||
string temp = val;
|
||||
if (temp.length()>0&&status.find(val) != -1)
|
||||
{
|
||||
AOM_ask_value_string(lines[j], "bl_rev_object_string", &val);
|
||||
name = val;
|
||||
return false;
|
||||
}
|
||||
if (!judge(lines[j], status, name))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int bs_bom_check(EPM_rule_message_t msg)
|
||||
{
|
||||
int ifail = EPM_go, att_count, line_cnt;
|
||||
tag_t rootTask, *attachments, win, top, *lines;
|
||||
char *val;
|
||||
EPM_ask_root_task(msg.task, &rootTask);
|
||||
|
||||
EPM_ask_attachments(rootTask, EPM_target_attachment, &att_count, &attachments);
|
||||
TC_argument_list_t * arguments = msg.arguments;
|
||||
int arg_cnt = TC_number_of_arguments(arguments), status = 0;
|
||||
vector<string> types;
|
||||
string name;
|
||||
map<string, string> paras;
|
||||
for (auto i = 0; i < arg_cnt; i++)
|
||||
{
|
||||
char *temp_key, *temp_val;
|
||||
ITK_ask_argument_named_value(TC_next_argument(arguments), &temp_key, &temp_val);
|
||||
paras[temp_key] = temp_val;
|
||||
|
||||
}
|
||||
split(paras["type"].c_str(),",", &types);
|
||||
printf("check status:%s\n", paras["status"].c_str());
|
||||
BOM_create_window(&win);
|
||||
for (int i = 0; i < att_count; i++)
|
||||
{
|
||||
bool pass = false;
|
||||
for (int j = 0; j < types.size(); j++)
|
||||
{
|
||||
if (isTypeOf(attachments[i], types[j].c_str()))
|
||||
{
|
||||
pass = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!pass)
|
||||
continue;
|
||||
printf("begin check \n");
|
||||
BOM_set_window_top_line(win, NULLTAG, attachments[i], NULLTAG, &top);
|
||||
if(!judge(top, paras["status"],name))
|
||||
{
|
||||
ifail = EPM_nogo;
|
||||
break;
|
||||
}
|
||||
printf("end check \n");
|
||||
|
||||
}
|
||||
BOM_close_window(win);
|
||||
if (ifail==EPM_nogo) {
|
||||
name += paras["prompt"];
|
||||
EMH_store_error_s1(EMH_severity_user_error, EMH_PROP_error_base, name.c_str());
|
||||
}
|
||||
return ifail;
|
||||
}
|
||||
|
@ -0,0 +1,95 @@
|
||||
#pragma once
|
||||
#include "util.h"
|
||||
static void replace_dataset_named_reference(tag_t dataset_tag, tag_t old_file,
|
||||
const char *new_file_path, char *ref_name)
|
||||
{
|
||||
IMF_file_data_p_t file_data;
|
||||
int index = 0;
|
||||
ITKCALL(IMF_get_file_access(old_file, 0, &file_data));
|
||||
|
||||
tag_t new_file_tag = NULLTAG;
|
||||
AOM_lock(old_file);
|
||||
|
||||
ITKCALL(IMF_replace_file_and_get_new_tag(old_file, new_file_path,
|
||||
FALSE, &new_file_tag));
|
||||
|
||||
AOM_lock(dataset_tag);
|
||||
|
||||
ITKCALL(AE_replace_dataset_named_ref2(dataset_tag, old_file, ref_name,
|
||||
AE_PART_OF, new_file_tag));
|
||||
ITKCALL(AE_save_myself(dataset_tag));
|
||||
AOM_unlock(dataset_tag);
|
||||
ITKCALL(IMF_release_file_access(&file_data));
|
||||
// ITKCALL2(AOM_lock_for_delete(old_file));
|
||||
// ITKCALL2(AOM_delete(old_file));
|
||||
}
|
||||
|
||||
int bs_sign_cad(EPM_action_message_t msg)
|
||||
{
|
||||
int ifail = ITK_ok, att_count,tag_cnt,form_cnt;
|
||||
tag_t rootTask, *attachments, *tags,ref,*forms;
|
||||
TC_argument_list_t * arguments = msg.arguments;
|
||||
char *name,*val;
|
||||
int arg_cnt = TC_number_of_arguments(arguments), status = 0;
|
||||
POM_AM__set_application_bypass(true);
|
||||
map<string, string> paras;
|
||||
string tempdir = getenv("temp");
|
||||
for (auto i = 0; i<arg_cnt; i++)
|
||||
{
|
||||
char *temp_key, *temp_val;
|
||||
ITK_ask_argument_named_value(TC_next_argument(arguments), &temp_key, &temp_val);
|
||||
paras[temp_key] = temp_val;
|
||||
}
|
||||
vector<string> prop_vec;
|
||||
map<string, string> prop_map;
|
||||
split(paras["prop"], ",", &prop_vec);
|
||||
for(int i=0;i<prop_vec.size();i++)
|
||||
{
|
||||
vector<string> temp_vec;
|
||||
split(prop_vec[i], "=", &temp_vec);
|
||||
if (temp_vec.size() == 2)
|
||||
prop_map[temp_vec[0]] = temp_vec[1];
|
||||
}
|
||||
EPM_ask_root_task(msg.task, &rootTask);
|
||||
Testclass ^test = gcnew Testclass();
|
||||
EPM_ask_attachments(rootTask, EPM_target_attachment, &att_count, &attachments);
|
||||
AE_reference_type_t ae_ref;
|
||||
POM_AM__set_application_bypass(true);
|
||||
for(int i=0;i<att_count;i++)
|
||||
{
|
||||
if(isTypeOf(attachments[i],paras["type"].c_str()))
|
||||
{
|
||||
printf("get item\n");
|
||||
AOM_ask_value_tags(attachments[i], "TC_Attaches", &tag_cnt, &tags);
|
||||
AOM_ask_value_tags(attachments[i], "IMAN_master_form_rev", &form_cnt, &forms);
|
||||
|
||||
for(int j=0;j<tag_cnt;j++)
|
||||
{
|
||||
AE_ask_dataset_named_ref2(tags[j], "JD2_dwg", &ae_ref, &ref);
|
||||
if(ref)
|
||||
{
|
||||
IMF_ask_original_file_name2(ref, &name);
|
||||
stringstream path;
|
||||
path << tempdir <<"\\"<< newGUID() << name;
|
||||
printf("path:%s\n", path.str().c_str());
|
||||
IMF_export_file(ref, path.str().c_str());
|
||||
System::Collections::Generic::Dictionary<String^, String^> ^dic = gcnew System::Collections::Generic::Dictionary<String^, String^>();
|
||||
for(auto k=prop_map.begin();k!=prop_map.end();k++)
|
||||
{
|
||||
AOM_UIF_ask_value(forms[0], k->second.c_str(), &val);
|
||||
dic[convert_to_cstring(k->first.c_str())] = convert_to_cstring(val);
|
||||
}
|
||||
bool result= test->signCad(convert_to_cstring(path.str().c_str()), convert_to_cstring(paras["title"].c_str()), dic);
|
||||
if(result)
|
||||
{
|
||||
replace_dataset_named_reference(tags[j], ref, path.str().c_str(), "JD2_dwg");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
POM_AM__set_application_bypass(false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,98 @@
|
||||
#include "util.h"
|
||||
|
||||
int bs_wl_check(EPM_rule_message_t msg)
|
||||
{
|
||||
int ifail = EPM_go, att_count, tag_cnt,form_cnt;
|
||||
tag_t rootTask, *attachments, win, top, *tags,*forms;
|
||||
char *val;
|
||||
EPM_ask_root_task(msg.task, &rootTask);
|
||||
|
||||
EPM_ask_attachments(rootTask, EPM_target_attachment, &att_count, &attachments);
|
||||
TC_argument_list_t * arguments = msg.arguments;
|
||||
int arg_cnt = TC_number_of_arguments(arguments), status = 0;
|
||||
vector<string> wl_types, judge_types,judge_vec;
|
||||
|
||||
string name;
|
||||
map<string, string> paras,judge_map;
|
||||
for (auto i = 0; i<arg_cnt; i++)
|
||||
{
|
||||
char *temp_key, *temp_val;
|
||||
ITK_ask_argument_named_value(TC_next_argument(arguments), &temp_key, &temp_val);
|
||||
paras[temp_key] = temp_val;
|
||||
}
|
||||
split(paras["wlType"], ",", &wl_types);
|
||||
split(paras["judgeType"], ",", &judge_types);
|
||||
split(paras["judgeProps"], ",", &judge_vec);
|
||||
for(int i=0;i<judge_vec.size();i++)
|
||||
{
|
||||
vector<string> temp;
|
||||
split(judge_vec[i], "=", &temp);
|
||||
if(temp.size()==2)
|
||||
{
|
||||
judge_map[temp[0]] = temp[1];
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i<att_count; i++)
|
||||
{
|
||||
bool pass=false;
|
||||
for(int j=0;j<wl_types.size();j++)
|
||||
{
|
||||
if(isTypeOf(attachments[i],wl_types[j].c_str()))
|
||||
{
|
||||
pass = true;
|
||||
printf("wl_type:%s\n", wl_types[j].c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!pass)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
AOM_ask_value_tags(attachments[i], "IMAN_master_form_rev", &form_cnt, &forms);
|
||||
pass = false;
|
||||
|
||||
for(auto j=judge_map.begin();j!=judge_map.end();j++)
|
||||
{
|
||||
AOM_UIF_ask_value(forms[0], j->first.c_str(), &val);
|
||||
if(j->second!=val)
|
||||
{
|
||||
pass = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!pass)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
AOM_ask_value_tags(attachments[i], paras["relation"].c_str(), &tag_cnt, &tags);
|
||||
printf("relation :%s\n, length:%d\n", paras["relation"].c_str(), tag_cnt);
|
||||
pass = false;
|
||||
|
||||
for(int j=0;j<tag_cnt;j++)
|
||||
{
|
||||
for(int k=0;k<judge_types.size();k++)
|
||||
{
|
||||
if(isTypeOf(tags[j], judge_types[k].c_str()))
|
||||
{
|
||||
printf("judge_type:%s\n", judge_types[k].c_str());
|
||||
pass = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!pass)
|
||||
{
|
||||
AOM_ask_value_string(attachments[i], "object_string", &val);
|
||||
name = val;
|
||||
ifail = EPM_nogo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ifail==EPM_nogo) {
|
||||
name += paras["prompt"];
|
||||
EMH_store_error_s1(EMH_severity_user_error, EMH_PROP_error_base, name.c_str());
|
||||
}
|
||||
return ifail;
|
||||
}
|
||||
|
@ -0,0 +1,61 @@
|
||||
#include "util.h"
|
||||
|
||||
|
||||
string ConvertToString(System::String^ str)
|
||||
{
|
||||
char* p = (char*)(void*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(str);
|
||||
return p;
|
||||
}
|
||||
System::String ^ convert_to_cstring(const char *p)
|
||||
{
|
||||
return System::Runtime::InteropServices::Marshal::PtrToStringAnsi((System::IntPtr)(char *)p);
|
||||
}
|
||||
bool isTypeOf(tag_t objtag, const char * type_name) {
|
||||
tag_t type = NULLTAG;
|
||||
TCTYPE_ask_object_type(objtag, &type);
|
||||
tag_t item_type = NULLTAG;
|
||||
TCTYPE_find_type(type_name, "", &item_type);
|
||||
bool is_type = false;
|
||||
if (item_type != NULLTAG) {
|
||||
logical isok = FALSE;
|
||||
TCTYPE_is_type_of(type, item_type, &isok);
|
||||
if (isok) {
|
||||
is_type = true;
|
||||
}
|
||||
}
|
||||
return is_type;
|
||||
}
|
||||
void split(std::string s, const char* delim, std::vector<std::string>* ret)
|
||||
{
|
||||
size_t last = 0;
|
||||
size_t index = s.find(delim, last);
|
||||
int size = strlen(delim);
|
||||
while (index != std::string::npos) {
|
||||
ret->push_back(s.substr(last, index - last));
|
||||
last = index + size;
|
||||
index = s.find(delim, last);
|
||||
}
|
||||
if (index - last > 0) {
|
||||
ret->push_back(s.substr(last, index - last));
|
||||
}
|
||||
}
|
||||
|
||||
const char* newGUID()
|
||||
{
|
||||
static char buf[64] = { 0 };
|
||||
GUID guid;
|
||||
if (S_OK == ::CoCreateGuid(&guid))
|
||||
{
|
||||
_snprintf(buf, sizeof(buf)
|
||||
, "%08X-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X"
|
||||
, 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]
|
||||
);
|
||||
}
|
||||
return (const char*)buf;
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
#include "epm_handler_common.h"
|
||||
#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 <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 <sa\am.h>
|
||||
#include "tc/envelope.h"
|
||||
#include <stdio.h>
|
||||
#include "ae/dataset.h"
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "ce/ce.h"
|
||||
#include <time.h>
|
||||
#include <windows.h>
|
||||
#include <iostream>
|
||||
#include <sql.h>
|
||||
#include <sqlext.h>
|
||||
#include "string"
|
||||
#include "sstream"
|
||||
#include <sa/tcfile.h>
|
||||
#include <tccore/aom.h>
|
||||
#include <sa/tcfile_cache.h>
|
||||
#include "ctime"
|
||||
#include "tchar.h"
|
||||
#include "ics/ics.h"
|
||||
#include "ics/ics2.h"
|
||||
#using "C:/Users/lyf/source/repos/Testdll/bin/Debug/declib.dll"
|
||||
|
||||
using namespace std;
|
||||
using namespace Testdll;
|
||||
using namespace System;
|
||||
extern "C" int POM_AM__set_application_bypass(logical bypass);
|
||||
|
||||
|
||||
|
||||
string ConvertToString(System::String^ str);
|
||||
System::String ^ convert_to_cstring(const char *p);
|
||||
bool isTypeOf(tag_t objtag, const char * type_name);
|
||||
void split(std::string s, const char* delim, std::vector<std::string>* ret);
|
||||
|
||||
const char* newGUID();
|
Loading…
Reference in new issue