部署网站Window server 2016 IIS报错总结
500.19
在IIS——>模块里找不到AspNetCoreModuleV2——>
.net Core3.1.202安装失败,失败原因大概是安装文件破坏了。
去官网找到下载https://dotnet.microsoft.com/download
500.25
应用程序池——>高级设置——》标识选择ApplicationPoolIdentity
HTTP Error 500.30 - ANCM In-Process Start Failure
配置文件配置错误路径缺少了一个斜杆
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\YiSha.Admin.Web.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 06F9BBCA-932B-4AB1-940C-E604AC82FA0F-->
库存表库存单价刷新时,物料表中的移动单价也更新
update 更改时查询另外一个表
update [dbo].[spm_material] set moving_price=(select inventory_unit_price from [dbo].[spm_stockrecord] s where [spm_material].material_no=s.material_no )
批量插入和批量更新
public class SqlBulkCopyHelper
{
public static int ExecuteNonQuery(string connectionStr, string sql)
{
using (SqlConnection conn = new SqlConnection(connectionStr))
{
SqlCommand command = new SqlCommand(sql, conn);
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
int result = command.ExecuteNonQuery();
conn.Close();
return result;
}
}
public static void BulkInsert<T>(string connStr, List<T> modelList)
{
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connStr))
{
var type = typeof(T);
PropertyDescriptorCollection props = TypeDescriptor.GetProperties(type);
foreach (PropertyDescriptor prop in props)
{
bulkCopy.ColumnMappings.Add(prop.Name, prop.Name);
}
bulkCopy.DestinationTableName = type.Name;
var sw = System.Diagnostics.Stopwatch.StartNew();
bulkCopy.WriteToServer(ToDataTable<T>(modelList));
Console.WriteLine(string.Format("BulkCopy: {0}ms", sw.ElapsedMilliseconds));
}
}
public static int BulkUpdate<T>(string connStr, List<T> list, string crateTemplateSql, string updateSql)
{
int result = 0;
using (SqlConnection conn = new SqlConnection(connStr))
{
if (conn.State != ConnectionState.Open)
{
conn.Open();
}
using (SqlCommand command = new SqlCommand("", conn))
{
//Creating temp table on database
command.CommandText = string.Format("CREATE TABLE #TmpTable({0})", crateTemplateSql);
command.ExecuteNonQuery();
//Bulk insert into temp table
using (SqlBulkCopy bulkcopy = new SqlBulkCopy(conn))
{
bulkcopy.BulkCopyTimeout = 660;
bulkcopy.DestinationTableName = "#TmpTable";
bulkcopy.WriteToServer(ToDataTable(list));
bulkcopy.Close();
}
// Updating destination table, and dropping temp table
command.CommandTimeout = 300;
command.CommandText = updateSql;
//UPDATE[spm_material] SET moving_price = inventory_unit_price FROM[spm_material] INNER JOIN[spm_stockrecord] Temp ON[spm_material].material_no = temp.material_no;
//command.CommandText = "UPDATE T SET ... FROM " + TableName + " T INNER JOIN #TmpTable Temp ON ...; DROP TABLE #TmpTable;";
result = command.ExecuteNonQuery();
conn.Close();
}
}
return result;
}
static DataTable ToDataTable<T>(IList<T> data)
{
PropertyDescriptorCollection props =
TypeDescriptor.GetProperties(typeof(T));
DataTable table = new DataTable();
for (int i = 0; i < props.Count; i++)
{
PropertyDescriptor prop = props[i];
Type colType = prop.PropertyType;
if ((colType.IsGenericType) && (colType.GetGenericTypeDefinition() == typeof(Nullable<>)))
{
colType = colType.GetGenericArguments()[0];
}
table.Columns.Add(prop.Name, colType);
}
object[] values = new object[props.Count];
foreach (T item in data)
{
for (int i = 0; i < values.Length; i++)
{
values[i] = props[i].GetValue(item);
}
table.Rows.Add(values);
}
return table;
}
}
服务层代码编写
public TData SynchronizationStockrecord(string dbConnectionString, List<spm_stockrecord> listStockrecord, List<MaterialTemp> listMaterialTemp)
{
TData returnTemp = new TData();
//删除库存表
int delResult = YiSha.Data.EF.SqlBulkCopyHelper.ExecuteNonQuery(dbConnectionString, "delete [spm_stockrecord]");
//新增库存表
YiSha.Data.EF.SqlBulkCopyHelper.BulkInsert(dbConnectionString, listStockrecord);
//根据物料编号更新物料表的移动单价,原来是用异步的
string crateTemplateSql = @"material_no [varchar](200) NULL,
inventory_unit_price[varchar](200) NULL";
string updateSql = " UPDATE[spm_material] SET moving_price = inventory_unit_price FROM[spm_material] INNER JOIN #TmpTable Temp ON[spm_material].material_no = temp.material_no ";
int updateResult = YiSha.Data.EF.SqlBulkCopyHelper.BulkUpdate(dbConnectionString, listMaterialTemp, crateTemplateSql, updateSql);
returnTemp.Tag = 1;
return returnTemp;
}