Beispiel #1
0
        /// <summary>
        /// ��ƼŬ��ȣ�� ��ƼŬ�� �����´�.
        /// </summary>
        /// <param name="articleNo"></param>
        /// <returns></returns>
        public static ArticleModel GetArticleByArticleNo(int articleNo)
        {
            SqlParameter[] param = { CreateInParam("@ArticleNo",SqlDbType.Int, 4, articleNo) };

            SqlCommand cmd			= GetSpCommand("UBA_GetArticleByArticleNo", param);
            SqlDataReader reader	= cmd.ExecuteReader(CommandBehavior.CloseConnection);
            ArticleModel model		= null;

            try
            {
                if( !reader.Read() ) return model;
                model = new ArticleModel();
                FillArticle( reader, model );
                FillTag(reader, model);
                FillAttachFile( reader, model );

                return model;
            }
            catch (Exception ex)
            {
                throw new UmcDataException("UBA_GetArticleByArticleNo ���ν��� ȣ���� ����", ex);
            }
            finally
            {
                ReleaseCommand(cmd);
            }
        }
 public void Add(ArticleModel model)
 {
     items.Add( model );
 }
    private void updateArticle(ArticleModel model)
    {
        model.ArticleNo						= articleNo;
        HttpFileCollection fileCollection	= Request.Files;
        bool succ = ArticleManager.GetInstance().UpdateArticle( model, fileCollection );

        string script = string.Empty;

        if( succ )
            script = string.Format("alert('{0}'); location.href='{1}{2}';",
                UmcConfiguration.Message[ArticleConst.MESSAGE_UPDATE_SUCCESS],
                ViewQueryString,
                articleNo.ToString());
        else
            script = string.Format("alert('{0}'); location.href='{1}{2}';",
                UmcConfiguration.Message[ArticleConst.MESSAGE_UPDATE_FAIL],
                ViewQueryString,
                articleNo.ToString());

        Utility.JsCall( this, script );
    }
    // 컨트롤 초기화
    private void init()
    {
        // FckEditor 초기화
        string sPath = Request.Url.AbsolutePath;
        sPath = "/FckEditor/";
        FCKeditor1.BasePath = sPath;

        FCKeditor1.Height = new Unit(400);
        FCKeditor1.UseBROnCarriageReturn = true;
        FCKeditor1.ImageBrowserURL = sPath + "editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/aspx/connector.aspx";
        FCKeditor1.LinkBrowserURL = sPath + "editor/filemanager/browser/default/browser.html?Connector=connectors/aspx/connector.aspx";

        // 카테고리 데이터를 초기화
        ddlCategoryL.Items.Clear();
        for (int i = 0; i < categoryL.Count; i++)
        {
            if (categoryL[i].CategoryStep == 1)
            {
                ListItem item = new ListItem(categoryL[i].CategoryTitle, categoryL[i].CategoryGroup.ToString());
                ddlCategoryL.Items.Add(item);
            }
        }

        // 아티클 수정 모드일때 내용 초기화
        if (articleNo > 0 )
        {
            articleModel = ArticleManager.GetInstance().GetArticleByArticleNo(articleNo);

            txtTitle.Text					= articleModel.Title;
            txtTrackbackUrl.Text			= articleModel.TrackbackUrl;
            FCKeditor1.Value				= articleModel.Content;
            rblPublicFlag.SelectedValue		= articleModel.PublicFlag.ToString();
            rblPublicRss.SelectedValue		= articleModel.PublicRss.ToString();
            rblAllowComment.SelectedValue	= articleModel.AllowComment.ToString();
            rblAllowTrackback.SelectedValue	= articleModel.AllowTrackback.ToString();
            txtTag.Text						= TagModel.Parse( articleModel.Tag );

            dlAttachFile.DataSource			= articleModel.AttachFile;
            dlAttachFile.DataBind();

            ddlCategoryL.SelectedValue		= articleModel.CategoryGroup.ToString();
        }
    }
    protected void lnkRegister_Click(object sender, EventArgs e)
    {
        if (txtTitle.Text.Length == 0)
        {
            Utility.JS_Alert(sender, MessageCode.GetMessageByCode("message.no.title"));
            return;
        }
        if (FCKeditor1.Value.Length == 0)
        {
            Utility.JS_Alert(sender, MessageCode.GetMessageByCode("message.no.content"));
            return;
        }
        bool tagValidate = true;
        foreach (string noTag in noTagList)
        {
            if (txtTag.Text.IndexOf(noTag) != -1)
            {
                tagValidate = false;
                break;
            }
        }
        if (!tagValidate)
        {
            Utility.JS_Alert(sender, MessageCode.GetMessageByCode("message.article.notaglist"));
            return;
        }

        HttpFileCollection fileCollection	= Request.Files;
        //CategoryNodeValue node				= CategoryNodeValue.Parse( ddlCategoryM.SelectedValue );

        ArticleModel model	= new ArticleModel();
        model.CategoryID	= int.Parse( ddlCategoryM.SelectedValue );
        model.Title			= txtTitle.Text;
        model.Content		= FCKeditor1.Value;
        model.TrackbackUrl	= txtTrackbackUrl.Text;
        model.PublicFlag	= bool.Parse( rblPublicFlag.SelectedValue );
        model.PublicRss		= bool.Parse( rblPublicRss.SelectedValue );
        model.AllowComment	= bool.Parse( rblAllowComment.SelectedValue );
        model.AllowTrackback= bool.Parse( rblAllowTrackback.SelectedValue );

        string[] tags	= txtTag.Text.Split(',');

        foreach (string tag in tags)
        {
            model.Tag.Add( new TagModel(tag) );
        }

        // 아티클 수정모드라면 다른곳으로 분기
        if (articleNo > 0)
        {
            updateArticle( model );
            return;
        }

        int seqNo = ArticleManager.GetInstance().InsertArticle( model, fileCollection );

        TrackbackModel trackbackModel	= new TrackbackModel();
        trackbackModel.ArticleNo		= seqNo;
        trackbackModel.Blog_Name		= BlogManager.GetInstance().BlogBaseModel.BlogModel.Title;
        trackbackModel.Title			= model.Title;
        trackbackModel.Exceprt			= model.Content;
        trackbackModel.Url				= Utility.MakeArticleUrl( seqNo );
        trackbackModel.UserIP			= Request.UserHostAddress;

        // 트랙백 보내는 아티클이면..
        if (txtTrackbackUrl.Text.Length > 0)
        {
            TrackbackManager.GetInstance().SendTrackback( txtTrackbackUrl.Text, trackbackModel );
        }

        string script = string.Format("alert('{0}'); location.href='{1}';",
                UmcConfiguration.Message[ArticleConst.MESSAGE_ARTICLE_REGIST],
                ListQueryString);
        Utility.JsCall( sender, script );
    }
        protected void bind()
        {
            model = ArticleManager.GetInstance().GetArticleByArticleNo(articleNo);

            if (model == null)
            {
                divTag.Visible			= false;
                divTrackback.Visible	= false;
                SetMessageContent(ArticleConst.MESSAGE_HAS_NOT_ARTICLE);
                return;
            }

            string tempContent = model.Content;
            if (BlogManager.GetInstance().BlogBaseModel.BlogModel.UseEmoticon)
            {
                List<EmoticonModel> bindModel = EmoticonManager.GetInstance().Model;
                for (int i = 0; i < bindModel.Count; i++)
                {
                    string imgTag = string.Format("<img src=\"{0}/Emoticon/{1}\" alt=\"{2}\" style=\"vertical-align:middle;\" />",
                        UmcConfiguration.Core["repository.dir"],
                        bindModel[i].EmoticonValue,
                        bindModel[i].Description);

                    tempContent = tempContent.Replace(bindModel[i].EmoticonString, imgTag);
                }
            }

            hpTitle.Text			= model.Title;
            hpTitle.NavigateUrl		= Utility.MakeArticleUrl( model.ArticleNo );
            hpTitle.Target			= "_parent";
            lblInsertDate.Text		= ((DateTime)model.InsertDate).ToShortDateString();
            divContent.InnerHtml	= tempContent;

            // 비공개 아티클일 경우
            if (!model.PublicFlag && CurrentUserInfo.Level != LevelAttribute.ADMIN)
            {
                divTag.Visible = divTrackback.Visible = divContent.Visible = false;
                SetMessageContent(ArticleConst.MESSAGE_NOT_PERMIT_READ_ARTICLE);
                return;
            }

            // 트랙백이 허용될경우
            if (model.AllowTrackback)
            {
                lblTrackbackUrl.Text = Utility.MakeTrackbackUrl(articleNo);
                lblTrackbackUrl.Style.Add("cursor", "hand");
                lblTrackbackUrl.Attributes["onclick"] = "javascript:copyBlock(this)";
            }

            // 댓글달리 리스트 바인딩
            CommentContent commentTempalte	= (CommentContent)LoadControl( CommentConst.PARAM_COMMENT_CONTROL_PATH );
            commentTempalte.ArticleNo		= articleNo;
            commentTempalte.IsWriteComment	=
                model.AllowComment && BlogManager.GetInstance().BlogBaseModel.PrivacyModel.CanWriteMemo;
            phComment.Controls.Add( commentTempalte );

            // 트랙백 리스트 바인딩
            dlTrackbackList.DataSource		= TrackbackManager.GetInstance().GetTrackbackList( articleNo );
            dlTrackbackList.DataBind();

            // 태그 바인딩
            dlTag.DataSource				= model.Tag;
            dlTag.DataBind();

            dlAttachFile.DataSource = model.AttachFile;
            dlAttachFile.DataBind();

            ltrCommentCount.Text			= model.CommentCount.ToString();
            ltrTrackbackCount.Text			= model.TrackbackCount.ToString();
            aGoComment.HRef					= Utility.MakeArticleUrl( model.ArticleNo ) + "#comment";
        }
