private void QueryTransactionsDetail()
        {
            //https://my.ipcommerce.com/Docs/DataServices/TMS_Developer_Guide/2.0.17/Implementation/SOAP/QueryTransactionsDetail.aspx

            bool BlnIncludeRelated = chkIncludeRelated.Checked;

            try
            {
                ((SampleCode_DeskTop)(Owner)).Helper.CheckTokenExpire();//Make sure the current token is valid
                txtTMSResults.Text = "";

                Cursor = Cursors.WaitCursor;

                TransactionDetailFormat TDF = new TransactionDetailFormat();
                ProcessQueryTransactionsDetailResponse(((SampleCode_DeskTop)(Owner)).Helper.Tmsoc.QueryTransactionsDetail(((SampleCode_DeskTop)(Owner)).Helper.SessionToken, QTP(), TDF, BlnIncludeRelated, PP()));;

                if (txtTMSResults.Text.Length < 1)
                {
                    txtTMSResults.Text = "No Query Transaction Detail Results : " + DateTime.Now;
                }
                Cursor = Cursors.Default;
            }
            catch (EndpointNotFoundException)
            {
                //In this case the SvcEndpoint was not available. Try the same logic again with the alternate Endpoint
                try
                {
                    ((SampleCode_DeskTop)(Owner)).Helper.SetTMSEndpoint();//Change the endpoint to use the backup.

                    TransactionDetailFormat TDF = new TransactionDetailFormat();
                    ProcessQueryTransactionsDetailResponse(((SampleCode_DeskTop)(Owner)).Helper.Tmsoc.QueryTransactionsDetail(((SampleCode_DeskTop)(Owner)).Helper.SessionToken, QTP(), TDF, BlnIncludeRelated, PP()));
                }
                catch (EndpointNotFoundException)
                {
                    MessageBox.Show(
                        "Neither the primary or secondary TMS endpoints are available. Unable to process.");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to Query Transaction Families\r\nError Message : " + ex.Message, "Query Transaction Families Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                string strErrorId;
                string strErrorMessage;
                if (_FaultHandler.handleTMSFault(ex, out strErrorId, out strErrorMessage))
                {
                    MessageBox.Show(strErrorId + " : " + strErrorMessage);
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
        private void QueryTransactionsDetail()
        {
            //https://my.ipcommerce.com/Docs/DataServices/TMS_Developer_Guide/2.0.17/Implementation/SOAP/QueryTransactionsDetail.aspx

            bool BlnIncludeRelated = chkIncludeRelated.Checked;
            try
            {
                ((SampleCode_DeskTop)(Owner)).Helper.CheckTokenExpire();//Make sure the current token is valid
                txtTMSResults.Text = "";

                Cursor = Cursors.WaitCursor;

                TransactionDetailFormat TDF = new TransactionDetailFormat();
                ProcessQueryTransactionsDetailResponse(((SampleCode_DeskTop)(Owner)).Helper.Tmsoc.QueryTransactionsDetail(((SampleCode_DeskTop)(Owner)).Helper.SessionToken, QTP(), TDF, BlnIncludeRelated, PP())); ;

                if (txtTMSResults.Text.Length < 1)
                    txtTMSResults.Text = "No Query Transaction Detail Results : " + DateTime.Now;
                Cursor = Cursors.Default;
            }
            catch (EndpointNotFoundException)
            {
                //In this case the SvcEndpoint was not available. Try the same logic again with the alternate Endpoint
                try
                {
                    ((SampleCode_DeskTop)(Owner)).Helper.SetTMSEndpoint();//Change the endpoint to use the backup.

                    TransactionDetailFormat TDF = new TransactionDetailFormat();
                    ProcessQueryTransactionsDetailResponse(((SampleCode_DeskTop)(Owner)).Helper.Tmsoc.QueryTransactionsDetail(((SampleCode_DeskTop)(Owner)).Helper.SessionToken, QTP(), TDF, BlnIncludeRelated, PP()));
                }
                catch (EndpointNotFoundException)
                {
                    MessageBox.Show(
                        "Neither the primary or secondary TMS endpoints are available. Unable to process.");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Unable to Query Transaction Families\r\nError Message : " + ex.Message, "Query Transaction Families Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                string strErrorId;
                string strErrorMessage;
                if (_FaultHandler.handleTMSFault(ex, out strErrorId, out strErrorMessage))
                    MessageBox.Show(strErrorId + " : " + strErrorMessage);
                else
                    MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
        public List<TransactionDetail> QueryTransactionsDetail(string sessionToken, QueryTransactionsParameters queryTransactionsParameters, TransactionDetailFormat transactionDetailFormat,PagingParameters pagingParameters, Boolean includeRelated)
        {
            if (_msgFormat == MessageFormat.SOAP.ToString())
            {
                using (var client = new TMSOperationsClient(ConfigurationManager.AppSettings["Bindings.MgmtSoap"]))
                {
                    try
                    {
                        return client.QueryTransactionsDetail(sessionToken, queryTransactionsParameters, transactionDetailFormat, includeRelated, pagingParameters).ToList();
                    }
                    catch (FaultException ex)
                    {
                        SoapFaultHandler.HandleFaultException(ex);
                    }
                }
            }
            else // REST JSON or XML
            {
                var isJson = string.Equals(_msgFormat, MessageFormat.JSON.ToString());
                var requestString = RestBaseUri + "/transactionsDetail";
                var restQtd = new QueryTransactionsDetail();
                restQtd.IncludeRelated = includeRelated;
                restQtd.TransactionDetailFormat = (schemas.ipcommerce.com.CWS.v2._0.DataServices.TMS.TransactionDetailFormat)(transactionDetailFormat);

                // Convert the namespace from service reference to the generated proxies used by rest.
                restQtd.QueryTransactionsParameters = Utilities.SwapObjectsNamespace<schemas.ipcommerce.com.CWS.v2._0.DataServices.TMS.QueryTransactionsParameters>(queryTransactionsParameters);
                restQtd.PagingParameters = Utilities.SwapObjectsNamespace<schemas.ipcommerce.com.CWS.v2._0.DataServices.PagingParameters>(pagingParameters);

                var request = RestHelper.CreateRestRequest<QueryTransactionsDetail>(restQtd, requestString, HttpMethod.POST, sessionToken, isJson);
                try
                {
                    var responseStr = RestHelper.GetResponse(request, isJson, false);
                    if (isJson)
                    {
                        var list = RestHelper.GetCWSObjectListFromJson<schemas.ipcommerce.com.CWS.v2._0.DataServices.TMS.TransactionDetail>(responseStr);
                        return list.Select(transactionDetail => Utilities.SwapObjectsNamespace<TMS.TransactionDetail>(transactionDetail)).ToList();
                    }
                    else
                    {
                        return RestHelper.GetCWSObjectListFromXml<TMS.TransactionDetail>(responseStr);
                    }
                }
                catch (Exception ex)
                {
                    RestFaultHandler.HandleFaultException(ex, isJson);
                }
            }
            return null;
        }