Пример #1
0
        /// <summary>
        /// Deletes any entity records that were created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user
        /// to delete the records created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            bool toBeDeleted = true;

            if (prompt)
            {
                // Ask the user if the created entities should be deleted.
                Console.Write("\nDo you want these entity records deleted? (y/n) [y]: ");
                String answer = Console.ReadLine();
                if (answer.StartsWith("y") ||
                    answer.StartsWith("Y") ||
                    answer == String.Empty)
                {
                    toBeDeleted = true;
                }
                else
                {
                    toBeDeleted = false;
                }
            }

            if (toBeDeleted)
            {
                // Delete all records created in this sample.
                service.Delete(Template.EntityLogicalName, _templateId);
                service.Delete(Account.EntityLogicalName, _accountId);;

                Console.WriteLine("Entity record(s) have been deleted.");
            }
        }
Пример #2
0
        /// <summary>
        /// Deletes any entity records that were created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user to delete the records created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            bool deleteRecords = true;

            if (prompt)
            {
                Console.WriteLine("\nDo you want these entity records deleted? (y/n)");
                String answer = Console.ReadLine();

                deleteRecords = (answer.StartsWith("y") || answer.StartsWith("Y"));
            }

            if (deleteRecords)
            {
                Console.WriteLine("Delting entity records... please wait!");

                // Remove 10 test child accounts.
                int deleteCount = 0;
                while (deleteCount < 10)
                {
                    service.Delete(Account.EntityLogicalName, childAccountIds[deleteCount]);
                    ++deleteCount;
                }

                // Remove the test parent account.
                service.Delete(Account.EntityLogicalName, parentAccountId);

                Console.WriteLine("Entity records have been deleted.");
            }
        }
Пример #3
0
        /// <summary>
        /// Deletes the custom entity record that was created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user
        /// to delete the entity created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            bool deleteRecords = true;

            if (prompt)
            {
                Console.WriteLine("\nDo you want these entity records deleted? (y/n)");
                String answer = Console.ReadLine();

                deleteRecords = (answer.StartsWith("y") || answer.StartsWith("Y"));
            }

            if (deleteRecords)
            {
                // Delete records created in this sample.  Delete the sales order first
                // or there will be an error due to restrict delete.
                if (_salesOrderId.HasValue)
                {
                    Console.WriteLine(String.Concat("Deleting sales order: ", _salesOrderId.Value));
                    service.Delete(SalesOrder.EntityLogicalName, _salesOrderId.Value);
                }
                if (_accountId.HasValue)
                {
                    Console.WriteLine(String.Concat("Deleting account: ", _accountId.Value));
                    service.Delete(Account.EntityLogicalName, _accountId.Value);
                }

                Console.WriteLine("Entity records have been deleted.");
            }
        }
        /// <summary>
        /// Deletes the custom entity record that was created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user
        /// to delete the entity created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            bool deleteRecords = true;

            if (prompt)
            {
                Console.WriteLine("\nDo you want these entity records deleted? (y/n)");
                String answer = Console.ReadLine();

                deleteRecords = (answer.StartsWith("y") || answer.StartsWith("Y"));
            }

            if (deleteRecords)
            {
                SetStateRequest setStateRequest = new SetStateRequest()
                {
                    EntityMoniker =
                        new EntityReference(Workflow.EntityLogicalName, _workflowId),
                    State  = new OptionSetValue((int)WorkflowState.Draft),
                    Status = new OptionSetValue(1)
                };
                service.Execute(setStateRequest);

                service.Delete(Workflow.EntityLogicalName, _workflowId);
                service.Delete(Lead.EntityLogicalName, _leadId);
                service.Delete(AsyncOperation.EntityLogicalName, _asyncOperationId);
                Console.WriteLine("Entity records have been deleted.");
            }
        }
