first edit

This commit is contained in:
Курнат Андрей
2026-01-31 16:11:36 +03:00
commit f0e11d6379
148 changed files with 6986 additions and 0 deletions

View File

@@ -0,0 +1,116 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace XLIMS.CORE.Helpers
{
public class ClosePsv
{
#region Constructor
public ClosePsv(DocViewModel document, XLAB7Repository repository, int copies = 0)
{
if (copies == 0) _copies = 1;
else _copies = copies;
_document = document;
_repository = repository;
_fi = new FileInfo(@"Resources\DOCX\ClosePsv.docx");
_wordApp = new Microsoft.Office.Interop.Word.Application();
_wordDocument = _wordApp.Documents.Open(_fi.FullName);
_table = _wordDocument.Tables[1];
}
#endregion //Constructor
#region Fields
private Microsoft.Office.Interop.Word.Application _wordApp;
private Microsoft.Office.Interop.Word.Document _wordDocument;
private object _wFalse = false;
private object _wTrue = true;
private object _missing = null;
private FileInfo _fi;
private DocViewModel _document;
private Table _table;
private int _copies;
private XLAB7Repository _repository;
#endregion //Fields
#region Properties
#endregion //Properties
#region Mehtods
private void Replace(string text, string replacementText)
{
Find find = _wordApp.Selection.Find;
find.Text = text;
find.Replacement.Text = replacementText;
find.Execute(FindText: Type.Missing,
MatchCase: false,
MatchWholeWord: false,
MatchWildcards: false,
MatchSoundsLike: Type.Missing,
MatchAllWordForms: false,
Forward: true,
Wrap: Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue,
Format: false,
ReplaceWith: Type.Missing,
Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);
}
public void Print()
{
Replace("number", _document.Number);
Replace("div", _document.CurrentFRPD.NMFRPD);
Replace("date", ((DateTime)_document.Date).ToLongDateString());
Replace("count", _document.AllEKZMK.Count.ToString());
Replace("bad", _document.AllEKZMK.Count(o => o.GDN == false).ToString());
Replace("good", _document.AllEKZMK.Count(o => o.GDN == true).ToString());
Replace("person", _document.CurrentPRSNVY.PRFIO);
Replace("today", ((DateTime)_document.DateVY).ToLongDateString());
var i = 2;
var n = 1;
foreach (var data in _document.AllGroupsEKZMK)
{
_table.Rows.Add();
_table.Rows[i].Cells[1].Range.Text = n.ToString();
_table.Rows[i].Cells[2].Range.Text = data.CurrentEKZMK.CurrentEKZ.IDTPRZNavigation.IDTIPSNavigation.IDSPNMTPNavigation.NMTP;
_table.Rows[i].Cells[3].Range.Text = data.CurrentEKZMK.CurrentEKZ.IDTPRZNavigation.IDTIPSNavigation.TP;
_table.Rows[i].Cells[4].Range.Text = data.CurrentEKZMK.CurrentEKZ.IDTPRZNavigation.DPZN;
if (data.GroupEKZMK.Count() > 3)
{
_table.Rows[i].Cells[5].Range.Text = data.GroupEKZMK.Count().ToString();
}
else
{
foreach (var d in data.GroupEKZMK)
{
_table.Rows[i].Cells[5].Range.Text += d.CurrentEKZ.NNZV + ", ";
}
}
_table.Rows[i].Cells[6].Range.Text = data.Count.ToString();
_table.Rows[i].Cells[7].Range.Text = data.GoodCount.ToString();
_table.Rows[i].Cells[8].Range.Text = data.BadCount.ToString();
try
{
_table.Rows[i].Cells[9].Range.Text = data.CurrentEKZMK.CurrentDMS.NND.ToString() + " от " + data.CurrentEKZMK.CurrentDMS.DTD.ToShortDateString();
}
catch { }
i++;
n++;
}
_wordDocument.PrintOut(Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, _copies);
_wordDocument.Close(_wFalse);
_wordApp.Quit();
}
#endregion //Mehtods
}
}

106
XLIMS.CORE/Helpers/Izv.cs Normal file
View File

