Click here to Skip to main content
15,886,788 members
Articles / Web Development / CSS

A SOA Approach to Dynamic DOCX-PDF Report Generation - Part 1

Rate me:
Please Sign up or sign in to vote.
5.00/5 (6 votes)
23 Aug 2010CDDL6 min read 60.3K   1.3K   65  
Generating docx reports in a client-server architecture, without using MS Office
//------------------------------------------------------------------------------
// <auto-generated>
//     Il codice è stato generato da uno strumento.
//     Versione runtime:2.0.50727.3607
//
//     Le modifiche apportate a questo file possono provocare un comportamento non corretto e andranno perse se
//     il codice viene rigenerato.
// </auto-generated>
//------------------------------------------------------------------------------

namespace DocxGenerator.PL.Web.SvcDynamicDocxGenerator {
    
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    [System.ServiceModel.ServiceContractAttribute(ConfigurationName="SvcDynamicDocxGenerator.IDynamicDocxGeneratorService")]
    public interface IDynamicDocxGeneratorService {
        
        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IDynamicDocxGeneratorService/GenerateDynamicDocx", ReplyAction="http://tempuri.org/IDynamicDocxGeneratorService/GenerateDynamicDocxResponse")]
        byte[] GenerateDynamicDocx(string customXML);
        
        [System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://tempuri.org/IDynamicDocxGeneratorService/GenerateDynamicDocx", ReplyAction="http://tempuri.org/IDynamicDocxGeneratorService/GenerateDynamicDocxResponse")]
        System.IAsyncResult BeginGenerateDynamicDocx(string customXML, System.AsyncCallback callback, object asyncState);
        
        byte[] EndGenerateDynamicDocx(System.IAsyncResult result);
    }
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public interface IDynamicDocxGeneratorServiceChannel : DocxGenerator.PL.Web.SvcDynamicDocxGenerator.IDynamicDocxGeneratorService, System.ServiceModel.IClientChannel {
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public partial class GenerateDynamicDocxCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
        
        private object[] results;
        
        public GenerateDynamicDocxCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : 
                base(exception, cancelled, userState) {
            this.results = results;
        }
        
        public byte[] Result {
            get {
                base.RaiseExceptionIfNecessary();
                return ((byte[])(this.results[0]));
            }
        }
    }
    
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
    public partial class DynamicDocxGeneratorServiceClient : System.ServiceModel.ClientBase<DocxGenerator.PL.Web.SvcDynamicDocxGenerator.IDynamicDocxGeneratorService>, DocxGenerator.PL.Web.SvcDynamicDocxGenerator.IDynamicDocxGeneratorService {
        
        private BeginOperationDelegate onBeginGenerateDynamicDocxDelegate;
        
        private EndOperationDelegate onEndGenerateDynamicDocxDelegate;
        
        private System.Threading.SendOrPostCallback onGenerateDynamicDocxCompletedDelegate;
        
        public DynamicDocxGeneratorServiceClient() {
        }
        
        public DynamicDocxGeneratorServiceClient(string endpointConfigurationName) : 
                base(endpointConfigurationName) {
        }
        
        public DynamicDocxGeneratorServiceClient(string endpointConfigurationName, string remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public DynamicDocxGeneratorServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public DynamicDocxGeneratorServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(binding, remoteAddress) {
        }
        
        public event System.EventHandler<GenerateDynamicDocxCompletedEventArgs> GenerateDynamicDocxCompleted;
        
        public byte[] GenerateDynamicDocx(string customXML) {
            return base.Channel.GenerateDynamicDocx(customXML);
        }
        
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        public System.IAsyncResult BeginGenerateDynamicDocx(string customXML, System.AsyncCallback callback, object asyncState) {
            return base.Channel.BeginGenerateDynamicDocx(customXML, callback, asyncState);
        }
        
        [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
        public byte[] EndGenerateDynamicDocx(System.IAsyncResult result) {
            return base.Channel.EndGenerateDynamicDocx(result);
        }
        
        private System.IAsyncResult OnBeginGenerateDynamicDocx(object[] inValues, System.AsyncCallback callback, object asyncState) {
            string customXML = ((string)(inValues[0]));
            return this.BeginGenerateDynamicDocx(customXML, callback, asyncState);
        }
        
        private object[] OnEndGenerateDynamicDocx(System.IAsyncResult result) {
            byte[] retVal = this.EndGenerateDynamicDocx(result);
            return new object[] {
                    retVal};
        }
        
        private void OnGenerateDynamicDocxCompleted(object state) {
            if ((this.GenerateDynamicDocxCompleted != null)) {
                InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
                this.GenerateDynamicDocxCompleted(this, new GenerateDynamicDocxCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
            }
        }
        
        public void GenerateDynamicDocxAsync(string customXML) {
            this.GenerateDynamicDocxAsync(customXML, null);
        }
        
        public void GenerateDynamicDocxAsync(string customXML, object userState) {
            if ((this.onBeginGenerateDynamicDocxDelegate == null)) {
                this.onBeginGenerateDynamicDocxDelegate = new BeginOperationDelegate(this.OnBeginGenerateDynamicDocx);
            }
            if ((this.onEndGenerateDynamicDocxDelegate == null)) {
                this.onEndGenerateDynamicDocxDelegate = new EndOperationDelegate(this.OnEndGenerateDynamicDocx);
            }
            if ((this.onGenerateDynamicDocxCompletedDelegate == null)) {
                this.onGenerateDynamicDocxCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGenerateDynamicDocxCompleted);
            }
            base.InvokeAsync(this.onBeginGenerateDynamicDocxDelegate, new object[] {
                        customXML}, this.onEndGenerateDynamicDocxDelegate, this.onGenerateDynamicDocxCompletedDelegate, userState);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)


Written By
Engineer
United Kingdom United Kingdom
I've been involved in object-oriented software development since 2006, when I graduated in Information and TLC Engineering. I've been working for several software companies / departments, mainly on Microsoft and Sun/Oracle technologies. My favourite programming language is C#, next comes Java.
I love design patterns and when I need to resolve a problem, I try to get the best solution, which is often not the quickest one.

"On the best teams, different individuals provide occasional leadership, taking charge in areas where they have particular strengths. No one is the permanent leader, because that person would then cease to be a peer and the team interaction would begin to break down. The structure of a team is a network, not a hierarchy ..."
My favourite team work quotation by DeMarco - Lister in Peopleware

Comments and Discussions