Asp.Net Zero achieve Universal Print

Asp.Net Zero is a very good web framework that can be used to quickly build business systems. Framework to meet the most common functions required by the business system, but the system must print reporting has not been achieved. Here to tell you how to integrate the print function in zero, you can realize template design, template printing, batch printing, print command, barcode / 2D code printing and so on.

First, we design a flexible system for printing business, business design as follows:

Prints first new folder in the core layer, prints in New PrintTemplate

    public class PrintTemplate : Entity<int>, ISoftDelete, IMustHaveTenant
    {
        public int TenantId { get; set; }

        public bool IsDeleted { get; set; }

        /// <summary>
        /// 模块
        /// </summary>
        [StringLength(50)]
        public string AppServiceName { get; set; }

        /// <summary>
        /// 模板名称
        /// </summary>
        [StringLength(50)]
        public string TemplateName { get; set; }

        /// <summary>
        /// 默认模板
        /// </summary>
        public bool Defaule { get; set; }

        /// <summary>
        /// 模板内容
        /// </summary>
        public string TemplateContent { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        [StringLength(100)]
        public string Remark { get; set; }
    }

After PrintTemplate create, easy to add IPrintTemplateManager field service interface calls:

    public interface IPrintTemplateManager: IDomainService
    {
        Task<List<string>> GetTemplates(string serviceName);

        Task<string> Print(string serviceName,string name);
    }

 Print print template is selected after acquiring template content, where you can directly obtain a single list of templates and content, but the possibility of business development, there will be a lot of print templates, so step by step to obtain more efficient.

 GetTemplates is to obtain a list of current print module, only the template name has no text.

 After database migration to add IPrintManagerAppService interface layer Application.Shared

    public interface IPrintManagerAppService: IApplicationService
    {
        Task CreateOrUpdatePrint(CreateOrEditPrintInput input);

        Task DeletePrint(EntityDto<int> input);

        Task<PagedResultDto<CreateOrEditPrintInput>> GetPrints(GetPrintInput input);
        
    }

 Print template is based on the service module, which is abp application service classification, need to get a list of all current module print template pages in the report:

     result.PrintTemplates = await _printTemplateManager.GetTemplates("SomeoneAppService");

After selecting a template to obtain the contents of the print template and print:

        public async Task<string> Print(string templateName)
        {
            return await _printTemplateManager.Print("PurchaseManagerAppService", templateName);
        }

Interface after the release of the new print management module for unified management template, the module should be maintained by the developer in the angular.

The following template design, templates can be designed according to the needs of other styles:

 Summary: The printing business has been achieved here, and finally need to be integrated in the angular print controls to start printing.

 Print control implementation: https://www.cnblogs.com/william-xu/p/11098562.html

Guess you like

Origin www.cnblogs.com/william-xu/p/11125623.html