Exemplo n.º 1
0
        // public string getBaseURL()
        //{
        //    cmd.CommandText = "SELECT BaseUrl FROM Brafton WHERE content='1'";
        //    string baseURL = cmd.ExecuteScalar().ToString();
        //    return baseURL;
        //}
        #endregion Base URL

        #region Updated Feed Content
        ///////////////////GET AND SET Checkbox for Updated Content//////////////////////////
        protected void setUpdateContent_Click()
        {
            connection2 = new SqlConnection(ConfigurationManager.ConnectionStrings["SiteSqlServer"].ToString());

            connection2.Open();
            cmd.Connection = connection2;

            cmd.CommandText = "IF OBJECT_ID('Brafton') IS NOT NULL(SELECT count(*) as total_record FROM Brafton WHERE content='1') ELSE SELECT 0";
            int updateContent = (int)cmd.ExecuteScalar();


            Brafton.DotNetNuke.BraftonSchedule B1 = new Brafton.DotNetNuke.BraftonSchedule();
            int checkForUpdatedCheck = B1.getUpdatedContent();



            //Check what is set in the db
            Brafton.DotNetNuke.BraftonSchedule B2 = new Brafton.DotNetNuke.BraftonSchedule();
            int checkForUpdatedCheckDB            = B2.getUpdatedContent();

            if (InclUpdatedFeedContent.Checked == true)
            {
                MyGlobals.IncludeUpdatedFeedContent = 1;
                cmd.CommandText = "UPDATE Brafton SET IncUpdatedFeedContentValue = 1 WHERE Content = '1'";
                cmd.ExecuteNonQuery();
                //checkedStatusLabel.Text = "The after click value in the db =" + checkForUpdatedCheckDB + " and the value in globals is " + MyGlobals.IncludeUpdatedFeedContent+"And should be checked";
                //checkedStatusLabel.Text = "CLICKED";
            }
            else if (InclUpdatedFeedContent.Checked == false)
            {
                MyGlobals.IncludeUpdatedFeedContent = 0;
                cmd.CommandText = "UPDATE Brafton SET IncUpdatedFeedContentValue = 0 WHERE Content = '1'";
                cmd.ExecuteNonQuery();
                //checkedStatusLabel.Text = "The afet click value in the db =" + checkForUpdatedCheckDB + " and the value in globals is " + MyGlobals.IncludeUpdatedFeedContent+"And should not be checked";
                //checkedStatusLabel.Text = "NOT CLICKED";
            }

            else
            {
                checkedStatusLabel.Text = "SOMETHING ELSE HAPPENED";
            }
            //connection2.Close();
            try
            {
            }
            catch (Exception ex)
            {
                labelError.Text = "Generic exception: " + ex.ToString();
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //connection.Open();
            //cmd.Connection = connection;
            //cmd2.Connection = connection;

            //cmd2.CommandText = "Select Title From Blog_Entries where EntryID = 2";

            //string apiTest = cmd2.ExecuteScalar().ToString();

            // apiURLLabel.Text = apiTest;

            //connection.Close();


            //********************************************************************
            //TODO check for Brafton Table


            //cmd2.CommandText = "CREATE TABLE [dbo].Brafton(Id int IDENTITY(1,1) NOT NULL,Content nvarchar(MAX) NULL,Api nvarchar(MAX) NULL,BaseUrl nvarchar(MAX) NULL, BlogId int NULL,PortalId int NULL,TabId int NULL,DomainName nvarchar(MAX) NULL, Limit int NULL)";
            //cmd2.ExecuteNonQuery();

            //********************************************************************



            try
            {
                //Get current directory for style sheets and images
                appPath = HttpRuntime.AppDomainAppVirtualPath == "/" ? appPath = "" : appPath = HttpRuntime.AppDomainAppVirtualPath;

                connection.Open();
                cmd.Connection = connection;

                //Showing your current portal ID

                intPortalID          = PortalSettings.PortalId;
                currentPortalID.Text = intPortalID.ToString();

                //Showing your current TabID
                PageTabId         = PortalSettings.ActiveTab.TabID;
                currentTabID.Text = PortalSettings.ActiveTab.TabID.ToString();

                //Get your current domain to insert into database for error checking
                checkDomain = HttpContext.Current.Request.Url.Host;

                //MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "Check Domain:" + checkDomain;

                Dictionary <string, int> checkAll = checks();

                //Sets the current PortalID in the Brafton Table
                cmd.CommandText = "IF Exists (SELECT * FROM Brafton WHERE content='1') UPDATE Brafton SET PortalId = " + intPortalID + " WHERE Content = '1' else INSERT INTO Brafton (Content, PortalId) VALUES (1, '" + intPortalID + "')";
                cmd.ExecuteNonQuery();

                //Sets the current TabID in the Brafton Table
                cmd.CommandText = "IF Exists (SELECT * FROM Brafton WHERE content='1') UPDATE Brafton SET TabId = " + PageTabId + " WHERE Content = '1' else INSERT INTO Brafton (Content, TabId) VALUES (1, '" + PageTabId + "')";
                cmd.ExecuteNonQuery();

                //Sets the current domain in the Brafton Table
                cmd.CommandText = "IF Exists (SELECT * FROM Brafton WHERE content='1') UPDATE Brafton SET DomainName = 'http://" + checkDomain + "' WHERE Content = '1' else INSERT INTO Brafton (Content, DomainName) VALUES (1, 'http://" + checkDomain + "')";
                cmd.ExecuteNonQuery();

                //HERE WE SET THE GLOBAL VARIABLES
                //This fills all the relevant fields with values from the database if they exist
                //All the prior queries have been left intact for the time being but can eventually be phased out

                MyGlobals.PopGlobals();

                checkedStatusLabel.Text = MyGlobals.MyGlobalError; //For debugging it is a global text field you pass errors into

                if (checkAll["Friendly Urls"] == 1)
                {
                    boolFriendURL.Text     = "True";
                    boolFriendURL.CssClass = "boolTrue";
                }
                else
                {
                    boolFriendURL.Text     = "False";
                    boolFriendURL.CssClass = "boolFalse";
                }

                if (checkAll["Blog Module"] == 1)
                {
                    boolBlogModule.Text     = "True";
                    boolBlogModule.CssClass = "boolTrue";
                    cmd.CommandText         = "IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='Blog_Entries' AND column_name='BraftonID') BEGIN ALTER TABLE Blog_Entries ADD BraftonID nvarchar(255) END";
                    cmd.ExecuteNonQuery();
                }
                else
                {
                    boolBlogModule.Text     = "False";
                    boolBlogModule.CssClass = "boolFalse";
                }


                if (checkAll["Blog"] == 1)
                {
                    boolBlogCreated.Text     = "True";
                    boolBlogCreated.CssClass = "boolTrue";

                    cmd.CommandText = "Select Title From Blog_Blogs where PortalID = '" + intPortalID + "'";
                    SqlDataReader blogOptions = cmd.ExecuteReader();

                    if (!IsPostBack && blogOptions.HasRows)
                    {
                        while (blogOptions.Read())
                        {
                            blogIdDrpDwn.Items.Add(new ListItem(blogOptions.GetString(0)));
                        }
                    }

                    blogOptions.Close();
                    setAPIPH.Visible = true;
                }
                else
                {
                    boolBlogCreated.Text     = "False";
                    boolBlogCreated.CssClass = "boolFalse";
                }

                if (checkAll["News API"] == 0)
                {
                    boolCheckAPI.Text     = "False";
                    boolCheckAPI.CssClass = "boolFalse";
                    nextStep.Visible      = false;
                }
                else
                {
                    cmd.CommandText = "SELECT Api FROM Brafton WHERE content='1'";
                    string newsAPI = (string)cmd.ExecuteScalar();
                    boolCheckAPI.Text = "<span class='boolTrue'>True</span>";
                    //apiURLLabel.Text = newsAPI;
                    apiURL.Text = newsAPI;
                    if (checkAll["Base Url"] == 1)
                    {
                        nextStep.Visible = true;
                    }
                }

                if (checkAll["Base Url"] == 0)
                {
                    boolCheckUrl.Text     = "False";
                    boolCheckUrl.CssClass = "boolFalse";
                }
                else
                {
                    cmd.CommandText = "SELECT BaseUrl FROM Brafton WHERE content='1'";
                    string newsAPI = (string)cmd.ExecuteScalar();
                    boolCheckUrl.Text = "<span class='boolTrue'>True</span>";
                    //baseURLLabel.Text = newsAPI;
                    baseURL.Text = newsAPI;
                }

                //if (checkAll["Limit"] == 1)
                //{
                //    cmd.CommandText = "SELECT Limit FROM Brafton WHERE content='1'";
                //    limitLabel.Text = cmd.ExecuteScalar().ToString();
                //}

                if (checkAll["Blog ID"] == 0)
                {
                    boolCheckBlogID.Text = "<span class='boolFalse'>False</span>";
                }
                else
                {
                    boolCheckBlogID.Text = "<span class='boolTrue'>True</span>";
                    cmd.CommandText      = "Select Title From Blog_Blogs Where BlogID = " + getBlogID();
                    string blogTitle = (string)cmd.ExecuteScalar();
                    currentBlogID.Text = blogTitle;
                }

                //check for video settings if there fill fields and make visible
                if (checkAll["Vid ID"] == 1)
                {
                    if (Page.IsPostBack == false)
                    {
                        VideoSettings.Visible = true;
                        //InclVideo.Checked = true;
                        updateVidSettings.Visible  = true;
                        MyGlobals.IncludeVideo     = 1;
                        setVidSettings.Visible     = false;
                        CurrentVidSetting1.Visible = true;
                        CurrentVidSetting2.Visible = false;
                        //CurrentVidSetting3.Visible = true;
                        VideoBaseURL.Text    = MyGlobals.VideoBaseURL;
                        VideoPhotoURL.Text   = MyGlobals.VideoPhotoURL;
                        VideoPublicKey.Text  = MyGlobals.VideoPublicKey;
                        VideoSecretKey.Text  = MyGlobals.VideoSecretKey;
                        VideoFeedNumber.Text = MyGlobals.VideoFeedNumber.ToString();

                        RadioButtonList1.SelectedValue = "video";
                        VideoSettings.Visible          = true;
                        VideoPlaceHolder.Visible       = true;

                        Import.Visible = true;
                    }
                }

                if (checkAll["Vid ID"] == 1 && checkAll["Base Url"] == 1)
                {
                    Import.Visible = true;
                    if (Page.IsPostBack == false)
                    {
                        RadioButtonList1.SelectedValue = "both";
                        ArticlePlaceHolder.Visible     = true;
                        VideoSettings.Visible          = true;
                        ArticlePlaceHolder.Visible     = true;
                        VideoPlaceHolder.Visible       = true;
                    }
                }

                if (checkAll.Values.Sum() == 6)
                {
                    Import.Visible = true;
                    if (Page.IsPostBack == false)
                    {
                        ArticlePlaceHolder.Visible = true;


                        RadioButtonList1.SelectedValue = "articles";
                        MyGlobals.MyGlobalError        = "Should be show Articles";
                    }
                }
                else
                {
                    int sumnum = checkAll.Values.Sum();
                    MyGlobals.MyGlobalError = "Here is the problem" + sumnum;
                }

                //Check what the value of IncUpdatedFeedContentValue is in the db 1 is checked 0 is not checked
                Brafton.DotNetNuke.BraftonSchedule B1 = new Brafton.DotNetNuke.BraftonSchedule();
                int checkForUpdatedCheck = B1.getUpdatedContent();
                //int checkForUpdatedCheck = 1;
                if (Page.IsPostBack == false)
                {
                    if (checkForUpdatedCheck == 1)
                    {
                        InclUpdatedFeedContent.Checked      = true;
                        MyGlobals.IncludeUpdatedFeedContent = 1;
                        cmd.CommandText = "IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='Blog_Entries' AND column_name='LastUpdatedOn') BEGIN ALTER TABLE Blog_Entries ADD LastUpdatedOn DATETIME NULL END";
                        cmd.ExecuteNonQuery();
                        //checkedStatusLabel.Text = "The value in the db =" + checkForUpdatedCheck + " and the value in globals is " + MyGlobals.IncludeUpdatedFeedContent +"Means it should be checked";
                    }
                    else
                    {
                        InclUpdatedFeedContent.Checked      = false;
                        MyGlobals.IncludeUpdatedFeedContent = 0;
                        //checkedStatusLabel.Text = "The value in the db =" + checkForUpdatedCheck + " and the value in globals is " + MyGlobals.IncludeUpdatedFeedContent+" Means it should not be checked";
                    }
                }
                connection.Close();
                cmd.Dispose();
            }
            catch (Exception ex)
            {
                labelError.Text = "Generic exception: " + ex.ToString();
                connection.Close();
                cmd.Dispose();
            }
        }