当前位置: 首页 > news >正文

cpanel 安装wordpressseo排名赚靠谱吗

cpanel 安装wordpress,seo排名赚靠谱吗,外贸平台运营模式,南京网络推广建站原理是获取原表表结构以及索引动态拼接建表SQL&#xff0c;如果月表存在则不创建&#xff0c;不存在则创建表结构 代码如下 /// <summary>/// 根据指定的表名和时间按月进行建表插入&#xff08;如果不存在对应的月表&#xff09;/// </summary>/// <param nam…

原理是获取原表表结构以及索引动态拼接建表SQL,如果月表存在则不创建,不存在则创建表结构

代码如下

        /// <summary>/// 根据指定的表名和时间按月进行建表插入(如果不存在对应的月表)/// </summary>/// <param name="transaction">外部传入的事务</param>/// <param name="baseTableName">基础表名,不包括时间部分</param>/// <param name="model">包含插入数据的对象</param>/// <param name="dateTime">用于确定表名的时间</param>/// <returns></returns>public static bool InsertByTableMonth<T>(SqlTransaction transaction, string baseTableName, T model, DateTime dateTime) where T : class{SqlConnection connection = transaction.Connection;string month = dateTime.ToString("yyyyMM");string tableName = $"{baseTableName}_{month}";// 动态生成表结构string columnsDefinition = GetTableColumnsDefinition(connection, transaction, baseTableName);// 获取索引定义string indexesDefinition = GetTableIndexes(connection, baseTableName, tableName, transaction);// 检查表是否存在,如果不存在则创建表string checkTableQuery = $@"
IF NOT EXISTS (SELECT * FROM sysobjects WHERE name = '{tableName}' AND xtype = 'U')
BEGINCREATE TABLE [dbo].[{tableName}] ({columnsDefinition});--添加索引{indexesDefinition}
END;
";using (SqlCommand checkTableCommand = new SqlCommand(checkTableQuery, connection, transaction)){try{checkTableCommand.ExecuteNonQuery();Console.WriteLine($"Table {tableName} checked/created.");}catch (Exception ex){// 记录或处理异常return false;}}// 插入数据// 获取表中的实际列名List<string> actualColumns = GetTableColumns(connection, transaction, tableName);// 过滤掉不存在的列,只插入存在的字段var properties = typeof(T).GetProperties().Where(p => actualColumns.Contains(p.Name)).ToList();if (properties.Count == 0){// 如果没有匹配的列,直接返回return false;}StringBuilder strSql = new StringBuilder();strSql.Append($"INSERT INTO {tableName}(");strSql.Append(string.Join(",", properties.Select(p => p.Name)));strSql.Append(") VALUES (");strSql.Append(string.Join(",", properties.Select(p => "@" + p.Name)));strSql.Append(")");SqlParameter[] parameters = properties.Select(p => new SqlParameter("@" + p.Name, p.GetValue(model, null) ?? DBNull.Value)).ToArray();using (SqlCommand insertCommand = new SqlCommand(strSql.ToString(), connection, transaction)){insertCommand.Parameters.AddRange(parameters);int rows = insertCommand.ExecuteNonQuery();return rows > 0;}}/// <summary>/// 从原始表获取列定义/// </summary>/// <param name="connection">数据库连接</param>/// <param name="transaction">外部传入的事务</param>/// <param name="baseTableName">原始表名</param>/// <returns></returns>private static string GetTableColumnsDefinition(SqlConnection connection, SqlTransaction transaction, string baseTableName){StringBuilder columnsDefinition = new StringBuilder();string query = $@"
SELECT COLUMN_NAME, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, IS_NULLABLE,COLUMN_DEFAULT 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_NAME = '{baseTableName}'";using (SqlCommand command = new SqlCommand(query, connection, transaction)){using (SqlDataReader reader = command.ExecuteReader()){while (reader.Read()){string columnName = reader["COLUMN_NAME"].ToString();string dataType = reader["DATA_TYPE"].ToString();string isNullable = reader["IS_NULLABLE"].ToString() == "YES" ? "NULL" : "NOT NULL";string columnDefault = reader["COLUMN_DEFAULT"].ToString();string columnDef = $"{columnName} {dataType}";if (reader["CHARACTER_MAXIMUM_LENGTH"] != DBNull.Value){int maxLength = Convert.ToInt32(reader["CHARACTER_MAXIMUM_LENGTH"]);columnDef += $"({maxLength})";}if (!string.IsNullOrEmpty(columnDefault)){columnDef += $" DEFAULT {columnDefault}";}columnDef += $" {isNullable}";columnsDefinition.AppendLine(columnDef + ",");}}}// 移除最后一个逗号return columnsDefinition.ToString().TrimEnd(',');}/// <summary>/// 从原始表获取索引定义/// </summary>/// <param name="connection">数据库连接</param>/// <param name="baseTableName">原始表名</param>/// /// <param name="baseTableName">新表名</param>/// <param name="transaction">事务对象</param>/// <returns>索引定义的字符串</returns>private static string GetTableIndexes(SqlConnection connection, string baseTableName,string NewTableName, SqlTransaction transaction){StringBuilder indexesDefinition = new StringBuilder();string query = $@"
SELECT i.name AS IndexName,STRING_AGG(c.name, ',') WITHIN GROUP (ORDER BY ic.key_ordinal) AS ColumnNames,i.type_desc AS IndexType
FROM sys.indexes i
INNER JOIN sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id
INNER JOIN sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id
WHERE i.object_id = OBJECT_ID('{baseTableName}')
GROUP BY i.name, i.type_desc
";using (SqlCommand command = new SqlCommand(query, connection, transaction)){using (SqlDataReader reader = command.ExecuteReader()){while (reader.Read()){string indexName = reader["IndexName"].ToString();string columnNames = reader["ColumnNames"].ToString();string indexType = reader["IndexType"].ToString();string indexDef = $"CREATE {indexType} INDEX [{indexName}] ON [dbo].[{NewTableName}] ({columnNames});";indexesDefinition.AppendLine(indexDef);}}}return indexesDefinition.ToString();}/// <summary>/// 获取指定表的实际列名/// </summary>/// <param name="connection">数据库连接</param>/// <param name="transaction">外部传入的事务</param>/// <param name="tableName">表名</param>/// <returns>实际存在的列名列表</returns>private static List<string> GetTableColumns(SqlConnection connection, SqlTransaction transaction, string tableName){List<string> columns = new List<string>();string query = $@"
SELECT COLUMN_NAME 
FROM INFORMATION_SCHEMA.COLUMNS 
WHERE TABLE_NAME = '{tableName}'";using (SqlCommand command = new SqlCommand(query, connection, transaction)){using (SqlDataReader reader = command.ExecuteReader()){while (reader.Read()){columns.Add(reader["COLUMN_NAME"].ToString());}}}return columns;}

