Ejemplo n.º 1
0
        private static List <T> GetRestAPIJSON <T>(string strRestAPIClientID, string restAPIClientType, string PrivateKey, string Token, string SecureURL, string RecordsGetLimit, long RecordsOffset, string StartDate = "", int LastInvoiceNum = 0)
        {
            RestAPIActions restAPIClientWM = GetRestAPIClient(PrivateKey, Token, SecureURL);

            string   restAPIClientStream = string.Empty;
            List <T> reclist             = new List <T>();

            restAPIClientWM.Type = restAPIClientType;

            int parsedValue;

            if (strRestAPIClientID.Length != 0 && int.TryParse(strRestAPIClientID, out parsedValue))
            {
                restAPIClientWM.ID = Convert.ToInt32(strRestAPIClientID);
            }

            int parsedRecordsGetLimitValue;

            if (RecordsGetLimit.Length != 0 && int.TryParse(RecordsGetLimit, out parsedRecordsGetLimitValue))
            {
                restAPIClientWM.RecordsGetLimit = Convert.ToInt32(RecordsGetLimit);
            }
            restAPIClientWM.RecordsOffset = RecordsOffset;

            // commected by Sam as date based search is not working
            //if (StartDate != string.Empty)
            //    restAPIClientWM.datestart = StartDate;

            if (LastInvoiceNum != 0)
            {
                restAPIClientWM.invoicenumberstart = LastInvoiceNum;
            }

            RecordInfo recInf = restAPIClientWM.GetRecords <T>();



            if (recInf.Status == ActionStatus.Succeeded)
            {
                try
                {
                    reclist             = (List <T>)recInf.ResultSet;
                    restAPIClientStream = Newtonsoft.Json.JsonConvert.SerializeObject(reclist);
                }
                catch (Exception ex)
                {
                }
            }

            return(reclist);
        }
Ejemplo n.º 2
0
        private static string GetRestAPIJSON(string strRestAPIClientID, string restAPIClientType, string PrivateKey, string Token, string SecureURL, string RecordsGetLimit)
        {
            RestAPIActions restAPIClientWM = GetRestAPIClient(PrivateKey, Token, SecureURL);


            string restAPIClientStream = string.Empty;

            restAPIClientWM.Type = restAPIClientType;

            int parsedValue;

            if (strRestAPIClientID.Length != 0 && int.TryParse(strRestAPIClientID, out parsedValue))
            {
                restAPIClientWM.ID = Convert.ToInt32(strRestAPIClientID);
            }

            int parsedRecordsGetLimitValue;

            if (RecordsGetLimit.Length != 0 && int.TryParse(RecordsGetLimit, out parsedRecordsGetLimitValue))
            {
                restAPIClientWM.RecordsGetLimit = Convert.ToInt32(RecordsGetLimit);
            }

            RecordInfo recInf = restAPIClientWM.GetRecords();



            if (recInf.Status == ActionStatus.Succeeded)
            {
                try
                {
                    List <Object> reclist = (List <Object>)recInf.ResultSet;
                    restAPIClientStream = Newtonsoft.Json.JsonConvert.SerializeObject(reclist);
                }
                catch (Exception ex)
                {
                }
            }

            return(restAPIClientStream);
        }