Пример #1
0
        public async Task <string> GrantCustomSpace(string userId, int type, string fileids = "")
        {
            DingTalkServerAddressConfig _addressConfig        = DingTalkServerAddressConfig.GetInstance();
            LoginMobileController       loginMobileController = new LoginMobileController();
            var access_token = await loginMobileController.GetAccessToken();

            HttpsClient _client = new HttpsClient();

            _client.QueryString.Add("access_token", access_token);
            _client.QueryString.Add("type", type == 0 ? "add" : "download");
            _client.QueryString.Add("userid", userId);
            _client.QueryString.Add("domain", "test");

            if (type == 0)
            {
                _client.QueryString.Add("path", "/"); //授权访问的路径,如授权访问所有文件传"/",授权访问/doc文件夹传"/doc/",需要utf-8 urlEncode, type=add时必须传递
            }
            else
            {
                _client.QueryString.Add("fileids", userId);
            }

            var url    = _addressConfig.GetGrantCustomSpace;
            var result = await _client.Get(url);

            return(result);
        }
Пример #2
0
        public async Task <object> SendCommomMessage(CommomOaSendModel commomOaSendModel)
        {
            DingTalkServerAddressConfig _addressConfig = DingTalkServerAddressConfig.GetInstance();
            HttpsClient _client = new HttpsClient();

            form[]      forms    = new form[] { };
            List <form> formList = new List <form>();

            if (commomOaSendModel.msg != null)
            {
                foreach (var item in commomOaSendModel.msg)
                {
                    formList.Add(new form()
                    {
                        key   = item.Key,
                        value = item.Value
                    }
                                 );
                }
            }
            forms = formList.ToArray();
            oa oa = new oa()
            {
                message_url = commomOaSendModel.linkUrl,
                head        = new head
                {
                    bgcolor = "FFBBBBBB",
                    text    = "头部标题111222"
                },
                body = new body
                {
                    title = commomOaSendModel.title,
                    form  = forms,
                }
            };
            NewOATestModel newOATestModel = new NewOATestModel()
            {
                msgtype = "oa",
                oa      = oa
            };

            DingTalk.Models.SendOAModel sendOAModel = new SendOAModel()
            {
                //E应用agent_id
                agent_id    = long.Parse(DTConfig.AppAgentId),
                userid_list = commomOaSendModel.userId,
                to_all_user = false,
                //dept_id_list = null,
                msg = newOATestModel
            };
            LoginMobileController loginMobileController = new LoginMobileController();
            var access_token = await loginMobileController.GetAccessToken();

            _client.QueryString.Add("access_token", access_token);
            var url    = _addressConfig.GetWorkMsgUrl;
            var result = await _client.UploadModel(url, sendOAModel);

            return(result);
        }
Пример #3
0
        public async Task <object> SendProjectMsg(string userId, string msg, string linkUrl = "eapp://page/start/index")
        {
            DingTalkServerAddressConfig _addressConfig = DingTalkServerAddressConfig.GetInstance();
            HttpsClient _client = new HttpsClient();
            oa          oa      = new oa()
            {
                message_url = linkUrl,
                head        = new head
                {
                    bgcolor = "FFBBBBBB",
                    text    = "头部标题111222"
                },
                body = new body
                {
                    title = "项目验收通知",
                    form  = new form[] {
                        new form {
                            key = "消息:", value = msg
                        },
                    },
                }
            };
            NewOATestModel newOATestModel = new NewOATestModel()
            {
                msgtype = "oa",
                oa      = oa
            };

            DingTalk.Models.SendOAModel sendOAModel = new SendOAModel()
            {
                //E应用agent_id
                agent_id    = long.Parse(DTConfig.AppAgentId),
                userid_list = userId,
                to_all_user = false,
                //dept_id_list = null,
                msg = newOATestModel
            };
            LoginMobileController loginMobileController = new LoginMobileController();
            var access_token = await loginMobileController.GetAccessToken();

            _client.QueryString.Add("access_token", access_token);
            var url    = _addressConfig.GetWorkMsgUrl;
            var result = await _client.UploadModel(url, sendOAModel);

            return(result);
        }
Пример #4
0
        public async Task <string> GetSendresult(long task_id)
        {
            DingTalkServerAddressConfig _addressConfig        = DingTalkServerAddressConfig.GetInstance();
            LoginMobileController       loginMobileController = new LoginMobileController();
            var access_token = await loginMobileController.GetAccessToken();

            HttpsClient _client = new HttpsClient();

            _client.QueryString.Add("access_token", access_token);
            var url = _addressConfig.GetResult;
            SendProgressModel sendProgressModel = new SendProgressModel()
            {
                task_id  = task_id,
                agent_id = 192520113
            };
            var result = await _client.UploadModel(url, sendProgressModel);

            return(result);
        }
