Esempio n. 1
0
        public WeThirdPartyCorpTokenResponse get_corp_token()
        {
            string url    = WeCorpUtil.GetCorpUrl(WeThirdPartyConst.CORP_TOKEN, WeixinSettings.Current.CorpUserManagerSecret);
            var    result = WeUtil.PostDataToUri(url, this.WriteJson(), new WeThirdPartyCorpTokenResponse());

            return(result);
        }
Esempio n. 2
0
        public WeixinResult Update()
        {
            string url = WeCorpUtil.GetCorpUrl(WeCorpConst.UPDATE_DEPARTMENT,
                                               WeixinSettings.Current.CorpUserManagerSecret);

            return(WeUtil.PostToUri(url, this.WriteJson(WeConst.WRITE_SETTINGS), new WeixinResult()));
        }
Esempio n. 3
0
        public WeThirdPartyGetAgentResponse get_agent()
        {
            string url    = WeCorpUtil.GetCorpUrl(WeThirdPartyConst.GET_AGENT, WeixinSettings.Current.CorpUserManagerSecret);
            var    result = WeUtil.PostToUri(url, this.WriteJson(), new WeThirdPartyGetAgentResponse());

            return(result);
        }
Esempio n. 4
0
        public WeThirdPartyAuthInfosResponse get_auth_info()
        {
            string url    = WeCorpUtil.GetCorpUrl(WeThirdPartyConst.AUTH_INFO, WeixinSettings.Current.CorpUserManagerSecret);
            var    result = WeUtil.PostDataToUri(url, this.WriteJson(), new WeThirdPartyAuthInfosResponse());

            return(result);
        }
Esempio n. 5
0
        internal static CorpTagList GetTagList()
        {
            string url = WeCorpUtil.GetCorpUrl(WeCorpConst.QUERY_TAG,
                                               WeixinSettings.Current.CorpUserManagerSecret);
            CorpTagList list = WeUtil.GetFromUri(url, new CorpTagList());

            return(list);
        }
Esempio n. 6
0
        internal static CorpDepartmentCollection GetDepartmentList()
        {
            string url = WeCorpUtil.GetCorpUrl(WeCorpConst.QUERY_DEPARTMENT,
                                               WeixinSettings.Current.CorpUserManagerSecret);
            CorpDepartmentCollection collection = WeUtil.GetFromUri <CorpDepartmentCollection>(url);

            return(collection);
        }
Esempio n. 7
0
        public static List <CorpAppSimpleInfo> GetAppList()
        {
            string url = WeCorpUtil.GetCorpUrl(WeCorpConst.AGENT_LIST,
                                               WeixinSettings.Current.CorpUserManagerSecret);
            var list = WeUtil.GetFromUri(url, new CorpAppList());

            return(list.AgentList);
        }
Esempio n. 8
0
        public WeixinResult Update()
        {
            string url = WeCorpUtil.GetCorpUrl(WeCorpConst.AGENT_SET,
                                               WeixinSettings.Current.CorpUserManagerSecret);
            CorpAppUpdateInfo updateInfo = new CorpAppUpdateInfo(this);
            WeixinResult      result     = WeUtil.PostToUri(url, updateInfo.WriteJson(), new WeixinResult());

            return(result);
        }
Esempio n. 9
0
        public static MpNewsArticle CreateArticle(string title, string content, int appId, string path)
        {
            TkDebug.AssertArgumentNullOrEmpty(path, "path", null);

            string  secret = WeixinSettings.Current.GetCorpSecret(appId);
            MediaId media  = WeCorpUtil.UploadFile(secret, MediaType.Image, path);

            return(new MpNewsArticle(title, media.Id, content));
        }
Esempio n. 10
0
        public static WeixinResult BatchDelete(IEnumerable <string> userIds)
        {
            TkDebug.AssertArgumentNull(userIds, "userIds", null);

            CorpUserIdList id  = new CorpUserIdList(userIds);
            string         url = WeCorpUtil.GetCorpUrl(WeCorpConst.BATCH_DELETE_USER,
                                                       WeixinSettings.Current.CorpUserManagerSecret);

            return(WeUtil.PostToUri(url, id.WriteJson(WeConst.WRITE_SETTINGS), new WeixinResult()));
        }
