Esempio n. 1
0
        public virtual int ExecuteNonQuery(string query, System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.Parameter> queryParameters, System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.Parameter> generatedKeys) /* throws Net.Vpc.Upa.Exceptions.UPAException */
        {
            if (closed)
            {
                throw new System.ArgumentException("Connection closed");
            }
            System.Exception error = null;
            int  count             = -1;
            bool gen       = generatedKeys != null && (generatedKeys).Count > 0;
            long startTime = System.DateTime.Now.Ticks;

            try {
                System.Data.IDbCommand s = null;
                s             = connection.CreateCommand();
                s.CommandText = query;
                s.CommandType = System.Data.CommandType.Text;
                int index = 1;
                if (queryParameters != null)
                {
                    foreach (Net.Vpc.Upa.Persistence.Parameter @value in queryParameters)
                    {
                        Net.Vpc.Upa.Types.DataTypeTransform         chain          = @value.GetTypeTransform();
                        Net.Vpc.Upa.Impl.Persistence.TypeMarshaller typeMarshaller = marshallManager.GetTypeMarshaller(chain);
                        typeMarshaller.Write(@value.GetValue(), index, s);
                        index += typeMarshaller.GetSize();
                    }
                }
                count = s.ExecuteNonQuery();
            } catch (System.Exception ee) {
                error = ee;
                //            Log.log(PersistenceUnitManager.DB_ERROR_LOG,"[Error] "+currentQueryInfo+" :=" + currentQuery);
                throw CreateUPAException(ee, "ExecuteUpdateFailedException", query);
            } finally {
                if (/*IsLoggable=*/ true)
                {
                    if (error != null)
                    {
                        log.TraceEvent(System.Diagnostics.TraceEventType.Error, 100, Net.Vpc.Upa.Impl.FwkConvertUtils.LogMessageExceptionFormatter(nameDebugString + " [Error] executeNonQuery " + query + " :: parameters = " + queryParameters, error));
                    }
                    else
                    {
                        log.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 60, Net.Vpc.Upa.Impl.FwkConvertUtils.LogMessageExceptionFormatter("{0} executeNonQuery {1}" + ((queryParameters != null && !(queryParameters.Count == 0)) ? "\n\tqueryParameters={2}" : "") + " ;; time = {3}", null, new object[] { nameDebugString, query, queryParameters, (System.DateTime.Now.Ticks - startTime) }));
                    }
                }
            }
            //            Log.log(PersistenceUnitManager.DB_NATIVE_UPDATE_LOG,"[TIME="+Log.DELTA_FORMAT.format(endTime-startTime)+" ; COUNT="+count+"] "+debug+" :=" + currentQuery);
            return(count);
        }
Esempio n. 2
0
 public override void Write(object @object, int i, System.Data.IDataReader updatableResultSet) /* throws System.Exception */
 {
     targetMarshaller.Write(dataTypeTransform.TransformValue(@object), i, updatableResultSet);
 }
Esempio n. 3
0
        public virtual Net.Vpc.Upa.Persistence.QueryResult ExecuteQuery(string query, Net.Vpc.Upa.Types.DataTypeTransform[] types, System.Collections.Generic.IList <Net.Vpc.Upa.Persistence.Parameter> queryParameters, bool updatable) /* throws Net.Vpc.Upa.Exceptions.UPAException */
        {
            if (closed)
            {
                throw new System.ArgumentException("Connection closed");
            }
            long startTime = System.DateTime.Now.Ticks;

            System.Exception error = null;
            try {
                try {
                    System.Data.IDbCommand s = null;
                    s             = connection.CreateCommand();
                    s.CommandText = query;
                    s.CommandType = System.Data.CommandType.Text;
                    int mi    = 0;
                    int index = 1;
                    if (queryParameters != null)
                    {
                        foreach (Net.Vpc.Upa.Persistence.Parameter @value in queryParameters)
                        {
                            Net.Vpc.Upa.Types.DataTypeTransform         transform  = @value.GetTypeTransform();
                            Net.Vpc.Upa.Impl.Persistence.TypeMarshaller marshaller = marshallManager.GetTypeMarshaller(transform);
                            marshaller.Write(@value.GetValue(), index, s);
                            index += marshaller.GetSize();
                            mi++;
                        }
                    }
                    System.Data.IDataReader resultSet = s.ExecuteReader();
                    if (types == null)
                    {
                        int           columnCount;
                        System.Type[] colTypes;
                        columnCount = resultSet.FieldCount;
                        colTypes    = new System.Type[columnCount];
                        for (int i = 0; i < columnCount; i++)
                        {
                            colTypes[i] = resultSet.GetFieldType(i);
                        }
                        types = new Net.Vpc.Upa.Types.DataTypeTransform[columnCount];
                        for (int i = 0; i < types.Length; i++)
                        {
                            types[i] = new Net.Vpc.Upa.Impl.Transform.IdentityDataTypeTransform(Net.Vpc.Upa.Types.TypesFactory.ForPlatformType(colTypes[i]));
                        }
                    }
                    Net.Vpc.Upa.Impl.Persistence.TypeMarshaller[] marshallers = new Net.Vpc.Upa.Impl.Persistence.TypeMarshaller[types.Length];
                    for (int i = 0; i < marshallers.Length; i++)
                    {
                        marshallers[i] = marshallManager.GetTypeMarshaller(types[i]);
                    }
                    //        Log.log(PersistenceUnitManager.DB_PRE_NATIVE_QUERY_LOG,"[BEFORE] "+currentQueryInfo+" :=" + currentQuery);
                    return(new Net.Vpc.Upa.Impl.Persistence.DefaultQueryResult(resultSet, s, marshallers, types));
                } catch (System.Exception ee) {
                    error = ee;
                    throw ee;
                } finally {
                    if (/*IsLoggable=*/ true)
                    {
                        if (error != null)
                        {
                            log.TraceEvent(System.Diagnostics.TraceEventType.Error, 100, Net.Vpc.Upa.Impl.FwkConvertUtils.LogMessageExceptionFormatter(nameDebugString + " [Error] executeQuery " + query + " :: parameters = " + queryParameters, error));
                        }
                        else
                        {
                            log.TraceEvent(System.Diagnostics.TraceEventType.Verbose, 60, Net.Vpc.Upa.Impl.FwkConvertUtils.LogMessageExceptionFormatter("{0}   executeQuery    {1} ;; parameters = {2} ;; time = {3}", null, new object[] { nameDebugString, query, queryParameters, (System.DateTime.Now.Ticks - startTime) }));
                        }
                    }
                }
            } catch (System.Exception ex) {
                throw CreateUPAException(ex, "ExecuteQueryFailedException", query);
            }
        }