public static string Create (this SalesforceClient self, SObject sobject)
		{
			var createRequest = new CreateRequest (sobject);
			var result = self.ProcessAsync (createRequest);
			if (!result.Wait (TimeSpan.FromSeconds (SalesforceClient.DefaultNetworkTimeout)))
				return null;

			if (result.IsFaulted)
				return null; // TODO: Do error reporting

			var json = result.Result.GetResponseText ();
			var jsonValue = JsonValue.Parse (json);
			if (jsonValue == null)
				return null;
			sobject.Id = jsonValue["id"];
			return sobject.Id;
		}
		public static async Task<string> CreateAsync (this SalesforceClient self, SObject sobject)
		{
			var createRequest = new CreateRequest (sobject);
			Response result;
			try {
				result = await self.ProcessAsync (createRequest).ConfigureAwait (true);
			} catch (AggregateException ex) {
				Debug.WriteLine (ex.Message);
				return null;
			}
			var json = result.GetResponseText ();
			var jsonValue = JsonValue.Parse (json);
			if (jsonValue == null)
				return null;
			sobject.Id = jsonValue["id"];
			return sobject.Id;
		}
Exemplo n.º 3
0
        public static async Task <string> CreateAsync(this SalesforceClient self, SObject sobject)
        {
            var      createRequest = new CreateRequest(sobject);
            Response result;

            try {
                result = await self.ProcessAsync(createRequest).ConfigureAwait(true);
            } catch (AggregateException ex) {
                Debug.WriteLine(ex.Message);
                return(null);
            }
            var json      = result.GetResponseText();
            var jsonValue = JsonValue.Parse(json);

            if (jsonValue == null)
            {
                return(null);
            }
            sobject.Id = jsonValue["id"];
            return(sobject.Id);
        }
Exemplo n.º 4
0
        public static string Create(this SalesforceClient self, SObject sobject)
        {
            var createRequest = new CreateRequest(sobject);
            var result        = self.ProcessAsync(createRequest);

            if (!result.Wait(TimeSpan.FromSeconds(SalesforceClient.DefaultNetworkTimeout)))
            {
                return(null);
            }

            if (result.IsFaulted)
            {
                return(null);                // TODO: Do error reporting
            }
            var json      = result.Result.GetResponseText();
            var jsonValue = JsonValue.Parse(json);

            if (jsonValue == null)
            {
                return(null);
            }
            sobject.Id = jsonValue["id"];
            return(sobject.Id);
        }