/// <summary> /// 获取指定记录 /// <param name="id">Id值</param> /// </summary> public ResPic Get(int PicId) { ResPic returnValue = null; MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdGetResPic = cmdGetResPic.Clone() as MySqlCommand; _cmdGetResPic.Connection = oc; try { _cmdGetResPic.Parameters["@PicId"].Value = PicId; if (oc.State == ConnectionState.Closed) { oc.Open(); } MySqlDataReader reader = _cmdGetResPic.ExecuteReader(); if (reader.HasRows) { reader.Read(); returnValue = new ResPic().BuildSampleEntity(reader); } } finally { oc.Close(); oc.Dispose(); oc = null; _cmdGetResPic.Dispose(); _cmdGetResPic = null; GC.Collect(); } return(returnValue); }
/// <summary> /// 绑定成长记录图片 /// </summary> /// <param name="bookid">成长记录ID</param> /// <param name="picid"></param> /// <param name="token"></param> /// <returns></returns> public RespResult BindBookPic(int bookid, int picid, string description, DateTime createtime, string token) { RespResult result = new RespResult(); try { if (!CacheManagerFactory.GetMemoryManager().Contains(token)) { result.Error = AppError.ERROR_PERSON_NOT_LOGIN; } else { ResPic pic = ResPicAccessor.Instance.Get(picid); pic.ObjId = bookid; pic.ObjType = PicType.Book; pic.PicDescription = description; pic.CreateTime = createtime; ResPicAccessor.Instance.Update(pic); result.Error = AppError.ERROR_SUCCESS; } } catch (Exception e) { result.Error = AppError.ERROR_FAILED; result.ExMessage = e.ToString(); } return(result); }
/// <summary> /// 添加数据 /// <param name="es">数据实体对象数组</param> /// <returns></returns> /// </summary> public int Insert(ResPic e) { MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdInsertResPic = cmdInsertResPic.Clone() as MySqlCommand; int returnValue = 0; _cmdInsertResPic.Connection = oc; try { if (oc.State == ConnectionState.Closed) { oc.Open(); } _cmdInsertResPic.Parameters["@PicDescription"].Value = e.PicDescription; _cmdInsertResPic.Parameters["@ObjId"].Value = e.ObjId; _cmdInsertResPic.Parameters["@ObjType"].Value = e.ObjType; _cmdInsertResPic.Parameters["@PicUrl"].Value = e.PicUrl; _cmdInsertResPic.Parameters["@PicHeight"].Value = e.PicHeight; _cmdInsertResPic.Parameters["@PicWidth"].Value = e.PicWidth; _cmdInsertResPic.ExecuteNonQuery(); returnValue = Convert.ToInt32(_cmdInsertResPic.LastInsertedId); return(returnValue); } finally { oc.Close(); oc.Dispose(); oc = null; _cmdInsertResPic.Dispose(); _cmdInsertResPic = null; } }
/// <summary> /// 修改指定的数据 /// <param name="e">修改后的数据实体对象</param> /// <para>数据对应的主键必须在实例中设置</para> /// </summary> public void Update(ResPic e) { MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdUpdateResPic = cmdUpdateResPic.Clone() as MySqlCommand; _cmdUpdateResPic.Connection = oc; try { if (oc.State == ConnectionState.Closed) { oc.Open(); } _cmdUpdateResPic.Parameters["@PicId"].Value = e.PicId; _cmdUpdateResPic.Parameters["@PicDescription"].Value = e.PicDescription; _cmdUpdateResPic.Parameters["@ObjId"].Value = e.ObjId; _cmdUpdateResPic.Parameters["@ObjType"].Value = e.ObjType; _cmdUpdateResPic.Parameters["@PicUrl"].Value = e.PicUrl; _cmdUpdateResPic.Parameters["@PicHeight"].Value = e.PicHeight; _cmdUpdateResPic.Parameters["@PicWidth"].Value = e.PicWidth; _cmdUpdateResPic.Parameters["@State"].Value = e.State; _cmdUpdateResPic.Parameters["@CreateTime"].Value = e.CreateTime; _cmdUpdateResPic.ExecuteNonQuery(); } finally { oc.Close(); oc.Dispose(); oc = null; _cmdUpdateResPic.Dispose(); _cmdUpdateResPic = null; GC.Collect(); } }
////修改宝贝信息 //public RespResult EditeBBPic(int bbid, int picid, string token) //{ // RespResult result = new RespResult(); // if (!CacheManagerFactory.GetMemoryManager().Contains(token)) // { // result.Error = AppError.ERROR_PERSON_NOT_LOGIN; // } // else // { // try // { // ProProduct pro = new ProProduct(); // pro = ProProductAccessor.Instance.Get(bbid); // if (picid != pro.PicId) // { // ResPicAccessor.Instance.Delete(pro.PicId); // ResPic pic = ResPicAccessor.Instance.Get(picid); // pic.ObjId = bbid; // ResPicAccessor.Instance.Update(pic); // } // ProProductAccessor.Instance.Update(pro); // result.Error = AppError.ERROR_SUCCESS; // } // catch (Exception e) // { // result.Error = AppError.ERROR_FAILED; // result.ExMessage = e.ToString(); // } // } // return result; //} /// <summary> /// 发布单个宝贝图片 /// </summary> /// <param name="postid">宝贝帖子ID</param> /// <param name="picid"></param> /// <param name="token"></param> /// <returns></returns> public RespResult BindBBPic(int postid, int picid, string token) { RespResult result = new RespResult(); try { if (!CacheManagerFactory.GetMemoryManager().Contains(token)) { result.Error = AppError.ERROR_PERSON_NOT_LOGIN; } else { ResPic pic = ResPicAccessor.Instance.Get(picid); pic.ObjId = postid; pic.ObjType = PicType.BBPicture; ResPicAccessor.Instance.Update(pic); result.Error = AppError.ERROR_SUCCESS; } } catch (Exception e) { result.Error = AppError.ERROR_FAILED; result.ExMessage = e.ToString(); } return(result); }
public AdvancedResult <ResPic> UploadPic(byte[] fileByte, int picHeight, int picWidth, string token) { AdvancedResult <ResPic> result = new AdvancedResult <ResPic>(); try { int userid = string.IsNullOrWhiteSpace(token) ? 0 : Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token)); string fileUrl = string.Empty; fileUrl = FileHelper.UploadFile(userid, fileByte, "jpg", PicType.Ignore); ResPic pic = new ResPic(); pic.ObjId = 0; pic.ObjType = PicType.Ignore; pic.PicUrl = fileUrl; pic.PicHeight = picHeight; pic.PicWidth = picWidth; pic.State = StateType.Active; int picid = ResPicAccessor.Instance.Insert(pic); pic.PicId = picid; result.Data = pic; result.Error = AppError.ERROR_SUCCESS; } catch (Exception e) { result.Error = AppError.ERROR_FAILED; result.ExMessage = e.ToString(); } return(result); }
public PicModel Bind(ResPic pic) { this.PicHeight = pic.PicHeight; this.PicWidth = pic.PicWidth; this.BPicUrl = pic.PicUrl; this.PicId = pic.PicId; this.Description = pic.PicDescription; this.CreateTime = pic.CreateTime; return(this); }
public JsonResult UploadFile(int saveSource, PicType fileType) { var Res = new JsonResult(); AdvancedResult <ResPic> result = new AdvancedResult <ResPic>(); if (Request.Files.Count > 0) { HttpPostedFileBase file = Request.Files[0]; int seat = file.FileName.LastIndexOf('.'); //返回位于String对象中指定位置的子字符串并转换为小写. string extension = file.FileName.Substring(seat).ToLower(); string fileSaveName = FileHelper.GetFileSaveName(extension); string path; if (saveSource == 1) { path = FileHelper.GetFileSavePath(0, fileType, null); } else { path = FileHelper.GetFileSavePath(0, PicType.Ignore, null); } string savepath = FileHelper.CreatePath(Server.MapPath(path)); string fullpath = Path.Combine(savepath, fileSaveName); file.SaveAs(fullpath); ResPic pic = new ResPic(); if (saveSource == 1) { pic.PicUrl = FileHelper.GetFileSavePath(0, fileType, fileSaveName); } else { pic.PicUrl = FileHelper.GetFileSavePath(0, PicType.Ignore, fileSaveName); } result.Data = pic; result.Error = AppError.ERROR_SUCCESS; } else { result.Error = AppError.ERROR_FAILED; result.ErrorMessage = result.ExMessage = "请选择上传的文件!"; } Res.Data = result; return(Res); }
public AdvancedResult <ResPic> UploadUserImage(byte[] fileByte, int picHeight, int picWidth, string token) { AdvancedResult <ResPic> result = new AdvancedResult <ResPic>(); try { if (!CacheManagerFactory.GetMemoryManager().Contains(token)) { result.Error = AppError.ERROR_PERSON_NOT_LOGIN; } else { int userid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token)); string fileUrl = string.Empty; fileUrl = FileHelper.UploadFile(userid, fileByte, "jpg", PicType.UserHeadImg); AdUser user = UserAccessor.Instance.Get(userid, string.Empty, string.Empty, StateType.Ignore); ResPic pic = new ResPic(); pic.ObjId = userid; pic.ObjType = PicType.UserHeadImg; pic.PicUrl = fileUrl; pic.PicHeight = picHeight; pic.PicWidth = picWidth; pic.State = StateType.Active; if (user.PicId > 0) { ResPicAccessor.Instance.Delete(user.PicId); } int picid = ResPicAccessor.Instance.Insert(pic); result.Data = pic; result.Error = AppError.ERROR_SUCCESS; } } catch (Exception e) { result.Error = AppError.ERROR_FAILED; result.ExMessage = e.ToString(); } return(result); }
public JsonResult AddPic(string sourcePath, PicType picType, string description) { var Res = new JsonResult(); AdvancedResult <ResPic> result = new AdvancedResult <ResPic>(); try { if (!CacheManagerFactory.GetMemoryManager().Contains(token)) { result.Error = AppError.ERROR_PERSON_NOT_LOGIN; } else { int userid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token)); ResPic pic = new ResPic(); pic.ObjId = userid; pic.ObjType = picType; pic.PicUrl = sourcePath; pic.PicDescription = description; pic.State = StateType.Active; int picid = ResPicAccessor.Instance.Insert(pic); pic.PicId = picid; result.Data = pic; result.Error = AppError.ERROR_SUCCESS; } } catch (Exception e) { result.Error = AppError.ERROR_FAILED; result.ExMessage = e.ToString(); } Res.Data = result; Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(Res); }
/// <summary> /// 添加企业合同(合同编号,合同名称,客户名称,合同有效期1,合同有效期2,合同承办人,合同签订时间,合同金额,付款方式(xml) /// </summary> /// <param name="contract"></param> /// <returns></returns> public JsonResult AddContractInfo(int ChanceId, String ContractNo, String CName, string CustomerName, DateTime StartTime, DateTime EndTime, DateTime ContractTime, double Amount, int HowToPay, List <ContractHowtopay> HowtopayList, List <int> attachments) { var Res = new JsonResult(); RespResult result = new RespResult(); int _conid = 0; if (CacheManagerFactory.GetMemoryManager().Contains(token)) { if (!CheckUserFunction(24)) { result.Error = AppError.ERROR_PERMISSION_FORBID; Res.Data = result; Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(Res); } int ownerid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token)); try { ContractInfo con = new ContractInfo(); con = ContractInfoAccessor.Instance.Get(ContractNo); if (con != null) { result.Error = AppError.ERROR_CONTRACTNO_EXIST; Res.Data = result; Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(Res); } ContractInfo co = new ContractInfo(); co.OwnerId = Convert.ToInt32(ownerid); co.CName = CName; co.ContractNo = ContractNo; co.CustomerName = CustomerName; co.StartTime = StartTime; co.EndTime = EndTime; co.ContractTime = ContractTime; co.Amount = Amount; co.Howtopay = HowToPay; co.HowtopayList = HowtopayList; co.EntId = CurrentUser.EntId; co.ChanceId = ChanceId; //if (entid == 0) //{ _conid = ContractInfoAccessor.Instance.Insert(co); try { for (int i = 0; i < HowtopayList.Count; i++) { HowtopayList[i].EntId = CurrentUser.EntId; ContractHowtopayAccessor.Instance.Insert(HowtopayList[i]); } } catch { } //} //else //{ // _entid = entid; // ce.EntId = _entid; // ContractInfoAccessor.Instance.Update(ce); //} try { for (int i = 0; i < attachments.Count; i++) { ResPic oldpic = ResPicAccessor.Instance.Get(attachments[i]); oldpic.ObjId = _conid; oldpic.ObjType = PicType.ContractFile; ResPicAccessor.Instance.Update(oldpic); } } catch { } result.Error = AppError.ERROR_SUCCESS; } catch (Exception e) { result.Error = AppError.ERROR_FAILED; result.ExMessage = e.ToString(); } } else { result.Error = AppError.ERROR_PERSON_NOT_LOGIN; } Res.Data = result; Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(Res); }