|
|
#include "util.h"
|
|
|
#include "libxl.h"
|
|
|
using namespace libxl;
|
|
|
|
|
|
char *w2c(char *pcstr, const wchar_t *pwstr, size_t len)
|
|
|
{
|
|
|
int nlength = wcslen(pwstr);
|
|
|
//获取转换后的长度
|
|
|
int nbytes = WideCharToMultiByte(0, 0, pwstr, nlength, NULL, 0, NULL, NULL);
|
|
|
if (nbytes > len) nbytes = len;
|
|
|
// 通过以上得到的结果,转换unicode 字符为ascii 字符
|
|
|
WideCharToMultiByte(0, 0, pwstr, nlength, pcstr, nbytes, NULL, NULL);
|
|
|
return pcstr;
|
|
|
}
|
|
|
|
|
|
int jd_prop_relate(METHOD_message_t *msg, va_list args) {
|
|
|
cout << "jd_prop_relate" << endl;
|
|
|
//获取属性对象
|
|
|
tag_t prop_tag = va_arg(args, tag_t), form;
|
|
|
//获取值
|
|
|
char* val = va_arg(args, char*);
|
|
|
cout << "jd2_flbm:" << val << endl;
|
|
|
ITKCALL(PROP_ask_owning_object(prop_tag, &form));
|
|
|
if (val&&strlen(val)) {
|
|
|
char **pref_temp;
|
|
|
map<string, vector<string>> pref_map;
|
|
|
int pref_cnt;
|
|
|
PREF_ask_char_values("connor_default_dataset", &pref_cnt, &pref_temp);
|
|
|
for (int i = 0; i < pref_cnt; i++) {
|
|
|
string temp1 = string(pref_temp[i]).substr(0, string(pref_temp[i]).find_first_of("="));
|
|
|
string temp2 = string(pref_temp[i]).substr(string(pref_temp[i]).find_first_of("=") + 1);
|
|
|
vector<string> temp_vec;
|
|
|
split(temp2, ",", &temp_vec);
|
|
|
pref_map[temp1] = temp_vec;
|
|
|
}
|
|
|
|
|
|
char *pref;
|
|
|
PREF_ask_char_value("jd_flbm_fldj_relation", 0, &pref);
|
|
|
tag_t dataset;
|
|
|
ITK__convert_uid_to_tag(pref, &dataset);
|
|
|
char* file_name;
|
|
|
ITKCALL(AOM_UIF_ask_value(dataset, "object_name", &file_name));
|
|
|
cout << "dataset file name:" << file_name << endl;
|
|
|
string suffix = string(file_name).substr(string(file_name).find_last_of(".") + 1);
|
|
|
if (pref_map.find(suffix) != pref_map.end()) {
|
|
|
string temp = getenv("temp");
|
|
|
temp.append("\\").append(file_name);
|
|
|
if (ACCESS(temp.c_str(), 0) == 0) {
|
|
|
cout << "delete exist file" << endl;
|
|
|
remove(temp.c_str());
|
|
|
}
|
|
|
ITKCALL(AE_export_named_ref(dataset, pref_map[suffix][1].c_str(), temp.c_str()));
|
|
|
cout << "download path:" << temp.c_str() << endl;
|
|
|
Book* book = xlCreateXMLBook();
|
|
|
book->setKey(L"TommoT", L"windows-2421220b07c2e10a6eb96768a2p7r6gc");
|
|
|
if (book->load(stringToWchar(temp.c_str()))) {
|
|
|
Sheet* sheet = book->getSheet(0);
|
|
|
if (sheet) {
|
|
|
cout << "open success" << endl;
|
|
|
for (int i = 0; i < sheet->lastRow(); i++) {
|
|
|
CellType celltype = sheet->cellType(i, 1);
|
|
|
if (celltype == CELLTYPE_NUMBER)
|
|
|
{
|
|
|
const wchar_t * t = sheet->readStr(i, 1);
|
|
|
char *pcstr = (char *)malloc(sizeof(char)*(2 * wcslen(t) + 1));
|
|
|
memset(pcstr, 0, 2 * wcslen(t) + 1);
|
|
|
w2c(pcstr, t, 2 * wcslen(t) + 1);
|
|
|
if (tc_strcmp(pcstr, val) == 0) {
|
|
|
const wchar_t * t2 = sheet->readStr(i, 3);
|
|
|
char *pcstr2 = (char *)malloc(sizeof(char)*(2 * wcslen(t2) + 1));
|
|
|
memset(pcstr2, 0, 2 * wcslen(t2) + 1);
|
|
|
w2c(pcstr2, t2, 2 * wcslen(t2) + 1);
|
|
|
cout << pcstr << "/tfind ckfj:" << pcstr2 << endl;
|
|
|
AOM_lock(form);
|
|
|
ITKCALL(AOM_set_value_string(form, "jd2_ckfj", pcstr2));
|
|
|
AOM_save(form);
|
|
|
AOM_unlock(form);
|
|
|
cout << "success" << endl;
|
|
|
book->release();
|
|
|
break;
|
|
|
}
|
|
|
free(pcstr);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return ITK_ok;
|
|
|
} |