Пример #5
0
        /// <summary>
        /// Deletes the custom entity record that was created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user
        /// to delete the entity created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            bool toBeDeleted = true;

            if (prompt)
            {
                // Ask the user if the created entities should be deleted.
                Console.Write("\nDo you want these entity records deleted? (y/n) [y]: ");
                String answer = Console.ReadLine();
                if (answer.StartsWith("y") ||
                    answer.StartsWith("Y") ||
                    answer == String.Empty)
                {
                    toBeDeleted = true;
                }
                else
                {
                    toBeDeleted = false;
                }
            }

            if (toBeDeleted)
            {
                service.Delete(Email.EntityLogicalName, emailId);
                service.Delete(Contact.EntityLogicalName, contactId);;

                Console.WriteLine("Entity records have been deleted.");
            }
        }
Пример #6
0
        /// <summary>
        /// Deletes any entity records that were created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user
        /// to delete the records created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            bool deleteRecords = true;

            if (prompt)
            {
                Console.WriteLine("\nDo you want these entity records deleted? (y/n) [y]: ");
                String answer = Console.ReadLine();

                deleteRecords = (answer.StartsWith("y") ||
                                 answer.StartsWith("Y") ||
                                 answer == String.Empty);
            }

            if (deleteRecords)
            {
                service.Delete(Account.EntityLogicalName, accountId);
                UnpublishDuplicateRuleRequest unpublishRequest = new UnpublishDuplicateRuleRequest
                {
                    DuplicateRuleId = ruleId
                };
                service.Execute(unpublishRequest);
                service.Delete(DuplicateRule.EntityLogicalName, ruleId);
                service.Delete(Account.EntityLogicalName, dupAccountId);
                Console.WriteLine("Entity records have been deleted.");
            }
        }
Пример #7
0
        /// <summary>
        /// Deletes/Reverts the record that was created/changed for this sample.
        /// <param name="prompt">Indicates whether to prompt the user to delete
        /// the records created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            bool toBeDeleted = true;

            if (prompt)
            {
                // Ask the user if the created entities should be deleted.
                Console.Write("\nDo you want these entity records deleted? (y/n) [y]: ");
                String answer = Console.ReadLine();
                if (answer.StartsWith("y") ||
                    answer.StartsWith("Y") ||
                    answer == String.Empty)
                {
                    toBeDeleted = true;
                }
                else
                {
                    toBeDeleted = false;
                }
            }

            if (toBeDeleted)
            {
                // Delete all records created in this sample.
                for (int i = 0; i < _accountIdArray.Length; i++)
                {
                    service.Delete(Account.EntityLogicalName, _accountIdArray[i]);
                }
                service.Delete(List.EntityLogicalName, _newListId);
                service.Delete(BulkOperation.EntityLogicalName, _qcBOId);
                Console.WriteLine("Entity record(s) have been deleted.");
            }
        }
Пример #8
0
        /// <summary>
        /// Deletes the custom entity record that was created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user
        /// to delete the entity created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            bool deleteRecords = true;

            if (prompt)
            {
                Console.WriteLine("\nDo you want these entity records deleted? (y/n) [y]: ");
                String answer = Console.ReadLine();

                deleteRecords = (answer.StartsWith("y") || answer.StartsWith("Y") || answer == String.Empty);
            }

            if (deleteRecords)
            {
                //delete Web Resources
                foreach (Guid id in _webResourceIds)
                {
                    service.Delete(WebResource.EntityLogicalName, id);
                }
                Console.WriteLine("Web Resource records have been deleted.");
                //Delete Solution

                service.Delete(Solution.EntityLogicalName, _importWebResourcesSampleSolutionId);
                Console.WriteLine("Solution has been deleted.");

                //
                if (_createdPublisher)
                {
                    // Delete the publisher
                    service.Delete(Publisher.EntityLogicalName, _crmSdkPublisherId);
                    Console.WriteLine("Publisher has been deleted.");
                }
            }
        }
