/// <summary> /// 更新一条数据 /// </summary> public bool Update(WeiXinPF.Model.wx_paizhao_picinfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update wx_paizhao_picinfo set "); strSql.Append("wid=@wid,"); strSql.Append("openid=@openid,"); strSql.Append("mediaId=@mediaId,"); strSql.Append("picUrl=@picUrl,"); strSql.Append("pStatus=@pStatus,"); strSql.Append("remark=@remark,"); strSql.Append("createDate=@createDate"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@openid", SqlDbType.VarChar, 300), new SqlParameter("@mediaId", SqlDbType.VarChar, 100), new SqlParameter("@picUrl", SqlDbType.VarChar, 1200), new SqlParameter("@pStatus", SqlDbType.Int, 4), new SqlParameter("@remark", SqlDbType.VarChar, 1000), new SqlParameter("@createDate", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.wid; parameters[1].Value = model.openid; parameters[2].Value = model.mediaId; parameters[3].Value = model.picUrl; parameters[4].Value = model.pStatus; parameters[5].Value = model.remark; parameters[6].Value = model.createDate; parameters[7].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WeiXinPF.Model.wx_paizhao_picinfo DataRowToModel(DataRow row) { WeiXinPF.Model.wx_paizhao_picinfo model = new WeiXinPF.Model.wx_paizhao_picinfo(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["wid"] != null && row["wid"].ToString() != "") { model.wid = int.Parse(row["wid"].ToString()); } if (row["openid"] != null) { model.openid = row["openid"].ToString(); } if (row["mediaId"] != null) { model.mediaId = row["mediaId"].ToString(); } if (row["picUrl"] != null) { model.picUrl = row["picUrl"].ToString(); } if (row["pStatus"] != null && row["pStatus"].ToString() != "") { model.pStatus = int.Parse(row["pStatus"].ToString()); } if (row["remark"] != null) { model.remark = row["remark"].ToString(); } if (row["createDate"] != null && row["createDate"].ToString() != "") { model.createDate = DateTime.Parse(row["createDate"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(WeiXinPF.Model.wx_paizhao_picinfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into wx_paizhao_picinfo("); strSql.Append("wid,openid,mediaId,picUrl,pStatus,remark,createDate)"); strSql.Append(" values ("); strSql.Append("@wid,@openid,@mediaId,@picUrl,@pStatus,@remark,@createDate)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@openid", SqlDbType.VarChar, 300), new SqlParameter("@mediaId", SqlDbType.VarChar, 100), new SqlParameter("@picUrl", SqlDbType.VarChar, 1200), new SqlParameter("@pStatus", SqlDbType.Int, 4), new SqlParameter("@remark", SqlDbType.VarChar, 1000), new SqlParameter("@createDate", SqlDbType.DateTime) }; parameters[0].Value = model.wid; parameters[1].Value = model.openid; parameters[2].Value = model.mediaId; parameters[3].Value = model.picUrl; parameters[4].Value = model.pStatus; parameters[5].Value = model.remark; parameters[6].Value = model.createDate; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WeiXinPF.Model.wx_paizhao_picinfo GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,wid,openid,mediaId,picUrl,pStatus,remark,createDate from wx_paizhao_picinfo "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; WeiXinPF.Model.wx_paizhao_picinfo model = new WeiXinPF.Model.wx_paizhao_picinfo(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 传图片 /// </summary> /// <param name="openid"></param> /// <param name="PicUrl"></param> /// <returns></returns> public string weipaiChuanTuPian(string openid, string PicUrl, int wid) { BLL.wx_userweixin uwbll = new BLL.wx_userweixin(); string wxId = uwbll.GetwxId(wid);//原始Id string returnCode = ""; WeiXinPF.BLL.wx_logs logBll = new WeiXinPF.BLL.wx_logs(); try { WeiXinPF.BLL.wx_paizhao_setting setBll = new WeiXinPF.BLL.wx_paizhao_setting(); WeiXinPF.Model.wx_paizhao_setting model = setBll.GetModelByWid(wid); if (model == null || model.isOpen == false) { return(""); } Dictionary <string, string> parameters = new Dictionary <string, string>(); string url = model.picApiUrl; // string userid = openid; string sourceid = wxId; // "gh_e2d7eb82cb50"; //该用户的来源,即关注的哪一个微信公众账号)、(微信号)原始ID string timestamp = ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000).ToString(); string v = "2000"; string downurl = PicUrl; string signature = ""; parameters.Add("userid", openid); parameters.Add("sourceid", sourceid); parameters.Add("downurl", downurl); parameters.Add("timestamp", timestamp); parameters.Add("v", "2000"); signature = GetBizSign(parameters); string postParam = "userid=" + userid + "&downurl=" + downurl + "&sourceid=" + sourceid + "×tamp=" + timestamp + "&v=" + v + "&signature=" + signature; string ret = Utils.HttpPost(url, postParam); Dictionary <string, object> dict = MyCommFun.JsonToDictionary(ret); returnCode = dict["returncode"].ToString(); if (returnCode == "200") { //成功 WXLogs.AddLog(wid, "微拍传图的接口", "weipaiChuanTuPian", "奥尔图微拍接口调用成功了", 1); WeiXinPF.BLL.wx_paizhao_picinfo pBll = new WeiXinPF.BLL.wx_paizhao_picinfo(); WeiXinPF.Model.wx_paizhao_picinfo pic = new WeiXinPF.Model.wx_paizhao_picinfo(); pic.openid = openid; pic.picUrl = PicUrl; pic.createDate = DateTime.Now; pBll.Add(pic); return(dict["mentioninfo"].ToString()); } else { WXLogs.AddLog(wid, "微拍传图的接口", "weipaiChuanTuPian", "奥尔图微拍接口调用失败:" + dict["returnmessage"].ToString(), 0); return(dict["returnmessage"].ToString()); } } catch (Exception ex) { WXLogs.AddLog(wid, "微拍传图的接口", "weipaiChuanTuPian", "报错:" + ex.Message, 0); return("打印接口报错:" + ex.Message); } }