public String Pedidos_CQ_Instant() { SessionClass session = new SessionClass(); session.UserLogon("admin", "admin", "PRESU", 2, "BPD_DESA"); OAdQuerydef queryDef = (OAdQuerydef)session.BuildQuery("Pedido_Pago"); queryDef.BuildField("id"); queryDef.BuildField("Importe_Total"); OAdResultset resultset = (OAdResultset)session.BuildResultSet(queryDef); resultset.Execute(); var Status = resultset.MoveNext(); String data = ""; while (Convert.ToInt32(Status) == 1) { data = (String)resultset.GetColumnValue(2); Status = resultset.MoveNext(); } return(data); }
public ArrayList Pedidos_CQ() { SessionClass session = new SessionClass(); session.UserLogon("admin", "admin", "PRESU", 2, "BPD_DESA"); OAdQuerydef queryDef = (OAdQuerydef)session.BuildQuery("Pedido_Pago"); queryDef.BuildField("id"); queryDef.BuildField("Importe_Total"); OAdResultset resultset = (OAdResultset)session.BuildResultSet(queryDef); ArrayList PedidosdePagos = new ArrayList(); resultset.Execute(); var Status = resultset.MoveNext(); while (Convert.ToInt32(Status) == 1) { Pedido_Pago data = new Pedido_Pago(); data.id_pedido = (String)resultset.GetColumnValue(1); data.importe_total = (String)resultset.GetColumnValue(2); PedidosdePagos.Add(data); Status = resultset.MoveNext(); } return(PedidosdePagos); }
internal static void ExecuteResultSet(OAdResultset resultSet) { try { resultSet.Execute(); } catch (COMException ex) { InteropErrorHandler.HandleCQException(ex); } }
internal static void EnableRecordCount(OAdResultset resultSet) { try { resultSet.EnableRecordCount(); } catch (COMException ex) { InteropErrorHandler.HandleCQException(ex); } }
internal static OAdResultset BuildResultSet(Session cqSession, OAdQuerydef qryDef) { OAdResultset resultSet = null; try { resultSet = (OAdResultset)cqSession.BuildResultSet(qryDef); } catch (COMException ex) { InteropErrorHandler.HandleCQException(ex); } return(resultSet); }
internal static object GetColumnValue(OAdResultset resultSet, int index) { object retval = null; try { retval = resultSet.GetColumnValue(index); } catch (COMException ex) { InteropErrorHandler.HandleCQException(ex); } return(retval); }
internal static string GetColumnLabel(OAdResultset resultSet, int index) { string retval = null; try { retval = resultSet.GetColumnLabel(index); } catch (COMException ex) { InteropErrorHandler.HandleCQException(ex); } return(retval); }
internal static int GetRecordCount(OAdResultset resultSet) { int retval = 0; try { retval = resultSet.RecordCount; } catch (COMException ex) { InteropErrorHandler.HandleCQException(ex); } return(retval); }
internal static int GetResultSetColumnCount(OAdResultset resultSet) { int retval = 0; try { retval = resultSet.GetNumberOfColumns(); } catch (COMException ex) { InteropErrorHandler.HandleCQException(ex); } return(retval); }
internal static int ResultSetMoveNext(OAdResultset resultSet) { int retval = 0; try { retval = resultSet.MoveNext(); } catch (COMException ex) { InteropErrorHandler.HandleCQException(ex); } return(retval); }
internal static OAdResultset BuildResultSet(Session cqSession, string sqlQry) { OAdResultset resultSet = null; try { resultSet = (OAdResultset)cqSession.BuildSQLQuery(sqlQry); } catch (COMException ex) { InteropErrorHandler.HandleCQException(ex); } return(resultSet); }
protected virtual void Query() { TraceManager.TraceInformation("CQ Query: {0}", m_queryStr); // prepare result set OAdResultset result = CQWrapper.BuildResultSet(m_userSession, m_queryStr); // enable record count before execute so that no of records can be fetched CQWrapper.EnableRecordCount(result); // execute the query CQWrapper.ExecuteResultSet(result); // lookup for dbid column bool dbidExist = false; int dbidColumnIndex = 0; int columnCount = CQWrapper.GetResultSetColumnCount(result); for (int colIter = 1; colIter <= columnCount; colIter++) { if (string.Equals(CQWrapper.GetColumnLabel(result, colIter), "dbid", StringComparison.OrdinalIgnoreCase)) { dbidExist = true; dbidColumnIndex = colIter; break; } } Debug.Assert(dbidExist, "dbid does not exist in resultset"); int recordCount = CQWrapper.GetRecordCount(result); TraceManager.TraceInformation("CQ Query: returned {0} record(s)", recordCount); // cache dbids m_resultSetDbIds = new int[recordCount]; int index = 0; while (CQWrapper.ResultSetMoveNext(result) == CQConstants.SUCCESS) { string dbid = (string)CQWrapper.GetColumnValue(result, dbidColumnIndex); m_resultSetDbIds[index++] = int.Parse(dbid); Trace.TraceInformation("DEBUG: dbid : {0}", int.Parse(dbid)); } MakeSureDBIDsAreUnique(); Trace.TraceInformation("Total number of records after removing the duplicate dbids: {0}", m_resultSetDbIds.Length); }
} // end of ValidateFieldMapOnCQ /// <summary> /// Execute the Query and migrate the data /// </summary> /// <param name="baseEntityName">Base Entity Name</param> private void MigrateData(string baseEntityName, string baseEntityWitName) { Session cqSession = m_cqConnection.GetUserSession(); OAdQuerydef qryDef = m_cqConnection.QueryDefinition; // edit the query and add dbid field // dbid is suppose to be unique within a Entity CQWrapper.BuildField(qryDef, "dbid"); // prepare result set OAdResultset result = CQWrapper.BuildResultSet(cqSession, qryDef); // process records for base entity CQEntity baseEntityRecords = m_cqParams.entityRecords[baseEntityName]; // enable record count before execute so that no of records can be fetched CQWrapper.EnableRecordCount(result); // execute the query CQWrapper.ExecuteResultSet(result); int columnCount = CQWrapper.GetResultSetColumnCount(result); // lookup for dbid column bool dbidExist = false; int dbidColumnIndex = 0; for (int colIter = 1; colIter <= columnCount; colIter++) { if (string.Equals(CQWrapper.GetColumnLabel(result, colIter), "dbid", StringComparison.OrdinalIgnoreCase)) { dbidExist = true; dbidColumnIndex = colIter; break; } } if (!dbidExist) { // neither query contain dbid nor can be edited to include a new column string errMsg = UtilityMethods.Format(CQResource.CQ_NO_DBID_IN_QUERY, m_cqConnection.QueryName, m_convParams.ConfigFile); PostMigrationReport.WriteIssue(null, null, RepStatus.Failed, ReportIssueType.Critical, String.Empty, baseEntityName, IssueGroup.Config, errMsg); Logger.Write(LogSource.CQ, TraceLevel.Error, errMsg); throw new ConverterException(errMsg); } // start the progress thread for updating the progress m_progressThread = new Thread(new ThreadStart(CQConverter.UpdateProgress)); m_progressThread.Name = "Progress"; try { // get the work item helper handle TotalRecords = CQWrapper.GetRecordCount(result); m_progressThread.Start(); while (CQWrapper.ResultSetMoveNext(result) == CQConstants.SUCCESS) { string dbid = (string)CQWrapper.GetColumnValue(result, dbidColumnIndex); // create a CQEntity for that CQEntityRec record = new CQEntityRec(int.Parse(dbid), baseEntityName, m_cqParams); try { // populate and migrate the record and all referenced records RecordsProcessed++; baseEntityRecords.AddRecord(record); if (record.Populate() == false && m_cqParams.exitOnError == true) { return; // stop processing more records } } catch (ConverterException conEx) { // log the error and continue with next item string errMsg = UtilityMethods.Format(CQResource.CQ_WI_READ_FAILED, dbid, conEx.Message); ReportWorkItemFailure(errMsg, dbid, baseEntityName, baseEntityWitName, m_cqParams.exitOnError); if (m_cqParams.exitOnError == true) { // throw the error back .. should not continue with the current record throw; } } } } finally { // terminate the progress thread m_progressThread.Abort(); Thread.Sleep(5000); // allow the display thread to stop } } // end of MigrateData