第三方系統向泛微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
相關文章
相關標籤/搜索