protected void Page_Load(object sender, EventArgs e) { tid=Convert .ToInt32( Request.Params["tid"]); pid = Convert.ToInt32(Request.Params["pid"]); Information.group myGroup = new Information.group(); thePost = myGroup.topicGetById(tid); }
public void getNotRead() { Information.group myGroup = new Information.group(); int count = myGroup.getNotReadAtCount(Convert.ToInt32(Session["id"])); if (count != 0) { StringBuilder sb = new StringBuilder(); sb.Append("<div id=\"messageTip\">"); sb.Append("有<span class=\"notReadCount\">" + count + "</span>个人提到你了,快<a href=\"robot-group-kewWordsShow.aspx?type=atMe\">去看看</a>吧。"); sb.Append("</div>"); Response.Write(sb); } }
/// <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); }
protected void Page_Load(object sender, EventArgs e) { type = Request.Params["type"]; if (type == "t") { Information.topic myTopic = new Information.topic(); thePost = myTopic.get(Convert.ToInt32(Request.Params["id"])); } else if (type == "g") { Information.group myGroup = new Information.group(); thePost = myGroup.topicGetById(Convert.ToInt32(Request.Params["id"])); } }
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; }
/// <summary> /// 机器人教育 /// </summary> /// <param name="userDate">用户信息</param> /// <returns>返回信息</returns> private Hashtable[] funcTeach(Hashtable userDate ) { Hashtable[] rt = new Hashtable[1]; rt[0] = new Hashtable(); rt[0]["id"] = 0; rt[0]["messageType"] = 2; rt[0]["title"] = "教左邻回答\"" + userDate["@body"].ToString() + "\""; rt[0]["body"] = "你刚说了\"" + userDate["@body"].ToString() + "\",但是我现在还不知道该怎么回答这个问题……\n"+ "教教我应该怎么回答好不好【撒娇】,\n"+ "以后定西只要再有人和我这么说,我就照你教我的回答Ta。"; rt[0]["picSmall"] = getPicUrl(false); rt[0]["picBig"] = "http://www.ai0932.com/images/weixin/teach.jpg"; rt[0]["url"] = "http://www.ai0932.com/mobile/robot-teach.aspx?q="+ HttpUtility.UrlEncode(userDate["@body"].ToString()) ; rt[0]["orders"] = 90; Robot.Main myRobot = new Robot.Main(); int uid = getWeiUserId(userDate["@FromUserName"].ToString()); myRobot.questionAdd(userDate["@body"].ToString(), uid); Information.group myGroup = new Information.group(); myGroup.topicNewByWeixin("求调教", "教左邻回答“" + userDate["@body"].ToString() + "”", -1, uid, "我刚对左邻说“<span style=\"color:red;\">" + userDate["@body"].ToString() + "</span>”但是她不知道该怎么回答我,<a href=\"robot-teach.aspx?q=" + HttpUtility.UrlEncode(userDate["@body"].ToString()) + "\">点击这里</a>去调教她!"); return rt; }
/// <summary> /// 用户签到 /// </summary> /// <param name="uid">用户编号</param> public int signIn(int uid) { Hashtable inQuer = new Hashtable(); inQuer["@uid"] = uid; inQuer["@lastDate"] = DateTime.Now.AddDays(-1).ToShortDateString(); inQuer["@nowDate"] = DateTime.Now.ToShortDateString(); Information.group myGroup = new Information.group(); User.Web myUser = new User.Web(); Hashtable theUser = new Hashtable(); theUser = myUser.get(uid); int tid; if (!isSigIn(uid)) { myDb.ExecNoneQuery("user_signIn", inQuer); tid = myGroup.topicNewByWeixin("签到", theUser["niceName"].ToString() + "在" + System.DateTime.Now.ToString() + "在左邻签到", -2, uid, theUser["niceName"] + "在" + System.DateTime.Now.ToShortTimeString() + "默默地签了一个到,什么都没有说,然后就默默默默地走掉了……"); } else { tid = getLastSiginTopic(uid); } return tid; }
private void makePhonePost() { Information.group myGroup = new Information.group(); myGroup.makePhonePost(); }