Beispiel #7
0
        /// <summary>
        /// ī�װ���� ��ƼŬ ����Ʈ�� �����´�
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static ArticleBindModel GetArticleList(CategoryNodeValue node)
        {
            SqlParameter[] param = {
                CreateInParam("@CategoryID",		SqlDbType.Int,4,		node.CategoryID),
                CreateInParam("@CategoryStep",		SqlDbType.Int,4,		node.CategoryStep)
            };

            SqlCommand cmd				= GetSpCommand("UBA_GetArticleListByCategoryID", param);
            SqlDataReader reader		= cmd.ExecuteReader( CommandBehavior.CloseConnection );
            ArticleBindModel bindModel	= new ArticleBindModel();
            try
            {
                while (reader.Read())
                {
                    ArticleModel model = new ArticleModel();

                    FillArticle(reader, model);

                    bindModel.Add(model);
                    model = null;
                }

                return bindModel;
            }
            catch ( Exception ex )
            {
                throw new UmcDataException("UBA_GetArticleListByCategoryID ���ν��� ȣ���� ����", ex);
            }
            finally
            {
                reader.Close();
                ReleaseCommand(cmd);
            }
        }
Beispiel #8
0
 private static void FillTag(SqlDataReader reader, ArticleModel model)
 {
     if (reader.NextResult())
     {
         while (reader.Read())
         {
             model.Tag.Add(new TagModel((int)reader["TagNo"], (string)reader["TagName"], (DateTime)reader["InsertDate"]));
         }
     }
 }
