public void Apply()
        {
            ICustomReportItem cri = null;

            try
            {
                cri = RdlEngineConfig.CreateCustomReportItem(_Type);
                foreach (XmlNode node in _ReportItems)
                {
                    cri.SetPropertiesInstance(_Draw.GetNamedChildNode(node, "CustomProperties"),
                                              pgProps.SelectedObject);
                }
            }
            catch
            {
                return;
            }
            finally
            {
                if (cri != null)
                {
                    cri.Dispose();
                }
            }
            return;
        }
示例#2
0
        static internal bool TestConnection(string dataProvider, string connection)
        {
            IDbConnection cnSQL   = null;
            bool          bResult = false;

            try
            {
                cnSQL = RdlEngineConfig.GetConnection(dataProvider, connection);
                cnSQL.Open();
                bResult = true;                                 // we opened the connection
            }
            catch (Exception e)
            {
                MessageBox.Show(e.InnerException == null? e.Message: e.InnerException.Message, "Unable to open connection");
            }
            finally
            {
                if (cnSQL != null)
                {
                    cnSQL.Close();
                    cnSQL.Dispose();
                }
            }
            return(bResult);
        }
示例#3
0
        static internal List <SqlColumn> GetSqlColumns(string dataProvider, string connection, string sql, IList parameters)
        {
            List <SqlColumn> cols       = new List <SqlColumn>();
            IDbConnection    cnSQL      = null;
            IDbCommand       cmSQL      = null;
            IDataReader      dr         = null;
            Cursor           saveCursor = Cursor.Current;

            Cursor.Current = Cursors.WaitCursor;
            try
            {
                // Open up a connection
                cnSQL = RdlEngineConfig.GetConnection(dataProvider, connection);
                if (cnSQL == null)
                {
                    return(cols);
                }

                cnSQL.Open();
                cmSQL             = cnSQL.CreateCommand();
                cmSQL.CommandText = sql;
                AddParameters(cmSQL, parameters);
                dr = cmSQL.ExecuteReader(CommandBehavior.SchemaOnly);
                for (int i = 0; i < dr.FieldCount; i++)
                {
                    SqlColumn sc = new SqlColumn();
                    sc.Name     = dr.GetName(i);
                    sc.DataType = dr.GetFieldType(i);
                    cols.Add(sc);
                }
            }
            catch (SqlException sqle)
            {
                MessageBox.Show(sqle.Message, "SQL Error");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.InnerException == null? e.Message:e.InnerException.Message, "Error");
            }
            finally
            {
                if (cnSQL != null)
                {
                    if (cmSQL != null)
                    {
                        cmSQL.Dispose();
                        if (dr != null)
                        {
                            dr.Close();
                        }
                    }
                    cnSQL.Close();
                    cnSQL.Dispose();
                }
                Cursor.Current = saveCursor;
            }
            return(cols);
        }
示例#4
0
        public static void Main(string[] args)
        {
            ConfigurationManager = new ConfigManager();
            RdlEngineConfig.RdlEngineConfigInit();
            var a = new QrCode();
            var b = GZipConstants.FCOMMENT;

            BuildWebHost(args).Run();
        }
        static internal void GetSqlData(string dataProvider, string connection, string sql, IList parameters, DataTable dt)
        {
            IDbConnection cnSQL      = null;
            IDbCommand    cmSQL      = null;
            IDataReader   dr         = null;
            Cursor        saveCursor = Cursor.Current;

            Cursor.Current = Cursors.WaitCursor;
            try
            {
                // Open up a connection
                cnSQL = RdlEngineConfig.GetConnection(dataProvider, connection);
                if (cnSQL == null)
                {
                    return;
                }

                cnSQL.Open();
                cmSQL             = cnSQL.CreateCommand();
                cmSQL.CommandText = sql;
                AddParameters(cmSQL, parameters);
                dr = cmSQL.ExecuteReader(CommandBehavior.SingleResult);

                object[] rowValues = new object[dt.Columns.Count];

                while (dr.Read())
                {
                    int ci = 0;
                    foreach (DataColumn dc in dt.Columns)
                    {
                        object v = dr[dc.ColumnName];
//                        string val = Convert.ToString(dr[dc.ColumnName], System.Globalization.NumberFormatInfo.InvariantInfo);
//                        rowValues[ci++] = val;
                        rowValues[ci++] = v;
                    }
                    dt.Rows.Add(rowValues);
                }
            }
            finally
            {
                if (cnSQL != null)
                {
                    cnSQL.Close();
                    cnSQL.Dispose();
                    if (cmSQL != null)
                    {
                        cmSQL.Dispose();
                        if (dr != null)
                        {
                            dr.Close();
                        }
                    }
                }
                Cursor.Current = saveCursor;
            }
            return;
        }
        public DialogDatabase(RdlUserControl rDesigner)
        {
            _rUserControl = rDesigner;
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            string[] items = RdlEngineConfig.GetProviders();
            cbOrientation.SelectedIndex = 0;
        }
