Ejemplo n.º 1
0
        /// <summary>
        /// Reads a string that is stored in a Object.
        /// </summary>
        /// <param name="variableName">The name under which the string is stored.</param>
        /// <returns>The value converted to string.</returns>
        public string ReadLongStringVariable(string variableName)
        {
            if (Dts.Variables[variableName].DataType.Equals(typeof(string)))
            {
                return(Dts.Variables[variableName].Value.ToString());
            }
            OleDbDataAdapter da = new OleDbDataAdapter();
            DataTable        dt = new DataTable();

            ADODB.Stream    stm    = new ADODB.Stream();
            ADODB.Recordset rs     = ((ADODB.Recordset)Dts.Variables[variableName].Value).Clone();
            ADODB.Recordset rsCopy = new ADODB.Recordset();

            rs.Save(stm);
            rsCopy.Open(stm);
            da.Fill(dt, rs);
            dt.Clear();
            da.Fill(dt, rsCopy);

            if (
                dt.Rows.Count > 0 &&
                dt.Rows[0].ItemArray.Count() > 0
                )
            {
                return(dt.Rows[0].ItemArray[0].ToString());
            }
            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Extracts the data contained in the ADO recordset and stores it in
        /// XmlSource.  If there is another recordset, then the first was actually
        /// Extended attributes metadata, so that document is move to XmlExtendedAttributes,
        /// and the data in the second recordset is store into XmlSource.
        /// </summary>
        private void GetSource()
        {
            ADODB.Connection oConn = null;
            if (oRs == null)
            {
                OpenRecordset(CreateCommand(ref oConn));
            }
            MSXML2.DOMDocument D1 = new MSXML2.DOMDocumentClass();
            // load the 1st dataset
            oRs.Save(D1, ADODB.PersistFormatEnum.adPersistXML);
            XmlSource = new XmlDocument();
            XmlSource.LoadXml(D1.xml);

            object RecordsAffected;

            oRs = oRs.NextRecordset(out RecordsAffected);
            if (oRs != null && oRs.State == 1)
            {
                XmlExtendedAttributes = XmlSource;
                // Load the 2nd dataset
                oRs.Save(D1, ADODB.PersistFormatEnum.adPersistXML);
                XmlSource = new XmlDocument();
                XmlSource.LoadXml(D1.xml);
            }
            if (oRs != null && oRs.State == 1)
            {
                oRs.Close();
            }
            if (oConn != null)
            {
                oConn.Close();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据SQL语句生成DOMDocumentClass对象
        /// </summary>
        /// <param name="Strsql">SQL语句</param>
        /// <param name="U8Login">U8Login对象</param>
        /// <returns></returns>
        public static MSXML2.DOMDocument getDom(string Strsql, string strConn)
        {
            MSXML2.DOMDocument dom  = new MSXML2.DOMDocument();
            ADODB.Connection   conn = new ADODB.Connection();
            ADODB.Recordset    rs   = new ADODB.Recordset();

            conn.Open(strConn);

            rs.Open(Strsql, conn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockOptimistic, -1);
            rs.Save(dom, ADODB.PersistFormatEnum.adPersistXML);

            return(dom);
        }
Ejemplo n.º 4
0
        // Output data to xml
        public static Boolean bExportDataToXML(String sDatabaseLocation, Boolean bDebug)
        {
            clsLog clsLog_ = new clsLog(msLogFile, msVersionData);
            clsError clsError_ = new clsError();

            ADODB.Connection conn = new ADODB.Connection();
            ADODB.Recordset rs = new ADODB.Recordset();

            clsLog_.mLog(Constants.gcInfo, "Exporting data to xml ...");

            String sOneLanPropertyfile = sDatabaseLocation + "\\xml\\OneLanProperty.xml";
            String sOneLanAccomfile = sDatabaseLocation + "\\xml\\OneLanAccom.xml";

            if (bDebug) { clsLog_.mLog(Constants.gcInfo, sIndent + "onelan.bExportDataToXML, sOneLanPropertyfile = " + sOneLanPropertyfile); }
            if (bDebug) { clsLog_.mLog(Constants.gcInfo, sIndent + "onelan.bExportDataToXML, sOneLanAccomfile = " + sOneLanAccomfile); }

            try
            {
                // Open connection to database
                conn.Open(gcDSN + sDatabaseLocation + "\\" + gsOneLanDatabase);

                // Remove previous versions of the files
                if (File.Exists(sOneLanPropertyfile)) {File.Delete(sOneLanPropertyfile);}
                if (File.Exists(sOneLanAccomfile)) {File.Delete(sOneLanAccomfile);}

                // Open the recordset
                rs.Open("SELECT * FROM Property", conn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockOptimistic, -1);
                rs.Save(sOneLanPropertyfile, ADODB.PersistFormatEnum.adPersistXML);
                rs.Close();

                rs.Open("SELECT * FROM Accom", conn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockOptimistic, -1);
                rs.Save(sOneLanAccomfile, ADODB.PersistFormatEnum.adPersistXML);
                rs.Close();

                conn.Close();

                return true;
            }
            catch (Exception e)
            {
               clsError_.mLogError("Problem exporting data to xml", "onelan", "bExportDataToXML", e, msVersionData, msLogFile, false);
               return false;
            }
        }