|
|
// CHINT_test.cpp : 定义控制台应用程序的入口点。
|
|
|
//
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
#include <tcinit\tcinit.h>
|
|
|
#include "epm_handler_common.h"
|
|
|
#include "util.h"
|
|
|
#include "test.h"
|
|
|
#include "unidefs.h"
|
|
|
#include <iostream>
|
|
|
#include "property\nr.h"
|
|
|
#include <ics\ics.h>
|
|
|
#include <ics\ics2.h>
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
//template <typename ...Args>
|
|
|
|
|
|
void readFile(const string&filename)
|
|
|
{
|
|
|
ifstream ifstr;
|
|
|
string mystr;
|
|
|
ifstr.open(filename);
|
|
|
if(ifstr.fail())
|
|
|
{
|
|
|
string error = "Unable to open" + filename;
|
|
|
throw invalid_argument(error);
|
|
|
}
|
|
|
if(ifstr.eof())
|
|
|
{
|
|
|
ifstr.close();
|
|
|
}else
|
|
|
{
|
|
|
string error = "Unable to colse" + filename;
|
|
|
throw runtime_error(error);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
bool isEmpty(const char str)
|
|
|
{
|
|
|
if (str && str != '\0')
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
bool isEmpty(string &str)
|
|
|
{
|
|
|
if (str.empty())
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
str.erase(0, str.find_first_not_of(" "));
|
|
|
str.erase(str.find_last_not_of(" ")+1);
|
|
|
return str.empty();
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
inline std::string format_string(const char *format,Args...args)
|
|
|
{
|
|
|
constexpr sizt_t oldLen = BUFSIZ;
|
|
|
char buffer[oldlen]; // 默认栈上的缓冲区
|
|
|
|
|
|
size_t newlen = snprintf(&buffer[0], oldlen, format, args...);
|
|
|
newlen++; // 算上终止符'\0'
|
|
|
|
|
|
if (newlen > oldlen) { // 默认缓冲区不够大,从堆上分配
|
|
|
std::vector<char> newbuffer(newlen);
|
|
|
snprintf(newbuffer.data(), newlen, format, args...);
|
|
|
return std::string(newbuffer.data());
|
|
|
}
|
|
|
|
|
|
return buffer;
|
|
|
}
|
|
|
*/
|
|
|
std::string format(const char *pszFmt, ...)
|
|
|
{
|
|
|
std::string str;
|
|
|
va_list args;
|
|
|
va_start(args, pszFmt);
|
|
|
{
|
|
|
int nLength = _vscprintf(pszFmt, args);
|
|
|
nLength += 1; //上面返回的长度是包含\0,这里加上
|
|
|
std::vector<char> vectorChars(nLength);
|
|
|
_vsnprintf(vectorChars.data(), nLength, pszFmt, args);
|
|
|
str.assign(vectorChars.data());
|
|
|
}
|
|
|
va_end(args);
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
int queryResult(string queryName,map<string,string> fields)
|
|
|
{
|
|
|
int size = fields.size();
|
|
|
cout << "个数:" << size<<endl;
|
|
|
|
|
|
char **entries, **vals;
|
|
|
entries = (char **)MEM_alloc(1 * sizeof(char *));
|
|
|
vals = (char **)MEM_alloc(1* sizeof(char *));
|
|
|
int index = 0;
|
|
|
for (auto it = fields.begin(); it != fields.end(); it++)
|
|
|
{
|
|
|
|
|
|
//strcpy(entries[index], it->first.c_str());
|
|
|
string id = it->first;
|
|
|
cout<<"ID:"<<id;
|
|
|
//strcpy(vals[index], it->second.c_str());
|
|
|
id = it->second;
|
|
|
cout<<"ID:"<<id;
|
|
|
index++;
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
|
|
|
string createHtml()
|
|
|
{
|
|
|
ofstream ecnHtml;
|
|
|
ecnHtml.open("D:\\test.html",ios::out|ios::trunc);
|
|
|
ecnHtml.close();
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int cnt, char* argv[])
|
|
|
{
|
|
|
printf("asisk\r\n");
|
|
|
string htmlPath="C:\\Users\\xiaol\\Desktop\\pdf.html";
|
|
|
createHtml();
|
|
|
printf("文件位置:%s\r\n",htmlPath.c_str());
|
|
|
if(1==1)
|
|
|
return 0;
|
|
|
|
|
|
ITK_init_module( "dcproxy", "dcproxy","");
|
|
|
printf("开始登陆TC\r\n");
|
|
|
|
|
|
printf("开始签字数据提取\r\n");
|
|
|
tag_t wx_task;
|
|
|
string v_uid = argv[1];
|
|
|
printf("uid:%s\r\n",v_uid.c_str());
|
|
|
LINFO<<"uid=["<<v_uid.c_str()<<"]";
|
|
|
ITK__convert_uid_to_tag(v_uid.c_str(),&wx_task);
|
|
|
|
|
|
wx_signoff2(wx_task);
|
|
|
|
|
|
printf("签字结束\r\n");
|
|
|
|
|
|
//ITK_exit_module(true);
|
|
|
if(1==1)
|
|
|
return 0;
|
|
|
|
|
|
ITK_init_module( "dcproxy", "dcproxy","");
|
|
|
printf("开始登陆TC\r\n");
|
|
|
string path = argv[1];
|
|
|
printf("开始更新\r\n");
|
|
|
//char *uid = argv[2];
|
|
|
//tag_t item;
|
|
|
//ITK__convert_uid_to_tag(uid,&item);
|
|
|
//ICS_find_class();
|
|
|
tag_t class_tag = NULLTAG, *attr_tags = NULL;
|
|
|
ICS_find_class("ICM0601",&class_tag);
|
|
|
int attr_cout = 0;
|
|
|
|
|
|
ICS_ask_attributes(class_tag,&attr_cout,&attr_tags);
|
|
|
cout<<"分类个数1:"<<attr_cout<<endl;
|
|
|
int *attr_ids;
|
|
|
char **attr_names;
|
|
|
ICS_attribute_search("-401 = * ",-401,ICS_SEARCH_CASE_INSENSITIVE,&attr_cout,&attr_tags,&attr_ids,&attr_names);
|
|
|
|
|
|
cout<<"分类个数2:"<<attr_cout<<endl;
|
|
|
ITK_exit_module(true);
|
|
|
|
|
|
|
|
|
if(true)
|
|
|
return 0;
|
|
|
|
|
|
char *method = argv[1];
|
|
|
//printf("method:%s\r\n",method);
|
|
|
//printf("2:%s\r\n",argv[2]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(strcmp(method,"Task")==0)
|
|
|
{
|
|
|
char *uid = argv[2];
|
|
|
tag_t item;
|
|
|
ITK__convert_uid_to_tag(uid,&item);
|
|
|
chint_Design_Task(item);
|
|
|
}else if(strcmp(method,"releation")==0)
|
|
|
{
|
|
|
char *path = argv[2];
|
|
|
LINFO<<"path:"<<path;
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
connor_import_relation(path);
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
else if(strcmp(method,"deleteBom")==0)
|
|
|
{
|
|
|
char *item_id = argv[2];
|
|
|
char *item_revision_id = argv[3];
|
|
|
LINFO<<"Item_id:["<<item_id<<"];item_revision_id:["<<item_revision_id<<"]";
|
|
|
tag_t rev;
|
|
|
ITEM_find_rev(item_id,item_revision_id,&rev);
|
|
|
if(rev)
|
|
|
{
|
|
|
chint_delete_Bom(rev);
|
|
|
}
|
|
|
}
|
|
|
else if(strcmp(method,"bom")==0)
|
|
|
{
|
|
|
|
|
|
char *uid = argv[2];
|
|
|
tag_t item;
|
|
|
ITK__convert_uid_to_tag(uid,&item);
|
|
|
connor_import_bom(item);
|
|
|
|
|
|
}else if(strcmp(method,"sendMessage")==0)
|
|
|
{
|
|
|
|
|
|
char *uid = argv[2];
|
|
|
tag_t item;
|
|
|
ITK__convert_uid_to_tag(uid,&item);
|
|
|
ChintSendMessage(item);
|
|
|
|
|
|
}
|
|
|
else if(strcmp(method,"Item")==0)
|
|
|
{
|
|
|
printf("开始对象导入\r\n");
|
|
|
char *uid = argv[2];
|
|
|
tag_t item;
|
|
|
ITK__convert_uid_to_tag(uid,&item);
|
|
|
connor_import_item(item);
|
|
|
printf("对象导入结束\r\n");
|
|
|
}
|
|
|
else if(strcmp(method,"importPM")==0)
|
|
|
{
|
|
|
printf("其他\r\n");
|
|
|
tag_t item1,item2;
|
|
|
ITK__convert_uid_to_tag(argv[1],&item1);
|
|
|
ITK__convert_uid_to_tag(argv[2],&item2);
|
|
|
char* item_id;
|
|
|
ITKCALL(AOM_ask_value_string(item1,"item_id",&item_id));
|
|
|
int r_cnt=0;
|
|
|
tag_t *tags;
|
|
|
ITKCALL(AOM_ask_value_tags(item1,"representation_for",&r_cnt,&tags));
|
|
|
tag_t *tags2;
|
|
|
int r_cnt2 = r_cnt<1?1:(r_cnt+1);
|
|
|
tags2 = (tag_t *)MEM_alloc((r_cnt2)*sizeof(tag_t));
|
|
|
for(auto i=0;i<r_cnt2;i++)
|
|
|
{
|
|
|
//tags2[i] = new tag_t[1];
|
|
|
tags[i]>>tags2[i];
|
|
|
}
|
|
|
|
|
|
POM_AM__set_application_bypass(true);
|
|
|
printf("父ID:%s\r\n",item_id);
|
|
|
ITKCALL(AOM_ask_value_string(item2,"item_id",&item_id));
|
|
|
printf("子ID:%s\r\n",item_id);
|
|
|
ITKCALL(AOM_set_value_tags(item1,"representation_for",r_cnt2,tags2));
|
|
|
POM_AM__set_application_bypass(false);
|
|
|
printf("成功\r\n");
|
|
|
}
|
|
|
|
|
|
|
|
|
LINFO<<"设计任务回传结束";
|
|
|
ITK_exit_module(true);
|
|
|
return 0;
|
|
|
}
|
|
|
|