示例#7
0
        public void Prepare2Tests()
        {
            if (_outputFolder == null)
            {
                _outputFolder = GeneralUtils.OutputTestsFolder();
            }

            _reportFolder = GeneralUtils.ReportsFolder();

            Directory.CreateDirectory(_outputFolder.LocalPath);

            RdlEngineConfig.RdlEngineConfigInit();
        }
示例#8
0
        private Report GetReport(string prog, string file)
        {
            // Now parse the file
            RDLParser rdlp;
            Report    r;

            try
            {
                // Make sure RdlEngine is configed before we ever parse a program
                //   The config file must exist in the Bin directory.

                //string searchDir = this.MapPathSecure(this.ReportFile.StartsWith("~") ? "~/Bin" : "/Bin") + Path.DirectorySeparatorChar;
                string searchDir = this.MapPathSecure("~/Bin") + Path.DirectorySeparatorChar;

                RdlEngineConfig.RdlEngineConfigInit(searchDir);

                rdlp = new RDLParser(prog);
                string folder = Path.GetDirectoryName(file);
                if (folder == "")
                {
                    folder = Environment.CurrentDirectory;
                }
                rdlp.Folder = folder;
                rdlp.DataSourceReferencePassword = new NeedPassword(this.GetPassword);

                r = rdlp.Parse();
                if (r.ErrorMaxSeverity > 0)
                {
                    AddError(r.ErrorMaxSeverity, r.ErrorItems);
                    if (r.ErrorMaxSeverity >= 8)
                    {
                        r = null;
                    }
                    r.ErrorReset();
                }

                // If we've loaded the report; we should tell it where it got loaded from
                if (r != null)
                {
                    r.Folder = folder;
                    r.Name   = Path.GetFileNameWithoutExtension(file);
                    r.GetDataSourceReferencePassword = new RDL.NeedPassword(GetPassword);
                }
            }
            catch (Exception e)
            {
                r = null;
                AddError(8, "Exception parsing report {0}.  {1}", file, e.Message);
            }
            return(r);
        }
示例#9
0
        public DialogDataSourceRef()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            string[] items = RdlEngineConfig.GetProviders();

            cbDataProvider.Items.AddRange(items);

            this.cbDataProvider.SelectedIndex = 0;
            this.bOK.Enabled = false;
        }
        public void Prepare2Tests()
        {
            if (_outputFolder == null)
            {
                string tmpf = System.IO.Path.GetTempPath();
                _outputFolder = new Uri(System.IO.Path.Combine(tmpf, "rdlTestResults", Guid.NewGuid().ToString()));
            }

            string cwd = System.Environment.CurrentDirectory;

            _reportFolder = new Uri(System.IO.Path.Combine(cwd, "Reports", "Excel/"));


            Directory.CreateDirectory(_outputFolder.LocalPath);

            RdlEngineConfig.RdlEngineConfigInit();
        }
