//If DB is down, throw an exception at this point. .Net Connector will then abort //the tRFC and the R/3 backend will try again later. public bool CheckTransactionID(RfcServerContextInfo serverContext, RfcTID tid) { if (string.IsNullOrEmpty(serverContext.TransactionID.TID.ToString())) { EventLog.WriteEntry( "Clarks SAP Adapter", string.Format("serverContext.TransactionID.TID in CheckTransactionID is null"), EventLogEntryType.Error); } if (tid == null) { EventLog.WriteEntry( "Clarks SAP Adapter", string.Format("tid.TID in CheckTransactionID is null"), EventLogEntryType.Error); } if (tid.TID == null) { EventLog.WriteEntry( "Clarks SAP Adapter", string.Format("tid.TID in CheckTransactionID is null"), EventLogEntryType.Error); } if (tid.TID != null) { if (string.IsNullOrEmpty(tid.TID.ToString())) { EventLog.WriteEntry( "Clarks SAP Adapter", string.Format("tid.TID.ToString in CheckTransactionID is null or Empty"), EventLogEntryType.Error); } else { EventLog.WriteEntry( "Clarks SAP Adapter", string.Format("Clarks SAP Adapter TID set to:{0} in CheckTransactionID callback", tid.TID.ToString()), EventLogEntryType.Information); } } // Notify any registered client with sessionId if (IDocSessionStart != null) { SAPSessionEventArgs sapSessionEvents = new SAPSessionEventArgs(); sapSessionEvents.SessionId = serverContext.SessionID; IDocSessionStart(sapSessionEvents); } System.Diagnostics.Trace.WriteLine(string.Format("Rfc Function Activated with SessionId:{0}", serverContext.SessionID)); lock (tids) { if (tids.Contains(tid.TID)) { return(false); } else { tids.Add(tid.TID); return(true); } } // "true" means that NCo will now execute the transaction, "false" means // that we have already executed this transaction previously, so NCo will // skip the function execution step and will immediately return an OK code to R/3. }
// call back to capture the session Id public void OnRfcSessionStart(SAPSessionEventArgs sessionArgs) { this._sessionId = sessionArgs.SessionId; }