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.
JK_ITK/jf_itk/w2_Clear_Form_PropValue.cpp

999 lines
30 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "w2_Clear_Form_PropValue.h"
#include "error_handling.h"
#include <string>
#include <vector>
#include <map>
#include <fstream>
#include <epm/epm.h>
#include <epm/epm_toolkit_tc_utils.h>
#include <ict/ict_userservice.h>
#include <tccore/item.h>
#include <ae/ae.h>
#include <tc/folder.h>
#include <tccore/aom.h>
#include <sa/sa.h>
#include <tccore/aom_prop.h>
#include <property/prop_errors.h>
#include <tccore/workspaceobject.h>
#include <tc/preferences.h>
#include <tccore/imantype.h>
#include <tccore//grm.h>
#include <tccore/grmtype.h>
#include <sa/am.h>
#include <cfm/cfm.h>
#include <bom/bom.h>
#include <tccore/uom.h>
#include <ps/ps.h>
#include <epm/signoff.h>
#include <fclasses/tc_date.h>
#include <ics\ics2.h>
//#include <iostream>
using namespace std;
#ifdef __cplusplus
extern "C" {
#endif
int delete_msword(tag_t dataset,char *ext,char *newRevType)
{
tag_t spec_dataset_rev = NULLTAG , ref_object = NULLTAG;
AE_reference_type_t reference_type;
printf("\n111111111111\n");
AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev);
char ref_name[WSO_name_size_c + 1] = "Fnd0word";
//printf("\n22222222222\n");
AE_ask_dataset_named_ref(spec_dataset_rev, ref_name, &reference_type, &ref_object);
if(reference_type == AE_PART_OF)
{
printf("\n3333333333333\n");
char pathname[SS_MAXPATHLEN] = "";
IMF_ask_file_pathname(ref_object, SS_WNT_MACHINE, pathname);
char origin_file_name[IMF_filename_size_c + 1] = "";
IMF_ask_original_file_name(ref_object, origin_file_name);
printf("\n44444444444444\n");
char new_ds_name[WSO_name_size_c + 1] = "";
char *new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
char *temp_dir = getenv("temp");
temp_dir="E:\\TEMP";
printf("\n555555555555\n");
char temp_file[SS_MAXPATHLEN] = "";
strcpy(temp_file, temp_dir);
strcat(temp_file, "\\");
strcat(temp_file, new_file_name);
IMF_export_file(ref_object, temp_file);
printf("\n66666666666666\n");
int iCnt;
char *user_lib_env,pTempStr[500];
char local_path[MAX_PATH] = "";
char cmd[256] = "";
//user_lib_env = getenv("TC_USER_LIB");
//strcpy(local_path, user_lib_env);
//iCnt = strlen(user_lib_env);
//while( user_lib_env[iCnt] != '\\' )
//{
// iCnt--;
//}
//strcpy(pTempStr,"");
//strcpy(pTempStr,&user_lib_env[iCnt+1]);
//if( strcmp(pTempStr,"SubstMacros-MSWord.wsf") != 0 )
//{
// strcat( user_lib_env, "\\SubstMacros-MSWord.wsf" );
//}
//strcpy( cmd, user_lib_env );
if(strcmp(newRevType,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"))
{
strcpy( cmd, "TXDeleteMacros-MSWord.wsf" );
}else
{
// strcpy( cmd, "JKDeleteMacros-MSWord.wsf" );
strcpy( cmd, "DeleteMacros-MSWord.wsf" );
}
strcat( cmd, " \"" );
strcat( cmd, temp_file );
strcat( cmd, "\"" );
printf( "\n%s\n",cmd );
system( cmd );
printf("\n777777777777\n");
//strcpy(user_lib_env, local_path);
tag_t new_file_tag = NULLTAG;
IMF_file_t file_descriptor;
IMF_import_file(temp_file, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor);
IMF_set_original_file_name(new_file_tag, origin_file_name);
IMF_close_file(file_descriptor);
AOM_save(new_file_tag);
AOM_unlock(new_file_tag);
AOM_lock(spec_dataset_rev);
AE_remove_dataset_named_ref_by_tag(spec_dataset_rev, ref_name, ref_object);
AE_add_dataset_named_ref(spec_dataset_rev, ref_name, AE_PART_OF, new_file_tag);
AOM_save(spec_dataset_rev);
AOM_unlock(spec_dataset_rev);
}
return ITK_ok;
}
int delete_msexcel(tag_t dataset, char *ext,char *newREV_type)
{
tag_t spec_dataset_rev = NULLTAG,
ref_object = NULLTAG;
AE_reference_type_t reference_type;
AE_ask_dataset_latest_rev(dataset, &spec_dataset_rev);
char ref_name[WSO_name_size_c + 1] = "excel";
AE_ask_dataset_named_ref(spec_dataset_rev, ref_name, &reference_type, &ref_object);
if(reference_type == AE_PART_OF)
{
char pathname[SS_MAXPATHLEN] = "";
IMF_ask_file_pathname(ref_object, SS_WNT_MACHINE, pathname);
char origin_file_name[IMF_filename_size_c + 1] = "";
IMF_ask_original_file_name(ref_object, origin_file_name);
char new_ds_name[WSO_name_size_c + 1] = "";
char *new_file_name = USER_new_file_name(new_ds_name, ref_name, ext, 0);
char *temp_dir = getenv("temp");
temp_dir="E:\\TEMP";
char temp_file[SS_MAXPATHLEN] = "";
strcpy(temp_file, temp_dir);
strcat(temp_file, "\\");
strcat(temp_file, new_file_name);
IMF_export_file(ref_object, temp_file);
int iCnt;
char *user_lib_env,pTempStr[500];
char local_path[MAX_PATH] = "";
char cmd[256] = "";
/*user_lib_env = getenv("TC_USER_LIB");
strcpy(local_path, user_lib_env);
iCnt = strlen(user_lib_env);
while( user_lib_env[iCnt] != '\\' )
{
iCnt--;
}
strcpy(pTempStr,"");
strcpy(pTempStr,&user_lib_env[iCnt+1]);
if( strcmp(pTempStr,"SubstMacros-MSExcel.wsf") != 0 )
{
strcat( user_lib_env, "\\SubstMacros-MSExcel.wsf" );
}*/
//strcpy( cmd, user_lib_env );
if(strcmp(newREV_type,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"))
{
strcpy( cmd, "TXDeleteMacros-MSExcel.wsf" );
}else
{
// strcpy( cmd, "JKDeleteMacros-MSExcel.wsf" );
strcpy( cmd, "DeleteMacros-MSExcel.wsf" );
}
strcat( cmd, " \"" );
strcat( cmd, temp_file );
strcat( cmd, "\"" );
printf( "\n%s\n",cmd );
system( cmd );
//strcpy(user_lib_env, local_path);
tag_t new_file_tag = NULLTAG;
IMF_file_t file_descriptor;
IMF_import_file(temp_file, new_file_name, SS_BINARY, &new_file_tag, &file_descriptor);
IMF_set_original_file_name(new_file_tag, origin_file_name);
IMF_close_file(file_descriptor);
AOM_save(new_file_tag);
AOM_unlock(new_file_tag);
AOM_lock(spec_dataset_rev);
//CALL(AOM_load (dataset));
//CALL(AOM_load(spec_dataset_rev));
AE_remove_dataset_named_ref_by_tag(spec_dataset_rev, ref_name, ref_object);
AE_add_dataset_named_ref(spec_dataset_rev, ref_name, AE_PART_OF, new_file_tag);
AOM_save(spec_dataset_rev);
AOM_unlock(spec_dataset_rev);
}
return ITK_ok;
}
int W2_Revise_clear_form( METHOD_message_t* msg, va_list args )
{
int ifail = ITK_ok, i = 0, j = 0;
char rev_type[ITEM_type_size_c + 1],
*optionname= "W2_Revise_clear_form";\
map<int, string> prop_map;
//int msgid = va_arg(args,int );
tag_t new_rev = va_arg(args,tag_t );
char* operation = va_arg(args,char* );
/*tag_t parent_rev = va_arg(args,tag_t );
int copyCount = va_arg(args,int );
tag_t **obj_tags = va_arg(args,tag_t** );*/
printf("*******************************************************\n");
printf("* W2_Revise_clear_form is comming *\n");
printf("*******************************************************\n");
//printf("msgid==============================%d \n",msgid);
printf("new_rev==============================%d\n",new_rev);
printf("operation==============================%s\n",operation);
//printf("parent_rev==============================%u\n",parent_rev);
//printf("copyCount==============================%d\n",copyCount);
//-------------<2D><>ȡ<EFBFBD><C8A1>ѡ<EFBFBD><D1A1>(origin+rev_type+_str),itemrev<65><76>Form<72><6D>ϵ<EFBFBD><CFB5>Form<72><6D><EFBFBD>͡<EFBFBD><CDA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int option_value_count;
char **option_values;
char *PREF_W2_Revise_clear_form="JK_Revise_ItemRev";//<2F><>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(strcmp(operation,"Revise")!=0 && strcmp(operation,"SaveAs")!=0){
return ifail;
}
ITKCALL(PREF_ask_char_values(PREF_W2_Revise_clear_form,&option_value_count,&option_values));
printf("=====option_value_count======%d\n",option_value_count);
if(option_value_count == 0)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>option<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>%s<><73>\n",PREF_W2_Revise_clear_form);
return ifail;
}
////-----------<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-------
//for (j = 1; j <option_value_count; j++)
//{
// prop_map.insert(make_pair(j-1, option_values[j]));
//}
for(int i=0;i<option_value_count;i++){
char charlist[100][100];
int col =0;
char *substr= strtok(option_values[i], ":");
printf("substr :%s\n", substr);
while (substr != NULL) {
strcpy(charlist[col],substr);
col++;
printf("%s\n", substr);
substr = strtok(NULL,":");
}
char *type=new char[32];
ITKCALL(WSOM_ask_object_type(new_rev,type));
printf("type :%s\n", type);
if(strcmp(type,charlist[0])==0){
char charlist2[100][100];
int col2 =0;
char *substr= strtok(charlist[1], ",");
while (substr != NULL) {
strcpy(charlist2[col2],substr);
col2++;
printf("%s\n", substr);
substr = strtok(NULL,",");
}
ITKCALL( AOM_lock( new_rev ) );
for(int m=0;m<col2;m++){
ITKCALL(AOM_set_value_string(new_rev,charlist2[m],""));
ITKCALL( AOM_save( new_rev ) );
}
ITKCALL( AOM_unlock( new_rev ) );
ITKCALL( AOM_refresh( new_rev,true ) );
}
}
MEM_free(option_values);
/* //-----------<2D><><EFBFBD>ҹ<EFBFBD>ϵ-----------WTB<54><42><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ֵ,<2C><>Ϊmasterform
tag_t relationTag = NULLTAG;
//ITKCALL (GRM_find_relation_type(option_values[0],&relationTag));
ITKCALL (GRM_find_relation_type("IMAN_master_form",&relationTag));
if(relationTag == NULLTAG)
{
printf("=====<3D><EFBFBD><EBBDA8>%s<><73>ϵ<EFBFBD><CFB5><EFBFBD>ͣ<EFBFBD>======\n",option_values[0]);
return ifail;
}
//-----------ͨ<><CDA8><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>Form<72><6D><EFBFBD><EFBFBD>
int rfCount = 0;
tag_t *rfTags = NULL;
char form_object_type[WSO_name_size_c+1];
ITKCALL (GRM_list_secondary_objects_only(new_rev,relationTag,&rfCount,&rfTags));//
printf("=====rfCount======%d\n",rfCount);
for(i = 0; i < rfCount; i++)
{
ITKCALL(WSOM_ask_object_type(rfTags[i],form_object_type));
printf("=====form_object_type======%s\n",form_object_type);
//----------WTBȡ<42><C8A1>item<65><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//if(tc_strcmp(form_object_type,option_values[1]) == 0)
{
ITKCALL( AOM_lock( rfTags[i] ) );
for(j = 1;j < option_value_count; j++)
//---------WTB<54><42>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>Ϊ<EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD>ֵ<EFBFBD><D6B5>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//for(j = 2;j < option_value_count; j++)
{
ITKCALL(AOM_set_value_string(rfTags[i],option_values[j],""));
ITKCALL( AOM_save( rfTags[i] ) );
}
ITKCALL( AOM_unlock( rfTags[i] ) );
ITKCALL( AOM_refresh( rfTags[i],true ) );
break;
}
}
*/
char rev_id[ITEM_id_size_c+1]="";
char item_id[ITEM_id_size_c+1]="";
char* newREV_type=NULL;
tag_t master_form_rel_type = NULLTAG;
tag_t item = NULLTAG;
ITEM_ask_rev_id(new_rev,rev_id);
ITEM_ask_item_of_rev( new_rev, &item);
ITEM_ask_id(item, item_id);
GRM_find_relation_type( TC_master_form_rtype, &master_form_rel_type );
AOM_ask_value_string(new_rev,"object_type",&newREV_type);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD>
tag_t relation_type=NULLTAG;
//tag_t attach_relation_type = NULLTAG;
GRM_find_relation_type(TC_specification_rtype, &relation_type);
tag_t *secondary_objects=NULLTAG;
int ds_count = 0;
char *dataset_type = NULL, *desc_value=NULL,*file_path = NULL,*desc_path;
GRM_list_secondary_objects_only(new_rev, relation_type, &ds_count, &secondary_objects);
for (int j = 0; j < ds_count; j++)
{
AOM_ask_value_string(secondary_objects[j], "object_type", &dataset_type);
//if(strcmp(dataset_type, "JF3_DWG") == 0)
//{
//// ECHO("<22><><EFBFBD><EFBFBD>dwg...\n");
//// POM_AM__set_application_bypass(true);
//// ifail = export_dataset_file(dataset_list[j], "PDF_Reference", "dwg", &filename,&original_name);
// if( data_file != NULL )
// signoff_acad(secondary_objects[j],data_file);
//}
//else
if(strcmp(dataset_type, "MSWord") ==0 )
{
delete_msword(secondary_objects[j],"doc",newREV_type);
}
else if(strcmp(dataset_type, "MSWordX") ==0)
{
delete_msword(secondary_objects[j],"docm",newREV_type);
}
else if(strcmp(dataset_type, "MSExcel") ==0 )
{
delete_msexcel(secondary_objects[j],"xls",newREV_type);
}
else if(strcmp(dataset_type, "MSExcelX") ==0)
{
delete_msexcel(secondary_objects[j],"xlsm",newREV_type);
}
//else if(strcmp(dataset_type, "PDF") ==0){
// signoff_pdf(secondary_objects[j],data_file,"pdf");
//}
MEM_free(dataset_type);
}
DOFREE(secondary_objects);
GRM_find_relation_type(TC_attaches_rtype, &relation_type);
GRM_list_secondary_objects_only(new_rev, relation_type, &ds_count, &secondary_objects);
for (int j = 0; j < ds_count; j++)
{
AOM_ask_value_string(secondary_objects[j], "object_type", &dataset_type);
//if(strcmp(dataset_type, "JF3_DWG") == 0)
//{
//// ECHO("<22><><EFBFBD><EFBFBD>dwg...\n");
//// POM_AM__set_application_bypass(true);
//// ifail = export_dataset_file(dataset_list[j], "PDF_Reference", "dwg", &filename,&original_name);
// if( data_file != NULL )
// signoff_acad(secondary_objects[j],data_file);
//}
//else
if(strcmp(dataset_type, "MSWord") ==0 )
{
delete_msword(secondary_objects[j],"doc",newREV_type);
}
else if(strcmp(dataset_type, "MSWordX") ==0)
{
delete_msword(secondary_objects[j],"docm",newREV_type);
}
else if(strcmp(dataset_type, "MSExcel") ==0 )
{
delete_msexcel(secondary_objects[j],"xls",newREV_type);
}
else if(strcmp(dataset_type, "MSExcelX") ==0)
{
delete_msexcel(secondary_objects[j],"xlsm",newREV_type);
}
//else if(strcmp(dataset_type, "PDF") ==0){
// signoff_pdf(secondary_objects[j],data_file,"pdf");
//}
MEM_free(dataset_type);
}
DOFREE(secondary_objects);
if(newREV_type!=NULL)
{
MEM_free(newREV_type);
newREV_type=NULL;
}
/**/
printf("*******************************************************\n");
printf("* W2_Clear_Form_PropValue is end *\n");
printf("*******************************************************\n");
return ifail;
}
//int D5DFHM_Clear_Form_PropValue( METHOD_message_t* msg, va_list args )
//{
// int ifail = ITK_ok, i = 0, j = 0;
// char rev_type[ITEM_type_size_c + 1],
// *origin = "DFHM_", *_str = "_Clear_QzInfo",
// *option_name ;
// tag_t new_rev = va_arg(args,tag_t );
// char* operation = va_arg(args,char* );
// tag_t parent_rev = va_arg(args,tag_t );
// int copyCount = va_arg(args,int );
// tag_t **obj_tags = va_arg(args,tag_t** );
// printf("*******************************************************\n");
// printf("* D5DFHM_Clear_Form_PropValue is comming *\n");
// printf("*******************************************************\n");
// /*printf("new_rev==============================%d\n",new_rev);
// printf("operation==============================%s\n",operation);
// printf("parent_rev==============================%u\n",parent_rev);
// printf("copyCount==============================%d\n",copyCount);*/
// int paramCount = 0, index = 0;
// BMF_extension_arguments_t *input_args = NULL;
// char DataSetType[BMF_EXTENSION_STRGVAL_size_c + 1];
// ifail = BMF_get_user_params(msg, &paramCount, &input_args);
// if (ifail == ITK_ok && paramCount > 0)
// {
// for(index = 0; index < paramCount; index++)
// {
// tc_strcpy(DataSetType, input_args[index].arg_val.str_value);
// printf("DataSetType=========%s\n",DataSetType);
// option_name = (char*)MEM_alloc(sizeof(char)*(tc_strlen(origin)+tc_strlen(DataSetType)+tc_strlen(_str)+1));
// tc_strcpy(option_name,origin);
// tc_strcat(option_name,DataSetType);
// tc_strcat(option_name,_str);
// //-------------<2D><>ȡ<EFBFBD><C8A1>ѡ<EFBFBD><D1A1>(origin+rev_type+_str),itemrev<65><76>Form<72><6D>ϵ<EFBFBD><CFB5>Form<72><6D><EFBFBD>͡<EFBFBD><CDA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// int option_value_count;
// char **option_values;
// ITKCALL(PREF_ask_char_values(option_name,&option_value_count,&option_values));
// printf("=====option_value_count======%d\n",option_value_count);
// if(option_value_count == 0)
// {
// printf("<22><><EFBFBD><EFBFBD>option<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>%s<><73>\n",option_name);
// MEM_free(option_name);
// break;
// }
// MEM_free(option_name);
// //-----------<2D><><EFBFBD>ҹ<EFBFBD>ϵ
// tag_t relationTag = NULLTAG;
// ITKCALL (GRM_find_relation_type(option_values[0],&relationTag));
// if(relationTag == NULLTAG)
// {
// printf("=====<3D><EFBFBD><EBBDA8>%s<><73>ϵ<EFBFBD><CFB5><EFBFBD>ͣ<EFBFBD>======\n",option_values[0]);
// break;
// }
// //-----------ͨ<><CDA8><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>Form<72><6D><EFBFBD><EFBFBD>
// int rfCount = 0;
// tag_t *rfTags = NULL;
// char form_object_type[WSO_name_size_c+1];
// ITKCALL (GRM_list_secondary_objects_only(new_rev,relationTag,&rfCount,&rfTags));//
// printf("=====rfCount======%d\n",rfCount);
// for(i = 0; i < rfCount; i++)
// {
// ITKCALL(WSOM_ask_object_type(rfTags[i],form_object_type));
// printf("=====form_object_type======%s\n",form_object_type);
// if(tc_strcmp(form_object_type,option_values[1]) == 0)
// {
// ITKCALL( AOM_lock( rfTags[i] ) );
// for(j = 2;j < option_value_count; j++)
// {
// ITKCALL(AOM_set_value_string(rfTags[i],option_values[j],""));
// ITKCALL( AOM_save( rfTags[i] ) );
// }
// ITKCALL( AOM_unlock( rfTags[i] ) );
// ITKCALL( AOM_refresh( rfTags[i],true ) );
// break;
// }
// }
// MEM_free(option_values);
// MEM_free(rfTags);
// }
// MEM_free(input_args);
// }
// /**/
// printf("*******************************************************\n");
// printf("* D5DFHM_Clear_Form_PropValue is end *\n");
// printf("*******************************************************\n");
// return ifail;
//}
/**/
//iman_save(itemrevision)
/*int Origin_Clear_Form_PropValue( METHOD_message_t* msg, va_list args )
{
int ifail = ITK_ok, i = 0, j = 0;
char rev_type[ITEM_type_size_c + 1],
*origin = "origin_", *_str = "_Clear_QzInfo",
*option_name = "Origin_ACADDWG_Clear_QzInfo";
tag_t item_rev = va_arg(args,tag_t );
printf("*******************************************************\n");
printf("* Origin_Clear_Form_PropValue is comming *\n");
printf("*******************************************************\n");
ITKCALL(ITEM_ask_rev_type(item_rev,rev_type));
char rev_id[ITEM_id_size_c + 1];
ITKCALL(ITEM_ask_rev_id(item_rev,rev_id));
printf("rev_type==============================%s\n",rev_type);
printf("rev_id==============================%s\n",rev_id);
//option_name = (char*)MEM_alloc(sizeof(char)*(tc_strlen(origin)+tc_strlen(rev_type)+tc_strlen(_str)+1));
//tc_strcpy(option_name,origin);
//tc_strcat(option_name,rev_type);
//tc_strcat(option_name,_str);
//-------------<2D><>ȡ<EFBFBD><C8A1>ѡ<EFBFBD><D1A1>(origin+rev_type+_str),itemrev<65><76>Form<72><6D>ϵ<EFBFBD><CFB5>Form<72><6D><EFBFBD>͡<EFBFBD><CDA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int option_value_count;
char **option_values;
ITKCALL(PREF_ask_char_values(option_name,&option_value_count,&option_values));
printf("=====option_value_count======%d\n",option_value_count);
if(option_value_count == 0)
{
printf("<22><><EFBFBD><EFBFBD>option<6F><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>%s<><73>\n",option_name);
return ITK_ok;
}
//-----------<2D><><EFBFBD>ҹ<EFBFBD>ϵ
tag_t relationTag = NULLTAG;
ITKCALL (GRM_find_relation_type(option_values[0],&relationTag));
if(relationTag == NULLTAG)
{
printf("=====<3D><EFBFBD><EBBDA8>%s<><73>ϵ<EFBFBD><CFB5><EFBFBD>ͣ<EFBFBD>======\n",option_values[0]);
return ITK_ok;
}
//-----------ͨ<><CDA8><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD>Form<72><6D><EFBFBD><EFBFBD>
int rfCount = 0;
tag_t *rfTags = NULL;
char form_object_type[WSO_name_size_c+1];
ITKCALL (GRM_list_secondary_objects_only(item_rev,relationTag,&rfCount,&rfTags));//
printf("=====rfCount======%d\n",rfCount);
GRM_relation_t* secondary_list ;
ITKCALL (GRM_list_secondary_objects(item_rev,relationTag,&rfCount,&secondary_list));//
printf("=====rfCount111111======%d\n",rfCount);
ITEM_attached_object_t* objects;
ITKCALL (ITEM_list_all_rev_attachments(item_rev,&rfCount,&objects));//
printf("=====rfCount2222222======%d\n",rfCount);
int t = 0;
tag_t *tg = NULLTAG;
ITKCALL(AOM_ask_value_tags(item_rev,option_values[0],&t,&tg));
printf("=====tttttttt======%d\n",t);
for(i = 0; i < rfCount; i++)
{
ITKCALL(WSOM_ask_object_type(objects[i].attachment,form_object_type));
printf("=====form_object_type======%s\n",form_object_type);
if(tc_strcmp(form_object_type,option_values[1]) == 0)
{
ITKCALL( AOM_lock( rfTags[i] ) );
for(j = 2;j < option_value_count; j++)
{
ITKCALL(AOM_set_value_string(rfTags[i],option_values[j]," "));
ITKCALL( AOM_save( rfTags[i] ) );
}
ITKCALL( AOM_unlock( rfTags[i] ) );
break;
}
}
//MEM_free(option_name);
MEM_free(option_values);
MEM_free(rfTags);
printf("*******************************************************\n");
printf("* Origin_Clear_Form_PropValue is end *\n");
printf("*******************************************************\n");
return ifail;
}*/
int Create_item_test( METHOD_message_t* msg, va_list args )
{
int ifail = ITK_ok, i = 0, j = 0, form_count=0;
tag_t item_tag = NULLTAG, rev = NULLTAG,master_form_rel_type = NULLTAG,
master_form = NULLTAG, *form_list=NULL;
char item_type[WSO_name_size_c+1]="", *value=NULL;
item_tag = msg->object;
CALL( WSOM_ask_object_type( item_tag, item_type ) );
printf("=============type is %s\n",item_type);
if (strcmp(item_type,"Item")==0)
{
CALL(ITEM_ask_latest_rev(item_tag, &rev));
CALL( GRM_find_relation_type( TC_master_form_rtype, &master_form_rel_type ) );
CALL(GRM_list_secondary_objects_only(rev, master_form_rel_type, &form_count, &form_list ));
master_form = form_list[0];
CALL(AOM_lock(master_form));
CALL( AOM_set_value_string( master_form, "user_data_1", "δ<EFBFBD><EFBFBD>ʼ") );
CALL( AOM_save( master_form ) );
CALL( AOM_unlock( master_form ) );
printf("set property success!\n");
}
//tag_t form_tag = NULLTAG;
//tag_t object_type_tag = NULLTAG;
//tag_t form_type_tag = NULLTAG;
//logical is_form_type = false;
//form_tag = msg->object;
//char form_type[WSO_name_size_c+1]="", *value=NULL;
//
//CALL( WSOM_ask_object_type( form_tag, form_type ) );
//
//CALL( TCTYPE_ask_object_type (form_tag, &object_type_tag));
//CALL( TCTYPE_find_type ("Form",NULL,&form_type_tag));
//CALL( AOM_is_type_of(form_tag,form_type_tag,&is_form_type));
// printf("=============type is %s\n",item_type);
//if (strstr(form_type, "ItemRevision Master") != NULL)
//{
// CALL(AOM_lock(form_tag));
// CALL(AOM_ask_value_string(form_tag, "user_data_1", &value));
// printf("=============value is %s\n",value);
// //if(strcmp(value,"")!=0)
// {
// //EMH_store_error_s1(EMH_severity_user_error, ERROR_NO_WRITE_PRIVILEGE, "Form");
// //ifail = ERROR_NO_WRITE_PRIVILEGE;
// //goto end_handler;
// //CALL(AOM_set_value_string(form_tag, "user_data_1",value));
// ifail = AM_insufficient_privilege;
// return ifail;
// }
//}
return ITK_ok;
}
extern int Register_revise_msg( void )
{
int status = ITK_ok;
char *err_string,*err_function;
int err_line = -1;
printf("W2_Revise_clear_form<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
METHOD_id_t mth_tag;
ITKCALL(status = METHOD_find_method("ItemRevision", ITEM_deep_copy_msg ,&mth_tag));
if (mth_tag.id != 0){
ITKCALL( METHOD_add_action(mth_tag, METHOD_post_action_type, W2_Revise_clear_form, NULL));
printf("ע<EFBFBD><EFBFBD>W2_Revise_clear_form<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
}
/* ITKCALL(status = METHOD_find_method("Item", ITEM_create_msg ,&mth_tag));
if (mth_tag.id != 0){
ITKCALL( METHOD_add_action(mth_tag, METHOD_post_action_type, Create_item_test, NULL));
printf("ע<><D7A2>Create_item_test<73><74><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>\n");
}*/
return status;
}
#define SAFECALL(x) \
{ \
err_function = #x; err_line = __LINE__; \
if((rcode = (x)) != ITK_ok) \
{ \
goto CLEANUP; \
} \
}
void va_copy( va_list *dest , va_list * src ){
*dest = *src ;
}
static int SMP_ask_bomline_value( METHOD_message_t * m, va_list args )
{
int rcode = ITK_ok;
char *err_string,*err_function;
int err_line = -1;
tag_t objTag = NULLTAG;
const char * prop_name;
char** value = NULL;
char *bom_rev_status = NULL;
char sQty[] = "";
char sUnRead[] = "UNREADABLE";
va_list largs;
tag_t bom_line_item = NULLTAG;
tag_t bom_line_rev = NULLTAG;
tag_t last_rev = NULLTAG;
tag_t iman_type_tag = NULLTAG ;
char obj_class_name[TCTYPE_class_name_size_c+1];
char obj_type_name[TCTYPE_name_size_c+1];
int attr_bom_item = 0;
int attr_bom_rev = 0;
int attr_bom_rev_status = 0;
char item_rev_id[ITEM_id_size_c+1]="",item_id[ITEM_id_size_c+1]="",rev_id[ITEM_id_size_c+1]="",
strRow[BUFSIZ]="",txtfile[BUFSIZ]="", obj_type[WSO_object_type_size_c+1]="";
tag_t master_form_rel_type = NULLTAG;
int form_count = 0, attr_qty_id = 0;
tag_t *form_list=NULL, master_form = NULLTAG;
char *d_value=NULL, *qty_value = NULL;
METHOD_PROP_MESSAGE_OBJECT(m, objTag) /* objTag is the tag of the property's owning object */
METHOD_PROP_MESSAGE_PROP_NAME(m, prop_name) /* prop_name is the name of the current property */
printf("\n <20><><EFBFBD><EFBFBD> name : %s\n",prop_name);
va_copy( &largs, &args );
va_arg( largs, tag_t ); /* ignore the first tag_t arg */
value = va_arg( largs, char**);
va_end( largs );
//<2F><>ȡĿ<C8A1><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ITKCALL( TCTYPE_ask_object_type( objTag,&iman_type_tag ) );
ITKCALL( TCTYPE_ask_class_name(iman_type_tag,obj_class_name));//get ClassName of attachment
ITKCALL( TCTYPE_ask_name(iman_type_tag,obj_type_name) );
printf("\n Type name : %s\n",obj_type_name);
//if ( strcmp( obj_type_name , "Mfg0BvrPart" ) == 0 )
//{
//
//}
//if ( strcmp( obj_type_name , "Mfg0BvrPart" ) == 0 )
if ( strcmp( obj_type_name , "BOMLine" ) == 0 )
{
printf("\n is BOMLine\n");
SAFECALL( BOM_line_look_up_attribute( bomAttr_lineItemTag , & attr_bom_item ) );
SAFECALL( BOM_line_look_up_attribute( bomAttr_lineItemRevTag , & attr_bom_rev ) );
SAFECALL( BOM_line_look_up_attribute( bomAttr_occQty , & attr_qty_id ) );
SAFECALL( BOM_line_ask_attribute_tag( objTag, attr_bom_item , &bom_line_item ));
SAFECALL( BOM_line_ask_attribute_tag( objTag, attr_bom_rev , &bom_line_rev ));
SAFECALL( BOM_line_ask_attribute_string( objTag, attr_qty_id, &qty_value ));
SAFECALL( WSOM_ask_object_type(bom_line_item, obj_type ));
printf("\n obj_type=%s",obj_type);
//if( strcmp(obj_type, "Mfg0BvrPart") == 0)
if( strcmp(obj_type, "C7Part") == 0)
{
SAFECALL( GRM_find_relation_type( TC_master_form_rtype, &master_form_rel_type ) );
SAFECALL( GRM_list_secondary_objects_only(bom_line_rev, master_form_rel_type, &form_count, &form_list ));
master_form = form_list[0];
if( master_form != NULLTAG )
{
SAFECALL(AOM_UIF_ask_value(master_form, "c7GeneralClfion", &d_value));
printf("\n d_value=%s\n",d_value);
TC_write_syslog("\n d_value=%s\n",d_value);
//<2F><><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD><DEB8><EFBFBD><EFBFBD>ӱ<EFBFBD>ʶ
if( strcmp(d_value, "C") == 0
|| strcmp(d_value, "F") == 0
|| strcmp(d_value, "F1") == 0
|| strcmp(d_value, "F2") == 0
|| strcmp(d_value, "F3") == 0 )
{
strcpy(sQty,"");
}
else
{
if( strcmp(qty_value,"") == 0)
{
strcpy(sQty,"1");
}
else
strcpy(sQty,qty_value);
}
MEM_free(d_value);
}
MEM_free(form_list);
}
}
CLEANUP :
if( rcode != ITK_ok)
{
if ( 515001 == rcode || err_line == 80 ){
if ( *value != NULL ) MEM_free( *value );
*value = NULL;
*value = (char*)MEM_alloc ( 10 + 1 );
strcpy ( *value, "1" );
EMH_clear_errors( );
rcode = ITK_ok;
}else
{
EMH_ask_error_text (rcode, &err_string);
printf ("ERROR: %d ERROR MSG: %s.\n", rcode, err_string);
printf ("Function: %s FILE: %s LINE: %d\n", err_function, __FILE__, err_line);
MEM_free (err_string);
}
TC_write_syslog("\n rcode != ITK_ok");
}else{
if ( *value != NULL ) MEM_free( *value );
*value = NULL ;
*value = (char*)MEM_alloc ( strlen ( sQty ) + 1 );
strcpy ( *value, sQty );
TC_write_syslog("\n else sQty=%s",sQty);
}
return rcode;
}
int SMP_init_user_bomline_props(METHOD_message_t* m, va_list args)
{
int rcode = ITK_ok;
char *err_string,*err_function;
int err_line = -1;
tag_t type_tag;
tag_t pd_tag = NULLTAG;
METHOD_id_t method;
char typename_cpp[TCTYPE_name_size_c+1];
tag_t lov_tag;
tag_t tmp_lov_tag;
va_list largs;
va_copy( &largs, &args );
type_tag = va_arg( largs, tag_t );
va_end( largs );
ITKCALL( TCTYPE_ask_name( type_tag, typename_cpp ) );
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>=%s \n",typename_cpp);
/* ====== add properties for Bomline class types ====== */
/* ---- add superseded runtime property ---- */
ITKCALL( TCTYPE_add_runtime_property( type_tag, "jk8ckckckc",PROP_string,1,&pd_tag ) );
//
///* --- set display name...can also be done in user_property_names.uil --- */
ITKCALL( PROPDESC_set_display_name(pd_tag,"jk8ckckckc") );
/* --- register method to ask value --- */
ITKCALL( METHOD_register_prop_method( (const char*)typename_cpp, "jk8ckckckc", PROP_ask_value_string_msg, SMP_ask_bomline_value , 0 , &method ) );
printf("\n <20><><EFBFBD><EFBFBD>\n");
/* --- register method to set value --- */
//SAFECALL( PROPDESC_set_protection( pd_tag, PROP_write ) );
//SAFECALL( METHOD_register_prop_method( (const char*)typename, "superseded", PROP_set_value_string_msg, SMP_set_bomline_superseded , 0 , &method ) );
CLEANUP:
if( rcode != ITK_ok)
{
EMH_ask_error_text (rcode, &err_string);
printf ("ERROR: %d ERROR MSG: %s.\n", rcode, err_string);
printf ("Function: FILE: %s LINE: %d\n", __FILE__, err_line);
MEM_free (err_string);
}
return( ITK_ok );
}
extern int Run_Time_register_properties( void )
{
int rcode = ITK_ok;
char *err_string,*err_function;
int err_line = -1;
USER_prop_init_entry_t user_types_methods[]= { { "BOMLine" , SMP_init_user_bomline_props , NULL } };
int n_types = sizeof(user_types_methods)/sizeof(USER_prop_init_entry_t);
printf("n_types=%d \n",n_types);
SAFECALL( TCTYPE_register_properties(user_types_methods, n_types ));
printf("\n TCTYPE_register_properties\n");
CLEANUP:
if( rcode != ITK_ok)
{
EMH_ask_error_text (rcode, &err_string);
printf ("ERROR: %d ERROR MSG: %s.\n", rcode, err_string);
printf ("Function: FILE: %s LINE: %d\n", __FILE__, err_line);
MEM_free (err_string);
}
return rcode;
}
#ifdef __cplusplus
}
#endif
#include <stdarg.h>
#include <base_utils\Mem.h>
#include <tccore\grm.h>
#include <tccore\grmtype.h>
#include <tc\iman.h>
#include <user_exits\user_exits.h>
#include <tccore\method.h>
#include <property\prop.h>
#include <tccore\aom_prop.h>
#include <property\prop_msg.h>
#include <tccore\imantype.h>
#include <property\prop_errors.h>
#include <tccore\item.h>
#include <lov\lov.h>
#include <sa\sa.h>
#include <tc\emh.h>
#include <res\reservation.h>
#include <tccore\workspaceobject.h>
#include <tc\wsouif_errors.h>
#include <tccore\aom.h>
#include <form\form.h>
#include <bom\bom.h>
#include <epm\cr.h>
#include <epm\releasestatus.h>
/**
* @headerfile standard c & cpp header files
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <fstream>
#include <iostream>
using namespace std;
/**
* @headerfile user's header files
*/