分类 Dynamics 365 下的文章

通过DP中将数据转换成bitmap,再转换成Base64存入字段中,在ReportDesign中赋值到图片上打印出来。

条形码

    protected BarCodeString barCode(String255   _BarCode)
    {
        Barcode barcode;
        barcode = Barcode::construct(BarcodeType::Code39);
        barcode.string(true,_BarCode);
        barcode.encode();

        return barcode.barcodeStr();
    }

二维码

      private container QrCode( str string)
    {
        EFDocQRCode_BR  qrcode  =  new EFDocQRCode_BR();
        Bitmap          img     =  qrcode.generateQRCode(string);
        return img;
    }

使用类编写

使用类打印Report主要需要三个类:

  • Controller
  • Contrect
  • DataProvider

如果需要定制参数页也可以使用UiBuilder:

  • Class_UiBuilder

Controller

    class ReportController extends SrsReportRunController//报表打印入口类.
{
    public static void main(Args    _args) 
    {
        ReportController controller = new ReportController(); 
        controller.parmArgs(_args);
        controller.parmReportName(ssrsReportStr(ReportReport,Report));//(报表格式模版,Design).
        controller.parmDialogCaption('@Label');//打印前配置dialog 标题.
        controller.parmShowDialog(true);//是否显示配置页.
        controller.startOperation();
    }

    protected void prePromptModifyContract()//配置页初始化操作.
    {
        
        ReportContract  contract;
        Args            _args;
        Table           tb;
        List            list;
        FormDataSource  fds;
        MultiSelectionHelper  multiSelectionHelper; 
        ;       
        _args= this.parmArgs();
        contract =this.parmReportContract().parmRdpContract() as ReportContract;//获取本次打印Contract类.
    
        //<如何从窗体Grid多选>
        list = new List(Types::String);
        fds = args.record().dataSource();
        multiSelectionHelper = MultiSelectionHelper::construct();
        multiSelectionHelper.parmDatasource(fds);
        tb = multiSelectionHelper.getFirst();
        while (tb)
        {
            list.addEnd(tb.Id);
            tb = multiSelectionHelper.getNext();
        }
        contract.parmList(list);
        //</如何从窗体Grid多选>


        contract.parmDate(today());//设定配置页初始值.
    }
}

Contract

    [
        DataContractAttribute,
        SysOperationContractProcessingAttribute(classlist(UiBuilder)),
        SysOperationLabelAttribute(literalStr("@label:aaa"))

    ]
    class Contract
    {
        date endDate;
        AssetBookId bookId;
        List list;
                
    
        [   
            DataMember,
            DataMemberAttribute('EndDate')
            ,SysOperationDisplayOrderAttribute('16')
            ,SysOperationControlVisibility(false)    
        ]
        public date parmEndDate(date theEndDate = endDate){
            endDate = theEndDate;
            return endDate;
        }

        [   DataMember,
            DataMemberAttribute('BookId')]
        public AssetBookId parmBookId(AssetBookId theBookId = bookId)
        {
            bookId = theBookId;
            return bookId;
        }

        [   DataMember,
            DataMemberAttribute('List'),
            AifCollectionType("List",Types::String),
            AifCollectionType("return",Types::String)    
        ]
        public List parmList(List theList = list)
        {
            list= theList;
            return list;
        }

    }

DataProvider

    [
    SRSReportParameterAttribute(classStr(XXXContract))
    ]
    class XXXDP Extends SRSReportDataProviderPreProcessTempDb
    {
        Table        tmp;

        [
            SRSReportDataSetAttribute(tablestr(Table))
        ]
            public Table getTmp()
        {
            select tmp;
            return tmp;
        }

        public void processReport()
        {
            Contract contract = this.parmDataContract() as Contract ;
        }

    }

Class_UiBuilder

    [
        SrsReportNameAttribute('Repot_Report.Report'),
        SysOperationContractProcessingAttribute(classstr(Class_UiBuilder),
        SysOperationDataContractProcessingMode::CreateUIBuilderForRootContractOnly)
    ]
    class Class_UiBuilder extends SrsReportDataContractUIBuilder
    {
        Class_Contrat  contract;

        DialogField fieldEndDate;
        DialogField fieldBookId;
        DialogField fieldAssetList;

        public void build()
        {
            contract = this.dataContractObject() as Class_Contrat;
            fieldAssetList = this.addDialogField(
                methodstr(Class_Contrat, parmAssetList),
                contract
                );
            fieldBookId = this.addDialogField(
                methodstr(Class_Contrat, parmBookId),
                contract
                );
            fieldEndDate= this.addDialogField(
                methodstr(Class_Contrat, parmEndDate),
                contract
                );
        }

        public void postBuild()
        {
            super();
            contract = this.dataContractObject() as Class_Contrat;

            fieldAssetList =  this.bindInfo().getDialogField(contract, methodstr(Class_Contrat, parmAssetList));
            fieldAssetList.lookupButton(FormLookupButton::Always);
            fieldAssetList.label("@IWS:IWS01401");

            fieldEndDate =  this.bindInfo().getDialogField(contract, methodstr(Class_Contrat, parmEndDate));
            fieldBookId =  this.bindInfo().getDialogField(contract, methodstr(Class_Contrat, parmBookId));
        }

        public void getFromDialog()
        {
            super();

        }

        public void postRun()
        {
            Query                query            = new Query();
            QueryBuildDataSource    qbdsLegalEntity     = query.addDataSource(tablenum(AssetTable));

            qbdsLegalEntity.fields().addField(fieldNum(AssetTable, AssetId));
            qbdsLegalEntity.fields().addField(fieldNum(AssetTable, Name));

            container selectedFields = [tableNum(AssetTable), fieldNum(AssetTable, AssetId)];

            SysLookupMultiSelectCtrl::constructWithQuery(this.dialog().dialogForm().formRun(), fieldAssetList.control(), query, true, selectedFields);

        }

    }

直接打印

 SRSPrintDestinationSettings printSettings = this.parmReportContract().parmPrintSettings();
    printSettings.printMediumType(SRSPrintMediumType::File);
    printSettings.fileFormat(SRSReportFileFormat::PDF);
    printSettings.overwriteFile(true);
    printSettings.fileName(strFmt("%1.pdf", this.parmDialogCaption()));

图片

字段用 EDT bitmap containner类型直接赋值stream;
design用Image。

SysDictEnum dictEnum = new SysDictEnum( enumnum(InventTransType) );
dictEnum.value2Label(InventTrans.TransType);

    JObject             jObj;
    JArray              dataJArray = new Newtonsoft.Json.Linq.JArray();

    jObj  = new JObject();

    jObj.Add("code", ecoResCategory.code);
    jObj.Add("name", ecoResCategory.Name);
    dataJArray.Add(jObj);

    keyinfo = int642Str( ecoResCategory.RecId );
    return strReplace(DataJArray.ToString(), "\r\n", "");