Пример #9
0
        /// <summary>
        /// Deletes the entity record that was created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user
        /// to delete the entity created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            bool deleteRecords = true;

            if (prompt)
            {
                Console.WriteLine("\nDo you want these entity records deleted? (y/n)");
                String answer = Console.ReadLine();

                deleteRecords = (answer.StartsWith("y") || answer.StartsWith("Y"));
            }

            if (deleteRecords)
            {
                // Delete action doesn't work on the UserQueryVisualization instance if it is assigned
                // to a user other than current user.
                // So as a workaround, we are impersonating the actual owner of
                // the UserQueryVisualization instance to complete the delete action.
                // To impersonate another user, set the OrganizationServiceProxy.CallerId
                // property to the ID of the other user.
                service.CallerId = _otherUserId;

                service.Delete(UserQueryVisualization.EntityLogicalName, _userOwnedVisualizationId);
                service.Delete(Account.EntityLogicalName, _accountId);
                Console.WriteLine("Entity records have been deleted.");
            }
        }
Пример #10
0
        /// <summary>
        /// Deletes any entity records that were created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user to delete the records created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            bool deleteRecords = true;

            if (prompt)
            {
                Console.WriteLine("\nDo you want these entity records deleted? (y/n)");
                String answer = Console.ReadLine();

                deleteRecords = (answer.StartsWith("y") || answer.StartsWith("Y"));
            }

            if (deleteRecords)
            {
                DeleteAttributeRequest deleteAttributeRequest = new DeleteAttributeRequest
                {
                    EntityLogicalName = Contact.EntityLogicalName,
                    LogicalName       = "sample" + "_examplepicklist"
                };
                service.Execute(deleteAttributeRequest);
                service.Delete(Solution.EntityLogicalName, _primarySolutionId);
                service.Delete(Solution.EntityLogicalName, _secondarySolutionId);
                service.Delete(Publisher.EntityLogicalName, _publisherId);


                Console.WriteLine("Entity records have been deleted.");
            }
        }
Пример #11
0
        /// <summary>
        /// Deletes the custom entity record that was created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user
        /// to delete the entity created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            bool deleteRecords = true;

            if (prompt)
            {
                Console.WriteLine("\nDo you want these entity records deleted? (y/n)");
                String answer = Console.ReadLine();

                deleteRecords = (answer.StartsWith("y") || answer.StartsWith("Y"));
            }

            if (deleteRecords)
            {
                foreach (Guid accountId in _accountIds)
                {
                    service.Delete(Account.EntityLogicalName, accountId);
                }
                foreach (Guid contactId in _contactIds)
                {
                    service.Delete(Contact.EntityLogicalName, contactId);
                }
                foreach (Guid leadId in _leadIds)
                {
                    service.Delete(Lead.EntityLogicalName, leadId);
                }

                Console.WriteLine("Entity records have been deleted.");
            }
        }
Пример #12
0
        public void DeletePluginExecutionSteps(string dll)
        {
            var pluginsteps = RetrievePluginstepsFromDll(dll);

            foreach (var step in pluginsteps)
            {
                _crmSvc.Delete("sdkmessageprocessingstep", step.Id);
            }
        }