示例#11
0
        public RdlReader(bool mono)
        {
            bMono = mono;
            GetStartupState();

            InitializeComponent();

            BuildMenus();
            // CustomReportItem load
            RdlEngineConfig.GetCustomReportTypes();

            Application.AddMessageFilter(this);

            this.Closing += new System.ComponentModel.CancelEventHandler(this.RdlReader_Closing);
            _GetPassword  = new RDL.NeedPassword(this.GetPassword);

            // open up the current files if any
            if (_CurrentFiles != null)
            {
                foreach (var dict in _CurrentFiles)
                {
                    MDIChild mc = new MDIChild(this.ClientRectangle.Width * 3 / 4, this.ClientRectangle.Height * 3 / 4);
                    mc.MdiParent = this;
                    mc.Viewer.GetDataSourceReferencePassword = _GetPassword;

                    mc.SourceFile = dict.Key;
                    if (dict.Value != string.Empty)
                    {
                        mc.Parameters = dict.Value;
                    }

                    mc.Text = dict.Key.LocalPath;

                    if (_CurrentFiles.Count == 1)
                    {
                        mc.WindowState = FormWindowState.Maximized;
                    }

                    mc.Show();
                }
                _CurrentFiles = null;           // don't need this any longer
            }
        }
示例#12
0
        private void InitValues()
        {
            ICustomReportItem cri = null;

            try
            {
                cri = RdlEngineConfig.CreateCustomReportItem(_Type);
                object props = cri.GetPropertiesInstance(_Draw.GetNamedChildNode(_ReportItems[0], "CustomProperties"));
                pgProps.SelectedObject = props;
            }
            catch
            {
                return;
            }
            finally
            {
                if (cri != null)
                {
                    cri.Dispose();
                }
            }
        }
示例#13
0
        private void SetCustomReportItem(PropertyDescriptorCollection pdc)
        {
            ICustomReportItem cri = null;

            try
            {
                string t = _Draw.GetElementValue(this.Node, "Type", "");

                cri = RdlEngineConfig.CreateCustomReportItem(t);

                _custom = cri.GetPropertiesInstance(_Draw.GetNamedChildNode(this.Node, "CustomProperties"));
                TypeDescriptor.CreateAssociation(this, _custom);

                PropertyDescriptorCollection bProps =
                    TypeDescriptor.GetProperties(_custom, true);

                foreach (PropertyDescriptor p in bProps)
                {
                    // create our custom property descriptor and add it to the collection

                    pdc.Add(p);
                }
            }
            catch
            {
            }
            finally
            {
                if (cri != null)
                {
                    cri.Dispose();
                }
            }

            return;
        }
示例#14
0
        private void InitValues()
        {
            // Populate the DataProviders
            cbDataProvider.Items.Clear();
            string[] items = RdlEngineConfig.GetProviders();
            cbDataProvider.Items.AddRange(items);

            //
            // Obtain the existing DataSets info
            //
            XmlNode rNode  = _Draw.GetReportNode();
            XmlNode dsNode = _Draw.GetNamedChildNode(rNode, "DataSources");

            if (dsNode == null)
            {
                return;
            }
            foreach (XmlNode dNode in dsNode)
            {
                if (dNode.Name != "DataSource")
                {
                    continue;
                }
                XmlAttribute nAttr = dNode.Attributes["Name"];
                if (nAttr == null)      // shouldn't really happen
                {
                    continue;
                }

                DataSourceValues dsv = new DataSourceValues(nAttr.Value);
                dsv.Node = dNode;

                dsv.DataSourceReference = _Draw.GetElementValue(dNode, "DataSourceReference", null);
                if (dsv.DataSourceReference == null)
                {       // this is not a data source reference
                    dsv.bDataSourceReference = false;
                    dsv.DataSourceReference  = "";

                    XmlNode cpNode = DesignXmlDraw.FindNextInHierarchy(dNode, "ConnectionProperties", "ConnectString");
                    dsv.ConnectionString = cpNode == null ? "" : cpNode.InnerText;

                    XmlNode datap = DesignXmlDraw.FindNextInHierarchy(dNode, "ConnectionProperties", "DataProvider");
                    dsv.DataProvider = datap == null ? "" : datap.InnerText;

                    XmlNode p = DesignXmlDraw.FindNextInHierarchy(dNode, "ConnectionProperties", "Prompt");
                    dsv.Prompt = p == null ? "" : p.InnerText;
                }
                else
                {       // we have a data source reference
                    dsv.bDataSourceReference = true;
                    dsv.ConnectionString     = "";
                    dsv.DataProvider         = "";
                    dsv.Prompt = "";
                }

                this.lbDataSources.Items.Add(dsv);
            }
            if (lbDataSources.Items.Count > 0)
            {
                lbDataSources.SelectedIndex = 0;
            }
            else
            {
                this.bOK.Enabled = false;
            }
        }
