예제 #1
0
        /// <summary>
        /// Set the underlying salesforce object.
        /// </summary>
        /// <param name="action">The underlying salesforce object to set.</param>
        internal void Update(SalesForceAPI.Tooling.ApexExecutionOverlayAction action)
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            _action = action;
        }
예제 #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="action">The action to build this object from.</param>
        /// <param name="fileName">The name of the file that the checkpoint is in.</param>
        internal Checkpoint(SalesForceAPI.Tooling.ApexExecutionOverlayAction action, string fileName)
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            _action  = action;
            FileName = fileName;
        }
예제 #3
0
        /// <summary>
        /// Create a new checkpoint.
        /// </summary>
        /// <param name="entityId">The id of the file to create a checkpoint in.</param>
        /// <param name="fileName">The name of the file to create a checkpoint in.</param>
        /// <param name="lineNumber">The line number in the file to create the checkpoint for.</param>
        /// <param name="iteration">The number of iterations before the checkpoint is processed.</param>
        /// <param name="isHeapDump">If true a heap dump will be collected with the checkpoint.</param>
        /// <param name="script">An optional script to run with the checkpoint.</param>
        /// <param name="scriptType">The type of script specified.</param>
        /// <returns>The newly created checkpoint.</returns>
        private Checkpoint CreateCheckpoint(
            string entityId,
            string fileName,
            int lineNumber,
            int iteration,
            bool isHeapDump,
            string script,
            CheckpointScriptType scriptType)
        {
            if (entityId == null)
            {
                throw new ArgumentNullException("entityId");
            }

            SalesForceAPI.Tooling.ApexExecutionOverlayAction action = new SalesForceAPI.Tooling.ApexExecutionOverlayAction();
            action.ActionScript            = script;
            action.ActionScriptType        = scriptType.ToString();
            action.ExecutableEntityId      = entityId;
            action.ExpirationDate          = DateTime.Now.AddDays(1);
            action.ExpirationDateSpecified = true;
            action.IsDumpingHeap           = isHeapDump;
            action.IsDumpingHeapSpecified  = true;
            action.Iteration          = iteration;
            action.IterationSpecified = true;
            action.Line          = lineNumber;
            action.LineSpecified = true;
            action.ScopeId       = _client.User.Id;

            SalesForceAPI.Tooling.createResponse response = _client.ToolingClient.create(new SalesForceAPI.Tooling.createRequest(
                                                                                             new SalesForceAPI.Tooling.SessionHeader()
            {
                sessionId = _client.SessionId
            },
                                                                                             new SalesForceAPI.Tooling.sObject[]
            {
                action
            }));

            if (response != null && response.result != null && response.result.Length == 1)
            {
                if (!response.result[0].success)
                {
                    StringBuilder sb = new StringBuilder();
                    if (response.result[0].errors != null)
                    {
                        foreach (SalesForceAPI.Tooling.Error err in response.result[0].errors)
                        {
                            sb.AppendLine(err.message);
                        }
                    }

                    throw new Exception("Couldn't create checkpoint: \r\n" + sb.ToString());
                }
            }
            else
            {
                throw new Exception("Couldn't create checkpoint: Invalid response received.");
            }

            action.Id = response.result[0].id;

            return(new Checkpoint(action, fileName));
        }