internal ServiceBatchResponse Batch(BatchRequestItem[] batchItems)
        {
            bool mustRetry  = false;    // used to determine if we should retry a failed job
            int  retryTimes = 0;        // we don't want to endlessly retry, so we only will retry 3 times

            do
            {
                try
                {
                    BatchResponseItem[] batchReponseItems = _client.Batch(_clientInfoHeader, batchItems);

                    return(new ServiceBatchResponse()
                    {
                        BatchResponseItems = batchReponseItems,
                        Successful = true
                    });
                }
                catch (Exception ex)
                {
                    GlobalContext.Log(string.Format("Failed Batch: Retry {0}: {1}", retryTimes, ex.Message), true);
                    GlobalContext.Log(string.Format("Failed Batch: Retry {0}: {1}{2}{3}", retryTimes, ex.Message, Environment.NewLine, ex.StackTrace), false);

                    if (retryTimes < 3)
                    {
                        // if we haven't retried 3 times then we retry the load again
                        mustRetry = true;
                        retryTimes++;
                    }
                    else
                    {
                        // don't retry for 3rd retry
                        return(new ServiceBatchResponse()
                        {
                            SuccessfulSet = true,
                            Successful = false,
                            Details = ex.ToString()
                        });
                    }
                }
                GlobalContext.Log(string.Format("Batch Must Retry {0}", mustRetry), false);
            } while (mustRetry);
            GlobalContext.Log("Batch End: This code should never be hit.", false);
            return(null);        // this code should never be hit
        }
        /// <summary>
        /// Perform Batch operation
        /// </summary>
        /// <param name="msg">BatchRequestItem Item</param>
        public bool callBatchJob(Object msg)
        {
            try
            {
                /*** Form BatchRequestItem structure ********************/

                BatchRequestItem[] requestItems = new BatchRequestItem[1];

                BatchRequestItem requestItem = new BatchRequestItem();

                requestItem.Item = msg;

                requestItems[0]                      = requestItem;
                requestItems[0].CommitAfter          = true;
                requestItems[0].CommitAfterSpecified = true;
                /*********************************************************/

                ClientInfoHeader clientInfoHeader = new ClientInfoHeader();
                clientInfoHeader.AppID = "Batcher";

                BatchResponseItem[] batchRes = _rightNowClient.Batch(clientInfoHeader, requestItems);
                //If response type is RequestErrorFaultType then show the error msg
                if (batchRes[0].Item.GetType().Name == "RequestErrorFaultType")
                {
                    RequestErrorFaultType requestErrorFault = (RequestErrorFaultType)batchRes[0].Item;
                    MessageBox.Show("There is an error with batch job :: " + requestErrorFault.exceptionMessage);
                    return(false);
                }
            }
            catch (FaultException ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// Perform Batch operation
        /// </summary>
        /// <param name="msg">BatchRequestItem Item</param>
        public void callBatchJob(Object msg)
        {
            try
            {
                /*** Form BatchRequestItem structure ********************/

                BatchRequestItem[] requestItems = new BatchRequestItem[1];

                BatchRequestItem requestItem = new BatchRequestItem();
                requestItem.Item = msg;

                requestItems[0]                      = requestItem;
                requestItems[0].CommitAfter          = true;
                requestItems[0].CommitAfterSpecified = true;
                /*********************************************************/

                ClientInfoHeader clientInfoHeader = new ClientInfoHeader();
                clientInfoHeader.AppID = "Batcher";

                BatchResponseItem[] batchRes = _rightNowClient.Batch(clientInfoHeader, requestItems);

                if (batchRes[0].Item.GetType().Name == "RequestErrorFaultType")
                {
                    RequestErrorFaultType requestErrorFault = (RequestErrorFaultType)batchRes[0].Item;
                    WorkspaceAddIn.InfoLog("There is an error with batch job :: " + requestErrorFault.exceptionMessage);
                }
            }
            catch (FaultException ex)
            {
                WorkspaceAddIn.InfoLog(ex.Message);
                return;
            }
            catch (Exception ex)
            {
                WorkspaceAddIn.InfoLog(ex.Message);
                return;
            }
        }