/// <summary> /// 头像上传 /// </summary> /// <param name="uid">用户编号</param> /// <param name="x1">选择区域左上点X坐标</param> /// <param name="y1">选择区域左上点Y坐标</param> /// <param name="height">选择区域的高度</param> /// <param name="width">选择区域的宽度</param> /// <param name="src">上传文件的路径</param> public bool newUpload(int uid, int x1,int y1,int height,int width,string src) { string path = System.Web.HttpContext.Current.Server.MapPath("~") + src.Replace("/","\\"); FileStream fs = new FileStream(path, FileMode.Open); BinaryReader br = new BinaryReader(fs); byte[] bytes = br.ReadBytes((int)fs.Length); br.Close(); fs.Close(); MemoryStream ms = new MemoryStream(bytes); System.Drawing.Image image = System.Drawing.Image.FromStream(ms); //文件夹路径 string tempPath="\\upload\\Avatar\\" + DateTime.Now.Year + "\\" + DateTime.Now.Month + "\\" + DateTime.Now.Day + "\\"; path = System.Web.HttpContext.Current.Server.MapPath("~") + tempPath; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string fileExtends = this.GetFileExtends(src.Replace("/", "\\"));//获取后缀 //保存头像们 string guid=Guid.NewGuid().ToString("N"); path += guid; try { saveAvatar(image, x1, y1, width, height, 320, 320, path + "-320_320." + fileExtends); saveAvatar(image, x1, y1, width, height, 160, 160, path + "-160_160." + fileExtends); saveAvatar(image, x1, y1, width, height, 64, 64, path + "-64_64." + fileExtends); saveAvatar(image, x1, y1, width, height, 32, 32, path + "-32_32." + fileExtends); Data.Db myDb = new Data.Db(); System.Collections.Hashtable inQuery=new System.Collections.Hashtable(); inQuery["@uid"] = uid; inQuery["@avatar"] = tempPath + guid + "-320_320." + fileExtends; myDb.ExecNoneQuery("user_avatar_update", inQuery); return true; } catch { return false; } finally { image.Dispose(); } }
public void getUserPoint() { if (Session["isLogin"] != null && Session["isLogin"].ToString() == "true") { moyu.Data.Db myDb = new Data.Db(); Hashtable inQuery = new Hashtable(); inQuery["@maxPoint"] = 10; inQuery["@uid"] = Session["id"].ToString(); inQuery["@point"] = 10; inQuery["@date"] = DateTime.Now.ToShortDateString(); int pointAllowAdd = Convert.ToInt32(moyu.Data.Type.dtToHash(myDb.GetQueryStro("user_point_postAdd", inQuery, "rt"))[0]["point"]); StringBuilder sb = new StringBuilder(); sb.Append("<li class=\"postItem\">"); sb.Append("<h2 class=\"group-post-info clear\" style=\"text-indent:0;\">"); sb.Append(Session["niceName"].ToString() + ",今天的10分已经拿到<span" + getWidthStyle(10 - pointAllowAdd) + " class=\"group-post-info-tag group_tag_5\">" + (10 - pointAllowAdd) + "</span>分了,还有<span" + getWidthStyle(pointAllowAdd) + " class=\"group-post-info-tag group_tag_4\">" + pointAllowAdd + "</span>分可拿。"); sb.Append("</h2></li>"); Response.Write(sb); } }