Kaynağa Gözat

报表数据保存

样式分支
pry 2 yıl önce
ebeveyn
işleme
0067f25c96
3 değiştirilmiş dosya ile 56 ekleme ve 3 silme
  1. +1
    -0
      BPASmartClient.Helper/BPASmartClient.Helper.csproj
  2. +52
    -0
      BPASmartClient.Helper/DataRecord.cs
  3. +3
    -3
      DosingSystem/View/HardwareStatusView.xaml

+ 1
- 0
BPASmartClient.Helper/BPASmartClient.Helper.csproj Dosyayı Görüntüle

@@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>

<ItemGroup>


+ 52
- 0
BPASmartClient.Helper/DataRecord.cs Dosyayı Görüntüle

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;

namespace BPASmartClient.Helper
{
public class DataRecord
{

/// <summary>
/// 读取序列化文件
/// </summary>
/// <param name="FilePath">需要读取序列化文件的文件名,包括后缀名</param>
/// <returns>返回序列化读取到的信息,需要自行转换成对应的类型</returns>
public ReadT Read<ReadT>(string FilePath)
{
if (File.Exists(FilePath))
{
FileStream fs = new FileStream(FilePath, FileMode.Open);
BinaryFormatter bf = new BinaryFormatter();
var res = (ReadT)bf.Deserialize(fs);
fs.Close();
return res;
}
return default;
}

/// <summary>
/// 保存序列化文件
/// </summary>
/// <param name="obj">需要通过序列化保存的对象</param>
/// <param name="FileName">设置保存的文件名,包括后缀名,后缀名可以自定义</param>
public void Save<SaveT>(SaveT obj, string FileName)
{
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\ProductionData"));
string path = $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\ProductionData\\{FileName}";
if (obj != null)
{
FileStream fs = new FileStream(path, FileMode.Create);
BinaryFormatter bf = new BinaryFormatter();//创建一个二进制格式化器
bf?.Serialize(fs, obj);
fs.Close();
}
}

}
}

+ 3
- 3
DosingSystem/View/HardwareStatusView.xaml Dosyayı Görüntüle

@@ -180,12 +180,12 @@
Grid.Row="1"
Width="{Binding ElementName=gr, Path=ActualWidth}"
Height="{Binding ElementName=gr, Path=ActualHeight}"
Margin="0,0,400,0"
Margin="10,0,400,0"
ConveyorBeltWidth="70"
Direction="1"
StrokeBrush="Red"
StrokeBrush="#00BEFA"
StrokeDashArray="1.5 1.5"
StrokeFillBrush="Red"
StrokeFillBrush="#00BEFA"
StrokeThickness="2" />
</Grid>



Yükleniyor…
İptal
Kaydet