Esempio n. 1
0
 public DataTable[] ExecuteSetSchema(DbAccessInformation accessInfo)
 {
     if (accessInfo == null)
     {
         return(null);
     }
     DataTable[] result = null;
     this.DbCommand.AttachAccessInfo(accessInfo);
     result = this.DbCommand.ExecuteSetSchema();
     this.DbCommand.PickupParameteValues(accessInfo);
     return(result);
 }
Esempio n. 2
0
        public int UpdateDataRow(DbAccessInformation accessInfo, params DataRow[] dataRows)
        {
            if (accessInfo == null)
            {
                return(-1);
            }
            int result = -1;

            this.DbCommand.AttachAccessInfo(accessInfo);
            result = this.DbCommand.UpdateDataRow(dataRows);
            this.DbCommand.PickupParameteValues(accessInfo);
            return(result);
        }
Esempio n. 3
0
        public XmlReader ExecuteXmlReader(DbAccessInformation accessInfo, bool isTransaction)
        {
            if (accessInfo == null)
            {
                return(null);
            }
            XmlReader result = null;

            this.DbCommand.AttachAccessInfo(accessInfo);
            result = this.DbCommand.ExecuteXmlReader();
            this.DbCommand.PickupParameteValues(accessInfo);
            return(result);
        }
Esempio n. 4
0
        public object ExecuteScalar(DbAccessInformation accessInfo)
        {
            if (accessInfo == null)
            {
                return(null);
            }
            object result = null;

            this.DbCommand.AttachAccessInfo(accessInfo);
            result = this.DbCommand.ExecuteScalar();
            this.DbCommand.PickupParameteValues(accessInfo);
            return(result);
        }
Esempio n. 5
0
        public int ExecuteNonQuery(DbAccessInformation accessInfo)
        {
            if (accessInfo == null)
            {
                return(-1);
            }
            int result = 0;

            this.DbCommand.AttachAccessInfo(accessInfo);
            result = this.DbCommand.ExecuteNonQuery();
            this.DbCommand.PickupParameteValues(accessInfo);
            return(result);
        }
Esempio n. 6
0
        public DataTable ExecuteDataTable(DbAccessInformation accessInfo, int startRecord, int maxRecords)
        {
            if (accessInfo == null)
            {
                return(null);
            }
            DataTable result = null;

            this.DbCommand.AttachAccessInfo(accessInfo);
            result = this.DbCommand.ExecuteDataTable(startRecord, maxRecords);
            this.DbCommand.PickupParameteValues(accessInfo);
            return(result);
        }
Esempio n. 7
0
        public int ExecuteDataTable(DbAccessInformation accessInfo, DataTable dataTable, int startRecord, int maxRecords)
        {
            if (accessInfo == null)
            {
                return(-1);
            }
            int result = -1;

            this.DbCommand.AttachAccessInfo(accessInfo);
            result = this.DbCommand.ExecuteDataTable(dataTable, startRecord, maxRecords);
            this.DbCommand.PickupParameteValues(accessInfo);
            return(result);
        }
Esempio n. 8
0
        public int ExecuteDataSet(DbAccessInformation accessInfo, DataSet dataSet, int startRecord, int maxRecords, string srcTable)
        {
            if (accessInfo == null)
            {
                return(0);
            }
            int result = 0;

            this.DbCommand.AttachAccessInfo(accessInfo);
            result = this.DbCommand.ExecuteDataSet(dataSet, startRecord, maxRecords, srcTable);
            this.DbCommand.PickupParameteValues(accessInfo);
            return(result);
        }
Esempio n. 9
0
        public int ExecuteDataSet(DbAccessInformation accessInfo, DataSet dataSet)
        {
            if (accessInfo == null)
            {
                return(-1);
            }
            int result = -1;

            this.DbCommand.AttachAccessInfo(accessInfo);
            result = this.DbCommand.ExecuteDataSet(dataSet);
            this.DbCommand.PickupParameteValues(accessInfo);
            return(result);
        }
Esempio n. 10
0
        public int UpdateDataTable(DbAccessInformation accessInfo, DataTable dataTable)
        {
            if (accessInfo == null)
            {
                return(-1);
            }
            int result = -1;

            this.DbCommand.AttachAccessInfo(accessInfo);
            result = this.DbCommand.UpdateDataTable(dataTable);
            this.DbCommand.PickupParameteValues(accessInfo);
            return(result);
        }
Esempio n. 11
0
        public DataRow ExecuteDataRow(DbAccessInformation accessInfo)
        {
            if (accessInfo == null)
            {
                return(null);
            }
            DataRow result = null;

            this.DbCommand.AttachAccessInfo(accessInfo);
            result = this.DbCommand.ExecuteDataRow();
            this.DbCommand.PickupParameteValues(accessInfo);
            return(result);
        }
