Beispiel #1
0
        /// <summary>
        /// 更新一条待办事项,该待办事项在该用户的“待办事项”列表页面中消失
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="userId"></param>
        /// <param name="record_id"></param>
        /// <returns></returns>
        public static SendWorkRecordResult UpdateWorkRecord(string accessToken, string userId, string record_id)
        {
            SendWorkRecordResult result = new SendWorkRecordResult();

            try
            {
                TimeSpan                    ts     = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                long                        time   = Convert.ToInt64(ts.TotalSeconds);
                IDingTalkClient             client = new  DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/workrecord/update");
                OapiWorkrecordUpdateRequest req    = new OapiWorkrecordUpdateRequest();
                req.Userid   = userId;
                req.RecordId = record_id;//待办时间。Unix时间戳,毫秒级
                OapiWorkrecordUpdateResponse response = client.Execute(req, accessToken);
                if (response.Errcode == 0)
                {
                    return(result = SendWorkRecordResult.CreateSuccessResult(
                               response.Errcode,
                               response.ErrMsg,
                               response.Result
                               ));
                }
                else
                {
                    return(result = SendWorkRecordResult.CreateFailResult(
                               response.Errcode,
                               response.SubErrMsg
                               ));
                }
            }
            catch
            {
                throw new Exception("发送出错");
            }
        }
Beispiel #2
0
        /// <summary>
        /// 发起一条待办事项
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="userId">待办事项对应的用户ID</param>
        /// <param name="title">待办事项的标题</param>
        /// <param name="url">待办事项的跳转链接</param>
        /// <param name="form">表单内容(标题+内容)</param>
        /// <returns></returns>
        public static SendWorkRecordResult AddWorkRecord(string accessToken, string userId, string title, string url, Dictionary <string, object> form)
        {
            SendWorkRecordResult result = new SendWorkRecordResult();

            try
            {
                TimeSpan                 ts     = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                long                     time   = Convert.ToInt64(ts.TotalSeconds);
                IDingTalkClient          client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/workrecord/add");
                OapiWorkrecordAddRequest req    = new OapiWorkrecordAddRequest();
                req.Userid     = userId;
                req.CreateTime = time;//待办时间。Unix时间戳,毫秒级
                req.Title      = title;
                req.Url        = url;
                List <OapiWorkrecordAddRequest.FormItemVoDomain> list2 = new List <OapiWorkrecordAddRequest.FormItemVoDomain>();
                OapiWorkrecordAddRequest.FormItemVoDomain        obj3  = new OapiWorkrecordAddRequest.FormItemVoDomain();
                foreach (KeyValuePair <string, object> item in form)
                {
                    obj3.Title   = item.Key;
                    obj3.Content = item.Value.ToString();
                    list2.Add(obj3);
                }
                req.FormItemList_ = list2;
                OapiWorkrecordAddResponse response = client.Execute(req, accessToken);

                if (response.Errcode == 0)
                {
                    return(result = SendWorkRecordResult.CreateSuccessResult(
                               response.Errcode,
                               response.ErrMsg,
                               response.RecordId
                               ));
                }
                else
                {
                    return(result = SendWorkRecordResult.CreateFailResult(
                               response.Errcode,
                               response.SubErrMsg
                               ));
                }
            }
            catch
            {
                throw new Exception("发送出错");
            }
        }