分类 Dynamics 365 下的文章

    catch(Exception::CLRError)
    {
        System.Exception    interopException = CLRInterop::getLastException();

        obj.Add("Code", 1);
        obj.Add("Message", interopException.Message.ToString());

    }
    catch
    {
        SysInfoLogEnumerator    infoLogEnum;
        str                     Message;

        infoLogEnum = SysInfoLogEnumerator::newData(infolog.copy(1, infologLine()));

        while(infoLogEnum.moveNext())
        {
            Message += infoLogEnum.currentMessage();
        }

        obj.Add("Code", 1);
        obj.Add("Message", Message);
    }

class IWS_RefreshUnrecievedInvoiceRunbase extends RunBaseBatch
{

protected void new()
{
    super();
}

public boolean canRunInNewSession()
{
    return true;
}

static IWS_RefreshUnrecievedInvoiceRunbase construct()
{
    return new IWS_RefreshUnrecievedInvoiceRunbase();
}

static ClassDescription description()
{
    return "Update project invoice ID for negative amounts " + curExt();
}

static void main(Args args)
{
    IWS_RefreshUnrecievedInvoiceRunbase    runbase;

    runbase = IWS_RefreshUnrecievedInvoiceRunbase::construct();

    if (runbase.prompt())
    {
        runbase.runOperation();
    }
}

public void run()
{
    
}

}

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;
}