commit f0e11d63790009ecb9ceca5caf5341dd9ca3cd0d Author: Курнат Андрей Date: Sat Jan 31 16:11:36 2026 +0300 first edit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9491a2f --- /dev/null +++ b/.gitignore @@ -0,0 +1,363 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd \ No newline at end of file diff --git a/XLIMS.CONTRACT/AssemblyInfo.cs b/XLIMS.CONTRACT/AssemblyInfo.cs new file mode 100644 index 0000000..b0ec827 --- /dev/null +++ b/XLIMS.CONTRACT/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/XLIMS.CONTRACT/IActivityViewModel.cs b/XLIMS.CONTRACT/IActivityViewModel.cs new file mode 100644 index 0000000..ded0e9c --- /dev/null +++ b/XLIMS.CONTRACT/IActivityViewModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace XLIMS.CONTRACT +{ + public interface IActivityViewModel + { + string Title { get; } + object View { get; } + } + +} diff --git a/XLIMS.CONTRACT/IDialogService.cs b/XLIMS.CONTRACT/IDialogService.cs new file mode 100644 index 0000000..8323f03 --- /dev/null +++ b/XLIMS.CONTRACT/IDialogService.cs @@ -0,0 +1,12 @@ +namespace XLIMS.CONTRACT; + +public interface IDialogService +{ + void ShowDialog(TViewModel viewModel) where TViewModel : class; + + // Если нужны модальные окна с результатом: + bool? ShowDialog(TViewModel viewModel, out object? result) + where TViewModel : class; + //немодальные окна + void Show(TViewModel viewModel) where TViewModel : class; +} \ No newline at end of file diff --git a/XLIMS.CONTRACT/IGenericRepository.cs b/XLIMS.CONTRACT/IGenericRepository.cs new file mode 100644 index 0000000..7efa8d9 --- /dev/null +++ b/XLIMS.CONTRACT/IGenericRepository.cs @@ -0,0 +1,32 @@ +using System.Linq.Expressions; + +namespace XLIMS.CONTRACT +{ + // Интерфейс generic-репозитория + public interface IGenericRepository where TEntity : class + { + Task GetByIdAsync(int id); + Task> GetAllAsync(); + Task> WhereAsync(Expression> predicate); + IEnumerable Find(Expression> predicate); + Task> FindAsync(Expression> predicate); + + Task SingleOrDefaultAsync(Expression> predicate); + + Task AddAsync(TEntity entity); + Task AddRangeAsync(IEnumerable entities); + + Task UpdateAsync(TEntity entity); + Task UpdateRangeAsync(IEnumerable entities); + + Task RemoveAsync(TEntity entity); + Task RemoveRangeAsync(IEnumerable entities); + + Task CountAsync(Expression> predicate = null); + + event Action SetChanged; + + Task SaveChangesAsync(); + int SaveChanges(); + } +} \ No newline at end of file diff --git a/XLIMS.CONTRACT/ILimsService.cs b/XLIMS.CONTRACT/ILimsService.cs new file mode 100644 index 0000000..41ec828 --- /dev/null +++ b/XLIMS.CONTRACT/ILimsService.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; +using XLIMS.DATA.Models; + +namespace XLIMS.CONTRACT +{ + public interface ILimsService + { + IGenericRepository Books { get; } + IGenericRepository Datas { get; } + IGenericRepository Devices { get; } + IGenericRepository Divisions { get; } + IGenericRepository Documents { get; } + IGenericRepository Personals { get; } + IGenericRepository Spnmtps { get; } + IGenericRepository Spois { get; } + IGenericRepository Tips { get; } + IGenericRepository Tprzs { get; } + + Task SaveChangesAsync(); + int SaveChanges(); + } +} diff --git a/XLIMS.CONTRACT/XLIMS.CONTRACT.csproj b/XLIMS.CONTRACT/XLIMS.CONTRACT.csproj new file mode 100644 index 0000000..f396ea1 --- /dev/null +++ b/XLIMS.CONTRACT/XLIMS.CONTRACT.csproj @@ -0,0 +1,28 @@ + + + + net10.0-windows + enable + true + enable + + + + + + + + + + + + + + + + + + + + + diff --git a/XLIMS.CORE/AssemblyInfo.cs b/XLIMS.CORE/AssemblyInfo.cs new file mode 100644 index 0000000..b0ec827 --- /dev/null +++ b/XLIMS.CORE/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/XLIMS.CORE/Helpers/ClosePsv.cs b/XLIMS.CORE/Helpers/ClosePsv.cs new file mode 100644 index 0000000..345f22c --- /dev/null +++ b/XLIMS.CORE/Helpers/ClosePsv.cs @@ -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 + } +} diff --git a/XLIMS.CORE/Helpers/Izv.cs b/XLIMS.CORE/Helpers/Izv.cs new file mode 100644 index 0000000..3396436 --- /dev/null +++ b/XLIMS.CORE/Helpers/Izv.cs @@ -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 _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(); + 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 + } +} diff --git a/XLIMS.CORE/Helpers/OpenPsv.cs b/XLIMS.CORE/Helpers/OpenPsv.cs new file mode 100644 index 0000000..8c33ba2 --- /dev/null +++ b/XLIMS.CORE/Helpers/OpenPsv.cs @@ -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 + } +} diff --git a/XLIMS.CORE/Helpers/Svid.cs b/XLIMS.CORE/Helpers/Svid.cs new file mode 100644 index 0000000..fb08427 --- /dev/null +++ b/XLIMS.CORE/Helpers/Svid.cs @@ -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 + } +} diff --git a/XLIMS.CORE/Resources/CoreDictionary.xaml b/XLIMS.CORE/Resources/CoreDictionary.xaml new file mode 100644 index 0000000..42f1cd1 --- /dev/null +++ b/XLIMS.CORE/Resources/CoreDictionary.xaml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/XLIMS.CORE/Resources/DOCX/ClosePsv.docx b/XLIMS.CORE/Resources/DOCX/ClosePsv.docx new file mode 100644 index 0000000..bb3085b Binary files /dev/null and b/XLIMS.CORE/Resources/DOCX/ClosePsv.docx differ diff --git a/XLIMS.CORE/Resources/DOCX/Izv.docx b/XLIMS.CORE/Resources/DOCX/Izv.docx new file mode 100644 index 0000000..c471a02 Binary files /dev/null and b/XLIMS.CORE/Resources/DOCX/Izv.docx differ diff --git a/XLIMS.CORE/Resources/DOCX/OpenPsv.docx b/XLIMS.CORE/Resources/DOCX/OpenPsv.docx new file mode 100644 index 0000000..3ff1a3a Binary files /dev/null and b/XLIMS.CORE/Resources/DOCX/OpenPsv.docx differ diff --git a/XLIMS.CORE/Resources/DOCX/Svid.docx b/XLIMS.CORE/Resources/DOCX/Svid.docx new file mode 100644 index 0000000..467e3e5 Binary files /dev/null and b/XLIMS.CORE/Resources/DOCX/Svid.docx differ diff --git a/XLIMS.CORE/ViewModels/MainViewModel.cs b/XLIMS.CORE/ViewModels/MainViewModel.cs new file mode 100644 index 0000000..72882d1 --- /dev/null +++ b/XLIMS.CORE/ViewModels/MainViewModel.cs @@ -0,0 +1,73 @@ +using Microsoft.EntityFrameworkCore.ChangeTracking; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Text; +using System.Windows; +using System.Windows.Input; +using XLIMS.CONTRACT; +using XLIMS.CORE.Windows; +using XLIMS.MVVM.Base; + +namespace XLIMS.CORE.ViewModels +{ + public class MainViewModel:ViewModelBase + { + #region Constructor + public MainViewModel(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + + // Регистрация доступных activities + Activities.Add(serviceProvider.GetRequiredService()); + Activities.Add(serviceProvider.GetRequiredService()); + Activities.Add(serviceProvider.GetRequiredService()); + Activities.Add(serviceProvider.GetRequiredService()); + + // По умолчанию открываем первую + CurrentActivity = Activities.FirstOrDefault(); + + NavigateCommand = new RelayCommand(Navigate); + } + #endregion //Constructor + + #region Events + #endregion //Events + + #region Fields + public readonly IServiceProvider _serviceProvider; + #endregion //Fields + + #region Properties + public ObservableCollection Activities { get; } + = new ObservableCollection(); + + private IActivityViewModel _currentActivity; + public IActivityViewModel CurrentActivity + { + get => _currentActivity; + set + { + if (_currentActivity != value) + { + _currentActivity = value; + OnPropertyChanged(); + } + } + } + #endregion //Properties + + #region Methods + private void Navigate(IActivityViewModel vm) + { + if (vm != null) + CurrentActivity = vm; + } + #endregion //Methods + + #region Commands + public ICommand NavigateCommand { get; } + #endregion //Commands + } +} diff --git a/XLIMS.CORE/Windows/EditWindow.xaml b/XLIMS.CORE/Windows/EditWindow.xaml new file mode 100644 index 0000000..8b449e7 --- /dev/null +++ b/XLIMS.CORE/Windows/EditWindow.xaml @@ -0,0 +1,42 @@ + + + + + + + + + + +