Beispiel #9
0
        private static void FillAttachFile(SqlDataReader reader, ArticleModel model)
        {
            if( !reader.NextResult() ) return;

            while (reader.Read())
            {
                AttachFileModel fileModel = new AttachFileModel((int)reader["FileNo"]);
                fileModel.ArticleNo		= (int)reader["ArticleNo"];
                fileModel.FilePath		= (string)reader["FilePath"];
                fileModel.FileSize		= (int)reader["FileSize"];
                fileModel.DownCount		= (int)reader["DownCount"];
                fileModel.InsertDate	= (DateTime)reader["InsertDate"];

                model.AttachFile.Add( fileModel );

                fileModel				= null;
            }
        }
Beispiel #10
0
        private static void FillArticle(IDataRecord reader,ArticleModel model)
        {
            model.ArticleNo			= (int)reader["ArticleNo"];
            model.CategoryID		= (int)reader["CategoryID"];
            model.Title				= (string)reader["Title"];
            model.Content			= (string)reader["Content"];
            model.TrackbackUrl		= reader["TrackbackUrl"] != DBNull.Value ? (string)reader["TrackbackUrl"] : null;
            model.ViewCount			= (int)reader["ViewCount"];
            model.TrackbackCount	= (int)reader["TrackbackCount"];
            model.CommentCount		= (int)reader["CommentCount"];
            model.PublicFlag		= (bool)reader["PublicFlag"];
            model.PublicRss			= (bool)reader["PublicRss"];
            model.AllowComment		= (bool)reader["AllowComment"];
            model.AllowTrackback	= (bool)reader["AllowTrackback"];
            model.CategoryLCode		= ( reader["CategoryLCode"] != DBNull.Value ) ? (int)reader["CategoryLCode"] : -1;
            model.CategoryMCode		= ( reader["CategoryMCode"] != DBNull.Value ) ? (int)reader["CategoryMCode"] : -1;
            model.InsertDate		= ( reader["InsertDate"] != DBNull.Value) ? reader["InsertDate"] : null;
            model.UpdateDate		= ( reader["UpdateDate"] != DBNull.Value) ? reader["UpdateDate"] : null;
            try
            {
                model.CategoryGroup = (int)reader["CategoryGroup"];
                model.CategoryOrder = (int)reader["CategoryStep"];
                model.CategoryStep	= (int)reader["CategoryOrder"];
            }
            catch (IndexOutOfRangeException ex) { }
            try
            {
                model.CategoryMTitle = (string)reader["CategoryMTitle"];
            }
            catch (IndexOutOfRangeException ex) { }

            try
            {
                model.Tag.Add((string)reader["Tag"]);
            }
            catch (IndexOutOfRangeException ex)
            {
            }
        }