Пример #13
0
        public void AddAndGetKnowledgeArticles()
        {
            using var ctx = new CrmServiceClient(connectionString);

            var categories = new QueryExpression <KnowledgeArticle>().RetrieveMultiple(ctx).Entities;
            var languages  = new QueryExpression <Language>().RetrieveMultiple(ctx).Entities.Where(x => x.Language2 == "English").OrderBy(x => x.Name);

            var knowledgeArticle = Builder.Create <KnowledgeArticle>()
                                   .Set(x => x.Language        = languages.FirstOrDefault(x => x.LocaleID == 1033).ToEntityReference())
                                   .Set(x => x.Status          = KnowledgeArticle.Enums.Status.Draft)
                                   .Set(x => x.StatusReason    = KnowledgeArticle.Enums.StatusReason.Draft)
                                   .Set(x => x.IsLatestVersion = true)
                                   .Set(x => x.PrimaryArticle  = null)
                                   .Set(x => x.ReadyForReview  = true)
                                   .Set(x => x.Categories      = Builder.Create <IEnumerable <Category> >());

            try
            {
                var id = ctx.Create(knowledgeArticle);

                var result = new QueryExpression <KnowledgeArticle>
                {
                    Conditions   = { new ConditionExpression <KnowledgeArticle>(x => x.Id, id) },
                    LinkEntities = { new LinkEntity <KnowledgeArticle, Category>(x => x.Categories) }
                }.RetrieveMultiple(ctx).Entities.First();

                result.Should().BeEquivalentTo(knowledgeArticle, x => x
                                               .Using <DateTime>(y => y.Subject.Should().BeCloseTo(y.Expectation, 1000)).WhenTypeIs <DateTime>()
                                               .Excluding(y => y.SelectedMemberInfo.MemberType == typeof(EntityReference))
                                               .Excluding(y => y.SelectedMemberInfo.DeclaringType == typeof(Entity))
                                               .Using(new IgnoreNullMembersInExpectation())
                                               .Excluding(x => x.IsLatestVersion)
                                               .Excluding(x => x.PrimaryArticle)
                                               .Excluding(y => y.Categories));

                result.Categories.Should().BeEquivalentTo(knowledgeArticle.Categories, x => x
                                                          .Excluding(y => y.SelectedMemberInfo.MemberType == typeof(EntityReference))
                                                          .Excluding(y => y.SelectedMemberInfo.DeclaringType == typeof(Entity))
                                                          .Using(new IgnoreNullMembersInExpectation()));
            }
            finally
            {
                ctx.Execute(new DisassociateRequest
                {
                    Target          = knowledgeArticle.ToEntityReference(),
                    RelatedEntities = new EntityReferenceCollection(knowledgeArticle.Categories.Select(x => x.ToEntityReference()).ToList()),
                    Relationship    = new Relationship(KnowledgeArticle.Relationships.Categories)
                });

                foreach (var cat in knowledgeArticle.Categories)
                {
                    ctx.Delete(cat.LogicalName, cat.Id);
                }

                ctx.Delete(knowledgeArticle.LogicalName, knowledgeArticle.Id);
            }
        }
Пример #14
0
        /// <summary>
        /// Deletes the custom entity record that was created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user
        /// to delete the entity created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            bool deleteRecords = true;

            if (prompt)
            {
                Console.WriteLine("\nDo you want these entity records deleted? (y/n)");
                String answer = Console.ReadLine();

                deleteRecords = (answer.StartsWith("y") || answer.StartsWith("Y"));
            }

            if (deleteRecords)
            {
                // Delete all records created in this sample.
                service.Delete(Account.EntityLogicalName, _accountId2);
                service.Delete(Incident.EntityLogicalName, _incidentId2);
                service.Delete(Account.EntityLogicalName, _accountId1);
                service.Delete(Lead.EntityLogicalName, _leadId);
                service.Delete(Incident.EntityLogicalName, _incidentId1);
                service.Delete(Contact.EntityLogicalName, _contactId4);
                service.Delete(Contact.EntityLogicalName, _contactId3);
                service.Delete(Contact.EntityLogicalName, _contactId2);
                service.Delete(Contact.EntityLogicalName, _contactId1);

                Console.WriteLine("Entity records have been deleted.");
            }
        }
Пример #15
0
        /// <summary>
        /// Deletes records that were created in the sample.
        /// </summary>
        /// <param name="prompt">whether or not to prompt the user for deletion.</param>
        private static void DeleteRecords(CrmServiceClient service, bool prompt)
        {
            var toBeDeleted = true;

            if (prompt)
            {
                // Ask the user if the created entities should be deleted.
                Console.Write("\nDo you want these entity records deleted? (y/n) [y]: ");
                String answer = Console.ReadLine();
                if (answer.StartsWith("y") ||
                    answer.StartsWith("Y") ||
                    answer == String.Empty)
                {
                    toBeDeleted = true;
                }
                else
                {
                    toBeDeleted = false;
                }
            }

            if (toBeDeleted)
            {
                // Delete the bulk delete operation so that it won't clutter the
                // database.
                service.Delete(
                    BulkDeleteOperation.EntityLogicalName, _bulkDeleteOperationId);

                var asyncOperationEntity = service.Retrieve(
                    AsyncOperation.EntityLogicalName,
                    _asyncOperationId,
                    new ColumnSet("statecode", "asyncoperationid"));
                var asyncOperation = asyncOperationEntity.ToEntity <AsyncOperation>();

                if (asyncOperation.StateCode != AsyncOperationState.Completed)
                {
                    // We have to update the AsyncOperation to be in a Completed state
                    // before we can delete it.
                    asyncOperation.StateCode = AsyncOperationState.Completed;
                    service.Update(asyncOperation);
                }

                service.Delete(
                    AsyncOperation.EntityLogicalName, _asyncOperationId);

                Console.WriteLine("  The AsyncOperation and BulkDeleteOperation have been deleted.");
            }
        }