Esempio n. 12
0
 public void AttachAccessInfo(DbAccessInformation accessInfo, DbParameter[] parameters)
 {
     if (accessInfo != null)
     {
         this.DbCommand.CommandText    = accessInfo.CommandText;
         this.DbCommand.CommandType    = accessInfo.CommandType;
         this.DbCommand.CommandTimeout = accessInfo.CommandTimeout;
         this.DbCommand.Parameters.Clear();
         if ((parameters == null) && (accessInfo.CommandType == System.Data.CommandType.StoredProcedure))
         {
             parameters = this.GetCachedParameters(accessInfo.CommandText);
         }
         if (parameters == null)
         {
             if (accessInfo.Parameters != null)
             {
                 foreach (DbAccessParameter accParameter in accessInfo.Parameters)
                 {
                     if (accParameter.ProvideType >= 0)
                     {
                         this.DbCommand.Parameters.Add(this.CreateParameter(accParameter.ParameterName, accParameter.ProvideType, accParameter.Size, accParameter.Direction, accParameter.IsNullable, accParameter.Precision, accParameter.Scale, accParameter.SourceColumn, accParameter.SourceVersion, accParameter.Value));
                     }
                     else
                     {
                         this.DbCommand.Parameters.Add(accParameter.ConvertParameter(base.CreateParameter()));
                     }
                 }
             }
         }
         else
         {
             this.DbCommand.Parameters.AddRange(parameters);
             if (accessInfo.Parameters != null)
             {
                 this.AssignParameterValues(accessInfo.Parameters);
             }
         }
         foreach (DbParameter parameter in this.DbCommand.Parameters)
         {
             if (parameter.Value == null)
             {
                 parameter.Value = DBNull.Value;
             }
         }
     }
 }
Esempio n. 13
0
 public void PickupParameteValues(DbAccessInformation accessInfo)
 {
     foreach (DbParameter parameter in this.DbCommand.Parameters)
     {
         if (parameter.Direction != ParameterDirection.Input)
         {
             if (accessInfo.Parameters.Contains(parameter.ParameterName))
             {
                 accessInfo.Parameters[parameter.ParameterName].Value = parameter.Value;
             }
             else
             {
                 accessInfo.AddParameter(parameter.ParameterName, parameter.Value);
             }
         }
     }
 }
Esempio n. 14
0
        public XmlDocument ExecuteXml(XmlNode input)
        {
            XmlNodeList accessNodes = input.SelectNodes("DbAccessInformation");

            DbExcuteType[]        exeTypes    = new DbExcuteType[accessNodes.Count];
            DbAccessInformation[] accessInfos = new DbAccessInformation[accessNodes.Count];
            int i = 0;
            int j = accessNodes.Count;

            while (i < j)
            {
                XmlNode             accessNode = accessNodes[i].CloneNode(true);
                DbExcuteType        exeType    = (DbExcuteType)DataConvert.ParseEnum(XmlHelper.GetAttributeValue(accessNode, "excuteType"), DbExcuteType.ExecuteNonQuery);
                DbAccessInformation accessInfo = SerializeHelper.XmlDeserialize(accessNode, typeof(DbAccessInformation)) as DbAccessInformation;
                exeTypes[i]    = exeType;
                accessInfos[i] = accessInfo;
                i++;
            }
            XmlDocument doc      = XmlHelper.CreateXmlDocument("ActionItems", null);
            bool        needOpen = this.DbCommand.Connection.State != ConnectionState.Open;

            if (needOpen)
            {
                this.DbCommand.Open();
            }
            bool isFailed = true;

            try
            {
                this.InnerExecuteXml(doc, this.DbCommand, exeTypes, accessInfos);
                isFailed = false;
            }
            finally
            {
                if (isFailed && (this.DbCommand.Transaction != null))
                {
                    this.DbCommand.RollbackTransaction();
                }
                if (needOpen || isFailed)
                {
                    this.DbCommand.Close();
                }
            }
            return(doc);
        }
Esempio n. 15
0
        private void InnerExecuteXml(XmlDocument doc, DbAccessCommand dbCommand, DbExcuteType[] exeTypes, DbAccessInformation[] accessInfos)
        {
            int i = 0;
            int j = exeTypes.Length;

            while (i < j)
            {
                DbAccessInformation accessInfo = accessInfos[i];
                XmlNode             itemNode   = XmlHelper.SetInnerText(doc.DocumentElement, "ActionItem", string.Empty);
                XmlHelper.SetAttribute(itemNode, "sequence", (i + 1).ToString());
                dbCommand.AttachAccessInfo(accessInfo);
                XmlNode resultNode = XmlHelper.SetInnerText(itemNode, "Result", string.Empty);
                this.FillResultNode(resultNode, dbCommand, exeTypes[i]);
                dbCommand.PickupParameteValues(accessInfo);
                XmlHelper.AddNode(itemNode, SerializeHelper.XmlSerialize(accessInfo));
                i++;
            }
        }
Esempio n. 16
0
        public object ExecuteReader(DbAccessInformation accessInfo, Func <DbDataReader, object> readerHandler, int startRecord)
        {
            if ((accessInfo == null) || (readerHandler == null))
            {
                return(null);
            }
            object result = null;

            this.DbCommand.AttachAccessInfo(accessInfo);
            DbDataReader reader = this.DbCommand.ExecuteReader(startRecord);

            if (readerHandler != null)
            {
                result = readerHandler(reader);
            }
            if (!reader.IsClosed)
            {
                reader.Close();
            }
            this.DbCommand.PickupParameteValues(accessInfo);
            return(result);
        }
Esempio n. 17
0
 public void AttachAccessInfo(DbAccessInformation accessInfo)
 {
     this.AttachAccessInfo(accessInfo, null);
 }