Beispiel #1
0
 public MessageCorpconversationAsyncsendV2Response SendAsynMsg(OpenAuth.Repository.Domain.Message message)
 {
     try
     {
         Message.Request.MessageCorpconversationAsyncsendV2Request req = new Message.Request.MessageCorpconversationAsyncsendV2Request();
         req.AgentId    = Ext.ToLong(DDHelper.GetAgentId());
         req.ToAllUser  = false;
         req.UseridList = message.RecieveUsers;
         var msg = new Message.Request.MessageCorpconversationAsyncsendV2Request.MsgDomain();
         msg.text         = new Message.Request.MessageCorpconversationAsyncsendV2Request.TextDomain();
         msg.text.content = message.MsgContent;
         msg.msgtype      = "text";
         req.Msg          = msg;
         string Url      = string.Format("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?access_token={0}", DDHelper.GetToken());
         string response = Infrastructure.Web.WebHelper.HttpWebRequestJson(Url, req.GetParametersToJosn());
         MessageCorpconversationAsyncsendV2Response res = response.ToObject <MessageCorpconversationAsyncsendV2Response>();
         if (res.Errcode == 0)
         {
             messageApp.UpdateToRecevice(new string[] { message.Id });
         }
         else
         {
             messageApp.UpdateToReceviceErrMsg(message.Id, res.Errmsg);
         }
         return(res);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Beispiel #2
0
        public MessageCorpconversationSendResponse SendMsg(OpenAuth.Repository.Domain.Message message)
        {
            try
            {
                Message.Request.MessageCorpconversationSendRequest req = new Message.Request.MessageCorpconversationSendRequest();
                req.AgentId     = Ext.ToLong(DDHelper.GetAgentId());
                req.ToUser      = message.RecieveUsers.Replace(",", "|");
                req.MessageType = ((Message.Request.MessageCorpconversationSendRequest.MessageTypeDomain)(message.MsgType)).ToString();

                req.textMessage = new Message.Request.MessageCorpconversationSendRequest.TextDomain
                {
                    content = message.MsgContent
                };
                string Url      = string.Format("https://oapi.dingtalk.com/message/send?access_token={0}", DDHelper.GetToken());
                string response = Infrastructure.Web.WebHelper.HttpWebRequestJson(Url, req.GetParametersToJosn());
                MessageCorpconversationSendResponse res = response.ToObject <MessageCorpconversationSendResponse>();
                if (res.Errcode == 0)
                {
                    messageApp.UpdateToRecevice(new string[] { message.Id });
                }
                else
                {
                    messageApp.UpdateToReceviceErrMsg(message.Id, res.Errmsg);
                }
                return(res);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Beispiel #3
0
 public UpdateUserResponse UpdateUser(UpdateUserRequest model)
 {
     try
     {
         string             url      = string.Format("https://oapi.dingtalk.com/user/update?access_token={0}", DDHelper.GetToken());
         string             response = Infrastructure.Web.WebHelper.HttpWebRequestJson(url, model.GetParametersToJosn());
         UpdateUserResponse res      = response.ToObject <UpdateUserResponse>();
         if (res.Errcode == 0)
         {
             _OtherUserApp.SetStatus(model.Userid, res.Errmsg, true);
         }
         else
         {
             _OtherUserApp.SetStatus(model.Userid, res.Errmsg, false);
         }
         return(res);
     }
     catch (Exception ex)
     {
         _OtherUserApp.SetStatus(model.Userid, ex.Message, false);
         return(null);
     }
 }
Beispiel #4
0
 public string GetJsApiTicket(string accessToken)
 {
     return(DDHelper.GetJsApiTicket(accessToken));
 }
Beispiel #5
0
        //public static DingDingService Instance = new DingDingService();


        /// <summary>
        /// 获取AccessToken
        /// 开发者在调用开放平台接口前需要通过CorpID和CorpSecret获取AccessToken。
        /// </summary>
        /// <returns></returns>
        public string GetAccessToken()
        {
            return(DDHelper.GetToken());
        }
Beispiel #6
0
 public GetDeptListRespon DDGetAllDept()
 {
     try
     {
         GetDeptRequest r = new GetDeptRequest();
         r.Id = "1";
         string            Url      = string.Format("https://oapi.dingtalk.com/department/list?access_token={0}", DDHelper.GetToken());
         string            response = Infrastructure.Web.WebHelper.HttpWebRequestJson(Url, r.ToJson(), false);
         GetDeptListRespon res      = response.ToObject <GetDeptListRespon>();
         return(res);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Beispiel #7
0
 public GetDeptRespon DDGetDept(DelDeptRequest model)
 {
     try
     {
         string        Url      = string.Format("https://oapi.dingtalk.com/department/get?access_token={0}&id={1}", DDHelper.GetToken(), model.Id);
         string        response = Infrastructure.Web.WebHelper.HttpWebRequest(Url);
         GetDeptRespon res      = response.ToObject <GetDeptRespon>();
         return(res);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Beispiel #8
0
 public void DDDelDept(DelDeptRequest model)
 {
     try
     {
         string           Url      = string.Format("https://oapi.dingtalk.com/department/delete?access_token={0}&id={1}", DDHelper.GetToken(), model.Id);
         string           response = Infrastructure.Web.WebHelper.HttpWebRequest(Url);
         CreateDeptRespon res      = response.ToObject <CreateDeptRespon>();
         if (res.Errcode == 0)
         {
             _Orgapp.SetStatus(model.Id, 0, res.Id.ToString(), true);
         }
         else
         {
             _Orgapp.SetStatus(model.Id, 1, res.Errmsg, false);
         }
     }
     catch (Exception ex)
     {
         _Orgapp.SetStatus(model.Id, 2, ex.Message, false);
     }
 }
Beispiel #9
0
 public void DDUpdateDept(UpdateDeptRequest model)
 {
     try
     {
         string           Url      = string.Format("https://oapi.dingtalk.com/department/update?access_token={0}", DDHelper.GetToken());
         string           response = Infrastructure.Web.WebHelper.HttpWebRequestJson(Url, model.GetParametersToJosn());
         CreateDeptRespon res      = response.ToObject <CreateDeptRespon>();
         if (res.Errcode == 0)
         {
             _Orgapp.SetStatus(model.SourceIdentifier, 0, res.Id.ToString(), true);
         }
         else
         {
             _Orgapp.SetStatus(model.SourceIdentifier, 1, res.Errmsg, false);
         }
     }
     catch (Exception ex)
     {
         _Orgapp.SetStatus(model.SourceIdentifier, 2, ex.Message, false);
     }
 }
Beispiel #10
0
        public GetUserListResponse GetUserList(GetUserListRequest model)
        {
            try
            {
                string url      = string.Format("https://oapi.dingtalk.com/user/list?access_token={0}&department_id={1}", DDHelper.GetToken(), model.DepartmentId);
                string response = Infrastructure.Web.WebHelper.HttpWebRequest(url);

                GetUserListResponse res = response.ToObject <GetUserListResponse>();
                return(res);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Beispiel #11
0
 public UserDeleteResponse DelUser(UserDeleteRequest model)
 {
     try
     {
         string             url      = string.Format("https://oapi.dingtalk.com/user/delete?access_token={0}&userid={1}", DDHelper.GetToken(), model.Userid);
         string             response = Infrastructure.Web.WebHelper.HttpWebRequest(url);
         UserDeleteResponse res      = response.ToObject <UserDeleteResponse>();
         if (res.Errcode == 0)
         {
             _OtherUserApp.SetStatus(model.Userid, res.Errmsg, true);
         }
         else
         {
             _OtherUserApp.SetStatus(model.Userid, res.Errmsg, false);
         }
         return(res);
     }
     catch (Exception ex)
     {
         _OtherUserApp.SetStatus(model.Userid, ex.Message, false);
         return(null);
     }
 }