Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["isLogin"] == null || Session["isLogin"].ToString() == "false")
     {
         Response.Redirect("login.aspx?rdUrl=newUser.aspx");
     }
     moyu.User.Functions myFunctions = new User.Functions();
     if (myFunctions.getPoint(Convert.ToInt32(Session["id"]))["hasNewPoint"].ToString() == "False")
     {
         Response.Write("<script>alert(\"你已经感谢过别人了\\n快去介绍别人来左邻为自己赚贡献吧~\\n\\nPS:贡献可是很珍贵的。\");</script>");
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 用户获取优惠券
 /// </summary>
 /// <param name="uid">用户编号</param>
 /// <param name="cid">优惠券编号</param>
 /// <returns>状态码</returns>
 public int getCoupons(int uid, int cid)
 {
     User.Functions myFunctions = new User.Functions();
     Hashtable theCoupons = new Hashtable();
     Hashtable thePoint = new Hashtable();
     theCoupons = couponsGet(cid);
     thePoint = myFunctions.getPoint(uid);
     int needPoint=Convert .ToInt32(theCoupons["needPoint"]);
     if (Convert.ToInt32(theCoupons["number"]) < 1)
     {
         return -10;
     }
     if (isHaveCoupon(uid, cid))
     {
         return 0; //已经拥有优惠券
     }
     if (Convert.ToDateTime(theCoupons["endTime"]) < DateTime.Now)
     {
         return -1; //已经过期
     }
     if (Convert.ToInt32(theCoupons["pointType"]) == 1 && needPoint > Convert.ToInt32(thePoint["point"]))
     {
         return -2; //积分不足
     }
     if (Convert.ToInt32(theCoupons["pointType"]) == 2 && needPoint > Convert.ToInt32(thePoint["contribute"]))
     {
         return -3; //贡献不足
     }
     else
     {
         myFunctions.userPointChange(uid, (needPoint * -1), "兑换优惠券消耗积分/贡献", Convert.ToInt32(theCoupons["pointType"]) == 1?1:2);
         Hashtable inQuery = new Hashtable();
         Random rd = new Random();
         string no = rd.Next(0, 9).ToString();
         no += rd.Next(0, 9).ToString();
         no += rd.Next(0, 9).ToString();
         no += rd.Next(0, 9).ToString();
         no += rd.Next(0, 9).ToString();
         no += rd.Next(0, 9).ToString();
         no += rd.Next(0, 9).ToString();
         no += rd.Next(0, 9).ToString();
         no += rd.Next(0, 9).ToString();
         inQuery["@uid"] = uid;
         inQuery["@cid"] = cid;
         inQuery["@no"] = no;
         myDb.ExecNoneQuery("ecard_union_coupons_setHave", inQuery);
     }
     return 1; //成功
 }
Exemplo n.º 3
0
        /// <summary>
        /// 分享信息
        /// </summary>
        /// <param name="userData">用户消息</param>
        /// <returns>返回信息</returns>
        private Hashtable[] funcShare(Hashtable userData)
        {
            string userMsg = userData["@body"].ToString().Replace(":", ":");
            string tag = userMsg.Split(':')[0];
            string body = userMsg.Substring(tag.Length + 1);
            Information.group myGroup = new Information.group();
            if (body.Length > 2)
            {
                myGroup.topicNewByWeixin(tag, body.Substring(0, (body.Length > 25 ? 25 : body.Length)), -1, getWeiUserId(userData["@FromUserName"].ToString()), body);
            }
            User.Functions myFunction = new User.Functions();

            if (tag == "秘密")
            {
                myFunction.userPointChange(getWeiUserId(userData["@FromUserName"].ToString()), -3, "发秘密消耗积分", 1);
            }
            else if (tag == "无标签")
            {

            }
            else
            {
                myFunction.givePostPoint(getWeiUserId(userData["@FromUserName"].ToString()), "发帖积分", 1);
            }

            if (HttpContext.Current.Cache["weixinRobotGroupPostKeywords"] != null)
            {
                Hashtable[] keyWords = (Hashtable[])HttpContext.Current.Cache["weixinRobotGroupPostKeywords"];
                bool hasThisTag = false;
                foreach (Hashtable keyWord in keyWords)
                {
                    if (keyWord["tag"].ToString().IndexOf(tag) > -1)
                    {
                        hasThisTag = true;
                    }
                }
                if (!hasThisTag)
                {
                    HttpContext.Current.Cache.Remove("weixinRobotGroupPostKeywords");
                }
            }
            return getRequestItem(userData);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 用户文字签到
        /// </summary>
        /// <param name="userData">用户信息</param>
        /// <returns>返回信息</returns>
        private Hashtable[] funcSigin(Hashtable userData)
        {
            moyu.User.Functions myFunctions = new User.Functions();
            int uid = getWeiUserId(userData["@FromUserName"].ToString());

            int siginId = myFunctions.signIn(uid);
            StringBuilder strBody = new StringBuilder();
            Hashtable points = new Hashtable();
            points = myFunctions.getPoint(uid);
            strBody.Append(myFunctions.isSigIn(uid) ? "签到成功," : "签到失败,");
            strBody.Append("连续签到" + points["signInDays"] + "天,");
            strBody.Append("积分:" + points["point"] + ",");
            strBody.Append("贡献:" + points["contribute"] + " 。点我去首页");

            Hashtable[] rt = new Hashtable[2];
            rt[0] = new Hashtable();
            rt[0]["id"] = 0;
            rt[0]["messageType"] = 2;
            rt[0]["title"] = strBody;
            rt[0]["body"] = strBody;
            rt[0]["picSmall"] = getPicUrl(false);
            rt[0]["picBig"] = getPicUrl(true);
            rt[0]["url"] = "http://www.ai0932.com/mobile/index.aspx";
            rt[0]["orders"] = 90;

            rt[1] = new Hashtable();
            rt[1]["id"] = 0;
            rt[1]["messageType"] = 2;
            rt[1]["title"] = "今天心情怎么样?点这里记录每天的心情";
            rt[1]["body"] = "今天心情怎么样?点这里记录每天的心情";
            rt[1]["picSmall"] = getPicUrl(false);
            rt[1]["picBig"] = getPicUrl(true);
            rt[1]["url"] = "http://www.ai0932.com/mobile/addPicIntroduce.aspx?tid=" + siginId + "&pid=0";
            rt[1]["orders"] = 80;
            return rt;
        }
Exemplo n.º 5
0
        private Hashtable[] getImageRequestItems(Hashtable userData)
        {
            Hashtable[] rt = new Hashtable[1];
            rt[0] = new Hashtable();
            rt[0]["id"] = 0;
            rt[0]["messageType"] = 1;
            rt[0]["title"] = "图片上传失败";
            rt[0]["body"] = "啊噢,图片上传失败了。。。\n" +
                "失败的具体原因是:";
            rt[0]["picSmall"] = getPicUrl(false);
            rt[0]["picBig"] = getPicUrl(true);
            rt[0]["url"] = "http://www.ai0932.com/mobile/robot-group-kewWordsShow.aspx?type=group&tag=-1";
            rt[0]["orders"] = 0;
            WebClient wc = new WebClient();
            HttpWebResponse res;
            string folderPath=System.DateTime.Now.Year + "/" + System.DateTime.Now.Month + "/" + System.DateTime.Now.Day + "/";
            string savePath = HttpContext.Current.Server.MapPath("~/upload/userImages/" + folderPath);
            if (!Directory.Exists(savePath))
            {
                Directory.CreateDirectory(savePath);
            }
            res = (HttpWebResponse)WebRequest.Create(userData["@PicUrl"].ToString()).GetResponse();
            if (res.StatusCode != HttpStatusCode.OK)
            {
                //链接不正常
                rt[0]["body"] = rt[0]["body"] + "服务器连接失败";
                return rt;
            }
            string contentType=res.ContentType.ToLower();
            if (contentType.IndexOf("image") == -1)
            {
                //不是图片
                rt[0]["body"] = rt[0]["body"] + "你上传的好像不是图片";
                return rt;
            }
            string fileName="";
            if (contentType.IndexOf("png") > -1)
            {
                fileName = ".png";
            }
            else if (contentType.IndexOf(".gif") > -1)
            {
                fileName = ".gif";
            }
            else if (contentType.IndexOf("jpeg") > -1 || contentType.IndexOf("jpg") > -1)
            {
                fileName = ".jpg";
            }
            if (fileName.Length == 0)
            {
                //未知图片格式
                rt[0]["body"] = rt[0]["body"] + "不支持的图片格式";
                return rt;
            }

            fileName = System.Guid.NewGuid().ToString("N") + fileName;
            wc.DownloadFile(userData["@PicUrl"].ToString(), savePath + fileName);

            string fileNameThumbnail ="s_"+ System.Guid.NewGuid().ToString("N") + fileName;
            moyu.Images myImg = new Images();
            moyu.Images.MakeThumbnail(savePath+fileName,savePath+fileNameThumbnail,300,0,"W");

            int uid=getWeiUserId(userData["@FromUserName"].ToString());
            string imgUrl = "http://www.ai0932.com/upload/userImages/" + folderPath + fileNameThumbnail;
            Information.group myGroup = new Information.group();
            int tid = myGroup.topicNewByWeixin("爆照", ("我在" + System.DateTime.Now.ToShortTimeString() + "在左邻分享了一张照片"), -1, uid, "<img src=\"" + imgUrl + "\"/>");
            moyu.User.Functions myUser=new User.Functions();
            int pid = myUser.upLoadImg(uid, savePath+ fileName, tid.ToString(), imgUrl);
            Hashtable[] rtSuccess = new Hashtable[1];
            rtSuccess[0] = new Hashtable();
            rtSuccess[0]["id"] = 0;
            rtSuccess[0]["messageType"] = 2;
            rtSuccess[0]["body"] = "图片分享成功";
            rtSuccess[0]["title"] = "成功分享了一张图片@" + System.DateTime.Now.ToShortTimeString() + "\n" +
                " 点这里为图片添加文字说明并查看分享的图片";
            rtSuccess[0]["picSmall"] = getPicUrl(false);
            rtSuccess[0]["picBig"] = imgUrl;
            rtSuccess[0]["url"] = "http://www.ai0932.com/mobile/addPicIntroduce.aspx?tid=" + tid + "&pid=" + pid;
            rtSuccess[0]["orders"] = 10;

            //rtSuccess[1] = new Hashtable();
            //rtSuccess[1]["id"] = 0;
            //rtSuccess[1]["messageType"] = 2;
            //rtSuccess[1]["title"] = "为图片添加文字说明?点击这里去给图片添加文字说明";
            //rtSuccess[1]["body"] = "为图片添加文字说明?点击这里去给图片添加文字说明";
            //rtSuccess[1]["picSmall"] = getPicUrl(false);
            //rtSuccess[1]["picBig"] = getPicUrl(true);
            //rtSuccess[1]["url"] = "http://www.ai0932.com/mobile/addPicIntroduce.aspx?tid="+tid+"&pid="+pid;
            //rtSuccess[1]["orders"] = 6;
            User.Functions myFunction = new User.Functions();
            myFunction.givePostPoint(uid, "发图积分", 1);
            return rtSuccess;
        }
Exemplo n.º 6
0
 public void getContent()
 {
     StringBuilder sb = new StringBuilder();
     string userName = "";
     Hashtable userPoint=new Hashtable();
     moyu.User.Functions myFunction=new User.Functions();
     string bodyClass = "";
     moyu.Functions myOtherFunction = new Functions();
     foreach (Hashtable p in posts)
     {
         userPoint=myFunction.getPoint( Convert .ToInt32(p["uid"]));
         if (p["tag"].ToString() == "秘密")
         {
             userName = "******";
         }
         else
         {
             userName = (p["niceName"].ToString() == "" ? "匿名用户" : p["niceName"].ToString());
             userName = "******"weixin://profile/" + p["weixinId"] + "\" class=\"" + (Convert.ToInt32(userPoint["signInDays"]) > 15 ? "red" : "") + "\">" + userName + "</a>";
         }
         bodyClass = Convert.ToBoolean(p["isElite"]) ? "f" : "c";
         bodyClass = p["tag"].ToString() == "秘密" ? "e" : bodyClass;
         sb.Append("<li data-id=\"" + p["id"] + "\" class=\"postItem ui-body ui-body-" + bodyClass + "\">");
         sb.Append("<h2 class=\"group-post-info clear\" style=\"text-indent:0;\">");
         if (Convert.ToBoolean(p["isElite"]))
         {
             sb.Append("<span class=\"left group-post-info-tag group_tag_4\">精华</span>");
         }
         if (Convert.ToBoolean(p["isTop"]))
         {
             sb.Append("<span class=\"left group-post-info-tag group_tag_9\">置顶</span>");
         }
         sb.Append("<span class=\"left group-post-info-tag group_tag_"+p["id"].ToString().Substring(p["id"].ToString().Length-1)+"\">" + p["tag"] + "</span>");
         sb.Append("<span class=\"left group-post-info-user\">");
         sb.Append(userName);
         sb.Append("</span><span class=\"right group-post-info-date\">");
         sb.Append( myOtherFunction.kindTime(Convert.ToDateTime( p["postDate"])));
         sb.Append("</span></h2>");
         sb.Append(p["body"].ToString().Replace("src=\"upload/images", "src=\"http://www.ai0932.com/upload/images"));
         sb.Append("<div class=\"group-post-functions\">");
         sb.Append("<a class=\"viewComments\" href=\"javascript:void(0)\">评论(" + p["commentsCount"] + ")</a>");
         sb.Append("<a class=\"shareThisItem\" href=\"javascript:void(0)\" onclick=\"weixinShare('" + p["title"] + "','真是太有意思啦','http://www.ai0932.com/Mobile/post-show.aspx?type=g&id=" + p["id"] + "');\">分享</a>");
         if (power > 0)
         {
             if (Convert.ToInt32(p["gid"]) == -10)
             {
                 sb.Append("<a target=\"_self\"  href=\"../Services/Information_group.ashx?action=back&tid=" + p["id"] + "\">恢复</a>");
             }
             else
             {
                 sb.Append("<a target=\"_self\"  href=\"../Services/Information_group.ashx?action=del&tid=" + p["id"] + "\">删</a>");
             }
             if (Convert.ToBoolean(p["isElite"]))
             {
                 sb.Append("<a target=\"_self\"  href=\"../Services/Information_group.ashx?action=delElite&tid=" + p["id"] + "\">消精</a>");
             }
             else
             {
                 sb.Append("<a target=\"_self\"  href=\"../Services/Information_group.ashx?action=addElite&tid=" + p["id"] + "\">加精</a>");
             }
         }
         if (power > 5)
         {
             if (Convert.ToBoolean(p["isTop"]))
             {
                 sb.Append("<a class=\"goTop\" target=\"_self\"  href=\"../Services/Information_group.ashx?action=delTop&tid=" + p["id"] + "\">消顶</a>");
             }
             else
             {
                 sb.Append("<a class=\"goTop\" target=\"_self\"  href=\"../Services/Information_group.ashx?action=addTop&tid=" + p["id"] + "\">置顶</a>");
             }
         }
         else
         {
             sb.Append("<a class=\"goTop\" target=\"_self\"  href=\"#\">顶部</a>");
         }
         sb.Append("</div>");
         sb.Append("</li>");
     }
     Response.Write(sb);
 }