泛微oa java .net_第三方系统向泛微OA系统推送消息
本文將要為您介紹的是第三方系統(tǒng)向泛微OA系統(tǒng)推送消息,具體完成步驟:向泛微OA系統(tǒng)推送消息
以下操作案例中關(guān)于第三方系統(tǒng)向泛微OA系統(tǒng)的移動(dòng)端和電腦端版本推送消息說明:
? 移動(dòng)端使用的是泛微系統(tǒng)登錄賬號(hào)(工號(hào))來最終實(shí)現(xiàn)消息的推送
?電腦端使用的是泛微系統(tǒng)用戶表中的id字段來最終實(shí)現(xiàn)消息的推送
一、移動(dòng)端消息推送
1、超級(jí)管理員賬號(hào),登錄移動(dòng)端門戶管理平臺(tái)
2、消息中心--消息類型創(chuàng)建
配置完成后,會(huì)自動(dòng)生成消息標(biāo)識(shí)Id;然后根據(jù)外部系統(tǒng)推送示例,實(shí)現(xiàn)移動(dòng)端消息推送。
實(shí)現(xiàn)移動(dòng)端消息推送,必須要消息標(biāo)識(shí)Id和e-mobile消息推送密鑰
消息標(biāo)識(shí)Id:新建消息類型成功后,會(huì)自動(dòng)生成消息標(biāo)識(shí)Id
消息推送密鑰:“服務(wù)器管理”—“系統(tǒng)狀態(tài)”—服務(wù)器屬性:e-mobile消息推送密鑰
請(qǐng)勿必保證license值是有效可用的,否則會(huì)導(dǎo)致調(diào)用接口失敗
以上都配置完成后,修改調(diào)用程序中對(duì)應(yīng)的相關(guān)參數(shù),可能首次調(diào)用接口無法接收到消息,請(qǐng)先多次調(diào)用后。
二、電腦端消息推送
1、超級(jí)管理員賬號(hào),登錄協(xié)同辦公平臺(tái)
2、后端應(yīng)用中心
頁面右上角
更多,點(diǎn)擊 后端應(yīng)用中心
3、配置允許調(diào)用工作流程WebService服務(wù)權(quán)限的IP地址
頁面地址為:/workflow/UserList.jsp
4、配置允許調(diào)用人力資源WebService服務(wù)權(quán)限的IP地址
需要在OA的/Ecology/WEB-INF/prop/HrmWebserviceIP.properties配置文件中配置調(diào)用接口客戶端的IP,調(diào)用接口時(shí)傳入的參數(shù)ip包涵在此配置文件才能調(diào)用人力資源WebService服務(wù)的所有接口。
5、流程引擎--表單管理--表單管理,創(chuàng)建自定義表單
點(diǎn)擊“新建”按紐,彈出新建表單模態(tài)窗,填寫“表單名稱”,最后點(diǎn)擊“保存”按紐。
“批量刪除”按紐旁邊文本框中輸入填寫的表單名稱,點(diǎn)擊搜索,查詢添加的表單,然后編輯該表單
維護(hù)表單相關(guān)字段信息
6、流程引擎—路徑管理—路徑設(shè)置,創(chuàng)建流程
選擇流程放在哪個(gè)路徑目錄下,然后點(diǎn)擊目錄文件夾,再點(diǎn)擊“添加”按紐,填寫路徑流程信息
基礎(chǔ)設(shè)置--基本信息,只需要填寫“路徑名稱”、“對(duì)應(yīng)表單”2個(gè)字段,其它可以不添加或修改
流轉(zhuǎn)設(shè)置--節(jié)點(diǎn)信息,--編輯,添加流程節(jié)點(diǎn),只需要添加“創(chuàng)建“、“歸檔“ 2 個(gè)節(jié)點(diǎn)
給節(jié)點(diǎn),添加操作者,如下圖所示
給節(jié)點(diǎn),設(shè)置表單內(nèi)容,如下圖所示
流轉(zhuǎn)設(shè)置--出口信息,添加出口信息即流程結(jié)束節(jié)點(diǎn),如下圖所示
7、查看流程Id(非常重要)
調(diào)用創(chuàng)建流程接口時(shí),需要使用流程Id(workflowId)
調(diào)用創(chuàng)建流程接口時(shí),需要?jiǎng)?chuàng)建人Id(creatorId),該值對(duì)應(yīng)的是泛微OA系統(tǒng)用戶表中的用戶Id
8、門戶--個(gè)人辦公,配置消息顯示
附.net代碼
///
/// 調(diào)用泛微OA系統(tǒng)接口
///
public class EcologyManager
{
ILog log = log4net.LogManager.GetLogger("EcologyManager");
static String basePushUrl = ConfigurationManager.AppSettings["EcologyMobilePushUrl"];
static String key = ConfigurationManager.AppSettings["EcologyMobilePushKey"];//emobile后臺(tái)的推送秘鑰
static String messageUrl = ConfigurationManager.AppSettings["EcologyMobileMessageUrl"];
static String messageTypeId = ConfigurationManager.AppSettings["EcologyMobileMessageTypeId"];
static String workflowServiceUrl = ConfigurationManager.AppSettings["EcologyWorkflowServiceUrl"];
static String hrmServiceUrl = ConfigurationManager.AppSettings["EcologyHrmServiceUrl"];
static String workflowId = ConfigurationManager.AppSettings["EcologyWorkflowId"];
static String workflowLevel = ConfigurationManager.AppSettings["EcologyWorkflowLevel"];
static String hrmIpAddress = ConfigurationManager.AppSettings["EcologyHrmIpAddress"];
///
/// 向泛微移動(dòng)端推送消息
///
/// 消息
/// 接收者的loginid,多用戶使用英文半角逗號(hào)分開
///
public void PushMobileMessage(string message, string receiverId)
{
try
{
//url = url ?? messageUrl + "?account=" + receiverId;
string badge = "1"; //消息數(shù)量+1
HttpClient httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; rv:8.0.1) Gecko/20100101 Firefox/8.0.1");
Dictionary para = new Dictionary();
para.Add("messagetypeid", messageTypeId);//在mobile后臺(tái)注冊(cè)的消息類型id
para.Add("module", "-2"); //標(biāo)示屬于自定義消息
para.Add("url", messageUrl);
string paraJson = Sheng.Kernal.JsonHelper.Serializer(para);
StringBuilder sendMsg = new StringBuilder();
if (message.Length > 100)
message = message.Substring(0, 100) + "...";
sendMsg.Append(receiverId);
sendMsg.Append(message);
sendMsg.Append(badge);
sendMsg.Append(paraJson);
sendMsg.Append(key);
string hash = Md5Hex(sendMsg.ToString());
List> paramList = new List>();
paramList.Add(new KeyValuePair("userid", receiverId));
paramList.Add(new KeyValuePair("msg", message));
paramList.Add(new KeyValuePair("badge", badge));
paramList.Add(new KeyValuePair("para", paraJson));
paramList.Add(new KeyValuePair("hash", hash));
HttpResponseMessage response = httpClient.PostAsync(new Uri(basePushUrl), new FormUrlEncodedContent(paramList)).Result;
log.Info($"Ecology移動(dòng)端消息推送:{Environment.NewLine}用戶工號(hào):{receiverId },消息內(nèi)容:{message };{Environment.NewLine}接口響應(yīng)結(jié)果:{Sheng.Kernal.JsonHelper.Serializer(response)}");
}
catch (Exception ex)
{
log.Error($"Ecology移動(dòng)端消息推送:{Environment.NewLine}用戶工號(hào):{receiverId },消息內(nèi)容:{message };{Environment.NewLine}接口異常,異常信息:{ex.Message},異常堆棧信息:{ex.StackTrace}");
}
}
///
/// 向泛微電腦端推送消息
///
/// 消息標(biāo)題
/// 消息接收人
public void PushPCMessage(string title, int ecoloryUserId)
{
try
{
//主字段
WorkflowRequestTableField[] wrti = new WorkflowRequestTableField[1]; //字段信息
wrti[0] = new WorkflowRequestTableField();
WorkflowRequestTableRecord[] wrtri = new WorkflowRequestTableRecord[1];//主字段只有一行數(shù)據(jù)
wrtri[0] = new WorkflowRequestTableRecord();
wrtri[0].workflowRequestTableFields = wrti;
WorkflowMainTableInfo wmi = new WorkflowMainTableInfo();
wmi.requestRecords = wrtri;
WorkflowBaseInfo wbi = new WorkflowBaseInfo();
wbi.workflowId = workflowId;
WorkflowRequestInfo wri = new WorkflowRequestInfo();//流程基本信息
wri.creatorId = ecoloryUserId.ToString();//接收人
wri.requestLevel = workflowLevel; //0 正常,1重要,2緊急
wri.requestName = title;//流程標(biāo)題
wri.workflowMainTableInfo = wmi;//添加主字段數(shù)據(jù)
wri.workflowBaseInfo = wbi;
//執(zhí)行創(chuàng)建流程接口
WorkflowService workflowService = new WorkflowService();
workflowService.Url = workflowServiceUrl;
String requestid = workflowService.doCreateWorkflowRequest(wri, ecoloryUserId);//接收人
log.Info($"Ecology電腦端消息推送;{Environment.NewLine}泛微USERID:{ecoloryUserId },消息內(nèi)容:{title }{Environment.NewLine}接口響應(yīng)結(jié)果:{requestid}");
}
catch (Exception ex)
{
log.Error($"Ecology電腦端消息推送;{Environment.NewLine}泛微USERID:{ecoloryUserId },消息內(nèi)容:{title }{Environment.NewLine}接口異常,異常信息:{ex.Message},異常堆棧信息:{ex.StackTrace}");
}
}
///
/// 根據(jù)工號(hào)獲取泛微用戶信息
///
/// 工號(hào)
///
public EcologyUser GetEcologyUserByWorkCode(string workCode)
{
EcologyUser ecologyUser = new EcologyUser();
try
{
//調(diào)用泛微OA系統(tǒng)人力資源接口
//需要在泛微OA系統(tǒng)的安裝目錄 /Ecology/WEB-INF/prop/HrmWebserviceIP.properties 配置文件中配置調(diào)用接口客戶端的IP(=hrmIpAddress),否則無法調(diào)用人力資源相關(guān)接口
HrmService hrmService = new HrmService();
hrmService.Url = hrmServiceUrl;
//獲取泛微所有用戶
string resultXml = hrmService.getHrmUserInfoXML(hrmIpAddress, "", "", "", "", "");
log.Info("調(diào)用泛微OA人力資源getHrmUserInfoXML接口,接口返回?cái)?shù)據(jù):" + resultXml);
if (string.IsNullOrWhiteSpace(resultXml)
|| resultXml == "")
{
return ecologyUser;
}
//xml轉(zhuǎn)成List
List userBeanList = Sheng.Kernal.JsonHelper.XmlToList(resultXml, "UserBean-array");
if (userBeanList.Any() == false)
{
return ecologyUser;
}
ecologyUser = userBeanList.FirstOrDefault(x => x.WorkCode == workCode);
}
catch (Exception ex)
{
log.Error("調(diào)用泛微OA人力資源getHrmUserInfoXML接口異常,異常信息:" + ex.Message + Environment.NewLine + ex.StackTrace);
}
return ecologyUser;
}
private static string Md5Hex(string data)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] dataHash = md5.ComputeHash(Encoding.UTF8.GetBytes(data));
StringBuilder sb = new StringBuilder();
foreach (byte b in dataHash)
{
sb.Append(b.ToString("x2").ToLower());
}
return sb.ToString();
}
}
View Code
第三方系統(tǒng)向泛微OA系統(tǒng)推送消息就為您介紹到這里,感謝您關(guān)注懶咪學(xué)編程c.lanmit.com.
本文地址:https://c.lanmit.com/bianchengkaifa/net/101281.html
總結(jié)
以上是生活随笔為你收集整理的泛微oa java .net_第三方系统向泛微OA系统推送消息的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前端学习(1508):组件和模块的区别
- 下一篇: 计算机操作系统(第四版)课后习题答案(第