|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Collections.ObjectModel;
- using System.Windows;
- using System.IO;
- using BPASmartClient.Helper;
-
- namespace BPASmartClient.CustomResource.Pages.Model
- {
- public class ProductionDataHelper<TProductionData> where TProductionData : class, new()
- {
-
-
-
-
-
-
-
-
- public static string SavePath { get; set; }
- private static string FileName = string.Empty;
- private static string FilePath = string.Empty;
- public static string Alias { get; set; } = string.Empty;
- private static string _path
- {
- get
- {
- Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\ProductionData\\{FilePath}"));
- return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\ProductionData\\{ FilePath}";
- }
- }
- public static ObservableCollection<TProductionData> productionDatas { get; set; } = new ObservableCollection<TProductionData>();
- //public static TProductionData Data { get; set; } = new TProductionData();
- public static void Add(TProductionData production)
- {
- if (FilePath.Length <= 0)
- {
- if (Alias.Length <= 0)
- FilePath = $"{DateTime.Now.ToString("yyy-MM-dd")}";
- else
- FilePath = $"{DateTime.Now.ToString("yyy-MM-dd")}\\{Alias}";
- }
- if (FileName.Length <= 0) FileName = $"{DateTime.Now.ToString("HH-mm-ss")}.pry";
- Application.Current.Dispatcher.Invoke(new Action(() =>
- {
- productionDatas.Add(production);
- }));
- }
-
- public static bool Save(string path = "")
- {
- DataRecord dr = new DataRecord();
- if (File.Exists(path))
- {
- dr.Save(productionDatas, FileName);
- return true;
- }
- if (SavePath != null && File.Exists(SavePath))
- {
- dr.Save(productionDatas, FileName);
- return true;
- }
-
- dr.Save(productionDatas, FileName);
- return true;
-
-
- }
-
- public static void End()
- {
- FileName = string.Empty;
- FilePath = string.Empty;
- Alias = string.Empty;
- }
-
-
- }
-
-
- }
|