Пример #16
0
        public void CreateNewContact()
        {
            //Setup
            string crmCon = TestCreateContact.GetConfigValue("CrmConnection");

            using (CrmServiceClient svc = new CrmServiceClient(crmCon))
            {
                // Act
                Entity c = new Entity("contact");

                c["firstname"] = "Test";
                c["lastname"]  = DateTime.Now.Date.ToShortDateString();

                c.Id = svc.Create(c);

                //Validate
                Thread.Sleep(5000);

                QueryByAttribute query = new QueryByAttribute("phonecall");
                query.Attributes.Add("regardingobjectid");
                query.Values.Add(c.Id);

                EntityCollection calls = svc.RetrieveMultiple(query);

                Assert.AreEqual(calls.Entities.Count, 1);

                //Clean up
                svc.Delete(c.LogicalName, c.Id);
            }
        }
Пример #17
0
 internal static void deleteEntityByID(CrmServiceClient service, string entityName, List <Guid> ids)
 {
     foreach (Guid item in ids)
     {
         service.Delete(entityName, item);
     }
 }
        private bool Clean(WebResource resource)
        {
            try
            {
                if (this.connection.IsReady)
                {
                    Log.Warning("Deleting {resource}", resource.Name);
                    connection.Delete("webresource", resource.WebResourceId);
                    return(true);
                }
                else
                {
                    throw new Exception(this.connection.LastCrmError);
                }
            }
            catch (FaultException <OrganizationServiceFault> ex)
            {
                if (ex.Message.ToLower().Contains("does not exist"))
                {
                    Log.Warning("File did not exist in CRM System.");
                    return(true);
                }

                Log.Error(ex, "Failed");

                return(false);
            }
        }
Пример #19
0
        /// <summary>
        /// Deletes the custom entity record that was created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user
        /// to delete the entity created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            bool deleteRecords = true;

            if (prompt)
            {
                Console.WriteLine("\nDo you want these entity records deleted? (y/n)");
                String answer = Console.ReadLine();

                deleteRecords = (answer.StartsWith("y") || answer.StartsWith("Y"));
            }

            if (deleteRecords)
            {
                // Deactivate and delete workflow
                SetStateRequest deactivateRequest = new SetStateRequest
                {
                    EntityMoniker = new EntityReference(Workflow.EntityLogicalName, _workflowId),
                    State         = new OptionSetValue((int)WorkflowState.Draft),
                    Status        = new OptionSetValue((int)workflow_statuscode.Draft)
                };
                service.Execute(deactivateRequest);
                service.Delete(Workflow.EntityLogicalName, _workflowId);
                Console.WriteLine("The workflow has been deactivated, and deleted.");
            }
        }
        public static void DeleteSpecificApplication()
        {
            EntityCollection data = RetrieveAppsCreatedToday(); //gets and list all apps created today with a number before to choose
            int numApps           = 1;                          // counter int to check if selected app is the one in the loop
            var validChoice       = false;

            Console.WriteLine("Select the number corresponding to the Application you wish to delete or 0 to quit.");
            var chosenNum = Console.ReadLine();

            if (chosenNum == "0")
            {
                return;
            }


            foreach (Entity ent in data.Entities)
            {
                Guid Id = ent.Id;
                if (int.Parse(chosenNum) == numApps)
                {
                    while (!validChoice)
                    {
                        validChoice = true;
                        Console.WriteLine("Are you sure you wish to delete Application " + ent.Attributes["madmv_appid"] + "? (y/n)");
                        var choice = Console.ReadLine();
                        if (choice.ToLower() == "n")
                        {
                            return;
                        }
                        else if (choice.ToLower() == "y")
                        {
                            Console.WriteLine("Processing Delete Action\n...");
                            svc.Delete("madmv_ma_application", Id);
                            Console.WriteLine("Application Deleted!");
                        }
                        else
                        {
                            Console.WriteLine("Invalid choice!");
                            validChoice = false;
                        }
                    }
                }
                numApps++;
            }
        }
