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.
165 lines
3.7 KiB
165 lines
3.7 KiB
#include "chint_method.h"
|
|
#include <iostream>
|
|
#include <sstream>
|
|
#include <vector>
|
|
#include <string>
|
|
#include "tc_util.h"
|
|
#include <stdarg.h>
|
|
#define CUST_PROP_ERROR_NO 38600
|
|
#include "util.h"
|
|
|
|
#include <extensionframework/OperationDispatcher.hxx>
|
|
#include <itk/bmf.h>
|
|
using namespace std;
|
|
|
|
int CHINT_set_bypass(void *returnValue)
|
|
{
|
|
POM_AM__set_application_bypass(true);
|
|
return 0;
|
|
}
|
|
|
|
int CHINT_close_bypass(void *returnValue)
|
|
{
|
|
POM_AM__set_application_bypass(false);
|
|
return 0;
|
|
}
|
|
|
|
int sapStateMonitor(METHOD_message_t *msg,va_list args)
|
|
{
|
|
int ifail = ITK_ok;
|
|
tag_t pro_tag = va_arg(args,tag_t);
|
|
char *values = va_arg(args,char*);
|
|
char *sapState = NULL,
|
|
*item_id = NULL,
|
|
*userID = NULL;
|
|
|
|
SAFECALL(AOM_ask_value_string(pro_tag, "item_id", &item_id));
|
|
//ask_user
|
|
SAFECALL(PROP_ask_name(pro_tag,&sapState));
|
|
char *before = NULL;
|
|
|
|
LINFO <<"用户["<<""<< "]修改图纸[" << "" << "]SAP状态为" << sapState;
|
|
|
|
if (sapState != NULL){
|
|
MEM_free(sapState);
|
|
sapState = NULL;
|
|
}
|
|
if (item_id != NULL){
|
|
MEM_free(item_id);
|
|
item_id = NULL;
|
|
}
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
void deletesub(string &str, const string &sub, int n)
|
|
{
|
|
int m, flag = 0, num = 0; //num是子串出现的次数
|
|
while (flag == 0)
|
|
{
|
|
m = str.find(sub);
|
|
if (m<0)
|
|
flag = 1;
|
|
else
|
|
{
|
|
str.erase(m, n); //删除子串
|
|
num++;
|
|
}
|
|
}
|
|
// cout<<num<<endl; //子串出现的次数
|
|
//cout << str << endl; // 输出删除后的字符串
|
|
}
|
|
using namespace Teamcenter;
|
|
//创建数据集 如果是Creo数据集,去掉数据集后缀
|
|
int Dataser_saveAs_post(METHOD_message_t* msg, va_list args){
|
|
cout << "Dataser_saveAs_post start" << endl;
|
|
tag_t save_rev = va_arg(args,tag_t);
|
|
|
|
|
|
//tag_t prop_tag = va_arg(args, tag_t);
|
|
//tag_t dataset = va_arg(args, tag_t);
|
|
//char* operation = va_arg(args, char*);
|
|
char *datasetName,*type;
|
|
std::string object_name;
|
|
ITKCALL(AOM_ask_value_string(save_rev, "object_type", &type));
|
|
//cout << "操作:" << operation << endl;
|
|
cout << "rev_type:" << type << endl;
|
|
vector<string> vec;
|
|
vec.push_back(".dwg");
|
|
vec.push_back(".prt");
|
|
vec.push_back(".asm");
|
|
string sts = "";
|
|
int n = 0;
|
|
|
|
if (isTypeOf(save_rev, "Dataset"))
|
|
{
|
|
AOM_ask_value_string(save_rev, "object_name", &datasetName);
|
|
cout << "object_name:" << object_name << endl;
|
|
for (auto it = vec.begin(); it != vec.end(); it++)
|
|
{
|
|
object_name = datasetName;
|
|
if (strstr(datasetName, (*it).c_str()) != NULL)
|
|
{
|
|
n = (*it).size();
|
|
deletesub(object_name, (*it).c_str(), n);
|
|
cout << "object_name:" << object_name << endl;
|
|
AOM_lock(save_rev);
|
|
AOM_set_value_string(save_rev, "object_name", object_name.c_str());
|
|
AOM_save(save_rev);
|
|
AOM_unlock(save_rev);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
cout << "Dataser_saveAs_post end" << endl;
|
|
|
|
|
|
return ITK_ok;
|
|
}
|
|
|
|
int Dataser_create_post(METHOD_message_t* msg, va_list args){
|
|
tag_t save_rev = va_arg(args, tag_t);
|
|
char *datasetName, *type;
|
|
std::string object_name;
|
|
//ITKCALL(AOM_ask_value_string(save_rev, "object_type", &type));
|
|
|
|
vector<string> vec;
|
|
vec.push_back(".dwg");
|
|
vec.push_back(".prt");
|
|
vec.push_back(".asm");
|
|
|
|
|
|
int n = 0;
|
|
AOM_ask_value_string(save_rev, "object_name", &datasetName);
|
|
cout << "object_name:" << object_name << endl;
|
|
for (auto it = vec.begin(); it != vec.end(); it++)
|
|
{
|
|
object_name = datasetName;
|
|
if (strstr(datasetName, (*it).c_str()) != NULL)
|
|
{
|
|
n = (*it).size();
|
|
deletesub(object_name, (*it).c_str(), n);
|
|
cout << "object_name:" << object_name << endl;
|
|
AOM_lock(save_rev);
|
|
AOM_set_value_string(save_rev, "object_name", object_name.c_str());
|
|
AOM_save(save_rev);
|
|
AOM_unlock(save_rev);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//cout << "操作:" << operation << endl;
|
|
cout << "rev_type:" << type << endl;
|
|
|
|
|
|
|
|
return ITK_ok;
|
|
|
|
} |