//INITIALIZE public ReaderProcessBase() { apiData = new ApiData(); connectionData = new ConnectionData(); enableZippedTransactions = false; errorOnReturnCode8 = false; executionsAttempted = 0; maximumRecordsToReturn = 0; maximumTimeToWaitBetweenRetries = 30000; maximumWaitTime = 30000; minimumTimeToWaitBetweenRetries = 5000; random = new Random(); requestFieldDataList = new List <RequestFieldData>(); executionsToAttempt = 3; returnCode = null; serverId = default(SERVER_ID); }
//INITIALIZE public WriterProcess() { apiData = new ApiData(); connectionData = new ConnectionData(); maximumWaitTime = 30000; _InputFieldDataList = new List <RequestFieldData>(); _OutputFieldData = new List <OutputFieldData>(); returnCode = null; serverId = default(SERVER_ID); }
//METHODS public void SetFields(ref SERVER_ID _ServerId) { FieldDescription = DataConverter.ToString(MvxSock.GetField(ref _ServerId, "FLDS")); FieldName = DataConverter.ToString(MvxSock.GetField(ref _ServerId, "FLNM")); FieldType = DataConverter.ToString(MvxSock.GetField(ref _ServerId, "TYPE")); InputOutput = DataConverter.ToString(MvxSock.GetField(ref _ServerId, "TRTP")); Length = DataConverter.ToString(MvxSock.GetField(ref _ServerId, "LENG")); ProgramName = DataConverter.ToString(MvxSock.GetField(ref _ServerId, "MINM")); TransactionName = DataConverter.ToString(MvxSock.GetField(ref _ServerId, "TRNM")); }
//METHODS public virtual Boolean ExecuteProcess() { try { if (ApiData == null) { throw new InvalidOperationException("'ApiData' cannot be null."); } if (ApiData.Api == null) { throw new InvalidOperationException("'ApiData.Api' cannot be null"); } if (ConnectionData == null) { throw new InvalidOperationException("'ConnectionData' cannot be null."); } if (ConnectionData.Password == null) { throw new InvalidOperationException("'ConnectionData.Password' cannot be null."); } if (ConnectionData.Port == 0) { throw new InvalidOperationException("'ConnectionData.Port' cannot be 0."); } if (ConnectionData.Server == null) { throw new InvalidOperationException("'ConnectionData.Server' cannot be null."); } if (ConnectionData.UserName == null) { throw new InvalidOperationException("'ConnectionData.UserName' cannot be null."); } if (InputFieldDataList == null) { throw new InvalidOperationException("RequestFieldDataList cannot be null."); } if (InputFieldDataList.Count == 0) { throw new InvalidOperationException("RequestFieldDataList.Count cannot be 0."); } serverId = new SERVER_ID(); if (!ConnectToServer()) { CloseServerConnection(); return(false); } if (!SetMaximumWaitTime()) { CloseServerConnection(); return(false); } if (!SetRequestFields()) { CloseServerConnection(); return(false); } if (!ExecuteApi()) { CloseServerConnection(); return(false); } if (!GetOutputFieldData()) { CloseServerConnection(); return(false); } CloseServerConnection(); return(true); } catch (Exception exception) { Trace.WriteLine(exception.ToString()); } TraceUtilities.WriteMethodError(MethodBase.GetCurrentMethod()); return(false); }
public override string ToString() { return(SERVER_ID.ToString() + "[" + SERVER_NAME + "]"); }
//METHODS public virtual Boolean ExecuteProcess() { try { Boolean returnState = false; while ((ExecutionsAttempted <= ExecutionsToAttempt) && (!returnState)) { if (ExecutionsAttempted > 1) { System.Threading.Thread.Sleep(random.Next((Int32)MinimumTimeToWaitBetweenRetries, (Int32)MaximumTimeToWaitBetweenRetries)); Trace.WriteLine(String.Format("Attempting to retry the API call. Execution Attempt:{0}", ExecutionsAttempted)); } if (ApiData == null) { throw new InvalidOperationException("ApiData can not be null."); } if (ConnectionData == null) { throw new InvalidOperationException("ConnectionData can not be null."); } if (RequestFieldDataList == null) { throw new InvalidOperationException("RequestFieldDataList can not be null."); } if (!ValidateInputs()) { return(false); } returnCode = null; serverId = new SERVER_ID(); ExecutionsAttempted++; if (!ConnectToServer()) { CloseServerConnection(); continue; } if (EnableZippedTransactions) { if (!SetEnableZippedTransactions()) { CloseServerConnection(); continue; } } if (!SetMaximumRecordsForApiToReturn()) { CloseServerConnection(); continue; } if (!SetMaximumWaitTime()) { CloseServerConnection(); continue; } if (!SetRequestFields()) { CloseServerConnection(); continue; } if (!ExecuteApi()) { CloseServerConnection(); continue; } if (ReturnCode.Value == 0) { if (!ProcessApiResults()) { CloseServerConnection(); continue; } } CloseServerConnection(); returnState = true; } return(returnState); } catch (Exception exception) { Trace.WriteLine(exception.ToString()); } TraceUtilities.WriteMethodError(MethodBase.GetCurrentMethod()); return(false); }