/// <summary> /// 获取指定记录 /// <param name="id">Id值</param> /// </summary> public GenReply Get(int Rid) { GenReply returnValue = null; MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdGetGenReply = cmdGetGenReply.Clone() as MySqlCommand; _cmdGetGenReply.Connection = oc; try { _cmdGetGenReply.Parameters["@Rid"].Value = Rid; if (oc.State == ConnectionState.Closed) { oc.Open(); } MySqlDataReader reader = _cmdGetGenReply.ExecuteReader(); if (reader.HasRows) { reader.Read(); returnValue = new GenReply().BuildSampleEntity(reader); } } finally { oc.Close(); oc.Dispose(); oc = null; _cmdGetGenReply.Dispose(); _cmdGetGenReply = null; GC.Collect(); } return(returnValue); }
/// <summary> /// 修改指定的数据 /// <param name="e">修改后的数据实体对象</param> /// <para>数据对应的主键必须在实例中设置</para> /// </summary> public void Update(GenReply e) { MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdUpdateGenReply = cmdUpdateGenReply.Clone() as MySqlCommand; _cmdUpdateGenReply.Connection = oc; try { if (oc.State == ConnectionState.Closed) { oc.Open(); } _cmdUpdateGenReply.Parameters["@Rid"].Value = e.Rid; _cmdUpdateGenReply.Parameters["@ObjId"].Value = e.ObjId; _cmdUpdateGenReply.Parameters["@ObjType"].Value = e.ObjType; _cmdUpdateGenReply.Parameters["@Content"].Value = e.Content; _cmdUpdateGenReply.Parameters["@CreateId"].Value = e.CreateId; _cmdUpdateGenReply.Parameters["@State"].Value = e.State; _cmdUpdateGenReply.Parameters["@RefUserId"].Value = e.RefUserId; _cmdUpdateGenReply.Parameters["@RefReplyId"].Value = e.RefReplyId; _cmdUpdateGenReply.ExecuteNonQuery(); } finally { oc.Close(); oc.Dispose(); oc = null; _cmdUpdateGenReply.Dispose(); _cmdUpdateGenReply = null; GC.Collect(); } }
/// <summary> /// 删除数据 /// <param name="es">数据实体对象数组</param> /// <returns></returns> /// </summary> public bool Delete(GenReply e) { MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdDeleteGenReply = cmdDeleteGenReply.Clone() as MySqlCommand; bool returnValue = false; _cmdDeleteGenReply.Connection = oc; try { if (oc.State == ConnectionState.Closed) { oc.Open(); } _cmdDeleteGenReply.Parameters["@Rid"].Value = e.Rid; _cmdDeleteGenReply.ExecuteNonQuery(); return(returnValue); } finally { oc.Close(); oc.Dispose(); oc = null; _cmdDeleteGenReply.Dispose(); _cmdDeleteGenReply = null; } }
/// <summary> /// 添加数据 /// <param name="es">数据实体对象数组</param> /// <returns></returns> /// </summary> public bool Insert(GenReply e) { MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdInsertGenReply = cmdInsertGenReply.Clone() as MySqlCommand; bool returnValue = false; _cmdInsertGenReply.Connection = oc; try { if (oc.State == ConnectionState.Closed) { oc.Open(); } _cmdInsertGenReply.Parameters["@ObjId"].Value = e.ObjId; _cmdInsertGenReply.Parameters["@ObjType"].Value = e.ObjType; _cmdInsertGenReply.Parameters["@Content"].Value = e.Content; _cmdInsertGenReply.Parameters["@CreateId"].Value = e.CreateId; _cmdInsertGenReply.Parameters["@RefUserId"].Value = e.RefUserId; _cmdInsertGenReply.Parameters["@RefReplyId"].Value = e.RefReplyId; _cmdInsertGenReply.ExecuteNonQuery(); return(returnValue); } finally { oc.Close(); oc.Dispose(); oc = null; _cmdInsertGenReply.Dispose(); _cmdInsertGenReply = null; } }
public ReplyModel Bind(GenReply item, ViewModelBindOption bindOptions) { this.Id = item.Rid; this.Content = item.Content; this.CreateTime = item.CreateTime; this.CreateTimeString = item.CreateTime.ToString("HH:mm"); if (ContainEnumType <ReplyBindType>(bindOptions.ReplayBindType, ReplyBindType.Author)) { UserServiceClient client = new UserServiceClient(); AdvancedResult <AdUser> userRes = client.GetUserInfoByID(item.CreateId); if (userRes.Error == DataStructure.AppError.ERROR_SUCCESS && userRes.Data != null) { this.Author = new UserModel().Bind(userRes.Data, bindOptions); } } if (ContainEnumType <ReplyBindType>(bindOptions.ReplayBindType, ReplyBindType.Product)) { ProductServiceClient client = new ProductServiceClient(); AdvancedResult <ProProduct> product = client.GetBBInfo(item.ObjId); if (product.Error == AppError.ERROR_SUCCESS) { this.Product = new ProductModel().Bind(product.Data, bindOptions); } } if (ContainEnumType <ReplyBindType>(bindOptions.ReplayBindType, ReplyBindType.RefReply)) { ReplyServiceClient client = new ReplyServiceClient(); if (--bindOptions.BindRefReplyCount >= 0 && item.RefReplyId > 0) { AdvancedResult <GenReply> refReply = client.Get(item.RefReplyId); if (refReply.Error == AppError.ERROR_SUCCESS) { RefReply = new ReplyModel().Bind(refReply.Data, bindOptions); } } } return(this); }
/// <summary> /// 回复心愿贴 /// </summary> /// <param name="blessID"></param> /// <param name="refReplyID"></param> /// <param name="Content"></param> /// <param name="token"></param> /// <returns></returns> public RespResult ReplyBless(int blessID, int refReplyID, string Content, string token) { RespResult result = new RespResult(); try { if (!CacheManagerFactory.GetMemoryManager().Contains(token)) { result.Error = AppError.ERROR_PERSON_NOT_LOGIN; } else { int userid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token)); GenBless bless = GetBless(blessID).Data; if (bless != null) { GenReply reply = new GenReply(); reply.ObjId = blessID; reply.ObjType = (int)ReplyType.Bless; reply.Content = Content; reply.CreateId = userid; reply.RefUserId = bless.CreateId; reply.RefReplyId = refReplyID; GenReplyAccessor.Instance.Insert(reply); result.Error = AppError.ERROR_SUCCESS; } else { result.Error = AppError.ERROR_FAILED; } } } catch (Exception e) { result.Error = AppError.ERROR_FAILED; result.ExMessage = e.ToString(); } return(result); }