Exemple #1
0
        public static List <CrmName> GetViewsName(string link, string username, string password)
        {
            List <CrmName> viewList = new List <CrmName>();

            IOrganizationService service = TryConnection(link, username, password);

            if (service == null)
            {
                return(null);
            }
            else
            {
                QueryExpression personalViews = new QueryExpression("savedquery");
                personalViews.ColumnSet = new ColumnSet("name");

                EntityCollection viewCollection = new EntityCollection();

                try
                {
                    viewCollection = service.RetrieveMultiple(personalViews);
                }
                catch
                {
                    throw new InvalidOperationException("Connection has failed!");
                }

                foreach (var c in viewCollection.Entities)
                {
                    CrmName crmName = new CrmName
                    {
                        displayName = c["name"].ToString(),
                        logicalName = c["name"].ToString()
                    };
                    viewList.Add(crmName);
                }

                var sortedList = viewList.OrderBy(x => x.displayName).ToList();
                return(sortedList);
            }
        }
Exemple #2
0
        public static List <CrmName> GetTableColumns(string link, string username, string password, string table)
        {
            List <CrmName> columns = new List <CrmName>();

            IOrganizationService service = TryConnection(link, username, password);

            if (service == null)
            {
                throw new InvalidOperationException("Connection has failed!");
            }
            else
            {
                RetrieveEntityRequest  metaDataRequest  = new RetrieveEntityRequest();
                RetrieveEntityResponse metaDataResponse = new RetrieveEntityResponse();
                metaDataRequest.EntityFilters = EntityFilters.Attributes;
                metaDataRequest.LogicalName   = table.ToLower();
                metaDataResponse = (RetrieveEntityResponse)service.Execute(metaDataRequest);

                var entities = metaDataResponse.EntityMetadata;

                foreach (var c in entities.Attributes)
                {
                    if (c.DisplayName.LocalizedLabels.Count() > 1)
                    {
                        CrmName crmName = new CrmName
                        {
                            displayName = c.DisplayName.UserLocalizedLabel.Label,
                            logicalName = c.LogicalName
                        };
                        columns.Add(crmName);
                    }
                }
            }

            var sortedList = columns.OrderBy(x => x.displayName).ToList();

            return(sortedList);
        }
Exemple #3
0
        public static List <CrmName> GetTablesName(string link, string username, string password)
        {
            List <CrmName> tableList = new List <CrmName>();

            IOrganizationService service = TryConnection(link, username, password);

            if (service == null)
            {
                return(null);
            }
            else
            {
                RetrieveAllEntitiesRequest  metaDataRequest  = new RetrieveAllEntitiesRequest();
                RetrieveAllEntitiesResponse metaDataResponse = new RetrieveAllEntitiesResponse();
                metaDataRequest.EntityFilters = EntityFilters.Entity;
                metaDataResponse = (RetrieveAllEntitiesResponse)service.Execute(metaDataRequest);

                var entities = metaDataResponse.EntityMetadata;

                foreach (var c in entities)
                {
                    if (c.DisplayName.LocalizedLabels.Count() > 1)
                    {
                        CrmName crmName = new CrmName
                        {
                            displayName = c.DisplayName.UserLocalizedLabel.Label,
                            logicalName = c.LogicalName
                        };
                        tableList.Add(crmName);
                    }
                }

                var sortedList = tableList.OrderBy(x => x.displayName).ToList();
                return(sortedList);
            }
        }