|
|
|
|
|
using DbfDataReader;
|
|
|
|
|
|
using DevExpress.Spreadsheet;
|
|
|
|
|
|
//using DfdIO.Elements;
|
|
|
|
|
|
//using DQ.Construction.NewLook.CustomControls;
|
|
|
|
|
|
using MiniExcelLibs;
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
using NPOI.SS.UserModel;
|
|
|
|
|
|
using NPOI.XSSF.UserModel;
|
|
|
|
|
|
//using ParameterDQ.Construction.Util;
|
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
using System.Data.OleDb;
|
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.IO.MemoryMappedFiles;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
using WellWorkDataUI;
|
|
|
|
|
|
using WellWorkDataUI.CustomControls;
|
|
|
|
|
|
using WorkData;
|
|
|
|
|
|
using WorkData.Entity;
|
|
|
|
|
|
using WorkData.EntityBase;
|
|
|
|
|
|
//using static ParameterDQ.Construction.Util.ParameterDataWriter;
|
|
|
|
|
|
using IRow = NPOI.SS.UserModel.IRow;
|
|
|
|
|
|
using Path = System.IO.Path;
|
|
|
|
|
|
using TableInfo = WorkData.Entity.TableInfo;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DQ.Construction.NewLook.DataManager
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// ImportManager
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class ImportManager
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// /// 执行次数,用于井斜分批导入时验证
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private int times = 0;
|
|
|
|
|
|
/// The preview line count.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private const int PreviewLineCount = 200;
|
|
|
|
|
|
public string errorMessage = string.Empty;
|
|
|
|
|
|
private int totalDuplicate = 0;
|
|
|
|
|
|
private string currentFileName;
|
|
|
|
|
|
|
|
|
|
|
|
private IImportDataUI ui;
|
|
|
|
|
|
private IImportDataCfg cfg;
|
|
|
|
|
|
|
|
|
|
|
|
private int importNum = 0;
|
|
|
|
|
|
private string importTips = string.Empty;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="ImportManager"/> class.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="ui">window</param>
|
|
|
|
|
|
public ImportManager(IImportDataUI ui)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ui = ui;
|
|
|
|
|
|
if (ui is IImportDataCfg cfg)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.cfg = cfg;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#region 属性
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// IsDataImported
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsDataImported { get; private set; } = false;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// PreviewCache
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public PreviewCache PreviewCache { get; private set; } = new PreviewCache();
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// RecordCount
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int RecordCount { get; private set; } = 0;
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the start i d.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>An int.</returns>
|
|
|
|
|
|
private int GetStartID<T>()
|
|
|
|
|
|
{
|
|
|
|
|
|
return DBHelp.Db.Queryable<T>().Max<int>("id") + 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the start i d.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>An int.</returns>
|
|
|
|
|
|
private int GetStartXHID<T>(string key)
|
|
|
|
|
|
{
|
|
|
|
|
|
return DBHelp.Db.Queryable<T>().Where("jh=" + key).Max<int>("id") + 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 导入数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="cfg">cfg</param>
|
|
|
|
|
|
/// <returns>task</returns>
|
|
|
|
|
|
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:Prefix local calls with this", Justification = "blabla")]
|
|
|
|
|
|
public async Task ImportTable(IImportDataCfg cfg)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.cfg = cfg ?? this.cfg;
|
|
|
|
|
|
|
|
|
|
|
|
using (SplashHelper.Create())
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.tableName == DBHelp.GetTableName<WellBase>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSave(this.CheckInputData, (table, matches, i, start) => Save<WellBase>(table, matches, i, start, this.SaveDataWellBase, false));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellBase>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellDeflection>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(this.CheckWellDeflection, (table, matches, i, start) => Save<WellDeflection>(table, matches, i, start, this.SaveWellDeflection, false));
|
|
|
|
|
|
DataHelp.UpdateSearchWellName<WellDeflection>();
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellDeflection>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<InterpretDrillWellLayered>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(this.CheckInputDataWithWellName, (table, matches, i, start) => Save<InterpretDrillWellLayered>(table, matches, i, start, this.SaveDataDrillWellLayered));
|
|
|
|
|
|
KEPDataManager.NotifyChange<InterpretDrillWellLayered>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellCurve>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(this.CheckWellCurve, (table, matches, i, start) => Save<WellCurve>(table, matches, i, start, this.SaveDataCurve, false));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellCurve>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellTimeDepth>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(this.CheckWellCurveOrTimeDepth, (table, matches, i, start) => Save<WellTimeDepth>(table, matches, i, start, this.SaveDataCurveOrTimeDepth<WellTimeDepth>));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellCurve>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellPerforation>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(this.CheckInputDataWithWellName, (table, matches, i, start) => Save<WellPerforation>(table, matches, i, start, this.SaveDataWellPerforation));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellPerforation>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellBreakPoint>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(this.CheckInputDataWithWellName, (table, matches, i, start) => Save<WellBreakPoint>(table, matches, i, start, this.SaveDataWellBreakPoint));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellBreakPoint>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellCapacityOilMonth>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSave(this.CheckWellCapacity, (table, matches, i, start) => SaveWellCapacity<WellCapacityOilMonth>(table, matches, i));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellCapacityOilMonth>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellCapacityOilYear>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSave(this.CheckWellCapacity, (table, matches, i, start) => SaveWellCapacity<WellCapacityOilYear>(table, matches, i));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellCapacityOilYear>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellCapacityWaterMonth>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSave(this.CheckWellCapacity, (table, matches, i, start) => SaveWellCapacity<WellCapacityWaterMonth>(table, matches, i));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellCapacityWaterMonth>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellCapacityWaterYear>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSave(this.CheckWellCapacity, (table, matches, i, start) => SaveWellCapacity<WellCapacityWaterYear>(table, matches, i));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellCapacityWaterYear>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellCapacityOilDay>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSave(this.CheckWellCapacity, (table, matches, i, start) => SaveWellCapacity<WellCapacityOilDay>(table, matches, i));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellCapacityOilDay>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellCapacityWaterDay>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSave(this.CheckWellCapacity, (table, matches, i, start) => SaveWellCapacity<WellCapacityWaterDay>(table, matches, i));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellCapacityWaterDay>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellTestResult>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSave(this.CheckWellCapacity, (table, matches, i, start) => SaveWellCapacity<WellTestResult>(table, matches, i));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellTestResult>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellTestTotal>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSave(this.CheckWellCapacity, (table, matches, i, start) => SaveWellCapacity<WellTestTotal>(table, matches, i));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellTestTotal>();
|
|
|
|
|
|
}
|
|
|
|
|
|
//else if (this.tableName == DBHelp.GetTableName<InterpretFault>())
|
|
|
|
|
|
//{
|
|
|
|
|
|
// await this.CheckAndSave(this.CheckFault, async (table, matches, i, start) => await SaveInterpret<InterpretFault>(table, matches, i, this.SaveDataFault));
|
|
|
|
|
|
// KEPDataManager.NotifyChange<InterpretFault>();
|
|
|
|
|
|
//}
|
|
|
|
|
|
//else if (this.tableName == DBHelp.GetTableName<InterpretBoundary>())
|
|
|
|
|
|
//{
|
|
|
|
|
|
// await this.CheckAndSave(this.CheckBoundary, async (table, matches, i, start) => await SaveInterpret<InterpretBoundary>(table, matches, i, this.SaveDataBoundary));
|
|
|
|
|
|
// KEPDataManager.NotifyChange<InterpretBoundary>();
|
|
|
|
|
|
//}
|
|
|
|
|
|
//else if (this.tableName == DBHelp.GetTableName<ScatterBaseFault>())
|
|
|
|
|
|
//{
|
|
|
|
|
|
// if (!string.IsNullOrWhiteSpace(this.cfg.UpdateNode))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await this.CheckAndSave(this.CheckFault, async (table, matches, i, start) => await this.SaveDataScatterSingleFault(table, matches, i));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await this.CheckAndSave(this.CheckFault, async (table, matches, i, start) => await SaveInterpret<ScatterBaseFault>(table, matches, i, this.SaveDataScatterFault));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// KEPDataManager.NotifyChange<ScatterBaseFault>();
|
|
|
|
|
|
//}
|
|
|
|
|
|
//else if (this.tableName == DBHelp.GetTableName<ScatterBaseBoundary>())
|
|
|
|
|
|
//{
|
|
|
|
|
|
// if (!string.IsNullOrWhiteSpace(this.cfg.UpdateNode))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await this.CheckAndSave(this.CheckBoundary, async (table, matches, i, start) => await this.SaveDataScatterSingleBoundary(table, matches, i));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await this.CheckAndSave(this.CheckBoundary, async (table, matches, i, start) => await SaveInterpret<ScatterBaseBoundary>(table, matches, i, this.SaveDataScatterBoundary));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// KEPDataManager.NotifyChange<ScatterBaseBoundary>();
|
|
|
|
|
|
//}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WorkArea>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSave(this.CheckWorkArea, async (table, matches, i, start) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.SaveWorkArea(table, matches);
|
|
|
|
|
|
});
|
|
|
|
|
|
KEPDataManager.NotifyChange<WorkArea>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<LssxCjx>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(
|
|
|
|
|
|
this.CheckInputDataWithWellName,
|
|
|
|
|
|
(table, matches, i, start) => this.SaveWellEntity<LssxCjx>(table, matches, i));
|
|
|
|
|
|
KEPDataManager.NotifyChange<LssxCjx>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<LssxSt>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(
|
|
|
|
|
|
this.CheckInputDataWithWellName,
|
|
|
|
|
|
(table, matches, i, start) => this.SaveWellEntity<LssxSt>(table, matches, i));
|
|
|
|
|
|
KEPDataManager.NotifyChange<LssxSt>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<LssxYlsy>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(
|
|
|
|
|
|
this.CheckInputDataWithWellName,
|
|
|
|
|
|
(table, matches, i, start) => this.SaveWellEntity<LssxYlsy>(table, matches, i));
|
|
|
|
|
|
KEPDataManager.NotifyChange<LssxYlsy>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<LssxYxsy>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(
|
|
|
|
|
|
this.CheckInputDataWithWellName,
|
|
|
|
|
|
(table, matches, i, start) => this.SaveWellEntity<LssxYxsy>(table, matches, i));
|
|
|
|
|
|
KEPDataManager.NotifyChange<LssxYxsy>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<HoriWellFracturParameter>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSave(
|
|
|
|
|
|
this.CheckInputData,
|
|
|
|
|
|
(table, matches, i, start) => Save<HoriWellFracturParameter>(table, matches, i, start, this.SaveDataHoriWellFractParm));
|
|
|
|
|
|
KEPDataManager.NotifyChange<HoriWellFracturParameter>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<HoriWellFracturCoord>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSave(
|
|
|
|
|
|
this.CheckInputData,
|
|
|
|
|
|
(table, matches, i, start) => Save<HoriWellFracturCoord>(table, matches, i, start, this.SaveDataHoriWellFractCoord));
|
|
|
|
|
|
KEPDataManager.NotifyChange<HoriWellFracturCoord>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellCasingDamage>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(
|
|
|
|
|
|
this.CheckWellExist,
|
|
|
|
|
|
(table, matches, i, start) => this.SaveWellEntity<WellCasingDamage>(table, matches, i));
|
|
|
|
|
|
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellCasingDamage>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<Surveyline2d>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSave(
|
|
|
|
|
|
this.CheckInputData,
|
|
|
|
|
|
(table, matches, i, start) => Save<Surveyline2d>(table, matches, i, start, this.SaveSurveyline2d));
|
|
|
|
|
|
KEPDataManager.NotifyChange<Surveyline2d>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<Crossplot>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSave((tableList, cache) => true, this.SaveCrossplot);
|
|
|
|
|
|
KEPDataManager.NotifyChange<Crossplot>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellLithology>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(this.CheckInputDataWithWellName, (table, matches, i, start) => Save<WellLithology>(table, matches, i, start, this.SaveWellLithology));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellLithology>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<CycleLongterm>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(this.CheckInputDataWithWellName, (table, matches, i, start) => Save<CycleLongterm>(table, matches, i, start, this.SaveCycleLongterm));
|
|
|
|
|
|
KEPDataManager.NotifyChange<CycleLongterm>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<CycleMediumterm>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(this.CheckInputDataWithWellName, (table, matches, i, start) => Save<CycleMediumterm>(table, matches, i, start, this.SaveCycleMediumterm));
|
|
|
|
|
|
KEPDataManager.NotifyChange<CycleMediumterm>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<CycleShortterm>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(this.CheckInputDataWithWellName, (table, matches, i, start) => Save<CycleShortterm>(table, matches, i, start, this.SaveCycleShortterm));
|
|
|
|
|
|
KEPDataManager.NotifyChange<CycleShortterm>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellInnerLayer>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(this.CheckInputDataWithWellName, (table, matches, i, start) => Save<WellInnerLayer>(table, matches, i, start, this.SaveWellInnerLayer));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellInnerLayer>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellReservesLayer>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(this.CheckInputDataWithWellName, (table, matches, i, start) => Save<WellReservesLayer>(table, matches, i, start, this.SaveWellReservesLayer));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellReservesLayer>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellCoring>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(this.CheckInputDataWithWellName, (table, matches, i, start) => Save<WellCoring>(table, matches, i, start, this.SaveWellCoring));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellCoring>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellSideWallCoring>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(this.CheckInputDataWithWellName, (table, matches, i, start) => Save<WellSideWallCoring>(table, matches, i, start, this.SaveWellSideWallCoring));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellSideWallCoring>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellWaterInjection>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(this.CheckInputDataWithWellName, (table, matches, i, start) => Save<WellWaterInjection>(table, matches, i, start, this.SaveWellWaterInjection));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellWaterInjection>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellFluidProducingProfile>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(this.CheckInputDataWithWellName, (table, matches, i, start) => Save<WellFluidProducingProfile>(table, matches, i, start, this.SaveWellFluidProducingProfile));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellFluidProducingProfile>();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellLithologicalAnalysis>())
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync(this.CheckInputDataWithWellName, (table, matches, i, start) => Save<WellLithologicalAnalysis>(table, matches, i, start, this.SaveWellLithologicalAnalysis));
|
|
|
|
|
|
KEPDataManager.NotifyChange<WellLithologicalAnalysis>();
|
|
|
|
|
|
}
|
|
|
|
|
|
//else if (this.tableType.IsType<IReservoirData>())
|
|
|
|
|
|
//{
|
|
|
|
|
|
// await SaveReservoirData<CcsjBhd>();
|
|
|
|
|
|
// await SaveReservoirData<CcsjKxd>();
|
|
|
|
|
|
// await SaveReservoirData<CcsjStl>();
|
|
|
|
|
|
// await SaveReservoirData<CcsjSyhd>();
|
|
|
|
|
|
// await SaveReservoirData<CcsjYxhd>();
|
|
|
|
|
|
//}
|
|
|
|
|
|
//else if (this.tableType.IsType<InterpretTable>())
|
|
|
|
|
|
//{
|
|
|
|
|
|
// await SaveInterpretTable<InterpretTimeLayer>();
|
|
|
|
|
|
// await SaveInterpretTable<InterpretDepthLayer>();
|
|
|
|
|
|
// await SaveInterpretTable<InterpretVaildThickness>();
|
|
|
|
|
|
// await SaveInterpretTable<InterpretSandThickness>();
|
|
|
|
|
|
// await SaveInterpretTable<InterpretPorosity>();
|
|
|
|
|
|
// await SaveInterpretTable<InterpretPenetration>();
|
|
|
|
|
|
// await SaveInterpretTable<InterpretSaturation>();
|
|
|
|
|
|
// await SaveInterpretTable<InterpretAttribute>();
|
|
|
|
|
|
// await SaveInterpretTable<ScatterBase>();
|
|
|
|
|
|
//}
|
|
|
|
|
|
//else if (this.tableType == ReservoirHelp.Type)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// await this.CheckAndSaveAsync(
|
|
|
|
|
|
// this.CheckInputDataWithWellName,
|
|
|
|
|
|
// async (table, matches, i, start) =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await Save<CcsjBhd>(table, matches, i, start, this.SaveCcsj<CcsjBhd>);
|
|
|
|
|
|
// await Save<CcsjKxd>(table, matches, i, start, this.SaveCcsj<CcsjKxd>);
|
|
|
|
|
|
// await Save<CcsjStl>(table, matches, i, start, this.SaveCcsj<CcsjStl>);
|
|
|
|
|
|
// await Save<CcsjSyhd>(table, matches, i, start, this.SaveCcsj<CcsjSyhd>);
|
|
|
|
|
|
// await Save<CcsjYxhd>(table, matches, i, start, this.SaveCcsj<CcsjYxhd>);
|
|
|
|
|
|
// });
|
|
|
|
|
|
//}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.IsDataImported = true;
|
|
|
|
|
|
// 保存InterpretTableXYZ
|
|
|
|
|
|
//async Task SaveInterpretTable<T>()
|
|
|
|
|
|
// where T : InterpretTable, new()
|
|
|
|
|
|
//{
|
|
|
|
|
|
// if (this.tableType == typeof(T))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await this.CheckAndSave(
|
|
|
|
|
|
// this.CheckMultipleInputData,
|
|
|
|
|
|
// async (table, matches, i, start) => await SaveInterpret<T>(table, matches, i, this.SaveDataInterpretTable<T>));
|
|
|
|
|
|
|
|
|
|
|
|
// KEPDataManager.NotifyChange<T>();
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//// 保存储层数据
|
|
|
|
|
|
//async Task SaveReservoirData<T>()
|
|
|
|
|
|
// where T : class, IReservoirData, new()
|
|
|
|
|
|
//{
|
|
|
|
|
|
// if (this.tableType == typeof(T))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await this.CheckAndSaveAsync(this.CheckWellExist, (table, matches, i, start) => Save<T>(table, matches, i, start, this.SaveCcsj<T>));
|
|
|
|
|
|
// KEPDataManager.NotifyChange<T>();
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
// 保存通用数据
|
|
|
|
|
|
Task Save<T>(DataTable table, MatchCache matches, int index, int startID, Action<DataTable, MatchCache, int, int, bool> action, bool bPrompt = true)
|
|
|
|
|
|
where T : class, new()
|
|
|
|
|
|
{
|
|
|
|
|
|
return SaveGeneral<T>(table, matches, index, startID, action, ref bPrompt);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Task SaveGeneral<T>(DataTable table, MatchCache matches, int index, int startID, Action<DataTable, MatchCache, int, int, bool> action, ref bool bPrompt)
|
|
|
|
|
|
where T : class, new()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (bPrompt && !this.AlwaysAppend && !this.UpdateAppend && this.GetTableRecordCount<T>() > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (DevExpress.XtraSplashScreen.SplashScreenManager.Default != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
|
|
|
|
|
|
}
|
|
|
|
|
|
var result = new DlgAppend().ShowDialog();
|
|
|
|
|
|
if (result == DialogResult.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.cfg is FrmImportData xtraForm)
|
|
|
|
|
|
{
|
|
|
|
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(xtraForm, typeof(DlgWait), false, false, DevExpress.XtraSplashScreen.ParentFormState.Unlocked);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (typeof(T) == typeof(InterpretDrillWellLayered))
|
|
|
|
|
|
{
|
|
|
|
|
|
DBHelp.Db.Deleteable<T>().AS(DBHelp.GetTableOriginName<T>()).ExecuteCommand();
|
|
|
|
|
|
}
|
|
|
|
|
|
//else if (typeof(T).IsType<IReservoirData>())
|
|
|
|
|
|
//{
|
|
|
|
|
|
// DBHelp.Db.Deleteable<T>().AS(DBHelp.GetTableOriginName<T>()).ExecuteCommand();
|
|
|
|
|
|
//}
|
|
|
|
|
|
DBHelp.Db.Deleteable<T>().ExecuteCommand();
|
|
|
|
|
|
action(table, matches, index, startID, false);
|
|
|
|
|
|
bPrompt = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (result == DialogResult.Ignore)
|
|
|
|
|
|
{
|
|
|
|
|
|
//加一个判断,如果是压裂段参数,走追加逻辑
|
|
|
|
|
|
if (typeof(T) == typeof(HoriWellFracturParameter))
|
|
|
|
|
|
{
|
|
|
|
|
|
this.AddDataHoriWellFractParm(table, matches);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
action(table, matches, index, startID, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
bPrompt = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
action(table, matches, index, startID, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 保存地层数据
|
|
|
|
|
|
async Task SaveInterpret<T>(DataTable table, MatchCache matches, int index, Func<DataTable, MatchCache, int, Task> func)
|
|
|
|
|
|
where T : class, new()
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> list_del = this.cfg.Storage.DataTableList.Rows.OfType<DataRow>()
|
|
|
|
|
|
.Select(row => row["层位"].ToString()).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
int cnt = DBHelp.Db.Queryable<T>().In("CW", list_del).Count();
|
|
|
|
|
|
if (!this.AlwaysAppend && cnt > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (DevExpress.XtraSplashScreen.SplashScreenManager.Default != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
|
|
|
|
|
|
}
|
|
|
|
|
|
var result = new DlgAppend().ShowDialog();
|
|
|
|
|
|
if (result == DialogResult.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.cfg is FrmImportData xtraForm)
|
|
|
|
|
|
{
|
|
|
|
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(xtraForm, typeof(DlgWait), false, false, DevExpress.XtraSplashScreen.ParentFormState.Unlocked);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DBHelp.Db.Deleteable<T>().Where($"CW in ({string.Join(", ", list_del.Select(o => $"'{o}'"))})").ExecuteCommand();
|
|
|
|
|
|
await func(table, matches, index);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (result == DialogResult.Ignore)
|
|
|
|
|
|
{
|
|
|
|
|
|
await func(table, matches, index);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
await func(table, matches, index);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 保存产能数据
|
|
|
|
|
|
Task SaveWellCapacity<T>(DataTable table, MatchCache matches, int index)
|
|
|
|
|
|
where T : WellCapacity, new()
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> list_del = table.Rows.OfType<DataRow>()
|
|
|
|
|
|
.Select(row => row["井号"].ToString()).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
int cnt = DBHelp.Db.Queryable<T>().In("JH", list_del).Count();
|
|
|
|
|
|
if (!this.AlwaysAppend && cnt > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (DevExpress.XtraSplashScreen.SplashScreenManager.Default != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
|
|
|
|
|
|
}
|
|
|
|
|
|
var result = new DlgAppend().ShowDialog();
|
|
|
|
|
|
if (result == DialogResult.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.cfg is FrmImportData xtraForm)
|
|
|
|
|
|
{
|
|
|
|
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(xtraForm, typeof(DlgWait), false, false, DevExpress.XtraSplashScreen.ParentFormState.Unlocked);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DBHelp.Db.Deleteable<T>().Where($"JH in ({string.Join(", ", list_del.Select(o => $"'{o}'"))})").ExecuteCommand();
|
|
|
|
|
|
this.SaveWellCapacity<T>(table, matches, index);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (result == DialogResult.Ignore)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.SaveWellCapacity<T>(table, matches, index);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.SaveWellCapacity<T>(table, matches, index);
|
|
|
|
|
|
}
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Checks the and save2.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="check">The check.</param>
|
|
|
|
|
|
/// <param name="save">The save.</param>
|
|
|
|
|
|
/// <returns>A Task.</returns>
|
|
|
|
|
|
private async Task CheckAndSaveAsync(Func<List<DataTable>, MatchCache, Task<bool>> check, Func<DataTable, MatchCache, int, int, Task> save)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
List<MatchFromItem> matches = this.cfg.ListMatches;
|
|
|
|
|
|
this.ui.UpdateProgress("数据准备中");
|
|
|
|
|
|
if (matches.All(m => m.Connections.Count == 0) && this.cfg.UseMatch)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox("未配置数据列", "提示");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
MatchCache cache = new MatchCache(matches);
|
|
|
|
|
|
Type t = EntityHelp.GetEntityTypeByName(this.tableName);
|
|
|
|
|
|
if (typeof(InterpretTable).IsAssignableFrom(t) || this.tableName == DBHelp.GetTableName<WorkArea>()
|
|
|
|
|
|
|| this.tableName == DBHelp.GetTableName<WellTimeDepth>())
|
|
|
|
|
|
{
|
|
|
|
|
|
this.cfg.TotalImport = 0;
|
|
|
|
|
|
DataTable table = this.cfg.Storage.DataTableList;
|
|
|
|
|
|
this.ui.UpdateProgress(Constants.Splash.DataChecking);
|
|
|
|
|
|
if (!await check(new List<DataTable>() { table }, cache))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.ui.UpdateProgress(Constants.Splash.DataSaving);
|
|
|
|
|
|
await save(table, cache, 0, -1);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellCurve>())
|
|
|
|
|
|
{
|
|
|
|
|
|
this.cfg.TotalImport = 0;
|
|
|
|
|
|
this.importNum = 0;
|
|
|
|
|
|
List<DataTable> tableList = new List<DataTable>();
|
|
|
|
|
|
if (!this.cfg.ImportFromTable)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<Task> readTasks = new List<Task>();
|
|
|
|
|
|
for (int i = 0; i < this.listFileNames.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
string filepath = this.listFileNames[i];
|
|
|
|
|
|
readTasks.Add(Task.Run(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
DataTable tmpTable = new DataTable();
|
|
|
|
|
|
int rowindex = this.cfg.BeginIndex;
|
|
|
|
|
|
this.LoadDataTable(ref tmpTable, filepath, rowindex, false, false);
|
|
|
|
|
|
DataTable table = this.cfg.IsVertical ? tmpTable : this.Convert2HorizonTable(tmpTable);
|
|
|
|
|
|
table.TableName = Path.GetFileNameWithoutExtension(filepath);
|
|
|
|
|
|
tableList.Add(table);
|
|
|
|
|
|
}));
|
|
|
|
|
|
}
|
|
|
|
|
|
await Task.WhenAll(readTasks);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
tableList.Add(this.cfg.Storage.DataTableShow);
|
|
|
|
|
|
}
|
|
|
|
|
|
this.ui.UpdateProgress(Constants.Splash.DataChecking);
|
|
|
|
|
|
if (!await check(tableList, cache))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.ui.UpdateProgress(Constants.Splash.DataSaving);
|
|
|
|
|
|
List<Task> taskList = new List<Task>();
|
|
|
|
|
|
for (int i = 0; i < tableList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
taskList.Add(save(tableList[i], cache, i, -1));
|
|
|
|
|
|
}
|
|
|
|
|
|
await Task.WhenAll(taskList);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.tableName == DBHelp.GetTableName<WellDeflection>())
|
|
|
|
|
|
{
|
|
|
|
|
|
List<Task> taskList = new List<Task>();
|
|
|
|
|
|
this.cfg.TotalImport = 0;
|
|
|
|
|
|
this.times = 0;
|
|
|
|
|
|
List<DataTable> tableList = new List<DataTable>();
|
|
|
|
|
|
//Stopwatch sw = new Stopwatch();
|
|
|
|
|
|
if (!this.cfg.ImportFromTable)
|
|
|
|
|
|
{
|
|
|
|
|
|
//Console.WriteLine($"``````抽稀规则:{this.cfg.RarefyIndex}``````````");
|
|
|
|
|
|
//totalSw.Start();
|
|
|
|
|
|
int rowindex = this.cfg.BeginIndex;
|
|
|
|
|
|
this.ui.UpdateProgress(Constants.Splash.DataSaving);
|
|
|
|
|
|
ConcurrentBag<WellDeflection> datas = new ConcurrentBag<WellDeflection>();
|
|
|
|
|
|
this.cfg.FileCount = this.listFileNames.Count;
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
int maxId = DBHelp.NewDb.Queryable<WellDeflection>().Max<int>("ID");
|
|
|
|
|
|
Parallel.ForEach(this.listFileNames, EntityHelp.Options, file =>
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
//sw.Restart();
|
|
|
|
|
|
DataTable tmpTable = new DataTable();
|
|
|
|
|
|
maxId = maxId + 1;
|
|
|
|
|
|
// txt文档每个文档一个井号,存储为一个文件
|
|
|
|
|
|
if (file.ToLower().EndsWith(".txt") || file.ToLower().EndsWith(".dev"))
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadDataTable(ref tmpTable, file, rowindex, false, false);
|
|
|
|
|
|
DataTable table = this.cfg.IsVertical ? tmpTable : this.Convert2HorizonTable(tmpTable);
|
|
|
|
|
|
this.ui.UpdateProgress(string.Format(Constants.Splash.HandleProgress, index + 1, this.cfg.FileCount));
|
|
|
|
|
|
string fileName = Path.GetFileNameWithoutExtension(file);
|
|
|
|
|
|
table.TableName = fileName;
|
|
|
|
|
|
|
|
|
|
|
|
// 将文件信息存储至数据库
|
|
|
|
|
|
WellDeflection wdd = new WellDeflection
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = maxId,
|
|
|
|
|
|
JH = fileName,
|
|
|
|
|
|
XHID = maxId,
|
|
|
|
|
|
FileName = $"{fileName}.data",
|
|
|
|
|
|
};
|
|
|
|
|
|
datas.Add(wdd);
|
|
|
|
|
|
|
|
|
|
|
|
save(table, cache, index, 1).Wait();
|
|
|
|
|
|
}
|
|
|
|
|
|
// dbf文件需要在读取时就拆分,否则太大也会很慢
|
|
|
|
|
|
else if (file.ToLower().EndsWith(".dbf"))
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadDataTable(ref tmpTable, file, rowindex, false, false);
|
|
|
|
|
|
//DataTable table = this.cfg.IsVertical ? tmpTable : this.Convert2HorizonTable(tmpTable);
|
|
|
|
|
|
//this.ui.UpdateProgress(string.Format(Constants.Splash.HandleProgress, index + 1, this.cfg.FileCount));
|
|
|
|
|
|
//string fileName = Path.GetFileNameWithoutExtension(file);
|
|
|
|
|
|
//table.TableName = fileName;
|
|
|
|
|
|
|
|
|
|
|
|
//// 将文件信息存储至数据库
|
|
|
|
|
|
//WellDeflection wdd = new WellDeflection
|
|
|
|
|
|
//{
|
|
|
|
|
|
// JH = fileName,
|
|
|
|
|
|
// FileName = $"{fileName}.data",
|
|
|
|
|
|
//};
|
|
|
|
|
|
//datas.Add(wdd);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 其它文件类型的数据
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadDataTable(ref tmpTable, file, rowindex, false, false);
|
|
|
|
|
|
DataTable table = this.cfg.IsVertical ? tmpTable : this.Convert2HorizonTable(tmpTable);
|
|
|
|
|
|
// 分解table
|
|
|
|
|
|
if (cache.Keys.Contains("JH"))
|
|
|
|
|
|
{
|
|
|
|
|
|
var matchColumn = cache["JH"];
|
|
|
|
|
|
var tables = table.AsEnumerable().GroupBy(row => row.Field<string>(matchColumn.MatchColumn))
|
|
|
|
|
|
.ToDictionary(g => g.Key, g => g.CopyToDataTable());
|
|
|
|
|
|
|
|
|
|
|
|
List<Task> tasks = new List<Task>();
|
|
|
|
|
|
|
|
|
|
|
|
bool isFirstRow = true;
|
|
|
|
|
|
foreach (var kvp in tables)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (isFirstRow)
|
|
|
|
|
|
{
|
|
|
|
|
|
isFirstRow = false;
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string jh = kvp.Key;
|
|
|
|
|
|
DataTable tb = kvp.Value;
|
|
|
|
|
|
tb.TableName = jh;
|
|
|
|
|
|
|
|
|
|
|
|
// 将文件信息存储至数据库
|
|
|
|
|
|
WellDeflection wdd = new WellDeflection
|
|
|
|
|
|
{
|
|
|
|
|
|
JH = jh,
|
|
|
|
|
|
XHID = maxId,
|
|
|
|
|
|
ID = maxId,
|
|
|
|
|
|
FileName = $"{jh}.data",
|
|
|
|
|
|
};
|
|
|
|
|
|
datas.Add(wdd);
|
|
|
|
|
|
|
|
|
|
|
|
tasks.Add(save(tb, cache, index, 1));
|
|
|
|
|
|
|
|
|
|
|
|
maxId = maxId + 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (tasks != null && tasks.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Task.WhenAll(tasks).Wait();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//sw.Stop();
|
|
|
|
|
|
//Console.WriteLine($"保存第 [{index + 1}] 个文件耗时:{sw.Elapsed}");
|
|
|
|
|
|
index++;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.WriteLine($"处理文件 [{file}] 异常:{ex.Message}");
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
if (datas.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
List<WellDeflection> newDatas = datas.ToList();
|
|
|
|
|
|
DBHelp.NewDb.Storageable(newDatas).WhereColumns(w => w.JH).ExecuteCommand();
|
|
|
|
|
|
DBHelp.NewDb.Ado.ExecuteCommand("UPDATE well_deflection SET xhid = id WHERE xhid is null or xhid = 0");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
tableList.Add(this.cfg.Storage.DataTableShow);
|
|
|
|
|
|
|
|
|
|
|
|
this.ui.UpdateProgress(Constants.Splash.DataChecking);
|
|
|
|
|
|
|
|
|
|
|
|
// 统一获取起始ID
|
|
|
|
|
|
int startID = this.GetStartID<WellDeflection>();
|
|
|
|
|
|
if (!await check(tableList, cache))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.ui.UpdateProgress(Constants.Splash.DataSaving);
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < tableList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
taskList.Add(save(tableList[i], cache, i, startID));
|
|
|
|
|
|
startID += tableList[i].Rows.Count;
|
|
|
|
|
|
}
|
|
|
|
|
|
await Task.WhenAll(taskList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.cfg.TotalImport = 0;
|
|
|
|
|
|
List<DataTable> tableList = new List<DataTable>();
|
|
|
|
|
|
if (!this.cfg.ImportFromTable)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < this.listFileNames.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
string filepath = this.listFileNames[i];
|
|
|
|
|
|
int rowindex = this.cfg.BeginIndex;
|
|
|
|
|
|
DataTable tmpTable = new DataTable();
|
|
|
|
|
|
this.LoadDataTable(ref tmpTable, filepath, rowindex, false, false);
|
|
|
|
|
|
DataTable table = this.cfg.IsVertical ? tmpTable : this.Convert2HorizonTable(tmpTable);
|
|
|
|
|
|
table.TableName = Path.GetFileNameWithoutExtension(filepath);
|
|
|
|
|
|
tableList.Add(table);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
tableList.Add(this.cfg.Storage.DataTableShow);
|
|
|
|
|
|
}
|
|
|
|
|
|
this.ui.UpdateProgress(Constants.Splash.DataChecking);
|
|
|
|
|
|
|
|
|
|
|
|
List<Task> taskList = new List<Task>();
|
|
|
|
|
|
//统一获取起始ID
|
|
|
|
|
|
int startID = 1;
|
|
|
|
|
|
if (this.tableName == DBHelp.GetTableName<WellDeflection>())
|
|
|
|
|
|
{
|
|
|
|
|
|
startID = this.GetStartID<WellDeflection>();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!await check(tableList, cache))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.ui.UpdateProgress(Constants.Splash.DataSaving);
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < tableList.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
taskList.Add(save(tableList[i], cache, i, startID));
|
|
|
|
|
|
startID += tableList[i].Rows.Count;
|
|
|
|
|
|
}
|
|
|
|
|
|
await Task.WhenAll(taskList);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.cfg.TotalImport > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.tableName == DBHelp.GetTableName<WellCurve>())
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox(string.Format("导入'测井曲线' {0} 口井!" + this.importTips, this.importNum), "提示");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox(string.Format("导入'{0}' {1} 条数据!", DBHelp.GetTableDescription(this.cfg.TableType), this.cfg.TotalImport), "提示");
|
|
|
|
|
|
}
|
|
|
|
|
|
this.ui.OnSaveFinish(this.cfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox($"{DBHelp.GetTableDescription(this.cfg.TableType)},未导入数据!", "提示");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox(ex.Message, "导入失败");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 检测并保存
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="check">检测函数</param>
|
|
|
|
|
|
/// <param name="save">保存函数</param>
|
|
|
|
|
|
private async Task CheckAndSave(Func<List<DataTable>, MatchCache, bool> check, Func<DataTable, MatchCache, int, int, Task> save)
|
|
|
|
|
|
{
|
|
|
|
|
|
await this.CheckAndSaveAsync((list, cache) => Task.FromResult(check(list, cache)), save);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 读取数据
|
|
|
|
|
|
|
|
|
|
|
|
private void LoadWellDeflectionDbfPreviewData(ref DataTable table, string filepath, int rowindex)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Columns.Clear();
|
|
|
|
|
|
table.Clear();
|
|
|
|
|
|
string dbfFilePath = filepath;
|
|
|
|
|
|
|
|
|
|
|
|
using (var dbfTable = new DbfTable(filepath, Encoding.GetEncoding("GB2312")))
|
|
|
|
|
|
{
|
|
|
|
|
|
var fields = dbfTable.Columns;
|
|
|
|
|
|
for (int i = 0; i < fields.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 忽略_NullFlags列
|
|
|
|
|
|
if ((int)fields[i].ColumnType == 0x30)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
table.Columns.Add(fields[i].ColumnName);
|
|
|
|
|
|
}
|
|
|
|
|
|
int beginRow = rowindex + (this.cfg.UseHeaderRow ? 1 : 0);
|
|
|
|
|
|
int index_temp = 0;
|
|
|
|
|
|
|
|
|
|
|
|
var dbfRecord = new DbfDataReader.DbfRecord(dbfTable);
|
|
|
|
|
|
|
|
|
|
|
|
while (dbfTable.Read(dbfRecord))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index_temp >= beginRow)
|
|
|
|
|
|
{
|
|
|
|
|
|
DataRow dr = table.NewRow();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < dbfRecord.Values.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 忽略_NullFlags列
|
|
|
|
|
|
if ((int)fields[i].ColumnType == 0x30)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
dr[i] = dbfRecord.Values[i].GetValue();
|
|
|
|
|
|
}
|
|
|
|
|
|
table.Rows.Add(dr);
|
|
|
|
|
|
}
|
|
|
|
|
|
index_temp++;
|
|
|
|
|
|
// 预览时只取前100条数据
|
|
|
|
|
|
if (table.Rows.Count == 100)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.RecordCount = index_temp;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = ex.Message;
|
|
|
|
|
|
Console.WriteLine(ex.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void LoadWellDeflectionDataTableDbf(ref DataTable table, string filepath, int rowindex)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Columns.Clear();
|
|
|
|
|
|
table.Clear();
|
|
|
|
|
|
string dbfFilePath = filepath;
|
|
|
|
|
|
//Stopwatch sw = new Stopwatch();
|
|
|
|
|
|
|
|
|
|
|
|
// 存储井斜导入结果
|
|
|
|
|
|
List<WellDeflection> datas = new List<WellDeflection>();
|
|
|
|
|
|
|
|
|
|
|
|
int wellCount = DBHelp.NewDb.Queryable<WellBase>().Count();
|
|
|
|
|
|
int maxId = DBHelp.NewDb.Queryable<WellDeflection>().Max<int>("ID");
|
|
|
|
|
|
int currentWellIndex = 0;
|
|
|
|
|
|
//Console.WriteLine($"井总数:{wellCount}");
|
|
|
|
|
|
if (wellCount > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.cfg.FileCount = wellCount;
|
|
|
|
|
|
this.RecordCount = wellCount;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string currentJH = string.Empty;
|
|
|
|
|
|
string jhKey = string.Empty;
|
|
|
|
|
|
int jhIndex = -1;
|
|
|
|
|
|
var matches = this.cfg.ListMatches;
|
|
|
|
|
|
bool isSameWell = true;
|
|
|
|
|
|
|
|
|
|
|
|
MatchCache cache = new MatchCache(matches);
|
|
|
|
|
|
if (cache.ContainsKey("JH"))
|
|
|
|
|
|
{
|
|
|
|
|
|
var jhItem = cache["JH"];
|
|
|
|
|
|
jhKey = jhItem.MatchColumn;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 没有井号,不能匹配数据
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(jhKey))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using (var dbfTable = new DbfTable(filepath, Encoding.GetEncoding("GB2312")))
|
|
|
|
|
|
{
|
|
|
|
|
|
var fields = dbfTable.Columns;
|
|
|
|
|
|
for (int i = 0; i < fields.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 忽略_NullFlags列
|
|
|
|
|
|
if ((int)fields[i].ColumnType == 0x30)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
table.Columns.Add(fields[i].ColumnName);
|
|
|
|
|
|
if (fields[i].ColumnName == jhKey)
|
|
|
|
|
|
{
|
|
|
|
|
|
jhIndex = i;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
int beginRow = rowindex + (this.cfg.UseHeaderRow ? 1 : 0);
|
|
|
|
|
|
int index_temp = 0;
|
|
|
|
|
|
|
|
|
|
|
|
var dbfRecord = new DbfDataReader.DbfRecord(dbfTable);
|
|
|
|
|
|
|
|
|
|
|
|
while (dbfTable.Read(dbfRecord))
|
|
|
|
|
|
{
|
|
|
|
|
|
//sw.Restart();
|
|
|
|
|
|
if (index_temp >= beginRow)
|
|
|
|
|
|
{
|
|
|
|
|
|
DataRow dr = table.NewRow();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < dbfRecord.Values.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 忽略_NullFlags列
|
|
|
|
|
|
if ((int)fields[i].ColumnType == 0x30)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
dr[i] = dbfRecord.Values[i].GetValue();
|
|
|
|
|
|
if (jhIndex == i)
|
|
|
|
|
|
{
|
|
|
|
|
|
var jhTemp = dr[i].ToString();
|
|
|
|
|
|
// 没有数据,则记录当前井号
|
|
|
|
|
|
if (table.Rows.Count == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.TableName = jhTemp;
|
|
|
|
|
|
currentJH = jhTemp;
|
|
|
|
|
|
isSameWell = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
// 不是同一口井的数据,则生成当前井的文件数据
|
|
|
|
|
|
if (jhTemp != currentJH)
|
|
|
|
|
|
{
|
|
|
|
|
|
//Console.WriteLine($"不是同一井号的数据:原井号-{currentJH}\t 新井号-{jhTemp}");
|
|
|
|
|
|
isSameWell = false;
|
|
|
|
|
|
currentJH = jhTemp;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 导入的数据是井斜
|
|
|
|
|
|
// 同一口井的数据就添加进表里面
|
|
|
|
|
|
if (isSameWell)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 如果配置了抽稀规则,则按抽稀规则取数据
|
|
|
|
|
|
if (this.cfg.RarefyIndex >= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index_temp == beginRow || (index_temp % (this.cfg.RarefyIndex + 2) == 0))
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Rows.Add(dr);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 没有配置抽稀规则,则直接取数据
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Rows.Add(dr);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 当前井的数据已经取完
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
currentWellIndex++;
|
|
|
|
|
|
// 先把数据保存,之后清空,再重新装入数据
|
|
|
|
|
|
string fileName = table.TableName;
|
|
|
|
|
|
DataTable saveTable = this.cfg.IsVertical ? table : this.Convert2HorizonTable(table);
|
|
|
|
|
|
if (wellCount > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ui.UpdateProgress(string.Format(Constants.Splash.HandleProgress, currentWellIndex, this.cfg.FileCount));
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ui.UpdateProgress($"当前导入第 {currentWellIndex} 口井的数据,井号为 【{fileName}】!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.SaveWellDeflection(saveTable, cache, 0, 0, false);
|
|
|
|
|
|
|
|
|
|
|
|
// 将文件信息存储至数据库
|
|
|
|
|
|
WellDeflection wdd = new WellDeflection
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = maxId + currentWellIndex,
|
|
|
|
|
|
JH = fileName,
|
|
|
|
|
|
XHID = maxId + currentWellIndex,
|
|
|
|
|
|
FileName = $"{fileName}.data",
|
|
|
|
|
|
};
|
|
|
|
|
|
datas.Add(wdd);
|
|
|
|
|
|
|
|
|
|
|
|
isSameWell = true;
|
|
|
|
|
|
table.Rows.Clear();
|
|
|
|
|
|
table.TableName = currentJH;
|
|
|
|
|
|
//currentJH = string.Empty;
|
|
|
|
|
|
//sw.Stop();
|
|
|
|
|
|
|
|
|
|
|
|
if (dr != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Rows.Add(dr);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Console.WriteLine($"导入第 {currentWellIndex} 口井,井号为【{fileName}】的井斜数据,耗时:{sw.Elapsed}");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
index_temp++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 最后一个表格数据
|
|
|
|
|
|
if (table != null && table.Rows.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
currentWellIndex++;
|
|
|
|
|
|
// 先把数据保存,之后清空,再重新装入数据
|
|
|
|
|
|
string fileName = table.TableName;
|
|
|
|
|
|
DataTable saveTable = this.cfg.IsVertical ? table : this.Convert2HorizonTable(table);
|
|
|
|
|
|
if (wellCount > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ui.UpdateProgress(string.Format(Constants.Splash.HandleProgress, currentWellIndex, this.cfg.FileCount));
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ui.UpdateProgress($"当前导入第 {currentWellIndex} 口井的数据,井号为 【{fileName}】!");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.SaveWellDeflection(saveTable, cache, 0, 0, false);
|
|
|
|
|
|
|
|
|
|
|
|
// 将文件信息存储至数据库
|
|
|
|
|
|
WellDeflection wdd = new WellDeflection
|
|
|
|
|
|
{
|
|
|
|
|
|
JH = fileName,
|
|
|
|
|
|
XHID = currentWellIndex,
|
|
|
|
|
|
FileName = $"{fileName}.data",
|
|
|
|
|
|
};
|
|
|
|
|
|
datas.Add(wdd);
|
|
|
|
|
|
|
|
|
|
|
|
//Console.WriteLine($"导入第 {currentWellIndex} 口井,井号为【{fileName}】的井斜数据,耗时:{sw.Elapsed}");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (datas.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
DBHelp.NewDb.Storageable(datas).WhereColumns(w => w.JH).ExecuteCommand();
|
|
|
|
|
|
DBHelp.NewDb.Ado.ExecuteCommand("UPDATE well_deflection SET xhid = id WHERE xhid is null or xhid = 0");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = ex.Message;
|
|
|
|
|
|
Console.WriteLine(ex.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// LoadDataTable
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">table</param>
|
|
|
|
|
|
/// <param name="filepath">filepath</param>
|
|
|
|
|
|
/// <param name="rowindex">rowindex</param>
|
|
|
|
|
|
/// <param name="reloadTableName">reloadTableName</param>
|
|
|
|
|
|
/// <param name="previewOnly">previewOnly</param>
|
|
|
|
|
|
public void LoadDataTable(ref DataTable table, string filepath, int rowindex, bool reloadTableName, bool previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
string filename = filepath.Substring(filepath.LastIndexOf("\\") + 1);
|
|
|
|
|
|
if (filename.LastIndexOf(".") == -1)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadDataTableTxt(ref table, filepath, this.GetFileEncoding(filepath), rowindex, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
string filetype = Path.GetExtension(filename).Replace(".", string.Empty).ToUpper();
|
|
|
|
|
|
if (filetype == "DBF")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.tableType == typeof(WellDeflection))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadWellDeflectionDbfPreviewData(ref table, filepath, rowindex);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadWellDeflectionDataTableDbf(ref table, filepath, rowindex);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadDataTableDbf(ref table, filepath, rowindex, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
// this.LoadDataTableDbf(ref table, filepath, rowindex, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (filetype == "DEV")
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadDataTableDev(ref table, filepath, this.GetFileEncoding(filepath), rowindex, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (filetype == "LAS")
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadDataTableLasNew(ref table, filepath, this.GetFileEncoding(filepath), rowindex, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (filetype == "DAT")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.tableName == DBHelp.GetTableName<WellCurve>())
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadDataTableDatByCurve(ref table, filepath, this.GetFileEncoding(filepath), rowindex, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadDataTableDat(ref table, filepath, this.GetFileEncoding(filepath), rowindex, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (filetype == "TXT" || filetype == "CSV" || filetype == "XYZ")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.tableName == DBHelp.GetTableName<WellCurve>())
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadDataTableTxtByCurve(ref table, filepath, this.GetFileEncoding(filepath), rowindex, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadDataTableTxt(ref table, filepath, this.GetFileEncoding(filepath), rowindex, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (filetype == "DFD")
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadDataTableDfd(ref table, filepath, rowindex, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (filetype == "XLS" || filetype == "XLSX" || filetype == "MDB")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (reloadTableName)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadOfficeTableName(filepath, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ReadOfficeData(ref table, filepath, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.RecordCount = table.Rows.Count;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 按表名读取数据.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">table</param>
|
|
|
|
|
|
/// <param name="previewOnly">previewOnly</param>
|
|
|
|
|
|
public void ReadDataByTableName(ref DataTable table, bool previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.dbType == "excel" || this.dbType == "access")
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ReadOfficeData(ref table, this.currentFileName, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.dbType == "oracle" || this.dbType == "sqlserver")
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ReadDataBasePreview(ref table, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Reads the office data.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="filepath">The filepath.</param>
|
|
|
|
|
|
/// <param name="previewOnly">If true, preview only.</param>
|
|
|
|
|
|
private void ReadOfficeData(ref DataTable table, string filepath, bool previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
using (SplashHelper.Create())
|
|
|
|
|
|
{
|
|
|
|
|
|
int rowindex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
string tableName = this.cfg.DbTableName;
|
|
|
|
|
|
|
|
|
|
|
|
if (this.dbType == "excel")
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadDataTableXls(ref table, filepath, tableName, rowindex, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.dbType == "access")
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadDataTableAccess(ref table, filepath, tableName, rowindex, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 加载excel的sheet
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="path">路径</param>
|
|
|
|
|
|
/// <param name="previewOnly">是否预览</param>
|
|
|
|
|
|
private void LoadOfficeTableName(string path, bool previewOnly = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.currentFileName = path;
|
|
|
|
|
|
|
|
|
|
|
|
if (this.dbType == "excel")
|
|
|
|
|
|
{
|
|
|
|
|
|
string ext = Path.GetExtension(path);
|
|
|
|
|
|
var lstSheetName = new List<string>();
|
|
|
|
|
|
int activeSheetIndex = 0;
|
|
|
|
|
|
if (ext.ToLower().Equals(".xls"))
|
|
|
|
|
|
{
|
|
|
|
|
|
using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
|
|
|
|
|
|
{
|
|
|
|
|
|
NPOI.SS.UserModel.IWorkbook workbook = WorkbookFactory.Create(stream, true);
|
|
|
|
|
|
int sheetIndex = 0;
|
|
|
|
|
|
for (int i = 0; i < workbook.NumberOfSheets; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
string sheetName = workbook.GetSheetName(i);
|
|
|
|
|
|
lstSheetName.Add(sheetName);
|
|
|
|
|
|
if (this.cfg.DbTableName == sheetName)
|
|
|
|
|
|
{
|
|
|
|
|
|
activeSheetIndex = sheetIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
sheetIndex++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
lstSheetName = MiniExcel.GetSheetNames(path);
|
|
|
|
|
|
for (int i = 0; i < lstSheetName.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.cfg.DbTableName == lstSheetName[i])
|
|
|
|
|
|
{
|
|
|
|
|
|
activeSheetIndex = i;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.ui.OnLoadOfficeTablesFinish(lstSheetName, activeSheetIndex);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.dbType == "access")
|
|
|
|
|
|
{
|
|
|
|
|
|
OleDbConnection conn = null;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
conn = new OleDbConnection(new ConnStringData { FilePath = path }.Access);
|
|
|
|
|
|
conn.Open();
|
|
|
|
|
|
DataTable dt_sheet = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
|
|
|
|
|
|
if (dt_sheet == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var list = new List<string>();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < dt_sheet.Rows.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
string tabletype = dt_sheet.Rows[i]["TABLE_TYPE"].ToString();
|
|
|
|
|
|
string tableName = dt_sheet.Rows[i]["TABLE_NAME"].ToString();
|
|
|
|
|
|
if (tabletype.ToUpper() == "TABLE")
|
|
|
|
|
|
{
|
|
|
|
|
|
list.Add(tableName);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
conn.Close();
|
|
|
|
|
|
this.ui.OnLoadOfficeTablesFinish(list, 0);
|
|
|
|
|
|
// conn.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox("无法打开此文件", "提示");
|
|
|
|
|
|
conn.Close();
|
|
|
|
|
|
this.errorMessage = e.Message;
|
|
|
|
|
|
Console.WriteLine(e.ToString());
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Loads the data table dbf.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="filepath">The filepath.</param>
|
|
|
|
|
|
/// <param name="rowindex">The rowindex.</param>
|
|
|
|
|
|
/// <param name="previewOnly">If true, preview only.</param>
|
|
|
|
|
|
private void LoadDataTableDbf(ref DataTable table, string filepath, int rowindex, bool previewOnly = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Columns.Clear();
|
|
|
|
|
|
table.Clear();
|
|
|
|
|
|
string dbfFilePath = filepath;
|
|
|
|
|
|
|
|
|
|
|
|
//using (var stream = File.Open(dbfFilePath, FileMode.Open, FileAccess.Read))
|
|
|
|
|
|
//using (var reader = new DotNetDBF.DBFReader(stream))
|
|
|
|
|
|
//{
|
|
|
|
|
|
// this.RecordCount = reader.RecordCount;
|
|
|
|
|
|
// var fields = reader.Fields;
|
|
|
|
|
|
|
|
|
|
|
|
// for (int i = 0; i < fields.Length; i++)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// // 忽略_NullFlags列
|
|
|
|
|
|
// if ((int)fields[i].DataType == 0x30)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// continue;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// table.Columns.Add(fields[i].Name);
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// int beginRow = rowindex + (this.cfg.UseHeaderRow ? 1 : 0);
|
|
|
|
|
|
// int index_temp = 0;
|
|
|
|
|
|
// var dbfRecord = reader.NextRecord();
|
|
|
|
|
|
// while (dbfRecord != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// if (index_temp >= beginRow)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// DataRow dr = table.NewRow();
|
|
|
|
|
|
// for (int i = 0; i < dbfRecord.Length; i++)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// // 忽略_NullFlags列
|
|
|
|
|
|
// if ((int)fields[i].DataType == 0x30)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// continue;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// dr[i] = dbfRecord.GetValue(i);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// table.Rows.Add(dr);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// dbfRecord = reader.NextRecord();
|
|
|
|
|
|
// index_temp++;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
using (var dbfTable = new DbfTable(filepath, Encoding.GetEncoding("GB2312")))
|
|
|
|
|
|
{
|
|
|
|
|
|
var fields = dbfTable.Columns;
|
|
|
|
|
|
for (int i = 0; i < fields.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 忽略_NullFlags列
|
|
|
|
|
|
if ((int)fields[i].ColumnType == 0x30)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
table.Columns.Add(fields[i].ColumnName);
|
|
|
|
|
|
}
|
|
|
|
|
|
int beginRow = rowindex + (this.cfg.UseHeaderRow ? 1 : 0);
|
|
|
|
|
|
int index_temp = 0;
|
|
|
|
|
|
|
|
|
|
|
|
var dbfRecord = new DbfRecord(dbfTable);
|
|
|
|
|
|
while (dbfTable.Read(dbfRecord))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index_temp >= beginRow)
|
|
|
|
|
|
{
|
|
|
|
|
|
DataRow dr = table.NewRow();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < dbfRecord.Values.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 忽略_NullFlags列
|
|
|
|
|
|
if ((int)fields[i].ColumnType == 0x30)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
dr[i] = dbfRecord.Values[i].GetValue();
|
|
|
|
|
|
}
|
|
|
|
|
|
table.Rows.Add(dr);
|
|
|
|
|
|
}
|
|
|
|
|
|
index_temp++;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.RecordCount = index_temp;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = ex.Message;
|
|
|
|
|
|
Console.WriteLine(ex.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void LoadDataTableDfd(ref DataTable table, string filename, int rowindex, bool previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
FileStream fs = File.OpenRead(filename);
|
|
|
|
|
|
StreamReader reader = new StreamReader(fs);
|
|
|
|
|
|
|
|
|
|
|
|
List<List<string>> list = new List<List<string>>();
|
|
|
|
|
|
string str = reader.ReadLine();
|
|
|
|
|
|
|
|
|
|
|
|
while (str != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> list_row = new List<string>();
|
|
|
|
|
|
|
|
|
|
|
|
string[] array = str.Split(Constants.StringSplit.Separator, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
for (int i = 0; i < array.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
list_row.Add(array[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
list.Add(list_row);
|
|
|
|
|
|
str = reader.ReadLine();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.RecordCount = list.Count;
|
|
|
|
|
|
|
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < list[0].Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
string colname = "列" + (i + 1);
|
|
|
|
|
|
if (this.cfg.UseHeaderRow)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 避免列头重名
|
|
|
|
|
|
colname = list[0][i] + $"({colname})";
|
|
|
|
|
|
|
|
|
|
|
|
// colname = list[0][i];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
table.Columns.Add(colname);
|
|
|
|
|
|
this.cfg.Storage.DataTableShow.Columns.Add(colname);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int rowcount_temp = 0;
|
|
|
|
|
|
|
|
|
|
|
|
int beginRow = rowindex + (this.cfg.UseHeaderRow ? 1 : 0);
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = beginRow; i < list.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (previewOnly && rowcount_temp > PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DataRow dr = table.NewRow();
|
|
|
|
|
|
for (int j = 0; j < list[i].Count; j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Reporter.WriteMsg("i:" + i+",j:"+j);
|
|
|
|
|
|
dr[j] = list[i][j];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
table.Rows.Add(dr);
|
|
|
|
|
|
|
|
|
|
|
|
rowcount_temp++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = e.Message;
|
|
|
|
|
|
Console.WriteLine(e.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void LoadDataTableAccess(ref DataTable table, string path, string tableName, int rowindex, bool previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(tableName))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OleDbConnection conn = null;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
conn = new OleDbConnection(new ConnStringData { FilePath = path }.Access);
|
|
|
|
|
|
conn.Open();
|
|
|
|
|
|
OleDbDataAdapter myDa = new OleDbDataAdapter("Select * from " + tableName, conn);
|
|
|
|
|
|
|
|
|
|
|
|
DataTable tmp = new DataTable();
|
|
|
|
|
|
|
|
|
|
|
|
myDa.Fill(tmp);
|
|
|
|
|
|
|
|
|
|
|
|
if (previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
DataHelp.CloneTable(tmp, table, false, count: PreviewLineCount);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
table = tmp;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.RecordCount = table.Rows.Count;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.WriteLine(ex.Message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
conn?.Close();
|
|
|
|
|
|
|
|
|
|
|
|
// conn.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = e.Message;
|
|
|
|
|
|
Console.WriteLine(e.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void LoadDataTableEmpty(DataTable table, string filename, int rowindex, bool previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
FileStream fs = File.OpenRead(filename);
|
|
|
|
|
|
StreamReader reader = new StreamReader(fs);
|
|
|
|
|
|
|
|
|
|
|
|
List<List<string>> list = new List<List<string>>();
|
|
|
|
|
|
|
|
|
|
|
|
string type = string.Empty;
|
|
|
|
|
|
string str = reader.ReadLine();
|
|
|
|
|
|
if (str == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (str == "# Type: scattered data")
|
|
|
|
|
|
{
|
|
|
|
|
|
type = "A";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (str.StartsWith("! "))
|
|
|
|
|
|
{
|
|
|
|
|
|
type = "B";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
type = "C";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool next = false;
|
|
|
|
|
|
|
|
|
|
|
|
while (str != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (type == "A")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (str.StartsWith("# "))
|
|
|
|
|
|
{
|
|
|
|
|
|
str = reader.ReadLine();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
next = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (type == "B")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (str == "@")
|
|
|
|
|
|
{
|
|
|
|
|
|
next = true;
|
|
|
|
|
|
str = reader.ReadLine();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (type == "C")
|
|
|
|
|
|
{
|
|
|
|
|
|
next = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!next)
|
|
|
|
|
|
{
|
|
|
|
|
|
str = reader.ReadLine();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<string> list_row = new List<string>();
|
|
|
|
|
|
|
|
|
|
|
|
string[] array = str.Split(Constants.StringSplit.Separator, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
for (int i = 0; i < array.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
list_row.Add(array[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
list.Add(list_row);
|
|
|
|
|
|
str = reader.ReadLine();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.RecordCount = list.Count;
|
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < list[0].Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
string colname = "列" + (i + 1);
|
|
|
|
|
|
if (this.cfg.UseHeaderRow)
|
|
|
|
|
|
{
|
|
|
|
|
|
colname = list[0][i];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
table.Columns.Add(colname);
|
|
|
|
|
|
this.cfg.Storage.DataTableShow.Columns.Add(colname);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int rowcount_temp = 0;
|
|
|
|
|
|
for (int i = rowindex; i < list.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (previewOnly && rowcount_temp > PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DataRow dr = table.NewRow();
|
|
|
|
|
|
for (int j = 0; j < list[i].Count; j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
dr[j] = list[i][j];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
table.Rows.Add(dr);
|
|
|
|
|
|
|
|
|
|
|
|
rowcount_temp++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = e.Message;
|
|
|
|
|
|
Console.WriteLine(e.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void LoadDataTableOracle(ref DataTable table, int rowindex, bool previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
string tableName = this.cfg.DbTableName;
|
|
|
|
|
|
Oracle10g dB = new Oracle10g(this.cfg.DbConnectString);
|
|
|
|
|
|
DataTable tmp = dB.GetDataTable("select * from " + tableName);
|
|
|
|
|
|
dB.Dispose();
|
|
|
|
|
|
|
|
|
|
|
|
if (previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
DataHelp.CloneTable(tmp, table, false, count: PreviewLineCount);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
table = tmp;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.RecordCount = table.Rows.Count;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show(ex.Message);
|
|
|
|
|
|
Console.WriteLine(ex.Message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void LoadDataTableSqlServer(ref DataTable table, int rowindex, bool previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
string tableName = this.cfg.DbTableName;
|
|
|
|
|
|
Server2008 dB = new Server2008(this.cfg.DbConnectString);
|
|
|
|
|
|
DataTable tmp = dB.GetDataTable("select * from " + tableName);
|
|
|
|
|
|
dB.Dispose();
|
|
|
|
|
|
|
|
|
|
|
|
if (previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
DataHelp.CloneTable(tmp, table, false, count: PreviewLineCount);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
table = tmp;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.RecordCount = table.Rows.Count;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = ex.Message;
|
|
|
|
|
|
Console.WriteLine(ex.Message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void LoadDataTableTxt(ref DataTable table, string filepath, string charset, int rowindex, bool previewOnly = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadDataTableTxtWithoutHeader(ref table, filepath, charset, rowindex, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Loads the data table dev.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="filename">The filename.</param>
|
|
|
|
|
|
/// <param name="charset">The charset.</param>
|
|
|
|
|
|
/// <param name="rowindex">The rowindex.</param>
|
|
|
|
|
|
/// <param name="previewOnly">If true, preview only.</param>
|
|
|
|
|
|
private void LoadDataTableDev(ref DataTable table, string filename, string charset, int rowindex, bool previewOnly = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
long length = new FileInfo(filename).Length;
|
|
|
|
|
|
using (MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile(filename, FileMode.Open, Guid.NewGuid().ToString()))
|
|
|
|
|
|
using (MemoryMappedViewStream stream = mmf.CreateViewStream(0, length))
|
|
|
|
|
|
using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding(charset)))
|
|
|
|
|
|
{
|
|
|
|
|
|
PreviewData preview = new PreviewData();
|
|
|
|
|
|
|
|
|
|
|
|
int lineindex = 0;
|
|
|
|
|
|
|
|
|
|
|
|
while (!reader.EndOfStream)
|
|
|
|
|
|
{
|
|
|
|
|
|
string str = reader.ReadLine();
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(str))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (str.StartsWith("#"))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string trimString = string.Join(",", str.Split(
|
|
|
|
|
|
Constants.StringSplit.EmptySeparator,
|
|
|
|
|
|
StringSplitOptions.RemoveEmptyEntries));
|
|
|
|
|
|
|
|
|
|
|
|
string[] array = trimString.Split(
|
|
|
|
|
|
Constants.StringSplit.Separator,
|
|
|
|
|
|
StringSplitOptions.None);
|
|
|
|
|
|
|
|
|
|
|
|
if (previewOnly && lineindex >= PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (lineindex < PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
preview.Add(new PreviewLine(array));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (lineindex == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < array.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.GenerateColumnByPreview(table, preview, i);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (lineindex == rowindex && this.cfg.UseHeaderRow && previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
lineindex++;
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (lineindex >= rowindex)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < array.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.GenerateColumnByPreview(table, preview, i);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (array.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Rows.Add(array);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
lineindex++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.PreviewCache[filename] = preview;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = e.Message;
|
|
|
|
|
|
Console.WriteLine(e.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Loads the data table dat.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="filename">The filename.</param>
|
|
|
|
|
|
/// <param name="charset">The charset.</param>
|
|
|
|
|
|
/// <param name="rowindex">The rowindex.</param>
|
|
|
|
|
|
/// <param name="previewOnly">If true, preview only.</param>
|
|
|
|
|
|
private void LoadDataTableDat(ref DataTable table, string filename, string charset, int rowindex, bool previewOnly = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
long length = new FileInfo(filename).Length;
|
|
|
|
|
|
using (MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile(filename, FileMode.Open, Guid.NewGuid().ToString()))
|
|
|
|
|
|
using (MemoryMappedViewStream stream = mmf.CreateViewStream(0, length))
|
|
|
|
|
|
using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding(charset)))
|
|
|
|
|
|
{
|
|
|
|
|
|
PreviewData preview = new PreviewData();
|
|
|
|
|
|
int lineindex = 0;
|
|
|
|
|
|
while (!reader.EndOfStream)
|
|
|
|
|
|
{
|
|
|
|
|
|
string str = reader.ReadLine();
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(str))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
string trimString = string.Join(",", str.Split(
|
|
|
|
|
|
Constants.StringSplit.EmptySeparator,
|
|
|
|
|
|
StringSplitOptions.RemoveEmptyEntries));
|
|
|
|
|
|
|
|
|
|
|
|
string[] array = trimString.Split(
|
|
|
|
|
|
Constants.StringSplit.Separator,
|
|
|
|
|
|
StringSplitOptions.None);
|
|
|
|
|
|
|
|
|
|
|
|
if (previewOnly && lineindex >= PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (lineindex < PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
preview.Add(new PreviewLine(array));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (lineindex == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < array.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.GenerateColumnByPreview(table, preview, i);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (lineindex == rowindex && this.cfg.UseHeaderRow)
|
|
|
|
|
|
{
|
|
|
|
|
|
lineindex++;
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (lineindex >= rowindex)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < array.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.GenerateColumnByPreview(table, preview, i);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (array.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Rows.Add(array);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
lineindex++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.PreviewCache[filename] = preview;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = e.Message;
|
|
|
|
|
|
Console.WriteLine(e.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Loads the data table dat.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="filename">The filename.</param>
|
|
|
|
|
|
/// <param name="charset">The charset.</param>
|
|
|
|
|
|
/// <param name="rowindex">The rowindex.</param>
|
|
|
|
|
|
/// <param name="previewOnly">If true, preview only.</param>
|
|
|
|
|
|
private List<string> LoadDataTableDatInHeader(ref DataTable table, string filename, string charset, int rowindex, bool previewOnly = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> columnNames = new List<string>();
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
long length = new FileInfo(filename).Length;
|
|
|
|
|
|
using (MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile(filename, FileMode.Open, Guid.NewGuid().ToString()))
|
|
|
|
|
|
using (MemoryMappedViewStream stream = mmf.CreateViewStream(0, length))
|
|
|
|
|
|
using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding(charset)))
|
|
|
|
|
|
{
|
|
|
|
|
|
PreviewData preview = new PreviewData();
|
|
|
|
|
|
int lineindex = 0;
|
|
|
|
|
|
while (!reader.EndOfStream)
|
|
|
|
|
|
{
|
|
|
|
|
|
string str = reader.ReadLine();
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(str))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
string trimString = string.Join(",", str.Split(
|
|
|
|
|
|
Constants.StringSplit.EmptySeparator,
|
|
|
|
|
|
StringSplitOptions.RemoveEmptyEntries));
|
|
|
|
|
|
|
|
|
|
|
|
string[] array = trimString.Split(
|
|
|
|
|
|
Constants.StringSplit.Separator,
|
|
|
|
|
|
StringSplitOptions.None);
|
|
|
|
|
|
|
|
|
|
|
|
if (previewOnly && lineindex >= PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (lineindex == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < array.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
string colName = array[i];
|
|
|
|
|
|
if (!columnNames.Contains(colName))
|
|
|
|
|
|
{
|
|
|
|
|
|
columnNames.Add(colName);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//判断表头
|
|
|
|
|
|
for (int i = 0; i < columnNames.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Columns.Add(columnNames[i]);
|
|
|
|
|
|
this.allColumnNames.Add(columnNames[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Rows.Add(array);
|
|
|
|
|
|
}
|
|
|
|
|
|
lineindex++;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.PreviewCache[filename] = preview;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = e.Message;
|
|
|
|
|
|
Console.WriteLine(e.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
return columnNames;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Loads the data table dat by curve.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="filename">The filename.</param>
|
|
|
|
|
|
/// <param name="charset">The charset.</param>
|
|
|
|
|
|
/// <param name="rowindex">The rowindex.</param>
|
|
|
|
|
|
/// <param name="previewOnly">If true, preview only.</param>
|
|
|
|
|
|
/// <returns>A list of string.</returns>
|
|
|
|
|
|
private List<string> LoadDataTableDatByCurve(ref DataTable table, string filename, string charset, int rowindex, bool previewOnly = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> columnNames = new List<string>();
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
long length = new FileInfo(filename).Length;
|
|
|
|
|
|
using (MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile(filename, FileMode.Open, Guid.NewGuid().ToString()))
|
|
|
|
|
|
using (MemoryMappedViewStream stream = mmf.CreateViewStream(0, length))
|
|
|
|
|
|
using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding(charset)))
|
|
|
|
|
|
{
|
|
|
|
|
|
PreviewData preview = new PreviewData();
|
|
|
|
|
|
int lineindex = 0;
|
|
|
|
|
|
bool isReadHeader = false;
|
|
|
|
|
|
bool isReadBody = false;
|
|
|
|
|
|
while (!reader.EndOfStream)
|
|
|
|
|
|
{
|
|
|
|
|
|
string str = reader.ReadLine();
|
|
|
|
|
|
str = str.Trim(' ');
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(str))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (str.StartsWith("# DEPT"))
|
|
|
|
|
|
{
|
|
|
|
|
|
str = str.Replace("# DEPT", "DEPT");
|
|
|
|
|
|
isReadHeader = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (str.StartsWith("# TVD"))
|
|
|
|
|
|
{
|
|
|
|
|
|
str = str.Replace("# TVD", "TVD");
|
|
|
|
|
|
isReadHeader = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (str.StartsWith("DEPTHT"))
|
|
|
|
|
|
{
|
|
|
|
|
|
str = str.Replace("DEPTHT", "DEPTH");
|
|
|
|
|
|
isReadHeader = true;
|
|
|
|
|
|
this.importTips = $"{filename}的深度列名是DEPTHT,导入时已将列名替换为Depth!";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string trimString = string.Join(",", str.Split(
|
|
|
|
|
|
Constants.StringSplit.EmptySeparator,
|
|
|
|
|
|
StringSplitOptions.RemoveEmptyEntries));
|
|
|
|
|
|
|
|
|
|
|
|
string[] array = trimString.Split(
|
|
|
|
|
|
Constants.StringSplit.Separator,
|
|
|
|
|
|
StringSplitOptions.None);
|
|
|
|
|
|
|
|
|
|
|
|
if (isReadHeader && !isReadBody)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var colName in array)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!columnNames.Contains(colName))
|
|
|
|
|
|
{
|
|
|
|
|
|
columnNames.Add(colName);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//判断表头
|
|
|
|
|
|
for (int i = 0; i < columnNames.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Columns.Add(columnNames[i]);
|
|
|
|
|
|
this.allColumnNames.Add(columnNames[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
isReadBody = true;
|
|
|
|
|
|
//说明表头写完了
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (isReadBody)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (previewOnly && lineindex >= PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (lineindex < PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
preview.Add(new PreviewLine(array));
|
|
|
|
|
|
}
|
|
|
|
|
|
table.Rows.Add(array);
|
|
|
|
|
|
lineindex++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.PreviewCache[filename] = preview;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = e.Message;
|
|
|
|
|
|
Console.WriteLine(e.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (columnNames.Count == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
columnNames = this.LoadDataTableDatInHeader(ref table, filename, charset, rowindex, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
return columnNames;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Loads the data table las.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="filename">The filename.</param>
|
|
|
|
|
|
/// <param name="charset">The charset.</param>
|
|
|
|
|
|
/// <param name="rowindex">The rowindex.</param>
|
|
|
|
|
|
/// <param name="previewOnly">If true, preview only.</param>
|
|
|
|
|
|
private List<string> LoadDataTableLas(ref DataTable table, string filename, string charset, int rowindex, bool previewOnly = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> columnNames = new List<string>();
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
long length = new FileInfo(filename).Length;
|
|
|
|
|
|
using (MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile(filename, FileMode.Open, Guid.NewGuid().ToString()))
|
|
|
|
|
|
using (MemoryMappedViewStream stream = mmf.CreateViewStream(0, length))
|
|
|
|
|
|
using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding(charset)))
|
|
|
|
|
|
{
|
|
|
|
|
|
PreviewData preview = new PreviewData();
|
|
|
|
|
|
int lineindex = 0;
|
|
|
|
|
|
bool isReadHeader = false;
|
|
|
|
|
|
bool isReadBody = false;
|
|
|
|
|
|
string strLine = string.Empty;
|
|
|
|
|
|
while (!reader.EndOfStream)
|
|
|
|
|
|
{
|
|
|
|
|
|
string str = reader.ReadLine();
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(str))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (str.StartsWith("~C") || str.StartsWith("~Curve"))
|
|
|
|
|
|
{
|
|
|
|
|
|
isReadHeader = true;
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (!isReadHeader)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (str.StartsWith("~A") || str.StartsWith("~Ascii"))
|
|
|
|
|
|
{
|
|
|
|
|
|
isReadBody = true;
|
|
|
|
|
|
table.Columns.Clear();
|
|
|
|
|
|
if (columnNames.Count == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage += $"文件{filename}列读取失败,已跳过文件,{Environment.NewLine}";
|
|
|
|
|
|
return new List<string>();
|
|
|
|
|
|
}
|
|
|
|
|
|
//说明表头写完了
|
|
|
|
|
|
for (int i = 0; i < columnNames.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Columns.Add(columnNames[i]);
|
|
|
|
|
|
this.allColumnNames.Add(columnNames[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (isReadHeader && !isReadBody)
|
|
|
|
|
|
{
|
|
|
|
|
|
//判断表头,对于小数点处理和冒号处理
|
|
|
|
|
|
string colName = str.Replace(":", string.Empty);
|
|
|
|
|
|
colName = colName.Split('.')[0];
|
|
|
|
|
|
if (colName.StartsWith("#"))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
colName = colName.Trim().ToUpper();
|
|
|
|
|
|
if (!columnNames.Contains(colName))
|
|
|
|
|
|
{
|
|
|
|
|
|
columnNames.Add(colName);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
//存在重复列名
|
|
|
|
|
|
table.Columns.Clear();
|
|
|
|
|
|
this.errorMessage += $"文件{filename}存在重复列名{colName},已跳过文件,{Environment.NewLine}";
|
|
|
|
|
|
return new List<string>();
|
|
|
|
|
|
}
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
strLine = str;
|
|
|
|
|
|
string trimString = string.Join(",", strLine.Split(Constants.StringSplit.EmptySeparator, StringSplitOptions.RemoveEmptyEntries));
|
|
|
|
|
|
string[] array = trimString.Split(Constants.StringSplit.Separator, StringSplitOptions.None);
|
|
|
|
|
|
if (array.Length != columnNames.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
strLine = string.Empty;
|
|
|
|
|
|
if (previewOnly && lineindex >= PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (lineindex < PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
preview.Add(new PreviewLine(array));
|
|
|
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < array.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.GenerateColumnByPreview(table, preview, i);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (array.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Rows.Add(array);
|
|
|
|
|
|
}
|
|
|
|
|
|
lineindex++;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.PreviewCache[filename] = preview;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = e.Message;
|
|
|
|
|
|
Console.WriteLine(e.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
return columnNames;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 从 ~A 行提取列名
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">存储加载的数据</param>
|
|
|
|
|
|
/// <param name="filename">文件的路径</param>
|
|
|
|
|
|
/// <param name="charset">字符编码</param>
|
|
|
|
|
|
/// <param name="rowindex">行索引</param>
|
|
|
|
|
|
/// <param name="previewOnly">仅加载预览数据</param>
|
|
|
|
|
|
private List<string> LoadDataTableLasNew(ref DataTable table, string filename, string charset, int rowindex, bool previewOnly = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> columnNames = new List<string>();
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
long length = new FileInfo(filename).Length;
|
|
|
|
|
|
using (MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile(filename, FileMode.Open, Guid.NewGuid().ToString()))
|
|
|
|
|
|
using (MemoryMappedViewStream stream = mmf.CreateViewStream(0, length))
|
|
|
|
|
|
using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding(charset)))
|
|
|
|
|
|
{
|
|
|
|
|
|
PreviewData preview = new PreviewData();
|
|
|
|
|
|
int lineindex = 0;
|
|
|
|
|
|
bool isReadBody = false;
|
|
|
|
|
|
string strLine = string.Empty;
|
|
|
|
|
|
while (!reader.EndOfStream)
|
|
|
|
|
|
{
|
|
|
|
|
|
string str = reader.ReadLine();
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(str))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (str.StartsWith("~A", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
isReadBody = true;
|
|
|
|
|
|
|
|
|
|
|
|
// 从 ~A 行提取列名
|
|
|
|
|
|
string headerLine = str.Substring(2).Trim(); // 去掉 ~A 前缀
|
|
|
|
|
|
string[] headers = headerLine.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
|
|
|
|
|
|
// 清空已有列名
|
|
|
|
|
|
table.Columns.Clear();
|
|
|
|
|
|
columnNames.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var header in headers)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 进一步处理列名,例如去除特殊字符
|
|
|
|
|
|
string colName = header.Trim().ToUpper();
|
|
|
|
|
|
if (!columnNames.Contains(colName))
|
|
|
|
|
|
{
|
|
|
|
|
|
columnNames.Add(colName);
|
|
|
|
|
|
table.Columns.Add(colName);
|
|
|
|
|
|
this.allColumnNames.Add(colName);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
// 存在重复列名
|
|
|
|
|
|
this.errorMessage += $"文件{filename}存在重复列名{colName}, 已跳过文件,{Environment.NewLine}";
|
|
|
|
|
|
table.Columns.Clear();
|
|
|
|
|
|
return new List<string>();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (isReadBody)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 读取数据行
|
|
|
|
|
|
strLine = str;
|
|
|
|
|
|
string trimString = string.Join(",", strLine.Split(Constants.StringSplit.EmptySeparator, StringSplitOptions.RemoveEmptyEntries));
|
|
|
|
|
|
string[] array = trimString.Split(Constants.StringSplit.Separator, StringSplitOptions.None);
|
|
|
|
|
|
if (array.Length != columnNames.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
strLine = string.Empty;
|
|
|
|
|
|
if (previewOnly && lineindex >= PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (lineindex < PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
preview.Add(new PreviewLine(array));
|
|
|
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < array.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.GenerateColumnByPreview(table, preview, i);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (array.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Rows.Add(array);
|
|
|
|
|
|
}
|
|
|
|
|
|
lineindex++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.PreviewCache[filename] = preview;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = e.Message;
|
|
|
|
|
|
Console.WriteLine(e.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
return columnNames;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Loads the data table txt by curve.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="filename">The filename.</param>
|
|
|
|
|
|
/// <param name="charset">The charset.</param>
|
|
|
|
|
|
/// <param name="rowindex">The rowindex.</param>
|
|
|
|
|
|
/// <param name="previewOnly">If true, preview only.</param>
|
|
|
|
|
|
/// <returns>A list of string.</returns>
|
|
|
|
|
|
private List<string> LoadDataTableTxtByCurve(ref DataTable table, string filename, string charset, int rowindex, bool previewOnly = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> columnNames = new List<string>();
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
long length = new FileInfo(filename).Length;
|
|
|
|
|
|
using (MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile(filename, FileMode.Open, Guid.NewGuid().ToString()))
|
|
|
|
|
|
using (MemoryMappedViewStream stream = mmf.CreateViewStream(0, length))
|
|
|
|
|
|
using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding(charset)))
|
|
|
|
|
|
{
|
|
|
|
|
|
PreviewData preview = new PreviewData();
|
|
|
|
|
|
int lineindex = 0;
|
|
|
|
|
|
bool isReadHeader = false;
|
|
|
|
|
|
bool isReadBody = false;
|
|
|
|
|
|
string strLine = string.Empty;
|
|
|
|
|
|
while (!reader.EndOfStream)
|
|
|
|
|
|
{
|
|
|
|
|
|
string str = reader.ReadLine();
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(str))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (str.StartsWith("#DEPTH") || str.StartsWith(" # DEPTH"))
|
|
|
|
|
|
{
|
|
|
|
|
|
isReadHeader = true;
|
|
|
|
|
|
str = str.Replace("#DEPTH", "DEPTH").Replace(" # DEPTH", "DEPTH").Replace(":", string.Empty);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (!isReadHeader)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
string trimString = string.Join(",", str.Split(Constants.StringSplit.EmptySeparator, StringSplitOptions.RemoveEmptyEntries));
|
|
|
|
|
|
string[] array = trimString.Split(Constants.StringSplit.Separator, StringSplitOptions.None);
|
|
|
|
|
|
if (isReadHeader && !isReadBody)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var colName in array)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!columnNames.Contains(colName))
|
|
|
|
|
|
{
|
|
|
|
|
|
columnNames.Add(colName);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//判断表头
|
|
|
|
|
|
for (int i = 0; i < columnNames.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.allColumnNames.Add(columnNames[i]);
|
|
|
|
|
|
table.Columns.Add(columnNames[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
isReadBody = true;
|
|
|
|
|
|
//说明表头写完了
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (previewOnly && lineindex >= PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (lineindex < PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
preview.Add(new PreviewLine(array));
|
|
|
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < array.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.GenerateColumnByPreview(table, preview, i);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (array.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Rows.Add(array);
|
|
|
|
|
|
}
|
|
|
|
|
|
lineindex++;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.PreviewCache[filename] = preview;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = e.Message;
|
|
|
|
|
|
Console.WriteLine(e.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
return columnNames;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Loads the data table txt without header.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="filename">The filename.</param>
|
|
|
|
|
|
/// <param name="charset">The charset.</param>
|
|
|
|
|
|
/// <param name="rowindex">The rowindex.</param>
|
|
|
|
|
|
/// <param name="previewOnly">If true, preview only.</param>
|
|
|
|
|
|
private void LoadDataTableTxtWithoutHeader(ref DataTable table, string filename, string charset, int rowindex, bool previewOnly = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
long length = new FileInfo(filename).Length;
|
|
|
|
|
|
|
|
|
|
|
|
using (MemoryMappedFile mmf = MemoryMappedFile.CreateFromFile(filename, FileMode.Open, Guid.NewGuid().ToString()))
|
|
|
|
|
|
using (MemoryMappedViewStream stream = mmf.CreateViewStream(0, length))
|
|
|
|
|
|
using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding(charset)))
|
|
|
|
|
|
//using (var reader = new StreamReader(filename, Encoding.GetEncoding(charset)))
|
|
|
|
|
|
{
|
|
|
|
|
|
PreviewData preview = new PreviewData();
|
|
|
|
|
|
int lineindex = 0;
|
|
|
|
|
|
while (!reader.EndOfStream)
|
|
|
|
|
|
{
|
|
|
|
|
|
string str = reader.ReadLine();
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(str))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
string trimString = string.Join(",", str.Split(
|
|
|
|
|
|
Constants.StringSplit.EmptySeparator,
|
|
|
|
|
|
StringSplitOptions.RemoveEmptyEntries));
|
|
|
|
|
|
|
|
|
|
|
|
string[] array = trimString.Split(
|
|
|
|
|
|
Constants.StringSplit.Separator,
|
|
|
|
|
|
StringSplitOptions.None);
|
|
|
|
|
|
|
|
|
|
|
|
if (previewOnly && lineindex >= PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (lineindex < PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
preview.Add(new PreviewLine(array));
|
|
|
|
|
|
}
|
|
|
|
|
|
if (lineindex == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < array.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.GenerateColumnByPreview(table, preview, i);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (lineindex == rowindex && this.cfg.UseHeaderRow && previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
lineindex++;
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (lineindex >= rowindex)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < array.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.GenerateColumnByPreview(table, preview, i);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (array.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Rows.Add(array);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
lineindex++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.PreviewCache[filename] = preview;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = e.Message;
|
|
|
|
|
|
Console.WriteLine(e.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Loads the data table txt with header.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="filename">The filename.</param>
|
|
|
|
|
|
/// <param name="charset">The charset.</param>
|
|
|
|
|
|
/// <param name="previewOnly">If true, preview only.</param>
|
|
|
|
|
|
private void LoadDataTableTxtWithHeader(ref DataTable table, string filename, string charset, bool previewOnly = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
Dictionary<string, string> mapHeaders = new Dictionary<string, string>();
|
|
|
|
|
|
List<string> listHeaders = new List<string>();
|
|
|
|
|
|
|
|
|
|
|
|
int nState = 0;
|
|
|
|
|
|
|
|
|
|
|
|
int lineindex = 0;
|
|
|
|
|
|
int beginindex = 0;
|
|
|
|
|
|
|
|
|
|
|
|
using (StreamReader reader = new StreamReader(filename, Encoding.GetEncoding(charset)))
|
|
|
|
|
|
{
|
|
|
|
|
|
while (!reader.EndOfStream)
|
|
|
|
|
|
{
|
|
|
|
|
|
string str = reader.ReadLine();
|
|
|
|
|
|
lineindex++;
|
|
|
|
|
|
|
|
|
|
|
|
if (previewOnly && lineindex > PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 状态切换, 0是映射行, 1是列头行, 2是列数据行
|
|
|
|
|
|
if (nState == 0 && !str.Contains(":"))
|
|
|
|
|
|
{
|
|
|
|
|
|
nState = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (nState == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
nState = 2;
|
|
|
|
|
|
beginindex = lineindex;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (nState == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
string[] array = str.Split(new[] { ":", " ", "\t" }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
if (array.Length == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
mapHeaders.Add(array[0], array[1]);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (nState == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
string[] array = str.Split(Constants.StringSplit.Separator, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
listHeaders.AddRange(array);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (KeyValuePair<string, string> kv in mapHeaders)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Columns.Add(kv.Key);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (string s in listHeaders)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Columns.Add(s);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (lineindex == beginindex && this.cfg.UseHeaderRow && previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string[] array = str.Split(Constants.StringSplit.Separator, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
|
|
|
|
|
|
if (array.Length == listHeaders.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Rows.Add(mapHeaders.Values.Concat(array).ToArray());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = e.Message;
|
|
|
|
|
|
Console.WriteLine(e.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 读取xls和xlsx格式
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="path">The path.</param>
|
|
|
|
|
|
/// <param name="tableName">The table name.</param>
|
|
|
|
|
|
/// <param name="rowindex">The rowindex.</param>
|
|
|
|
|
|
/// <param name="previewOnly">If true, preview only.</param>
|
|
|
|
|
|
private void LoadDataTableXls(ref DataTable table, string path, string tableName, int rowindex, bool previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Clear();
|
|
|
|
|
|
table.Columns.Clear();
|
|
|
|
|
|
DataTable dt_from2 = new DataTable();
|
|
|
|
|
|
string ext = Path.GetExtension(path);
|
|
|
|
|
|
if (ext.ToLower().Equals(".xls"))
|
|
|
|
|
|
{
|
|
|
|
|
|
this.NpoiImportExcel(ref dt_from2, path, previewOnly, PreviewLineCount, tableName);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.MiniExcelImportExcel(ref dt_from2, path, previewOnly, PreviewLineCount, tableName);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (dt_from2 == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.RecordCount = 0;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
//前面为全表数据
|
|
|
|
|
|
if (this.cfg.UseHeaderRow)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Columns.Clear();
|
|
|
|
|
|
table.Clear();
|
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < dt_from2.Columns.Count; j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 此处为设置首行为列名,原来此处rowindex默认是0,因为首行是可以改变的,所以此处调整为按照首行来进行设置列名。
|
|
|
|
|
|
string columnName = dt_from2.Rows[rowindex][j].ToString().Replace("#", ".");
|
|
|
|
|
|
|
|
|
|
|
|
// 防止重名
|
|
|
|
|
|
if (table.Columns.Contains(columnName))
|
|
|
|
|
|
{
|
|
|
|
|
|
int index = 1;
|
|
|
|
|
|
string newName;
|
|
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
{
|
|
|
|
|
|
newName = $"{columnName}_{index}";
|
|
|
|
|
|
index++;
|
|
|
|
|
|
}
|
|
|
|
|
|
while (table.Columns.Contains(newName));
|
|
|
|
|
|
|
|
|
|
|
|
columnName = newName;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
table.Columns.Add(columnName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < dt_from2.Columns.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
dt_from2.Columns[i].ColumnName = "列" + (i + 1);
|
|
|
|
|
|
table.Columns.Add("列" + (i + 1));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int beginRow = 0;
|
|
|
|
|
|
if (previewOnly && this.cfg.UseHeaderRow)
|
|
|
|
|
|
{
|
|
|
|
|
|
beginRow = rowindex + 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
for (int i = beginRow; i < dt_from2.Rows.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (previewOnly && i > PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.NewRow();
|
|
|
|
|
|
for (int j = 0; j < dt_from2.Columns.Count; j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
dr[j] = dt_from2.Rows[i][j];
|
|
|
|
|
|
}
|
|
|
|
|
|
table.Rows.Add(dr);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//table 实际为this.cfg.Storage.DataTableShow;
|
|
|
|
|
|
this.RecordCount = table.Rows.Count;
|
|
|
|
|
|
|
|
|
|
|
|
LoadDataResult dataResult = new LoadDataResult();
|
|
|
|
|
|
if (this.RecordCount == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
dataResult.status = ResultStatus.失败;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
dataResult.status = ResultStatus.成功;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.ui.OnReadDataFinish(dataResult);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = ex.Message;
|
|
|
|
|
|
Console.WriteLine(ex.Message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// NpoiImports the excel.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dt">DataTable</param>
|
|
|
|
|
|
/// <param name="path">路径</param>
|
|
|
|
|
|
/// <param name="previewOnly">是否预览</param>
|
|
|
|
|
|
/// <param name="previewCount">预览数量</param>
|
|
|
|
|
|
/// <param name="sheetName">表名</param>
|
|
|
|
|
|
/// <returns>表格</returns>
|
|
|
|
|
|
private DataTable NpoiImportExcel(ref DataTable dt, string path, bool previewOnly, int previewCount, string sheetName = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
string ext = path.Substring(path.LastIndexOf(".") + 1);
|
|
|
|
|
|
int customBufferSize = 40 * 1024 * 1024;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, customBufferSize))
|
|
|
|
|
|
{
|
|
|
|
|
|
NPOI.SS.UserModel.IWorkbook workbook = WorkbookFactory.Create(stream, true);
|
|
|
|
|
|
IFormulaEvaluator formulaEvaluator = WorkbookFactory.CreateFormulaEvaluator(workbook);
|
|
|
|
|
|
ISheet sheet = null;
|
|
|
|
|
|
// 获取工作表 默认取第一张
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(sheetName))
|
|
|
|
|
|
{
|
|
|
|
|
|
sheet = workbook.GetSheetAt(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
sheet = workbook.GetSheet(sheetName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (sheet == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IRow headerRow = sheet.GetRow(0);
|
|
|
|
|
|
IRow secondRow = sheet.GetRow(1);
|
|
|
|
|
|
int cellCount = headerRow.LastCellNum;
|
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < cellCount; j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
ICell cell = headerRow.GetCell(j);
|
|
|
|
|
|
if (cell != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
dt.Columns.Add(cell.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
dt.Columns.Add(string.Empty);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = sheet.FirstRowNum; i <= sheet.LastRowNum; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
DataRow dataRow = dt.NewRow();
|
|
|
|
|
|
IRow row = sheet.GetRow(i);
|
|
|
|
|
|
if (row != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int j = row.FirstCellNum; j < cellCount; j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var cell = row.GetCell(j);
|
|
|
|
|
|
|
|
|
|
|
|
if (cell != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cell.CellType == CellType.Formula)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var evalCell = formulaEvaluator.EvaluateInCell(cell);
|
|
|
|
|
|
SetRowCell(dataRow, evalCell, j);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetRowCell(dataRow, null, j);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (cell.CellType == CellType.Numeric && DateUtil.IsCellDateFormatted(cell))
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cell.DateCellValue.Value.Hour > 0 || cell.DateCellValue.Value.Minute > 0 || cell.DateCellValue.Value.Second > 0 || cell.DateCellValue.Value.Millisecond > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetRowCellValue(dataRow, cell.DateCellValue.ToString(), j);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SetRowCellValue(dataRow, cell.DateCellValue.Value.ToString("yyyy-MM-dd"), j);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetRowCell(dataRow, null, j);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SetRowCell(dataRow, cell, j);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
dt.Rows.Add(dataRow);
|
|
|
|
|
|
if (previewOnly && i >= previewCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (DuplicateNameException)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = ", 文件包含重复列名!";
|
|
|
|
|
|
dt = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.WriteLine(ex.ToString());
|
|
|
|
|
|
dt = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return dt;
|
|
|
|
|
|
|
|
|
|
|
|
void SetRowCell(DataRow dataRow, NPOI.SS.UserModel.ICell cell, int col)
|
|
|
|
|
|
{
|
|
|
|
|
|
dataRow[col] = cell != null ? cell.ToString() : string.Empty;
|
|
|
|
|
|
}
|
|
|
|
|
|
void SetRowCellValue(DataRow dataRow, string cellValue, int col)
|
|
|
|
|
|
{
|
|
|
|
|
|
dataRow[col] = cellValue != null ? cellValue : string.Empty;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// DevExpressImportExcel
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dt">DataTable</param>
|
|
|
|
|
|
/// <param name="path">路径</param>
|
|
|
|
|
|
/// <param name="previewOnly">是否预览</param>
|
|
|
|
|
|
/// <param name="previewCount">预览数量</param>
|
|
|
|
|
|
/// <param name="sheetName">表名</param>
|
|
|
|
|
|
/// <returns>表格</returns>
|
|
|
|
|
|
private DataTable DevExpressImportExcel(ref DataTable dt, string path, bool previewOnly, int previewCount, string sheetName = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
string ext = Path.GetExtension(path);
|
|
|
|
|
|
int customBufferSize = 40 * 1024 * 1024;
|
|
|
|
|
|
using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, customBufferSize))
|
|
|
|
|
|
{
|
|
|
|
|
|
using (var workbook = WorkbookFactory.Create(stream))
|
|
|
|
|
|
{
|
|
|
|
|
|
//workbook.LoadDocument(stream);
|
|
|
|
|
|
//workbook.Calculate();
|
|
|
|
|
|
IFormulaEvaluator formulaEvaluator = WorkbookFactory.CreateFormulaEvaluator(workbook);
|
|
|
|
|
|
ISheet sheet = null;
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(sheetName))
|
|
|
|
|
|
{
|
|
|
|
|
|
sheet = workbook.GetSheetAt(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
sheet = workbook.GetSheet(sheetName);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (sheet == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
int rowCount = sheet.LastRowNum + 1;
|
|
|
|
|
|
IRow headerRow = sheet.GetRow(sheet.FirstRowNum);
|
|
|
|
|
|
int colCount = headerRow != null ? headerRow.LastCellNum : 0;
|
|
|
|
|
|
for (int columnIndex = 0; columnIndex < colCount; columnIndex++)
|
|
|
|
|
|
{
|
|
|
|
|
|
ICell cell = headerRow?.GetCell(columnIndex);
|
|
|
|
|
|
if (cell != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
dt.Columns.Add(cell.ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
dt.Columns.Add(string.Empty);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
for (int rowIndex = 0; rowIndex < rowCount; rowIndex++)
|
|
|
|
|
|
{
|
|
|
|
|
|
IRow row = sheet.GetRow(rowIndex);
|
|
|
|
|
|
DataRow dataRow = dt.NewRow();
|
|
|
|
|
|
for (int colIndex = 0; colIndex < colCount; colIndex++)
|
|
|
|
|
|
{
|
|
|
|
|
|
ICell cell = row.GetCell(colIndex);
|
|
|
|
|
|
// 处理公式单元格
|
|
|
|
|
|
if (cell.CellType == CellType.Formula)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
ICell evaluatedCell = formulaEvaluator.EvaluateInCell(cell);
|
|
|
|
|
|
SetRowCell(dataRow, evaluatedCell, colIndex);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch
|
|
|
|
|
|
{
|
|
|
|
|
|
SetRowCell(dataRow, cell, colIndex);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SetRowCell(dataRow, cell, colIndex);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
dt.Rows.Add(dataRow);
|
|
|
|
|
|
if (previewOnly && rowCount >= previewCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (DuplicateNameException ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = ", 文件包含重复列名!";
|
|
|
|
|
|
dt = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.WriteLine(ex.ToString());
|
|
|
|
|
|
dt = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
return dt;
|
|
|
|
|
|
|
|
|
|
|
|
// 辅助方法
|
|
|
|
|
|
void SetRowCell(DataRow dataRow, ICell cell, int col)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cell == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
dataRow[col] = string.Empty;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (cell.CellType)
|
|
|
|
|
|
{
|
|
|
|
|
|
case CellType.Numeric:
|
|
|
|
|
|
dataRow[col] = cell.NumericCellValue;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case CellType.String:
|
|
|
|
|
|
dataRow[col] = cell.StringCellValue;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case CellType.Boolean:
|
|
|
|
|
|
dataRow[col] = cell.BooleanCellValue;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case CellType.Formula:
|
|
|
|
|
|
dataRow[col] = cell.CellFormula;
|
|
|
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
dataRow[col] = $"{cell}";
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// MiniExcelImportExcel
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="dt">DataTable</param>
|
|
|
|
|
|
/// <param name="path">路径</param>
|
|
|
|
|
|
/// <param name="previewOnly">是否预览</param>
|
|
|
|
|
|
/// <param name="previewCount">预览数量</param>
|
|
|
|
|
|
/// <param name="sheetName">表名</param>
|
|
|
|
|
|
/// <returns>表格</returns>
|
|
|
|
|
|
private DataTable MiniExcelImportExcel(ref DataTable dt, string path, bool previewOnly, int previewCount, string sheetName = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
string ext = Path.GetExtension(path);
|
|
|
|
|
|
int customBufferSize = 40 * 1024 * 1024;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, customBufferSize))
|
|
|
|
|
|
{
|
|
|
|
|
|
using (MiniExcelDataReader excelReader = MiniExcel.GetReader(stream, false, sheetName))
|
|
|
|
|
|
{
|
|
|
|
|
|
int fieldCount = excelReader.FieldCount;//有的excel表列会读出上万列,因此限制一下
|
|
|
|
|
|
if (fieldCount > 256)
|
|
|
|
|
|
fieldCount = 256;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < fieldCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
dt.Columns.Add(excelReader.GetName(i));
|
|
|
|
|
|
}
|
|
|
|
|
|
int rowCount = 0;
|
|
|
|
|
|
while (excelReader.Read())
|
|
|
|
|
|
{
|
|
|
|
|
|
rowCount++;
|
|
|
|
|
|
DataRow row = dt.NewRow();
|
|
|
|
|
|
for (int i = 0; i < fieldCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
row[i] = excelReader.GetValue(i); // 假设 GetValue 返回 object 类型
|
|
|
|
|
|
}
|
|
|
|
|
|
dt.Rows.Add(row);
|
|
|
|
|
|
if (previewOnly && rowCount >= previewCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (DuplicateNameException ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = ", 文件包含重复列名!";
|
|
|
|
|
|
dt = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.WriteLine(ex.ToString());
|
|
|
|
|
|
dt = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//去掉合并行
|
|
|
|
|
|
if (this.tableName == DBHelp.GetTableName<WellTestTotal>() && dt.Rows.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 清理第一行
|
|
|
|
|
|
if (this.IsMergedRow(dt.Rows[0]))
|
|
|
|
|
|
{
|
|
|
|
|
|
dt.Rows.RemoveAt(0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 清理最后连续的“合并空行”或“无效尾部行”
|
|
|
|
|
|
while (dt.Rows.Count > 0 && this.IsMergedRow(dt.Rows[dt.Rows.Count - 1]))
|
|
|
|
|
|
{
|
|
|
|
|
|
dt.Rows.RemoveAt(dt.Rows.Count - 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return dt;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool IsMergedRow(DataRow row)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (row == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int nonEmptyCount = 0;
|
|
|
|
|
|
foreach (var item in row.ItemArray)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (item != null && !string.IsNullOrWhiteSpace(item.ToString()))
|
|
|
|
|
|
{
|
|
|
|
|
|
nonEmptyCount++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return nonEmptyCount <= 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 读取数据库
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void ReadDataBasePreview(ref DataTable table, bool previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
using (SplashHelper.Create())
|
|
|
|
|
|
{
|
|
|
|
|
|
int rowindex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
if (this.dbType == "sqlserver")
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadDataTableSqlServer(ref table, rowindex, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.dbType == "oracle")
|
|
|
|
|
|
{
|
|
|
|
|
|
this.LoadDataTableOracle(ref table, rowindex, previewOnly);
|
|
|
|
|
|
}
|
|
|
|
|
|
LoadDataResult dataResult = new LoadDataResult();
|
|
|
|
|
|
if (this.RecordCount == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
dataResult.status = ResultStatus.失败;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
dataResult.status = ResultStatus.成功;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.ui.OnReadDataFinish(dataResult);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private List<string> allColumnNames = new List<string>();
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 读取文件预览
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="previewOnly">If true, preview only.</param>
|
|
|
|
|
|
public void ReadFilePreview(ref DataTable table, bool previewOnly)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.errorMessage = string.Empty;
|
|
|
|
|
|
using (SplashHelper.Create())
|
|
|
|
|
|
{
|
|
|
|
|
|
LoadDataResult dataResult = new LoadDataResult() { status = ResultStatus.失败 };
|
|
|
|
|
|
if (this.listFileNames.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
table = new DataTable();
|
|
|
|
|
|
if (this.tableName == DBHelp.GetTableName<WellCurve>())
|
|
|
|
|
|
{
|
|
|
|
|
|
//需要合并表格
|
|
|
|
|
|
int fail = 0;
|
|
|
|
|
|
foreach (var filepath in this.listFileNames)
|
|
|
|
|
|
{
|
|
|
|
|
|
int rowindex = this.cfg.BeginIndex;
|
|
|
|
|
|
DataTable dt = new DataTable();
|
|
|
|
|
|
this.LoadDataTable(ref dt, filepath, rowindex, true, previewOnly);
|
|
|
|
|
|
if (dt.Columns.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Merge(dt);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
fail++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.listFileNames.Count > fail && fail > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
dataResult.status = ResultStatus.部分成功;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (this.listFileNames.Count == fail)
|
|
|
|
|
|
{
|
|
|
|
|
|
dataResult.status = ResultStatus.失败;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
dataResult.status = ResultStatus.成功;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.cfg.Storage.DataTableShow = table;
|
|
|
|
|
|
this.RecordCount = table.Rows.Count;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
string filepath = this.listFileNames[0];
|
|
|
|
|
|
int rowindex = this.cfg.BeginIndex;
|
|
|
|
|
|
this.LoadDataTable(ref table, filepath, rowindex, true, previewOnly);
|
|
|
|
|
|
this.cfg.Storage.DataTableShow = table;
|
|
|
|
|
|
if (this.RecordCount == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
dataResult.status = ResultStatus.失败;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
dataResult.status = ResultStatus.成功;
|
|
|
|
|
|
dataResult.recordCount = this.RecordCount;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
this.ui.OnReadDataFinish(dataResult);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 读取文件单行预览
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <param name="updateStatus">If true, update status.</param>
|
|
|
|
|
|
public void ReadFileByRowPreview(ref DataTable table, int index, bool updateStatus)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.listFileNames.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index < 0 || index >= this.listFileNames.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
index = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using (SplashHelper.Create())
|
|
|
|
|
|
{
|
|
|
|
|
|
string filepath = this.listFileNames[index];
|
|
|
|
|
|
int rowindex = this.cfg.BeginIndex;
|
|
|
|
|
|
this.cfg.Storage.DataTableShow = new DataTable();
|
|
|
|
|
|
this.LoadDataTable(ref table, filepath, rowindex, true, true);
|
|
|
|
|
|
this.RecordCount = table.Rows.Count;
|
|
|
|
|
|
if (updateStatus)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.RegenerateMatch();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 读取dataTablePaste数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">table</param>
|
|
|
|
|
|
public void ReadPasteData(ref DataTable table)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.cfg.Storage.DataTablePaste != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
using (SplashHelper.Create())
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.cfg.UseHeaderRow)
|
|
|
|
|
|
{
|
|
|
|
|
|
int colcount = 0;
|
|
|
|
|
|
for (int i = 0; i < this.cfg.Storage.DataTablePaste.Columns.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
colcount = 0;
|
|
|
|
|
|
for (int j = i + 1; j < this.cfg.Storage.DataTablePaste.Columns.Count; j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.cfg.Storage.DataTablePaste.Rows[0][i].ToString() == string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox("首行有空值,不能做为列名", "提示");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.cfg.Storage.DataTablePaste.Rows[0][i].ToString()
|
|
|
|
|
|
== this.cfg.Storage.DataTablePaste.Rows[0][j].ToString())
|
|
|
|
|
|
{
|
|
|
|
|
|
colcount++;
|
|
|
|
|
|
if (colcount >= 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox("首行有重复列名", "提示");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
table = new DataTable();
|
|
|
|
|
|
DataHelp.CloneTable(this.cfg.Storage.DataTablePaste, table, this.cfg.UseHeaderRow, count: PreviewLineCount);
|
|
|
|
|
|
this.RecordCount = table.Rows.Count;
|
|
|
|
|
|
LoadDataResult dataResult = new LoadDataResult();
|
|
|
|
|
|
if (this.RecordCount == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
dataResult.status = ResultStatus.失败;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
dataResult.status = ResultStatus.成功;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.ui.OnReadDataFinish(dataResult);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Reads the preview text.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="filepath">The filepath.</param>
|
|
|
|
|
|
/// <param name="rowindex">The rowindex.</param>
|
|
|
|
|
|
/// <param name="rowcount">The rowcount.</param>
|
|
|
|
|
|
/// <returns>A string.</returns>
|
|
|
|
|
|
public string ReadPreviewText(string filepath, int rowindex, int rowcount = PreviewLineCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool isLas = false; /*filepath.EndsWith(".las", StringComparison.OrdinalIgnoreCase);*/
|
|
|
|
|
|
|
|
|
|
|
|
string charset = this.GetFileEncoding(filepath);
|
|
|
|
|
|
|
|
|
|
|
|
using (StreamReader reader = new StreamReader(filepath, Encoding.GetEncoding(charset)))
|
|
|
|
|
|
{
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
if (isLas)
|
|
|
|
|
|
{
|
|
|
|
|
|
while (!reader.EndOfStream)
|
|
|
|
|
|
{
|
|
|
|
|
|
string line = reader.ReadLine();
|
|
|
|
|
|
|
|
|
|
|
|
if (line.StartsWith("~A"))
|
|
|
|
|
|
{
|
|
|
|
|
|
sb.AppendLine(line.Substring(2));
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
while (i < rowcount && !reader.EndOfStream)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (i++ < rowindex)
|
|
|
|
|
|
{
|
|
|
|
|
|
reader.ReadLine();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
sb.AppendLine(reader.ReadLine().Trim());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 具体表导入函数
|
|
|
|
|
|
// 保存井基础
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Saves the data well base.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <param name="append">If true, append.</param>
|
|
|
|
|
|
private void SaveDataWellBase(DataTable table, MatchCache cache, int index, int statrID, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<WellBase>().Max<int>("id") + 1;
|
|
|
|
|
|
string xhid_s = DBHelp.Db.Queryable<WellBase>().Max<string>("xhid");
|
|
|
|
|
|
int xhid = 1;
|
|
|
|
|
|
if (xhid_s != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
xhid = Convert.ToInt32(xhid_s) + 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HashSet<string> origin = this.GetAvailableWellName();
|
|
|
|
|
|
HashSet<string> current = new HashSet<string>();
|
|
|
|
|
|
HashSet<string> deletes = new HashSet<string>();
|
|
|
|
|
|
|
|
|
|
|
|
string colNameJH = cache["JH"]?.MatchColumn;
|
|
|
|
|
|
string colNameWELL_NAME = cache["WELL_NAME"]?.MatchColumn;
|
|
|
|
|
|
string colNameX = cache["X"]?.MatchColumn;
|
|
|
|
|
|
string colNameY = cache["Y"]?.MatchColumn;
|
|
|
|
|
|
string colNameMDCX = cache["MDCX"]?.MatchColumn;
|
|
|
|
|
|
string colNameMDCY = cache["MDCY"]?.MatchColumn;
|
|
|
|
|
|
string colNameBXHB = cache["BXHB"]?.MatchColumn;
|
|
|
|
|
|
string colNameDMHB = cache["DMHB"]?.MatchColumn;
|
|
|
|
|
|
string colNameJB = cache["JB"]?.MatchColumn;
|
|
|
|
|
|
string colNameXSJ = cache["XSJ"]?.MatchColumn;
|
|
|
|
|
|
string colNameYSJ = cache["YSJ"]?.MatchColumn;
|
|
|
|
|
|
string colNameMDCXSJ = cache["MDCXSJ"]?.MatchColumn;
|
|
|
|
|
|
string colNameMDCYSJ = cache["MDCYSJ"]?.MatchColumn;
|
|
|
|
|
|
string colNameYF = cache["YF"]?.MatchColumn;
|
|
|
|
|
|
string colNameQ = cache["Q"]?.MatchColumn;
|
|
|
|
|
|
string colNameBZ = cache["BZ"]?.MatchColumn;
|
|
|
|
|
|
string colNameCXA = cache["CXA"]?.MatchColumn;
|
|
|
|
|
|
string colNameGBRQ = cache["GBRQ"]?.MatchColumn;
|
|
|
|
|
|
string colNameWZJS = cache["WZJS"]?.MatchColumn;
|
|
|
|
|
|
string colNameWZRQ = cache["WZRQ"]?.MatchColumn;
|
|
|
|
|
|
string colNameQKMC = cache["QKMC"]?.MatchColumn;
|
|
|
|
|
|
string colNameCXB = cache["CXB"]?.MatchColumn;
|
|
|
|
|
|
string colNameQKHM = cache["QKHM"]?.MatchColumn;
|
|
|
|
|
|
string colNameMQJB = cache["MQJB"]?.MatchColumn;
|
|
|
|
|
|
string colNameX2 = cache["X2"]?.MatchColumn;
|
|
|
|
|
|
string colNameY2 = cache["Y2"]?.MatchColumn;
|
|
|
|
|
|
string colNameQKDY = cache["QKDY"]?.MatchColumn;
|
|
|
|
|
|
string colNameJWBZ = cache["JWBZ"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
List<WellBase> listObj = new List<WellBase>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
int duplicate = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
WellBase obj = new WellBase();
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameJH) && dr[colNameJH].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.JH = dr[colNameJH].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameWELL_NAME) && dr[colNameWELL_NAME].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.WELL_NAME = dr[colNameWELL_NAME].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果JH为空, 赋值为WELL_NAME
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(obj.JH))
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.JH = obj.WELL_NAME;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果WELL_NAME为空, 赋值为JH
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(obj.WELL_NAME))
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.WELL_NAME = obj.JH;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 追加, 如果数据库中井号已存在, 则跳过
|
|
|
|
|
|
//if (append && origin.Contains(obj.JH))
|
|
|
|
|
|
//{
|
|
|
|
|
|
// continue;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
// 覆盖, 如果数据库中井号已存在, 则增加到删除列表
|
|
|
|
|
|
//else if (origin.Contains(obj.JH) && !string.IsNullOrWhiteSpace(obj.JH))
|
|
|
|
|
|
//{
|
|
|
|
|
|
// deletes.Add(obj.JH);
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果当前数据中, 井号已存在, 则跳过
|
|
|
|
|
|
if (current.Contains(obj.JH))
|
|
|
|
|
|
{
|
|
|
|
|
|
duplicate++;
|
|
|
|
|
|
var filename = this.cfg.ListFileNames[index];
|
|
|
|
|
|
continue;
|
|
|
|
|
|
throw new DataException($"重复井号: '{obj.JH}', 文件: '{filename}'");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果井号不为空, 则添加到当前数据中
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(obj.JH))
|
|
|
|
|
|
{
|
|
|
|
|
|
current.Add(obj.JH);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameX) && dr[colNameX].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (double.TryParse(dr[colNameX].ToString(), out double x))
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.X = x;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameY) && dr[colNameY].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (double.TryParse(dr[colNameY].ToString(), out double y))
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Y = y;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameMDCX) && dr[colNameMDCX].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.MDCX = Convert.ToDouble(dr[colNameMDCX].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameMDCY) && dr[colNameMDCY].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.MDCY = Convert.ToDouble(dr[colNameMDCY].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameBXHB) && dr[colNameBXHB].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.BXHB = Convert.ToDouble(dr[colNameBXHB].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameDMHB) && dr[colNameDMHB].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.DMHB = Convert.ToDouble(dr[colNameDMHB].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameJB) && dr[colNameJB].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.JB = dr[colNameJB].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameXSJ) && dr[colNameXSJ].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.XSJ = Convert.ToDouble(dr[colNameXSJ].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameYSJ) && dr[colNameYSJ].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.YSJ = Convert.ToDouble(dr[colNameYSJ].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameMDCXSJ) && dr[colNameMDCXSJ].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.MDCXSJ = Convert.ToDouble(dr[colNameMDCXSJ].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameMDCYSJ) && dr[colNameMDCYSJ].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.MDCYSJ = Convert.ToDouble(dr[colNameMDCYSJ].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameYF) && dr[colNameYF].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.YF = dr[colNameYF].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameQ) && dr[colNameQ].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Q = dr[colNameQ].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameBZ) && dr[colNameBZ].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.BZ = dr[colNameBZ].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameCXA) && dr[colNameCXA].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.CXA = dr[colNameCXA].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameGBRQ) && dr[colNameGBRQ].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.GBRQ = dr[colNameGBRQ].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameWZJS) && dr[colNameWZJS].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.WZJS = Convert.ToDouble(dr[colNameWZJS].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameWZRQ) && dr[colNameWZRQ].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.WZRQ = dr[colNameWZRQ].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameQKMC) && dr[colNameQKMC].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.QKMC = dr[colNameQKMC].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameCXB) && dr[colNameCXB].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.CXB = dr[colNameCXB].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameQKHM) && dr[colNameQKHM].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.QKHM = dr[colNameQKHM].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameMQJB) && dr[colNameMQJB].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.MQJB = dr[colNameMQJB].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameX2) && dr[colNameX2].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.X2 = Convert.ToDouble(dr[colNameX2].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameY2) && dr[colNameY2].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Y2 = Convert.ToDouble(dr[colNameY2].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameQKDY) && dr[colNameQKDY].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.QKDY = dr[colNameQKDY].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameJWBZ) && dr[colNameJWBZ].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.JWBZ = dr[colNameJWBZ].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 更新井数据
|
|
|
|
|
|
if (origin.Contains(obj.JH))
|
|
|
|
|
|
{
|
|
|
|
|
|
DBHelp.Db.Updateable(obj)
|
|
|
|
|
|
.IgnoreColumns(o => new { o.ID, o.XHID })
|
|
|
|
|
|
.Where(o => o.JH == obj.JH)
|
|
|
|
|
|
.ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
obj.XHID = xhid++;
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Action<SqlSugarClient> prepare = null;
|
|
|
|
|
|
if (!append)
|
|
|
|
|
|
{
|
|
|
|
|
|
prepare = db =>
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (string item in deletes)
|
|
|
|
|
|
{
|
|
|
|
|
|
db.Deleteable<WellBase>(r => r.JH == item).ExecuteCommand();
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj, prepare);
|
|
|
|
|
|
DataHelp.SyncSearchWellName();
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
this.totalDuplicate += duplicate;
|
|
|
|
|
|
|
|
|
|
|
|
if (duplicate > 0 && index == this.listFileNames.Count - 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show($"检测到重复井号数据: {this.totalDuplicate}条!");
|
|
|
|
|
|
this.totalDuplicate = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 保存断点
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <param name="start">The start.</param>
|
|
|
|
|
|
/// <param name="append">If true, append.</param>
|
|
|
|
|
|
private void SaveDataWellBreakPoint(DataTable table, MatchCache cache, int index, int start, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<WellBreakPoint>().Max<int>("id") + 1;
|
|
|
|
|
|
string xhid_s = DBHelp.Db.Queryable<WellBreakPoint>().Max<string>("xhid");
|
|
|
|
|
|
int xhid = 1;
|
|
|
|
|
|
if (xhid_s != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
xhid = Convert.ToInt32(xhid_s) + 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string colNameJH = cache["JH"]?.MatchColumn;
|
|
|
|
|
|
string colNameDCBH = cache["DCBH"]?.MatchColumn;
|
|
|
|
|
|
string colNameDDSD = cache["DDSD"]?.MatchColumn;
|
|
|
|
|
|
string colNameDSDC = cache["DSDC"]?.MatchColumn;
|
|
|
|
|
|
string colNameDSDC2 = cache["DSDC2"]?.MatchColumn;
|
|
|
|
|
|
string colNameDBJDS = cache["DBJDS"]?.MatchColumn;
|
|
|
|
|
|
string colNameDBJDS2 = cache["DBJDS2"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
List<WellBreakPoint> listObj = new List<WellBreakPoint>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
WellBreakPoint obj = new WellBreakPoint();
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameJH) && dr[colNameJH].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.JH = dr[colNameJH].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameDCBH) && dr[colNameDCBH].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.DCBH = dr[colNameDCBH].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameDDSD) && dr[colNameDDSD].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.DDSD = Convert.ToDouble(dr[colNameDDSD].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameDSDC) && dr[colNameDSDC].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.DSDC = dr[colNameDSDC].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameDSDC2) && dr[colNameDSDC2].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.DSDC2 = dr[colNameDSDC2].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameDBJDS) && dr[colNameDBJDS].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.DBJDS = Convert.ToDouble(dr[colNameDBJDS].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameDBJDS2) && dr[colNameDBJDS2].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.DBJDS2 = Convert.ToDouble(dr[colNameDBJDS2].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
obj.XHID = xhid++;
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
DataHelp.UpdateSearchWellName<WellBreakPoint>();
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 保存测井曲线
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <param name="append">The append.</param>
|
|
|
|
|
|
private void SaveDataCurve(DataTable table, MatchCache cache, int index, int start, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
string tableName = DBHelp.GetTableName<WellCurve>();
|
|
|
|
|
|
var colNames = DBHelp.Db.Queryable<TableInfo>().Where(x => SqlFunc.ToLower(x.TableName) == tableName).Select(x => x.ColumnName).ToList();
|
|
|
|
|
|
List<WellCurve> listObj = new List<WellCurve>();
|
|
|
|
|
|
int nCount = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
string block = Path.GetFileNameWithoutExtension(this.listFileNames[index]);
|
|
|
|
|
|
bool isWriteFile = true;
|
|
|
|
|
|
if (isWriteFile)
|
|
|
|
|
|
{
|
|
|
|
|
|
//获取目录创建
|
|
|
|
|
|
string path = Config.ProjectPath + FileHelp.DirWellCurve;
|
|
|
|
|
|
if (!Directory.Exists(path))
|
|
|
|
|
|
{
|
|
|
|
|
|
Directory.CreateDirectory(path);
|
|
|
|
|
|
}
|
|
|
|
|
|
string file = Path.Combine(path, $"{table.TableName}.las");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (StreamWriter wr = new StreamWriter(file))
|
|
|
|
|
|
{
|
|
|
|
|
|
//文件标准头部
|
|
|
|
|
|
wr.WriteLine("~VERSION INFORMATION BLOCK");
|
|
|
|
|
|
wr.WriteLine(" VERS. 2.00: CWLS LOG ASCII STANDARD - VERSION 2.000000");
|
|
|
|
|
|
wr.WriteLine(" WRAP. NO: ONE LINE PER DEPTH STEP");
|
|
|
|
|
|
wr.WriteLine("~WELL INFORMATION BLOCK");
|
|
|
|
|
|
wr.WriteLine("#MNEM.UNIT DATA DESCRIPTION OF MNEMONIC");
|
|
|
|
|
|
wr.WriteLine("#---------- ----------------------------------- -----------------------");
|
|
|
|
|
|
wr.WriteLine(" STRT.M : START DEPTH");
|
|
|
|
|
|
wr.WriteLine(" STOP.M : STOP DEPTH");
|
|
|
|
|
|
wr.WriteLine(" STEP.M : STEP VALUE");
|
|
|
|
|
|
wr.WriteLine(" NULL. : NULL VALUE");
|
|
|
|
|
|
wr.WriteLine(" COMP. : COMPANY NAME");
|
|
|
|
|
|
wr.WriteLine(" WELL. : NULL VALUE");
|
|
|
|
|
|
wr.WriteLine(" FLD . : FIELD NAME");
|
|
|
|
|
|
wr.WriteLine(" LOC . : LOCATION");
|
|
|
|
|
|
wr.WriteLine(" PROV. : PROVINCE");
|
|
|
|
|
|
wr.WriteLine(" SRVC. : SERVICE COMPANY NAME");
|
|
|
|
|
|
wr.WriteLine(" DATE. : DATE");
|
|
|
|
|
|
wr.WriteLine(" UWI . : UNIQUE WELL IDENTIFIER");
|
|
|
|
|
|
wr.WriteLine("~CURVE INFORMATION BLOCK");
|
|
|
|
|
|
wr.WriteLine("#MNEM.UNIT API CODE CURVE DESCRIPTION");
|
|
|
|
|
|
wr.WriteLine("#--------- ------------- ------------------------------");
|
|
|
|
|
|
{ //笨方法写文件
|
|
|
|
|
|
|
|
|
|
|
|
//获取所有左侧名称一对一关系
|
|
|
|
|
|
List<(string, string)> lst = new List<(string, string)>();
|
|
|
|
|
|
foreach (string propName in colNames)
|
|
|
|
|
|
{
|
|
|
|
|
|
//理论上全部存在
|
|
|
|
|
|
if (cache.ContainsMatch(propName))
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = string.Empty;
|
|
|
|
|
|
foreach (var matchItem in cache[propName].MatchColumns)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (table.Columns.Contains(matchItem))
|
|
|
|
|
|
{
|
|
|
|
|
|
lst.Add((propName, matchItem));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//判断是否存在深度
|
|
|
|
|
|
bool isValidDepth = lst.Any(x => x.Item1 == "DEPTH");
|
|
|
|
|
|
if (!isValidDepth)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
//写入表头
|
|
|
|
|
|
string line = string.Empty;
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
int rowIndex = 1;
|
|
|
|
|
|
sb.AppendLine($" DEPTH\t{"."}\t\t:\t1");
|
|
|
|
|
|
foreach (var header in lst)
|
|
|
|
|
|
{
|
|
|
|
|
|
rowIndex++;
|
|
|
|
|
|
if (!header.Item1.Equals("DEPTH"))
|
|
|
|
|
|
{
|
|
|
|
|
|
line += "\t" + header.Item1;
|
|
|
|
|
|
sb.AppendLine($" {header.Item1}\t{"."}\t\t:\t{rowIndex}");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//写入行头
|
|
|
|
|
|
wr.WriteLine(sb.ToString());
|
|
|
|
|
|
wr.WriteLine($"~A DEPTH{line}");
|
|
|
|
|
|
//写入数据
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
string rowGuid = Guid.NewGuid().ToString();
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
bool isValid = false;
|
|
|
|
|
|
double depth = 0;
|
|
|
|
|
|
//判断当前行的深度是否有效
|
|
|
|
|
|
foreach (var matchItem in cache["DEPTH"].MatchColumns)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (table.Columns.Contains(matchItem))
|
|
|
|
|
|
{
|
|
|
|
|
|
string v_depth = dr[matchItem].ToString();
|
|
|
|
|
|
if (double.TryParse(v_depth, out depth))
|
|
|
|
|
|
{
|
|
|
|
|
|
isValid = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!isValid)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
//写入深度第一列
|
|
|
|
|
|
string lineData = string.Empty;
|
|
|
|
|
|
lineData += $"{depth}";
|
|
|
|
|
|
foreach (var head in lst)
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = string.Empty;
|
|
|
|
|
|
if (head.Item1 == "DEPTH")
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
value = dr[head.Item2].ToString();
|
|
|
|
|
|
lineData += "\t" + value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//源文件存在错误数据
|
|
|
|
|
|
lineData = lineData.Replace("--9", "-9");
|
|
|
|
|
|
wr.WriteLine(lineData);
|
|
|
|
|
|
nCount++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
WellCurveFile wellCurveFile = new WellCurveFile()
|
|
|
|
|
|
{
|
|
|
|
|
|
JH = table.TableName,
|
|
|
|
|
|
Columns = string.Empty,
|
|
|
|
|
|
FilePath = FileHelp.Convert2RelativePath(file),
|
|
|
|
|
|
};
|
|
|
|
|
|
DBHelp.NewDb.Insertable(wellCurveFile).ExecuteCommand();
|
|
|
|
|
|
this.importNum++;
|
|
|
|
|
|
DataHelp.UpdateSearchWellName<WellCurveFile>();
|
|
|
|
|
|
}
|
|
|
|
|
|
//聪明方法写文件
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nCount;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 保存压裂参数
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <param name="append">If true, append.</param>
|
|
|
|
|
|
private void SaveDataHoriWellFractParm(DataTable table, MatchCache cache, int index, int start, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.UpdateAppend)
|
|
|
|
|
|
{
|
|
|
|
|
|
//更新操作
|
|
|
|
|
|
List<EntityColumnInfo> columns = DBHelp.GetEntityColumnInfo(typeof(HoriWellFracturParameter));
|
|
|
|
|
|
List<HoriWellFracturParameter> listObj = new List<HoriWellFracturParameter>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
string block = Path.GetFileNameWithoutExtension(this.listFileNames[index]);
|
|
|
|
|
|
|
|
|
|
|
|
List<string> array = new List<string>();
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
HoriWellFracturParameter obj = new HoriWellFracturParameter();
|
|
|
|
|
|
foreach (EntityColumnInfo col in columns)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cache.ContainsMatch(col.DbColumnName))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!array.Contains(col.DbColumnName))
|
|
|
|
|
|
{
|
|
|
|
|
|
array.Add(col.DbColumnName);
|
|
|
|
|
|
}
|
|
|
|
|
|
object obj2 = dr[cache[col.DbColumnName].MatchColumn];
|
|
|
|
|
|
if (obj2 != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = obj2.ToString();
|
|
|
|
|
|
this.SetPropertyData(col.PropertyInfo, obj, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
string[] whereColumns = { "JH", "XHID" };
|
|
|
|
|
|
if (array.Intersect(whereColumns.ToList()).Count() == whereColumns.Count())
|
|
|
|
|
|
{
|
|
|
|
|
|
DBHelp.NewDb.Fastest<HoriWellFracturParameter>().BulkUpdate(listObj, whereColumns, array.ToArray());
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
string tableName = DBHelp.GetTableName<HoriWellFracturParameter>();
|
|
|
|
|
|
var colNames = DBHelp.Db.Queryable<TableInfo>().Where(x => SqlFunc.ToLower(x.TableName) == tableName).Select(x => x.ColumnName).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
List<HoriWellFracturParameter> listObj = new List<HoriWellFracturParameter>();
|
|
|
|
|
|
int nCount = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
string block = Path.GetFileNameWithoutExtension(this.listFileNames[index]);
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<HoriWellFracturParameter>().Max<int>(x => x.RowID) + 1;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
DataTable tb = table;
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
string rowGuid = Guid.NewGuid().ToString();
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
HoriWellFracturParameter obj = new HoriWellFracturParameter();
|
|
|
|
|
|
//判断
|
|
|
|
|
|
Dictionary<string, string> pairs = new Dictionary<string, string>();
|
|
|
|
|
|
bool isOK = true;
|
|
|
|
|
|
foreach (string propName in colNames)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cache.ContainsMatch(propName))
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = string.Empty;
|
|
|
|
|
|
foreach (var matchItem in cache[propName].MatchColumns)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (table.Columns.Contains(matchItem))
|
|
|
|
|
|
{
|
|
|
|
|
|
value = dr[matchItem].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (propName == "JH")
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.JH = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (propName == "XHID")
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.XHID = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (propName == "SYWZ1")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (double.TryParse(value, out double z1))
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.SYWZ1 = z1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
isOK = false;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (propName == "SYWZ2")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (double.TryParse(value, out double z2))
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.SYWZ2 = z2;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
isOK = false;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
pairs.Add(propName, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
isOK = false;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (isOK)
|
|
|
|
|
|
{
|
|
|
|
|
|
id++;
|
|
|
|
|
|
obj.RowID = id;
|
|
|
|
|
|
obj.RowGuid = rowGuid;
|
|
|
|
|
|
obj.ColumnValue = Newtonsoft.Json.JsonConvert.SerializeObject(pairs);
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
nCount++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<string> noSYWZJHs = new List<string>();
|
|
|
|
|
|
var groupedByJh = listObj.GroupBy(x => x.JH)
|
|
|
|
|
|
.ToDictionary(g => g.Key, g => g.ToList());
|
|
|
|
|
|
foreach (var kv in groupedByJh)
|
|
|
|
|
|
{
|
|
|
|
|
|
string jh = kv.Key;
|
|
|
|
|
|
var newList = kv.Value;
|
|
|
|
|
|
bool newSYWZ1AllNull = newList.All(item => item.SYWZ1 == null);
|
|
|
|
|
|
bool newSYWZ2AllNull = newList.All(item => item.SYWZ2 == null);
|
|
|
|
|
|
|
|
|
|
|
|
if (newSYWZ1AllNull || newSYWZ2AllNull)
|
|
|
|
|
|
{
|
|
|
|
|
|
noSYWZJHs.Add(jh);
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(newList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (noSYWZJHs.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
noSYWZJHs = noSYWZJHs.Distinct().ToList();
|
|
|
|
|
|
foreach (string jh in noSYWZJHs)
|
|
|
|
|
|
{
|
|
|
|
|
|
nCount -= table.AsEnumerable().Count(row => row.Field<string>("井号") == jh);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MessageBox.Show(string.Join(", ", noSYWZJHs) + "无法导入,不含试油顶深或者试油底深!", "提示");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nCount;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 保存压裂坐标
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <param name="append">If true, append.</param>
|
|
|
|
|
|
private void SaveDataHoriWellFractCoord(DataTable table, MatchCache cache, int index, int start, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<HoriWellFracturCoord>().Max<int>("id") + 1;
|
|
|
|
|
|
List<EntityColumnInfo> columns = DBHelp.GetEntityColumnInfo(typeof(HoriWellFracturCoord));
|
|
|
|
|
|
List<HoriWellFracturCoord> listObj = new List<HoriWellFracturCoord>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
string block = Path.GetFileNameWithoutExtension(this.listFileNames[index]);
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
HoriWellFracturCoord obj = new HoriWellFracturCoord();
|
|
|
|
|
|
foreach (EntityColumnInfo col in columns)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cache.ContainsMatch(col.DbColumnName))
|
|
|
|
|
|
{
|
|
|
|
|
|
object obj2 = dr[cache[col.DbColumnName].MatchColumn];
|
|
|
|
|
|
if (obj2 != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = obj2.ToString();
|
|
|
|
|
|
this.SetPropertyData(col.PropertyInfo, obj, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 追加压裂参数
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <param name="append">If true, append.</param>
|
|
|
|
|
|
private void AddDataHoriWellFractParm(DataTable table, MatchCache cache)
|
|
|
|
|
|
{
|
|
|
|
|
|
string tableName = DBHelp.GetTableName<HoriWellFracturParameter>();
|
|
|
|
|
|
var colNames = DBHelp.Db.Queryable<TableInfo>().Where(x => SqlFunc.ToLower(x.TableName) == tableName).Select(x => x.ColumnName).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
List<HoriWellFracturParameter> listObj = new List<HoriWellFracturParameter>();
|
|
|
|
|
|
int nCount = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<HoriWellFracturParameter>().Max<int>(x => x.RowID) + 1;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
string rowGuid = Guid.NewGuid().ToString();
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
HoriWellFracturParameter obj = new HoriWellFracturParameter();
|
|
|
|
|
|
//判断
|
|
|
|
|
|
Dictionary<string, string> pairs = new Dictionary<string, string>();
|
|
|
|
|
|
bool isOK = true;
|
|
|
|
|
|
foreach (string propName in colNames)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cache.ContainsMatch(propName))
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = string.Empty;
|
|
|
|
|
|
foreach (var matchItem in cache[propName].MatchColumns)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (table.Columns.Contains(matchItem))
|
|
|
|
|
|
{
|
|
|
|
|
|
value = dr[matchItem].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (propName == "JH")
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.JH = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (propName == "XHID")
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.XHID = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (propName == "SYWZ1")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (double.TryParse(value, out double z1))
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.SYWZ1 = z1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
isOK = false;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (propName == "SYWZ2")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (double.TryParse(value, out double z2))
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.SYWZ2 = z2;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
isOK = false;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
pairs.Add(propName, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
isOK = false;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (isOK)
|
|
|
|
|
|
{
|
|
|
|
|
|
id++;
|
|
|
|
|
|
obj.RowID = id;
|
|
|
|
|
|
obj.RowGuid = rowGuid;
|
|
|
|
|
|
obj.ColumnValue = Newtonsoft.Json.JsonConvert.SerializeObject(pairs);
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
nCount++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 分组按井号
|
|
|
|
|
|
var groupedByJh = listObj.GroupBy(x => x.JH)
|
|
|
|
|
|
.ToDictionary(g => g.Key, g => g.ToList());
|
|
|
|
|
|
|
|
|
|
|
|
List<string> noSYWZJHs = new List<string>();
|
|
|
|
|
|
foreach (var kv in groupedByJh)
|
|
|
|
|
|
{
|
|
|
|
|
|
string jh = kv.Key;
|
|
|
|
|
|
var newList = kv.Value;
|
|
|
|
|
|
|
|
|
|
|
|
// 已存在的记录(按JH取出)
|
|
|
|
|
|
var existingRecords = DBHelp.Db.Queryable<HoriWellFracturParameter>()
|
|
|
|
|
|
.Where(x => x.JH == jh)
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
if (this.IsSYWZMissing(existingRecords, newList))
|
|
|
|
|
|
{
|
|
|
|
|
|
noSYWZJHs.Add(jh);
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (string propName in colNames)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cache.ContainsMatch(propName))
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = string.Empty;
|
|
|
|
|
|
foreach (var matchItem in cache[propName].MatchColumns)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (table.Columns.Contains(matchItem))
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Columns[matchItem].ColumnName = propName;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (existingRecords.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var existing in existingRecords)
|
|
|
|
|
|
{
|
|
|
|
|
|
var matchedRow = table.AsEnumerable()
|
|
|
|
|
|
.FirstOrDefault(r => r.Field<string>("JH") == existing.JH &&
|
|
|
|
|
|
r.Field<string>("XHID") == existing.XHID);
|
|
|
|
|
|
|
|
|
|
|
|
if (matchedRow == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var originalData = JsonConvert.DeserializeObject<Dictionary<string, string>>(existing.ColumnValue ?? "{}");
|
|
|
|
|
|
|
|
|
|
|
|
foreach (DataColumn col in table.Columns)
|
|
|
|
|
|
{
|
|
|
|
|
|
string colName = col.ColumnName;
|
|
|
|
|
|
if (colName == "JH" || colName == "XHID" || colName == "SYWZ1" || colName == "SYWZ2")
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
originalData[colName] = matchedRow[colName]?.ToString() ?? string.Empty;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
existing.ColumnValue = JsonConvert.SerializeObject(originalData);
|
|
|
|
|
|
DBHelp.NewDb.Updateable<HoriWellFracturParameter>().SetColumns(x => x.ColumnValue == existing.ColumnValue).Where(x => x.RowID == existing.RowID).ExecuteCommand();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(newList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (noSYWZJHs.Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
MessageBox.Show(string.Join(", ", noSYWZJHs) + "无法导入,不含试油顶深或者试油底深!", "提示");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nCount;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void SaveWellLithology(DataTable table, MatchCache cache, int index, int start, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<WellLithology>().Max<int>("id") + 1;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameJH = cache["well"]?.MatchColumn;
|
|
|
|
|
|
string colNametop = cache["top"]?.MatchColumn;
|
|
|
|
|
|
string colNamebottom = cache["bottom"]?.MatchColumn;
|
|
|
|
|
|
string colNamethickness = cache["thickness"]?.MatchColumn;
|
|
|
|
|
|
string colNamecolor = cache["color"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameoilcontent = cache["oilcontent"]?.MatchColumn;
|
|
|
|
|
|
string colNameinclusions = cache["inclusions"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNamelithologyprefix = cache["lithologyprefix"]?.MatchColumn;
|
|
|
|
|
|
string colNamestructure = cache["structure"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNamelithology = cache["lithology"]?.MatchColumn;
|
|
|
|
|
|
string colNamefistlayer = cache["firstlayer"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNamesecondlayer = cache["secondlayer"]?.MatchColumn;
|
|
|
|
|
|
string colNamethirdlayer = cache["thirdlayer"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNamefourthlayer = cache["fourthlayer"]?.MatchColumn;
|
|
|
|
|
|
string colNamefifthlayer = cache["fifthlayer"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNamelithologyname = cache["lithologyname"]?.MatchColumn;
|
|
|
|
|
|
string colNamemarkerlayerr = cache["markerlayer"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
List<WellLithology> listObj = new List<WellLithology>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
WellLithology obj = new WellLithology();
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameJH) && dr[colNameJH].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Well = dr[colNameJH].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNametop) && dr[colNametop].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.top = Convert.ToDouble(dr[colNametop].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamebottom) && dr[colNamebottom].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.bottom = Convert.ToDouble(dr[colNamebottom].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamethickness) && dr[colNamethickness].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.thickness = Convert.ToDouble(dr[colNamethickness].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamecolor) && dr[colNamecolor].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.color = dr[colNamecolor].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameoilcontent) && dr[colNameoilcontent].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.oilcontent = dr[colNamecolor].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameinclusions) && dr[colNameinclusions].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.inclusions = dr[colNameinclusions].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamelithologyprefix) && dr[colNamelithologyprefix].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.lithologyprefix = dr[colNamelithologyprefix].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamestructure) && dr[colNamestructure].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.structure = dr[colNamestructure].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamelithology) && dr[colNamelithology].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.lithology = dr[colNamelithology].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamefistlayer) && dr[colNamefistlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.firstlayer = dr[colNamefistlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamesecondlayer) && dr[colNamesecondlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.secondlayer = dr[colNamesecondlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamethirdlayer) && dr[colNamethirdlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.thirdlayer = dr[colNamethirdlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamefourthlayer) && dr[colNamefourthlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.fourthlayer = dr[colNamefourthlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamefifthlayer) && dr[colNamefifthlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.fourthlayer = dr[colNamefifthlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamelithologyname) && dr[colNamelithologyname].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.lithologyname = dr[colNamelithologyname].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamemarkerlayerr) && dr[colNamemarkerlayerr].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.markerlayer = dr[colNamemarkerlayerr].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// obj.XHID = xhid++;
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
DataHelp.UpdateSearchWellName<WellLithology>();
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SaveCycleLongterm(DataTable table, MatchCache cache, int index, int start, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<CycleLongterm>().Max<int>("id") + 1;
|
|
|
|
|
|
string colNameJH = cache["well"]?.MatchColumn;
|
|
|
|
|
|
string colNametop = cache["top"]?.MatchColumn;
|
|
|
|
|
|
string colNamebottom = cache["bottom"]?.MatchColumn;
|
|
|
|
|
|
string colNametype = cache["type"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
List<CycleLongterm> listObj = new List<CycleLongterm>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
CycleLongterm obj = new CycleLongterm();
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameJH) && dr[colNameJH].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Well = dr[colNameJH].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNametop) && dr[colNametop].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.top = Convert.ToDouble(dr[colNametop].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamebottom) && dr[colNamebottom].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.bottom = Convert.ToDouble(dr[colNamebottom].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNametype) && dr[colNametype].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.type = dr[colNametype].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
DataHelp.UpdateSearchWellName<CycleLongterm>();
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SaveCycleMediumterm(DataTable table, MatchCache cache, int index, int start, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<CycleMediumterm>().Max<int>("id") + 1;
|
|
|
|
|
|
string colNameJH = cache["well"]?.MatchColumn;
|
|
|
|
|
|
string colNametop = cache["top"]?.MatchColumn;
|
|
|
|
|
|
string colNamebottom = cache["bottom"]?.MatchColumn;
|
|
|
|
|
|
string colNametype = cache["type"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
List<CycleMediumterm> listObj = new List<CycleMediumterm>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
CycleMediumterm obj = new CycleMediumterm();
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameJH) && dr[colNameJH].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Well = dr[colNameJH].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNametop) && dr[colNametop].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.top = Convert.ToDouble(dr[colNametop].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamebottom) && dr[colNamebottom].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.bottom = Convert.ToDouble(dr[colNamebottom].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNametype) && dr[colNametype].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.type = dr[colNametype].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
DataHelp.UpdateSearchWellName<CycleMediumterm>();
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SaveCycleShortterm(DataTable table, MatchCache cache, int index, int start, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<CycleShortterm>().Max<int>("id") + 1;
|
|
|
|
|
|
string colNameJH = cache["well"]?.MatchColumn;
|
|
|
|
|
|
string colNametop = cache["top"]?.MatchColumn;
|
|
|
|
|
|
string colNamebottom = cache["bottom"]?.MatchColumn;
|
|
|
|
|
|
string colNametype = cache["type"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
List<CycleShortterm> listObj = new List<CycleShortterm>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
CycleShortterm obj = new CycleShortterm();
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameJH) && dr[colNameJH].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Well = dr[colNameJH].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNametop) && dr[colNametop].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.top = Convert.ToDouble(dr[colNametop].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamebottom) && dr[colNamebottom].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.bottom = Convert.ToDouble(dr[colNamebottom].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNametype) && dr[colNametype].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.type = dr[colNametype].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
DataHelp.UpdateSearchWellName<CycleShortterm>();
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
//SaveWellInnerLayer
|
|
|
|
|
|
private void SaveWellInnerLayer(DataTable table, MatchCache cache, int index, int start, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<WellInnerLayer>().Max<int>("id") + 1;
|
|
|
|
|
|
string colNameJH = cache["well"]?.MatchColumn;
|
|
|
|
|
|
string colNametop = cache["top"]?.MatchColumn;
|
|
|
|
|
|
string colNamebottom = cache["bottom"]?.MatchColumn;
|
|
|
|
|
|
string colNamethickness = cache["thickness"]?.MatchColumn;
|
|
|
|
|
|
string colNametype = cache["type"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
List<WellInnerLayer> listObj = new List<WellInnerLayer>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
WellInnerLayer obj = new WellInnerLayer();
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameJH) && dr[colNameJH].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Well = dr[colNameJH].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNametop) && dr[colNametop].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.top = Convert.ToDouble(dr[colNametop].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamebottom) && dr[colNamebottom].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.bottom = Convert.ToDouble(dr[colNamebottom].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamethickness) && dr[colNamethickness].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.thickness = Convert.ToDouble(dr[colNamethickness].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNametype) && dr[colNametype].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.type = dr[colNametype].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
DataHelp.UpdateSearchWellName<WellInnerLayer>();
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SaveWellReservesLayer(DataTable table, MatchCache cache, int index, int start, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<WellReservesLayer>().Max<int>("id") + 1;
|
|
|
|
|
|
string colNameJH = cache["well"]?.MatchColumn;
|
|
|
|
|
|
string colNameLayer = cache["Layer"]?.MatchColumn;
|
|
|
|
|
|
string colNameXzb = cache["XCoordinate"]?.MatchColumn;
|
|
|
|
|
|
string colNameYzb = cache["YCoordinate"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameTop2 = cache["TopSecondSandstone"]?.MatchColumn;
|
|
|
|
|
|
string colNameBot2 = cache["BottomSecondSandstone"]?.MatchColumn;
|
|
|
|
|
|
string colNamethick2 = cache["ThicknessSecondSandstone"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameTop1 = cache["TopFirstSandstone"]?.MatchColumn;
|
|
|
|
|
|
string colNameBot1 = cache["BottomFirstSandstone"]?.MatchColumn;
|
|
|
|
|
|
string colNamethick1 = cache["ThicknessFirstSandstone"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameTopView = cache["ViewEffectiveTop"]?.MatchColumn;
|
|
|
|
|
|
string colNamethickView = cache["ViewEffectiveThickness"]?.MatchColumn;
|
|
|
|
|
|
string colNameTopPure = cache["PureEffectiveTopEstimate"]?.MatchColumn;
|
|
|
|
|
|
string colNamethickPure = cache["PureEffectiveThicknessEstimate"]?.MatchColumn;
|
|
|
|
|
|
string colNameECategory = cache["EffectiveCategory"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNamePorosity = cache["Porosity"]?.MatchColumn;
|
|
|
|
|
|
string colNamePermeability = cache["Permeability"]?.MatchColumn;
|
|
|
|
|
|
string colNameClayContent = cache["ClayContent"]?.MatchColumn;
|
|
|
|
|
|
string colNameOilSaturation = cache["OilSaturation"]?.MatchColumn;
|
|
|
|
|
|
string colNameMobileOilSaturation = cache["MobileOilSaturation"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameWaterSaturation = cache["WaterSaturation"]?.MatchColumn;
|
|
|
|
|
|
string colNameElectricLogInterpretation = cache["ElectricLogInterpretation"]?.MatchColumn;
|
|
|
|
|
|
string colNamePerforationStatus = cache["PerforationStatus"]?.MatchColumn;
|
|
|
|
|
|
string colNameWaterFloodingInterpretation = cache["WaterFloodingInterpretation"]?.MatchColumn;
|
|
|
|
|
|
string colNameFacies = cache["Facies"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameLithology = cache["Lithology"]?.MatchColumn;
|
|
|
|
|
|
string colNameInterpretationNumber = cache["InterpretationNumber"]?.MatchColumn;
|
|
|
|
|
|
string colNameXCoordinateSandstoneTop = cache["XCoordinateSandstoneTop"]?.MatchColumn;
|
|
|
|
|
|
string colNameYCoordinateSandstoneTop = cache["YCoordinateSandstoneTop"]?.MatchColumn;
|
|
|
|
|
|
string colNameGasSaturation = cache["GasSaturation"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameWaterFloodingValue = cache["WaterFloodingValue"]?.MatchColumn;
|
|
|
|
|
|
string colNameSubfacies = cache["Subfacies"]?.MatchColumn;
|
|
|
|
|
|
string colNameFlowUnit = cache["FlowUnit"]?.MatchColumn;
|
|
|
|
|
|
string colNameBoundWaterSaturation = cache["BoundWaterSaturation"]?.MatchColumn;
|
|
|
|
|
|
string colNameWaterInjectionVolume = cache["WaterInjectionVolume"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNamePermeabilityGradient = cache["PermeabilityGradient"]?.MatchColumn;
|
|
|
|
|
|
string colNamePermeabilityBreakthrough = cache["PermeabilityBreakthrough"]?.MatchColumn;
|
|
|
|
|
|
string colNamePermeabilityVariance = cache["PermeabilityVariance"]?.MatchColumn;
|
|
|
|
|
|
string colNameAirPermability = cache["AirPermability"]?.MatchColumn;
|
|
|
|
|
|
string colNameAirPermability1 = cache["AirPermability1"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameEffectivePermability = cache["EffectivePermability"]?.MatchColumn;
|
|
|
|
|
|
string colNameEffectivePermability1 = cache["EffectivePermability1"]?.MatchColumn;
|
|
|
|
|
|
string colNameOriginalWaterSaturation = cache["OriginalWaterSaturation"]?.MatchColumn;
|
|
|
|
|
|
string colNameRecoveryDegree = cache["RecoveryDegree"]?.MatchColumn;
|
|
|
|
|
|
string colNameCalciumContent = cache["CalciumContent"]?.MatchColumn;
|
|
|
|
|
|
string colNameGravelContent = cache["GravelContent"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
List<WellReservesLayer> listObj = new List<WellReservesLayer>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
WellReservesLayer obj = new WellReservesLayer();
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameJH) && dr[colNameJH].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Well = dr[colNameJH].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameLayer) && dr[colNameLayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Layer = dr[colNameLayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameXzb) && dr[colNameXzb].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.XCoordinate = Convert.ToDouble(dr[colNameXzb].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameYzb) && dr[colNameYzb].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.YCoordinate = Convert.ToDouble(dr[colNameYzb].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameTop2) && dr[colNameTop2].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.TopSecondSandstone = Convert.ToDouble(dr[colNameTop2].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameBot2) && dr[colNameBot2].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.BottomSecondSandstone = Convert.ToDouble(dr[colNameBot2].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamethick2) && dr[colNamethick2].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.ThicknessSecondSandstone = Convert.ToDouble(dr[colNamethick2].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameTop1) && dr[colNameTop1].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.TopFirstSandstone = Convert.ToDouble(dr[colNameTop1].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameBot1) && dr[colNameBot1].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.BottomFirstSandstone = Convert.ToDouble(dr[colNameBot1].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamethick1) && dr[colNamethick1].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.ThicknessFirstSandstone = Convert.ToDouble(dr[colNamethick1].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameTopView) && dr[colNameTopView].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.ViewEffectiveTop = Convert.ToDouble(dr[colNameTopView].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamethickView) && dr[colNamethickView].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.ViewEffectiveThickness = Convert.ToDouble(dr[colNamethickView].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameTopPure) && dr[colNameTopPure].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.PureEffectiveTopEstimate = Convert.ToDouble(dr[colNameTopPure].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamethickPure) && dr[colNamethickPure].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.PureEffectiveThicknessEstimate = Convert.ToDouble(dr[colNamethickPure].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameECategory) && dr[colNameECategory].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.EffectiveCategory = dr[colNameECategory].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamePorosity) && dr[colNamePorosity].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Porosity = Convert.ToDouble(dr[colNamePorosity].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamePermeability) && dr[colNamePermeability].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Permeability = Convert.ToDouble(dr[colNamePermeability].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameClayContent) && dr[colNameClayContent].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.ClayContent = Convert.ToDouble(dr[colNameClayContent].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameOilSaturation) && dr[colNameOilSaturation].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.OilSaturation = Convert.ToDouble(dr[colNameOilSaturation].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameMobileOilSaturation) && dr[colNameMobileOilSaturation].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.MobileOilSaturation = Convert.ToDouble(dr[colNameMobileOilSaturation].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameWaterSaturation) && dr[colNameWaterSaturation].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.WaterSaturation = Convert.ToDouble(dr[colNameWaterSaturation].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameElectricLogInterpretation) && dr[colNameElectricLogInterpretation].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.ElectricLogInterpretation = dr[colNameElectricLogInterpretation].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamePerforationStatus) && dr[colNamePerforationStatus].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.PerforationStatus = dr[colNamePerforationStatus].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameWaterFloodingInterpretation) && dr[colNameWaterFloodingInterpretation].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.WaterFloodingInterpretation = dr[colNameWaterFloodingInterpretation].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameFacies) && dr[colNameFacies].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Facies = dr[colNameFacies].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameLithology) && dr[colNameLithology].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Lithology = dr[colNameLithology].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameInterpretationNumber) && dr[colNameInterpretationNumber].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.InterpretationNumber = dr[colNameInterpretationNumber].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameXCoordinateSandstoneTop) && dr[colNameXCoordinateSandstoneTop].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.XCoordinateSandstoneTop = Convert.ToDouble(dr[colNameXCoordinateSandstoneTop].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameYCoordinateSandstoneTop) && dr[colNameYCoordinateSandstoneTop].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.YCoordinateSandstoneTop = Convert.ToDouble(dr[colNameYCoordinateSandstoneTop].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameGasSaturation) && dr[colNameGasSaturation].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.GasSaturation = Convert.ToDouble(dr[colNameGasSaturation].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameWaterFloodingValue) && dr[colNameWaterFloodingValue].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.WaterFloodingValue = Convert.ToDouble(dr[colNameWaterFloodingValue].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameSubfacies) && dr[colNameSubfacies].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Subfacies = dr[colNameSubfacies].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameFlowUnit) && dr[colNameFlowUnit].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.FlowUnit = dr[colNameFlowUnit].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameBoundWaterSaturation) && dr[colNameBoundWaterSaturation].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.BoundWaterSaturation = Convert.ToDouble(dr[colNameBoundWaterSaturation].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameWaterInjectionVolume) && dr[colNameWaterInjectionVolume].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.WaterInjectionVolume = Convert.ToDouble(dr[colNameWaterInjectionVolume].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamePermeabilityGradient) && dr[colNamePermeabilityGradient].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.PermeabilityGradient = Convert.ToDouble(dr[colNamePermeabilityGradient].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamePermeabilityBreakthrough) && dr[colNamePermeabilityBreakthrough].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.PermeabilityBreakthrough = Convert.ToDouble(dr[colNamePermeabilityBreakthrough].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamePermeabilityVariance) && dr[colNamePermeabilityVariance].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.PermeabilityVariance = Convert.ToDouble(dr[colNamePermeabilityVariance].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameAirPermability) && dr[colNameAirPermability].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.AirPermability = Convert.ToDouble(dr[colNameAirPermability].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameAirPermability1) && dr[colNameAirPermability1].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.AirPermability1 = (dr[colNameAirPermability1].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameEffectivePermability) && dr[colNameEffectivePermability].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.EffectivePermability = Convert.ToDouble(dr[colNameEffectivePermability].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameEffectivePermability1) && dr[colNameEffectivePermability1].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.EffectivePermability1 = (dr[colNameEffectivePermability1].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameOriginalWaterSaturation) && dr[colNameOriginalWaterSaturation].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.OriginalWaterSaturation = Convert.ToDouble(dr[colNameOriginalWaterSaturation].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameRecoveryDegree) && dr[colNameRecoveryDegree].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.RecoveryDegree = Convert.ToDouble(dr[colNameRecoveryDegree].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameCalciumContent) && dr[colNameCalciumContent].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.CalciumContent = Convert.ToDouble(dr[colNameCalciumContent].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameGravelContent) && dr[colNameGravelContent].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.GravelContent = Convert.ToDouble(dr[colNameGravelContent].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
DataHelp.UpdateSearchWellName<WellReservesLayer>();
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool IsSYWZMissing(List<HoriWellFracturParameter> existingRecords, List<HoriWellFracturParameter> newRecords)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool existingSYWZ1AllNull = existingRecords.All(item => item.SYWZ1 == null);
|
|
|
|
|
|
bool existingSYWZ2AllNull = existingRecords.All(item => item.SYWZ2 == null);
|
|
|
|
|
|
bool newSYWZ1AllNull = newRecords.All(item => item.SYWZ1 == null);
|
|
|
|
|
|
bool newSYWZ2AllNull = newRecords.All(item => item.SYWZ2 == null);
|
|
|
|
|
|
|
|
|
|
|
|
return (existingSYWZ1AllNull || existingSYWZ2AllNull) &&
|
|
|
|
|
|
(newSYWZ1AllNull || newSYWZ2AllNull);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SaveWellCoring(DataTable table, MatchCache cache, int index, int start, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<WellCoring>().Max<int>("id") + 1;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameJH = cache["well"]?.MatchColumn;
|
|
|
|
|
|
string colNametop = cache["top"]?.MatchColumn;
|
|
|
|
|
|
string colNamebottom = cache["bottom"]?.MatchColumn;
|
|
|
|
|
|
string colNameMethod = cache["method"]?.MatchColumn;
|
|
|
|
|
|
string colNameDate = cache["date"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameLayer = cache["layer"]?.MatchColumn;
|
|
|
|
|
|
string colNameLength = cache["length"]?.MatchColumn;
|
|
|
|
|
|
string colNameDiameter = cache["diameter"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNametimes = cache["times"]?.MatchColumn;
|
|
|
|
|
|
string colNameoilsaturatedlength = cache["oilsaturatedlength"]?.MatchColumn;
|
|
|
|
|
|
string colNamefistlayer = cache["firstlayer"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNamesecondlayer = cache["secondlayer"]?.MatchColumn;
|
|
|
|
|
|
string colNamethirdlayer = cache["thirdlayer"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
List<WellCoring> listObj = new List<WellCoring>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
WellCoring obj = new WellCoring();
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameJH) && dr[colNameJH].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Well = dr[colNameJH].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNametop) && dr[colNametop].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.top = Convert.ToDouble(dr[colNametop].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamebottom) && dr[colNamebottom].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.bottom = Convert.ToDouble(dr[colNamebottom].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameDate) && dr[colNameDate].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.date = dr[colNameDate].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameMethod) && dr[colNameMethod].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.method = dr[colNameMethod].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameLayer) && dr[colNameLayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.layer= dr[colNameLayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameLength) && dr[colNameLength].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.length = Convert.ToDouble(dr[colNameLength].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameDiameter) && dr[colNameDiameter].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.diameter = Convert.ToDouble(dr[colNameDiameter].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNametimes) && dr[colNametimes].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.times = Convert.ToInt32(dr[colNametimes].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameoilsaturatedlength) && dr[colNameoilsaturatedlength].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.oilsaturatedlength = Convert.ToDouble(dr[colNameoilsaturatedlength].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamefistlayer) && dr[colNamefistlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.firstlayer = dr[colNamefistlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamesecondlayer) && dr[colNamesecondlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.secondlayer = dr[colNamesecondlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamethirdlayer) && dr[colNamethirdlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.thirdlayer = dr[colNamethirdlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// obj.XHID = xhid++;
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
DataHelp.UpdateSearchWellName<WellCoring>();
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SaveWellWaterInjection(DataTable table, MatchCache cache, int index, int start, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<WellWaterInjection>().Max<int>("id") + 1;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameJH = cache["well"]?.MatchColumn;
|
|
|
|
|
|
string colNametop = cache["top"]?.MatchColumn;
|
|
|
|
|
|
string colNamebottom = cache["bottom"]?.MatchColumn;
|
|
|
|
|
|
string colNameDate = cache["date"]?.MatchColumn;
|
|
|
|
|
|
string colNameLayer = cache["layer"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameDaily = cache["dailyinjection"]?.MatchColumn;
|
|
|
|
|
|
string colNameInjectionpercentage = cache["injectionpercentage"]?.MatchColumn;
|
|
|
|
|
|
string colNameInjectionpressure = cache["injectionpressure"]?.MatchColumn;
|
|
|
|
|
|
string colNameInjectionintesity = cache["injectionintesity"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameWaterabsorptionrate = cache["waterabsorptionrate"]?.MatchColumn;
|
|
|
|
|
|
string colNameShutoff = cache["shutoff"]?.MatchColumn;
|
|
|
|
|
|
string colNameSandthickness = cache["sandthickness"]?.MatchColumn;
|
|
|
|
|
|
string colNameEffectionthickness = cache["effectionthickness"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNamefistlayer = cache["firstlayer"]?.MatchColumn;
|
|
|
|
|
|
string colNamesecondlayer = cache["secondlayer"]?.MatchColumn;
|
|
|
|
|
|
string colNamethirdlayer = cache["thirdlayer"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
List<WellWaterInjection> listObj = new List<WellWaterInjection>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
WellWaterInjection obj = new WellWaterInjection();
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameJH) && dr[colNameJH].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Well = dr[colNameJH].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNametop) && dr[colNametop].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.top = Convert.ToDouble(dr[colNametop].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamebottom) && dr[colNamebottom].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.bottom = Convert.ToDouble(dr[colNamebottom].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameDate) && dr[colNameDate].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.date = dr[colNameDate].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameLayer) && dr[colNameLayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.layer = dr[colNameLayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameDaily) && dr[colNameDaily].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.dailyinjection = Convert.ToDouble(dr[colNameDaily].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameInjectionpercentage) && dr[colNameInjectionpercentage].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.injectionpercentage = Convert.ToDouble(dr[colNameInjectionpercentage].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameInjectionpressure) && dr[colNameInjectionpressure].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.injectionpressure = Convert.ToDouble(dr[colNameInjectionpressure].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameInjectionintesity) && dr[colNameInjectionintesity].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.injectionintesity = Convert.ToDouble(dr[colNameInjectionintesity].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameWaterabsorptionrate) && dr[colNameWaterabsorptionrate].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.waterabsorptionrate = Convert.ToDouble(dr[colNameWaterabsorptionrate].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameShutoff) && dr[colNameShutoff].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.shutoff = dr[colNameShutoff].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameSandthickness) && dr[colNameSandthickness].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.sandthickness = Convert.ToDouble(dr[colNameSandthickness].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameEffectionthickness) && dr[colNameEffectionthickness].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.effectionthickness = Convert.ToDouble(dr[colNameEffectionthickness].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamefistlayer) && dr[colNamefistlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.firstlayer = dr[colNamefistlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamesecondlayer) && dr[colNamesecondlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.secondlayer = dr[colNamesecondlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamethirdlayer) && dr[colNamethirdlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.thirdlayer = dr[colNamethirdlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
// obj.XHID = xhid++;
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
DataHelp.UpdateSearchWellName<WellWaterInjection>();
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SaveWellFluidProducingProfile(DataTable table, MatchCache cache, int index, int start, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<WellFluidProducingProfile>().Max<int>("id") + 1;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameJH = cache["well"]?.MatchColumn;
|
|
|
|
|
|
string colNametop = cache["top"]?.MatchColumn;
|
|
|
|
|
|
string colNamebottom = cache["bottom"]?.MatchColumn;
|
|
|
|
|
|
string colNameDate = cache["date"]?.MatchColumn;
|
|
|
|
|
|
string colNameLayer = cache["layer"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameSequencenumber = cache["sequencenumber"]?.MatchColumn;
|
|
|
|
|
|
string colNameMeasurementdepth = cache["measurementdepth"]?.MatchColumn;
|
|
|
|
|
|
string colNameLayercount = cache["layercount"]?.MatchColumn;
|
|
|
|
|
|
string colNameTemperature = cache["temperature"]?.MatchColumn;
|
|
|
|
|
|
string colNameFlowingpressure = cache["flowingpressure"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameFlowrate = cache["flowrate"]?.MatchColumn;
|
|
|
|
|
|
string colNameDensity = cache["density"]?.MatchColumn;
|
|
|
|
|
|
string colNameDailyliquid = cache["dailyliquid"]?.MatchColumn;
|
|
|
|
|
|
string colNameDailygas = cache["dailygas"]?.MatchColumn;
|
|
|
|
|
|
string colNameWatercut = cache["watercut"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNamefistlayer = cache["firstlayer"]?.MatchColumn;
|
|
|
|
|
|
string colNamesecondlayer = cache["secondlayer"]?.MatchColumn;
|
|
|
|
|
|
string colNamethirdlayer = cache["thirdlayer"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
List<WellFluidProducingProfile> listObj = new List<WellFluidProducingProfile>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
WellFluidProducingProfile obj = new WellFluidProducingProfile();
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameJH) && dr[colNameJH].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Well = dr[colNameJH].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNametop) && dr[colNametop].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.top = Convert.ToDouble(dr[colNametop].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamebottom) && dr[colNamebottom].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.bottom = Convert.ToDouble(dr[colNamebottom].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameDate) && dr[colNameDate].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.date = dr[colNameDate].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameLayer) && dr[colNameLayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.layer = dr[colNameLayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameSequencenumber) && dr[colNameSequencenumber].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.sequencenumber = Convert.ToInt32(dr[colNameSequencenumber].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameMeasurementdepth) && dr[colNameMeasurementdepth].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.measurementdepth = Convert.ToDouble(dr[colNameMeasurementdepth].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameLayercount) && dr[colNameLayercount].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.layercount = Convert.ToInt32(dr[colNameLayercount].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameTemperature) && dr[colNameTemperature].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.temperature = Convert.ToDouble(dr[colNameTemperature].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameFlowingpressure) && dr[colNameFlowingpressure].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.flowingpressure = Convert.ToDouble(dr[colNameFlowingpressure].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameFlowrate) && dr[colNameFlowrate].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.flowrate = Convert.ToDouble(dr[colNameFlowrate].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameDensity) && dr[colNameDensity].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.density = Convert.ToDouble(dr[colNameDensity].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameDailyliquid) && dr[colNameDailyliquid].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.dailyliquid = Convert.ToDouble(dr[colNameDailyliquid].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameWatercut) && dr[colNameWatercut].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.watercut = Convert.ToDouble(dr[colNameWatercut].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameDailygas) && dr[colNameDailygas].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.dailygas = Convert.ToDouble(dr[colNameDailygas].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamefistlayer) && dr[colNamefistlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.firstlayer = dr[colNamefistlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamesecondlayer) && dr[colNamesecondlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.secondlayer = dr[colNamesecondlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamethirdlayer) && dr[colNamethirdlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.thirdlayer = dr[colNamethirdlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
// obj.XHID = xhid++;
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
DataHelp.UpdateSearchWellName<WellFluidProducingProfile>();
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
private void SaveWellLithologicalAnalysis(DataTable table, MatchCache cache, int index, int start, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<WellLithologicalAnalysis>().Max<int>("id") + 1;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameJH = cache["well"]?.MatchColumn;
|
|
|
|
|
|
string colNametop = cache["top"]?.MatchColumn;
|
|
|
|
|
|
string colNamebottom = cache["bottom"]?.MatchColumn;
|
|
|
|
|
|
string colNamesamplenumber = cache["samplenumber"]?.MatchColumn;
|
|
|
|
|
|
string colNamelithology = cache["lithology"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNamesampleposition = cache["sampleposition"]?.MatchColumn;
|
|
|
|
|
|
string colNamesampledepth = cache["sampledepth"]?.MatchColumn;
|
|
|
|
|
|
string colNamecolor = cache["color"]?.MatchColumn;
|
|
|
|
|
|
string colNameoilcontent = cache["oilcontent"]?.MatchColumn;
|
|
|
|
|
|
string colNameinclusions = cache["inclusions"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNamelithologyprefix = cache["lithologyprefix"]?.MatchColumn;
|
|
|
|
|
|
string colNamestructure = cache["structure"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNamesamporosity = cache["porosity"]?.MatchColumn;
|
|
|
|
|
|
string colNamepermeability = cache["permeability"]?.MatchColumn;
|
|
|
|
|
|
string colNameoilsaturation = cache["oilsaturation"]?.MatchColumn;
|
|
|
|
|
|
string colNamewatersaturation = cache["watersaturation"]?.MatchColumn;
|
|
|
|
|
|
string colNameboundwatersaturation = cache["boundwatersaturation"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameclaycontent = cache["claycontent"]?.MatchColumn;
|
|
|
|
|
|
string colNamelithologyname = cache["lithologyname"]?.MatchColumn;
|
|
|
|
|
|
string colNamefistlayer = cache["firstlayer"]?.MatchColumn;
|
|
|
|
|
|
string colNamesecondlayer = cache["secondlayer"]?.MatchColumn;
|
|
|
|
|
|
string colNamethirdlayer = cache["thirdlayer"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
List<WellLithologicalAnalysis> listObj = new List<WellLithologicalAnalysis>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
WellLithologicalAnalysis obj = new WellLithologicalAnalysis();
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameJH) && dr[colNameJH].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Well = dr[colNameJH].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNametop) && dr[colNametop].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.top = Convert.ToDouble(dr[colNametop].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamebottom) && dr[colNamebottom].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.bottom = Convert.ToDouble(dr[colNamebottom].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamesamplenumber) && dr[colNamesamplenumber].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.samplenumber = Convert.ToInt32(dr[colNamesamplenumber].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamesampleposition) && dr[colNamesampleposition].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.sampleposition = Convert.ToDouble(dr[colNamesampleposition].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamesampledepth) && dr[colNamesampledepth].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.sampledepth = Convert.ToDouble(dr[colNamesampledepth].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamecolor) && dr[colNamecolor].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.color = dr[colNamecolor].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameoilcontent) && dr[colNameoilcontent].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.oilcontent = dr[colNamecolor].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameinclusions) && dr[colNameinclusions].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.inclusions = dr[colNameinclusions].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamelithologyprefix) && dr[colNamelithologyprefix].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.lithologyprefix = dr[colNamelithologyprefix].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamestructure) && dr[colNamestructure].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.structure = dr[colNamestructure].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamelithology) && dr[colNamelithology].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.lithology = dr[colNamelithology].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamesamporosity) && dr[colNamesamporosity].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.porosity = Convert.ToDouble(dr[colNamesamporosity].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamepermeability) && dr[colNamepermeability].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.permeability = Convert.ToDouble(dr[colNamepermeability].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameoilsaturation) && dr[colNameoilsaturation].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.oilsaturation = Convert.ToDouble(dr[colNameoilsaturation].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamewatersaturation) && dr[colNamewatersaturation].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.watersaturation = Convert.ToDouble(dr[colNamewatersaturation].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameboundwatersaturation) && dr[colNameboundwatersaturation].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.boundwatersaturation = Convert.ToDouble(dr[colNameboundwatersaturation].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameclaycontent) && dr[colNameclaycontent].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.claycontent = Convert.ToDouble(dr[colNameclaycontent].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamefistlayer) && dr[colNamefistlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.firstlayer = dr[colNamefistlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamesecondlayer) && dr[colNamesecondlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.secondlayer = dr[colNamesecondlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamethirdlayer) && dr[colNamethirdlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.thirdlayer = dr[colNamethirdlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamelithologyname) && dr[colNamelithologyname].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.lithologyname = dr[colNamelithologyname].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
// obj.XHID = xhid++;
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
DataHelp.UpdateSearchWellName<WellLithologicalAnalysis>();
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
private void SaveWellSideWallCoring(DataTable table, MatchCache cache, int index, int start, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<WellSideWallCoring>().Max<int>("id") + 1;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameJH = cache["well"]?.MatchColumn;
|
|
|
|
|
|
string colNametop = cache["top"]?.MatchColumn;
|
|
|
|
|
|
string colNameNumber = cache["number"]?.MatchColumn;
|
|
|
|
|
|
string colNamecolor = cache["color"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameoilcontent = cache["oilcontent"]?.MatchColumn;
|
|
|
|
|
|
string colNameinclusions = cache["inclusions"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNamelithologyprefix = cache["lithologyprefix"]?.MatchColumn;
|
|
|
|
|
|
string colNamestructure = cache["structure"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNamelithology = cache["lithology"]?.MatchColumn;
|
|
|
|
|
|
string colNamefistlayer = cache["firstlayer"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNamesecondlayer = cache["secondlayer"]?.MatchColumn;
|
|
|
|
|
|
string colNamethirdlayer = cache["thirdlayer"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNamevDepth = cache["verticaldepth"]?.MatchColumn;
|
|
|
|
|
|
string colNameelevaDepth = cache["elevationdepth"]?.MatchColumn;
|
|
|
|
|
|
string colNamelithologyname = cache["lithologyname"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
List<WellSideWallCoring> listObj = new List<WellSideWallCoring>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
WellSideWallCoring obj = new WellSideWallCoring();
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameJH) && dr[colNameJH].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Well = dr[colNameJH].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNametop) && dr[colNametop].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.top = Convert.ToDouble(dr[colNametop].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamecolor) && dr[colNamecolor].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.color = dr[colNamecolor].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameNumber) && dr[colNameNumber].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.number = Convert.ToInt32(dr[colNameNumber].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameoilcontent) && dr[colNameoilcontent].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.oilcontent = dr[colNamecolor].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameinclusions) && dr[colNameinclusions].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.inclusions = dr[colNameinclusions].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamelithologyprefix) && dr[colNamelithologyprefix].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.lithologyprefix = dr[colNamelithologyprefix].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamestructure) && dr[colNamestructure].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.structure = dr[colNamestructure].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamelithology) && dr[colNamelithology].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.lithology = dr[colNamelithology].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamefistlayer) && dr[colNamefistlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.firstlayer = dr[colNamefistlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamesecondlayer) && dr[colNamesecondlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.secondlayer = dr[colNamesecondlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamethirdlayer) && dr[colNamethirdlayer].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.thirdlayer = dr[colNamethirdlayer].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamevDepth) && dr[colNamevDepth].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.verticaldepth = Convert.ToDouble(dr[colNamevDepth].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameelevaDepth) && dr[colNameelevaDepth].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.elevationdepth = Convert.ToDouble(dr[colNameelevaDepth].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNamelithologyname) && dr[colNamelithologyname].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.lithologyname = dr[colNamelithologyname].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
DataHelp.UpdateSearchWellName<WellSideWallCoring>();
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 保存射孔
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Saves the data well perforation.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <param name="append">If true, append.</param>
|
|
|
|
|
|
private void SaveDataWellPerforation(DataTable table, MatchCache cache, int index, int startID, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<WellPerforation>().Max<int>("id") + 1;
|
|
|
|
|
|
string xhid_s = DBHelp.Db.Queryable<WellPerforation>().Max<string>("xhid");
|
|
|
|
|
|
int xhid = 1;
|
|
|
|
|
|
if (xhid_s != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
xhid = Convert.ToInt32(xhid_s) + 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string colNameJH = cache["JH"]?.MatchColumn;
|
|
|
|
|
|
string colNameDS = cache["DS"]?.MatchColumn;
|
|
|
|
|
|
string colNameDS2 = cache["DS2"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
string colNameCW = cache["CW"]?.MatchColumn;
|
|
|
|
|
|
string colNameSK = cache["SK"]?.MatchColumn;
|
|
|
|
|
|
|
|
|
|
|
|
List<WellPerforation> listObj = new List<WellPerforation>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
WellPerforation obj = new WellPerforation();
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameJH) && dr[colNameJH].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.JH = dr[colNameJH].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameDS) && dr[colNameDS].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.DS = Convert.ToDouble(dr[colNameDS].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameDS2) && dr[colNameDS2].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.DS2 = Convert.ToDouble(dr[colNameDS2].ToString());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameCW) && dr[colNameCW].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.CW = dr[colNameCW].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(colNameSK) && dr[colNameSK].ToString() != string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.SK = dr[colNameSK].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
obj.XHID = xhid++;
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
DataHelp.UpdateSearchWellName<WellPerforation>();
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 通用井斜
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Saves the well common.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <param name="append">If true, append.</param>
|
|
|
|
|
|
//private void SaveWellDeflection(DataTable table, MatchCache cache, int index, int startID, bool append)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// int id = DBHelp.Db.Queryable<WellDeflection>().Max<int>("id") + 1;
|
|
|
|
|
|
// string xhid_s = DBHelp.Db.Queryable<WellDeflection>().Max<string>("xhid");
|
|
|
|
|
|
// int xhid = 1;
|
|
|
|
|
|
// if (xhid_s != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// xhid = Convert.ToInt32(xhid_s) + 1;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// PropertyInfo[] properties = typeof(WellDeflection).GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
|
|
|
|
|
// List<WellDeflection> listObj = new List<WellDeflection>();
|
|
|
|
|
|
// int nIndex = 0;
|
|
|
|
|
|
// int count = table.Rows.Count;
|
|
|
|
|
|
// int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
// for (int i = 0; i < count; i++)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// continue;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// DataRow dr = table.Rows[i];
|
|
|
|
|
|
// WellDeflection obj = new WellDeflection();
|
|
|
|
|
|
// foreach (PropertyInfo prop in properties)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// if (cache.ContainsMatch(prop.Name))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// string value = this.GetMatchValue(cache[prop.Name], dr, this.listFileNames[index]);
|
|
|
|
|
|
// this.SetPropertyData(prop, obj, value);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// obj.XHID = xhid++;
|
|
|
|
|
|
// obj.ID = id++;
|
|
|
|
|
|
// nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
// listObj.Add(obj);
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
// this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
//}
|
|
|
|
|
|
private void SaveWellDeflection(DataTable table, MatchCache cache, int index, int startID, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
PropertyInfo[] properties = typeof(WellDeflection).GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
List<WellDeflection> listObj = new List<WellDeflection>();
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
WellDeflection obj = new WellDeflection();
|
|
|
|
|
|
foreach (PropertyInfo prop in properties)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cache.ContainsMatch(prop.Name))
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = this.GetMatchValue(cache[prop.Name], dr, this.listFileNames[index]);
|
|
|
|
|
|
this.SetPropertyData(prop, obj, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
obj.ID = obj.XHID = i + 1;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
EntityHelp.SaveWellDeflectionFile(table.TableName, listObj);
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.WriteLine($"处理文件失败:{table.TableName} \r\n 原因:{ex.Message}");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 通用产能数据保存
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
private void SaveWellCapacity<T>(DataTable table, MatchCache cache, int index)
|
|
|
|
|
|
where T : WellCapacity, new()
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<T>().Max<int>("id") + 1;
|
|
|
|
|
|
string xhid_s = DBHelp.Db.Queryable<T>().Max<string>("xhid");
|
|
|
|
|
|
int xhid = 1;
|
|
|
|
|
|
if (xhid_s != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
xhid = Convert.ToInt32(xhid_s) + 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
|
|
|
|
|
List<T> listObj = new List<T>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
|
|
|
|
|
|
string block = Path.GetFileNameWithoutExtension(this.listFileNames[index]);
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
T obj = new T();
|
|
|
|
|
|
foreach (PropertyInfo prop in properties)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cache.ContainsMatch(prop.Name))
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = dr[cache[prop.Name].MatchColumn].ToString();
|
|
|
|
|
|
this.SetPropertyData(prop, obj, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(obj.Block))
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Block = block;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (obj is WellTestTotal wellTestObj)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj.Block = !string.IsNullOrEmpty(wellTestObj.BlockName) ? wellTestObj.BlockName : "默认";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
obj.XHID = xhid++;
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Saves the well entity.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <returns>A Task.</returns>
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Saves the well entity.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <returns>A Task.</returns>
|
|
|
|
|
|
private async Task SaveWellEntity<T>(DataTable table, MatchCache cache, int index)
|
|
|
|
|
|
where T : class, new()
|
|
|
|
|
|
{
|
|
|
|
|
|
//int id = DBHelp.Db.Queryable<T>().Max<int>("id") + 1;
|
|
|
|
|
|
PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
|
|
|
|
|
List<T> listObj = new List<T>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
T obj = new T();
|
|
|
|
|
|
foreach (PropertyInfo prop in properties)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cache.ContainsMatch(prop.Name))
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = dr[cache[prop.Name].MatchColumn].ToString();
|
|
|
|
|
|
this.SetPropertyData(prop, obj, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (obj is WellCasingDamage casingDamage)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(casingDamage.GROUP))
|
|
|
|
|
|
{
|
|
|
|
|
|
casingDamage.GROUP = "默认";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
await Task.CompletedTask;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 保存工区
|
|
|
|
|
|
private async Task SaveWorkArea(DataTable table, MatchCache cache)
|
|
|
|
|
|
{
|
|
|
|
|
|
int nCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < this.cfg.Storage.DataTableList.Rows.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
WorkArea obj = new WorkArea();
|
|
|
|
|
|
|
|
|
|
|
|
obj.ID = 1;
|
|
|
|
|
|
obj.PATH = FileHelp.DirWorkArea;
|
|
|
|
|
|
obj.OUTFILENAME = "workarea.kev";
|
|
|
|
|
|
if (DBHelp.Db.Queryable<WorkArea>().Any())
|
|
|
|
|
|
{
|
|
|
|
|
|
DBHelp.Db.Updateable(obj).IgnoreColumns(o => o.WORKNAME).ExecuteCommand();
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DBHelp.Db.Insertable(obj).ExecuteCommand();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string outputfile = Config.ProjectPath + obj.PATH + "\\" + obj.OUTFILENAME;
|
|
|
|
|
|
|
|
|
|
|
|
// 创建目录, 清理已有文件
|
|
|
|
|
|
this.PrepareFile(outputfile);
|
|
|
|
|
|
|
|
|
|
|
|
//if (this.IsDfdFile(this.listFileNames[i]))
|
|
|
|
|
|
//{
|
|
|
|
|
|
// await RewriteDfdOutput(this.listFileNames[i], outputfile, "边界");
|
|
|
|
|
|
//}
|
|
|
|
|
|
//else
|
|
|
|
|
|
//{
|
|
|
|
|
|
// await this.WriteDfdOutput(cache.Matches, this.listFileNames[i], outputfile, "边界", true);
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
nCount++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nCount;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 保存边界
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Saves the data boundary.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <returns>A Task.</returns>
|
|
|
|
|
|
//private async Task SaveDataBoundary(DataTable table, MatchCache cache, int index)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// int id = DBHelp.Db.Queryable<InterpretBoundary>().Max<int>("id") + 1;
|
|
|
|
|
|
// string xhid_s = DBHelp.Db.Queryable<InterpretBoundary>().Max<string>("xhid");
|
|
|
|
|
|
// int xhid = 1;
|
|
|
|
|
|
// if (xhid_s != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// xhid = Convert.ToInt32(xhid_s) + 1;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// int nCount = this.cfg.Storage.DataTableList.Rows.Count;
|
|
|
|
|
|
|
|
|
|
|
|
// IEnumerable<Task> tasks = Enumerable.Range(0, nCount).Select(async i =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// InterpretBoundary obj = new InterpretBoundary()
|
|
|
|
|
|
// {
|
|
|
|
|
|
// XHID = xhid++,
|
|
|
|
|
|
// ID = id++,
|
|
|
|
|
|
// PATH = FileHelp.DirInterpretBoundary,
|
|
|
|
|
|
// CWID = Convert.ToInt32(this.cfg.Storage.DataTableList.Rows[i]["层位ID"].ToString()),
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
// this.SetInterpretProperty(obj, i);
|
|
|
|
|
|
|
|
|
|
|
|
// obj.OUTFILENAME = obj.CW + ".kev";
|
|
|
|
|
|
|
|
|
|
|
|
// DBHelp.NewDb.Storageable(obj).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
// string outputfile = Config.ProjectPath + obj.PATH + "\\" + obj.OUTFILENAME;
|
|
|
|
|
|
|
|
|
|
|
|
// // 创建目录, 清理已有文件
|
|
|
|
|
|
// this.PrepareFile(outputfile);
|
|
|
|
|
|
|
|
|
|
|
|
// if (this.IsDfdFile(this.listFileNames[i]))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await RewriteDfdOutput(this.listFileNames[i], outputfile, "边界");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await this.WriteDfdOutput(cache.Matches, this.listFileNames[i], outputfile, "边界", true);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
// await Task.WhenAll(tasks);
|
|
|
|
|
|
|
|
|
|
|
|
// this.cfg.TotalImport += nCount;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//// 保存散点边界
|
|
|
|
|
|
//private async Task SaveDataScatterBoundary(DataTable table, MatchCache cache, int index)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// int id = DBHelp.Db.Queryable<ScatterBaseBoundary>().Max<int>("id") + 1;
|
|
|
|
|
|
// string xhid_s = DBHelp.Db.Queryable<ScatterBaseBoundary>().Max<string>("xhid");
|
|
|
|
|
|
// int xhid = 1;
|
|
|
|
|
|
// if (xhid_s != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// xhid = Convert.ToInt32(xhid_s) + 1;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// int nCount = this.cfg.Storage.DataTableList.Rows.Count;
|
|
|
|
|
|
|
|
|
|
|
|
// IEnumerable<Task> tasks = Enumerable.Range(0, nCount).Select(async i =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// ScatterBaseBoundary obj = new ScatterBaseBoundary()
|
|
|
|
|
|
// {
|
|
|
|
|
|
// XHID = xhid++,
|
|
|
|
|
|
// ID = id++,
|
|
|
|
|
|
// PATH = FileHelp.DirScatterBoundary,
|
|
|
|
|
|
// CWID = Convert.ToInt32(this.cfg.Storage.DataTableList.Rows[i]["层位ID"].ToString()),
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
// this.SetInterpretProperty(obj, i);
|
|
|
|
|
|
|
|
|
|
|
|
// obj.OUTFILENAME = obj.CW + ".kev";
|
|
|
|
|
|
|
|
|
|
|
|
// DBHelp.NewDb.Storageable(obj).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
// string outputfile = Config.ProjectPath + obj.PATH + "\\" + obj.OUTFILENAME;
|
|
|
|
|
|
|
|
|
|
|
|
// // 创建目录, 清理已有文件
|
|
|
|
|
|
// this.PrepareFile(outputfile);
|
|
|
|
|
|
|
|
|
|
|
|
// if (this.IsDfdFile(this.listFileNames[i]))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await RewriteDfdOutput(this.listFileNames[i], outputfile, "边界");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await this.WriteDfdOutput(cache.Matches, this.listFileNames[i], outputfile, "边界", true);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
// await Task.WhenAll(tasks);
|
|
|
|
|
|
|
|
|
|
|
|
// this.cfg.TotalImport += nCount;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//// 保存单层散点边界
|
|
|
|
|
|
//private async Task SaveDataScatterSingleBoundary(DataTable table, MatchCache cache, int index)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// //判断是否存在不存在择创建
|
|
|
|
|
|
// bool isBoundary = DBHelp.NewDb.Queryable<ScatterBaseBoundary>().Any(x => x.CW == this.cfg.UpdateNode);
|
|
|
|
|
|
// int nCount = this.cfg.Storage.DataTableList.Rows.Count;
|
|
|
|
|
|
// IEnumerable<Task> tasks = Enumerable.Range(0, nCount).Select(async i =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// ScatterBaseBoundary obj = new ScatterBaseBoundary()
|
|
|
|
|
|
// {
|
|
|
|
|
|
// PATH = FileHelp.DirScatterBoundary,
|
|
|
|
|
|
// CWID = Convert.ToInt32(this.cfg.Storage.DataTableList.Rows[i]["层位ID"].ToString()),
|
|
|
|
|
|
// };
|
|
|
|
|
|
// this.SetInterpretProperty(obj, i);
|
|
|
|
|
|
// obj.OUTFILENAME = obj.CW + ".kev";
|
|
|
|
|
|
// if (!isBoundary)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// int id = DBHelp.Db.Queryable<ScatterBaseBoundary>().Max<int>("id") + 1;
|
|
|
|
|
|
// string xhid_s = DBHelp.Db.Queryable<ScatterBaseBoundary>().Max<string>("xhid");
|
|
|
|
|
|
// int xhid = 1;
|
|
|
|
|
|
// if (xhid_s != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// xhid = Convert.ToInt32(xhid_s) + 1;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// obj.XHID = xhid++;
|
|
|
|
|
|
// obj.ID = id++;
|
|
|
|
|
|
// obj.CW = this.cfg.UpdateNode;
|
|
|
|
|
|
// DBHelp.NewDb.Storageable(obj).ExecuteCommand();
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// string outputfile = Config.ProjectPath + obj.PATH + "\\" + obj.OUTFILENAME;
|
|
|
|
|
|
// this.PrepareFile(outputfile);
|
|
|
|
|
|
|
|
|
|
|
|
// if (this.IsDfdFile(this.listFileNames[i]))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await RewriteDfdOutput(this.listFileNames[i], outputfile, "边界");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await this.WriteDfdOutput(cache.Matches, this.listFileNames[i], outputfile, "边界", false);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// await Task.WhenAll(tasks);
|
|
|
|
|
|
// this.cfg.TotalImport += nCount;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Saves the data interpret table.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <returns>A Task.</returns>
|
|
|
|
|
|
//private async Task SaveDataInterpretTable<T>(DataTable table, MatchCache cache, int index)
|
|
|
|
|
|
// where T : InterpretTable, new()
|
|
|
|
|
|
//{
|
|
|
|
|
|
// int id = DBHelp.Db.Queryable<T>().Max<int>("id") + 1;
|
|
|
|
|
|
// string xhid_s = DBHelp.Db.Queryable<T>().Max<string>("xhid");
|
|
|
|
|
|
// int xhid = 1;
|
|
|
|
|
|
// if (xhid_s != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// xhid = Convert.ToInt32(xhid_s) + 1;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// List<InterpretLayer> list_layer = this.listInterpretLayer;
|
|
|
|
|
|
|
|
|
|
|
|
// int nCount = this.cfg.Storage.DataTableList.Rows.Count;
|
|
|
|
|
|
|
|
|
|
|
|
// IEnumerable<Task> tasks = Enumerable.Range(0, nCount).Select(async i =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// InterpretLayer obj_layer = this.GetInterpretLayer(this.cfg.Storage.DataTableList.Rows[i]["层位"].ToString());
|
|
|
|
|
|
// T obj = new T()
|
|
|
|
|
|
// {
|
|
|
|
|
|
// XHID = xhid++,
|
|
|
|
|
|
// ID = id++,
|
|
|
|
|
|
// CWID = obj_layer.ID,
|
|
|
|
|
|
// PATH = $@"\Interpret\{typeof(T).Name.Replace("Interpret", string.Empty)}",
|
|
|
|
|
|
// OUTFILENAME = obj_layer.CW + ".xyz",
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
// this.SetInterpretProperty(obj, i);
|
|
|
|
|
|
|
|
|
|
|
|
// string outputfile = Config.ProjectPath + obj.PATH + "\\" + obj.OUTFILENAME;
|
|
|
|
|
|
|
|
|
|
|
|
// // 创建目录, 清理已有文件
|
|
|
|
|
|
// this.PrepareFile(outputfile);
|
|
|
|
|
|
|
|
|
|
|
|
// RangeData range = null;
|
|
|
|
|
|
|
|
|
|
|
|
// if (this.IsDfdFile(this.listFileNames[i]))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// range = await this.WriteXYZOutputFromDfd(this.listFileNames[i], outputfile);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else
|
|
|
|
|
|
// {
|
|
|
|
|
|
// range = await this.WriteXYZOutput(cache.Matches, this.listFileNames[i], outputfile);
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// //if (typeof(T).IsType<InterpretTableXYZ>())
|
|
|
|
|
|
// //{
|
|
|
|
|
|
// // var xyz = obj as InterpretTableXYZ;
|
|
|
|
|
|
// // xyz.MAXZ = range?.MaxZ;
|
|
|
|
|
|
|
|
|
|
|
|
// // if (typeof(T).IsType<InterpretDepthLayer>())
|
|
|
|
|
|
// // {
|
|
|
|
|
|
// // double absMinValue = this.AbsValue(range?.MinZ);
|
|
|
|
|
|
// // double absMaxValue = this.AbsValue(range?.MaxZ);
|
|
|
|
|
|
|
|
|
|
|
|
// // xyz.MAXZ = Math.Max(absMinValue, absMaxValue);
|
|
|
|
|
|
// // }
|
|
|
|
|
|
// //}
|
|
|
|
|
|
|
|
|
|
|
|
// DBHelp.NewDb.Insertable(obj).ExecuteCommand();
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
// await Task.WhenAll(tasks);
|
|
|
|
|
|
|
|
|
|
|
|
// this.cfg.TotalImport += nCount;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
private double AbsValue(double? value)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!value.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return value.Value < 0 ? -value.Value : value.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//// 保存断层
|
|
|
|
|
|
//private async Task SaveDataFault(DataTable table, MatchCache cache, int index)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// int id = DBHelp.Db.Queryable<InterpretFault>().Max<int>("id") + 1;
|
|
|
|
|
|
// string xhid_s = DBHelp.Db.Queryable<InterpretFault>().Max<string>("xhid");
|
|
|
|
|
|
// int xhid = 1;
|
|
|
|
|
|
// if (xhid_s != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// xhid = Convert.ToInt32(xhid_s) + 1;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// int nCount = this.cfg.Storage.DataTableList.Rows.Count;
|
|
|
|
|
|
|
|
|
|
|
|
// IEnumerable<Task> tasks = Enumerable.Range(0, nCount).Select(async i =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// InterpretFault obj = new InterpretFault()
|
|
|
|
|
|
// {
|
|
|
|
|
|
// XHID = xhid++,
|
|
|
|
|
|
// ID = id++,
|
|
|
|
|
|
// PATH = FileHelp.DirInterpretFault,
|
|
|
|
|
|
// CWID = Convert.ToInt32(this.cfg.Storage.DataTableList.Rows[i]["层位ID"].ToString()),
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
// this.SetInterpretProperty(obj, i);
|
|
|
|
|
|
|
|
|
|
|
|
// obj.OUTFILENAME = obj.CW + ".kev";
|
|
|
|
|
|
|
|
|
|
|
|
// DBHelp.NewDb.Storageable(obj).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
// string outputfile = Config.ProjectPath + obj.PATH + "\\" + obj.OUTFILENAME;
|
|
|
|
|
|
// this.PrepareFile(outputfile);
|
|
|
|
|
|
|
|
|
|
|
|
// if (this.IsDfdFile(this.listFileNames[i]))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await RewriteDfdOutput(this.listFileNames[i], outputfile, "断层");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await this.WriteDfdOutput(cache.Matches, this.listFileNames[i], outputfile, "断层", false);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// await Task.WhenAll(tasks);
|
|
|
|
|
|
// this.cfg.TotalImport += nCount;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
|
///// 保存散点断层
|
|
|
|
|
|
///// </summary>
|
|
|
|
|
|
///// <param name="table">The table.</param>
|
|
|
|
|
|
///// <param name="cache">The cache.</param>
|
|
|
|
|
|
///// <param name="index">The index.</param>
|
|
|
|
|
|
///// <returns>A Task.</returns>
|
|
|
|
|
|
//private async Task SaveDataScatterFault(DataTable table, MatchCache cache, int index)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// int nCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// int id = DBHelp.Db.Queryable<ScatterBaseFault>().Max<int>("id") + 1;
|
|
|
|
|
|
// string xhid_s = DBHelp.Db.Queryable<ScatterBaseFault>().Max<string>("xhid");
|
|
|
|
|
|
// int xhid = 1;
|
|
|
|
|
|
// if (xhid_s != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// xhid = Convert.ToInt32(xhid_s) + 1;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// nCount = this.cfg.Storage.DataTableList.Rows.Count;
|
|
|
|
|
|
// IEnumerable<Task> tasks = Enumerable.Range(0, nCount).Select(async i =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// ScatterBaseFault obj = new ScatterBaseFault()
|
|
|
|
|
|
// {
|
|
|
|
|
|
// XHID = xhid++,
|
|
|
|
|
|
// ID = id++,
|
|
|
|
|
|
// PATH = FileHelp.DirScatterFault,
|
|
|
|
|
|
// CWID = Convert.ToInt32(this.cfg.Storage.DataTableList.Rows[i]["层位ID"].ToString()),
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
// this.SetInterpretProperty(obj, i);
|
|
|
|
|
|
|
|
|
|
|
|
// obj.OUTFILENAME = obj.CW + ".kev";
|
|
|
|
|
|
|
|
|
|
|
|
// DBHelp.NewDb.Storageable(obj).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
// string outputfile = Config.ProjectPath + obj.PATH + "\\" + obj.OUTFILENAME;
|
|
|
|
|
|
// this.PrepareFile(outputfile);
|
|
|
|
|
|
|
|
|
|
|
|
// if (this.IsDfdFile(this.listFileNames[i]))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await RewriteDfdOutput(this.listFileNames[i], outputfile, "断层");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await this.WriteDfdOutput(cache.Matches, this.listFileNames[i], outputfile, "断层", false);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// await Task.WhenAll(tasks);
|
|
|
|
|
|
|
|
|
|
|
|
// this.cfg.TotalImport += nCount;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
|
///// 保存散点断层单层
|
|
|
|
|
|
///// </summary>
|
|
|
|
|
|
///// <param name="table">The table.</param>
|
|
|
|
|
|
///// <param name="cache">The cache.</param>
|
|
|
|
|
|
///// <param name="index">The index.</param>
|
|
|
|
|
|
///// <returns>A Task.</returns>
|
|
|
|
|
|
//private async Task SaveDataScatterSingleFault(DataTable table, MatchCache cache, int index)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// int nCount = this.cfg.Storage.DataTableList.Rows.Count;
|
|
|
|
|
|
// bool isFault = DBHelp.NewDb.Queryable<ScatterBaseFault>().Any(x => x.CW == this.cfg.UpdateNode);
|
|
|
|
|
|
// IEnumerable<Task> tasks = Enumerable.Range(0, nCount).Select(async i =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// ScatterBaseFault obj = new ScatterBaseFault()
|
|
|
|
|
|
// {
|
|
|
|
|
|
// PATH = FileHelp.DirScatterBoundary,
|
|
|
|
|
|
// CWID = Convert.ToInt32(this.cfg.Storage.DataTableList.Rows[i]["层位ID"].ToString()),
|
|
|
|
|
|
// };
|
|
|
|
|
|
// this.SetInterpretProperty(obj, i);
|
|
|
|
|
|
// obj.OUTFILENAME = obj.CW + ".kev";
|
|
|
|
|
|
// if (!isFault)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// int id = DBHelp.Db.Queryable<ScatterBaseFault>().Max<int>("id") + 1;
|
|
|
|
|
|
// string xhid_s = DBHelp.Db.Queryable<ScatterBaseFault>().Max<string>("xhid");
|
|
|
|
|
|
// int xhid = 1;
|
|
|
|
|
|
// if (xhid_s != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// xhid = Convert.ToInt32(xhid_s) + 1;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// obj.XHID = xhid++;
|
|
|
|
|
|
// obj.ID = id++;
|
|
|
|
|
|
// obj.CW = this.cfg.UpdateNode;
|
|
|
|
|
|
// DBHelp.NewDb.Storageable(obj).ExecuteCommand();
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// string outputfile = Config.ProjectPath + obj.PATH + "\\" + obj.OUTFILENAME;
|
|
|
|
|
|
// this.PrepareFile(outputfile);
|
|
|
|
|
|
|
|
|
|
|
|
// if (this.IsDfdFile(this.listFileNames[i]))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await RewriteDfdOutput(this.listFileNames[i], outputfile, "断层");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// else
|
|
|
|
|
|
// {
|
|
|
|
|
|
// await this.WriteDfdOutput(cache.Matches, this.listFileNames[i], outputfile, "断层", false);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
// await Task.WhenAll(tasks);
|
|
|
|
|
|
// this.cfg.TotalImport += nCount;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Saves the data curve or time depth.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <param name="append">If true, append.</param>
|
|
|
|
|
|
private void SaveDataCurveOrTimeDepth<T>(DataTable table, MatchCache cache, int index, int start, bool append) where T : WellFileTable, new()
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<T>().Max<int>("id") + 1;
|
|
|
|
|
|
string xhid_s = DBHelp.Db.Queryable<T>().Max<string>("xhid");
|
|
|
|
|
|
int xhid = 1;
|
|
|
|
|
|
if (xhid_s != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
xhid = Convert.ToInt32(xhid_s) + 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int nCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
List<T> listObj = new List<T>();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < this.cfg.Storage.DataTableList.Rows.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
T obj = new T()
|
|
|
|
|
|
{
|
|
|
|
|
|
XHID = xhid++,
|
|
|
|
|
|
ID = id++,
|
|
|
|
|
|
PATH = FileHelp.DirWellTimeDepth,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
obj.JH = this.cfg.Storage.DataTableList.Rows[i]["井号"].ToString();
|
|
|
|
|
|
obj.FILE_NAME = this.cfg.Storage.DataTableList.Rows[i]["文件名"].ToString();
|
|
|
|
|
|
obj.CATEGARY = this.cfg.Storage.DataTableList.Rows[i]["类型"].ToString();
|
|
|
|
|
|
// obj.FILE_DATA = this.GetFileData(this.listFileNames[i]);
|
|
|
|
|
|
obj.OUTFILENAME = obj.FILE_NAME;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
|
|
|
|
|
|
// copy link
|
|
|
|
|
|
{
|
|
|
|
|
|
string outputfile = Config.ProjectPath + obj.PATH + "\\link\\" + obj.FILE_NAME;
|
|
|
|
|
|
this.PrepareFile(outputfile);
|
|
|
|
|
|
|
|
|
|
|
|
this.RewriteFile(this.listFileNames[i], outputfile);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
string outputfile = Config.ProjectPath + obj.PATH + "\\" + obj.OUTFILENAME;
|
|
|
|
|
|
|
|
|
|
|
|
this.RewriteFile(this.listFileNames[i], outputfile);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nCount++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
|
|
|
|
|
|
DataHelp.UpdateSearchWellName<T>();
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nCount;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 保存 二维测线
|
|
|
|
|
|
private void SaveSurveyline2d(DataTable table, MatchCache cache, int index, int start, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<Surveyline2d>().Max<int>("id") + 1;
|
|
|
|
|
|
|
|
|
|
|
|
List<EntityColumnInfo> columns = DBHelp.GetEntityColumnInfo(typeof(Surveyline2d));
|
|
|
|
|
|
|
|
|
|
|
|
List<Surveyline2d> listObj = new List<Surveyline2d>();
|
|
|
|
|
|
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
string block = Path.GetFileNameWithoutExtension(this.listFileNames[index]);
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
|
|
|
|
|
|
Surveyline2d obj = new Surveyline2d();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (EntityColumnInfo col in columns)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cache.ContainsMatch(col.DbColumnName))
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = dr[cache[col.DbColumnName].MatchColumn].ToString();
|
|
|
|
|
|
|
|
|
|
|
|
this.SetPropertyData(col.PropertyInfo, obj, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 保存 交汇图
|
|
|
|
|
|
private async Task SaveCrossplot(DataTable table, MatchCache cache, int index, int start)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<Crossplot>().Max<int>("id") + 1;
|
|
|
|
|
|
|
|
|
|
|
|
string filepath = this.listFileNames[0];
|
|
|
|
|
|
string filename = Path.GetFileNameWithoutExtension(filepath) + ".xlsx";
|
|
|
|
|
|
|
|
|
|
|
|
Crossplot obj = new Crossplot()
|
|
|
|
|
|
{
|
|
|
|
|
|
ID = id++,
|
|
|
|
|
|
DATA_NAME = Path.GetFileNameWithoutExtension(filename),
|
|
|
|
|
|
DATA_TYPE = Path.GetExtension(filename).ToLower(),
|
|
|
|
|
|
FILE_NAME = filename,
|
|
|
|
|
|
FILE_PATH = @"\Crossplot\",
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
string outputfile = Config.ProjectPath + obj.FILE_PATH + "\\" + obj.FILE_NAME;
|
|
|
|
|
|
|
|
|
|
|
|
// 创建目录, 清理已有文件
|
|
|
|
|
|
this.PrepareFile(outputfile);
|
|
|
|
|
|
|
|
|
|
|
|
await this.WriteExcelOutput(table, outputfile);
|
|
|
|
|
|
|
|
|
|
|
|
DBHelp.NewDb.Insertable(obj).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Task WriteExcelOutput(DataTable table, string outputfile)
|
|
|
|
|
|
{
|
|
|
|
|
|
NPOI.SS.UserModel.IWorkbook wb = new XSSFWorkbook();
|
|
|
|
|
|
ISheet sheet = wb.CreateSheet("Sheet1");
|
|
|
|
|
|
IRow row;
|
|
|
|
|
|
int rowIndex = 0;
|
|
|
|
|
|
|
|
|
|
|
|
row = sheet.CreateRow(rowIndex++);
|
|
|
|
|
|
|
|
|
|
|
|
int colIndex = 0;
|
|
|
|
|
|
foreach (DataColumn dtCol in table.Columns)
|
|
|
|
|
|
{
|
|
|
|
|
|
row.CreateCell(colIndex++).SetCellValue(dtCol.ColumnName);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (DataRow dtRow in table.Rows)
|
|
|
|
|
|
{
|
|
|
|
|
|
row = sheet.CreateRow(rowIndex++);
|
|
|
|
|
|
colIndex = 0;
|
|
|
|
|
|
|
|
|
|
|
|
foreach (DataColumn dtCol in table.Columns)
|
|
|
|
|
|
{
|
|
|
|
|
|
var s = dtRow[dtCol].ToString();
|
|
|
|
|
|
if (double.TryParse(s, out var dValue))
|
|
|
|
|
|
{
|
|
|
|
|
|
row.CreateCell(colIndex++).SetCellValue(dValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
row.CreateCell(colIndex++).SetCellValue(s);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using (FileStream stream = File.Create(outputfile))
|
|
|
|
|
|
{
|
|
|
|
|
|
wb.Write(stream);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 保存储层数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void SaveCcsj<T>(DataTable table, MatchCache cache, int index, int start, bool append)
|
|
|
|
|
|
where T : IReservoirData, new()
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<T>().AS(DBHelp.GetTableOriginName<T>()).Max<int>("id") + 1;
|
|
|
|
|
|
|
|
|
|
|
|
List<EntityColumnInfo> columns = DBHelp.GetEntityColumnInfo(typeof(T));
|
|
|
|
|
|
List<T> listObj = new List<T>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
string block = Path.GetFileNameWithoutExtension(this.listFileNames[index]);
|
|
|
|
|
|
string tableName = DBHelp.GetEntityInfo<T>().TableDescription;
|
|
|
|
|
|
int processedCount = 0;
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
Interlocked.Increment(ref processedCount);
|
|
|
|
|
|
double percent = processedCount * 100.0 / count;
|
|
|
|
|
|
this.ui.UpdateProgress($"保存{tableName}数据,{Math.Round(percent, 2)} %");
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
T obj = new T();
|
|
|
|
|
|
foreach (EntityColumnInfo col in columns)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cache.ContainsMatch(col.DbColumnName))
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = dr[cache[col.DbColumnName].MatchColumn].ToString();
|
|
|
|
|
|
this.SetPropertyData(col.PropertyInfo, obj, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (obj is CcsjKxd kxd)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!kxd.KXD.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (obj is CcsjBhd bhd)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!bhd.HSBHD.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (obj is CcsjStl stl)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!stl.STL.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (obj is CcsjYxhd yxhd)
|
|
|
|
|
|
{
|
|
|
|
|
|
int k1 = 3;
|
|
|
|
|
|
int k2 = 3;
|
|
|
|
|
|
if (!yxhd.YXHD.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
k1--;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!yxhd.DJSD1.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
k1--;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!yxhd.DJSD2.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
k1--;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!yxhd.YXCS_T.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
k2--;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!yxhd.YXCS_B.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
k2--;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!yxhd.YXCS_HD.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
k2--;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (k1 < 2 && k2 < 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (obj is CcsjSyhd syhd)
|
|
|
|
|
|
{
|
|
|
|
|
|
int k1 = 3;
|
|
|
|
|
|
int k2 = 3;
|
|
|
|
|
|
if (!syhd.SYHD.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
k1--;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!syhd.SYSD_T.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
k1--;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!syhd.SYSD_B.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
k1--;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!syhd.SYCS_T.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
k2--;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!syhd.SYCS_B.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
k2--;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!syhd.SYCS_HD.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
k2--;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (k1 < 2 && k2 < 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (typeof(T) == typeof(CcsjSyhd))
|
|
|
|
|
|
{
|
|
|
|
|
|
DBHelp.NewDb.Fastest<CcsjSyhd>().AS(DBHelp.GetTableOriginName<T>()).BulkCopy(listObj.OfType<CcsjSyhd>().ToList());
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (typeof(T) == typeof(CcsjYxhd))
|
|
|
|
|
|
{
|
|
|
|
|
|
DBHelp.NewDb.Fastest<CcsjYxhd>().AS(DBHelp.GetTableOriginName<T>()).BulkCopy(listObj.OfType<CcsjYxhd>().ToList());
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (typeof(T) == typeof(CcsjStl))
|
|
|
|
|
|
{
|
|
|
|
|
|
DBHelp.NewDb.Fastest<CcsjStl>().AS(DBHelp.GetTableOriginName<T>()).BulkCopy(listObj.OfType<CcsjStl>().ToList());
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (typeof(T) == typeof(CcsjKxd))
|
|
|
|
|
|
{
|
|
|
|
|
|
DBHelp.NewDb.Fastest<CcsjKxd>().AS(DBHelp.GetTableOriginName<T>()).BulkCopy(listObj.OfType<CcsjKxd>().ToList());
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (typeof(T) == typeof(CcsjBhd))
|
|
|
|
|
|
{
|
|
|
|
|
|
DBHelp.NewDb.Fastest<CcsjBhd>().AS(DBHelp.GetTableOriginName<T>()).BulkCopy(listObj.OfType<CcsjBhd>().ToList());
|
|
|
|
|
|
}
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 保存 井分层
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <param name="append">If true, append.</param>
|
|
|
|
|
|
private void SaveDataDrillWellLayered(DataTable table, MatchCache cache, int index, int startID, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<InterpretDrillWellLayered>().AS(DBHelp.GetTableOriginName<InterpretDrillWellLayered>()).Max<int>("id") + 1;
|
|
|
|
|
|
|
|
|
|
|
|
Dictionary<string, int> dictXhid = DBHelp.Db.Queryable<InterpretDrillWellLayered>().AS(DBHelp.GetTableOriginName<InterpretDrillWellLayered>())
|
|
|
|
|
|
.GroupBy(o => o.JH)
|
|
|
|
|
|
.Select(o => new { o.JH, XHID = SqlFunc.AggregateMax(o.XHID) })
|
|
|
|
|
|
.ToList()
|
|
|
|
|
|
.ToDictionary(o => o.JH, o => o.XHID);
|
|
|
|
|
|
|
|
|
|
|
|
int getXhid(string jh)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!dictXhid.ContainsKey(jh))
|
|
|
|
|
|
{
|
|
|
|
|
|
dictXhid[jh] = 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
dictXhid[jh] = dictXhid[jh] + 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return dictXhid[jh];
|
|
|
|
|
|
}
|
|
|
|
|
|
List<InterpretDrillWellLayered> listObj = new List<InterpretDrillWellLayered>();
|
|
|
|
|
|
int nIndex = 0;
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
PropertyInfo[] properties = typeof(InterpretDrillWellLayered).GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DataRow dr = table.Rows[i];
|
|
|
|
|
|
InterpretDrillWellLayered obj = new InterpretDrillWellLayered();
|
|
|
|
|
|
foreach (PropertyInfo prop in properties)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cache.ContainsMatch(prop.Name))
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = dr[cache[prop.Name].MatchColumn].ToString();
|
|
|
|
|
|
this.SetPropertyData(prop, obj, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (obj.JH == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
obj.XHID = getXhid(obj.JH);
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
nIndex++;
|
|
|
|
|
|
listObj.Add(obj);
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{ }
|
|
|
|
|
|
}
|
|
|
|
|
|
DBHelp.NewDb.Fastest<InterpretDrillWellLayered>().AS(DBHelp.GetTableOriginName<InterpretDrillWellLayered>()).BulkCopy(listObj);
|
|
|
|
|
|
//DBHelp.NewDb.BulkInsert(listObj);
|
|
|
|
|
|
//DataHelp.UpdateSearchWellName<InterpretDrillWellLayered>(); 应该创建表时创建
|
|
|
|
|
|
this.cfg.TotalImport += nIndex;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 保存 地震属性
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Saves the data attribute.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <param name="append">If true, append.</param>
|
|
|
|
|
|
private void SaveDataAttribute(DataTable table, MatchCache cache, int index, bool append)
|
|
|
|
|
|
{
|
|
|
|
|
|
DBHelp.Db.BeginTran();
|
|
|
|
|
|
int id = DBHelp.Db.Queryable<InterpretAttribute>().Max<int>("id") + 1;
|
|
|
|
|
|
string xhid_s = DBHelp.Db.Queryable<InterpretAttribute>().Max<string>("xhid");
|
|
|
|
|
|
int xhid = 1;
|
|
|
|
|
|
if (xhid_s != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
xhid = Convert.ToInt32(xhid_s) + 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int nCount = 0;
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
for (int i = 0; i < this.cfg.Storage.DataTableList.Rows.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
InterpretAttribute obj = new InterpretAttribute();
|
|
|
|
|
|
|
|
|
|
|
|
obj.XHID = xhid++;
|
|
|
|
|
|
obj.ID = id++;
|
|
|
|
|
|
obj.CW = this.cfg.Storage.DataTableList.Rows[i]["层位"].ToString();
|
|
|
|
|
|
obj.FILE_NAME = this.cfg.Storage.DataTableList.Rows[i]["文件名"].ToString();
|
|
|
|
|
|
obj.Attribute = this.cfg.Storage.DataTableList.Rows[i]["属性名"].ToString();
|
|
|
|
|
|
obj.CATEGARY = this.cfg.Storage.DataTableList.Rows[i]["类型"].ToString();
|
|
|
|
|
|
obj.FILE_DATA = this.GetFileData(this.listFileNames[i]);
|
|
|
|
|
|
obj.CWID = Convert.ToInt32(this.cfg.Storage.DataTableList.Rows[i]["层位ID"].ToString());
|
|
|
|
|
|
DBHelp.Db.Storageable(obj).ExecuteCommand();
|
|
|
|
|
|
nCount++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.cfg.TotalImport += nCount;
|
|
|
|
|
|
|
|
|
|
|
|
if (nCount > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
DBHelp.Db.CommitTran();
|
|
|
|
|
|
this.ShowMessageBox(string.Format("导入 {0} 条数据!", nCount), "提示");
|
|
|
|
|
|
|
|
|
|
|
|
this.ui.OnSaveFinish(this.cfg);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DBHelp.Db.CommitTran();
|
|
|
|
|
|
this.ShowMessageBox("未导入数据!", "提示");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 检查数据
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 检查井斜数据.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="tableList">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
|
|
|
|
private async Task<bool> CheckWellDeflection(List<DataTable> tableList, MatchCache cache)
|
|
|
|
|
|
{
|
|
|
|
|
|
HashSet<string> set = this.GetAvailableWellName();
|
|
|
|
|
|
HashSet<string> missing = new HashSet<string>();
|
|
|
|
|
|
|
|
|
|
|
|
HashSet<string> set2 = this.GetAvailableWellDeflectionWellName();
|
|
|
|
|
|
HashSet<string> exist = new HashSet<string>();
|
|
|
|
|
|
|
|
|
|
|
|
DataTable missingTable = tableList.First().Clone();
|
|
|
|
|
|
bool bRet = this.CheckInputData(tableList, cache, (row, index) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
string jh = this.GetMatchValue(cache["JH"], row, this.listFileNames[index]);
|
|
|
|
|
|
if (!this.checkIsWellExist(row, set, cache["JH"], this.listFileNames[index]))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(jh))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!missing.Contains(jh))
|
|
|
|
|
|
{
|
|
|
|
|
|
missingTable.Rows.Add(row.ItemArray);
|
|
|
|
|
|
}
|
|
|
|
|
|
missing.Add(jh);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!exist.Contains(jh) && set2.Contains(jh))
|
|
|
|
|
|
{
|
|
|
|
|
|
exist.Add(jh);
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (exist.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (DevExpress.XtraSplashScreen.SplashScreenManager.Default != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
|
|
|
|
|
|
}
|
|
|
|
|
|
var result = new DlgAppend().ShowDialog();
|
|
|
|
|
|
if (result == DialogResult.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.cfg is FrmImportData xtraForm)
|
|
|
|
|
|
{
|
|
|
|
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(xtraForm, typeof(DlgWait), false, false, DevExpress.XtraSplashScreen.ParentFormState.Unlocked);
|
|
|
|
|
|
}
|
|
|
|
|
|
DBHelp.Db.Deleteable<WellDeflection>()
|
|
|
|
|
|
.Where(o => exist.Contains(o.JH))
|
|
|
|
|
|
.ExecuteCommand();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!bRet)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (missing.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
DataTable dt = new DataTable();
|
|
|
|
|
|
dt.Columns.Add("井号");
|
|
|
|
|
|
foreach (var item in missing)
|
|
|
|
|
|
{
|
|
|
|
|
|
DataRow dataRow = dt.NewRow();
|
|
|
|
|
|
dataRow[0] = item;
|
|
|
|
|
|
dt.Rows.Add(dataRow);
|
|
|
|
|
|
}
|
|
|
|
|
|
//missingTable 返回数据
|
|
|
|
|
|
return await this.ImportWellBase(dt);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 检查水平井压裂参数.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="tableList">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
|
|
|
|
private async Task<bool> CheckHoriWellFracturParm(List<DataTable> tableList, MatchCache cache)
|
|
|
|
|
|
{
|
|
|
|
|
|
HashSet<string> set = this.GetAvailableWellName();
|
|
|
|
|
|
HashSet<string> missing = new HashSet<string>();
|
|
|
|
|
|
HashSet<string> set2 = this.GetAvailableHoriWellFracturParmWellName();
|
|
|
|
|
|
HashSet<string> exist = new HashSet<string>();
|
|
|
|
|
|
DataTable missingTable = tableList.First().Clone();
|
|
|
|
|
|
|
|
|
|
|
|
bool bRet = this.CheckInputData(tableList, cache, (row, index) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
string jh = this.GetMatchValue(cache["JH"], row, this.listFileNames[index]);
|
|
|
|
|
|
if (!this.checkIsWellExist(row, set, cache["JH"], this.listFileNames[index]))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(jh))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!missing.Contains(jh))
|
|
|
|
|
|
{
|
|
|
|
|
|
missingTable.Rows.Add(row.ItemArray);
|
|
|
|
|
|
}
|
|
|
|
|
|
missing.Add(jh);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!exist.Contains(jh) && set2.Contains(jh))
|
|
|
|
|
|
{
|
|
|
|
|
|
exist.Add(jh);
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (exist.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (DevExpress.XtraSplashScreen.SplashScreenManager.Default != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
|
|
|
|
|
|
}
|
|
|
|
|
|
var result = new DlgAppend().ShowDialog();
|
|
|
|
|
|
if (result == DialogResult.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.cfg is FrmImportData xtraForm)
|
|
|
|
|
|
{
|
|
|
|
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(xtraForm, typeof(DlgWait), false, false, DevExpress.XtraSplashScreen.ParentFormState.Unlocked);
|
|
|
|
|
|
}
|
|
|
|
|
|
DBHelp.Db.Deleteable<HoriWellFracturParameter>().Where(o => exist.Contains(o.JH)).ExecuteCommand();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!bRet)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (missing.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await this.ImportWellBase(missingTable);
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 检查输入数据, 并判断井号是否存在.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="tableList">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
|
|
|
|
private async Task<bool> CheckInputDataWithWellName(List<DataTable> tableList, MatchCache cache)
|
|
|
|
|
|
{
|
|
|
|
|
|
HashSet<string> set = this.GetAvailableWellName();
|
|
|
|
|
|
HashSet<string> missing = new HashSet<string>();
|
|
|
|
|
|
DataTable missingTable = tableList.First().Clone();
|
|
|
|
|
|
bool bRet = this.CheckInputData(tableList, cache, (row, index) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!this.checkIsWellExist(row, set, cache["JH"], this.listFileNames[index]))
|
|
|
|
|
|
{
|
|
|
|
|
|
string jh = this.GetMatchValue(cache["JH"], row, this.listFileNames[index]);
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(jh))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!missing.Contains(jh))
|
|
|
|
|
|
{
|
|
|
|
|
|
missingTable.Rows.Add(row.ItemArray);
|
|
|
|
|
|
}
|
|
|
|
|
|
missing.Add(jh);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (!bRet)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (missing.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await this.ImportWellBase(missingTable);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 检查输入数据(层位相关).
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
|
|
|
|
private bool CheckMultipleInputData(List<DataTable> tableList, MatchCache cache)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.cfg.Storage.DataTableList == null || this.cfg.Storage.DataTableList.Rows.Count == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox("请选择数据文件", "提示");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 校验格式
|
|
|
|
|
|
for (int i = 0; i < this.cfg.Storage.DataTableList.Rows.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.cfg.Storage.DataTableList.Rows[i]["层位"].ToString().Trim() == string.Empty)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox("第" + (i + 1) + "行层位名不能为空", "提示");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.tableType == typeof(ScatterBaseBoundary) || this.tableType == typeof(ScatterBaseFault))
|
|
|
|
|
|
{
|
|
|
|
|
|
string cw = this.cfg.Storage.DataTableList.Rows[i]["层位"].ToString().Trim();
|
|
|
|
|
|
if (!DBHelp.Db.Queryable<ScatterBase>().Any(x => x.CW == cw))
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox("第" + (i + 1) + "行散点层位不存,不能保存", "提示");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.cfg.Storage.DataTableList.Rows[i]["层位ID"] = DBHelp.Db.Queryable<ScatterBase>().First(x => x.CW == cw).CWID;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.cfg.UseMatch)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (MatchFromItem item in cache.Matches)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (item.Connections.Count == 0 && item.Name != "线号" && item.Name != "道号")
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox($"请配置{item.Name}列!");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool CheckBoundary(List<DataTable> tableList, MatchCache cache)
|
|
|
|
|
|
{
|
|
|
|
|
|
return this.CheckMultipleInputData(tableList, cache);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool CheckDepthLayer(List<DataTable> tableList, MatchCache cache)
|
|
|
|
|
|
{
|
|
|
|
|
|
return this.CheckMultipleInputData(tableList, cache);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool CheckFault(List<DataTable> tableList, MatchCache cache)
|
|
|
|
|
|
{
|
|
|
|
|
|
return this.CheckMultipleInputData(tableList, cache);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool CheckTimeLayer(List<DataTable> tableList, MatchCache cache)
|
|
|
|
|
|
{
|
|
|
|
|
|
return this.CheckMultipleInputData(tableList, cache);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Checks the well curve.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="tableList">The table list.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <returns>A Task.</returns>
|
|
|
|
|
|
private async Task<bool> CheckWellCurve(List<DataTable> tableList, MatchCache cache)
|
|
|
|
|
|
{
|
|
|
|
|
|
HashSet<string> set = this.GetAvailableWellName();
|
|
|
|
|
|
HashSet<string> missing = new HashSet<string>();
|
|
|
|
|
|
List<string> set2 = DBHelp.Db.Queryable<WellCurve>().Select(x => x.JH).ToList();
|
|
|
|
|
|
HashSet<string> exist = new HashSet<string>();
|
|
|
|
|
|
DataTable missingTable = tableList.First().Clone();
|
|
|
|
|
|
foreach (var dataTable in tableList)
|
|
|
|
|
|
{
|
|
|
|
|
|
string jh = dataTable.TableName;
|
|
|
|
|
|
if (!exist.Contains(jh) && set2.Contains(jh))
|
|
|
|
|
|
{
|
|
|
|
|
|
exist.Add(jh);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (exist.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (DevExpress.XtraSplashScreen.SplashScreenManager.Default != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.CloseForm();
|
|
|
|
|
|
}
|
|
|
|
|
|
var result = new DlgAppend().ShowDialog();
|
|
|
|
|
|
if (result == DialogResult.OK)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.cfg is FrmImportData xtraForm)
|
|
|
|
|
|
{
|
|
|
|
|
|
DevExpress.XtraSplashScreen.SplashScreenManager.ShowForm(xtraForm, typeof(DlgWait), false, false, DevExpress.XtraSplashScreen.ParentFormState.Unlocked);
|
|
|
|
|
|
}
|
|
|
|
|
|
DBHelp.Db.Deleteable<WellCurve>().Where(x => exist.Contains(x.JH)).ExecuteCommand();
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (result == DialogResult.Cancel)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
private async Task<bool> CheckWellCurveOrTimeDepth(List<DataTable> tableList, MatchCache cache)
|
|
|
|
|
|
{
|
|
|
|
|
|
HashSet<string> set = this.GetAvailableWellName();
|
|
|
|
|
|
|
|
|
|
|
|
HashSet<string> missing = new HashSet<string>();
|
|
|
|
|
|
DataTable missingTable = tableList.First().Clone();
|
|
|
|
|
|
|
|
|
|
|
|
int count = this.cfg.Storage.DataTableList.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!this.checkIsWellExist(this.cfg.Storage.DataTableList.Rows[i], set, new MatchData("井号"), this.listFileNames[i]))
|
|
|
|
|
|
{
|
|
|
|
|
|
string jh = this.cfg.Storage.DataTableList.Rows[i]["井号"].ToString();
|
|
|
|
|
|
if (!missing.Contains(jh))
|
|
|
|
|
|
{
|
|
|
|
|
|
missingTable.Rows.Add(this.cfg.Storage.DataTableList.Rows[i].ItemArray);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
missing.Add(jh);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (MatchFromItem item in cache.Matches)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (item.Connections.Count == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox($"请配置{item.Name}列!");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (missing.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await this.ImportWellBase(missingTable);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Checks the well exist.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="tableList">The table list.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <returns>A Task.</returns>
|
|
|
|
|
|
private async Task<bool> CheckWellExist(List<DataTable> tableList, MatchCache cache)
|
|
|
|
|
|
{
|
|
|
|
|
|
HashSet<string> set = this.GetAvailableWellName();
|
|
|
|
|
|
HashSet<string> missing = new HashSet<string>();
|
|
|
|
|
|
DataTable missingTable = tableList.First().Clone();
|
|
|
|
|
|
foreach (var dataTable in tableList)
|
|
|
|
|
|
{
|
|
|
|
|
|
int count = dataTable.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
string jh = dataTable.Rows[i][cache["JH"].MatchColumn].ToString();
|
|
|
|
|
|
if (!set.Contains(jh))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!missing.Contains(jh))
|
|
|
|
|
|
{
|
|
|
|
|
|
missingTable.Rows.Add(dataTable.Rows[i].ItemArray);
|
|
|
|
|
|
}
|
|
|
|
|
|
missing.Add(jh);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (missing.Count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
//不存在的井
|
|
|
|
|
|
//MessageBox.Show();
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool CheckWorkArea(List<DataTable> tableList, MatchCache cache)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool isDfd = this.IsDfdFile(this.cfg.ListFileNames.FirstOrDefault());
|
|
|
|
|
|
|
|
|
|
|
|
if (!isDfd)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (MatchFromItem item in cache.Matches)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (item.Connections.Count == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox($"请配置{item.Name}列!");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool CheckWellCapacity(List<DataTable> tableList, MatchCache cache)
|
|
|
|
|
|
{
|
|
|
|
|
|
return this.CheckInputData(tableList, cache);
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 检查输入数据.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="tableList">The table list.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
|
|
|
|
private bool CheckInputData(List<DataTable> tableList, MatchCache cache)
|
|
|
|
|
|
{
|
|
|
|
|
|
return this.CheckInputData(tableList, cache, null);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 检查输入数据.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="tableList">The table.</param>
|
|
|
|
|
|
/// <param name="cache">The cache.</param>
|
|
|
|
|
|
/// <param name="extendFunc">The extend function.</param>
|
|
|
|
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
|
|
|
|
private bool CheckInputData(List<DataTable> tableList, MatchCache cache, Func<DataRow, int, bool> extendFunc)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int index = 0; index < tableList.Count; index++)
|
|
|
|
|
|
{
|
|
|
|
|
|
DataTable table = tableList[index];
|
|
|
|
|
|
// 校验格式
|
|
|
|
|
|
int count = table.Rows.Count;
|
|
|
|
|
|
int beginIndex = this.cfg.BeginIndex;
|
|
|
|
|
|
for (int i = 0; i < count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this.IsSkippingRow(beginIndex, i))
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
foreach (TableInfo item in this.listColumnNames)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (cache.ContainsMatch(item.ColumnName) && table.Columns.Contains(item.ColumnName))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (item.ColumnType == "整型" || item.ColumnType == "浮点")
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!this.checkIsNumber(this.GetFileNameByIndex(index), table.Rows[i], cache[item.ColumnName]))
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (item.ColumnType == "文本" && int.TryParse(item.ColumnWidth, out int width))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!this.checkIsLessThan(this.GetFileNameByIndex(index), table.Rows[i], cache[item.ColumnName], width))
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (extendFunc?.Invoke(table.Rows[i], index) == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 辅助函数[数据操作]
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Generates the column by preview.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="table">The table.</param>
|
|
|
|
|
|
/// <param name="preview">The preview.</param>
|
|
|
|
|
|
/// <param name="index">The i.</param>
|
|
|
|
|
|
private void GenerateColumnByPreview(DataTable table, PreviewData preview, int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index >= table.Columns.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
string defaultName = "列" + (index + 1);
|
|
|
|
|
|
|
|
|
|
|
|
if (preview.Count > 0 && index < preview[0].Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
string colname = this.cfg.UseHeaderRow ? preview[0][index] : defaultName;
|
|
|
|
|
|
string caption = this.cfg.UseHeaderRow
|
|
|
|
|
|
? preview[0][index] + $"({defaultName})"
|
|
|
|
|
|
: defaultName;
|
|
|
|
|
|
|
|
|
|
|
|
DataColumn col = table.Columns.Add(colname);
|
|
|
|
|
|
col.Caption = caption;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
table.Columns.Add(defaultName);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private int GetTableRecordCount<T>()
|
|
|
|
|
|
{
|
|
|
|
|
|
return DBHelp.NewDb.Queryable<T>().Count();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 转换纵向表为横向表
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="origin">纵向表</param>
|
|
|
|
|
|
/// <returns>横向表</returns>
|
|
|
|
|
|
public DataTable Convert2HorizonTable(DataTable origin)
|
|
|
|
|
|
{
|
|
|
|
|
|
DataTable result = new DataTable();
|
|
|
|
|
|
int columnIndex = this.cfg.BeginColumn;
|
|
|
|
|
|
int columnWidth = this.cfg.ColumnWidth;
|
|
|
|
|
|
int columnEndIndex = this.cfg.BeginColumn + columnWidth;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < columnIndex; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
result.Columns.Add(origin.Columns[i].ColumnName);
|
|
|
|
|
|
}
|
|
|
|
|
|
result.Columns.Add("名称");
|
|
|
|
|
|
for (int i = 0; i < columnWidth; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
result.Columns.Add($"数据{i + 1}");
|
|
|
|
|
|
}
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int i = 0; i < origin.Rows.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (int j = columnIndex; j < origin.Columns.Count; j += columnWidth)
|
|
|
|
|
|
{
|
|
|
|
|
|
object[] objs = origin.Rows[i].ItemArray.Take(columnIndex).ToArray();
|
|
|
|
|
|
objs = objs.Union(new object[] { origin.Columns[j].ColumnName }).ToArray();
|
|
|
|
|
|
for (int k = 0; k < columnWidth; k++)
|
|
|
|
|
|
{
|
|
|
|
|
|
objs = objs.Union(new object[] { origin.Rows[i][j + k], }).ToArray();
|
|
|
|
|
|
}
|
|
|
|
|
|
result.Rows.Add(objs);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取当前WellBase已有的井号
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>井号列表</returns>
|
|
|
|
|
|
private HashSet<string> GetAvailableWellName()
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> list = DBHelp.Db.Queryable<WellBase>().GroupBy(r => r.JH).Select(r => r.JH).ToList();
|
|
|
|
|
|
HashSet<string> set = new HashSet<string>();
|
|
|
|
|
|
foreach (string item in list)
|
|
|
|
|
|
{
|
|
|
|
|
|
set.Add(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取当前WellDeflection已有的井号
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>井号列表</returns>
|
|
|
|
|
|
private HashSet<string> GetAvailableWellDeflectionWellName()
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> list = DBHelp.Db.Queryable<WellDeflection>().GroupBy(r => r.JH).Select(r => r.JH).ToList();
|
|
|
|
|
|
HashSet<string> set = new HashSet<string>();
|
|
|
|
|
|
foreach (string item in list)
|
|
|
|
|
|
{
|
|
|
|
|
|
set.Add(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
return set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取当前WellDeflection已有的井号
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>井号列表</returns>
|
|
|
|
|
|
private HashSet<string> GetAvailableHoriWellFracturParmWellName()
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> list = DBHelp.Db.Queryable<HoriWellFracturParameter>().GroupBy(r => r.JH).Select(r => r.JH).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
HashSet<string> set = new HashSet<string>();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (string item in list)
|
|
|
|
|
|
{
|
|
|
|
|
|
set.Add(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return set;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置属性值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="prop">prop</param>
|
|
|
|
|
|
/// <param name="obj">obj</param>
|
|
|
|
|
|
/// <param name="value">value</param>
|
|
|
|
|
|
private void SetPropertyData(PropertyInfo prop, object obj, string value)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(value))
|
|
|
|
|
|
{
|
|
|
|
|
|
Type type = prop.PropertyType;
|
|
|
|
|
|
if (Nullable.GetUnderlyingType(type) is Type underlyingType)
|
|
|
|
|
|
{
|
|
|
|
|
|
type = underlyingType;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (type == typeof(string))
|
|
|
|
|
|
{
|
|
|
|
|
|
prop.SetValue(obj, value);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (type == typeof(double))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (double.TryParse(value, out double parsed))
|
|
|
|
|
|
{
|
|
|
|
|
|
prop.SetValue(obj, parsed);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (type == typeof(float))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (float.TryParse(value, out float parsed))
|
|
|
|
|
|
{
|
|
|
|
|
|
prop.SetValue(obj, parsed);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (type == typeof(int))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (int.TryParse(value, out int parsed))
|
|
|
|
|
|
{
|
|
|
|
|
|
prop.SetValue(obj, parsed);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (double.TryParse(value, out double parsed2))
|
|
|
|
|
|
{
|
|
|
|
|
|
prop.SetValue(obj, (int)parsed2);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (type == typeof(long))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (long.TryParse(value, out long parsed))
|
|
|
|
|
|
{
|
|
|
|
|
|
prop.SetValue(obj, parsed);
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (double.TryParse(value, out double parsed2))
|
|
|
|
|
|
{
|
|
|
|
|
|
prop.SetValue(obj, (long)parsed2);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (type == typeof(DateTime))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (DateTime.TryParse(value, out DateTime parsed))
|
|
|
|
|
|
{
|
|
|
|
|
|
prop.SetValue(obj, parsed);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SetInterpretProperty(IInterpretEntity entity, int i)
|
|
|
|
|
|
{
|
|
|
|
|
|
// entity.FILE_DATA = this.GetFileData(this.listFileNames[i]);
|
|
|
|
|
|
entity.CW = this.cfg.Storage.DataTableList.Rows[i]["层位"].ToString();
|
|
|
|
|
|
entity.FILE_NAME = this.cfg.Storage.DataTableList.Rows[i]["文件名"].ToString();
|
|
|
|
|
|
entity.CATEGARY = this.cfg.Storage.DataTableList.Rows[i]["类型"].ToString();
|
|
|
|
|
|
|
|
|
|
|
|
string outputfile = Config.ProjectPath + entity.PATH + "\\link\\" + entity.FILE_NAME;
|
|
|
|
|
|
this.PrepareFile(outputfile);
|
|
|
|
|
|
|
|
|
|
|
|
File.Copy(this.listFileNames[i], outputfile, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private InterpretLayer GetInterpretLayer(string cw)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<InterpretLayer> list_layer = this.listInterpretLayer;
|
|
|
|
|
|
|
|
|
|
|
|
InterpretLayer obj_layer = list_layer.FirstOrDefault(o => o.CW.Equals(cw, StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
|
|
|
|
|
|
|
if (obj_layer == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
obj_layer = new InterpretLayer();
|
|
|
|
|
|
int id_cw = list_layer.Count > 0 ? list_layer.Max(o => o.ID) + 1 : 0;
|
|
|
|
|
|
obj_layer.ID = id_cw;
|
|
|
|
|
|
obj_layer.CW = cw;
|
|
|
|
|
|
obj_layer.GQID = WorkConfig.GetGQID();
|
|
|
|
|
|
DBHelp.Db.Storageable(obj_layer).ExecuteCommand();
|
|
|
|
|
|
|
|
|
|
|
|
list_layer.Add(obj_layer);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return obj_layer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private byte[] GetFileData(string fileUrl)
|
|
|
|
|
|
{
|
|
|
|
|
|
int rowindex = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
string charset = this.GetFileEncoding(fileUrl);
|
|
|
|
|
|
|
|
|
|
|
|
using (FileStream stream = File.OpenRead(fileUrl))
|
|
|
|
|
|
using (StreamReader reader = new StreamReader(stream, Encoding.GetEncoding(charset)))
|
|
|
|
|
|
{
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
while (i++ < rowindex && !reader.EndOfStream)
|
|
|
|
|
|
{
|
|
|
|
|
|
reader.ReadLine();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Encoding.UTF8.GetBytes(reader.ReadToEnd());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 输出dfd文件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="m">数据配置结果</param>
|
|
|
|
|
|
/// <param name="filename">输入文件</param>
|
|
|
|
|
|
/// <param name="outputfile">输出文件</param>
|
|
|
|
|
|
/// <param name="layerName">层名</param>
|
|
|
|
|
|
/// <param name="autoClose">自动关闭曲线</param>
|
|
|
|
|
|
/// <returns>Task</returns>
|
|
|
|
|
|
//internal async Task WriteDfdOutput(
|
|
|
|
|
|
// List<MatchFromItem> m,
|
|
|
|
|
|
// string filename,
|
|
|
|
|
|
// string outputfile,
|
|
|
|
|
|
// string layerName,
|
|
|
|
|
|
// bool autoClose)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// const long kMinProgressSize = 100 * 1024 * 1024;
|
|
|
|
|
|
// long filesize = new FileInfo(filename).Length;
|
|
|
|
|
|
|
|
|
|
|
|
// using (FileStream stream = File.OpenRead(filename))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// int xIndex = m.FirstOrDefault(r => r.Index == 0)?.Connections.FirstOrDefault()?.Index ?? 0;
|
|
|
|
|
|
// int yIndex = m.FirstOrDefault(r => r.Index == 1)?.Connections.FirstOrDefault()?.Index ?? 1;
|
|
|
|
|
|
// int nameIndex = m.FirstOrDefault(r => r.Index == 2)?.Connections.FirstOrDefault()?.Index ?? 2;
|
|
|
|
|
|
|
|
|
|
|
|
// int nSkip = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
// DelegateProgress progress = (current, total) =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// double percent = current * 100.0 / total;
|
|
|
|
|
|
// SplashHelper.SetDescription($"文件处理进度: {percent:F1}%");
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
// await CreateCurveDfd(
|
|
|
|
|
|
// stream,
|
|
|
|
|
|
// outputfile,
|
|
|
|
|
|
// layerName,
|
|
|
|
|
|
// nSkip,
|
|
|
|
|
|
// autoClose,
|
|
|
|
|
|
// xIndex,
|
|
|
|
|
|
// yIndex,
|
|
|
|
|
|
// nameIndex,
|
|
|
|
|
|
// filesize > kMinProgressSize ? progress : null);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
|
///// 输出xyz文件
|
|
|
|
|
|
///// </summary>
|
|
|
|
|
|
///// <param name="filename">输入文件</param>
|
|
|
|
|
|
///// <param name="outputfile">输出文件</param>
|
|
|
|
|
|
///// <returns>Task</returns>
|
|
|
|
|
|
//private async Task<RangeData> WriteXYZOutputFromDfd(string filename, string outputfile)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// RangeData data = new RangeData();
|
|
|
|
|
|
|
|
|
|
|
|
// DfdDocument input_doc = await DfdDocument.ParseAsync(filename);
|
|
|
|
|
|
|
|
|
|
|
|
// using (StreamWriter writer = new StreamWriter(outputfile))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// foreach (DfdClass cls in input_doc.Classes)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// foreach (DfdLayer ly in cls.Layers)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// foreach (DfdElementPoint pt in ly.Elements.OfType<DfdElementPoint>())
|
|
|
|
|
|
// {
|
|
|
|
|
|
// data.UpdateX(pt.X);
|
|
|
|
|
|
// data.UpdateY(pt.Y);
|
|
|
|
|
|
// data.UpdateZ(pt.Z);
|
|
|
|
|
|
|
|
|
|
|
|
// writer.WriteLine(string.Join(",", new object[] { pt.X, pt.Y, pt.Z }));
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// writer.Flush();
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// return data;
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 输出xyz文件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="m">数据配置结果</param>
|
|
|
|
|
|
/// <param name="filename">输入文件</param>
|
|
|
|
|
|
/// <param name="outputfile">输出文件</param>
|
|
|
|
|
|
/// <returns>Task</returns>
|
|
|
|
|
|
//private async Task<RangeData> WriteXYZOutput(List<MatchFromItem> m, string filename, string outputfile)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// const long kMinProgressSize = 100 * 1024 * 1024;
|
|
|
|
|
|
// long filesize = new FileInfo(filename).Length;
|
|
|
|
|
|
|
|
|
|
|
|
// using (FileStream fileStream = File.OpenRead(filename))
|
|
|
|
|
|
// using (BufferedStream stream = new BufferedStream(fileStream, 81920))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// int xIndex = m.FirstOrDefault(r => r.Index == 0)?.Connections.FirstOrDefault()?.Index ?? 0;
|
|
|
|
|
|
// int yIndex = m.FirstOrDefault(r => r.Index == 1)?.Connections.FirstOrDefault()?.Index ?? 1;
|
|
|
|
|
|
// int zIndex = m.FirstOrDefault(r => r.Index == 2)?.Connections.FirstOrDefault()?.Index ?? 2;
|
|
|
|
|
|
// int? mIndex = m.FirstOrDefault(r => r.Index == 3)?.Connections.FirstOrDefault()?.Index;
|
|
|
|
|
|
// int? nIndex = m.FirstOrDefault(r => r.Index == 4)?.Connections.FirstOrDefault()?.Index;
|
|
|
|
|
|
|
|
|
|
|
|
// int nSkip = this.cfg.BeginIndex;
|
|
|
|
|
|
|
|
|
|
|
|
// DelegateProgress progress = (current, total) =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// double percent = current * 100.0 / total;
|
|
|
|
|
|
// SplashHelper.SetDescription($"文件处理进度: {percent:F1}%");
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
// return await CreateXYZData(stream, outputfile, nSkip, xIndex, yIndex, zIndex, mIndex, nIndex,
|
|
|
|
|
|
// filesize > kMinProgressSize ? progress : null);
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 转写dfd文件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input">The input.</param>
|
|
|
|
|
|
/// <param name="outputfile">The outputfile.</param>
|
|
|
|
|
|
/// <param name="layerName">Name of the layer.</param>
|
|
|
|
|
|
/// <returns>task</returns>
|
|
|
|
|
|
public static async Task RewriteDfdOutput(string input, string outputfile, string layerName)
|
|
|
|
|
|
{
|
|
|
|
|
|
await Task.CompletedTask;
|
|
|
|
|
|
|
|
|
|
|
|
File.Copy(input, outputfile, true);
|
|
|
|
|
|
|
|
|
|
|
|
/*DfdDocument input_doc = await DfdDocument.ParseAsync(input);
|
|
|
|
|
|
|
|
|
|
|
|
DfdDocument doc = new DfdDocument();
|
|
|
|
|
|
DfdLayer layer = doc.FindOrCreateClass("Layer").FindOrCreateLayer(layerName);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (DfdClass cls in input_doc.Classes)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (DfdLayer ly in cls.Layers)
|
|
|
|
|
|
{
|
|
|
|
|
|
layer.Elements.AddRange(ly.Elements);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using (DfdStreamWriter writer = new DfdStreamWriter(outputfile))
|
|
|
|
|
|
{
|
|
|
|
|
|
await writer.WriteDocumentAsync(doc);
|
|
|
|
|
|
}*/
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 拷贝文件
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="input">The input.</param>
|
|
|
|
|
|
/// <param name="output">The output.</param>
|
|
|
|
|
|
private void RewriteFile(string input, string output)
|
|
|
|
|
|
{
|
|
|
|
|
|
string dir = Path.GetDirectoryName(output);
|
|
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(dir))
|
|
|
|
|
|
{
|
|
|
|
|
|
Directory.CreateDirectory(dir);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
File.Copy(input, output, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 辅助函数[检查/其他]
|
|
|
|
|
|
|
|
|
|
|
|
private string GetMatchValue(MatchData md, DataRow dr, string filename)
|
|
|
|
|
|
{
|
|
|
|
|
|
string value;
|
|
|
|
|
|
|
|
|
|
|
|
if (md?.MatchTag?.StartsWith("$") == true)
|
|
|
|
|
|
{
|
|
|
|
|
|
value = md.MatchTag.Replace("${FileName}", Path.GetFileNameWithoutExtension(filename));
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
value = dr[md.MatchColumn].ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool IsTxtWithHeader(string filepath, string charset)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<string> lines = File.ReadLines(filepath, Encoding.GetEncoding(charset)).Take(10).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (string line in lines)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (line.Contains(":"))
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool checkIsDateTime(string filename, DataRow row, MatchData md)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (md != null && !string.IsNullOrWhiteSpace(md.MatchColumn))
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = this.GetMatchValue(md, row, filename);
|
|
|
|
|
|
|
|
|
|
|
|
if (!Validation.IsDateTime(value))
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox($"文件{filename}, 第{row.Index() + 1}行, {md.ChineseName}列, 格式不正确,非日期类型", "提示");
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool checkIsNotEmpty(string filename, DataRow row, MatchData md)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (md != null && !string.IsNullOrWhiteSpace(md.MatchColumn))
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = this.GetMatchValue(md, row, filename);
|
|
|
|
|
|
|
|
|
|
|
|
if (!Validation.IsNotEmpty(value))
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox($"文件{filename}, 第{row.Index() + 1}行, {md.ChineseName}列, 不能为空!", "提示");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool checkIsLessThan(string filename, DataRow row, MatchData md, int length)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (md != null && !string.IsNullOrWhiteSpace(md.MatchColumn))
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = this.GetMatchValue(md, row, filename);
|
|
|
|
|
|
|
|
|
|
|
|
if (!Validation.IsLessThan(value, length))
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox($"文件{filename}, 第{row.Index() + 1}行, {md.ChineseName}列, 长度不得超过{length}个字符!", "提示");
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool checkIsNumber(string filename, DataRow row, MatchData md)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (md != null && !string.IsNullOrWhiteSpace(md.MatchColumn))
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = this.GetMatchValue(md, row, filename);
|
|
|
|
|
|
|
|
|
|
|
|
if (!Validation.IsNumber(value))
|
|
|
|
|
|
{
|
|
|
|
|
|
this.ShowMessageBox($"文件{filename}, 第{row.Index() + 1}行, {md.ChineseName}列, 格式不正确,非数字类型!,值{value}", "提示");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool checkIsWellExist(DataRow row, HashSet<string> set, MatchData md, string filename)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (md != null && !string.IsNullOrWhiteSpace(md.MatchColumn) && row.Table.Columns.Contains(filename))
|
|
|
|
|
|
{
|
|
|
|
|
|
string value = this.GetMatchValue(md, row, filename);
|
|
|
|
|
|
|
|
|
|
|
|
if (!set.Contains(value))
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private DialogResult ShowMessageBox(string text, string title = "", MessageBoxButtons buttons = MessageBoxButtons.OK, MessageBoxIcon icon = MessageBoxIcon.Information)
|
|
|
|
|
|
{
|
|
|
|
|
|
return this.ui.ShowMessageBox(text, title, buttons, icon);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private string GetFileEncoding(string filename)
|
|
|
|
|
|
{
|
|
|
|
|
|
return EncodingType.GetType(filename)?.BodyName;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool IsXYZFile(string filename)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (filename.EndsWith(".xyz", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool IsDfdFile(string filename)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (filename.EndsWith(".kev", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (filename.EndsWith(".dfd", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// PrepareFile
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="fullpath">f</param>
|
|
|
|
|
|
private void PrepareFile(string fullpath)
|
|
|
|
|
|
{
|
|
|
|
|
|
string dir = Path.GetDirectoryName(fullpath);
|
|
|
|
|
|
|
|
|
|
|
|
if (!Directory.Exists(dir))
|
|
|
|
|
|
{
|
|
|
|
|
|
Directory.CreateDirectory(dir);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (File.Exists(fullpath))
|
|
|
|
|
|
{
|
|
|
|
|
|
File.Delete(fullpath);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 兼容函数
|
|
|
|
|
|
private List<TableInfo> listColumnNames => this.cfg.ListColumnNames;
|
|
|
|
|
|
private List<string> listFileNames => this.cfg.ListFileNames;
|
|
|
|
|
|
private bool IsSkippingRow(int beginIndex, int i) => this.cfg.IsSkippingRow(beginIndex, i);
|
|
|
|
|
|
private string tableName => this.cfg.TableName;
|
|
|
|
|
|
private Type tableType => this.cfg.TableType;
|
|
|
|
|
|
private string dbType => this.cfg.DbType;
|
|
|
|
|
|
private bool AlwaysAppend => this.cfg.AlwaysAppend;
|
|
|
|
|
|
private bool UpdateAppend => this.cfg.UpdateAppend;
|
|
|
|
|
|
private List<InterpretLayer> listInterpretLayer => this.cfg.ListInterpretLayer;
|
|
|
|
|
|
private void RegenerateMatch() => this.ui.RegenerateMatch();
|
|
|
|
|
|
private Task<bool> ImportWellBase(DataTable dt) => this.ui.ImportWellBase(dt);
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the index of the file name by.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="index">The index.</param>
|
|
|
|
|
|
/// <returns>System.String.</returns>
|
|
|
|
|
|
private string GetFileNameByIndex(int index)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (index >= 0 && index < this.listFileNames.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
return this.listFileNames[index];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return "内存数据";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// MatchCache.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class MatchCache : Dictionary<string, MatchData>
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="MatchCache" /> class.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="matches">The matches.</param>
|
|
|
|
|
|
public MatchCache(List<MatchFromItem> matches)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Matches = matches;
|
|
|
|
|
|
foreach (MatchFromItem m in matches)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
//用于处理多条关系
|
|
|
|
|
|
this.Add(m.Tag.ToString().ToUpper(),
|
|
|
|
|
|
new MatchData
|
|
|
|
|
|
{
|
|
|
|
|
|
EnglishName = m.Tag.ToString(),
|
|
|
|
|
|
ChineseName = m.Name,
|
|
|
|
|
|
MatchColumn = m.Connections.FirstOrDefault()?.Name,
|
|
|
|
|
|
MatchTag = m.Connections.FirstOrDefault()?.Tag?.ToString(),
|
|
|
|
|
|
MatchColumns = m.Connections.Select(x => x.Name).ToList(),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets the matches.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value>The matches.</value>
|
|
|
|
|
|
public List<MatchFromItem> Matches { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets the <see cref="MatchData" /> with the specified key.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="key">The key.</param>
|
|
|
|
|
|
/// <returns>MatchData.</returns>
|
|
|
|
|
|
public new MatchData this[string key]
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var newKey = key.ToUpper();
|
|
|
|
|
|
|
|
|
|
|
|
MatchData result;
|
|
|
|
|
|
|
|
|
|
|
|
this.TryGetValue(newKey, out result);
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
var newKey = key.ToUpper();
|
|
|
|
|
|
|
|
|
|
|
|
base[newKey] = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// ContainsKey
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="key">key</param>
|
|
|
|
|
|
/// <returns>bool</returns>
|
|
|
|
|
|
public new bool ContainsKey(string key)
|
|
|
|
|
|
{
|
|
|
|
|
|
var newKey = key.ToUpper();
|
|
|
|
|
|
|
|
|
|
|
|
return base.ContainsKey(newKey);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Determines whether the specified key contains match.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="key">The key.</param>
|
|
|
|
|
|
/// <returns><c>true</c> if the specified key contains match; otherwise, <c>false</c>.</returns>
|
|
|
|
|
|
public bool ContainsMatch(string key)
|
|
|
|
|
|
{
|
|
|
|
|
|
return !string.IsNullOrWhiteSpace(key) && this.ContainsKey(key) && this[key].MatchColumn != null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Class MatchData.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class MatchData
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="MatchData" /> class.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public MatchData()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="MatchData" /> class.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="nameForAll">The name for all.</param>
|
|
|
|
|
|
public MatchData(string nameForAll)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.EnglishName = this.ChineseName = this.MatchColumn = nameForAll;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets the name of the chinese.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value>The name of the chinese.</value>
|
|
|
|
|
|
public string ChineseName { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets the name of the english.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value>The name of the english.</value>
|
|
|
|
|
|
public string EnglishName { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets the match column.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <value>The match column.</value>
|
|
|
|
|
|
public string MatchColumn { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets the match Tag.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string MatchTag { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets or sets the match columns.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public List<string> MatchColumns { get; set; } = new List<string>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// PreviewCache.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class PreviewCache : Dictionary<string, PreviewData>
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// PreviewData.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class PreviewData : List<PreviewLine>
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// PreviewLine.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class PreviewLine : List<string>
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="PreviewLine" /> class.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public PreviewLine()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="PreviewLine" /> class.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="collection">The collection.</param>
|
|
|
|
|
|
public PreviewLine(IEnumerable<string> collection)
|
|
|
|
|
|
: base(collection)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|