Exemple #1
0
        public override WeMediaId Add()
        {
            string url    = WeUtil.GetUrl(WeMaterialConst.ADD_MATERIAL);
            var    result = WeUtil.UploadFile(url, fFileName, fData, new WeMediaId());

            return(result);
        }
Exemple #2
0
        public static MpNewsArticle CreateArticle(string title, string content, string path)
        {
            TkDebug.AssertArgumentNullOrEmpty(path, "path", null);

            MediaId media = WeUtil.UploadFile(MediaType.Image, path);

            return(new MpNewsArticle(title, media.Id, content));
        }
Exemple #3
0
        public static WeixinResult UploadHeadImg(string account, string fileName, byte[] fileData)
        {
            TkDebug.AssertArgumentNullOrEmpty(account, "account", null);
            TkDebug.AssertArgumentNullOrEmpty(fileName, "fileName", null);
            TkDebug.AssertArgumentNull(fileData, "fileData", null);

            string url = string.Format(ObjectUtil.SysCulture, WeConst.SET_KF_HEADING,
                                       AccessToken.CurrentToken, account);

            WeixinResult result = WeUtil.UploadFile(url, fileName, fileData, new WeixinResult());

            return(result);
        }
Exemple #4
0
        public BaseSendMessage Reply(ReceiveMessage message)
        {
            string fileName = FileUtil.GetRealFileName(ThumbMediaFileName, Position);
            string thumbMediaId;
            var    md = WeUtil.UploadFile(Weixin.MediaType.Image, fileName);

            if (WeixinSettings.Current.Mode == WeixinMode.Normal)
            {
                thumbMediaId = WeDataUtil.GetMediaId(Weixin.MediaType.Image, fileName);
            }

            else
            {
                thumbMediaId = WeDataUtil.GetMediaId(message.AgentId, Weixin.MediaType.Image, fileName);
            }

            MusicSendMessage reply = new MusicSendMessage(message, thumbMediaId, Title, Description, MusicUrl, HQMusicUrl);

            return(reply);
        }
Exemple #5
0
        public MediaId GetWeixinMediaId(MediaType type, string path)
        {
            DataRow row = TrySelectRowWithKeys(type.ToString(), path);

            if (row == null)
            {
                SetCommands(AdapterCommand.Insert);
                MediaId mediaId = WeUtil.UploadFile(type, path);
                row = NewRow();
                row.BeginEdit();
                row["MediaType"] = type.ToString();
                row["MediaKey"]  = path;
                SetMediaRow(row, mediaId);
                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 = WeUtil.UploadFile(type, path);
                    row.BeginEdit();
                    SetMediaRow(row, mediaId);
                    row.EndEdit();
                    UpdateDatabase();

                    return(mediaId);
                }
            }
        }
Exemple #6
0
        private static MediaId UploadMedia(MediaType type, string path)
        {
            var mediaId = WeUtil.UploadFile(type, path);

            return(mediaId);
        }