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.

143 lines
3.9 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"kutil.h"
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include "libxl.h"
#include <io.h>
#include <direct.h>
#include <cstring>
#include <ctime>
#include <cfm/cfm.h>
#include <wchar.h>
#include <locale>
#include <ctime>
#include <iostream>
#include <codecvt>
#include <chrono>
#include <Windows.h>
#include <thread>
#include <regex>
#include <res\reservation.h>
#include "libxl.h"
#include <map>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
extern "C" int POM_AM__set_application_bypass(logical bypass);
int SH_PLM_Email(EPM_action_message_t msg) {
bool debug = false;
int ifail = ITK_ok, arg_cnt = 0, att_cnt = 0, task_count = 0, user_cnt = 0;
char* arg = NULL, * argflag = NULL, * argvalue = NULL;
char* user_name = NULL, * job_name = NULL, * object_string,*username = "";
tag_t owning_user = NULL;
tag_t task_tag = NULLTAG, rootTask_tag = NULLTAG, user_tag = NULLTAG;
tag_t* attachments = NULL, * task_tags = NULL;
arg_cnt = TC_number_of_arguments(msg.arguments);
vector<tag_t> all_user_tags;
vector<string> mail_addrs;
char* outPersonMailAddress = NULL;
char* content = NULL;
ITKCALL(POM_get_user(&user_name, &user_tag));
printf("=============================================================\n");
printf("¿ªÊ¼Ö´ÐУºSH_PLM_Email\n");
printf("=============================================================\n");
printf("¿ª³¬¼¶È¨ÏÞ\n");
POM_AM__set_application_bypass(true);
task_tag = msg.task;
if (task_tag == NULLTAG) {
goto end;
}
if (arg_cnt > 0)
{
for (int i = 0; i < arg_cnt; i++) {
arg = TC_next_argument(msg.arguments);
ITKCALL(ifail = ITK_ask_argument_named_value(arg, &argflag, &argvalue));
if (strcmp(argflag, "recipient") == 0) {
outPersonMailAddress = argvalue;
printf("outPersonMailAddress:%s\n",outPersonMailAddress);
}
if (strcmp(argflag, "content") == 0) {
content = argvalue;
printf("content:%s\n", content);
}
MEM_free(argflag);
MEM_free(argvalue);
}
}
ITKCALL(ifail = EPM_ask_root_task(task_tag, &rootTask_tag));
ITKCALL(ifail = AOM_ask_value_string(rootTask_tag, "job_name", &job_name));
ITKCALL(ifail = AOM_ask_value_tag(rootTask_tag, "owning_user", &owning_user));
ITKCALL(ifail = AOM_ask_value_string(owning_user, "user_name", &username));
ITKCALL(ifail = AOM_ask_value_string(rootTask_tag, "object_string", &object_string));
printf("Á÷³ÌÃû³Æ£º%s\n", job_name);
printf("·¢ÆðÈË£º%s\n", user_name);
//½âÎöÍⲿÓÊÏäÈËÔ±µØÖ·
if (outPersonMailAddress != NULL) {
vector<string> mailaddressVector;
Split(outPersonMailAddress, ";", mailaddressVector);
for (int i = 0; i < mailaddressVector.size(); i++) {
mail_addrs.push_back(mailaddressVector[i]);
}
}
user_cnt = mail_addrs.size();
printf("·¢ËÍÓʼþ¸öÊý£º%d\n", user_cnt);
printf("·¢ËÍÓʼþÈËÔ±£º%s\n", mail_addrs[0].c_str());
char zt[128] = "";
strcat(zt, "¡¾TeamCenter¡¿-");
strcat(zt, object_string);
printf("·¢ËÍÓʼþÖ÷Ì⣺%s\n", zt);
char nr[512] = "";
strcat(nr, "ÊÕµ½");
strcat(nr, username);
strcat(nr, "·¢ÆðµÄ");
strcat(nr, job_name);
strcat(nr, "ÈÎÎñ£¬");
strcat(nr, content);
printf("·¢ËÍÓʼþÄÚÈÝ£º%s\n", nr);
char jarfile[512] = "";
sprintf(jarfile, "%s\\bin\\EMailSender.jar", getenv("TC_ROOT"));
for (int i = 0; i < user_cnt; i++) {
char cmd[1024] = "";
string mail_addr = mail_addrs[i];
strcpy(cmd, "java -jar ");
strcat(cmd, jarfile);
strcat(cmd, " \"");
strcat(cmd, mail_addr.c_str());
strcat(cmd, "\" \"");
strcat(cmd, zt);
strcat(cmd, "\" \"");
strcat(cmd, nr);
strcat(cmd, "\"");
printf("CMD£º%s", cmd);
system(cmd);
printf("Ö´ÐÐÍê³É");
}
printf("¹Ø³¬¼¶È¨ÏÞ\n");
POM_AM__set_application_bypass(false);
end:
DOFREE(job_name);
DOFREE(attachments);
all_user_tags.clear();
printf("=============================================================\n");
printf("Ö´ÐнáÊø£ºSH_PLM_Email\n");
printf("=============================================================\n");
return ITK_ok;
}