Пример #1
0
        /// <summary>
        /// 获取离线图片
        /// </summary>
        /// <param name="offpic"></param>
        /// <param name="msg"></param>
        /// <param name="picout"></param>
        /// <param name="listener"></param>
        /// <returns></returns>
        public QQActionFuture GetOffPic(OffPicItem offpic, QQMsg msg, Stream picout,
                                        QQActionEventHandler listener)
        {
            var mod = GetModule <ChatModule>(QQModuleType.CHAT);

            return(mod.GetOffPic(offpic, msg, picout, listener));
        }
Пример #2
0
        public override void OnHttpStatusOK(QQHttpResponse response)
        {
            var rex = new Regex(QQConstants.REGXP_JSON_SINGLE_RESULT);
            var str = response.GetResponseString();
            var m   = rex.Match(str);

            if (!m.Success)
            {
                throw new QQException(QQErrorCode.UnexpectedResponse, str);
            }

            var pic       = new OffPicItem();
            var regResult = Regex.Replace(Regex.Replace(m.Groups[0].Value, "[\\r]?[\\n]", " "), "[\r]?[\n]", " ");
            var obj       = JObject.Parse(regResult);

            var retcode = obj["retcode"].ToObject <int>();

            if (retcode == 0)
            {
                pic.IsSuccess = (obj["progress"].ToObject <int>() == 100) ? true : false;
                pic.FileSize  = obj["filesize"].ToObject <int>();
                pic.FileName  = obj["filename"].ToString();
                pic.FilePath  = obj["filepath"].ToString();
                NotifyActionEvent(QQActionEventType.EvtOK, pic);
                return;
            }

            // 失败后返回路径
            pic.FilePath  = _file;
            pic.IsSuccess = false;
            throw new QQException(QQErrorCode.UnexpectedResponse, str);
        }
Пример #3
0
 public GetOffPicAction(QQContext context, QQActionEventHandler listener,
                        OffPicItem offpic, QQMsg msg, Stream picOut)
     : base(context, listener)
 {
     this.offpic = offpic;
     this.msg    = msg;
     this.picOut = picOut;
 }
Пример #4
0
 public GetOffPicAction(IQQContext context, QQActionListener listener,
                        OffPicItem offpic, QQMsg msg, Stream picOut)
     : base(context, listener)
 {
     _offpic = offpic;
     _msg    = msg;
     _picOut = picOut;
 }
        public override void OnHttpStatusOK(QQHttpResponse response)
        {
            Regex rex = new Regex(QQConstants.REGXP_JSON_SINGLE_RESULT);
            Match m   = rex.Match(response.GetResponseString());

            OffPicItem pic = new OffPicItem();
            JObject    obj = null;

            if (!m.Success)
            {
                pic.IsSuccess = false;
                NotifyActionEvent(QQActionEventType.EVT_ERROR,
                                  new QQException(QQErrorCode.UNEXPECTED_RESPONSE, response.GetResponseString()));
            }

            string regResult = Regex.Replace(Regex.Replace(m.Groups[0].Value, "[\\r]?[\\n]", " "), "[\r]?[\n]", " ");

            obj = JObject.Parse(regResult);

            int retcode = obj["retcode"].ToObject <int>();

            if (retcode == 0)
            {
                pic.IsSuccess = (obj["progress"].ToObject <int>() == 100) ? true : false;
                pic.FileSize  = obj["filesize"].ToObject <int>();
                pic.FileName  = obj["filename"].ToString();
                pic.FilePath  = obj["filepath"].ToString();
                NotifyActionEvent(QQActionEventType.EVT_OK, pic);
                return;
            }

            // 失败后返回路径
            pic.FilePath  = file;
            pic.IsSuccess = false;
            NotifyActionEvent(QQActionEventType.EVT_ERROR,
                              new QQException(QQErrorCode.UNEXPECTED_RESPONSE, response.GetResponseString()));
        }
Пример #6
0
 public QQActionFuture GetOffPic(OffPicItem offpic, QQMsg msg, Stream picout, QQActionEventHandler listener)
 {
     return(PushHttpAction(new GetOffPicAction(this.Context, listener, offpic, msg, picout)));
 }