示例#1
0
        static void Main(string[] args)
        {
            //Initialize the engine
            Report.Init();

            //Open template file and create output file
            FileStream template = File.OpenRead("../../../Samples/Windward OData - Template.docx");
            FileStream output   = File.Create("../../../Samples/OData Report.pdf");

            //Create report process
            Report myReport = new ReportPdf(template, output);

            //Run the report process
            myReport.ProcessSetup();

            //Datasource connection code for 'ODataSample' (datasource name inside template)
            IReportDataSource ODataSampleData = new ODataDataSourceImpl("Url=http://services.odata.org/northwind/northwind.svc/;Version=3");
            var dataSources = new Dictionary <string, IReportDataSource>()
            {
                { "ODataSample", ODataSampleData }
            };

            myReport.ProcessData(dataSources);
            myReport.ProcessComplete();

            //Close out of our template file and output
            output.Close();
            template.Close();

            //Open the finished report
            string fullPath = Path.GetFullPath("../../../Samples/OData Report.pdf");

            System.Diagnostics.Process.Start(fullPath);
        }
        static void Main(string[] args)
        {
            //Initialize the engine
            Report.Init();

            //Open template file and create output file
            FileStream template = File.OpenRead("../../../Samples/Sharepoint with OData - Template.docx");
            FileStream output   = File.Create("../../../Samples/Sharepoint Report.pdf");

            //Create report process
            Report myReport = new ReportPdf(template, output);

            //Run the report process
            myReport.ProcessSetup();

            //Datasource connection code for 'ODataSample' (datasource name inside template)
            IReportDataSource ODataSampleData = new ODataDataSourceImpl("http://sharepointdemo.windward.net/_vti_bin/listdata.svc/", "windwarddemo\\demo", "demo", FileUtils.CONNECT_MODE.CREDENTIALS, 2);
            var dataSources = new Dictionary <string, IReportDataSource>()
            {
                { "sp", ODataSampleData }
            };

            myReport.ProcessData(dataSources);
            myReport.ProcessComplete();

            //Close out of our template file and output
            output.Close();
            template.Close();

            //Open the finished report
            string fullPath = Path.GetFullPath("../../../Samples/Sharepoint Report.pdf");

            System.Diagnostics.Process.Start(fullPath);
        }
示例#3
0
        static void Main(string[] args)
        {
            // Initialize the engine
            Report.Init();

            // Open template file and create output file
            FileStream template = File.OpenRead("../../../Samples/MSDynamics CRM - Template.docx");
            FileStream output   = File.Create("../../../Samples/OData Report.pdf");
            Report     myReport = new ReportPdf(template, output);


            // To connect we first we need to grab the security access token, here we use Windward's example implementation
            // of WS-Trust authenticator and you can change AuthenticateWithWsTrust() to be AuthenticateWithOAuthPrompt() here.
            // Also you can replace the authenticator with your own implementation and pass it's token into WrCredentials instead.
            var authToken = WsTrustAuthenticate();

            var securityTokenCredentials = new WrCredentials {
                SecurityToken = authToken.AccessToken
            };

            var datasource = new ODataDataSourceImpl(serviceUrl, securityTokenCredentials, FileUtils.CONNECT_MODE.SECURITY_TOKEN, 2);

            // Run the report process
            myReport.ProcessSetup();
            // The second parameter is "" to tell the process that our data is the default data source
            myReport.ProcessData(datasource, "");
            myReport.ProcessComplete();

            // Close out of our template file and output
            output.Close();
            template.Close();

            // Opens the finished report
            string fullPath = Path.GetFullPath("../../../Samples/OData Report.pdf");

            System.Diagnostics.Process.Start(fullPath);
        }