Esempio n. 11
0
        public CorpMessageResult Send(int appId)
        {
            AgentId = appId;
            string            secret = WeixinSettings.Current.GetCorpSecret(appId);
            string            url    = WeCorpUtil.GetCorpUrl(WeCorpConst.MESSAGE_URL, secret);
            CorpMessageResult result = new CorpMessageResult();

            result = WeUtil.PostToUri(url, ToJson(), result);
            return(result);
        }
Esempio n. 12
0
        public static WeThirdPartyPermanentCodeResponse get_permanent_code(string authCode)
        {
            TkDebug.AssertArgumentNullOrEmpty(authCode, "authCode", null);

            string url = WeCorpUtil.GetCorpUrl(WeThirdPartyConst.PERMANENT_CODE, WeixinSettings.Current.CorpUserManagerSecret);
            WeThirdPartyPermanentCodeRequest request = new WeThirdPartyPermanentCodeRequest(authCode);
            var result = WeUtil.PostDataToUri(url, request.WriteJson(), new WeThirdPartyPermanentCodeResponse());

            return(result);
        }
Esempio n. 13
0
        public static string get_pre_auth_code(params string[] ids)
        {
            TkDebug.AssertArgumentNull(ids, "ids", null);

            string url = WeCorpUtil.GetCorpUrl(WeThirdPartyConst.PRE_AUTH_CODE, WeixinSettings.Current.CorpUserManagerSecret);
            WeThirdPartyPreAuthCodeRequest request = new WeThirdPartyPreAuthCodeRequest(ids);
            var result = WeUtil.PostToUri(url, request.WriteJson(), new WeThirdPartyPreAuthCodeResponse());

            return(result.PreAuthCode);
        }
Esempio n. 14
0
        public static string get_suite_token(string suiteTicket)
        {
            TkDebug.AssertArgumentNullOrEmpty(suiteTicket, "suiteTicket", null);

            string url = WeCorpUtil.GetCorpUrl(WeThirdPartyConst.SUITE_TOKEN, WeixinSettings.Current.CorpUserManagerSecret);
            WeThirdPartySuiteTokenRequest request = new WeThirdPartySuiteTokenRequest(suiteTicket);
            var result = WeUtil.PostDataToUri(url, request.WriteJson(), new WeThirdPartySuiteTokenResponse());

            return(result.SuiteAccessToken);
        }
Esempio n. 15
0
        public static WeixinResult set_agent(string authCorpid, string permanentCode, WeThirdPartyAgentSet agent)
        {
            TkDebug.AssertArgumentNullOrEmpty(authCorpid, "authCorpid", null);
            TkDebug.AssertArgumentNullOrEmpty(permanentCode, "permanentCode", null);
            TkDebug.AssertArgumentNull(agent, "agent", null);

            string url = WeCorpUtil.GetCorpUrl(WeThirdPartyConst.SET_AGENT, WeixinSettings.Current.CorpUserManagerSecret);
            WeThirdPartySetAgentRequest request = new WeThirdPartySetAgentRequest(authCorpid, permanentCode, agent);
            var result = WeUtil.PostToUri(url, request.WriteJson(), new WeixinResult());

            return(result);
        }
Esempio n. 16
0
        public ReceiveMessage CreateCorpReceiveMessage(string msgSignature,
                                                       string timeStamp, string nonce)
        {
            var xml = WeCorpUtil.DecryptMsg(this, msgSignature, timeStamp, nonce);

            if (string.IsNullOrEmpty(xml))
            {
                return(null);
            }

            return(CreateReceiveMessage(xml));
        }
Esempio n. 17
0
        public static CorpTag Create(string name)
        {
            TkDebug.AssertArgumentNullOrEmpty(name, "name", null);

            CorpTag data = new CorpTag
            {
                Name = name
            };
            string url = WeCorpUtil.GetCorpUrl(WeCorpConst.CREATE_TAG,
                                               WeixinSettings.Current.CorpUserManagerSecret);

            return(WeUtil.PostToUri(url, data.WriteJson(WeConst.WRITE_SETTINGS), data));
        }
