public void CreateOfflineSymbolTable(List <string> sobjectList) { var nameSpace = ConnectionUtil.GetSession().VsProjectName + ".SObjects"; Parallel.ForEach(sobjectList, (sobject) => { HttpManager httpManager = new HttpManager(); var objectDetailjson = httpManager.Get($"sobjects/{sobject}/describe"); SObjectDetail sObjectDetail = JsonConvert.DeserializeObject <SObjectDetail>(objectDetailjson); objectDetailjson = JsonConvert.SerializeObject(sObjectDetail, Formatting.Indented); var cacheLocation = Path.Combine(ConnectionUtil.GetSession().VsProjectLocation, "Cache"); var jsonFileName = cacheLocation + "/" + sobject + ".json"; File.WriteAllText(jsonFileName, objectDetailjson); var sObjectClass = CreateSalesForceClasses(nameSpace, sObjectDetail); var sobjectLocation = Path.Combine(ConnectionUtil.GetSession().VsProjectLocation, "SObjects"); var saveFileName = sobjectLocation + "\\" + sobject + ".cs"; File.WriteAllText(saveFileName, sObjectClass); Log.ForContext <ModelGen>().Debug("Saved {sobject}", saveFileName); }); }
public string Del(string uriFunction) { HttpRequestMessage request = new HttpRequestMessage { RequestUri = new Uri(ConnectionUtil.GetSession().RestUrl + "/data/v" + ConnectionUtil.GetSession().SalesForceApiVersion + ".0/" + uriFunction), Method = HttpMethod.Delete, }; return(Http(request)); }
public string Patch(string uriFunction, string json) { HttpRequestMessage request = new HttpRequestMessage { RequestUri = new Uri(ConnectionUtil.GetSession().RestUrl + "/data/v" + ConnectionUtil.GetSession().SalesForceApiVersion + ".0/" + uriFunction), Method = new HttpMethod("PATCH"), Content = new StringContent(json, Encoding.UTF8, "application/json"), }; return(Http(request)); }
private string Http(HttpRequestMessage request) { request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); request.Headers.Add("Authorization", ConnectionUtil.GetSession().RestSessionId); //WebProxy proxy = new WebProxy { Address = new Uri("http://naproxy.gm.com:80") }; //HttpClientHandler httpClientHandler = new HttpClientHandler() //{ // Proxy = proxy, // PreAuthenticate = true, // UseDefaultCredentials = false, //}; //HttpClient httpClient = new HttpClient(httpClientHandler); HttpClient httpClient = new HttpClient(); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; Log.ForContext <HttpManager>().Verbose("Outgoing Request {@request}", request); HttpResponseMessage responseMessage = httpClient.SendAsync(request).Result; Log.ForContext <HttpManager>().Verbose("Incoming Response {@responseMessage}", responseMessage); string jsonData = responseMessage.Content.ReadAsStringAsync().Result; Log.ForContext <HttpManager>().Verbose("Incoming Data {@jsonData}", jsonData); switch (responseMessage.StatusCode) { case HttpStatusCode.NoContent: case HttpStatusCode.Created: case HttpStatusCode.OK: return(jsonData); default: var exp = new ApexSharpHttpException(Environment.StackTrace); Log.ForContext <HttpManager>().Error(exp, jsonData); throw exp; } }
public List <string> GetAllObjectNames() { List <string> objectList = new List <string>(); HttpManager httpManager = new HttpManager(); var requestJson = httpManager.Get($"sobjects/"); var cacheLocation = Path.Combine(ConnectionUtil.GetSession().VsProjectLocation, "Cache"); File.WriteAllText(cacheLocation + "/objectList.json", requestJson); var json = File.ReadAllText(cacheLocation + "/objectList.json"); SObjectDescribe sObjectList = JsonConvert.DeserializeObject <SObjectDescribe>(json); foreach (var sobject in sObjectList.sobjects) { objectList.Add(sobject.name); } return(objectList); }
public List <Sobject> GetAllObjects() { string dirPath = ConnectionUtil.GetSession().VsProjectLocation; HttpManager httpManager = new HttpManager(); var requestJson = httpManager.Get($"sobjects/"); File.WriteAllText(dirPath + @"\objectList.json", requestJson); var json = File.ReadAllText(dirPath + @"\objectList.json"); SObjectDescribe sObjectList = JsonConvert.DeserializeObject <SObjectDescribe>(json); return(sObjectList.sobjects.ToList()); //var customObjectCount = allSobjects.Where(x => x.custom).ToList(); //var customSetting = allSobjects.Where(x => x.customSetting).ToList(); //var objectCount = allSobjects.Where(x => x.custom == false && x.customSetting == false).ToList(); //System.Console.WriteLine(customObjectCount.Count()); //System.Console.WriteLine(customSetting.Count()); //System.Console.WriteLine(objectCount.Count()); }
public static ApexSharpConfig GetSession() { return(ConnectionUtil.GetSession(null)); }
public static ApexSharpConfig GetSession(string configFileLocation) { return(ConnectionUtil.GetSession(configFileLocation)); }
public BulkApi() { _connectionDetail = ConnectionUtil.GetSession(); }