1094 lines
47 KiB
C#
1094 lines
47 KiB
C#
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Diagnostics;
|
||
using System.Linq;
|
||
using System.Reflection;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using System.Windows.Forms;
|
||
|
||
using ClosedXML.Excel;
|
||
using System.IO.Packaging;
|
||
using static AnchorsTest.TagAnalyzer;
|
||
using DocumentFormat.OpenXml.Spreadsheet;
|
||
|
||
|
||
namespace AnchorsTest
|
||
{
|
||
internal class Controller
|
||
{
|
||
static Controller instance = null;
|
||
const string _nameConfig = "/Config.json";
|
||
|
||
private DataTable _anchors, _anchorsGroups, _engines, _finalyAncorGroupStates;
|
||
TagsTimerController _tagControler;
|
||
TagsTimerController TagController
|
||
{
|
||
get
|
||
{
|
||
if (_tagControler == null)
|
||
{
|
||
_tagControler = new TagsTimerController();
|
||
}
|
||
return _tagControler;
|
||
}
|
||
}
|
||
public static Controller Get
|
||
{
|
||
get
|
||
{
|
||
if (instance == null)
|
||
{
|
||
instance = new Controller();
|
||
}
|
||
return instance;
|
||
}
|
||
}
|
||
|
||
|
||
// Методы работы с файлом конфигурации
|
||
public void LoadJSConfig()
|
||
{
|
||
// Получаем путь к исполняемому файлу (EXE)
|
||
string exePath = Assembly.GetExecutingAssembly().Location;
|
||
|
||
// Получаем путь к директории, где находится EXE файл
|
||
string exeDirectory = Path.GetDirectoryName(exePath);
|
||
|
||
JSConfig jsConfig = null;
|
||
LoadFromFile(exeDirectory, out jsConfig);
|
||
|
||
Configuration.Get.LoadConfigFromJSConfig(jsConfig);
|
||
}
|
||
|
||
void LoadFromFile(string directoryPath, out JSConfig config)
|
||
{
|
||
directoryPath += _nameConfig;
|
||
string data = File.ReadAllText(directoryPath);
|
||
config = JsonConvert.DeserializeObject<JSConfig>(data);
|
||
if (config == null)
|
||
{
|
||
throw new Exception($"File {directoryPath} not opened");
|
||
}
|
||
}
|
||
|
||
// directoryPath - путь до дирректории
|
||
public void SaveJSConfig()
|
||
{
|
||
// Получаем путь к исполняемому файлу (EXE)
|
||
string exePath = Assembly.GetExecutingAssembly().Location;
|
||
|
||
// Получаем путь к директории, где находится EXE файл
|
||
string exeDirectory = Path.GetDirectoryName(exePath);
|
||
|
||
SaveConfigurationToFile(exeDirectory, Configuration.Get);
|
||
}
|
||
|
||
private void SaveConfigurationToFile(string directoryPath, Configuration config)
|
||
{
|
||
JSConfig jsConfig = Configuration.Get.GetJSConfig();
|
||
SaveConfigurationToFile(directoryPath, jsConfig);
|
||
}
|
||
|
||
private void SaveConfigurationToFile(string directoryPath, JSConfig config)
|
||
{
|
||
string json = JsonConvert.SerializeObject(config);
|
||
Debug.WriteLine(json);
|
||
directoryPath += _nameConfig;
|
||
File.WriteAllText(directoryPath, json);
|
||
}
|
||
|
||
|
||
// Методы работы с API
|
||
public void GetToken()
|
||
{
|
||
RTLSApi api = new RTLSApi();
|
||
api.GetToken(HandleGotToken);
|
||
}
|
||
|
||
void HandleGotToken(string tokenConentDataString)
|
||
{
|
||
TokenData tokenData = JsonConvert.DeserializeObject<TokenData>(tokenConentDataString);
|
||
if (tokenData != null && tokenData.token != null)
|
||
{
|
||
Configuration.Get.RTLSToken = tokenData.token;
|
||
}
|
||
}
|
||
|
||
public void GetMonitorTag(int serNumber)
|
||
{
|
||
RTLSApi api = new RTLSApi();
|
||
api.GetMonitorTag(serNumber, HandlerMonitorTag);
|
||
}
|
||
|
||
private async void HandlerMonitorTag(HttpResponseMessage responce)
|
||
{
|
||
if (responce.IsSuccessStatusCode)
|
||
{
|
||
//responce.Content.ReadAsStringAsync();
|
||
string responceContentString = await responce.Content.ReadAsStringAsync();
|
||
Debug.WriteLine(responceContentString);
|
||
}
|
||
}
|
||
|
||
public void StartTrackTag()
|
||
{
|
||
Configuration.Get.counterGet = 0;
|
||
TagController.Start();
|
||
}
|
||
|
||
public void StopTrackTag()
|
||
{
|
||
TagController.Stop();
|
||
}
|
||
|
||
private string GetLogFolder()
|
||
{
|
||
string exePath = Assembly.GetExecutingAssembly().Location;
|
||
|
||
// Получаем путь к директории, где находится EXE файл
|
||
string exeDirectory = Path.GetDirectoryName(exePath);
|
||
|
||
// Создаём папку logs
|
||
string folderPath = exeDirectory + "\\logs";
|
||
|
||
// Проверяем существование папки
|
||
if (!Directory.Exists(folderPath))
|
||
{
|
||
try
|
||
{
|
||
// Создаем папку
|
||
Directory.CreateDirectory(folderPath);
|
||
Console.WriteLine($"Папка '{folderPath}' успешно создана.");
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
Console.WriteLine($"Ошибка при создании папки '{folderPath}': {ex.Message}");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Console.WriteLine($"Папка '{folderPath}' уже существует.");
|
||
}
|
||
|
||
return folderPath;
|
||
}
|
||
public void SaveTrackTag()
|
||
{
|
||
string fileContent = TagController.SerializeObject();
|
||
DateTime now = DateTime.Now;
|
||
string formattedDateTime = $"{now.Year}#{now.Month:D2}#{now.Day:D2}_{now.Hour:D2}#{now.Second:D2}";
|
||
string fileName = $"{Configuration.Get.TrackingTag}_{Configuration.Get.FileTagSuffix}_{formattedDateTime}.json";
|
||
|
||
string folderPath = GetLogFolder();
|
||
|
||
|
||
// Сохраняет содержимое
|
||
string fullPathFile = Path.Combine(folderPath, fileName);
|
||
File.WriteAllText(fullPathFile, fileContent);
|
||
}
|
||
|
||
public void ChooseFile1Path()
|
||
{
|
||
string folderPath = GetLogFolder();
|
||
|
||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||
openFileDialog.InitialDirectory = folderPath;
|
||
openFileDialog.Filter = "Json files | *.json"; // указываем типы файлов для загрузки
|
||
|
||
openFileDialog.RestoreDirectory = true;
|
||
string selectedFile;
|
||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||
{
|
||
// Process selected file
|
||
selectedFile = openFileDialog.FileName;
|
||
Console.WriteLine($"Selected file: {selectedFile}");
|
||
|
||
Configuration.Get.File1Path = selectedFile;
|
||
MainWindowForm.Instance.LabelFile1Path.Text = selectedFile;
|
||
}
|
||
else
|
||
{
|
||
Console.WriteLine("Dialog was canceled.");
|
||
return;
|
||
}
|
||
}
|
||
|
||
public void ChooseFile2Path()
|
||
{
|
||
string folderPath = GetLogFolder();
|
||
|
||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||
openFileDialog.InitialDirectory = folderPath;
|
||
openFileDialog.Filter = "Json files | *.json"; // указываем типы файлов для загрузки
|
||
|
||
openFileDialog.RestoreDirectory = true;
|
||
string selectedFile;
|
||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||
{
|
||
// Process selected file
|
||
selectedFile = openFileDialog.FileName;
|
||
Console.WriteLine($"Selected file: {selectedFile}");
|
||
|
||
Configuration.Get.File2Path = selectedFile;
|
||
MainWindowForm.Instance.LabelFile2Path.Text = selectedFile;
|
||
}
|
||
else
|
||
{
|
||
Console.WriteLine("Dialog was canceled.");
|
||
return;
|
||
}
|
||
}
|
||
|
||
public void Analyze()
|
||
{
|
||
//Configuration.Get.RTLSToken
|
||
if (Configuration.Get.File1Path != "" && Configuration.Get.File2Path != "")
|
||
{
|
||
TagAnalyzer analyzer1 = new TagAnalyzer();
|
||
TagAnalyzer analyzer2 = new TagAnalyzer();
|
||
analyzer1.Analyze(Configuration.Get.File1Path);
|
||
analyzer2.Analyze(Configuration.Get.File2Path);
|
||
|
||
// Обновляем dataSource
|
||
|
||
//MainWindowForm.Instance.GridViewAnchorState.DataSource = GetDataTableAnchorSate(analyzer1, analyzer2);
|
||
_anchors = GetDataTableAnchorSate(analyzer1, analyzer2);
|
||
_anchorsGroups = GetDataTableAnchorGroupSate(analyzer1, analyzer2);
|
||
_finalyAncorGroupStates = GetDataTableFinalyAnchorGroupSate(analyzer1, analyzer2);
|
||
_engines = GetDataTableEngineSate(analyzer1, analyzer2);
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
DataTable GetDataTableAnchorGroupSate(TagAnalyzer analyzer1, TagAnalyzer analyzer2)
|
||
{
|
||
DataTable anchorStatesDataTable = new DataTable();
|
||
var anchorGroupStates1 = analyzer1.AnchorsGroupState;
|
||
var anchorGroupStates2 = analyzer2.AnchorsGroupState;
|
||
|
||
// Use HashSet to store unique keys
|
||
HashSet<int> uniqueKeys = new HashSet<int>();
|
||
|
||
// Add keys from dict1
|
||
foreach (int key in anchorGroupStates1.Keys)
|
||
{
|
||
uniqueKeys.Add(key);
|
||
}
|
||
|
||
// Add keys from dict2
|
||
foreach (int key in anchorGroupStates2.Keys)
|
||
{
|
||
uniqueKeys.Add(key);
|
||
}
|
||
|
||
anchorStatesDataTable.TableName = "Сравнение анкерных групп";
|
||
|
||
// Добавляем столбцы
|
||
// Common
|
||
anchorStatesDataTable.Columns.Add("SN", typeof(long));
|
||
anchorStatesDataTable.Columns.Add("AnchorGroupName", typeof(string));
|
||
anchorStatesDataTable.Columns.Add("Count1", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentTotal1", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("Count2", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentTotal2", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("CountDif", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentTotalDif", typeof(double));
|
||
|
||
// RSS
|
||
anchorStatesDataTable.Columns.Add("RSSAverage1", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("RSSAverage2", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("RSSAveragePercent", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("RSSMin1", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("RSSMin2", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("RSSMinPercent", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("RSSMax1", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("RSSMax2", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("RSSMaxPercent", typeof(double));
|
||
|
||
|
||
foreach (int key in uniqueKeys)
|
||
{
|
||
//var state1 = anchorGroupStates1[key];
|
||
//var state2 = anchorGroupStates2[key];
|
||
TagAnalyzer.AnchorGroupState state1 = null, state2 = null;
|
||
if (anchorGroupStates1.ContainsKey(key))
|
||
{
|
||
state1 = anchorGroupStates1[key];
|
||
}
|
||
if (anchorGroupStates2.ContainsKey(key))
|
||
{
|
||
state2 = anchorGroupStates2[key];
|
||
}
|
||
|
||
DataRow newRow = anchorStatesDataTable.Rows.Add();
|
||
|
||
newRow["SN"] = key;
|
||
|
||
if (state1 == null)
|
||
{
|
||
newRow["AnchorGroupName"] = state2.name;
|
||
|
||
newRow["count1"] = 0;
|
||
newRow["PercentTotal1"] = 0;
|
||
newRow["count2"] = state2.count;
|
||
newRow["PercentTotal2"] = state2.percentTotalCount;
|
||
newRow["CountDif"] = state2.count;
|
||
newRow["PercentTotalDif"] = state2.percentTotalCount;
|
||
|
||
newRow["RSSAverage1"] = 0;
|
||
newRow["RSSAverage2"] = state2.AverageRSS;
|
||
newRow["RSSAveragePercent"] = 1.0;
|
||
newRow["RSSMin1"] = 0;
|
||
newRow["RSSMin2"] = state2.minRSS;
|
||
newRow["RSSMinPercent"] = 1.0;
|
||
newRow["RSSMax1"] = 0;
|
||
newRow["RSSMax2"] = state2.maxRSS;
|
||
newRow["RSSMaxPercent"] = 1.0;
|
||
}
|
||
else if (state2 == null)
|
||
{
|
||
newRow["AnchorGroupName"] = state1.name;
|
||
newRow["count1"] = state1.count;
|
||
newRow["PercentTotal1"] = state1.percentTotalCount;
|
||
newRow["count2"] = 0;
|
||
newRow["PercentTotal2"] = 0;
|
||
newRow["CountDif"] = -state1.count;
|
||
newRow["PercentTotalDif"] = -state1.percentTotalCount;
|
||
|
||
newRow["RSSAverage1"] = state1.AverageRSS;
|
||
newRow["RSSAverage2"] = 0;
|
||
newRow["RSSAveragePercent"] = -1.0;
|
||
newRow["RSSMin1"] = state1.minRSS;
|
||
newRow["RSSMin2"] = 0;
|
||
newRow["RSSMinPercent"] = -1.0;
|
||
newRow["RSSMax1"] = state1.maxRSS;
|
||
newRow["RSSMax2"] = 0;
|
||
newRow["RSSMaxPercent"] = -1.0;
|
||
}
|
||
else
|
||
{
|
||
newRow["AnchorGroupName"] = state2.name;
|
||
newRow["count1"] = state1.count;
|
||
newRow["PercentTotal1"] = state1.percentTotalCount;
|
||
newRow["count2"] = state2.count;
|
||
newRow["PercentTotal2"] = state2.percentTotalCount;
|
||
newRow["CountDif"] = state2.count - state1.count;
|
||
newRow["PercentTotalDif"] = state2.percentTotalCount - state1.percentTotalCount;
|
||
|
||
newRow["RSSAverage1"] = state1.AverageRSS;
|
||
newRow["RSSAverage2"] = state2.AverageRSS;
|
||
newRow["RSSAveragePercent"] = (1 - state2.AverageRSS / state1.AverageRSS);
|
||
newRow["RSSMin1"] = state1.minRSS;
|
||
newRow["RSSMin2"] = state2.minRSS;
|
||
newRow["RSSMinPercent"] = 1 - state2.minRSS / state1.minRSS;
|
||
newRow["RSSMax1"] = state1.maxRSS;
|
||
newRow["RSSMax2"] = state2.maxRSS;
|
||
newRow["RSSMaxPercent"] = 1 - state2.maxRSS / state1.maxRSS;
|
||
}
|
||
}
|
||
return anchorStatesDataTable;
|
||
}
|
||
|
||
DataTable GetDataTableFinalyAnchorGroupSate(TagAnalyzer analyzer1, TagAnalyzer analyzer2)
|
||
{
|
||
DataTable anchorStatesFinalyDataTable = new DataTable();
|
||
var anchorGroupFinalyStates1 = analyzer1.FinalyAnchorGroup;
|
||
var anchorGroupFinalyStates2 = analyzer2.FinalyAnchorGroup;
|
||
|
||
// Use HashSet to store unique keys
|
||
HashSet<long> uniqueKeys = new HashSet<long>();
|
||
|
||
// Add keys from dict1
|
||
foreach (long key in anchorGroupFinalyStates1.Keys)
|
||
{
|
||
uniqueKeys.Add(key);
|
||
}
|
||
|
||
// Add keys from dict2
|
||
foreach (long key in anchorGroupFinalyStates2.Keys)
|
||
{
|
||
uniqueKeys.Add(key);
|
||
}
|
||
|
||
|
||
anchorStatesFinalyDataTable.TableName = "финал анкерных групп";
|
||
|
||
// Добавляем столбцы
|
||
// Common
|
||
anchorStatesFinalyDataTable.Columns.Add("SN", typeof(long));
|
||
anchorStatesFinalyDataTable.Columns.Add("AnchorGroupName", typeof(string));
|
||
anchorStatesFinalyDataTable.Columns.Add("Count1", typeof(int));
|
||
anchorStatesFinalyDataTable.Columns.Add("PercentTotal1", typeof(double));
|
||
anchorStatesFinalyDataTable.Columns.Add("Count2", typeof(int));
|
||
anchorStatesFinalyDataTable.Columns.Add("PercentTotal2", typeof(double));
|
||
anchorStatesFinalyDataTable.Columns.Add("CountDif", typeof(int));
|
||
anchorStatesFinalyDataTable.Columns.Add("PercentTotalDif", typeof(double));
|
||
|
||
// Valid
|
||
anchorStatesFinalyDataTable.Columns.Add("CountValid1", typeof(int));
|
||
anchorStatesFinalyDataTable.Columns.Add("PercentValid1", typeof(double));
|
||
anchorStatesFinalyDataTable.Columns.Add("CountValid2", typeof(int));
|
||
anchorStatesFinalyDataTable.Columns.Add("PercentValid2", typeof(double));
|
||
anchorStatesFinalyDataTable.Columns.Add("CountValidDiff", typeof(int));
|
||
anchorStatesFinalyDataTable.Columns.Add("CountValidPercentDiff", typeof(double));
|
||
|
||
// Z
|
||
anchorStatesFinalyDataTable.Columns.Add("ZAverage1", typeof(double));
|
||
anchorStatesFinalyDataTable.Columns.Add("ZAverage2", typeof(double));
|
||
anchorStatesFinalyDataTable.Columns.Add("ZAveragePercent", typeof(double));
|
||
anchorStatesFinalyDataTable.Columns.Add("ZMin1", typeof(double));
|
||
anchorStatesFinalyDataTable.Columns.Add("ZMin2", typeof(double));
|
||
anchorStatesFinalyDataTable.Columns.Add("ZMinPercent", typeof(double));
|
||
anchorStatesFinalyDataTable.Columns.Add("ZMax1", typeof(double));
|
||
anchorStatesFinalyDataTable.Columns.Add("ZMax2", typeof(double));
|
||
anchorStatesFinalyDataTable.Columns.Add("ZMaxPercent", typeof(double));
|
||
|
||
|
||
foreach (long key in uniqueKeys)
|
||
{
|
||
TagAnalyzer.AnchorGroupFinalyState state1 = null, state2 = null;
|
||
if (anchorGroupFinalyStates1.ContainsKey(key))
|
||
{
|
||
state1 = anchorGroupFinalyStates1[key];
|
||
}
|
||
if (anchorGroupFinalyStates2.ContainsKey(key))
|
||
{
|
||
state2 = anchorGroupFinalyStates2[key];
|
||
}
|
||
|
||
DataRow newRow = anchorStatesFinalyDataTable.Rows.Add();
|
||
|
||
newRow["SN"] = key;
|
||
if (key == 0)
|
||
{
|
||
if (state1 != null)
|
||
{
|
||
state1.name = "Undef";
|
||
}
|
||
if (state2 != null)
|
||
{
|
||
state2.name = "Undef";
|
||
}
|
||
}
|
||
if (state1 == null)
|
||
{
|
||
newRow["AnchorGroupName"] = state2.name;
|
||
newRow["count1"] = 0;
|
||
newRow["PercentTotal1"] = 0;
|
||
newRow["count2"] = state2.count;
|
||
newRow["PercentTotal2"] = state2.percentTotalCount;
|
||
newRow["CountDif"] = state2.count;
|
||
newRow["PercentTotalDif"] = state2.percentTotalCount;
|
||
|
||
// Валидность
|
||
newRow["CountValid1"] = 0;
|
||
newRow["PercentValid1"] = 0;
|
||
newRow["CountValid2"] = state2.countValid;
|
||
newRow["PercentValid2"] = state2.percentValid;
|
||
newRow["CountValidDiff"] = state2.countValid;
|
||
newRow["CountValidPercentDiff"] = state2.percentValid;
|
||
|
||
newRow["ZAverage1"] = 0;
|
||
newRow["ZAverage2"] = state2.ZMin;
|
||
newRow["ZAveragePercent"] = 1.0;
|
||
|
||
// Z
|
||
newRow["ZMin1"] = 0;
|
||
newRow["ZMin2"] = state2.ZMin;
|
||
newRow["ZMinPercent"] = 1.0;
|
||
newRow["ZMax1"] = 0;
|
||
newRow["ZMax2"] = state2.ZMax;
|
||
newRow["ZMaxPercent"] = 1.0;
|
||
}
|
||
else if (state2 == null)
|
||
{
|
||
newRow["AnchorGroupName"] = state1.name;
|
||
newRow["count1"] = state1.count;
|
||
newRow["PercentTotal1"] = state1.percentTotalCount;
|
||
newRow["count2"] = 0;
|
||
newRow["PercentTotal2"] = 0;
|
||
newRow["CountDif"] = -state1.count;
|
||
newRow["PercentTotalDif"] = -state1.percentTotalCount;
|
||
|
||
// Валидность
|
||
newRow["CountValid1"] = state1.countValid;
|
||
newRow["PercentValid1"] = state1.percentValid;
|
||
newRow["CountValid2"] = 0;
|
||
newRow["PercentValid2"] = 0;
|
||
newRow["CountValidDiff"] = -state1.countValid;
|
||
newRow["CountValidPercentDiff"] = -state1.percentValid;
|
||
|
||
newRow["ZAverage1"] = state1.ZMin;
|
||
newRow["ZAverage2"] = 0;
|
||
newRow["ZAveragePercent"] = -1.0;
|
||
|
||
// Z
|
||
newRow["ZMin1"] = state1.ZMin;
|
||
newRow["ZMin2"] = 0;
|
||
newRow["ZMinPercent"] = -1.0;
|
||
|
||
newRow["ZMax1"] = state1.ZMax;
|
||
newRow["ZMax2"] = 0;
|
||
newRow["ZMaxPercent"] = -1.0;
|
||
}
|
||
else
|
||
{
|
||
newRow["AnchorGroupName"] = state2.name;
|
||
newRow["count1"] = state1.count;
|
||
newRow["PercentTotal1"] = state1.percentTotalCount;
|
||
newRow["count2"] = state2.count;
|
||
newRow["PercentTotal2"] = state2.percentTotalCount;
|
||
newRow["CountDif"] = state2.count - state1.count;
|
||
newRow["PercentTotalDif"] = state2.percentTotalCount - state1.percentTotalCount;
|
||
|
||
// Валидность
|
||
newRow["CountValid1"] = state1.countValid;
|
||
newRow["PercentValid1"] = state1.percentValid;
|
||
newRow["CountValid2"] = state2.countValid;
|
||
newRow["PercentValid2"] = state2.percentValid;
|
||
newRow["CountValidDiff"] = state2.countValid - state1.countValid;
|
||
newRow["CountValidPercentDiff"] = state2.percentValid - state1.percentValid;
|
||
|
||
newRow["ZAverage1"] = state1.ZMin;
|
||
newRow["ZAverage2"] = state2.ZMin;
|
||
newRow["ZAveragePercent"] = state2.ZMin / state1.ZMin - 1;
|
||
|
||
// Z
|
||
newRow["ZMin1"] = state1.ZMin;
|
||
newRow["ZMin2"] = state2.ZMin;
|
||
newRow["ZMinPercent"] = state2.ZMin / state1.ZMin - 1;
|
||
|
||
newRow["ZMax1"] = state1.ZMax;
|
||
newRow["ZMax2"] = state2.ZMax;
|
||
newRow["ZMaxPercent"] = state2.ZMax / state1.ZMax - 1;
|
||
}
|
||
}
|
||
return anchorStatesFinalyDataTable;
|
||
}
|
||
|
||
DataTable GetDataTableEngineSate(TagAnalyzer analyzer1, TagAnalyzer analyzer2)
|
||
{
|
||
DataTable anchorStatesFinalyDataTable = new DataTable();
|
||
var engineStates1 = analyzer1.EnginesSate;
|
||
var engineStates2 = analyzer2.EnginesSate;
|
||
|
||
// Use HashSet to store unique keys
|
||
HashSet<long> uniqueKeys = new HashSet<long>();
|
||
|
||
// Add keys from dict1
|
||
foreach (var key in engineStates1)
|
||
{
|
||
uniqueKeys.Add(key.Key);
|
||
}
|
||
|
||
// Add keys from dict2
|
||
foreach (var key in engineStates2)
|
||
{
|
||
uniqueKeys.Add(key.Key);
|
||
}
|
||
|
||
anchorStatesFinalyDataTable.TableName = "Сравнение движков";
|
||
|
||
// Добавляем столбцы
|
||
// Common
|
||
anchorStatesFinalyDataTable.Columns.Add("SN", typeof(long));
|
||
anchorStatesFinalyDataTable.Columns.Add("EngineName", typeof(string));
|
||
anchorStatesFinalyDataTable.Columns.Add("Count1", typeof(int));
|
||
anchorStatesFinalyDataTable.Columns.Add("PercentTotal1", typeof(double));
|
||
anchorStatesFinalyDataTable.Columns.Add("Count2", typeof(int));
|
||
anchorStatesFinalyDataTable.Columns.Add("PercentTotal2", typeof(double));
|
||
anchorStatesFinalyDataTable.Columns.Add("CountDif", typeof(int));
|
||
anchorStatesFinalyDataTable.Columns.Add("PercentTotalDif", typeof(double));
|
||
|
||
foreach (long key in uniqueKeys)
|
||
{
|
||
TagAnalyzer.EngineState state1 = null, state2 = null;
|
||
if (engineStates1.ContainsKey(key))
|
||
{
|
||
state1 = engineStates1[key];
|
||
}
|
||
if (engineStates2.ContainsKey(key))
|
||
{
|
||
state2 = engineStates2[key];
|
||
}
|
||
|
||
DataRow newRow = anchorStatesFinalyDataTable.Rows.Add();
|
||
|
||
newRow["SN"] = key;
|
||
if (state1 == null)
|
||
{
|
||
newRow["EngineName"] = state2.name;
|
||
|
||
newRow["count1"] = 0;
|
||
newRow["PercentTotal1"] = 0;
|
||
newRow["count2"] = state2.count;
|
||
newRow["PercentTotal2"] = state2.percentTotalCount;
|
||
newRow["CountDif"] = state2.count;
|
||
newRow["PercentTotalDif"] = state2.percentTotalCount;
|
||
}
|
||
else if (state2 == null)
|
||
{
|
||
newRow["EngineName"] = state1.name;
|
||
newRow["count1"] = state1.count;
|
||
newRow["PercentTotal1"] = state1.percentTotalCount;
|
||
newRow["count2"] = 0;
|
||
newRow["PercentTotal2"] = 0;
|
||
newRow["CountDif"] = -state1.count;
|
||
newRow["PercentTotalDif"] = -state1.percentTotalCount;
|
||
}
|
||
else
|
||
{
|
||
newRow["EngineName"] = state2.name;
|
||
newRow["count1"] = state1.count;
|
||
newRow["PercentTotal1"] = state1.percentTotalCount;
|
||
newRow["count2"] = state2.count;
|
||
newRow["PercentTotal2"] = state2.percentTotalCount;
|
||
newRow["CountDif"] = state2.count - state1.count;
|
||
newRow["PercentTotalDif"] = state2.percentTotalCount - state1.percentTotalCount;
|
||
}
|
||
}
|
||
return anchorStatesFinalyDataTable;
|
||
}
|
||
|
||
DataTable GetDataTableAnchorSate(TagAnalyzer analyzer1, TagAnalyzer analyzer2)
|
||
{
|
||
DataTable anchorStatesDataTable = new DataTable();
|
||
Dictionary<long, AnchorState> anchorStates1, anchorStates2;
|
||
anchorStates1 = analyzer1.AnchorsStates;
|
||
anchorStates2 = analyzer2.AnchorsStates;
|
||
|
||
|
||
|
||
// Use HashSet to store unique keys
|
||
HashSet<int> uniqueKeys = new HashSet<int>();
|
||
|
||
// Add keys from dict1
|
||
foreach (int key in anchorStates1.Keys)
|
||
{
|
||
uniqueKeys.Add(key);
|
||
}
|
||
|
||
// Add keys from dict2
|
||
foreach (int key in anchorStates2.Keys)
|
||
{
|
||
uniqueKeys.Add(key);
|
||
}
|
||
|
||
anchorStatesDataTable.TableName = "Сравнение анкеров";
|
||
|
||
// Добавляем столбцы
|
||
// Common
|
||
anchorStatesDataTable.Columns.Add("SN", typeof(long));
|
||
anchorStatesDataTable.Columns.Add("Count1", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentTotal1", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("Count2", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentTotal2", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("CountDif", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentTotalDif", typeof(double));
|
||
|
||
// RSS
|
||
anchorStatesDataTable.Columns.Add("RSSAverage1", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("RSSAverage2", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("RSSAveragePercent", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("RSSMin1", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("RSSMin2", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("RSSMinPercent", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("RSSMax1", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("RSSMax2", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("RSSMaxPercent", typeof(double));
|
||
|
||
// LOS
|
||
anchorStatesDataTable.Columns.Add("CountLos1", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentLos1", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("CountLos2", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentLos2", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("CountLosDiff", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentLosDiff", typeof(double));
|
||
|
||
// NLOS
|
||
anchorStatesDataTable.Columns.Add("CountNLos1", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentNLos1", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("CountNLos2", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentNLos2", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("CountNLosDiff", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentNLosDiff", typeof(double));
|
||
|
||
// Undef
|
||
anchorStatesDataTable.Columns.Add("CountUndef1", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentUndef1", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("CountUndef2", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentUndef2", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("CountUndefDiff", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentUndefDiff", typeof(double));
|
||
|
||
// Empty
|
||
anchorStatesDataTable.Columns.Add("CountEmpty1", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentEmpty1", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("CountEmpty2", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentEmpty2", typeof(double));
|
||
anchorStatesDataTable.Columns.Add("CountEmptyDiff", typeof(int));
|
||
anchorStatesDataTable.Columns.Add("PercentEmptyDiff", typeof(double));
|
||
|
||
foreach (int key in uniqueKeys)
|
||
{
|
||
//var state1 = anchorStates1[key];
|
||
//var state2 = anchorStates2[key];
|
||
|
||
|
||
TagAnalyzer.AnchorState state1 = null, state2 = null;
|
||
if (anchorStates1.ContainsKey(key))
|
||
{
|
||
state1 = anchorStates1[key];
|
||
}
|
||
if (anchorStates2.ContainsKey(key))
|
||
{
|
||
state2 = anchorStates2[key];
|
||
}
|
||
|
||
DataRow newRow = anchorStatesDataTable.Rows.Add();
|
||
|
||
newRow["SN"] = key;
|
||
if (key == 2825)
|
||
{
|
||
Console.WriteLine();
|
||
}
|
||
if (state1 == null || state1.countEmptyPercent == 1.0)
|
||
{
|
||
newRow["count1"] = 0;
|
||
newRow["PercentTotal1"] = 0;
|
||
newRow["count2"] = state2.count;
|
||
newRow["PercentTotal2"] = state2.percentTotalCount;
|
||
newRow["CountDif"] = state2.count;
|
||
newRow["PercentTotalDif"] = state2.percentTotalCount;
|
||
|
||
newRow["RSSAverage1"] = 0;
|
||
newRow["RSSAverage2"] = state2.AverageRSS;
|
||
newRow["RSSAveragePercent"] = 1.0;
|
||
newRow["RSSMin1"] = 0;
|
||
newRow["RSSMin2"] = state2.minRSS;
|
||
newRow["RSSMinPercent"] = 1.0;
|
||
newRow["RSSMax1"] = 0;
|
||
newRow["RSSMax2"] = state2.maxRSS;
|
||
newRow["RSSMaxPercent"] = 1.0;
|
||
|
||
newRow["CountLos1"] = 0;
|
||
newRow["PercentLos1"] = 0;
|
||
newRow["CountLos2"] = state2.countLos;
|
||
newRow["PercentLos2"] = state2.countLosPercent;
|
||
newRow["CountLosDiff"] = state2.countLos;
|
||
newRow["PercentLosDiff"] = state2.countLosPercent;
|
||
|
||
newRow["CountNLos1"] = 0;
|
||
newRow["PercentNLos1"] = 0;
|
||
newRow["CountNLos2"] = state2.countNLos;
|
||
newRow["PercentNLos2"] = state2.countNLosPercent;
|
||
newRow["CountNLosDiff"] = state2.count;
|
||
newRow["PercentNLosDiff"] = state2.countNLosPercent;
|
||
|
||
newRow["CountUndef1"] = 0;
|
||
newRow["PercentUndef1"] = 0;
|
||
newRow["CountUndef2"] = state2.countUndef;
|
||
newRow["PercentUndef2"] = state2.countUndefPercent;
|
||
newRow["CountUndefDiff"] = state2.countUndef;
|
||
newRow["PercentUndefDiff"] = state2.countUndefPercent;
|
||
|
||
newRow["CountEmpty1"] = 0;
|
||
newRow["PercentEmpty1"] = 0;
|
||
newRow["CountEmpty2"] = state2.countEmpty;
|
||
newRow["PercentEmpty2"] = state2.countEmptyPercent;
|
||
newRow["CountEmptyDiff"] = state2.countEmpty;
|
||
newRow["PercentEmptyDiff"] = state2.countEmptyPercent;
|
||
}
|
||
else if (state2 == null || state2.countEmptyPercent == 1.0)
|
||
{
|
||
newRow["count1"] = state1.count;
|
||
newRow["PercentTotal1"] = state1.percentTotalCount;
|
||
newRow["count2"] = 0;
|
||
newRow["PercentTotal2"] = 0;
|
||
newRow["CountDif"] = -state1.count;
|
||
newRow["PercentTotalDif"] = -state1.percentTotalCount;
|
||
|
||
newRow["RSSAverage1"] = state1.AverageRSS;
|
||
newRow["RSSAverage2"] = 0;
|
||
newRow["RSSAveragePercent"] = -1.0;
|
||
newRow["RSSMin1"] = state1.minRSS;
|
||
newRow["RSSMin2"] = 0;
|
||
newRow["RSSMinPercent"] = -1.0;
|
||
newRow["RSSMax1"] = state1.maxRSS;
|
||
newRow["RSSMax2"] = 0;
|
||
newRow["RSSMaxPercent"] = -1.0;
|
||
|
||
newRow["CountLos1"] = state1.countLos;
|
||
newRow["PercentLos1"] = state1.countLosPercent;
|
||
newRow["CountLos2"] = 0;
|
||
newRow["PercentLos2"] = 0;
|
||
newRow["CountLosDiff"] = -state1.countLos;
|
||
newRow["PercentLosDiff"] = -state1.countLosPercent;
|
||
|
||
newRow["CountNLos1"] = state1.countNLos;
|
||
newRow["PercentNLos1"] = state1.countNLosPercent;
|
||
newRow["CountNLos2"] = 0;
|
||
newRow["PercentNLos2"] = 0;
|
||
newRow["CountNLosDiff"] = -state1.countNLos;
|
||
newRow["PercentNLosDiff"] = -state1.countNLosPercent;
|
||
|
||
newRow["CountUndef1"] = state1.countUndef;
|
||
newRow["PercentUndef1"] = state1.countUndefPercent;
|
||
newRow["CountUndef2"] = 0;
|
||
newRow["PercentUndef2"] = 0;
|
||
newRow["CountUndefDiff"] = -state1.countUndef;
|
||
newRow["PercentUndefDiff"] = -state1.countUndefPercent;
|
||
|
||
newRow["CountEmpty1"] = state1.countEmpty;
|
||
newRow["PercentEmpty1"] = state1.countEmptyPercent;
|
||
newRow["CountEmpty2"] = 0;
|
||
newRow["PercentEmpty2"] = 0;
|
||
newRow["CountEmptyDiff"] = -state1.countEmpty;
|
||
newRow["PercentEmptyDiff"] = -state1.countEmptyPercent;
|
||
}
|
||
else
|
||
{
|
||
newRow["count1"] = state1.count;
|
||
newRow["PercentTotal1"] = state1.percentTotalCount;
|
||
newRow["count2"] = state2.count;
|
||
newRow["PercentTotal2"] = state2.percentTotalCount;
|
||
newRow["CountDif"] = state2.count - state1.count;
|
||
newRow["PercentTotalDif"] = state2.percentTotalCount - state1.percentTotalCount;
|
||
|
||
newRow["RSSAverage1"] = state1.AverageRSS;
|
||
newRow["RSSAverage2"] = state2.AverageRSS;
|
||
|
||
double RSSAverage = 0;
|
||
if (state1.AverageRSS != 0)
|
||
{
|
||
RSSAverage = (1 - state2.AverageRSS / state1.AverageRSS);
|
||
}
|
||
newRow["RSSAveragePercent"] = RSSAverage;
|
||
newRow["RSSMin1"] = state1.minRSS;
|
||
newRow["RSSMin2"] = state2.minRSS;
|
||
newRow["RSSMinPercent"] = 1 - state2.minRSS / state1.minRSS;
|
||
newRow["RSSMax1"] = state1.maxRSS;
|
||
newRow["RSSMax2"] = state2.maxRSS;
|
||
newRow["RSSMaxPercent"] = 1 - state2.maxRSS / state1.maxRSS;
|
||
|
||
newRow["CountLos1"] = state1.countLos;
|
||
newRow["PercentLos1"] = state1.countLosPercent;
|
||
newRow["CountLos2"] = state2.countLos;
|
||
newRow["PercentLos2"] = state2.countLosPercent;
|
||
newRow["CountLosDiff"] = state2.countLos - state1.countLos;
|
||
newRow["PercentLosDiff"] = state2.countLosPercent - state1.countLosPercent;
|
||
|
||
newRow["CountNLos1"] = state1.countNLos;
|
||
newRow["PercentNLos1"] = state1.countNLosPercent;
|
||
newRow["CountNLos2"] = state2.countNLos;
|
||
newRow["PercentNLos2"] = state2.countNLosPercent;
|
||
newRow["CountNLosDiff"] = state2.countNLos - state1.countNLos;
|
||
newRow["PercentNLosDiff"] = state2.countNLosPercent - state1.countNLosPercent;
|
||
|
||
newRow["CountUndef1"] = state1.countUndef;
|
||
newRow["PercentUndef1"] = state1.countUndefPercent;
|
||
newRow["CountUndef2"] = state2.countUndef;
|
||
newRow["PercentUndef2"] = state2.countUndefPercent;
|
||
newRow["CountUndefDiff"] = state2.countUndef - state1.countUndef;
|
||
newRow["PercentUndefDiff"] = state2.countUndefPercent - state1.countUndefPercent;
|
||
|
||
newRow["CountEmpty1"] = state1.countEmpty;
|
||
newRow["PercentEmpty1"] = state1.countEmptyPercent;
|
||
newRow["CountEmpty2"] = state2.countEmpty;
|
||
newRow["PercentEmpty2"] = state2.countEmptyPercent;
|
||
newRow["CountEmptyDiff"] = state2.countEmpty - state1.countEmpty;
|
||
newRow["PercentEmptyDiff"] = state2.countEmptyPercent - state1.countEmptyPercent;
|
||
}
|
||
}
|
||
|
||
return anchorStatesDataTable;
|
||
}
|
||
|
||
public void LoafForms()
|
||
{
|
||
MainWindowForm.Instance.GridViewAnchorState.DataSource = _anchors;
|
||
MainWindowForm.Instance.GridViewGroupState.DataSource = _anchorsGroups;
|
||
MainWindowForm.Instance.GridViewFinalGroupState.DataSource = _finalyAncorGroupStates;
|
||
MainWindowForm.Instance.GridViewEngineState.DataSource = _engines;
|
||
}
|
||
public void SaveToExcel()
|
||
{
|
||
if (_anchors != null)
|
||
{
|
||
try
|
||
{
|
||
XLWorkbook wb = new XLWorkbook();
|
||
//DataTable dt = GetDataTableOrWhatever();
|
||
|
||
IXLWorksheet sheet = wb.Worksheets.Add(_anchors, _anchors.TableName);
|
||
int column = 2;
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
|
||
sheet = wb.Worksheets.Add(_anchorsGroups, _anchorsGroups.TableName);
|
||
column = 2;
|
||
sheet.Column(column++).AdjustToContents();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
|
||
|
||
sheet = wb.Worksheets.Add(_finalyAncorGroupStates, _finalyAncorGroupStates.TableName);
|
||
|
||
|
||
column = 2;
|
||
sheet.Column(column++).AdjustToContents();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
|
||
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
|
||
sheet = wb.Worksheets.Add(_engines, _engines.TableName);
|
||
column = 2;
|
||
sheet.Column(column++).AdjustToContents();
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
sheet.Column(column++).Hide();
|
||
sheet.Column(column).AdjustToContents();
|
||
sheet.Column(column++).Style.NumberFormat.Format = "0.00%";
|
||
|
||
using (SaveFileDialog saveDialog = new SaveFileDialog())
|
||
{
|
||
saveDialog.Filter = "Text files (*.xlsx)|*.xlsx|All files (*.*)|*.*";
|
||
saveDialog.FileName = "Report.xlsx"; // Начальное имя файла
|
||
|
||
if (saveDialog.ShowDialog() == DialogResult.OK)
|
||
{
|
||
// Получение пути к выбранному файлу
|
||
//fullPath = saveDialog.FileName;
|
||
|
||
// Получение значения для записи
|
||
//byte[] valueToSave = package.GetAsByteArray();
|
||
wb.SaveAs(saveDialog.FileName);
|
||
}
|
||
//Test(saveDialog.FileName);
|
||
};
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
Debug.WriteLine(ex.Message);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
}
|