Beispiel #1
0
        /// <summary>
        /// Променя данните за страницата
        /// </summary>
        public void SetPage(int siteID, SPageModel page)
        {
            // HTML Page
            if (page.TypeID == 1)
            {
                using (SQLiteCommand command = new SQLiteCommand(base.SQLConnection))
                {
                    command.CommandText =
                        @"UPDATE S_PAGES
     SET PAGE_NAME = " + ParameterString(page.Name) + @"
       , PAGE_TITLE = " + ParameterString(page.Title) + @"
       , PAGE_VALUE = " + ParameterString(page.Value) + @"
WHERE ID = " + ParameterInt(page.ID) + @"
  AND SITE_ID = " + ParameterInt(siteID);
                    command.ExecuteNonQuery();
                }
            }
            // MVC Page & MVC Layout
            else
            {
                using (SQLiteCommand command = new SQLiteCommand(base.SQLConnection))
                {
                    command.CommandText =
                        @"UPDATE S_PAGES
     SET PAGE_NAME = " + ParameterString(page.Name) + @"
       , PAGE_TITLE = " + ParameterString(page.Title) + @"
WHERE ID = " + ParameterInt(page.ID) + @"
  AND SITE_ID = " + ParameterInt(siteID);
                    command.ExecuteNonQuery();
                }

                string pagePath = GetPagePath(page.Name);
                WriterCSHTML(pagePath, page.Value);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Основни данни за нова страницата
        /// </summary>
        public SPageModel GetNewPage(int siteID, int typePage)
        {
            SPageModel page = null;

            using (SQLiteCommand command = new SQLiteCommand(base.SQLConnection))
            {
                command.CommandText =
                    @"SELECT pgt.ID AS PAGE_TYPE_ID
       , pgt.PAGE_TYPE_NAME
       , upt.S_PAGE_TYPE_EDITOR_ID
FROM S_PAGE_TYPES pgt
LEFT JOIN U_PAGE_TYPE_EDITOR upt
  ON upt.S_PAGE_TYPE_ID = pgt.ID
 AND upt.U_USER_ID = " + ParameterInt(HttpSession.UserID) + @"
WHERE pgt.ID = " + ParameterInt(typePage);
                using (SQLiteDataReader dReader = command.ExecuteReader())
                {
                    if (dReader.HasRows && dReader.Read())
                    {
                        page = new SPageModel
                        {
                            ID           = 0,
                            SiteID       = siteID,
                            TypeID       = TryParse.ToInt32(dReader["PAGE_TYPE_ID"]),
                            TypeName     = dReader["PAGE_TYPE_NAME"].ToString(),
                            TypeEditorID = TryParse.ToInt32(dReader["S_PAGE_TYPE_EDITOR_ID"])
                        };
                    }
                    else
                    {
                        page = new SPageModel
                        {
                            ID           = 0,
                            SiteID       = siteID,
                            TypeID       = 1,
                            TypeName     = "HTML Page",
                            TypeEditorID = 2    // Tinymce
                        };
                    }
                }
            }
            // Само при редакция
            if (page.ID > 0)
            {
                // MVC Page
                if (page.TypeID == 2)
                {
                    string pagePath = GetPagePath(page.SiteVeiw, page.Name);
                    page.Value = ReaderCSHTML(pagePath);
                }
            }
            return(page);
        }
Beispiel #3
0
        /// <summary>
        /// Основни данни за страницата
        /// </summary>
        public SPageModel GetPage(int siteID, int pageID)
        {
            SPageModel page = null;

            using (SQLiteCommand command = new SQLiteCommand(base.SQLConnection))
            {
                command.CommandText =
                    @"SELECT pg.ID
       , pg.PAGE_NAME
       , pg.PAGE_TITLE
       , pg.PAGE_VALUE
       , pg.PAGE_TYPE_ID
       , pgt.PAGE_TYPE_NAME
       , upt.S_PAGE_TYPE_EDITOR_ID
       , st.VIEW_ID
FROM S_PAGES pg
INNER JOIN S_SITES st
   ON st.ID = pg.SITE_ID
LEFT JOIN S_PAGE_TYPES pgt
  ON pgt.ID = pg.PAGE_TYPE_ID
LEFT JOIN U_PAGE_TYPE_EDITOR upt
  ON upt.S_PAGE_TYPE_ID = pg.PAGE_TYPE_ID
 AND upt.U_USER_ID = " + ParameterInt(HttpSession.UserID) + @"
WHERE pg.ID = " + ParameterInt(pageID) + @"
  AND pg.SITE_ID = " + ParameterInt(siteID);
                using (SQLiteDataReader dReader = command.ExecuteReader())
                {
                    if (dReader.HasRows && dReader.Read())
                    {
                        page = new SPageModel
                        {
                            ID           = pageID,
                            SiteID       = siteID,
                            Name         = dReader["PAGE_NAME"].ToString(),
                            Title        = dReader["PAGE_TITLE"].ToString(),
                            Value        = dReader["PAGE_VALUE"].ToString(),
                            TypeID       = TryParse.ToInt32(dReader["PAGE_TYPE_ID"]),
                            TypeName     = dReader["PAGE_TYPE_NAME"].ToString(),
                            TypeEditorID = TryParse.ToInt32(dReader["S_PAGE_TYPE_EDITOR_ID"]),
                            SiteVeiw     = dReader["VIEW_ID"].ToString()
                        };
                    }
                }
            }
            // MVC Page
            if (page.TypeID == 2)
            {
                string pagePath = GetPagePath(page.SiteVeiw, page.Name);
                page.Value = ReaderCSHTML(pagePath);
            }
            return(page);
        }
Beispiel #4
0
        /// <summary>
        /// Добавя страница
        /// </summary>
        public void AddPage(int siteID, SPageModel page)
        {
            // HTML Page
            if (page.TypeID == 1)
            {
                using (SQLiteCommand command = new SQLiteCommand(base.SQLConnection))
                {
                    command.CommandText =
                        @"INSERT INTO S_PAGES
  ( PAGE_NAME, PAGE_TITLE, PAGE_VALUE, SITE_ID, PAGE_TYPE_ID)
VALUES (" + ParameterString(page.Name) +
                        ", " + ParameterString(page.Title) +
                        ", " + ParameterString(page.Value) +
                        ", " + ParameterInt(siteID) +
                        ", " + ParameterInt(page.TypeID) + ")";
                    command.ExecuteNonQuery();
                }
            }
            // MVC Page & MVC Layout
            else
            {
                using (SQLiteCommand command = new SQLiteCommand(base.SQLConnection))
                {
                    command.CommandText =
                        @"INSERT INTO S_PAGES
  ( PAGE_NAME, PAGE_TITLE, SITE_ID, PAGE_TYPE_ID)
VALUES (" + ParameterString(page.Name) +
                        ", " + ParameterString(page.Title) +
                        ", " + ParameterInt(siteID) +
                        ", " + ParameterInt(page.TypeID) + ")";
                    command.ExecuteNonQuery();
                }

                page.SiteVeiw = GetSiteVeiw(siteID);
                string pagePath = GetPagePath(page.SiteVeiw, page.Name);
                WriterCSHTML(pagePath, page.Value);
            }
        }