예제 #1
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(1))
        {
            int intOfCurrentState = (int)currentState;

            Debug.Log(countOfEnums);

            int        nextState = (intOfCurrentState + 1) % countOfEnums;
            PostStates next      = (PostStates)nextState;
            currentState = next;
        }
    }
예제 #2
0
    private void SavePost(PostStates state)
    {
        BSPost bsPost = new BSPost();
        bsPost.UserID = Blogsa.ActiveUser.UserID;
        bsPost.Title = txtPostTitle.Text;
        bsPost.Code = BSHelper.CreateCode(txtPostTitle.Text);
        bsPost.Content = txtPostContent.Text;
        bsPost.State = state;
        bsPost.Date = DateTime.Now;

        if (bsPost.Save())
        {
            SaveTags(bsPost.PostID);
            Response.Redirect("Posts.aspx?PostID=" + bsPost.PostID + "&Message=1");
        }
    }
    private void SavePost(PostStates state)
    {
        BSPost bsPost = new BSPost();

        bsPost.UserID  = Blogsa.ActiveUser.UserID;
        bsPost.Title   = txtPostTitle.Text;
        bsPost.Code    = BSHelper.CreateCode(txtPostTitle.Text);
        bsPost.Content = txtPostContent.Text;
        bsPost.State   = state;
        bsPost.Date    = DateTime.Now;

        if (bsPost.Save())
        {
            SaveTags(bsPost.PostID);
            Response.Redirect("Posts.aspx?PostID=" + bsPost.PostID + "&Message=1");
        }
    }
    public static List <BSPost> GetPosts(PostTypes postType, PostStates postState, int postCount)
    {
        List <BSPost> posts = new List <BSPost>();

        using (DataProcess dp = new DataProcess())
        {
            dp.AddParameter("Type", (short)postType);

            if (postState != PostStates.All)
            {
                dp.AddParameter("State", (short)postState);
                dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type AND [State]=@State ORDER By [CreateDate] DESC,[Title]"
                                               , postCount == 0 ? String.Empty : "TOP " + postCount));
            }
            else
            {
                dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type ORDER By [CreateDate] DESC,[Title]"
                                               , postCount == 0 ? String.Empty : "TOP " + postCount));
            }


            if (dp.Return.Status == DataProcessState.Success)
            {
                using (IDataReader dr = dp.Return.Value as IDataReader)
                {
                    while (dr != null && dr.Read())
                    {
                        BSPost bsPost = new BSPost();
                        FillPost(dr, bsPost);
                        posts.Add(bsPost);
                    }
                }
            }
        }
        return(posts);
    }
    public static List <BSPost> GetPostsByTerm(int termId, string code, TermTypes termType, PostTypes postType, PostStates postState)
    {
        List <BSPost> posts = new List <BSPost>();

        using (DataProcess dp = new DataProcess())
        {
            BSTerm bsTerm = null;

            bsTerm = termId != 0 ? BSTerm.GetTerm(termId) : BSTerm.GetTerm(code, termType);

            if (bsTerm != null)
            {
                dp.AddParameter("TermID", bsTerm.TermID);

                if (postState != PostStates.All)
                {
                    dp.AddParameter("State", (short)postState);
                    dp.ExecuteReader("SELECT * FROM Posts WHERE [PostID] IN (SELECT [ObjectID] FROM TermsTo WHERE [TermID]=@TermID) AND [State]=@State ORDER By [CreateDate] DESC");
                }
                else
                {
                    dp.ExecuteReader("SELECT * FROM Posts WHERE [PostID] IN (SELECT [ObjectID] FROM TermsTo WHERE [TermID]=@TermID) AND [Type]=@Type ORDER By [CreateDate] DESC");
                }
            }
            else
            {
                return(posts);
            }

            if (dp.Return.Status == DataProcessState.Success)
            {
                using (IDataReader dr = dp.Return.Value as IDataReader)
                {
                    while (dr != null && dr.Read())
                    {
                        BSPost bsPost = new BSPost();
                        FillPost(dr, bsPost);
                        posts.Add(bsPost);
                    }
                }
            }
        }
        return(posts);
    }
    public static List <BSPost> GetPostsByColumnValue(string column, object value, int postCount, string orderBy, PostTypes postType, PostStates postState)
    {
        List <BSPost> posts = new List <BSPost>();

        using (DataProcess dp = new DataProcess())
        {
            string top = postCount > 0 ? "TOP " + postCount : String.Empty;

            if (!String.IsNullOrEmpty(column) && value != null)
            {
                dp.AddParameter("Type", (short)postType);
                dp.AddParameter(column, value);
                if (postState == PostStates.All)
                {
                    dp.ExecuteReader(String.Format("SELECT {1} * FROM Posts WHERE [Type]=@Type AND [{0}]=@{0} {2}", column, top, orderBy));
                }
                else
                {
                    dp.AddParameter("State", (short)postState);
                    dp.ExecuteReader(String.Format("SELECT {1} * FROM Posts WHERE [Type]=@Type AND [{0}]=@{0} AND [State]=@State {2}", column, top, orderBy));
                }
            }
            else
            {
                dp.AddParameter("Type", (short)postType);
                if (postState == PostStates.All)
                {
                    dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type {1}", top, orderBy));
                }
                else
                {
                    dp.AddParameter("State", (short)postState);
                    dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type AND [State]=@State {1}", top, orderBy));
                }
            }
            if (dp.Return.Status == DataProcessState.Success)
            {
                using (IDataReader dr = dp.Return.Value as IDataReader)
                {
                    while (dr != null && dr.Read())
                    {
                        BSPost bsPost = new BSPost();
                        FillPost(dr, bsPost);
                        posts.Add(bsPost);
                    }
                }
            }
        }
        return(posts);
    }