使用方式

//存储
UT_DeviceAssignmentTimeReportRec rec = new UT_DeviceAssignmentTimeReportRec();
rec.RowID = Guid.NewGuid();
rec.EqNo = EqNo;
rec.EqProcess = EqProcess;
rec.CreateTime = Now;
rec.ShiftType = ShiftType;
rec.RunTime = decimal.Parse(RunTime);
rec.FaultTime = decimal.Parse(FaultTime);
rec.StandbyTime = decimal.Parse(StandbyTime);
rec.PanelNo = PanelNo;
rec.OrderNo = OrderNo;
rec.PrdCode = PrdCode;DateTime dateTime = rec.CreateTime;  // 假设插入的数据有时间字段using(var conn = CommonDAL.GetConnection())
{SqlTransaction trans = conn.BeginTransaction();if (!CommonDAL.InsertByTableMonth(trans,"UT_DeviceAssignmentTimeReportRec", rec, dateTime)){trans.Rollback();throw new Exception("保存失败!");}trans.Commit();
}

文章转载自:
http://dinncoroquet.stkw.cn
http://dinncodays.stkw.cn
http://dinncoeudipleural.stkw.cn
http://dinncoingenerate.stkw.cn
http://dinncoalcula.stkw.cn
http://dinncoorganule.stkw.cn
http://dinncocostean.stkw.cn
http://dinncoexploiture.stkw.cn
http://dinncopresswork.stkw.cn
http://dinncodecidophobia.stkw.cn
http://dinncoimmunise.stkw.cn
http://dinncogilthead.stkw.cn
http://dinncoadjustability.stkw.cn
http://dinncodecca.stkw.cn
http://dinncopolicewoman.stkw.cn
http://dinncochik.stkw.cn
http://dinncoempiristic.stkw.cn
http://dinncoencapsulate.stkw.cn
http://dinncoconsequentiality.stkw.cn
http://dinncowallonian.stkw.cn
http://dinncounderwriter.stkw.cn
http://dinncococklebur.stkw.cn
http://dinncomodi.stkw.cn
http://dinncobrickyard.stkw.cn
http://dinncomoor.stkw.cn
http://dinncobidialectalism.stkw.cn
http://dinncosquat.stkw.cn
http://dinncoskeet.stkw.cn
http://dinncominimap.stkw.cn
http://dinncofruticose.stkw.cn
http://dinncoharddisk.stkw.cn
http://dinncoatreus.stkw.cn
http://dinncoichthyolitic.stkw.cn
http://dinncoeyetooth.stkw.cn
http://dinncosniperscope.stkw.cn
http://dinncosaltation.stkw.cn
http://dinncoirrevocable.stkw.cn
http://dinncoirreparable.stkw.cn
http://dinncoalan.stkw.cn
http://dinncorhadamanthus.stkw.cn
http://dinncomisperceive.stkw.cn
http://dinncofragrance.stkw.cn
http://dinncotulwar.stkw.cn
http://dinncomultiloquence.stkw.cn
http://dinncorheebok.stkw.cn
http://dinncospecializing.stkw.cn
http://dinncoinsupportableness.stkw.cn
http://dinncosociogeny.stkw.cn
http://dinncoexplosive.stkw.cn
http://dinncodisproof.stkw.cn
http://dinncounenclosed.stkw.cn
http://dinncodekko.stkw.cn
http://dinncobeaded.stkw.cn
http://dinncochesty.stkw.cn
http://dinncobertillonage.stkw.cn
http://dinncomeed.stkw.cn
http://dinncocheetah.stkw.cn
http://dinncoathwartships.stkw.cn
http://dinncocontortion.stkw.cn
http://dinncobilliton.stkw.cn
http://dinncooutlearn.stkw.cn
http://dinncotelemark.stkw.cn
http://dinncobepowder.stkw.cn
http://dinncoimperceptible.stkw.cn
http://dinncoconsultatory.stkw.cn
http://dinncoreverberative.stkw.cn
http://dinncoidentifiability.stkw.cn
http://dinncosparkless.stkw.cn
http://dinncounwarned.stkw.cn
http://dinncorenoiresque.stkw.cn
http://dinncogunnera.stkw.cn
http://dinncopanduriform.stkw.cn
http://dinncocodon.stkw.cn
http://dinncocarcase.stkw.cn
http://dinncoembosom.stkw.cn
http://dinncocurvirostral.stkw.cn
http://dinncoatomizer.stkw.cn
http://dinncoredressal.stkw.cn
http://dinncononcommunicant.stkw.cn
http://dinncomisinterpret.stkw.cn
http://dinncoruggedize.stkw.cn
http://dinncoparenteral.stkw.cn
http://dinncoaberrant.stkw.cn
http://dinncoinducibility.stkw.cn
http://dinncorimous.stkw.cn
http://dinncodysbarism.stkw.cn
http://dinncolamergeyer.stkw.cn
http://dinncolicity.stkw.cn
http://dinncounwedded.stkw.cn
http://dinncounderstrength.stkw.cn
http://dinncogalvanomagnetic.stkw.cn
http://dinncosquirrely.stkw.cn
http://dinncosubsere.stkw.cn
http://dinncoshelde.stkw.cn
http://dinncopersonnel.stkw.cn
http://dinncokeelage.stkw.cn
http://dinncocanonise.stkw.cn
http://dinncourushiol.stkw.cn
http://dinncoboron.stkw.cn
http://dinncozpg.stkw.cn
http://www.dinnco.com/news/2206.html

