コード例 #1
0
        public bool addArticle(string article, string title, int categoryDbKey)
        {
            string sqlstatement = null;
            string url          = title.ToLower();

            url = url.Replace(' ', '-');
            int          status     = 0;
            DataSet      objDataSet = new DataSet();
            MySqlCommand cmd        = new MySqlCommand();

            try
            {
                using (MySqlConnection con = new MySqlConnection(connectionString))
                {
                    con.Open();
                    sqlstatement    = @"insert into article (CategoryDbKey,ArticleType,Title,Url,MetaKeyWord,MetaDescription,CreatedBy, Status, CreatedOn, CreatedIP) 
                            values (" + categoryDbKey + ",'SNIPPET','" + title + "','" + url + "','" + title + "','" + title + "'," + UtilityOperations.getUserKey() + ",'INACTIVE',NOW(),'" + UtilityOperations.GetLocalIPAddress() + "')";// Check user login details
                    cmd.CommandText = sqlstatement;
                    cmd.Connection  = con;
                    status          = cmd.ExecuteNonQuery();
                }
                if (status > 0)
                {
                    using (MySqlConnection con = new MySqlConnection(connectionString))
                    {
                        string articleDbKey = getDbKey();
                        con.Open();
                        sqlstatement    = @"insert into article_details (ArticleDbKey,ArticleDetails,Status, CreatedBy, CreatedIP, CreatedOn) 
                            values (" + articleDbKey + ",'" + article + "','ACTIVE','" + UtilityOperations.getUserKey() + "','" + UtilityOperations.GetLocalIPAddress() + "',NOW())";// Check user login details
                        cmd.CommandText = sqlstatement;
                        cmd.Connection  = con;
                        status          = cmd.ExecuteNonQuery();
                    }
                    if (status > 0)
                    {
                        using (MySqlConnection con = new MySqlConnection(connectionString))
                        {
                            string articleDbKey = getDbKey();
                            con.Open();
                            sqlstatement = @"insert into article_subcategory (ArticleDbKey,SubcategoryDbKey,Status, CreatedBy, CreatedIP, CreatedOn) 
                            values (" + articleDbKey + ",'" + 40 + "','ACTIVE','" + UtilityOperations.getUserKey() + "','" + UtilityOperations.GetLocalIPAddress() + "',NOW())"; // Check user login details

                            sqlstatement = sqlstatement + ";" + @"insert into article_subcategory (ArticleDbKey,SubcategoryDbKey,Status, CreatedBy, CreatedIP, CreatedOn) 
                            values (" + articleDbKey + ",'" + 42 + "','ACTIVE','" + UtilityOperations.getUserKey() + "','" + UtilityOperations.GetLocalIPAddress() + "',NOW())"; // Check user login details

                            cmd.CommandText = sqlstatement;
                            cmd.Connection  = con;
                            status          = cmd.ExecuteNonQuery();
                        }
                        if (status > 0)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #2
0
 public AllMethodsClass()
 {
     connectionString = UtilityOperations.getConnectionString();
 }