Пример #21
0
        public void Delete(string id)
        {
            var SecurityPaper = service.Retrieve(entityName, Guid.Parse(id), new ColumnSet(true));

            if (SecurityPaper != null)
            {
                service.Delete(entityName, Guid.Parse(id));
            }
        }
Пример #22
0
        /// <summary>
        /// Deletes the custom entity record that was created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user
        /// to delete the entity created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            bool deleteRecords = true;

            if (prompt)
            {
                Console.WriteLine("\nDo you want these entity records deleted? (y/n)");
                String answer = Console.ReadLine();

                deleteRecords = (answer.StartsWith("y") || answer.StartsWith("Y"));
            }

            if (deleteRecords)
            {
                service.Delete(Team.EntityLogicalName, _teamId);
                service.Delete(Role.EntityLogicalName, _roleId);
                Console.WriteLine("Entity records have been deleted.");
            }
        }
Пример #23
0
        /// <summary>
        /// Deletes any entity records that were created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user
        /// to delete the records created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            bool deleteRecords = true;

            if (prompt)
            {
                Console.WriteLine("\nDo you want these entity records deleted? (y/n) [y]: ");
                String answer = Console.ReadLine();

                deleteRecords = (answer.StartsWith("y") || answer.StartsWith("Y") || answer == String.Empty);
            }

            if (deleteRecords)
            {
                service.Delete(Account.EntityLogicalName, accountId);
                service.Delete(Account.EntityLogicalName, parentAccountId);
                Console.WriteLine("Entity records have been deleted.");
            }
        }
Пример #24
0
        /// <summary>
        /// Deletes any entity records that were created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user
        /// to delete the records created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            // The three system users that were created by this sample will continue to
            // exist on your system because system users cannot be deleted in Microsoft
            // Dynamics CRM.  They can only be enabled or disabled.

            bool toBeDeleted = true;

            if (prompt)
            {
                // Ask the user if the created entities should be deleted.
                Console.Write("\nDo you want these entity records deleted? (y/n) [y]: ");
                String answer = Console.ReadLine();
                if (answer.StartsWith("y") ||
                    answer.StartsWith("Y") ||
                    answer == String.Empty)
                {
                    toBeDeleted = true;
                }
                else
                {
                    toBeDeleted = false;
                }
            }

            if (toBeDeleted)
            {
                // Delete all records created in this sample.
                service.Delete("goal", _firstChildGoalId);
                service.Delete("goal", _secondChildGoalId);
                service.Delete("goal", _parentGoalId);
                service.Delete("goalrollupquery", _rollupQueryIds[0]);
                service.Delete("goalrollupquery", _rollupQueryIds[1]);
                service.Delete("account", _accountId);
                service.Delete("phonecall", _phoneCallId);
                service.Delete("phonecall", _phoneCall2Id);
                service.Delete("rollupfield", _actualId);
                service.Delete("metric", _metricId);

                Console.WriteLine("Entity record(s) have been deleted.");
            }
        }
 public static void DeleteWebResourcetFromCrm(CrmServiceClient client, Guid webResourceId)
 {
     try
     {
         client.Delete("webresource", webResourceId);
     }
     catch (Exception ex)
     {
         ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorDeletingWebResource, ex);
     }
 }