示例#15
0
        static internal List <SqlSchemaInfo> GetSchemaInfo(string dataProvider, string connection)
        {
            List <SqlSchemaInfo> schemaList = new List <SqlSchemaInfo>();
            IDbConnection        cnSQL      = null;
            IDbCommand           cmSQL      = null;
            IDataReader          dr         = null;
            Cursor saveCursor = Cursor.Current;

            Cursor.Current = Cursors.WaitCursor;

            // Get the schema information
            try
            {
                int ID_TABLE = 0;
                int ID_TYPE  = 1;

                // Open up a connection
                cnSQL = RdlEngineConfig.GetConnection(dataProvider, connection);
                if (cnSQL == null)
                {
                    MessageBox.Show(string.Format("Unable to connect using dataProvider '{0}'", dataProvider), "SQL Error");
                    return(schemaList);
                }
                cnSQL.Open();

                // Take advantage of .Net metadata if available
                if (cnSQL is System.Data.SqlClient.SqlConnection)
                {
                    return(GetSchemaInfo((System.Data.SqlClient.SqlConnection)cnSQL, schemaList));
                }
                if (cnSQL is System.Data.Odbc.OdbcConnection)
                {
                    return(GetSchemaInfo((System.Data.Odbc.OdbcConnection)cnSQL, schemaList));
                }
                if (cnSQL is System.Data.OleDb.OleDbConnection)
                {
                    return(GetSchemaInfo((System.Data.OleDb.OleDbConnection)cnSQL, schemaList));
                }

                // Obtain the query needed to get table/view list
                string sql = RdlEngineConfig.GetTableSelect(dataProvider, cnSQL);
                if (sql == null || sql.Length == 0)                             // when no query string; no meta information available
                {
                    return(schemaList);
                }

                // Obtain the query needed to get table/view list
                cmSQL             = cnSQL.CreateCommand();
                cmSQL.CommandText = sql;

                dr = cmSQL.ExecuteReader();
                string type = "TABLE";
                while (dr.Read())
                {
                    SqlSchemaInfo ssi = new SqlSchemaInfo();

                    if (ID_TYPE >= 0 &&
                        dr.FieldCount < ID_TYPE &&
                        (string)dr[ID_TYPE] == "VIEW")
                    {
                        type = "VIEW";
                    }

                    ssi.Type = type;
                    ssi.Name = (string)dr[ID_TABLE];
                    schemaList.Add(ssi);
                }
            }
            catch (SqlException sqle)
            {
                MessageBox.Show(sqle.Message, "SQL Error");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.InnerException == null? e.Message: e.InnerException.Message, "Error");
            }
            finally
            {
                if (cnSQL != null)
                {
                    cnSQL.Close();
                    if (cmSQL != null)
                    {
                        cmSQL.Dispose();
                    }
                    if (dr != null)
                    {
                        dr.Close();
                    }
                }
                Cursor.Current = saveCursor;
            }
            return(schemaList);
        }