Exemple #1
0
 public ProjectController(ProjectBll projectBll, FileBll fileBll, IssueBll issueBll, UserBll userBll, LinkBll linkBll, ScheduleBll scheduleBll, UserModule.Bll.UserBll userModuleUserBll, LogBll logBll)
 {
     _projectBll        = projectBll;
     _fileBll           = fileBll;
     _issueBll          = issueBll;
     _userBll           = userBll;
     _linkBll           = linkBll;
     _scheduleBll       = scheduleBll;
     _userModuleUserBll = userModuleUserBll;
     _logBll            = logBll;
 }
Exemple #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            LinkBll lb       = new LinkBll();
            string  linkList = "";

            switch (action)
            {
            case "select":
                linkList = lb.select();
                context.Response.Write(linkList);
                break;

            default: break;
            }
        }
Exemple #3
0
        public string Index()
        {
            StreamReader reader    = new StreamReader(Request.InputStream);
            string       xmlData   = reader.ReadToEnd();
            BaseMsg      baseModel = XmlHelper.ConvertToModel <BaseMsg>(xmlData);

            BaseResponseMsg response = new BaseResponseMsg
            {
                CreateTime   = CommonHelp.TimeToLong(DateTime.Now),
                ToUserName   = baseModel.FromUserName,
                FromUserName = baseModel.ToUserName
            };//响应对象

            string result = "";

            try
            {
                if (baseModel.MsgType == "event")
                {
                    EventMsg model = XmlHelper.ConvertToModel <EventMsg>(xmlData);
                    //EventMsgBll.HandlerTheEvent(model);
                    EventMsgBll.Add(model);
                    EventMsgBll.SaveChanges();
                    return("");
                }
                var res = (MsgType)Enum.Parse(typeof(MsgType), baseModel.MsgType);
                switch (res)
                {
                case MsgType.text:
                {
                    TextMsg model = XmlHelper.ConvertToModel <TextMsg>(xmlData);
                    TextMsgBll.Add(model);
                    //TODO 处理用户的文字信息
                    response = new ResponseTextMsg
                    {
                        CreateTime   = CommonHelp.TimeToLong(DateTime.Now),
                        ToUserName   = baseModel.FromUserName,
                        FromUserName = baseModel.ToUserName,
                        Content      = "欢迎关注我的微信!我是wdq!"
                    };
                }
                break;

                case MsgType.image:
                {
                    ImageMsg model = XmlHelper.ConvertToModel <ImageMsg>(xmlData);
                    ImageMsgBll.Add(model);
                    //TODO 处理用户的图片信息
                    response = new ResponseImageMsg
                    {
                        CreateTime   = CommonHelp.TimeToLong(DateTime.Now),
                        FromUserName = baseModel.ToUserName,
                        ToUserName   = baseModel.FromUserName,
                        MediaId      = "1212"
                    };
                }
                break;

                case MsgType.voice:
                {
                    VoiceMsg model = XmlHelper.ConvertToModel <VoiceMsg>(xmlData);
                    VoiceMsgBll.Add(model);
                    if (model.Recognition != null)
                    {
                        //TODO 处理用户的语音信息
                    }
                    response = new ResponseVoiceMsg
                    {
                        FromUserName = baseModel.ToUserName,
                        ToUserName   = baseModel.FromUserName,
                        CreateTime   = CommonHelp.TimeToLong(DateTime.Now),
                        MediaId      = "123"
                    };
                }
                break;

                case MsgType.video:
                case MsgType.shortvideo:
                {
                    VideoMsg model = XmlHelper.ConvertToModel <VideoMsg>(xmlData);
                    VideoMsgBll.Add(model);
                    //TODO 处理用户的小视频信息
                }
                    response = new ResponseVideoMsg
                    {
                        FromUserName = baseModel.ToUserName,
                        ToUserName   = baseModel.FromUserName,
                        CreateTime   = CommonHelp.TimeToLong(DateTime.Now),
                        MediaId      = "123",
                        Description  = "test",
                        Title        = "回复视频消息"
                    };
                    break;

                case MsgType.location:
                {
                    LocationMsg model = XmlHelper.ConvertToModel <LocationMsg>(xmlData);
                    LocationMsgBll.Add(model);
                    //TODO 处理用户的地理位置信息
                }
                    response = new ResponseMusicMsg
                    {
                        FromUserName = baseModel.ToUserName,
                        ToUserName   = baseModel.FromUserName,
                        CreateTime   = CommonHelp.TimeToLong(DateTime.Now),
                        Title        = "回复音乐消息",
                        Description  = "一段感人的音乐",
                        HQMusicUrl   = "http://baidu.music.com",
                        MusicUrl     = "fuuuul",
                        ThumbMediaId = "123"
                    };
                    break;

                case MsgType.link:
                {
                    LinkMsg model = XmlHelper.ConvertToModel <LinkMsg>(xmlData);
                    LinkBll.Add(model);
                    //TODO 处理用户的连接信息
                }
                    response = new ResponseNewsMsg
                    {
                        FromUserName = baseModel.ToUserName,
                        ToUserName   = baseModel.FromUserName,
                        CreateTime   = CommonHelp.TimeToLong(DateTime.Now),
                        ArticleCount = 1,
                        Articles     = new[] { new ResponseNewsMsg.Article {
                                                   Description = "", PicUrl = "", Title = "", Url = ""
                                               } },
                    };
                    break;
                }

                EventMsgBll.SaveChanges();
            }
            catch (DbEntityValidationException dbEx)
            {
                result = dbEx.EntityValidationErrors.SelectMany(item => item.ValidationErrors).Aggregate(result, (current, item2) => current + string.Format("{0}:{1}\r\n", item2.PropertyName, item2.ErrorMessage));
            }
            return(response.ToUserName == null ? "" : response.GetResponseStr());
        }