public static System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(System.Xml.Schema.XmlSchemaSet xs)
            {
                System.Xml.Schema.XmlSchemaComplexType type     = new System.Xml.Schema.XmlSchemaComplexType();
                System.Xml.Schema.XmlSchemaSequence    sequence = new System.Xml.Schema.XmlSchemaSequence();
                dsVendorPO ds = new dsVendorPO();

                xs.Add(ds.GetSchemaSerializable());
                System.Xml.Schema.XmlSchemaAny any1 = new System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                System.Xml.Schema.XmlSchemaAny any2 = new System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                System.Xml.Schema.XmlSchemaAttribute attribute1 = new System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                System.Xml.Schema.XmlSchemaAttribute attribute2 = new System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "dtPOListDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                return(type);
            }
        public override System.Data.DataSet Clone()
        {
            dsVendorPO cln = ((dsVendorPO)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
        public static System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(System.Xml.Schema.XmlSchemaSet xs)
        {
            dsVendorPO ds = new dsVendorPO();

            System.Xml.Schema.XmlSchemaComplexType type     = new System.Xml.Schema.XmlSchemaComplexType();
            System.Xml.Schema.XmlSchemaSequence    sequence = new System.Xml.Schema.XmlSchemaSequence();
            xs.Add(ds.GetSchemaSerializable());
            System.Xml.Schema.XmlSchemaAny any = new System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            return(type);
        }
コード例 #4
0
        static void Main(string[] args)
        {
            Console.Title = "Daily Vendor PO Summary Report";

            LocalReport rpvVendorPO = new LocalReport();

            //declare connection string
            string cnString = "Data Source=(local);Initial Catalog=RealWorld;Integrated Security=SSPI;";

            //declare Connection, command and other related objects
            SqlConnection conReport = new SqlConnection(cnString);
            SqlCommand    cmdReport = new SqlCommand();
            SqlDataReader drReport;
            DataSet       dsReport = new dsVendorPO();

            try
            {
                //open connection
                conReport.Open();

                //prepare connection object to get the data through reader and populate into dataset
                cmdReport.CommandType = CommandType.Text;
                cmdReport.Connection  = conReport;
                cmdReport.CommandText = "SELECT * FROM tblVendorPO ORDER BY PurchaseOrderID";

                //read data from command object
                drReport = cmdReport.ExecuteReader();

                //load data directly from reader to dataset
                dsReport.Tables[0].Load(drReport);

                //close reader and connection
                drReport.Close();
                conReport.Close();

                //provide local report information to viewer
                rpvVendorPO.ReportEmbeddedResource = "VendorPO.rptVendorPO.rdlc";

                //setup report parameter to pass vendor name
                ReportParameter[] Param = new ReportParameter[1];
                Param[0] = new ReportParameter("parVendorName", "ABCD1234 Inc.");

                rpvVendorPO.SetParameters(Param);

                //prepare report data source
                ReportDataSource rds = new ReportDataSource();
                rds.Name  = "dsVendorPO_dtPOList";
                rds.Value = dsReport.Tables[0];
                rpvVendorPO.DataSources.Add(rds);

                Warning[] warnings;
                string[]  streamids;
                string    mimeType;
                string    encoding;
                string    filenameExtension;

                byte[] bytes = rpvVendorPO.Render(
                    "PDF", null, out mimeType, out encoding, out filenameExtension,
                    out streamids, out warnings);

                using (FileStream fs = new FileStream("output.pdf", FileMode.Create))
                {
                    fs.Write(bytes, 0, bytes.Length);
                }

                //upload fle to FTP site
                UploadToFTP("output.pdf");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Initial Error Message: " + ex.Message);

                string    FinalErrorMessage = string.Empty;
                Exception innerError        = ex.InnerException;
                while (!((innerError == null)))
                {
                    FinalErrorMessage += innerError.Message;
                    innerError         = innerError.InnerException;
                }

                Console.WriteLine("Final Error Message:" + FinalErrorMessage);
                Console.WriteLine("Press any key to exit");

                //Wait for user action of press nay key
                Console.ReadKey();
            }
            finally
            {
                //check if connection is still open then attempt to close it
                if (conReport.State == ConnectionState.Open)
                {
                    conReport.Close();
                }
            }
        }