コード例 #1
0
        private void UpdateSetting(TransmitData transmitData)
        {
            //https://oapi.dingtalk.com/call_back/update_call_back?access_token=ACCESS_TOKEN
            string url = string.Format(CallbackSettingUrl.callBackSettingTemplate, CallbackSettingUrl.update_call_back, this.access_token);
            Dictionary <string, object> dicPara = new Dictionary <string, object>();

            dicPara.Add("call_back_tag", transmitData.callbackTag.ToArray());
            dicPara.Add("token", transmitData.token);
            dicPara.Add("aes_key", transmitData.aesKey);
            dicPara.Add("url", transmitData.callbackUrl);

            string result = SettingCallback.Request(url, "POST", dicPara);

            JObject rObj    = JObject.Parse(result);
            int     errcode = Convert.ToInt32(rObj["errcode"].ToString());

            if (errcode == 0)
            {
                SettingCallback.callbackNameList = transmitData.callbackTag;
            }
            else
            {
                throw new Exception("更新事件回调发生异常!响应内容:" + result);
            }
        }
コード例 #2
0
 public static SettingCallback GetInstance(TransmitData transmitData)
 {
     if (instance == null)
     {
         lock (locker)
         {
             if (instance == null)
             {
                 instance = new SettingCallback(transmitData);
             }
         }
         return(instance);
     }
     instance.access_token = instance.GetToken(transmitData.appKey, transmitData.appSecret);
     return(instance);
 }
コード例 #3
0
        private void RemoveSetting(TransmitData transmitData)
        {
            string url = string.Format(CallbackSettingUrl.callBackSettingTemplate, CallbackSettingUrl.delete_call_back, this.access_token);

            string result = SettingCallback.Request(url, "GET", null);

            JObject rObj    = JObject.Parse(result);
            int     errcode = Convert.ToInt32(rObj["errcode"].ToString());

            if (errcode == 0)
            {
                SettingCallback.callbackNameList = transmitData.callbackTag;
            }
            else
            {
                throw new Exception("删除事件回调发生异常!响应内容:" + result);
            }
        }
コード例 #4
0
        private SettingCallback(TransmitData transmitData)
        {
            this.access_token = this.GetToken(transmitData.appKey, transmitData.appSecret);

            List <string> tagList    = new List <string>();
            bool          hasSetting = this.HasSetting(out tagList);

            if (transmitData.callbackTag == null || transmitData.callbackTag.Count == 0)
            {
                if (hasSetting)
                {
                    new LaterExecute.LaterThread(RemoveSetting, transmitData);
                }
                else
                {
                    SettingCallback.callbackNameList = transmitData.callbackTag;
                }
            }
            else
            {
                if (hasSetting)
                {
                    if (!SettingCallback.ArrayIsEqual(tagList, transmitData.callbackTag))
                    {
                        //修改
                        new LaterExecute.LaterThread(UpdateSetting, transmitData);
                    }
                    else
                    {
                        SettingCallback.callbackNameList = tagList;
                    }
                }
                else
                {
                    //新增
                    new LaterExecute.LaterThread(RegisterSetting, transmitData);
                }
            }
        }
コード例 #5
0
 protected BaseHandles(TransmitData transmitData)
 {
     this.transmitData = transmitData;
 }