Пример #1
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (value != default(Dynamics365Solution))
            {
                Dynamics365Solution solution = (Dynamics365Solution)value;
                return(string.Format("{0} ({1})", solution.FriendlyName, solution.UniqueName));
            }

            return(null);
        }
        public List <Dynamics365Solution> GetSolutions()
        {
            List <Dynamics365Solution> solutions = new List <Dynamics365Solution>();

            try
            {
                solutions.AddRange(Dynamics365Solution.GetSolutions(Connection));
            }
            catch
            { }

            return(solutions);
        }
Пример #3
0
        /// <summary>
        /// </summary>
        /// <param name="connection"></param>
        /// <returns></returns>
        public static List <Dynamics365Solution> GetSolutions(Dynamics365Connection connection)
        {
            ConnectionCache            cache     = new ConnectionCache(connection);
            string                     cacheKey  = "GetSolutions:{0}";
            List <Dynamics365Solution> solutions = (List <Dynamics365Solution>)cache[cacheKey];

            if (solutions == default(List <Dynamics365Solution>))
            {
                // get a list of all solutions in the specified Dynamics 365 instance.
                solutions = new List <Dynamics365Solution>();

                using (OrganizationServiceProxy proxy = connection.OrganizationServiceProxy)
                {
                    QueryExpression query = new QueryExpression()
                    {
                        EntityName = "solution",
                        ColumnSet  = new ColumnSet(true),
                        Criteria   = new FilterExpression()
                    };

                    EntityCollection response = proxy.RetrieveMultiple(query);

                    foreach (Entity entity in response.Entities)
                    {
                        Dynamics365Solution solution = new Dynamics365Solution()
                        {
                            UniqueName   = entity.Attributes["uniquename"].ToString(),
                            FriendlyName = entity.Attributes["friendlyname"].ToString(),
                            Version      = entity.Attributes["version"].ToString()
                        };

                        solutions.Add(solution);
                    }

                    solutions.Sort((solution1, solution2) => solution1.FriendlyName.CompareTo(solution2.FriendlyName));
                }

                cache[cacheKey] = solutions;
            }

            return(solutions);
        }