Beispiel #11
0
        /// <summary>
        /// ��ƼŬ�� �����Ѵ�.
        /// </summary>
        /// <param name="model"></param>
        /// <param name="fileCollection"></param>
        /// <returns></returns>
        public static bool UpdateArticle(ArticleModel model, HttpFileCollection fileCollection)
        {
            object trackbackUrl = model.TrackbackUrl.Length > 0 ? (object)model.TrackbackUrl : DBNull.Value;

            SqlParameter[] param =
                {
                    CreateInParam("@ArticleNo",					SqlDbType.Int,4,				model.ArticleNo),
                    CreateInParam("@CategoryID",				SqlDbType.Int, 4,				model.CategoryID),
                    CreateInParam("@Title",						SqlDbType.VarChar,255,			model.Title),
                    CreateInParam("@Content",					SqlDbType.Text,Int32.MaxValue,	model.Content),
                    CreateInParam("@TrackbackUrl",				SqlDbType.VarChar,255,			trackbackUrl),
                    CreateInParam("@PublicFlag",				SqlDbType.Bit,1,				model.PublicFlag),
                    CreateInParam("@PublicRss",					SqlDbType.Bit,1,				model.PublicRss),
                    CreateInParam("@AllowComment",				SqlDbType.Bit,1,				model.AllowComment),
                    CreateInParam("@AllowTrackback",			SqlDbType.Bit,1,				model.AllowTrackback)
                };

            SqlCommand cmd = GetSpCommand("UBA_UpdateArticle", param, IsolationLevel.ReadCommitted);

            try
            {
                cmd.ExecuteNonQuery();

                // ÷������ ����
                for (int i = 0; i < fileCollection.Count; i++)
                {
                    if (fileCollection[i].ContentLength <= 0) continue;
                    string path = string.Format("{0}/{1}", REPOSITORY_ARTICLE, model.ArticleNo.ToString());
                    RepositoryManager.GetInstance().SaveAs(path, fileCollection[i]);

                    AttachFileModel fileModel = new AttachFileModel();
                    fileModel.ArticleNo = model.ArticleNo;
                    fileModel.FilePath = path + "/" + Path.GetFileName(fileCollection[i].FileName);
                    fileModel.FileSize = fileCollection[i].ContentLength;

                    InsertAttachFile(cmd, fileModel);

                    fileModel = null;
                }

                // �±׸� ����� ������ �±׸� �����Ѵ�.
                RemoveTagAll( cmd, model.ArticleNo );
                if (!InsertTag(cmd, model.ArticleNo, model.Tag))
                {
                    throw new UmcDataException("Tag ������ ����");
                }

                ReleaseCommandWithCommit(cmd);

                return true;
            }
            catch (Exception ex)
            {
                ReleaseCommandWithRollback(cmd);
                //return false;
                throw new UmcDataException("UBA_UpdateArticle ���ν��� ȣ���� ����", ex);
            }
        }
