Esempio 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);
            });
        }
Esempio n. 2
0
        public static SalesForceApiLimits GetApiLimits()
        {
            HttpManager         httpManager = new HttpManager();
            var                 json        = httpManager.Get(@"limits/");
            SalesForceApiLimits apiLimits   = JsonConvert.DeserializeObject <SalesForceApiLimits>(json,
                                                                                                  new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });

            return(apiLimits);
        }
Esempio n. 3
0
        private static SObjectDetail LoadSObjectImpl(string sobject)
        {
            var httpManager      = new HttpManager();
            var objectDetailjson = httpManager.Get($"sobjects/{sobject}/describe");

            var sObjectDetail = JsonConvert.DeserializeObject <SObjectDetail>(objectDetailjson);

            objectDetailjson = JsonConvert.SerializeObject(sObjectDetail, Formatting.Indented);
            var jsonFileName  = sobject + ".json";
            var cacheLocation = Path.Combine(ApexSharp.GetSession().VsProjectLocation, "Cache", jsonFileName);

            File.WriteAllText(cacheLocation, objectDetailjson);
            return(sObjectDetail);
        }
Esempio n. 4
0
        public List <Sobject> GetAllObjects()
        {
            string objectListPath = Path.Combine(ApexSharp.GetSession().VsProjectLocation, "objectList.json");

            HttpManager httpManager = new HttpManager();
            var         requestJson = httpManager.Get("sobjects/");

            File.WriteAllText(objectListPath, requestJson);

            var             json        = File.ReadAllText(objectListPath);
            SObjectDescribe sObjectList = JsonConvert.DeserializeObject <SObjectDescribe>(json);

            return(sObjectList.sobjects.ToList());
        }
Esempio n. 5
0
        private static List <T> PerformQuery <T>(string query)
        {
            Log.ForContext <SoqlApi>().Debug("SOQL Query {query}", query);

            HttpManager httpManager = new HttpManager();
            var         json        = httpManager.Get($"query/?q={query}");

            RecordReadList <T> returnData = JsonConvert.DeserializeObject <RecordReadList <T> >(json,
                                                                                                new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });

            return(returnData.records);
        }
Esempio n. 6
0
        public IEnumerable <string> GetAllObjectNames()
        {
            var objectList = new List <string>();

            var httpManager = new HttpManager();
            var requestJson = httpManager.Get("sobjects/");

            var cacheLocation = Path.Combine(ApexSharp.GetSession().VsProjectLocation, "Cache", "objectList.json");

            File.WriteAllText(cacheLocation, requestJson);
            var json = File.ReadAllText(cacheLocation);

            var sObjectList = JsonConvert.DeserializeObject <SObjectDescribe>(json);

            foreach (var sobject in sObjectList.sobjects)
            {
                objectList.Add(sobject.name);
            }

            return(objectList);
        }
Esempio n. 7
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);
        }
Esempio n. 8
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());
        }