예제 #1
0
        protected virtual Boolean SetMaximumRecordsForApiToReturn()
        {
            try
            {
                StringBuilder stringBuilder = new StringBuilder();

                UInt32 size = 128;

                ReturnCode = MvxSock.Trans(ref serverId, String.Format("SetLstMaxRec   {0}", MaximumRecordsToReturn.ToString()), stringBuilder, ref size);

                if (ReturnCode.Value == 0)
                {
                    return(true);
                }
                else
                {
                    Trace.WriteLine(String.Format("The 'MvxSock.Trans' method retured non zero code:{0}.", ReturnCode));

                    String errorText = GetErrorText();

                    Trace.WriteLineIf((errorText != null), errorText);
                }
            }
            catch (Exception exception)
            { Trace.WriteLine(exception); }

            TraceUtilities.WriteMethodError(MethodBase.GetCurrentMethod());

            return(false);
        }
예제 #2
0
        protected virtual Boolean SetMaximumWaitTime()
        {
            try
            {
                ReturnCode = MvxSock.SetMaxWait(ref serverId, MaximumWaitTime);

                if (ReturnCode.Value == 0)
                {
                    return(true);
                }
                else
                {
                    Trace.WriteLine(String.Format("The 'MvxSock.SetMaxWait' method retured the following non zero code.  {0}", ReturnCode));
                }
            }
            catch (Exception exception)
            { Trace.WriteLine(exception.ToString()); }

            String errorText = GetErrorText();

            Trace.WriteLineIf((errorText != null), errorText);

            TraceUtilities.WriteMethodError(MethodBase.GetCurrentMethod());

            return(false);
        }
예제 #3
0
        protected virtual Boolean ConnectToServer()
        {
            try
            {
                ReturnCode = MvxSock.Connect(ref serverId, ConnectionData.Server, ConnectionData.Port, ConnectionData.UserName, ConnectionData.Password, ApiData.Api, null);

                if (ReturnCode.Value == 0)
                {
                    return(true);
                }
                else
                {
                    Trace.WriteLine(String.Format("The 'MvxSock.Connect' method retured the following non zero code.  {0}", ReturnCode));
                }
            }
            catch (Exception exception)
            { Trace.WriteLine(exception.ToString()); }

            String errorText = GetErrorText();

            Trace.WriteLineIf((errorText != null), errorText);

            TraceUtilities.WriteMethodError(MethodBase.GetCurrentMethod());

            return(false);
        }
예제 #4
0
        protected virtual Boolean SetEnableZippedTransactions()
        {
            try
            {
                ReturnCode = MvxSock.SetZippedTransactions(ref serverId, 1);

                if (ReturnCode.Value == 0)
                {
                    return(true);
                }
                else
                {
                    Trace.WriteLine(String.Format("The 'MvxSock.SetZippedTransactions' method retured non zero code:{0}.", ReturnCode));

                    String errorText = GetErrorText();

                    Trace.WriteLineIf((errorText != null), errorText);
                }
            }
            catch (Exception exception)
            { Trace.WriteLine(exception); }

            TraceUtilities.WriteMethodError(MethodBase.GetCurrentMethod());

            return(false);
        }
예제 #5
0
        protected virtual bool ProcessApiResult()
        {
            try
            {
                T_DataObject dataObject = CreateDataObject();

                AddDataObjectToDataObjectCollection(dataObject);

                return(true);
            }
            catch (Exception exception)
            { Trace.WriteLine(exception); }

            TraceUtilities.WriteMethodError(MethodBase.GetCurrentMethod());

            return(false);
        }
예제 #6
0
        protected virtual Boolean SetRequestField(RequestFieldData requestFieldData)
        {
            try
            {
                ReturnCode = null;

                MvxSock.SetField(ref serverId, requestFieldData.FieldName, requestFieldData.FieldValue);

                return(true);
            }
            catch (Exception exception)
            { Trace.WriteLine(exception.ToString()); }

            TraceUtilities.WriteMethodError(MethodBase.GetCurrentMethod());

            return(false);
        }