Esempio n. 18
0
        public CorpTagUserResult RemoveMembers(IEnumerable <string> userList, IEnumerable <int> partyList)
        {
            TkDebug.AssertArgument(userList != null || partyList != null, "userList",
                                   "参数userList或者partyList不能全为空", this);

            CorpPostTagUser postData = new CorpPostTagUser(Id, userList, partyList);
            string          url      = WeCorpUtil.GetCorpUrl(WeCorpConst.REMOVE_TAG_USER,
                                                             WeixinSettings.Current.CorpUserManagerSecret);
            CorpTagUserResult result = WeUtil.PostToUri(url,
                                                        postData.WriteJson(WeConst.WRITE_SETTINGS), new CorpTagUserResult());

            return(result);
        }
Esempio n. 19
0
        public static InviteType Invite(string userId, string tips)
        {
            TkDebug.AssertArgumentNullOrEmpty(userId, "userId", null);
            TkDebug.AssertArgumentNullOrEmpty(tips, "tips", null);

            CorpInviteRequest request = new CorpInviteRequest(userId)
            {
                InviteTips = tips
            };
            string url = WeCorpUtil.GetCorpUrl(WeCorpConst.INVITE_SEND,
                                               WeixinSettings.Current.CorpUserManagerSecret);
            var result = WeUtil.PostToUri(url, request.WriteJson(), new CorpInviteResult());

            return(result.Type);
        }
Esempio n. 20
0
        public static CorpDepartment Create(int parentId, string name, int order)
        {
            TkDebug.AssertArgumentNullOrEmpty(name, "name", null);

            CorpDepartment data = new CorpDepartment
            {
                Name     = name,
                ParentId = parentId,
                Order    = order
            };
            string url = WeCorpUtil.GetCorpUrl(WeCorpConst.CREATE_DEPARTMENT,
                                               WeixinSettings.Current.CorpUserManagerSecret);

            return(WeUtil.PostToUri(url, data.WriteJson(WeConst.WRITE_SETTINGS), data));
        }
Esempio n. 21
0
        public MediaId GetWeCorpMediaId(string secret, MediaType type, string path)
        {
            DataRow row = TrySelectRowWithKeys(type.ToString(), path);

            if (row == null)
            {
                SetCommands(AdapterCommand.Insert);
                MediaId mediaId = WeCorpUtil.UploadFile(secret, type, path);
                row = NewRow();
                row.BeginEdit();
                row["MediaType"] = type.ToString();
                row["MediaKey"]  = path;
                SetMediaRow(row, mediaId);
                row["CorpSecret"] = secret;
                row.EndEdit();
                UpdateDatabase();

                return(mediaId);
            }
            else
            {
                DateTime validDate = row["ValidDate"].Value <DateTime>();
                if (validDate > DateTime.Now)
                {
                    return(new MediaId(row["MediaId"].ToString()));
                }
                else
                {
                    SetCommands(AdapterCommand.Update);
                    MediaId mediaId = WeCorpUtil.UploadFile(secret, type, path);
                    row.BeginEdit();
                    SetMediaRow(row, mediaId);
                    row.EndEdit();
                    UpdateDatabase();

                    return(mediaId);
                }
            }
        }
Esempio n. 22
0
        public static WeixinResult DeleteCorpMenu(int appId)
        {
            string url = WeCorpUtil.GetCorpMenuUrl(WeCorpConst.DELETE_MENU, appId);

            return(WeUtil.GetFromUri <WeixinResult>(url));
        }
Esempio n. 23
0
        public static WeMenu QueryCorpMenu(int appId)
        {
            string url = WeCorpUtil.GetCorpMenuUrl(WeCorpConst.QUERY_MENU, appId);

            return(InternalQueryMenu(url));
        }
Esempio n. 24
0
        public WeixinResult CreateCorpMenu(int appId)
        {
            string url = WeCorpUtil.GetCorpMenuUrl(WeCorpConst.CREATE_MENU, appId);

            return(InternalCreateMenu(url));
        }