/// <summary> /// ���� ����Ʈ�� �����´�. /// </summary> /// <param name="articleNo"></param> /// <returns></returns> public static CommentBindModel GetCommentList(int articleNo) { SqlParameter[] param = { CreateInParam("@ArticleNo", SqlDbType.Int, 4, articleNo) }; SqlCommand cmd = GetSpCommand("UBC_GetCommentList", param); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); CommentBindModel bindModel; try { bindModel = new CommentBindModel(articleNo); while (reader.Read()) { CommentModel model = new CommentModel(); FillComment( reader, model ); bindModel.Add( model ); model = null; } return bindModel; } catch( Exception ex ) { throw ex; } finally { ReleaseCommand(cmd); } }
/// <summary> /// ��� ��ȣ�� ����� �����´�. /// </summary> /// <param name="commentNo"></param> /// <returns></returns> public static CommentModel GetComment(int commentNo) { SqlParameter[] param = { CreateInParam("@CommentNo", SqlDbType.Int,4, commentNo ) }; SqlCommand cmd = GetSpCommand("UBC_GetComment", param ); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); CommentModel model = null; try { if (!reader.Read()) return model; model = new CommentModel(); FillComment(reader, model); return model; } catch (Exception ex) { throw new UmcDataException("UBC_GetComment ���ν��� ȣ���� ����", ex); } finally { ReleaseCommand(cmd); } }
public void Add(CommentModel model) { items.Add(model); }
protected void btnRegister_Click(object sender, ImageClickEventArgs e) { if (txtUserName.Text == string.Empty ) { Utility.JS_Alert(sender, CommentConst.MESSAGE_COMMENT_EMPTY_NAME); return; } if (txtPassword.Text == string.Empty) { Utility.JS_Alert(sender, CommentConst.MESSAGE_COMMENT_EMPTY_PASSWORD); return; } if (txtContent.Text == string.Empty) { Utility.JS_Alert(sender, CommentConst.MESSAGE_COMMENT_EMPTY_CONTENT); return; } if (txtConfirmBitmapHandler.Text == string.Empty) { Utility.JS_Alert(sender, CommentConst.MESSAGE_COMMENT_EMPTY_CONFIRM_VALIDATE_STRING ); return; } if (txtConfirmBitmapHandler.Text != (string)Session[Parameters.SESSION_CONFIRM_VALIDATE_STRING]) { Utility.JS_Alert(sender, CommentConst.MESSAGE_COMMENT_NOT_EQUAL_CONFIRM_VALIDATE_STRING ); return; } CommentModel model = new CommentModel(articleNo); model.UserEmail = CurrentUserInfo.EMail; model.Password = FormsAuthentication.HashPasswordForStoringInConfigFile( txtPassword.Text, AuthenticateConst.AUTHENTICATE_HASH_FORMAT); model.UserName = txtUserName.Text; model.UserBlogUrl = txtUserBlogUrl.Text; model.Content = txtContent.Text; model.UserIP = Request.UserHostAddress; CommentManager.GetInstance().InsertComment(model); Utility.JS_Alert(sender, CommentConst.MESSAGE_INSERT_COMMENT); bind(); ClearControl(); }
/// <summary> /// ����� �����Ѵ�. /// </summary> /// <param name="model"></param> public void UpdateComment(CommentModel model) { CommentAccess.UpdateComment(model); }
/* public Control LoadCommentControl(object form, int articleNo) { if( form is Page ) { UmcBlogBasePage template = (UmcBlogBasePage)((Page)form).LoadControl(CommentConst.PARAM_COMMENT_CONTROL_PATH); return template; } else if( form is UserControl ) { UmcContentsCommonPage template = (UmcContentsCommonPage)((UserControl)form).LoadControl(CommentConst.PARAM_COMMENT_CONTROL_PATH); return template; } throw new UmcException("Comment ��Ʈ���� �ε��� �� �����ϴ�"); } */ /// <summary> /// ��� ���� /// </summary> /// <param name="model"></param> /// <returns></returns> public int InsertComment(CommentModel model) { return CommentAccess.InsertComment(model); }
/// <summary> /// �ֽ� ��� ����Ʈ�� ������ŭ �����´�. /// </summary> /// <param name="count"></param> /// <returns></returns> public static CommentBindModel GetRecentCommentList(int count) { SqlParameter[] param = { CreateInParam("@Count", SqlDbType.Int,4, count ) }; SqlCommand cmd = GetSpCommand("UBC_GetRecentCommentList", param); SqlDataReader reader= cmd.ExecuteReader(CommandBehavior.CloseConnection); CommentBindModel bindModel = new CommentBindModel(); try { while(reader.Read()) { CommentModel model = new CommentModel(); FillComment( reader, model ); bindModel.Add( model ); model = null; } return bindModel; } catch( Exception ex) { throw new UmcDataException("UBC_GetRecentCommentList ���ν��� ȣ���� ����", ex); } finally { ReleaseCommand(cmd); } }
/// <summary> /// Ŭ������ ������ ä���. /// </summary> /// <param name="row"></param> /// <param name="Model"></param> private static void FillComment(IDataRecord row, CommentModel Model) { Model.ArticleNo = (int)row["ArticleNo"]; Model.CommentGroup = (int)row["CommentGroup"]; Model.CommentNo = (int)row["CommentNo"]; Model.CommentOrder = (int)row["CommentOrder"]; Model.CommentStep = (int)row["CommentStep"]; Model.Content = (string)row["Content"]; Model.InsertDate = (DateTime)row["InsertDate"]; Model.Password = (string)row["Password"]; Model.UpdateDate = row["UpdateDate"] != DBNull.Value ? row["UpdateDate"] : null; Model.UserBlogUrl = row["UserBlogUrl"]!=DBNull.Value ? (string)row["UserBlogUrl"] : null; Model.UserEmail = row["UserEmail"]!=DBNull.Value ? (string)row["UserEmail"] : null; Model.UserIP = (string)row["UserIP"]; Model.UserName = (string)row["UserName"]; }
/// <summary> /// ����� �����Ѵ�. /// </summary> /// <param name="model"></param> public static void UpdateComment(CommentModel model) { SqlParameter[] param = { CreateInParam("@CommentNo", SqlDbType.Int, 4, model.CommentNo), CreateInParam("@UserName", SqlDbType.VarChar,20, model.UserName), CreateInParam("@UserBlogUrl",SqlDbType.VarChar,255, model.UserBlogUrl), CreateInParam("@Content", SqlDbType.Text, Int32.MaxValue, model.Content), CreateInParam("@Password", SqlDbType.VarChar,100, model.Password ) }; SqlCommand cmd = GetSpCommand("UBC_UpdateComment", param, IsolationLevel.ReadUncommitted); try { cmd.ExecuteNonQuery(); ReleaseCommandWithCommit(cmd); } catch (Exception ex) { ReleaseCommandWithRollback(cmd); throw new UmcDataException("UBC_UpdateComment ���ν��� ȣ���� ����", ex); } }
/// <summary> /// ������ �߰��Ѵ�. /// </summary> /// <param name="model"></param> /// <returns></returns> public static int InsertComment(CommentModel model) { object email = model.UserEmail != null ? (object)model.UserEmail : DBNull.Value; SqlParameter[] param = { CreateInParam("@ArticleNo", SqlDbType.Int,4, model.ArticleNo), CreateInParam("@CommentGroup",SqlDbType.Int,4, model.CommentGroup), CreateInParam("@CommentStep",SqlDbType.Int,4, model.CommentStep), CreateInParam("@CommentOrder",SqlDbType.Int,4, model.CommentOrder), CreateInParam("@UserEmail",SqlDbType.VarChar,20, email), CreateInParam("@UserName",SqlDbType.VarChar,20, model.UserName), CreateInParam("@UserBlogUrl",SqlDbType.VarChar,255, model.UserBlogUrl), CreateInParam("@Content",SqlDbType.Text,Int32.MaxValue, model.Content ), CreateInParam("@Password",SqlDbType.VarChar,100, model.Password), CreateInParam("@UserIP",SqlDbType.VarChar,20, model.UserIP), CreateInParam("@Mode",SqlDbType.Int,4, (int)model.CommentType), CreateReturnValue() }; SqlCommand cmd = GetSpCommand("UBC_InsertComment", param, IsolationLevel.ReadUncommitted); try { cmd.ExecuteNonQuery(); int identity = (int)cmd.Parameters["@ReturnValue"].Value; ReleaseCommandWithCommit(cmd); return identity; } catch (Exception ex) { ReleaseCommandWithRollback(cmd); //throw new UmcDataException("UBC_InsertComment ȣ���� ����",ex); throw ex; } }