Exemple #1
0
        public void Execute(ExecutingProcess executingProcess)
        {
            PrintPackageEntity package = (PrintPackageEntity)executingProcess.Data !;

            executingProcess.ForEachLine(package.Lines().Where(a => a.State != PrintLineState.Printed), line =>
            {
                PrintLineGraph.Print(line);
            });
        }
Exemple #2
0
    public static void Start(SchemaBuilder sb, FileTypeSymbol?testFileType = null)
    {
        if (sb.NotDefined(MethodInfo.GetCurrentMethod()))
        {
            TestFileType = testFileType;

            sb.Include <PrintLineEntity>()
            .WithQuery(() => p => new
            {
                Entity = p,
                p.CreationDate,
                p.File,
                p.State,
                p.Package,
                p.PrintedOn,
                p.Referred,
            });

            sb.Include <PrintPackageEntity>()
            .WithQuery(() => e => new
            {
                Entity = e,
                e.Id,
                e.Name
            });

            ProcessLogic.AssertStarted(sb);
            ProcessLogic.Register(PrintPackageProcess.PrintPackage, new PrintPackageAlgorithm());
            PermissionAuthLogic.RegisterPermissions(PrintPermission.ViewPrintPanel);
            PrintLineGraph.Register();

            SimpleTaskLogic.Register(PrintTask.RemoveOldFiles, (ScheduledTaskContext ctx) =>
            {
                var lines = Database.Query <PrintLineEntity>().Where(a => a.State == PrintLineState.Printed).Where(b => b.CreationDate <= Clock.Now.AddMinutes(-DeleteFilesAfter));
                foreach (var line in lines)
                {
                    try
                    {
                        using (var tr = new Transaction())
                        {
                            line.File.DeleteFileOnCommit();
                            line.State = PrintLineState.PrintedAndDeleted;
                            using (OperationLogic.AllowSave <PackageLineEntity>())
                                line.Save();

                            tr.Commit();
                        }
                    }
                    catch (Exception e)
                    {
                        e.LogException();
                    }
                }
                return(null);
            });
        }
    }