예제 #1
0
파일: WinXin.cs 프로젝트: uwitec/O2O
 /// <summary>
 /// 产品列表
 /// </summary>
 /// <param name="ToUserName">请求人</param>
 /// <param name="FromUserName">服务号OpenId</param>
 /// <param name="TypeId"></param>
 /// <returns></returns>
 private bool ProductList(string ToUserName, string FromUserName, string TypeId)
 {
     List<NewsReplyMessageItem> items = new List<NewsReplyMessageItem>();
     int rowsCount = 0;
     var list = new Eyousoft_yhq.BLL.Product().GetList(5, 1, ref rowsCount, new Eyousoft_yhq.Model.SerProduct() { PurductType = TypeId });
     foreach (var model in list)
     {
         string picUrl = "";
         //if (!String.IsNullOrEmpty(model.ProductPhoto))
         //{
         //    string Photo = model.ProductPhoto + "S_" + System.IO.Path.GetFileName(model.ProductPhoto);
         //    string file = System.IO.Path.GetFileName(Photo);
         //    picUrl = Photo.Substring(0, Photo.Length - file.Length) + "S_" + file;
         //}
         NewsReplyMessageItem itm = new NewsReplyMessageItem()
         {
             Description = model.ProductName,
             Url = "http://oa.finawin.cn/APP/WeiXin/ProductDetail.aspx?OpenId=" + FromUserName + "&id=" + model.ProductID.ToString(),
             PicUrl = picUrl,
             Title = model.ProductName
         };
         items.Add(itm);
     }
     NewsReplyMessage replyMsg = new NewsReplyMessage()
     {
         CreateTime = Tools.ConvertDateTimeInt(DateTime.Now),
         FromUserName = ToUserName,
         ToUserName = FromUserName,
         Articles = items
     };
     MessageHandler.SendReplyMessage(replyMsg);
     return true;
 }
예제 #2
0
파일: WinXin.cs 프로젝트: uwitec/O2O
 /// <summary>
 /// 注册绑定
 /// </summary>
 /// <param name="ToUserName">请求人</param>
 /// <param name="FromUserName">服务号OpenId</param>
 /// <returns></returns>
 private bool RegisterBind(string ToUserName, string FromUserName)
 {
     List<NewsReplyMessageItem> items = new List<NewsReplyMessageItem>();
     NewsReplyMessageItem NewsPicHeader = new NewsReplyMessageItem()
     {
         Description = "注册绑定",
         Url = "http://www.4008005216.com/AppPage/weixin/Register.aspx?OpenId=" + FromUserName,
         //  PicUrl = "http://oa.finawin.cn/APP/Images/Img01.jpg",
         Title = "注册绑定"
     };
     items.Add(NewsPicHeader);
     NewsReplyMessage replyMsg = new NewsReplyMessage()
     {
         CreateTime = Tools.ConvertDateTimeInt(DateTime.Now),
         FromUserName = ToUserName,
         ToUserName = FromUserName,
         Articles = items
     };
     MessageHandler.SendReplyMessage(replyMsg);
     return true;
 }
예제 #3
0
파일: WinXin.cs 프로젝트: uwitec/O2O
        /// <summary>
        /// 产品码查询
        /// </summary>
        /// <param name="ToUserName">请求人</param>
        /// <param name="FromUserName">服务号OpenId</param>
        /// <returns></returns>
        private bool NewsList(TextReceiveMessage msg, params object[] args)
        {
            string msgWord = msg.Content.ToLower();
            if (msgWord.StartsWith("h"))
            {
                var usermodel = WeiXin.GetUserInfo(msg.FromUserName);
                if (usermodel != null)
                {
                    List<NewsReplyMessageItem> items = new List<NewsReplyMessageItem>();
                    int rowsCount = 0;
                    string wxm = msgWord.Substring(1);
                    var list = new Eyousoft_yhq.BLL.Product().GetList(1, 1, ref rowsCount, new Eyousoft_yhq.Model.SerProduct() { FavourCode = wxm });
                    NewsReplyMessageItem NewsPicHeader = new NewsReplyMessageItem();
                    if (list != null && list.Count > 0)
                    {
                        NewsPicHeader.Description = EyouSoft.Common.Utils.GetText2(list[0].ProductDis, 50, true);
                        NewsPicHeader.Url = "http://www.4008005216.com/AppPage/weixin/ProductInfo.aspx?id=" + list[0].ProductID;
                        NewsPicHeader.PicUrl = (list[0].AttachList != null && list[0].AttachList.Count > 0) ? list[0].AttachList[0].FilePath : "";
                        NewsPicHeader.Title = list[0].ProductName;
                    };
                    items.Add(NewsPicHeader);

                    NewsReplyMessage replyMsg = new NewsReplyMessage()
                    {
                        CreateTime = Tools.ConvertDateTimeInt(DateTime.Now),
                        FromUserName = msg.ToUserName,
                        ToUserName = msg.FromUserName,
                        Articles = items
                    };
                    if (list == null || list.Count == 0)
                    {
                        MessageHandler.SendTextReplyMessage(msg.ToUserName, msg.FromUserName, "查询产品不存在!");
                        return true;
                    }
                    MessageHandler.SendReplyMessage(replyMsg);

                }
                else
                {
                    MessageHandler.SendTextReplyMessage(msg.ToUserName, msg.FromUserName, "获取用户信息失败!" + msg.FromUserName);
                }
            }
            else
            {
                MessageHandler.SendTextReplyMessage(msg.ToUserName, msg.FromUserName, "亲!您的问题我不明白,要不您换个问法再试试,我这里只要输入5位产品码就行了。或者您可以进入\"旅游超市\"按分类查询。!");
            }
            return true;
        }