在IIS中开启WebDAV
- 安装“WebDAV 发布”
- 启用 WebDAV 并添加创作规则
- 添加创作规则
- “身份验证”开启“Windows 身份验证”
- "授权"账户
Microsoft Visual C++ 2005 Redistributable Package (32位)
http://download.microsoft.com/download/8/B/4/8B42259F-5D70-43F4-AC2E-4B208FD8D66A/vcredist_x86.exeMicrosoft Visual C++ 2005 Redistributable Package (64位)
http://download.microsoft.com/download/8/B/4/8B42259F-5D70-43F4-AC2E-4B208FD8D66A/vcredist_x64.exeMicrosoft Visual C++ 2008 Redistributable Package (32位)
https://download.microsoft.com/download/9/7/7/977B481A-7BA6-4E30-AC40-ED51EB2028F2/vcredist_x86.exeMicrosoft Visual C++ 2008 Redistributable Package (64位)
https://download.microsoft.com/download/9/7/7/977B481A-7BA6-4E30-AC40-ED51EB2028F2/vcredist_x64.exeMicrosoft Visual C++ 2010 SP1 Redistributable Package (32位)
https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x86.exeMicrosoft Visual C++ 2010 SP1 Redistributable Package (64位)
https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x64.exeMicrosoft Visual C++ 2012 Redistributable (x64)
https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x64.exeMicrosoft Visual C++ 2012 Redistributable (x86)
https://download.microsoft.com/download/1/6/B/16B06F60-3B20-4FF2-B699-5E9B7962F9AE/VSU_4/vcredist_x86.exeVisual C++ Redistributable for Visual Studio 2012 Update 4 (32位)
https://download.microsoft.com/download/9/C/D/9CD480DC-0301-41B0-AAAB-FE9AC1F60237/VSU4/vcredist_x86.exeVisual C++ Redistributable for Visual Studio 2012 Update 4 (64位)
https://download.microsoft.com/download/9/C/D/9CD480DC-0301-41B0-AAAB-FE9AC1F60237/VSU4/vcredist_x64.exeVisual C++ Redistributable Packages for Visual Studio 2013 (32位)
https://download.microsoft.com/download/F/3/5/F3500770-8A08-488E-94B6-17A1E1DD526F/vcredist_x86.exeVisual C++ Redistributable Packages for Visual Studio 2013 (64位)
https://download.microsoft.com/download/F/3/5/F3500770-8A08-488E-94B6-17A1E1DD526F/vcredist_x64.exeVisual Studio 2015, 2017, 2019, and 2022 (32位)
https://aka.ms/vs/17/release/vc_redist.x86.exeVisual Studio 2015, 2017, 2019, and 2022 (64位)
https://aka.ms/vs/17/release/vc_redist.x64.exe 场景:
在一个工厂ERP管理系统中,有部分实体的界面需要显示相关联的其它信息,而这部分信息是弱连接的,需要调用WebAPI取回,传统的方式是一一取回,结果是用户感知的速度达不到要求。
使用BackgroundWorker,在后台取资料,取完资料后再显示,如果取资料的过程中,主实体已经变更了,或者已多次变更了,则等上次任务完成后,直接再取最后一次变更的资料,中间的直接丢弃,既加快了速度,也节省了资源。
实现思路:
先加入BackgroundWorker,(命名如:BackgroundWorker_ShowItem)。
再定义两个变量,用于保存要显示的主实体(或其关联键)
private T Item = null;
private T NextItem = null;当需要显示一个主体的内容时,不直接显示,而是呼叫BackgroundWorker来处理
public void ShowItem(T item)
{
if (BackgroundWorker_ShowItem.IsBusy)
{
this.NextItem = item;
}
else
{
this.Item = item;
this.BackgroundWorker_ShowItem.RunWorkerAsync();
}
}
private void BackgroundWorker_ShowItem_DoWork(object sender, DoWorkEventArgs e)
{
this.ShowItem();
}
private void BackgroundWorker_ShowItem_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (this.NextItem != null)
{
var nextItem = this.NextItem;
this.NextItem = null;
this.ShowItem(nextItem);
}
}注意,当ShowItem()中有访问前端时,会报“线程间操作无效”的例外,需要使用Invoke,但不要在DoWork中将ShowItem()全部包含,而应该在ShowItem()中单独处理。否则达不到性能优化的效果。
在C#中,implicit operator 和 explicit operator 都用于用户定义的类型转换,但它们在转换方式和安全性上有重要区别。
特点:
public class Celsius
{
public double Temperature { get; set; }
public Celsius(double temp)
{
Temperature = temp;
}
// 隐式转换:double → Celsius
public static implicit operator Celsius(double d)
{
return new Celsius(d);
}
// 隐式转换:Celsius → double
public static implicit operator double(Celsius c)
{
return c.Temperature;
}
}
// 使用示例
class Program
{
static void Main()
{
// 隐式转换 - 自动进行
Celsius c = 25.5; // double 自动转为 Celsius
double temp = c; // Celsius 自动转为 double
Console.WriteLine($"温度: {temp}°C"); // 输出: 温度: 25.5°C
// 在方法调用中也自动转换
DisplayTemperature(30.0); // double 自动转为 Celsius
}
static void DisplayTemperature(Celsius celsius)
{
Console.WriteLine($"显示温度: {celsius.Temperature}°C");
}
}特点:
public class Money
{
public decimal Amount { get; set; }
public string Currency { get; set; }
public Money(decimal amount, string currency)
{
Amount = amount;
Currency = currency;
}
// 显式转换:Money → decimal(可能丢失货币信息)
public static explicit operator decimal(Money money)
{
return money.Amount;
}
// 显式转换:decimal → Money(需要指定默认货币)
public static explicit operator Money(decimal amount)
{
return new Money(amount, "USD");
}
}
// 使用示例
class Program
{
static void Main()
{
Money salary = new Money(5000.00m, "USD");
// 显式转换 - 必须明确指定
decimal amount = (decimal)salary; // Money → decimal
Money money = (Money)2500.00m; // decimal → Money
Console.WriteLine($"金额: {amount}"); // 输出: 金额: 5000.00
Console.WriteLine($"货币: {money.Currency}, 金额: {money.Amount}");
// 如果不使用显式转换,编译器会报错
// decimal wrong = salary; // 错误: 无法隐式转换
}
}public class Distance
{
public double Meters { get; set; }
public Distance(double meters)
{
Meters = meters;
}
// 隐式转换:int → Distance(总是安全的)
public static implicit operator Distance(int meters)
{
return new Distance(meters);
}
// 显式转换:Distance → int(可能丢失精度)
public static explicit operator int(Distance d)
{
return (int)d.Meters;
}
// 隐式转换:double → Distance(总是安全的)
public static implicit operator Distance(double meters)
{
return new Distance(meters);
}
// 显式转换:Distance → double(安全,但为了对称性使用显式)
public static explicit operator double(Distance d)
{
return d.Meters;
}
public override string ToString()
{
return $"{Meters}米";
}
}
class Program
{
static void Main()
{
// 隐式转换示例
Distance d1 = 100; // int → Distance (隐式)
Distance d2 = 123.45; // double → Distance (隐式)
Console.WriteLine($"d1: {d1}"); // 输出: d1: 100米
Console.WriteLine($"d2: {d2}"); // 输出: d2: 123.45米
// 显式转换示例
int metersInt = (int)d2; // Distance → int (显式,丢失精度)
double metersDouble = (double)d2; // Distance → double (显式)
Console.WriteLine($"整数米数: {metersInt}"); // 输出: 整数米数: 123
Console.WriteLine($"精确米数: {metersDouble}"); // 输出: 精确米数: 123.45
// 在运算中的使用
Distance total = d1 + 50; // 隐式转换 50 → Distance
Console.WriteLine($"总距离: {total}"); // 输出: 总距离: 150米
}
}| 特性 | implicit operator | explicit operator |
|---|---|---|
| 转换方式 | 自动 | 必须显式指定 |
| 安全性 | 安全,不会丢失数据 | 可能不安全,可能丢失数据 |
| 使用场景 | 无损转换、小范围到大范围 | 有损转换、大范围到小范围 |
| 编译器行为 | 自动识别转换 | 需要强制类型转换语法 |
| 代码可读性 | 更简洁 | 更明确意图 |
使用 implicit operator 当:
使用 explicit operator 当:
这种机制让C#能够提供灵活的类型转换,同时保持类型安全性和代码清晰度。
原因在于每个扇区的物理字节数。
使用以下命令可以查看:
fsutil fsinfo sectorinfo c:LogicalBytesPerSector : 512
PhysicalBytesPerSectorForAtomicity : 32768
PhysicalBytesPerSectorForPerformance : 32768
FileSystemEffectivePhysicalBytesPerSectorForAtomicity : 4096
设备校准 : 已校准(0x000)
设备上的分区校准: 已校准(0x000)
无搜寻惩罚
支持剪裁
不支持 DAX
未精简预配这两个32768是导致sqlserver出错的原因。
解决方案就是执行以下命令:
reg add "HKLM\SYSTEM\CurrentControlSet\Services\stornvme\Parameters\Device" /v "ForcedPhysicalSectorSizeInBytes" /t reg_multi_sz /d "* 4095" /f重启之后再查看结果:
LogicalBytesPerSector : 512
PhysicalBytesPerSectorForAtomicity : 4096
PhysicalBytesPerSectorForPerformance : 4096
FileSystemEffectivePhysicalBytesPerSectorForAtomicity : 4096
设备校准 : 已校准(0x000)
设备上的分区校准: 已校准(0x000)
无搜寻惩罚
支持剪裁
不支持 DAX
未精简预配