Пример #5
0
        public async Task <string> SendDingPanFileToUser(SendDingPanModel sendDingPanModel)
        {
            DingTalkServerAddressConfig _addressConfig        = DingTalkServerAddressConfig.GetInstance();
            LoginMobileController       loginMobileController = new LoginMobileController();
            var access_token = await loginMobileController.GetAccessToken();

            HttpsClient _client = new HttpsClient();

            _client.QueryString.Add("access_token", access_token);
            _client.QueryString.Add("agent_id", DTConfig.AgentId);
            _client.QueryString.Add("userid", sendDingPanModel.userid);
            _client.QueryString.Add("media_id", sendDingPanModel.media_id);
            _client.QueryString.Add("file_name", sendDingPanModel.file_name);
            var url = _addressConfig.GetSendDingPanFileUrl;

            sendDingPanModel.agent_id     = DTConfig.AgentId;
            sendDingPanModel.access_token = access_token;
            var result = await _client.UploadModel(url, sendDingPanModel);

            return(result);
        }
Пример #6
0
        public async Task <string> SendLinkMessage(string userId, string text)
        {
            DingTalkServerAddressConfig _addressConfig = DingTalkServerAddressConfig.GetInstance();
            HttpsClient _client = new HttpsClient();
            //string urls = HttpUtility.UrlEncode("eapp://page/start/Test/Test?corpId=dingac9b87fa3acab57135c2f4657eb6378f&port63824");
            //string results = HttpUtility.UrlEncode(urls);
            SendWorkModel sendWorkModel = new SendWorkModel()
            {
                //manager5312
                //E应用agent_id 192520113
                agent_id     = long.Parse(DTConfig.AppAgentId),
                userid_list  = userId,
                to_all_user  = false,
                dept_id_list = null,
                msg          = (new MsgModel
                {
                    msgtype = "link",
                    link = new DingTalk.Models.MobileModels.linkTest
                    {
                        messageUrl = HttpUtility.UrlEncode("eapp://page/start/index"),
                        picUrl = "@lALOACZwe2Rk",
                        title = "标题:" + text,
                        text = text
                    },
                })
            };
            LoginMobileController loginMobileController = new LoginMobileController();
            var access_token = await loginMobileController.GetAccessToken();

            //AccessTokenModel accessTokenModel = JsonConvert.DeserializeObject<AccessTokenModel>(access_token);
            _client.QueryString.Add("access_token", access_token);
            var url    = _addressConfig.GetWorkMsgUrl;
            var result = await _client.UploadModel(url, sendWorkModel);

            return(result);
        }
        public async Task <string> SendLinkMessage(string userId)
        {
            DingTalkServerAddressConfig _addressConfig = DingTalkServerAddressConfig.GetInstance();
            HttpsClient _client = new HttpsClient();
            //string urls = HttpUtility.UrlEncode("eapp://page/start/Test/Test?corpId=dingac9b87fa3acab57135c2f4657eb6378f&port63824");
            //string results = HttpUtility.UrlEncode(urls);
            SendWorkModel sendWorkModel = new SendWorkModel()
            {
                //189694580    083452125733424957

                agent_id    = long.Parse(DTConfig.AgentId),
                userid_list = userId,
                to_all_user = false,
                msg         = (new MsgModel
                {
                    msgtype = "link",
                    link = new DingTalk.Models.MobileModels.linkTest
                    {
                        //messageUrl = "eapp:\\/\\/page/start\\/index?corpId=dingac9b87fa3acab57135c2f4657eb6378f",
                        //messageUrl= "https://www.baidu.com/",
                        messageUrl = HttpUtility.UrlEncode("eapp://page/start/Test/Test?corpId=dingac9b87fa3acab57135c2f4657eb6378f&port=63824"),
                        picUrl = "@lALOACZwe2Rk",
                        title = "测试啊321",
                        text = "继续测试"
                    },
                })
            };

            var access_token = await dtManager.GetAccessToken();

            AccessTokenModel accessTokenModel = JsonConvert.DeserializeObject <AccessTokenModel>(access_token);

            _client.QueryString.Add("access_token", accessTokenModel.access_token);
            var url    = _addressConfig.GetWorkMsgUrl;
            var result = await _client.UploadModel(url, sendWorkModel);

            return(result);

            //TopSDKTest top = new TopSDKTest();
            //OATextModel oaTextModel = new OATextModel();
            //oaTextModel.message_url = "eapp://page/start/index?corpId=dingac9b87fa3acab57135c2f4657eb6378f&port=49312";
            //oaTextModel.head = new head
            //{
            //    bgcolor = "FFBBBBBB",
            //    text = "头部标题111222"
            //};
            //oaTextModel.body = new body
            //{
            //    form = new form[] {
            //            new form{ key="姓名",value="11张三"},
            //            new form{ key="爱好",value="打球"},
            //        },
            //    rich = new rich
            //    {
            //        num = "15.6",
            //        unit = "元"
            //    },
            //    //title = "正文标题",
            //    content = "111一大段文字",
            //    image = "@lADOADmaWMzazQKA",
            //    file_count = "3",
            //    author = "李四"
            //};
            //return top.SendOaMessage(userId, oaTextModel);
        }
