zoukankan      html  css  js  c++  java
  • 第三方系统向泛微OA系统推送消息

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

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

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

    一、移动端消息推送

    1、超级管理员账号,登录移动端门户管理平台

     

    2、消息中心--消息类型创建

     

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

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

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

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

        

    • 请勿必保证license值是有效可用的,否则会导致调用接口失败

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

    二、电脑端消息推送

    1、超级管理员账号,登录协同办公平台

       

    2、后端应用中心

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

       

    3、配置允许调用工作流程WebService服务权限的IP地址

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

       

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

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

    5、流程引擎--表单管理--表单管理,创建自定义表单

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

       

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

       

    • 维护表单相关字段信息

       

       

    6、流程引擎—路径管理—路径设置,创建流程

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

       

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

       

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

       

    • 给节点,添加操作者,如下图所示

       

      

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

       

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

       

    7、查看流程Id(非常重要)

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

       

    8、门户--个人办公,配置消息显示

     

     

     

     

    附.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 resultXml = hrmService.getHrmUserInfoXML(hrmIpAddress, "", "", "", "", "");
                    log.Info("调用泛微OA人力资源getHrmUserInfoXML接口,接口返回数据:" + resultXml);
                    if (string.IsNullOrWhiteSpace(resultXml)
                        || resultXml == "<UserBean-array/>")
                    {
                        return ecologyUser;
                    }
    
                    //xml转成List
                    List<EcologyUser> userBeanList = Sheng.Kernal.JsonHelper.XmlToList<EcologyUser>(resultXml, "UserBean-array");
                    if (userBeanList.Any() == false)
                    {
                        return ecologyUser;
                    }
    
                    ecologyUser = userBeanList.FirstOrDefault(x => x.WorkCode == workCode);
                }
                catch (Exception ex)
                {
                    log.Error("调用泛微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
  • 相关阅读:
    fla使用as文件
    软件测试职业发展之路的反思(转)
    java 关键字
    卖空大师”:中国经济构造畸形 坚决卖空中国
    Cumulative Update package 3 for SQL Server 2008 R2
    tt
    javadoc
    as3程序主类,执行顺序
    AS3 (25) 处理声音
    10个励志小故事
  • 原文地址:https://www.cnblogs.com/YanKeJun/p/13501330.html
Copyright © 2011-2022 走看看