Beispiel #12
0
        /// <summary>
        /// �ֱ� ��ƼŬ�� �����´�.
        /// </summary>
        /// <param name="count"></param>
        /// <returns></returns>
        public static ArticleBindModel GetRecentArticleList(int count)
        {
            SqlParameter[] param = { CreateInParam("@Count", SqlDbType.Int,4, count) };

            SqlCommand cmd			= GetSpCommand("UBA_GetRecentArticle", param);
            SqlDataReader reader	= cmd.ExecuteReader(CommandBehavior.CloseConnection);
            ArticleBindModel bindModel = new ArticleBindModel();

            try
            {
                while (reader.Read())
                {
                    ArticleModel model = new ArticleModel();
                    FillArticle(reader, model);

                    bindModel.Add(model);

                    model = null;
                }
                return bindModel;
            }
            catch (Exception ex)
            {
                throw new UmcDataException("UBA_GetRecentArticle ���ν��� ȣ���� ����", ex);
            }
            finally
            {
                ReleaseCommand(cmd);
            }
        }
Beispiel #13
0
        /// <summary>
        /// �±׷� ��ƼŬ�� �����´�.
        /// </summary>
        /// <param name="currentPage"></param>
        /// <param name="pageCount"></param>
        /// <param name="tag"></param>
        /// <param name="publicArticle"></param>
        /// <returns></returns>
        public static ArticleBindModel GetArticleListByTag(string tag, bool publicArticle)
        {
            SqlParameter[] param = {
                CreateInParam("@Tag",			SqlDbType.VarChar,50,			tag),
                CreateInParam("@PublicArticle",	SqlDbType.Bit,1,				publicArticle)
            };

            SqlCommand cmd					= GetSpCommand("UBA_GetArticleListByTag", param);
            SqlDataReader reader			= cmd.ExecuteReader( CommandBehavior.CloseConnection );
            ArticleBindModel bindModel		= new ArticleBindModel();

            try
            {
                while (reader.Read())
                {
                    ArticleModel model = new ArticleModel();
                    FillArticle(reader, model);
                    bindModel.Add(model);

                    model = null;
                }

                return bindModel;
            }
            finally
            {
                ReleaseCommand(cmd);
            }
        }
Beispiel #14
0
        /// <summary>
        /// �˻� �Ǵ� ������ ���� ��ƼŬ�� �����´�.
        /// </summary>
        /// <param name="currentPage"></param>
        /// <param name="pageCount"></param>
        /// <param name="searchMode"></param>
        /// <param name="searchKeyword"></param>
        /// <param name="publicArticle">��������Ʈ true / ����� ����Ʈ���� false</param>
        /// <returns></returns>
        public static ArticleBindModel GetArticleList(int currentPage, int pageCount, string searchMode, string searchKeyword, bool publicArticle)
        {
            SqlParameter[] param = {
                CreateInParam("@CurrentPage",			SqlDbType.Int,4,			currentPage),
                CreateInParam("@PageSize",				SqlDbType.Int,4,			pageCount),
                CreateInParam("@SearchMode",			SqlDbType.VarChar,20,		searchMode),
                CreateInParam("@SearchKeyword",			SqlDbType.VarChar,20,		searchKeyword),
                CreateInParam("@PublicArticle",			SqlDbType.Bit,1,			publicArticle)
            };

            SqlCommand cmd				= GetSpCommand("UBA_GetArticleList", param);
            SqlDataReader reader		= cmd.ExecuteReader( CommandBehavior.CloseConnection );
            ArticleBindModel bindModel	= new ArticleBindModel();

            try
            {
                if( reader.Read() )
                    bindModel.TotalCount= (int)reader["Count"];

                if( !reader.NextResult() ) return bindModel;

                while (reader.Read())
                {
                    ArticleModel model	= new ArticleModel();
                    FillArticle( reader, model );

                    bindModel.Add( model );
                    model				= null;
                }

                return bindModel;
            }
            finally
            {
                ReleaseCommand(cmd);
            }
        }
Beispiel #15
0
 /// <summary>
 /// ��ƼŬ�� �����Ѵ�.
 /// </summary>
 /// <param name="model"></param>
 /// <param name="fileCollection"></param>
 /// <returns></returns>
 public bool UpdateArticle(ArticleModel model, HttpFileCollection fileCollection)
 {
     return ArticleAccess.UpdateArticle( model, fileCollection );
 }
Beispiel #16
0
 /// <summary>
 /// ��ƼŬ�� �����Ѵ�.
 /// </summary>
 /// <param name="model"></param>
 public int InsertArticle( ArticleModel model, HttpFileCollection fileCollection)
 {
     return ArticleAccess.InsertArticle( model, fileCollection );
 }