Пример #26
0
 /// <summary>
 /// Deletes the provided web resource
 /// </summary>
 /// <param name="webResource">Web resource to delete</param>
 internal static void DeleteWebResource(this CrmServiceClient service, Entity webResource)
 {
     try
     {
         service.Delete(webResource.LogicalName, webResource.Id);
     }
     catch (Exception error)
     {
         throw new Exception("Error while deleting web resource: " + error.Message);
     }
 }
Пример #27
0
        /// <summary>
        /// Deletes any entity records that were created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user
        /// to delete the records created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            bool toBeDeleted = true;

            if (prompt)
            {
                // Ask the user if the created entities should be deleted.
                Console.Write("\nDo you want these entity records deleted? (y/n) [y]: ");
                String answer = Console.ReadLine();
                if (answer.StartsWith("y") ||
                    answer.StartsWith("Y") ||
                    answer == String.Empty)
                {
                    toBeDeleted = true;
                }
                else
                {
                    toBeDeleted = false;
                }
            }

            if (toBeDeleted)
            {
                // Delete the job
                Console.WriteLine("  Deleting the job");
                service.Delete(AsyncOperation.EntityLogicalName, response.JobId);

                // Delete the duplicate detection rule
                Console.WriteLine("  Deleting the duplicate detection rule");
                service.Delete(DuplicateRule.EntityLogicalName, rule.Id);

                // Delete the accounts
                Console.WriteLine("  Deleting the accounts");
                foreach (Account account in duplicateAccounts)
                {
                    service.Delete(Account.EntityLogicalName, account.Id);
                }
                service.Delete(Account.EntityLogicalName, account.Id);
                Console.WriteLine("Entity records have been deleted.");
            }
        }
Пример #28
0
        /// <summary>
        /// This method deletes the AsyncOperation and BulkDeleteOperation that were
        /// created in the database, if the user confirms that deleting these is
        /// desired.
        /// </summary>
        private static void DeleteRequiredRecords(CrmServiceClient service, bool promptToDelete)
        {
            var toBeDeleted = true;

            if (promptToDelete)
            {
                // Ask the user if the created entities should be deleted.
                Console.Write("\nDo you want these entity records deleted? (y/n) [y]: ");
                String answer = Console.ReadLine();
                if (answer.StartsWith("y") ||
                    answer.StartsWith("Y") ||
                    answer == String.Empty)
                {
                    toBeDeleted = true;
                }
                else
                {
                    toBeDeleted = false;
                }
            }

            if (toBeDeleted)
            {
                // Delete the bulk delete operation so that it won't clutter the
                // database.
                if (_bulkDeleteOperationId.HasValue)
                {
                    service.Delete(
                        BulkDeleteOperation.EntityLogicalName,
                        _bulkDeleteOperationId.Value);
                }

                if (_asyncOperationId.HasValue)
                {
                    service.Delete(
                        AsyncOperation.EntityLogicalName, _asyncOperationId.Value);
                }

                Console.WriteLine("The AsyncOperation and BulkDeleteOperation have been deleted.");
            }
        }
Пример #29
0
 public void DeleteExpense(Guid guid)
 {
     try
     {
         CrmServiceClient service = new CrmServiceClient(_conectionString);
         service.Delete("new_expenseee", guid);
     }
     catch (Exception e)
     {
         throw new Exception("Failed To Delete");
     }
 }
        /// <summary>
        /// Deletes the custom entity record that was created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user
        /// to delete the entity created in this sample.</param>
        /// </summary>
        public static void DeleteRequiredRecords(CrmServiceClient service, bool prompt)
        {
            bool deleteRecords = true;

            if (prompt)
            {
                Console.WriteLine("\nDo you want these entity records deleted? (y/n)");
                String answer = Console.ReadLine();

                deleteRecords = (answer.StartsWith("y") || answer.StartsWith("Y"));
            }

            if (deleteRecords)
            {
                service.Delete(SavedQueryVisualization.EntityLogicalName,
                               _orgOwnedVisualizationId);
                service.Delete("account", _accountId);

                Console.WriteLine("Entity records have been deleted.");
            }
        }