Пример #8
0
        public async Task <object> SendProcessingProgress(string userId, int type,
                                                          string applyMan, string bom, string taskId, string companyName,
                                                          string speedOfProgress, bool?IsRead, string linkUrl = "eapp://page/start/index")
        {
            DingTalkServerAddressConfig _addressConfig = DingTalkServerAddressConfig.GetInstance();
            HttpsClient _client = new HttpsClient();
            string      keyword = "";

            switch (type)
            {
            case 0: keyword = "新增"; break;

            case 1: keyword = "确认"; break;

            case 2: keyword = "修改"; break;

            case 3: keyword = "分配"; break;
            }
            ;

            oa oa = new oa()
            {
                message_url = linkUrl,
                head        = new head
                {
                    bgcolor = "FFBBBBBB",
                    text    = "头部标题111222"
                },
                body = new body
                {
                    title = string.Format("生产加工进度{0}通知", keyword),
                    form  = new form[] {
                        new form {
                            key = "公司名称:", value = companyName
                        },
                        new form {
                            key = string.Format("{0}人:", keyword), value = applyMan
                        },
                        new form {
                            key = string.Format("{0}时间:", keyword), value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                        },
                        new form {
                            key = string.Format("流水号:", keyword), value = taskId
                        },
                        new form {
                            key = string.Format("{0}BOM:", keyword), value = bom
                        },
                        new form {
                            key = string.Format("进度状态:"), value = speedOfProgress
                        },
                        new form {
                            key = string.Format("确认状态:"), value = IsRead == true?"已确认":"未确认"
                        },
                    },
                }
            };
            NewOATestModel newOATestModel = new NewOATestModel()
            {
                msgtype = "oa",
                oa      = oa
            };

            DingTalk.Models.SendOAModel sendOAModel = new SendOAModel()
            {
                //E应用agent_id
                agent_id    = long.Parse(DTConfig.AppAgentId),
                userid_list = userId,
                to_all_user = false,
                //dept_id_list = null,
                msg = newOATestModel
            };
            LoginMobileController loginMobileController = new LoginMobileController();
            var access_token = await loginMobileController.GetAccessToken();

            _client.QueryString.Add("access_token", access_token);
            var url    = _addressConfig.GetWorkMsgUrl;
            var result = await _client.UploadModel(url, sendOAModel);

            return(result);
        }
Пример #9
0
        public async Task <object> sendOaMessage(string userId, string title,
                                                 string applyMan, string linkUrl = "eapp://page/start/index")
        {
            DingTalkServerAddressConfig _addressConfig = DingTalkServerAddressConfig.GetInstance();
            HttpsClient _client = new HttpsClient();
            oa          oa      = new oa()
            {
                message_url = linkUrl,
                head        = new head
                {
                    bgcolor = "FFBBBBBB",
                    text    = "头部标题111222"
                },
                body = new body
                {
                    title = title,
                    form  = new form[] {
                        new form {
                            key = "申请人:", value = applyMan
                        },
                        new form {
                            key = "申请时间:", value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
                        },
                    },
                    //rich = new rich
                    //{
                    //    num = "15.6",
                    //    unit = "元"
                    //},
                    //content = "测试测试",
                    //image = "@lADOADmaWMzazQKA",
                    //file_count = "3",
                    //author = "申请人:" + applyMan
                }
            };
            NewOATestModel newOATestModel = new NewOATestModel()
            {
                msgtype = "oa",
                oa      = oa
            };

            DingTalk.Models.SendOAModel sendOAModel = new SendOAModel()
            {
                //E应用agent_id
                agent_id    = long.Parse(DTConfig.AppAgentId),
                userid_list = userId,
                to_all_user = false,
                //dept_id_list = null,
                msg = newOATestModel
            };


            LoginMobileController loginMobileController = new LoginMobileController();
            var access_token = await loginMobileController.GetAccessToken();

            _client.QueryString.Add("access_token", access_token);
            var url    = _addressConfig.GetWorkMsgUrl;
            var result = await _client.UploadModel(url, sendOAModel);

            return(result);
        }