public void LogOpenForPrinting(string title) { var dbcontext = new Model_PDFFinder(); dbcontext.Statisticas.Where(x => x.group_name == title.Substring(0, 5)).First().processed_files_count++; dbcontext.SaveChanges(); }
public void LogOpenForView() { var dbcontext = new Model_PDFFinder(); dbcontext.Statisticas.Where(x => x.group_name == "NoGroup").First().processed_files_count++; dbcontext.SaveChanges(); App.Current.Shutdown(); }
public Report_Template GetPrinterSettings(string metaData, Model_PDFFinder context) { Report_Template report = context.Report_Template.Where(x => x.report_name == metaData).FirstOrDefault(); if (report != null) { return(report); } Group_Template group = context.Group_Template.Where(x => metaData.Contains(x.group_name)).FirstOrDefault(); if (group == null) { return(null); } List <Report_Template> reports = context.Report_Template.Where(x => x.report_name.Contains(group.group_name)).ToList(); string printerName, paperFormat; bool? reportDuplex; if (reports.Count != 0) { Report_Template defaultReport = reports.First(); printerName = reports.All(x => x.printer_name == defaultReport.printer_name) ? defaultReport.printer_name : group.printer_name; reportDuplex = reports.All(x => x.duplex == defaultReport.duplex) ? defaultReport.duplex : group.duplex; paperFormat = reports.All(x => x.paper_format == defaultReport.paper_format) ? defaultReport.paper_format : group.paper_format; } else { printerName = group.printer_name; reportDuplex = group.duplex; paperFormat = group.paper_format; } Report_Template printerSettings = new Report_Template() { report_name = metaData, printer_name = printerName, duplex = reportDuplex, paper_format = paperFormat }; return(printerSettings); }
/// <summary> /// Простой пример работы функции /// </summary> /// <param name="fileName"></param> public void Execute(string fileName) { string title = Parser.Parse(fileName); FileAssociationManager associationManager = new FileAssociationManager(); //Временная заглушка (названия процесса) string processName = associationManager.GetAssociatedApplication(".pdf").Path; using (var context = new Model_PDFFinder()) { Report_Template printerSettings = Analizer.GetPrinterSettings(title, context); if (printerSettings != null) { Printer.Print(fileName, printerSettings); Logger.LogOpenForPrinting(title); } else { Viewer.View(fileName, processName); Logger.LogOpenForView(); } } }