예제 #7
0
파일: BSPost.cs 프로젝트: Blogsa/blogsa
    public static List<BSPost> GetPostsByTerm(int termId, string code, TermTypes termType, PostTypes postType, PostStates postState)
    {
        List<BSPost> posts = new List<BSPost>();
        using (DataProcess dp = new DataProcess())
        {
            BSTerm bsTerm = null;

            bsTerm = termId != 0 ? BSTerm.GetTerm(termId) : BSTerm.GetTerm(code, termType);

            if (bsTerm != null)
            {
                dp.AddParameter("TermID", bsTerm.TermID);

                if (postState != PostStates.All)
                {
                    dp.AddParameter("State", (short)postState);
                    dp.ExecuteReader("SELECT * FROM Posts WHERE [PostID] IN (SELECT [ObjectID] FROM TermsTo WHERE [TermID]=@TermID) AND [State]=@State ORDER By [CreateDate] DESC");
                }
                else
                {
                    dp.ExecuteReader("SELECT * FROM Posts WHERE [PostID] IN (SELECT [ObjectID] FROM TermsTo WHERE [TermID]=@TermID) AND [Type]=@Type ORDER By [CreateDate] DESC");
                }
            }
            else
                return posts;

            if (dp.Return.Status == DataProcessState.Success)
            {
                using (IDataReader dr = dp.Return.Value as IDataReader)
                {
                    while (dr != null && dr.Read())
                    {
                        BSPost bsPost = new BSPost();
                        FillPost(dr, bsPost);
                        posts.Add(bsPost);
                    }
                }
            }
        }
        return posts;
    }
예제 #8
0
파일: BSPost.cs 프로젝트: Blogsa/blogsa
    public static List<BSPost> GetPostsByColumnValue(string column, object value, int postCount, string orderBy, PostTypes postType, PostStates postState)
    {
        List<BSPost> posts = new List<BSPost>();
        using (DataProcess dp = new DataProcess())
        {
            string top = postCount > 0 ? "TOP " + postCount : String.Empty;

            if (!String.IsNullOrEmpty(column) && value != null)
            {
                dp.AddParameter("Type", (short)postType);
                dp.AddParameter(column, value);
                if (postState == PostStates.All)
                {
                    dp.ExecuteReader(String.Format("SELECT {1} * FROM Posts WHERE [Type]=@Type AND [{0}]=@{0} {2}", column, top, orderBy));
                }
                else
                {
                    dp.AddParameter("State", (short)postState);
                    dp.ExecuteReader(String.Format("SELECT {1} * FROM Posts WHERE [Type]=@Type AND [{0}]=@{0} AND [State]=@State {2}", column, top, orderBy));
                }
            }
            else
            {
                dp.AddParameter("Type", (short)postType);
                if (postState == PostStates.All)
                    dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type {1}", top, orderBy));
                else
                {
                    dp.AddParameter("State", (short)postState);
                    dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type AND [State]=@State {1}", top, orderBy));
                }
            }
            if (dp.Return.Status == DataProcessState.Success)
            {
                using (IDataReader dr = dp.Return.Value as IDataReader)
                {
                    while (dr != null && dr.Read())
                    {
                        BSPost bsPost = new BSPost();
                        FillPost(dr, bsPost);
                        posts.Add(bsPost);
                    }
                }
            }
        }
        return posts;
    }
예제 #9
0
파일: BSPost.cs 프로젝트: Blogsa/blogsa
    public static List<BSPost> GetPosts(PostTypes postType, PostStates postState, int postCount)
    {
        List<BSPost> posts = new List<BSPost>();
        using (DataProcess dp = new DataProcess())
        {
            dp.AddParameter("Type", (short)postType);

            if (postState != PostStates.All)
            {
                dp.AddParameter("State", (short)postState);
                dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type AND [State]=@State ORDER By [CreateDate] DESC,[Title]"
                    , postCount == 0 ? String.Empty : "TOP " + postCount));
            }
            else
            {
                dp.ExecuteReader(String.Format("SELECT {0} * FROM Posts WHERE [Type]=@Type ORDER By [CreateDate] DESC,[Title]"
                    , postCount == 0 ? String.Empty : "TOP " + postCount));
            }

            if (dp.Return.Status == DataProcessState.Success)
            {
                using (IDataReader dr = dp.Return.Value as IDataReader)
                {
                    while (dr != null && dr.Read())
                    {
                        BSPost bsPost = new BSPost();
                        FillPost(dr, bsPost);
                        posts.Add(bsPost);
                    }
                }
            }
        }
        return posts;
    }