|
|
#include "epm_handler_common.h"
|
|
|
#include <tccore\aom_prop.h>
|
|
|
#include <tccore\aom.h>
|
|
|
#include <epm\epm.h>
|
|
|
#include <objbase.h>
|
|
|
#include <tccore\grm.h>
|
|
|
#include <tccore\iman_grmtype.h>
|
|
|
#include <fclasses/tc_date.h>
|
|
|
|
|
|
#include <tc\preferences.h>
|
|
|
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF","adoEOF")rename("BOF","adoBOF")
|
|
|
|
|
|
#define DOFREE(obj) \
|
|
|
{ \
|
|
|
if(obj) \
|
|
|
{ \
|
|
|
MEM_free(obj); \
|
|
|
obj = NULL; \
|
|
|
} \
|
|
|
}
|
|
|
|
|
|
int JL_Welding_Syetem(EPM_action_message_t msg){
|
|
|
int ifail = ITK_ok;
|
|
|
//当零部件发布时,若为D状态,且版本非D00版本,则向焊装排产系统数据库表写入发布的零件号、件名、版本、发布日期、发布时间等信息
|
|
|
tag_t rootTask = NULLTAG,*attachments,relation_type = NULLTAG;
|
|
|
int attachments_num = 0;
|
|
|
char *object_type = NULL,*revision = NULL,*status = NULL,*item_id = NULL,*item_name = NULL;
|
|
|
EPM_ask_root_task(msg.task, &rootTask);
|
|
|
//获取任务目标对象
|
|
|
EPM_ask_attachments(rootTask, EPM_target_attachment, &attachments_num, &attachments);
|
|
|
|
|
|
::CoInitialize(NULL); //初始化OLE/COM库环境
|
|
|
HRESULT hr = NULL;
|
|
|
_ConnectionPtr m_pConnection; // 数据库
|
|
|
_RecordsetPtr m_pRecordset; // 命令
|
|
|
_CommandPtr m_pCommand; // 记录
|
|
|
|
|
|
hr = m_pConnection.CreateInstance(_uuidof(Connection));//创建连接对象实例
|
|
|
if (SUCCEEDED(hr))
|
|
|
{
|
|
|
//m_pConnection->ConnectionString = ("Provider = SQLOLEDB.1; Persist Security Info = False; User ID =infodba; Password=infodba; Initial Catalog = TCTEST2; Data Source = 10.110.81.13");
|
|
|
m_pConnection->ConnectionString = ("Provider = SQLOLEDB.1; Persist Security Info = False; User ID =lw; Password=lw590; Initial Catalog = HZPC; Data Source = 192.168.200.6");
|
|
|
//printf("\n==========================================================\n");
|
|
|
hr = m_pConnection->Open("", "", "", adConnectUnspecified);//打开数据库
|
|
|
if (FAILED(hr))
|
|
|
{
|
|
|
printf("Open Failed!");
|
|
|
return 1;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
for (int i = 0; i < attachments_num; i++)
|
|
|
{
|
|
|
int release_counts = 0;
|
|
|
tag_t *release_tag = NULLTAG;
|
|
|
char release_value[SS_MAXPATHLEN] = "";
|
|
|
char *release_name = NULL;
|
|
|
AOM_ask_value_string(attachments[i], "object_type", &object_type);
|
|
|
printf("类型为:%s\n",object_type);
|
|
|
if(strstr(object_type,"PartsRevision") == NULL || strstr(object_type,"Master") != NULL){
|
|
|
continue;
|
|
|
}
|
|
|
//得到所有的发布状态
|
|
|
ITKCALL(AOM_ask_value_tags(attachments[i],"release_status_list",&release_counts, &release_tag));
|
|
|
printf("发布的数量:%d\n",release_counts);
|
|
|
for (int j = 0; j < release_counts; j++)
|
|
|
{
|
|
|
AOM_ask_value_string(release_tag[j], "object_name", &release_name); //原来excel数据集的object_name
|
|
|
printf("%s\n",release_name);
|
|
|
strcat(release_value,release_name);
|
|
|
}
|
|
|
//AOM_ask_value_string(attachments[i],"release_status_list",&status);
|
|
|
AOM_ask_value_string(attachments[i],"item_revision_id",&revision);
|
|
|
//若为D状态,且版本非D00版本
|
|
|
printf("%s——%s\n",release_value,revision);
|
|
|
if(strstr(release_value,"Gd6_D") !=NULL && strstr(revision,"D00") == NULL){
|
|
|
//向焊装排产系统数据库表写入发布的零件号、件名、版本、发布日期、发布时间等信息
|
|
|
//修改数据库
|
|
|
|
|
|
printf("开始写入\n");
|
|
|
//开始写入
|
|
|
AOM_ask_value_string(attachments[i],"object_name",&item_name);
|
|
|
AOM_ask_value_string(attachments[i],"item_id",&item_id);
|
|
|
date_t date = NULLDATE;
|
|
|
char *date_string = NULL;
|
|
|
AOM_ask_value_date(attachments[i],"date_released",&date);
|
|
|
DATE_date_to_string(date,"%Y-%m-%d %H:%M",&date_string);
|
|
|
printf("创建时间为:%s\n",date_string);
|
|
|
//printf("%s\n",date.year);
|
|
|
//printf("%s\n",date.month);
|
|
|
//printf("%s\n",date.day);
|
|
|
//printf("%s\n",date.hour);
|
|
|
//printf("%s\n",date.minute);
|
|
|
//printf("%s\n",date.second);
|
|
|
char* insertSql = (char*)calloc(1024, sizeof(char));
|
|
|
//sprintf(insertSql,"insert into AAA(PARTNO,PARTNAME,VerNO,REL_date) values('%s','%s','%s','%s')",item_id,item_name,revision,date_string);
|
|
|
sprintf(insertSql,"insert into PLM_GetPartVerNO(PARTNO,PARTNAME,VerNO,REL_date) values('%s','%s','%s','%s')",item_id,item_name,revision,date_string);
|
|
|
printf("写入语句为:%s\n",insertSql);
|
|
|
m_pConnection->Execute(_bstr_t(insertSql), 0, adCmdText);
|
|
|
insertSql = NULL;
|
|
|
DOFREE(release_name);
|
|
|
DOFREE(date_string);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
printf("Create instance of connection failed!");
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
|
|
|
DOFREE(object_type);
|
|
|
DOFREE(revision);
|
|
|
DOFREE(status);
|
|
|
DOFREE(item_id);
|
|
|
DOFREE(item_name);
|
|
|
return ifail;
|
|
|
}
|