Commit 7fc356d7 by mahaisong

fix:修正并发后数量统计,确保之后的数值和与文件中的记录条数相同。

parent 2d4dee73
...@@ -67,7 +67,6 @@ ...@@ -67,7 +67,6 @@
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<None Include="hive_export .csv" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput> <LastGenOutput>Settings.Designer.cs</LastGenOutput>
......
...@@ -81,7 +81,7 @@ namespace CsvCount_ES ...@@ -81,7 +81,7 @@ namespace CsvCount_ES
{ {
Stopwatch st = new Stopwatch(); Stopwatch st = new Stopwatch();
st.Start(); st.Start();
int Btotal = 0;
if (!String.IsNullOrWhiteSpace(textBox1.Text)) if (!String.IsNullOrWhiteSpace(textBox1.Text))
{ {
...@@ -278,7 +278,7 @@ namespace CsvCount_ES ...@@ -278,7 +278,7 @@ namespace CsvCount_ES
try try
{ {
string key = k[j].Split(',')[1].Replace("\0", string.Empty).Replace("\r", string.Empty).Trim(); string key = k[j].Split(',')[1].Replace("\0", string.Empty).Replace("\r", string.Empty).Trim();
totalCountDic.AddOrUpdate(key, 0, (skey, scount) => { return scount = scount + 1; }); totalCountDic.AddOrUpdate(key, 1, (skey, scount) => { return scount = scount + 1; });
} }
catch (Exception ext) catch (Exception ext)
...@@ -415,9 +415,9 @@ namespace CsvCount_ES ...@@ -415,9 +415,9 @@ namespace CsvCount_ES
try try
{ {
count = count + 1;//记录计算了多少次,与分块对应(其实就是与listModelDic的key-1对应即代表完整) count = count + 1;//记录计算了多少次,多少行
string key = line.Split(',')[1]; string key = line.Split(',')[1];
BtotalCountDic.AddOrUpdate(key, 0, (skey, scount) => { return scount = scount + 1; }); BtotalCountDic.AddOrUpdate(key, 1, (skey, scount) => { return scount = scount + 1; });
} }
catch (Exception ext) catch (Exception ext)
...@@ -429,13 +429,7 @@ namespace CsvCount_ES ...@@ -429,13 +429,7 @@ namespace CsvCount_ES
swtp.Stop(); swtp.Stop();
MessageBox.Show("完整性测试运行时间:" + swtp.ElapsedMilliseconds.ToString()); MessageBox.Show("完整性测试运行时间:" + swtp.ElapsedMilliseconds.ToString());
#endregion #endregion
//可能出现重复,这里的条数与日志文件的条数可能不同。
foreach (var item in BtotalCountDic)
{
Btotal = Btotal + item.Value;
}
//全比较 //全比较
var dz1 = BtotalCountDic.Except(totalCountDic); var dz1 = BtotalCountDic.Except(totalCountDic);
...@@ -480,17 +474,18 @@ namespace CsvCount_ES ...@@ -480,17 +474,18 @@ namespace CsvCount_ES
total = total+ item.Value; total = total+ item.Value;
} }
if (total == Btotal)
if (total == count)
{ {
MessageBox.Show("正确:点击数和为总条数"); MessageBox.Show("正确:点击数计算后之和" + total.ToString()+" ===文件记录总行数,"+ count.ToString());
} }
else else
{ {
MessageBox.Show("错误:点击数和不等于总条数"); MessageBox.Show("错误(不相等):点击数计算后之和" + total.ToString() + " !=!=!=文件记录总行数," + count.ToString());
} }
MessageBox.Show("结果行数:" + count.ToString());
total = 0;
errorCount = 0; errorCount = 0;
count = 0; count = 0;
......
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
...@@ -15,6 +15,3 @@ C:\Users\admin\Desktop\CsvCount_ES\CsvCount_ES\bin\Debug\CsvCount_ES.pdb ...@@ -15,6 +15,3 @@ C:\Users\admin\Desktop\CsvCount_ES\CsvCount_ES\bin\Debug\CsvCount_ES.pdb
C:\Users\admin\Desktop\CsvCount_ES\CsvCount_ES\obj\Debug\CsvCount_ES.Form1.resources C:\Users\admin\Desktop\CsvCount_ES\CsvCount_ES\obj\Debug\CsvCount_ES.Form1.resources
C:\Users\admin\Desktop\CsvCount_ES\CsvCount_ES\obj\Debug\CsvCount_ES.Properties.Resources.resources C:\Users\admin\Desktop\CsvCount_ES\CsvCount_ES\obj\Debug\CsvCount_ES.Properties.Resources.resources
C:\Users\admin\Desktop\CsvCount_ES\CsvCount_ES\obj\Debug\CsvCount_ES.csproj.GenerateResource.Cache C:\Users\admin\Desktop\CsvCount_ES\CsvCount_ES\obj\Debug\CsvCount_ES.csproj.GenerateResource.Cache
D:\smallproject\6.CsvCount_ES\CsvCount_ES\bin\Debug\CsvCount_ES.exe.config
D:\smallproject\6.CsvCount_ES\CsvCount_ES\obj\Debug\CsvCount_ES.exe
D:\smallproject\6.CsvCount_ES\CsvCount_ES\obj\Debug\CsvCount_ES.pdb
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment