예제 #1
0
        private DbAccessCommand CreateAccessCommand()
        {
            switch (this.AccessType)
            {
            case DbAccessType.Odbc:
                this.DbCommand = OdbcAccessCommand.GetInstance(this.ConnectionString);
                break;

            case DbAccessType.OleDb:
                this.DbCommand = OleDbAccessCommand.GetInstance(this.ConnectionString);
                break;

            case DbAccessType.Oracle:
                this.DbCommand = OracleAccessCommand.GetInstance(this.ConnectionString);
                break;

            case DbAccessType.Sql:
                this.DbCommand = SqlAccessCommand.GetInstance(this.ConnectionString);
                break;

            default:
                throw new NotSupportedException(this.AccessType.ToString());
            }
            return(this.DbCommand);
        }
예제 #2
0
        private void FillResultNode(XmlNode resultNode, DbAccessCommand dbCommand, DbExcuteType exeType)
        {
            object result = null;

            switch (exeType)
            {
            case DbExcuteType.ExecuteNonQuery:
                result = this.DbCommand.ExecuteNonQuery();
                break;

            case DbExcuteType.ExecuteReader:
                result = this.DbCommand.ExecuteDataSet();
                break;

            case DbExcuteType.ExecuteScalar:
                result = this.DbCommand.ExecuteScalar();
                break;

            case DbExcuteType.ExecuteXmlReader:
            {
                XmlDocument tempDoc = new XmlDocument();
                tempDoc.Load(this.DbCommand.ExecuteXmlReader());
                result = tempDoc.DocumentElement;
                break;
            }

            case DbExcuteType.ExecuteSchemaTable:
                result = this.DbCommand.ExecuteSchemaTable();
                break;

            case DbExcuteType.ExecuteDataTable:
                result = this.DbCommand.ExecuteDataTable();
                break;

            case DbExcuteType.ExecuteDataRow:
                result = this.DbCommand.ExecuteDataRow().Table;
                break;

            case DbExcuteType.ExecuteTableSchema:
                result = this.DbCommand.ExecuteTableSchema();
                break;

            case DbExcuteType.ExecuteDataSet:
                result = this.DbCommand.ExecuteDataSet();
                break;

            case DbExcuteType.ExecuteSetSchema:
                result = this.DbCommand.ExecuteSetSchema();
                break;
            }
            if (result is XmlNode)
            {
                XmlHelper.AddNode(resultNode, result as XmlNode);
            }
            else if (result != null)
            {
                XmlHelper.AddNode(resultNode, SerializeHelper.XmlSerialize(result));
            }
        }
예제 #3
0
 public ExecuteContext(DbAccessCommand dbCommand)
 {
     this.NeedClose    = false;
     this.IsSuccessful = false;
     this.DbCommand    = dbCommand;
     if (this.DbCommand.AutoOpenClose && (this.DbCommand.DbConnection.State != ConnectionState.Open))
     {
         this.DbCommand.Open();
         this.NeedClose = true;
     }
 }
예제 #4
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++;
            }
        }
예제 #5
0
 public static SqlAccessCommand GetInstance(string connectionString)
 {
     return(DbAccessCommand.GetInstance <SqlAccessCommand>(connectionString));
 }