Exemplo n.º 1
0
        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);
            });
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        // Double Check For All These Values
        public ApexSharpConfig CreateSession()
        {
            FileInfo      configLocation  = new FileInfo(_apexSharpConfigSettings.ConfigLocation);
            DirectoryInfo configDirectory = configLocation.Directory;

            DirectoryInfo vsProjectLocation = new DirectoryInfo(_apexSharpConfigSettings.VsProjectLocation);

            DirectoryInfo salesForceLocation = new DirectoryInfo(_apexSharpConfigSettings.SalesForceLocation);

            Directory.CreateDirectory(_apexSharpConfigSettings.VsProjectLocation + "CSharpClasses");
            Directory.CreateDirectory(_apexSharpConfigSettings.VsProjectLocation + "NoApex");
            Directory.CreateDirectory(_apexSharpConfigSettings.VsProjectLocation + "Cache");
            Directory.CreateDirectory(_apexSharpConfigSettings.VsProjectLocation + "SObjects");

            return(ConnectionUtil.CreateSession(_apexSharpConfigSettings));
        }
Exemplo n.º 5
0
        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;
            }
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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());
        }
Exemplo n.º 8
0
        // ToDo: Double Check For All These Values
        public void CreateSession()
        {
            FileInfo configLocation = new FileInfo(_apexSharpConfigSettings.ConfigLocation);

            Log.ForContext <ApexSharp>().Debug(configLocation.FullName);

            DirectoryInfo vsProjectLocation = new DirectoryInfo(_apexSharpConfigSettings.VsProjectLocation);

            Log.ForContext <ApexSharp>().Debug(vsProjectLocation.FullName);

            DirectoryInfo salesForceLocation = new DirectoryInfo(_apexSharpConfigSettings.SalesForceLocation);

            Log.ForContext <ApexSharp>().Debug(salesForceLocation.FullName);

            // ToDo: Only Create If we do not have it
            Directory.CreateDirectory(_apexSharpConfigSettings.VsProjectLocation + "CSharpClasses");
            Directory.CreateDirectory(_apexSharpConfigSettings.VsProjectLocation + "NoApex");
            Directory.CreateDirectory(_apexSharpConfigSettings.VsProjectLocation + "Cache");
            Directory.CreateDirectory(_apexSharpConfigSettings.VsProjectLocation + "SObjects");

            ConnectionUtil.CreateSession(_apexSharpConfigSettings);
        }
Exemplo n.º 9
0
 public static ApexSharpConfig GetSession()
 {
     return(ConnectionUtil.GetSession(null));
 }
Exemplo n.º 10
0
 public static ApexSharpConfig GetSession(string configFileLocation)
 {
     return(ConnectionUtil.GetSession(configFileLocation));
 }
Exemplo n.º 11
0
 public BulkApi()
 {
     _connectionDetail = ConnectionUtil.GetSession();
 }