public static DataTable QueryInvoices(CustomProcessingSoapClient customSdk, Datalayer.Xero.Interresolve.AquariumCustomProcessing.SessionDetails sessionDetails, AquariumInvoiceTypeToQuery theInvoiceType)
        {
            DataTable TableToReturn = new DataTable();
            string ProcName = "";

            switch(theInvoiceType)
            {
                case AquariumInvoiceTypeToQuery.InboundInvoice:
                    ProcName = System.Configuration.ConfigurationManager.AppSettings["_C74_Xero_GetInboundInvoiceData"].ToString();
                    break;

                case AquariumInvoiceTypeToQuery.OutboundInvoice:
                    ProcName = System.Configuration.ConfigurationManager.AppSettings["_C74_Xero_GetInvoiceData"].ToString();
                    break;

            }

            string[] ProcParm = null;

            ReportResult result = new ReportResult();

            result = customSdk.RunCustomProc(sessionDetails, ProcName, ProcParm);

            if (result.ResultInfo.ReturnCode == Datalayer.Xero.Interresolve.AquariumCustomProcessing.BasicCode.OK)
            {
                TableToReturn = SDKGeckoboardHelper.GetDataTableFromSdkResult(result.Data.Columns, result.Data.Rows);
                return TableToReturn;
            }

            else
            {
                Exception ex = new Exception("There has been a problem in the QueryInvoices method in the invoice helper class");
                throw ex;
            }
        }
        public void GetProviderInvoiceNumbersTest()
        {
            setupDBTests();

            login.LoginToAquarium();

            customSession = login.SetUpCustomSessionForSDKAction();

            CustomProcessingSoapClient customSdk = new CustomProcessingSoapClient();

            ReportResult theResults = customSdk.RunCustomProc(customSession, "_C74_Xero_GetInboundInvoice_ProvidersInvoiceNumberAndLeadID", new string[0]);

            int Count = Convert.ToInt32(theResults.Data.Rows.Count());

            Assert.Greater(Count, 1);
        }
        /// <summary>
        /// Get All Work TimeShifts
        /// </summary>
        /// <returns>List of TimeShifts</returns>
        public List<TimeShift> GetAllTimeshiftValues()
        {
            List<TimeShift> TempList = new List<TimeShift>();

            string ProcName = System.Configuration.ConfigurationManager.AppSettings["GetAllTimeshiftsSPName"].ToString();
            string[] ProcParm = null;
            ReportResult result = new ReportResult();
            CustomProcessingSoapClient Customsdk = new CustomProcessingSoapClient();

            AquariumCustomProcessing.SessionDetails sd = SDKHelper.GetSessionDetails<AquariumCustomProcessing.SessionDetails>("User");
            result = Customsdk.RunCustomProc(sd, ProcName, ProcParm);

            if (result.ResultInfo.ReturnCode == AquariumCustomProcessing.BasicCode.OK)
            {
                TempList = ToList(result.Data);
            }
            else if (result.ResultInfo.ReturnCode == AquariumCustomProcessing.BasicCode.Failed)
            {
                throw new System.ApplicationException("Error ID:" + result.ResultInfo.Errors[0].ResultCodeID + ", Description:" + result.ResultInfo.Errors[0].Description);
            }

            return TempList;
        }
        /// <summary>
        /// Get Case Details from DB by CustomerID
        /// </summary>
        /// <param name="ID">CustomerID</param>
        public void GetCaseDetails(int ID)
        {
            string ProcName = System.Configuration.ConfigurationManager.AppSettings["GetCaseDetails"].ToString();
            string[] ProcParm = new string[] { ID.ToString() };
            ReportResult result = new ReportResult();

            CustomProcessingSoapClient sdk = new CustomProcessingSoapClient();

            AquariumCustomProcessing.SessionDetails sd = SDKHelper.GetSessionDetails<AquariumCustomProcessing.SessionDetails>("User");

            result = sdk.RunCustomProc(sd, ProcName, ProcParm);

            if (result.ResultInfo.ReturnCode == AquariumCustomProcessing.BasicCode.OK)
            {
                ToObject(result.Data);
            }
            else if (result.ResultInfo.ReturnCode == AquariumCustomProcessing.BasicCode.Failed)
            {
                throw new System.ApplicationException("Error ID:" + result.ResultInfo.Errors[0].ResultCodeID + ", Description:" + result.ResultInfo.Errors[0].Description);
            }
        }
        /// <summary>
        /// calls the stored proc to put this invoice into aquarium 
        /// </summary>
        /// <returns></returns>
        public bool ApplyInvoiceToAquarium()
        {
            try
            {

                //  bool result = false;
                //gets specified invoices -- everything in this case

                AquariumLogin login = new AquariumLogin();
                login.LoginToAquarium();

                LoggedOnUserResult theUserResult = login.GetLoggedOnUserResult();

                Datalayer.Xero.Interresolve.AquariumUserManagement.SessionDetails sessionDetails = new Datalayer.Xero.Interresolve.AquariumUserManagement.SessionDetails(); //set this from the logon
                //set the USER sesson
                sessionDetails.SessionKey = theUserResult.SessionKey;
                sessionDetails.Username = theUserResult.Username;
                sessionDetails.ThirdPartySystemId = 29;

                //map a custom session
                Datalayer.Xero.Interresolve.AquariumCustomProcessing.SessionDetails customSessionDetails = new Datalayer.Xero.Interresolve.AquariumCustomProcessing.SessionDetails();
                customSessionDetails.SessionKey = sessionDetails.SessionKey;
                customSessionDetails.ThirdPartySystemId = 29;
                customSessionDetails.Username = theUserResult.Username;

                CustomProcessingSoapClient customSdk = new CustomProcessingSoapClient();

                //now put this invoice's fields into the proc and push the proc to Aquarium
                string ProcName = System.Configuration.ConfigurationManager.AppSettings["_C74_Insert_Inbound_Invoice_Table_Record"].ToString();

                string[] ProcParm = new string[21];

                //map the elements of this invoice to the string array

                ProcParm[0] = this.LeadID.ToString();
                ProcParm[1] = this.MatterID.ToString();
                ProcParm[2] = this.LeadTypeID.ToString();
                ProcParm[3] = this.InvoiceDate.ToString();
                ProcParm[4] = this.InvoiceType.ToString();
                ProcParm[5] = this.ProvidersInvoiceNumber.ToString();

                ProcParm[6] = this.LineItem1Desc.ToString();
                ProcParm[7] = this.LineItem1Qty.ToString();
                ProcParm[8] = this.LineItem1Cost.ToString();

                ProcParm[9] = this.LineItem2Desc.ToString();
                ProcParm[10] = this.LineItem2Qty.ToString();
                ProcParm[11] = this.LineItem2Cost.ToString();

                ProcParm[12] = this.LineItem3Desc.ToString();
                ProcParm[13] = this.LineItem3Qty.ToString();
                ProcParm[14] = this.LineItem3Cost.ToString();

                ProcParm[15] = this.LineItem4Desc.ToString();
                ProcParm[16] = this.LineItem4Qty.ToString();
                ProcParm[17] = this.LineItem4Cost.ToString();

                ProcParm[18] = this.InvoiceVATAmount.ToString();
                ProcParm[19] = this.InvoiceSubtotal.ToString();
                ProcParm[20] = this.InvoiceTotalCost.ToString();

                //  DataTable InvoiceResults = new DataTable();
                //  InvoiceResults = InvoiceHelper.QueryInvoices(customSdk, customSessionDetails, InvoiceHelper.AquariumInvoiceTypeToQuery.OutboundInvoice);
                ReportResult result = new ReportResult();

                result = customSdk.RunCustomProc(customSessionDetails, ProcName, ProcParm);

                //has it worked?
                if (result.ResultInfo.ReturnCode == AquariumCustomProcessing.BasicCode.OK)
                {

                    //it's worked
                }
                else
                {
                    //it ain't
                }

            }
            catch (Exception ex)
            { throw ex; }

            return true;
        }