コード例 #1
0
 /// <summary>
 /// Logs the Message
 /// </summary>
 /// <param name="type">Log Type</param>
 /// <param name="message">Message to be logged</param>
 /// <param name="args">Values to be substituted in the message</param>
 public void LogMessage(LogType type, string message, params object[] args)
 {
     if (this.TracingService != null)
     {
         Logger.Log(type, ExtensionBase.ConcatenatedString(message, args), this.TracingService);
     }
 }
コード例 #2
0
        /// <summary>
        /// Retrieves the first or default entity
        /// </summary>
        /// <param name="service">Organization Service</param>
        /// <param name="entityName">Name of the entity that has to be retrieved</param>
        /// <param name="columns">Array of column names </param>
        /// <param name="conditions">Filter condition</param>
        /// <param name="orders">Order condition</param>
        /// <returns>Retrieved entity</returns>
        public static Entity RetrieveFirstOrDefaultEntity(IOrganizationService service, string entityName, string[] columns, FilterExpression conditions, Collection <OrderExpression> orders)
        {
            ExtensionBase.IsObjectNotNull(service, new ArgumentNullException("service", "The service parameter passed to RetrieveFirstOrDefaultEntity cannot be null"));

            QueryExpression query = new QueryExpression();

            query.ColumnSet           = new ColumnSet(columns);
            query.PageInfo            = new PagingInfo();
            query.PageInfo.PageNumber = 1;
            query.PageInfo.Count      = 1;
            query.EntityName          = entityName;
            if (conditions != null)
            {
                query.Criteria = conditions;
            }

            SetOrderConditions(query, orders);

            EntityCollection entities = service.RetrieveMultiple(query);

            if (entities != null &&
                entities.Entities != null &&
                entities.Entities.Count > 0)
            {
                return(entities.Entities[0]);
            }

            return(null);
        }
コード例 #3
0
        /// <summary>
        /// Retrieves all the records from RetrieveMultiple
        /// </summary>
        /// <param name="service">Organization Service</param>
        /// <param name="entityName">Name of the entity that has to be retrieved</param>
        /// <param name="columns">Array of column names </param>
        /// <param name="conditions">Filter condition</param>
        /// <param name="orders">Order condition</param>
        /// <returns>Retrieved entity</returns>
        public static EntityCollection IterativeRetrieveMultiple(IOrganizationService service, string entityName, string[] columns, FilterExpression conditions, Collection <OrderExpression> orders)
        {
            ExtensionBase.IsObjectNotNull(service, new ArgumentNullException("service", "The service parameter passed to RetrieveFirstOrDefaultEntity cannot be null"));

            QueryExpression query = new QueryExpression();

            query.ColumnSet  = new ColumnSet(columns);
            query.EntityName = entityName;
            if (conditions != null)
            {
                query.Criteria = conditions;
            }

            SetOrderConditions(query, orders);

            query.PageInfo            = new PagingInfo();
            query.PageInfo.Count      = 5000;
            query.PageInfo.PageNumber = 1;

            EntityCollection results = new EntityCollection();

            EntityCollection eachBatchResults = new EntityCollection();

            while (true)
            {
                eachBatchResults = service.RetrieveMultiple(query);

                if (eachBatchResults.HasRecords())
                {
                    results.Entities.AddRange(eachBatchResults.Entities.ToArray());
                }

                if (eachBatchResults.MoreRecords)
                {
                    // Increment the page number to retrieve the next page.
                    query.PageInfo.PageNumber++;

                    // Set the paging cookie to the paging cookie returned from current results.
                    query.PageInfo.PagingCookie = eachBatchResults.PagingCookie;
                }
                else
                {
                    // If no more records are in the result nodes, exit the loop.
                    break;
                }
            }

            return(results);
        }
コード例 #4
0
 /// <summary>
 /// Throws an Argument Out of Range Exception
 /// </summary>
 /// <param name="parameterName">Parameter Name</param>
 /// <param name="message">Message to be included in the exception</param>
 /// <param name="args">Values to be substituted in the message</param>
 /// <returns>Argument Out of Range Exception</returns>
 public ArgumentOutOfRangeException ArgumentOutOfRangeException(string parameterName, string message, params object[] args)
 {
     return(new ArgumentOutOfRangeException(parameterName, ExtensionBase.ConcatenatedString(message, args)));
 }
コード例 #5
0
 /// <summary>
 /// Throws an Invalid Plugin Exception
 /// </summary>
 /// <param name="message">Message to be included in the exception</param>
 /// <param name="args">Values to be substituted in the message</param>
 /// <returns>Invalid Plugin Exception</returns>
 public InvalidPluginExecutionException InvalidPluginExecutionException(string message, params object[] args)
 {
     return(new InvalidPluginExecutionException(ExtensionBase.ConcatenatedString(message, args)));
 }