如下操做案例中关于第三方系统向泛微OA系统的移动端和电脑端版本推送消息说明:html
• 移动端使用的是泛微系统登陆帐号(工号)来最终实现消息的推送后端
• 电脑端使用的是泛微系统用户表中的id字段来最终实现消息的推送服务器
配置完成后,会自动生成消息标识Id;而后根据外部系统推送示例,实现移动端消息推送。jsp
实现移动端消息推送,必需要消息标识Id和e-mobile消息推送密钥ide
消息标识Id:新建消息类型成功后,会自动生成消息标识Idui
消息推送密钥:“服务器管理”—“系统状态”—服务器属性:e-mobile消息推送密钥url
请勿必保证license值是有效可用的,不然会致使调用接口失败.net
以上都配置完成后,修改调用程序中对应的相关参数,可能首次调用接口没法接收到消息,请先屡次调用后。3d
页面右上角更多,点击 后端应用中心code
须要在OA的/Ecology/WEB-INF/prop/HrmWebserviceIP.properties配置文件中配置调用接口客户端的IP,调用接口时传入的参数ip包涵在此配置文件才能调用人力资源WebService服务的全部接口。
附.net代码
/// <summary> /// 调用泛微OA系统接口 /// </summary> public class EcologyManager { ILog log = log4net.LogManager.GetLogger("EcologyManager"); static String basePushUrl = ConfigurationManager.AppSettings["EcologyMobilePushUrl"]; static String key = ConfigurationManager.AppSettings["EcologyMobilePushKey"];//emobile后台的推送秘钥 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"]; /// <summary> /// 向泛微移动端推送消息 /// </summary> /// <param name="message">消息</param> /// <param name="receiverId">接收者的loginid,多用户使用英文半角逗号分开</param> /// <returns></returns> public void PushMobileMessage(string message, string receiverId) { try { //url = url ?? messageUrl + "?account=" + receiverId; string badge = "1"; //消息数量+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<string, string> para = new Dictionary<string, string>(); para.Add("messagetypeid", messageTypeId);//在mobile后台注册的消息类型id para.Add("module", "-2"); //标示属于自定义消息 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<KeyValuePair<String, String>> paramList = new List<KeyValuePair<String, String>>(); paramList.Add(new KeyValuePair<string, string>("userid", receiverId)); paramList.Add(new KeyValuePair<string, string>("msg", message)); paramList.Add(new KeyValuePair<string, string>("badge", badge)); paramList.Add(new KeyValuePair<string, string>("para", paraJson)); paramList.Add(new KeyValuePair<string, string>("hash", hash)); HttpResponseMessage response = httpClient.PostAsync(new Uri(basePushUrl), new FormUrlEncodedContent(paramList)).Result; log.Info($"Ecology移动端消息推送:{Environment.NewLine}用户工号:{receiverId },消息内容:{message };{Environment.NewLine}接口响应结果:{Sheng.Kernal.JsonHelper.Serializer(response)}"); } catch (Exception ex) { log.Error($"Ecology移动端消息推送:{Environment.NewLine}用户工号:{receiverId },消息内容:{message };{Environment.NewLine}接口异常,异常信息:{ex.Message},异常堆栈信息:{ex.StackTrace}"); } } /// <summary> /// 向泛微电脑端推送消息 /// </summary> /// <param name="title">消息标题</param> /// <param name="ecoloryUserId">消息接收人</param> public void PushPCMessage(string title, int ecoloryUserId) { try { //主字段 WorkflowRequestTableField[] wrti = new WorkflowRequestTableField[1]; //字段信息 wrti[0] = new WorkflowRequestTableField(); WorkflowRequestTableRecord[] wrtri = new WorkflowRequestTableRecord[1];//主字段只有一行数据 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;//流程标题 wri.workflowMainTableInfo = wmi;//添加主字段数据 wri.workflowBaseInfo = wbi; //执行建立流程接口 WorkflowService workflowService = new WorkflowService(); workflowService.Url = workflowServiceUrl; String requestid = workflowService.doCreateWorkflowRequest(wri, ecoloryUserId);//接收人 log.Info($"Ecology电脑端消息推送;{Environment.NewLine}泛微USERID:{ecoloryUserId },消息内容:{title }{Environment.NewLine}接口响应结果:{requestid}"); } catch (Exception ex) { log.Error($"Ecology电脑端消息推送;{Environment.NewLine}泛微USERID:{ecoloryUserId },消息内容:{title }{Environment.NewLine}接口异常,异常信息:{ex.Message},异常堆栈信息:{ex.StackTrace}"); } } /// <summary> /// 根据工号获取泛微用户信息 /// </summary> /// <param name="workCode">工号</param> /// <returns></returns> public EcologyUser GetEcologyUserByWorkCode(string workCode) { EcologyUser ecologyUser = new EcologyUser(); try { //调用泛微OA系统人力资源接口 //须要在泛微OA系统的安装目录 /Ecology/WEB-INF/prop/HrmWebserviceIP.properties 配置文件中配置调用接口客户端的IP(=hrmIpAddress),不然没法调用人力资源相关接口 HrmService hrmService = new HrmService(); hrmService.Url = hrmServiceUrl; //获取泛微全部用户 string result"", "", "", "", ""); log.Info("调用泛微OA人力资源getHrmUserInfo" + resultif (string.IsNullOrWhiteSpace(result|| result"<UserBean-array/>") { return ecologyUser; } // List<EcologyUser> userBeanList = Sheng.Kernal.JsonHelper."UserBean-array"); if (userBeanList.Any() == false) { return ecologyUser; } ecologyUser = userBeanList.FirstOrDefault(x => x.WorkCode == workCode); } catch (Exception ex) { log.Error("调用泛微OA人力资源getHrmUserInfo" + 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 第三方系统向泛微OA系统推送消息 文章转载:http://www.shaoqun.com/a/464378.html