@@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace XLIMS.CORE.Helpers
{
public class Izv
{
#region Constructor
public Izv(DMS document, XLAB7Repository repository, int copies = 1)
{
_document = document;
_repository = repository;
_copies = copies;
_docs = _repository.GetDMS().Where(w => w.NND == _document.NND).ToList();
_fi = new FileInfo(@"Resources\DOCX\Izv.docx");
_wordApp = new Application();
_wordDocument = _wordApp.Documents.Open(_fi.FullName);
}
#endregion //Constructor
#region Fields
private Application _wordApp;
private Microsoft.Office.Interop.Word.Document _wordDocument;
private object _wFalse = false;
private object _wTrue = true;
private object _missing = null;
private FileInfo _fi;
private DMS _document;
private List<DMS> _docs;
private Table _table;
private int _copies;
private XLAB7Repository _repository;
#endregion //Fields
#region Properties
#endregion //Properties
#region Mehtods
private void Replace(string text, string replacementText)
{
Find find = _wordApp.Selection.Find;
find.Text = text;
find.Replacement.Text = replacementText;
find.Execute(FindText: Type.Missing,
MatchCase: false,
MatchWholeWord: false,
MatchWildcards: false,
MatchSoundsLike: Type.Missing,
MatchAllWordForms: false,
Forward: true,
Wrap: Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue,
Format: false,
ReplaceWith: Type.Missing,
Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);
}
public void Print()
{
var ekzmk = new List<EKZMK>();
foreach (var doc in _docs)
{
try
{
ekzmk.Add(_repository.GetEKZMK().Result.FirstOrDefault(f => f.IDEKZMK == doc.IDOD));
}
catch { continue; }
}
Replace("number", _document.NND);
Replace("name", ekzmk.FirstOrDefault().IDEKZNavigation.IDTPRZNavigation.IDTIPSNavigation.IDSPNMTPNavigation.NMTP);
if (ekzmk.Count() > 3)
{
Replace("serial", ekzmk.Count().ToString()+" шт.");
}
else
{
string serials=string.Empty;
foreach (var d in ekzmk)
{
serials += d.IDEKZNavigation.NNZV+", ";
}
Replace("serial", serials);
}
Replace("type", ekzmk.FirstOrDefault().IDEKZNavigation.IDTPRZNavigation.IDTIPSNavigation.TP);
Replace("gr", ekzmk.FirstOrDefault().IDEKZNavigation.IDTPRZNavigation.IDTIPSNavigation.NNTPGR);
Replace("reason", ekzmk.FirstOrDefault().PRCHNPGDN);
Replace("method", "");
Replace("dev", ekzmk.FirstOrDefault().IDEKZNavigation.IDFRPDVNavigation.NMFRPD);
Replace("person", ekzmk.FirstOrDefault().IDPRSNNavigation.PRFIO);
Replace("date", ((DateTime)ekzmk.FirstOrDefault().DTMKFK).ToLongDateString());
_wordDocument.PrintOut(Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, _copies);
_wordDocument.Close(_wFalse);
_wordApp.Quit();
}
#endregion //Mehtods
}
}

View File

@@ -0,0 +1,124 @@
using System;
using System.IO;
namespace XLIMS.CORE.Helpers
{
public class OpenPsv
{
#region Fields
private readonly dynamic _wordApp;
private readonly dynamic _wordDocument;
private readonly dynamic _table;
private readonly DocViewModel _document;
private readonly XLAB7Repository _repository;
private readonly int _copies;
#endregion
#region Constructor
public OpenPsv(DocViewModel document, XLAB7Repository repository, int copies = 1)
{
_document = document ?? throw new ArgumentNullException(nameof(document));
_repository = repository ?? throw new ArgumentNullException(nameof(repository));
_copies = copies < 1 ? 1 : copies;
var templatePath = Path.Combine("Resources", "DOCX", "OpenPsv.docx");
if (!File.Exists(templatePath))
throw new FileNotFoundException("Шаблон Word не найден", templatePath);
var wordType = Type.GetTypeFromProgID("Word.Application");
if (wordType == null)
throw new InvalidOperationException("Microsoft Word не установлен");
_wordApp = Activator.CreateInstance(wordType);
_wordApp.Visible = false;
_wordDocument = _wordApp.Documents.Open(templatePath);
if (_wordDocument.Tables.Count < 1)
throw new InvalidOperationException("В документе отсутствует таблица");
_table = _wordDocument.Tables[1];
}
#endregion
#region Methods
private void Replace(string placeholder, string value)
{
dynamic range = _wordDocument.Content;
dynamic find = range.Find;
find.ClearFormatting();
find.Text = placeholder;
find.Replacement.ClearFormatting();
find.Replacement.Text = value ?? string.Empty;
find.Execute(
Replace: 2, // wdReplaceAll
Wrap: 1 // wdFindContinue
);
}
public void Print()
{
Replace("number", _document.Number);
Replace("div", _document.CurrentFRPD.NMFRPD);
Replace("date", ((DateTime)_document.Date).ToLongDateString());
Replace("count", _document.AllEKZMK.Count.ToString());
Replace("next", ((DateTime)_document.Date).AddDays(30).ToLongDateString());
Replace("person", _document.CurrentPRSNPR.PRFIO);
int rowIndex = 2;
int index = 1;
foreach (var group in _document.AllGroupsEKZMK)
{
_table.Rows.Add();
_table.Cell(rowIndex, 1).Range.Text = index.ToString();
_table.Cell(rowIndex, 2).Range.Text =
group.CurrentEKZMK.CurrentEKZ.IDTPRZNavigation
.IDTIPSNavigation.IDSPNMTPNavigation.NMTP;
_table.Cell(rowIndex, 3).Range.Text =
group.CurrentEKZMK.CurrentEKZ.IDTPRZNavigation
.IDTIPSNavigation.TP;
_table.Cell(rowIndex, 4).Range.Text =
group.CurrentEKZMK.CurrentEKZ.IDTPRZNavigation.DPZN;
if (group.GroupEKZMK.Count() > 3)
{
_table.Cell(rowIndex, 5).Range.Text =
group.GroupEKZMK.Count().ToString();
}
else
{
foreach (var item in group.GroupEKZMK)
{
_table.Cell(rowIndex, 5).Range.Text +=
item.CurrentEKZ.NNZV + ", ";
}
}
_table.Cell(rowIndex, 6).Range.Text = group.Count.ToString();
_table.Cell(rowIndex, 9).Range.Text = group.CurrentEKZMK.DSEKZMK;
rowIndex++;
index++;
}
_wordDocument.PrintOut(Copies: _copies);
_wordDocument.Close(false);
_wordApp.Quit();
}
#endregion
}
}

