第三方系统向泛微OA系统推送消息

向泛微OA系统推送消息

如下操做案例中关于第三方系统向泛微OA系统的移动端和电脑端版本推送消息说明:html

  •  移动端使用的是泛微系统登陆帐号(工号)来最终实现消息的推送后端

  •  电脑端使用的是泛微系统用户表中的id字段来最终实现消息的推送服务器

 

1、移动端消息推送

一、超级管理员帐号,登陆移动端门户管理平台

 

 

二、消息中心--消息类型建立

 

  • 配置完成后,会自动生成消息标识Id;而后根据外部系统推送示例,实现移动端消息推送。jsp

  • 实现移动端消息推送,必需要消息标识Id和e-mobile消息推送密钥ide

    消息标识Id:新建消息类型成功后,会自动生成消息标识Idui

    消息推送密钥:“服务器管理”—“系统状态”—服务器属性:e-mobile消息推送密钥url

    

  • 请勿必保证license值是有效可用的,不然会致使调用接口失败.net

  • 以上都配置完成后,修改调用程序中对应的相关参数,可能首次调用接口没法接收到消息,请先屡次调用后。3d

 

2、电脑端消息推送

一、超级管理员帐号,登陆协同办公平台

   

 

二、后端应用中心

  页面右上角更多,点击 后端应用中心code

   

 

三、配置容许调用工做流程WebService服务权限的IP地址

  • 页面地址为:/workflow/UserList.jsp

   

 

四、配置容许调用人力资源WebService服务权限的IP地址

  • 须要在OA的/Ecology/WEB-INF/prop/HrmWebserviceIP.properties配置文件中配置调用接口客户端的IP,调用接口时传入的参数ip包涵在此配置文件才能调用人力资源WebService服务的全部接口。

 

五、流程引擎--表单管理--表单管理,建立自定义表单

  • 点击“新建”按纽,弹出新建表单模态窗,填写“表单名称”,最后点击“保存”按纽。

   

 

  • “批量删除”按纽旁边文本框中输入填写的表单名称,点击搜索,查询添加的表单,而后编辑该表单

   

 

  • 维护表单相关字段信息

   

   

 

六、流程引擎—路径管理—路径设置,建立流程

  • 选择流程放在哪一个路径目录下,而后点击目录文件夹,再点击“添加”按纽,填写路径流程信息

   

 

  • 基础设置--基本信息,只须要填写“路径名称”、“对应表单”2个字段,其它能够不添加或修改

   

 

  • 流转设置--节点信息,--编辑,添加流程节点,只须要添加“建立“、“归档“ 2 个节点

   

 

  • 给节点,添加操做者,以下图所示

   

  

 

  • 给节点,设置表单内容,以下图所示

   

 

  • 流转设置--出口信息,添加出口信息即流程结束节点,以下图所示

   

 

七、查看流程Id(很是重要)

  • 调用建立流程接口时,须要使用流程Id(workflowId)
  • 调用建立流程接口时,须要建立人Id(creatorId),该值对应的是泛微OA系统用户表中的用户Id

   

 

八、门户--我的办公,配置消息显示

 

 

 

 

 

附.net代码

ContractedBlock.gif ExpandedBlockStart.gif
 /// <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
相关文章
相关标签/搜索