|
|
#include <wchar.h>
|
|
|
#include <string.h>
|
|
|
#ifdef WIN32
|
|
|
#include <io.h>
|
|
|
#include <direct.h>
|
|
|
#else
|
|
|
#include <unistd.h>
|
|
|
#endif
|
|
|
#include "connor_itk_util.h"
|
|
|
#include<ics\ics.h>
|
|
|
#include<ics\ics2.h>
|
|
|
|
|
|
#define ARGS_LENGTH 200
|
|
|
#define ARGS_NAME_DEBUG "-debug"
|
|
|
#define DEBUG "-debug="
|
|
|
#define MAX_PRINTLINE_LENGTH 20000
|
|
|
#define MAX_PATH_LENGTH 2000
|
|
|
#define MAX_ARGUMENT_LENGTH 400
|
|
|
#define MAX_FILE_EXT_LENGTH 10
|
|
|
#define TRUE_FLAG 1
|
|
|
#define FALSE_FLAG 0
|
|
|
#define DETAILLOG 1
|
|
|
|
|
|
void ECHO(char* format, ...)
|
|
|
{
|
|
|
//if( !YFJC_OPT_DEBUG )
|
|
|
// return;
|
|
|
|
|
|
char msg[4096];
|
|
|
va_list args;
|
|
|
|
|
|
va_start(args, format);
|
|
|
vsprintf(msg, format, args);
|
|
|
va_end(args);
|
|
|
|
|
|
printf(msg);
|
|
|
TC_write_syslog(msg);
|
|
|
}
|
|
|
|
|
|
FILE* logFile = NULL;
|
|
|
|
|
|
/*=============================================================================*
|
|
|
* FUNCTION: current_time
|
|
|
* PURPOSE : get the current datetime
|
|
|
* INPUT:
|
|
|
* date_t* date_tag // current date time tag
|
|
|
*
|
|
|
* RETURN:
|
|
|
* void
|
|
|
*============================================================================*/
|
|
|
void current_time(date_t* date_tag)
|
|
|
{
|
|
|
time_t ltime;
|
|
|
struct tm* today;
|
|
|
|
|
|
// Set time zone from TZ environment variable. If TZ is not set,
|
|
|
// the operating system is queried to obtain the default value
|
|
|
// for the variable.
|
|
|
//
|
|
|
//_tzset();
|
|
|
|
|
|
// Get UNIX-style time and display as number and string.
|
|
|
time(<ime);
|
|
|
|
|
|
today = localtime(<ime);
|
|
|
date_tag->year = today->tm_year + 1900;
|
|
|
date_tag->month = today->tm_mon;
|
|
|
date_tag->day = today->tm_mday;
|
|
|
date_tag->hour = today->tm_hour;
|
|
|
date_tag->minute = today->tm_min;
|
|
|
date_tag->second = today->tm_sec;
|
|
|
}
|
|
|
/*=============================================================================*
|
|
|
* FUNCTION: CreateLogFile
|
|
|
* PURPOSE : create log file
|
|
|
* INPUT:
|
|
|
* char* FunctionName // the funtion which need to create log file
|
|
|
* FILE** logFile // out: the log file pointer
|
|
|
*
|
|
|
* RETURN:
|
|
|
* void
|
|
|
*============================================================================*/
|
|
|
void CreateLogFile(char* FunctionName, char** fullname)
|
|
|
{
|
|
|
int i = 0, ifail = ITK_ok;
|
|
|
//date_t status_now;
|
|
|
//char* date_string = NULL;
|
|
|
char date_string[MAX_PATH_LENGTH];
|
|
|
char logFileDir[MAX_PATH_LENGTH];
|
|
|
char logFileName[MAX_PATH_LENGTH];
|
|
|
|
|
|
char* session_uid = NULL;
|
|
|
tag_t session_tag = NULLTAG;
|
|
|
time_t now;
|
|
|
struct tm* p;
|
|
|
|
|
|
time(&now);
|
|
|
|
|
|
logFile = NULL;
|
|
|
|
|
|
p = localtime(&now);
|
|
|
|
|
|
memset(date_string, 0, sizeof(date_string));
|
|
|
sprintf(date_string,"%4d%02d%02d%02d%02d%02d",1900+p->tm_year,p->tm_mon+1 ,p->tm_mday ,p->tm_hour,p->tm_min ,p->tm_sec );
|
|
|
//sprintf(date_string, "%4d%02d%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday);
|
|
|
|
|
|
memset(logFileDir, 0, sizeof(logFileDir));
|
|
|
memset(logFileName, 0, sizeof(logFileName));
|
|
|
//get log dir
|
|
|
sprintf(logFileDir, "%s", getenv("TEMP"));
|
|
|
printf("\n log file dir: %s\n", logFileDir);
|
|
|
//try to change dir to TC_USER_LOG_DIR
|
|
|
if (chdir(logFileDir) != ITK_ok)
|
|
|
{
|
|
|
|
|
|
memset(logFileDir, 0, sizeof(logFileDir));
|
|
|
sprintf(logFileDir, "%s", getenv("TC_LOG"));
|
|
|
printf("\n TC_USER_LOG_DIR invalide, log file dir: %s\n", logFileDir);
|
|
|
if (chdir(logFileDir) != ITK_ok)
|
|
|
{
|
|
|
//still can not change to log dir
|
|
|
printf("!*ERROR*!: Failed to change dir to TC_USER_LOG_DIR\n");
|
|
|
goto CLEANUP;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
POM_ask_session(&session_tag);
|
|
|
ITK__convert_tag_to_uid(session_tag, &session_uid);
|
|
|
|
|
|
|
|
|
sprintf(logFileName, "%s_%s.log", FunctionName, date_string);
|
|
|
printf("log file name: %s\n", logFileName);
|
|
|
|
|
|
*fullname = (char*)MEM_alloc(sizeof(char) * 512);
|
|
|
sprintf(*fullname, "%s\\%s", logFileDir, logFileName);
|
|
|
|
|
|
|
|
|
logFile = fopen(logFileName, "a");
|
|
|
|
|
|
CLEANUP:
|
|
|
//DOFREE(date_string);
|
|
|
DOFREE(session_uid);
|
|
|
}
|
|
|
|
|
|
|
|
|
/*=============================================================================*
|
|
|
* FUNCTION: WriteLog
|
|
|
* PURPOSE : write log, if debug log File not null, write log message to log File
|
|
|
* INPUT:
|
|
|
* const char* format // debug message string
|
|
|
*
|
|
|
* RETURN:
|
|
|
* void
|
|
|
*============================================================================*/
|
|
|
void WriteLog(const char* format, ...)
|
|
|
{
|
|
|
va_list arg;
|
|
|
char tmp[MAX_PRINTLINE_LENGTH];
|
|
|
|
|
|
if (logFile)
|
|
|
{
|
|
|
//get the message
|
|
|
memset(tmp, 0, sizeof(tmp));
|
|
|
va_start(arg, format);
|
|
|
vsprintf(tmp, format, arg);
|
|
|
va_end(arg);
|
|
|
|
|
|
//----------print to command window for trace--------//
|
|
|
printf("%s\n", tmp);
|
|
|
|
|
|
//print message to log file
|
|
|
fprintf(logFile, "%s\n", tmp);
|
|
|
fflush(logFile);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
printf("*!Error!*: Log File Not Exist\n");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void CloseLog(void)
|
|
|
{
|
|
|
if (logFile)
|
|
|
{
|
|
|
fclose(logFile);
|
|
|
logFile = NULL;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
char* getTime() {
|
|
|
time_t now;
|
|
|
struct tm* p;
|
|
|
char date_string[30];
|
|
|
time(&now);
|
|
|
//logFile = NULL;
|
|
|
//current_time(&status_now);
|
|
|
p = localtime(&now);
|
|
|
memset(date_string, 0, sizeof(date_string));
|
|
|
//sprintf(date_string, "%4d-%02d-%02d %02d:%02d:%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
|
|
|
sprintf(date_string, "%4d-%02d-%02d %02d-%02d-%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
|
|
|
char* dateC = (char*)malloc(sizeof(char) * (strlen(date_string) + 1));
|
|
|
strcpy(dateC, date_string);
|
|
|
return dateC;
|
|
|
}
|
|
|
|
|
|
string getUUid()
|
|
|
{
|
|
|
GUID guid;
|
|
|
char buffer[64] = { 0 };
|
|
|
if (CoCreateGuid(&guid))
|
|
|
{
|
|
|
printf("create guid error\n");
|
|
|
return "";
|
|
|
}
|
|
|
//_snprintf(buffer, sizeof(buffer), "%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]);
|
|
|
sprintf_s(buffer, sizeof(buffer),
|
|
|
"%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 buffer;
|
|
|
}
|
|
|
|
|
|
char* GbkToUtf8(const char* src_str)
|
|
|
{
|
|
|
int len = MultiByteToWideChar(CP_ACP, 0, src_str, -1, NULL, 0);
|
|
|
wchar_t* wstr = (wchar_t*)MEM_alloc((len + 1) * sizeof(wchar_t));
|
|
|
memset(wstr, 0, len + 1);
|
|
|
MultiByteToWideChar(CP_ACP, 0, src_str, -1, wstr, len);
|
|
|
len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
|
|
|
char* str = (char*)MEM_alloc((len + 1) * sizeof(char));
|
|
|
|
|
|
memset(str, 0, len + 1);
|
|
|
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL);
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
char* Utf8ToGbk(const char* src_str)
|
|
|
{
|
|
|
int len = MultiByteToWideChar(CP_UTF8, 0, src_str, -1, NULL, 0);
|
|
|
wchar_t* wszGBK = (wchar_t*)MEM_alloc((len + 1) * sizeof(wchar_t));
|
|
|
memset(wszGBK, 0, len * 2 + 2);
|
|
|
MultiByteToWideChar(CP_UTF8, 0, src_str, -1, wszGBK, len);
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, NULL, 0, NULL, NULL);
|
|
|
char* szGBK = (char*)MEM_alloc((len + 1) * sizeof(char));
|
|
|
|
|
|
memset(szGBK, 0, len + 1);
|
|
|
WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, szGBK, len, NULL, NULL);
|
|
|
return szGBK;
|
|
|
}
|
|
|
|
|
|
void starTime() {
|
|
|
time_t now;
|
|
|
struct tm* p;
|
|
|
time(&now);
|
|
|
p = localtime(&now);
|
|
|
WriteLog("start time %4d%02d%02d%02d%02d%02d", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* <20>ж<EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ΪItemRevision
|
|
|
*
|
|
|
*/
|
|
|
logical checkIsItemRevision(tag_t objtag) {
|
|
|
tag_t type = NULLTAG;
|
|
|
tag_t item_type = NULLTAG;
|
|
|
logical isItems = false;
|
|
|
ITKCALL(TCTYPE_ask_object_type(objtag, &type));
|
|
|
ITKCALL(TCTYPE_find_type("ItemRevision", "", &item_type));
|
|
|
if (item_type != NULLTAG) {
|
|
|
logical isok = FALSE;
|
|
|
ITKCALL(TCTYPE_is_type_of(type, item_type, &isok));
|
|
|
if (isok) {
|
|
|
isItems = TRUE;
|
|
|
}
|
|
|
else {
|
|
|
isItems = FALSE;
|
|
|
}
|
|
|
}
|
|
|
return isItems;
|
|
|
}
|
|
|
|
|
|
int checkIsInType(tag_t objtag, string parentType) {
|
|
|
tag_t type = NULLTAG;
|
|
|
tag_t item_type = NULLTAG;
|
|
|
ITKCALL(TCTYPE_ask_object_type(objtag, &type));
|
|
|
ITKCALL(TCTYPE_find_type(parentType.c_str(), "", &item_type));
|
|
|
if (item_type != NULLTAG) {
|
|
|
logical isok = FALSE;
|
|
|
ITKCALL(TCTYPE_is_type_of(type, item_type, &isok));
|
|
|
if (isok) {
|
|
|
return 1;
|
|
|
}
|
|
|
else {
|
|
|
return 0;
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
int getPrefStrings(const char* preference, vector<string>& pref_vec)
|
|
|
{
|
|
|
int ifail = ITK_ok, i = 0, j = 0, k = 0, num = 0;
|
|
|
char** values;
|
|
|
ITKCALL(ifail = PREF_ask_char_values(preference, &num, &values));
|
|
|
for (i = 0; i < num; i++)
|
|
|
{
|
|
|
pref_vec.push_back(values[i]);
|
|
|
}
|
|
|
DOFREE(values);
|
|
|
return ifail;
|
|
|
}
|
|
|
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(string strArg, string spliter, vector<string>& ans)
|
|
|
{
|
|
|
ans.clear();
|
|
|
size_t index0 = 0;
|
|
|
string one_arg;
|
|
|
if (strArg.find_first_not_of(' ') == string::npos)
|
|
|
strArg = "";
|
|
|
int len = spliter.size();
|
|
|
while (strArg.size() > 0)
|
|
|
{
|
|
|
index0 = strArg.find(spliter);
|
|
|
if (index0 != string::npos)
|
|
|
{
|
|
|
one_arg = strArg.substr(0, index0);
|
|
|
strArg = strArg.substr(index0 + len);
|
|
|
ans.push_back(one_arg);
|
|
|
if (strArg.size() == 0) {
|
|
|
ans.push_back(strArg);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ans.push_back(strArg);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
string dealPre(tag_t attachment, char* item_id, char* form_name, char* deal_type,tag_t classificationObject,char* typePref) {
|
|
|
char** pre_values = NULL;
|
|
|
int valueNum = 0;
|
|
|
WriteLog("(char*)tableName.c_str()============%s<><73>\n", form_name);
|
|
|
PREF_ask_char_values(typePref, &valueNum, &pre_values);
|
|
|
if (pre_values == NULL) {
|
|
|
return "";
|
|
|
}
|
|
|
WriteLog("<EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>\n");
|
|
|
tag_t item, * forms;
|
|
|
ITEM_ask_item_of_rev(attachment, &item);
|
|
|
WriteLog("<EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>\n");
|
|
|
int rev_cnt = 0;
|
|
|
ITKCALL(AOM_ask_value_tags(attachment, "IMAN_master_form_rev", &rev_cnt, &forms));
|
|
|
char* item_type, * rev_type, * form_type;
|
|
|
WriteLog("<EFBFBD><EFBFBD>3<EFBFBD><EFBFBD>\n");
|
|
|
ITKCALL(AOM_ask_value_string(attachment, "object_type", &rev_type));
|
|
|
ITKCALL(AOM_ask_value_string(item, "object_type", &item_type));
|
|
|
ITKCALL(AOM_ask_value_string(forms[0], "object_type", &form_type));
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷֱ<EFBFBD>Ϊ<EFBFBD><EFBFBD>%s--------%s------%s\n", item_type, rev_type, form_type);
|
|
|
WriteLog("<EFBFBD><EFBFBD>4<EFBFBD><EFBFBD>\n");
|
|
|
string sql;
|
|
|
|
|
|
|
|
|
|
|
|
if (strcmp("update", deal_type) == 0) {
|
|
|
sql.append("UPDATE [");
|
|
|
sql.append(form_name);
|
|
|
sql.append("] SET ");
|
|
|
for (int i = 0; i < valueNum; i++)
|
|
|
{
|
|
|
WriteLog("<EFBFBD><EFBFBD>5<EFBFBD><EFBFBD>\n");
|
|
|
vector<string> one;
|
|
|
vector<string> two;
|
|
|
Split(pre_values[i], ".", one);
|
|
|
Split(one[1], "=", two);
|
|
|
char* temp_value = NULL;
|
|
|
sql.append("[");
|
|
|
sql.append(two[1]);
|
|
|
sql.append("]");
|
|
|
if (strcmp("ItemID", two[1].c_str()) == 0) {
|
|
|
WriteLog("<EFBFBD><EFBFBD>6<EFBFBD><EFBFBD>\n");
|
|
|
sql.append("='");
|
|
|
if (strcmp(item_type, one[0].c_str()) == 0) {
|
|
|
ITKCALL(AOM_ask_value_string(item, two[0].c_str(), &temp_value));
|
|
|
}
|
|
|
else if (strcmp(rev_type, one[0].c_str()) == 0) {
|
|
|
ITKCALL(AOM_ask_value_string(attachment, two[0].c_str(), &temp_value));
|
|
|
}
|
|
|
else if (strcmp(form_type, one[0].c_str()) == 0) {
|
|
|
ITKCALL(AOM_ask_value_string(forms[0], two[0].c_str(), &temp_value));
|
|
|
}
|
|
|
else if (classificationObject != NULL && strcmp(one[0].c_str(),"classField") == 0) {
|
|
|
ICS_ask_attribute_value(classificationObject, two[0].c_str(), &temp_value);
|
|
|
}
|
|
|
if (temp_value != NULL) {
|
|
|
sql.append(temp_value);
|
|
|
|
|
|
}
|
|
|
sql.append("',");
|
|
|
}
|
|
|
else {
|
|
|
WriteLog("<EFBFBD><EFBFBD>7<EFBFBD><EFBFBD>\n");
|
|
|
sql.append("='");
|
|
|
if (strcmp(item_type, one[0].c_str()) == 0) {
|
|
|
ITKCALL(AOM_ask_value_string(item, two[0].c_str(), &temp_value));
|
|
|
}
|
|
|
else if (strcmp(rev_type, one[0].c_str()) == 0) {
|
|
|
ITKCALL(AOM_ask_value_string(attachment, two[0].c_str(), &temp_value));
|
|
|
}
|
|
|
else if (strcmp(form_type, one[0].c_str()) == 0) {
|
|
|
ITKCALL(AOM_ask_value_string(forms[0], two[0].c_str(), &temp_value));
|
|
|
}
|
|
|
else if (classificationObject != NULL && strcmp(one[0].c_str(), "classField") == 0) {
|
|
|
ICS_ask_attribute_value(classificationObject, two[0].c_str(), &temp_value);
|
|
|
}
|
|
|
if (temp_value != NULL) {
|
|
|
sql.append(temp_value);
|
|
|
|
|
|
}
|
|
|
sql.append("',");
|
|
|
}
|
|
|
}
|
|
|
WriteLog("<EFBFBD><EFBFBD>8<EFBFBD><EFBFBD>\n");
|
|
|
sql.erase(sql.size() - 1, 1);
|
|
|
sql.append(" WHERE \"ItemID\" = '");
|
|
|
sql.append(item_id);
|
|
|
sql.append("'");
|
|
|
}
|
|
|
else if (strcmp("insert", deal_type) == 0) {
|
|
|
sql.append("INSERT INTO [");
|
|
|
sql.append(form_name);
|
|
|
sql.append("](");
|
|
|
//<2F><>ֵ<EFBFBD>ֶ<EFBFBD>
|
|
|
WriteLog("<EFBFBD><EFBFBD>9<EFBFBD><EFBFBD>\n");
|
|
|
for (int i = 0; i < valueNum; i++)
|
|
|
{
|
|
|
vector<string> one;
|
|
|
Split(pre_values[i], "=", one);
|
|
|
sql.append("[");
|
|
|
sql.append(one[1]);
|
|
|
sql.append("]");
|
|
|
if (i < valueNum - 1) {
|
|
|
sql.append(",");
|
|
|
}
|
|
|
}
|
|
|
WriteLog("<EFBFBD><EFBFBD>10<EFBFBD><EFBFBD>\n");
|
|
|
sql.append(") VALUES (");
|
|
|
//<2F><>ֵ<EFBFBD>ֶε<D6B6>ֵ
|
|
|
for (int i = 0; i < valueNum; i++)
|
|
|
{
|
|
|
WriteLog("<EFBFBD><EFBFBD>11<EFBFBD><EFBFBD>\n");
|
|
|
vector<string> one;
|
|
|
WriteLog("<EFBFBD><EFBFBD>11 1<><31>\n");
|
|
|
vector<string> two;
|
|
|
WriteLog("<EFBFBD><EFBFBD>11 2<><32>\n");
|
|
|
Split(pre_values[i], ".", one);
|
|
|
WriteLog("<EFBFBD><EFBFBD>11 3<><33>\n");
|
|
|
Split(one[1], "=", two);
|
|
|
WriteLog("<EFBFBD><EFBFBD>11 4<><34>\n");
|
|
|
char* temp_value = NULL;
|
|
|
WriteLog("<EFBFBD><EFBFBD>11 5<><35>\n");
|
|
|
if (strcmp("ItemID", two[1].c_str()) == 0) {
|
|
|
sql.append("'");
|
|
|
if (strcmp(item_type, one[0].c_str()) == 0) {
|
|
|
WriteLog("<EFBFBD><EFBFBD>11 6<><36>\n");
|
|
|
ITKCALL(AOM_ask_value_string(item, two[0].c_str(), &temp_value));
|
|
|
}
|
|
|
else if (strcmp(rev_type, one[0].c_str()) == 0) {
|
|
|
WriteLog("<EFBFBD><EFBFBD>11 7<><37>\n");
|
|
|
ITKCALL(AOM_ask_value_string(attachment, two[0].c_str(), &temp_value));
|
|
|
}
|
|
|
else if (strcmp(form_type, one[0].c_str()) == 0) {
|
|
|
WriteLog("<EFBFBD><EFBFBD>11 8<><38>\n");
|
|
|
ITKCALL(AOM_ask_value_string(forms[0], two[0].c_str(), &temp_value));
|
|
|
}
|
|
|
else if (classificationObject != NULL && strcmp(one[0].c_str(), "classField") == 0) {
|
|
|
WriteLog("<EFBFBD><EFBFBD>11 9<><39>\n");
|
|
|
ICS_ask_attribute_value(classificationObject, two[0].c_str(), &temp_value);
|
|
|
WriteLog("<EFBFBD><EFBFBD>11 10<31><30>\n");
|
|
|
}
|
|
|
WriteLog("<EFBFBD><EFBFBD>11 11<31><31>\n");
|
|
|
if (temp_value != NULL) {
|
|
|
sql.append(temp_value);
|
|
|
WriteLog("<EFBFBD><EFBFBD>11 12<31><32>\n");
|
|
|
|
|
|
WriteLog("<EFBFBD><EFBFBD>11 13<31><33>\n");
|
|
|
}
|
|
|
sql.append("',");
|
|
|
}
|
|
|
else {
|
|
|
WriteLog("<EFBFBD><EFBFBD>12<EFBFBD><EFBFBD>\n");
|
|
|
sql.append("'");
|
|
|
if (strcmp(item_type, one[0].c_str()) == 0) {
|
|
|
ITKCALL(AOM_ask_value_string(item, two[0].c_str(), &temp_value));
|
|
|
}
|
|
|
else if (strcmp(rev_type, one[0].c_str()) == 0) {
|
|
|
ITKCALL(AOM_ask_value_string(attachment, two[0].c_str(), &temp_value));
|
|
|
}
|
|
|
else if (strcmp(form_type, one[0].c_str()) == 0) {
|
|
|
ITKCALL(AOM_ask_value_string(forms[0], two[0].c_str(), &temp_value));
|
|
|
}
|
|
|
else if (classificationObject != NULL && strcmp(one[0].c_str(), "classField") == 0) {
|
|
|
ICS_ask_attribute_value(classificationObject, two[0].c_str(), &temp_value);
|
|
|
}
|
|
|
WriteLog("<EFBFBD><EFBFBD>12 11<31><31>\n");
|
|
|
if (temp_value != NULL) {
|
|
|
sql.append(temp_value);
|
|
|
WriteLog("<EFBFBD><EFBFBD>12 12<31><32>\n");
|
|
|
|
|
|
WriteLog("<EFBFBD><EFBFBD>12 13<31><33>\n");
|
|
|
}
|
|
|
sql.append("',");
|
|
|
}
|
|
|
}
|
|
|
WriteLog("<EFBFBD><EFBFBD>13<EFBFBD><EFBFBD>\n");
|
|
|
sql.erase(sql.size() - 1, 1);
|
|
|
sql.append(")");
|
|
|
}
|
|
|
return sql;
|
|
|
}
|
|
|
|
|
|
/*******************************************************************
|
|
|
*
|
|
|
*<2A><>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD>Ϣд<CFA2>뵽<EFBFBD>м<EFBFBD><D0BC>ļ<EFBFBD>
|
|
|
*
|
|
|
*@param file_content ǩ<><C7A9><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
*@param item_id <20><><EFBFBD><EFBFBD>id
|
|
|
*@param file_name <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
*
|
|
|
*******************************************************************/
|
|
|
int Supor_create_signinfo_file(char* file_content, char* item_id, char** file_name)
|
|
|
{
|
|
|
time_t now;
|
|
|
struct tm* p;
|
|
|
FILE* filePtr = NULL;
|
|
|
char temp_dir[MAX_PATH_LENGTH];
|
|
|
char local_path[MAX_PATH] = "";
|
|
|
char date_string[MAX_PATH_LENGTH];
|
|
|
memset(temp_dir, 0, sizeof(temp_dir));
|
|
|
memset(local_path, 0, sizeof(local_path));
|
|
|
sprintf(temp_dir, "%s", getenv("TEMP"));
|
|
|
printf("\n file dir: %s\n", temp_dir);
|
|
|
time(&now);
|
|
|
p = localtime(&now);
|
|
|
if (chdir(temp_dir) != ITK_ok)
|
|
|
{
|
|
|
memset(temp_dir, 0, sizeof(temp_dir));
|
|
|
sprintf(temp_dir, "%s", getenv("TC_LOG"));
|
|
|
printf("\n TC_USER_LOG_DIR invalide, log file dir: %s\n", temp_dir);
|
|
|
if (chdir(temp_dir) != ITK_ok)
|
|
|
{
|
|
|
printf("!*ERROR*!: Failed to change dir to TC_USER_LOG_DIR\n");
|
|
|
|
|
|
}
|
|
|
}
|
|
|
memset(date_string, 0, sizeof(date_string));
|
|
|
if (item_id != NULL) {
|
|
|
sprintf(date_string, "%s_%4d%02d%02d%02d%02d%02d.dat", item_id, 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
sprintf(date_string, "%4d%02d%02d%02d%02d%02d.dat", 1900 + p->tm_year, p->tm_mon + 1, p->tm_mday, p->tm_hour, p->tm_min, p->tm_sec);
|
|
|
}
|
|
|
printf("file name: %s\n", date_string);
|
|
|
filePtr = fopen(date_string, "w");
|
|
|
printf("create the temp dat file success!\n");
|
|
|
*file_name = (char*)MEM_alloc(sizeof(char) * 512);
|
|
|
sprintf(local_path, "%s\\%s", temp_dir, date_string);
|
|
|
strcpy((*file_name), local_path);
|
|
|
fprintf(filePtr, "%s", file_content);
|
|
|
//fwrite(file_content, sizeof(char), strlen(file_content), filePtr);
|
|
|
fclose(filePtr);
|
|
|
|
|
|
return ITK_ok;
|
|
|
} |