예제 #7
0
        protected virtual String GetErrorText()
        {
            String errorText;

            try
            {
                errorText = MvxSock.GetLastError(ref serverId).Trim();

                return(errorText.Length == 0 ? null : errorText);
            }
            catch (Exception exception)
            { Trace.WriteLine(exception.ToString()); }

            TraceUtilities.WriteMethodError(MethodBase.GetCurrentMethod());

            return(null);
        }
예제 #8
0
        protected virtual Boolean ExecuteApi()
        {
            try
            {
                ReturnCode = MvxSock.Access(ref serverId, ApiData.Method);

                return(EvaluateMvxSockAccessReturnCode());
            }
            catch (Exception exception)
            { Trace.WriteLine(exception.ToString()); }

            TraceUtilities.WriteMethodError(MethodBase.GetCurrentMethod());

            ReturnCode = null;

            return(false);
        }
예제 #9
0
        protected virtual Boolean SetRequestFields()
        {
            try
            {
                foreach (RequestFieldData requestField in InputFieldDataList)
                {
                    if (!SetRequestField(requestField))
                    {
                        return(false);
                    }
                }

                return(true);
            }
            catch (Exception exception)
            { Trace.WriteLine(exception.ToString()); }

            TraceUtilities.WriteMethodError(MethodBase.GetCurrentMethod());

            return(false);
        }
예제 #10
0
        protected virtual Boolean GetOutputFieldData()
        {
            try
            {
                foreach (OutputFieldData _OutputFieldData in OutputFieldData)
                {
                    _OutputFieldData.Value = GetValueFromField(_OutputFieldData.FieldName);
                }

                return(true);
            }
            catch (Exception exception)
            { Trace.WriteLine(exception.ToString()); }

            String errorText = GetErrorText();

            Trace.WriteLineIf((errorText != null), errorText);

            TraceUtilities.WriteMethodError(MethodBase.GetCurrentMethod());

            return(false);
        }
예제 #11
0
        protected virtual Boolean ExecuteApi()
        {
            try
            {
                ReturnCode = MvxSock.Access(ref serverId, ApiData.Method);

                if (ReturnCode.Value == 0)
                {
                    return(true);
                }
                else
                {
                    Trace.WriteLine(String.Format("The 'MvxSock.Access' method retured the following non zero code.  {0}", ReturnCode));
                }
            }
            catch (Exception exception)
            { Trace.WriteLine(exception.ToString()); }

            TraceUtilities.WriteMethodError(MethodBase.GetCurrentMethod());

            return(false);
        }
예제 #12
0
        protected override bool ProcessApiResults()
        {
            DataObjectCollection = new T_DataObjectCollection();

            try
            {
                while (MvxSock.More(ref serverId))
                {
                    if (!ProcessApiResult())
                    {
                        return(false);
                    }

                    ReturnCode = MvxSock.Access(ref serverId, null);

                    if (ReturnCode.Value != 0)
                    {
                        Trace.WriteLine(String.Format("The 'MvxSock.Access' method retured the following non zero code.  {0}", ReturnCode));

                        String errorText = GetErrorText();

                        Trace.WriteLineIf((errorText != null), errorText);

                        return(false);
                    }
                }

                return(true);
            }
            catch (Exception exception)
            { Trace.WriteLine(exception); }

            TraceUtilities.WriteMethodError(MethodBase.GetCurrentMethod());

            return(false);
        }
예제 #13
0
        //FUNCTIONS
        protected virtual Boolean CloseServerConnection()
        {
            try
            {
                ReturnCode = MvxSock.Close(ref serverId);

                if (ReturnCode.Value == 0)
                {
                    return(true);
                }
                else
                {
                    Trace.WriteLine(String.Format("The 'MvxSock.Close' method retured non zero code:{0}", ReturnCode));
                }
            }
            catch (Exception exception)
            { Trace.WriteLine(exception.ToString()); }

            TraceUtilities.WriteMethodError(MethodBase.GetCurrentMethod());

            ReturnCode = null;

            return(false);
        }
예제 #14
0
        //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);
        }
예제 #15
0
        //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);
        }