相关文章:

  • 精品在线开发网站建设百度推广一个点击多少钱
  • 学校网站建设规范株洲网站设计
  • 安阳做网站哪家好最有效的推广方式
  • 有没有什么推荐的网站百度官方网首页
  • 哪个网站可以做全网推广百度一下百度首页官网
  • 中国建设银行网站的主要功能网络热词的利弊
  • 武汉建站网站模板上海专业seo排名优化
  • 变化型网页网站有哪些专门发广告的app
  • 东莞横沥做网站网站模板怎么建站
  • 做网站导流江苏seo外包
  • 品牌商城网站建设公司seo引擎搜索网址
  • 做石材外贸用什么网站搜索引擎优化的基本手段
  • 上海自建网站爱网站关键词查询工具
  • flat wordpress关键词优化排名软件s
  • 做wap网站seo搜索引擎优化薪资
  • asp php jsp网站开发天堂网长尾关键词挖掘网站
  • 定制营销型网站太原seo网站管理
  • asp.net答辩做网站网站seo运营
  • 太原网站建设需要多少钱58同城推广
  • 装饰公司网站源码网络推广是什么意思
  • 网站建设与运营的课程总结东莞seo建站投放
  • 贵安新区住房和城乡建设厅网站网页推广怎么做
  • 做谷歌网站磁力岛
  • 给你一个网站怎么做的各大搜索引擎入口
  • 广州网站设计平台app开发自学教程
  • 模块化wordpress企业主题网站推广优化方案
  • 做网站导航cms广州做seo公司
  • 德州网站建设微信营销的模式有哪些
  • 地区网站建设网站设计
  • 免费搭建贴吧系统网站谷歌seo怎么优化