印仔 发布的文章

常用格式为:yyyy-MM-dd HH:mm:ss
以 2019-12-31 06:07:59:666 时间为例:

Letter含义Example
yyyyy------>2019
MMM------->12 大写的M
d一月中的天数dd--------->31
H小时(0-23)HH--------->18 24 小时制的是大写的H
h小时(1-12)hh---------->06 24 小时制的是大写的h
mmm-------->07 小写的m
sss-------->59
S毫秒SSS--------->666
YWeek YearYYYY---->2020
D一年中天数DD-------->365

原文链接:https://blog.csdn.net/qq_37358143/article/details/103868657

private Stream buildPdf(str Id)
{

    System.IO.MemoryStream stream;

    
    Contract contract = new Contract ();
    Controller controller = new Controller ();
    SRSPrintDestinationSettings settings;
    SRSReportRunService srsReportRunService = new SrsReportRunService();
    Microsoft.Dynamics.AX.Framework.Reporting.Shared.ReportingService.ParameterValue[] parameterValueArray;

    SRSReportExecutionInfo executionInfo = new SRSReportExecutionInfo();
    Map reportParametersMap;
    SRSProxy srsProxy;
    System.Byte[] reportBytes = new System.Byte[0]();

    

    contract.parmId("Id");

    
    controller.parmReportName(ssrsReportStr(Report, Report));
    //controller.parmDialogCaption('@IWS:IWS02036');
    //controller.parmShowDialog(false);
    //controller.parmLoadFromSysLastValue(false);
    controller.parmReportContract().parmRdpContract(contract);

    settings = controller.parmReportContract().parmPrintSettings();
    settings.printMediumType(SRSPrintMediumType::File);
    settings.fileFormat(SRSReportFileFormat::PDF);

    controller.parmReportContract().parmReportServerConfig(SRSConfiguration::getDefaultServerConfiguration());
    controller.parmReportContract().parmReportExecutionInfo(executionInfo);
    srsReportRunService.getReportDataContract(controller.parmreportcontract().parmReportName());
    srsReportRunService.preRunReport(controller.parmreportcontract());
    reportParametersMap = srsReportRunService.createParamMapFromContract(controller.parmReportContract());
    parameterValueArray = SrsReportRunUtil::getParameterValueArray(reportParametersMap);
    srsProxy = SRSProxy::constructWithConfiguration(controller.parmReportContract().parmReportServerConfig());

    reportBytes = srsproxy.renderReportToByteArray(
        controller.parmreportcontract().parmreportpath(),
        parameterValueArray,
        settings.fileFormat(),
        settings.deviceinfo());

    if (reportBytes)
    {
        stream = new System.IO.MemoryStream(reportBytes);
        stream.Position = 0;
    }
    return  stream;
}

public static str SendPostWithHeader(str url, str param, System.Net.WebHeaderCollection _headers, str contentType = "application/json", str encoding = "utf-8")
{
    System.Net.HttpWebRequest request = null;
    System.IO.Stream requestStream;
    str  dataString;
    if (strStartsWith(url, "https"))
    {
        request = System.Net.WebRequest::Create(url)as System.Net.HttpWebRequest;
    }
    else
    {
        request = System.Net.WebRequest::CreateHttp(url)as System.Net.HttpWebRequest;
    }
    request.Method = "POST";
    request.Headers = _headers;
    request.ContentType = contentType;
    System.Byte[] postData = System.Text.Encoding::GetEncoding( encoding ).GetBytes(param);
    request.ContentLength = postData.Length;
    try
    {
        System.IO.Stream outputStream = request.GetRequestStream();
        outputStream.Write(postData,0,postData.Length);
        outputStream.Close();

        System.Net.HttpWebResponse response = request.GetResponse() as System.Net.HttpWebResponse;
        System.IO.Stream responseStream = response.GetResponseStream();
        System.IO.StreamReader reader=new System.IO.StreamReader(responseStream,System.Text.Encoding::GetEncoding("GBK"));
        dataString = reader.ReadToEnd();
        reader.Close();

        if(!dataString)
            throw error("接口数据返回异常");
    }
    catch (Exception::CLRError)
    {
        System.Exception ex;
        ex = ClrInterop::getLastException();
        if (ex != null)
        {
            ex = ex.get_InnerException();
            if (ex != null)
            {
                dataString = ex.ToString();
            }
        }
    }
    catch
    {
        SysInfoLogEnumerator infoLogEnum;
        infoLogEnum = SysInfoLogEnumerator::newData(infolog.copy(1, infologLine()));
        while(infoLogEnum.moveNext())
        {
            dataString += infoLogEnum.currentMessage();
        }
    }

    return dataString;
}

  container fileCon = DocumentManagement::getAttachmentAsContainer(_docuRef);
  

System.IO.Stream stream = Binary::constructFromContainer(fileCon).getMemoryStream();

  DocumentManagement::attachFile(tableNum(IWS_DeliveryForecastTable), recId, DataAreaId, '文件', stream, name, '', name);