View File

@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace XLIMS.CORE.Helpers
{
public class Svid
{
#region Constructor
public Svid(DMS document, XLAB7Repository repository, int copies = 1)
{
_copies = copies;
_document = document;
_repository = repository;
_fi = new FileInfo(@"Resources\DOCX\Svid.docx");
_wordApp = new Application();
_wordDocument = _wordApp.Documents.Open(_fi.FullName);
}
#endregion //Constructor
#region Fields
private Application _wordApp;
private Microsoft.Office.Interop.Word.Document _wordDocument;
private object _wFalse = false;
private object _wTrue = true;
private object _missing = null;
private FileInfo _fi;
private DMS _document;
private Table _table;
private int _copies;
private XLAB7Repository _repository;
#endregion //Fields
#region Properties
#endregion //Properties
#region Mehtods
private void Replace(string text, string replacementText)
{
Find find = _wordApp.Selection.Find;
find.Text = text;
find.Replacement.Text = replacementText;
find.Execute(FindText: Type.Missing,
MatchCase: false,
MatchWholeWord: false,
MatchWildcards: false,
MatchSoundsLike: Type.Missing,
MatchAllWordForms: false,
Forward: true,
Wrap: Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue,
Format: false,
ReplaceWith: Type.Missing,
Replace: Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll);
}
public void Print()
{
var ekzmk = _repository.GetEKZMK().Result.FirstOrDefault(f => f.IDEKZMK == _document.IDOD);
Replace("number", _document.NND);
Replace("nextpovdate", ((DateTime)ekzmk.IDEKZNavigation.EKZMCP.FirstOrDefault().DTMKPLO).ToLongDateString());
Replace("name", ekzmk.IDEKZNavigation.IDTPRZNavigation.IDTIPSNavigation.IDSPNMTPNavigation.NMTP);
Replace("serial", ekzmk.IDEKZNavigation.NNZV);
Replace("type", ekzmk.IDEKZNavigation.IDTPRZNavigation.IDTIPSNavigation.TP);
Replace("gr", ekzmk.IDEKZNavigation.IDTPRZNavigation.IDTIPSNavigation.NNTPGR);
Replace("method", "");
Replace("temp", ekzmk.EKZMKFCTVL.FirstOrDefault(f=>f.IDSPIV==1000).ZNFCTVLMIN.ToString());
Replace("hum", ekzmk.EKZMKFCTVL.FirstOrDefault(f => f.IDSPIV == 1002).ZNFCTVLMIN.ToString());
Replace("press", ekzmk.EKZMKFCTVL.FirstOrDefault(f => f.IDSPIV == 1001).ZNFCTVLMIN.ToString());
Replace("count", "");
Replace("person", ekzmk.IDPRSNNavigation.PRFIO);
Replace("date", ((DateTime)ekzmk.DTMKFK).ToLongDateString());
_wordDocument.PrintOut(Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, _copies);
_wordDocument.Close(_wFalse);
_wordApp.Quit();
}
#endregion //Mehtods
}
}