示例#1
0
        /// <summary> Get an InputStream so that the Runtime can build a
        /// template with it.
        /// *
        /// </summary>
        /// <param name="name">name of template
        /// </param>
        /// <returns>InputStream containing template
        ///
        /// </returns>
        //UPGRADE_NOTE: Synchronized keyword was removed from method 'getResourceStream'. Lock expression was added. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1027"'
        public override System.IO.Stream getResourceStream(System.String name)
        {
            lock (this) {
                if (name == null || name.Length == 0)
                {
                    throw new ResourceNotFoundException("Need to specify a template name!");
                }

                try {
                    System.Data.OleDb.OleDbConnection conn = openDbConnection();

                    try {
                        //UPGRADE_TODO: The equivalent of java.sql.ResultSet must call Close() before performing any other operation with the associated connection. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1129"'
                        System.Data.OleDb.OleDbDataReader rs = readData(conn, templateColumn, name);

                        try {
                            if (rs.Read())
                            {
                                //UPGRADE_ISSUE: Method 'java.sql.ResultSet.getAsciiStream' was not converted. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1000_javasqlResultSetgetAsciiStream_javalangString"'
                                return(new System.IO.BufferedStream(rs.getAsciiStream(templateColumn)));
                            }
                            else
                            {
                                System.String msg = "DataSourceResourceLoader Error: cannot find resource " + name;
                                System.Diagnostics.Process.error(msg);

                                throw new ResourceNotFoundException(msg);
                            }
                        } finally {
                            rs.Close();
                        }
                    } finally {
                        closeDbConnection(conn);
                    }
                } catch (System.Exception e) {
                    System.String msg = "DataSourceResourceLoader Error: database problem trying to load resource " + name + ": " + e.ToString();

                    System.Diagnostics.Process.error(msg);

                    throw new ResourceNotFoundException(msg);
                }
            }
        }