Exemple #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)
            {
                var request = new DeleteEntityRequest()
                {
                    LogicalName = _customEntitySchemaName.ToLower(),
                };
                service.Execute(request);
                Console.WriteLine("Entity record(s) have been deleted.");
            }
        }
Exemple #2
0
 public Task <BaseResponse> Delete([FromBody] DeleteEntityRequest deleteDepartmentRequest)
 => this.clientFactory.PostAsync <BaseResponse>
 (
     "api/Department/Delete",
     JsonSerializer.Serialize(deleteDepartmentRequest),
     this.configurationOptions.BaseBslUrl
 );
Exemple #3
0
 public async Task <BaseResponse> Delete([FromBody] DeleteEntityRequest deleteUserRequest)
 => await this.clientFactory.PostAsync <BaseResponse>
 (
     "api/User/Delete",
     JsonSerializer.Serialize(deleteUserRequest),
     this.configurationOptions.BaseBslUrl
 );
Exemple #4
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            if (!ConfirmDelete("OCIDatacatalogEntity", "Remove"))
            {
                return;
            }

            DeleteEntityRequest request;

            try
            {
                request = new DeleteEntityRequest
                {
                    CatalogId    = CatalogId,
                    DataAssetKey = DataAssetKey,
                    EntityKey    = EntityKey,
                    IfMatch      = IfMatch,
                    OpcRequestId = OpcRequestId
                };

                response = client.DeleteEntity(request).GetAwaiter().GetResult();
                WriteOutput(response);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Exemple #5
0
        public async Task <IActionResult> Delete(TKey id)
        {
            var request = new DeleteEntityRequest <TKey, TEntity>(id);
            var result  = await _mediator.Send(request);

            return(new NoContentResult()
            {
            });
        }
        protected void deleteCustomEntityWithOptionSet()
        {
            DeleteEntityRequest request = new DeleteEntityRequest()
            {
                LogicalName = _customEntitySchemaName.ToLower(),
            };

            _service.Execute(request);
        }
Exemple #7
0
        public virtual async Task <EntityResponse <T> > DeleteAsync <T>(DeleteEntityRequest <T> request, CancellationToken cancellationToken = default) where T : class
        {
            var httpRequest = DeleteHttpRequestFactory.Create(request);

            using (var res = await SendAsync(httpRequest, cancellationToken).ForAwait())
            {
                return(await ProcessEntityResponseAsync(request, res).ForAwait());
            }
        }
        public async Task <bool> Handle(DeleteEntityRequest <TKey, TEntity> request, CancellationToken cancellationToken)
        {
            var entityToDelete = await innerDataContext.Set <TEntity>().FindAsync(request.Key);

            var entry = innerDataContext.Set <TEntity>().Remove(entityToDelete);
            await innerDataContext.SaveChangesAsync(cancellationToken);

            return(entry.Property <bool>("IsDeleted").CurrentValue);
        }
Exemple #9
0
        public virtual async Task <EntityResponse <T> > DeleteAsync <T>(DeleteEntityRequest <T> request) where T : class
        {
            var httpRequest = CreateHttpRequest(request);

            using (var res = await SendAsync(httpRequest).ForAwait())
            {
                return(ProcessEntityResponse(request, res));
            }
        }
        protected virtual string GetEntityRev <T>(DeleteEntityRequest <T> request) where T : class
        {
            var entityRev = Reflector.RevMember.GetValueFrom(request.Entity);

            Ensure.That(entityRev, "request")
            .WithExtraMessageOf(() => "Could not extract entity rev from entity being deleted. Ensure member exists.")
            .IsNotNullOrWhiteSpace();
            return(entityRev);
        }
        protected virtual void RemoveTestEntity()
        {
            using (var orgService = (OrganizationServiceContext)this.GetCrmServiceProvider().GetOrganisationService())
            {
                // Check for test entity - if it doesn't exist then create it.

                var retrieveEntity = new RetrieveEntityRequest();
                retrieveEntity.RetrieveAsIfPublished = true;
                retrieveEntity.LogicalName           = TestDynamicsCrmServerSyncProvider.TestEntityName;
                RetrieveEntityResponse retrieveEntityResponse = null;
                try
                {
                    var entity = GetTestEntityMetadata();
                }
                catch (Exception e)
                {
                    if (e.Message.ToLower().StartsWith("could not find"))
                    {
                        // this means no need to remove the entity as it doesn't exist.
                        return;
                    }
                    else
                    {
                        // This means some other error happened.
                        // Write the error, but proceed so we can atleast still attempt to remove the entity.
                        Console.WriteLine("error checking whether entity exists, but will still try and remove it. Message: " + e.Message);
                    }
                }

                var request = new DeleteEntityRequest();
                request.LogicalName = TestDynamicsCrmServerSyncProvider.TestEntityName;
                try
                {
                    var response = (DeleteEntityResponse)orgService.Execute(request);
                    if (response == null)
                    {
                        throw new Exception("Expected response.");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error deleting test entity metadata. " + e.Message);

                    RetrieveDependenciesForDeleteRequest req = new RetrieveDependenciesForDeleteRequest();
                    req.ComponentType = (int)SolutionComponentType.Entity;
                    //use the metadata browser or a retrieveentity request to get the MetadataId for the entity
                    req.ObjectId = retrieveEntityResponse.EntityMetadata.MetadataId.Value;
                    var dependenciesResponse = (RetrieveDependenciesForDeleteResponse)orgService.Execute(req);

                    foreach (Entity item in dependenciesResponse.EntityCollection.Entities)
                    {
                        Console.WriteLine("Could not remove the entity because of a dependency: " + item.LogicalName + " id: " + item.Id);
                    }
                }
            }
        }
 public Task <BaseResponse> DeleteEntity(DeleteEntityRequest request, string url = null)
 => PollyHelpers.ExecutePolicyAsync
 (
     () => this.factory.PostAsync <BaseResponse>
     (
         url,
         JsonSerializer.Serialize(request),
         App.BASE_URL
     )
 );
Exemple #13
0
        public Task <bool> Handle(DeleteEntityRequest <TKey, TEntity> request, CancellationToken cancellationToken)
        {
            var keyProperty = typeof(TEntity).GetProperties().FirstOrDefault(p => p.GetCustomAttribute <KeyAttribute>() != null);

            return(Task.Run(() =>
            {
                var item = _entities.FirstOrDefault(e => ((TKey)keyProperty.GetValue(e)).Equals(request.Key));
                return _entities.Remove(item);
            }));
        }
        public void Delete <T>() where T : CrmPlusPlusEntity, new()
        {
            var entityName = EntityNameAttribute.GetFromType <T>();

            var deleteEntityRequest = new DeleteEntityRequest
            {
                LogicalName = entityName
            };

            service.Execute(deleteEntityRequest);
        }
Exemple #15
0
        public virtual HttpRequest Create <T>(DeleteEntityRequest <T> request) where T : class
        {
            Ensure.Any.IsNotNull(request, nameof(request));

            var entityId  = GetEntityId(request);
            var entityRev = GetEntityRev(request);

            return(new HttpRequest(HttpMethod.Delete, GenerateRelativeUrl(entityId, entityRev))
                   .SetRequestTypeHeader(request.GetType())
                   .SetIfMatchHeader(entityRev));
        }
Exemple #16
0
        protected virtual string GetEntityRev <T>(DeleteEntityRequest <T> request) where T : class
        {
            var entityRev = Reflector.RevMember.GetValueFrom(request.Entity);

            if (string.IsNullOrWhiteSpace(entityRev))
            {
                throw new ArgumentException("Could not extract entity rev from entity being deleted. Ensure member exists.", nameof(request));
            }

            return(entityRev);
        }
Exemple #17
0
        protected virtual EntityResponse <T> ProcessEntityResponse <T>(DeleteEntityRequest <T> request, HttpResponseMessage response) where T : class
        {
            var entityResponse = EntityResponseFactory.Create <T>(response);

            entityResponse.Content = request.Entity;

            if (entityResponse.IsSuccess)
            {
                Reflector.RevMember.SetValueTo(entityResponse.Content, entityResponse.Rev);
            }

            return(entityResponse);
        }
Exemple #18
0
        /// <summary>
        /// Delete the Custom Activity itself
        /// </summary>
        public static void DeleteCustomActivity()
        {
            DeleteEntityRequest request = new DeleteEntityRequest()
            {
                LogicalName = _customActivityName,
            };

            service.Execute(request);
            // Customizations must be published after an entity is updated.
            PublishAllXmlRequest publishRequest = new PublishAllXmlRequest();

            service.Execute(publishRequest);
            Console.WriteLine("The custom entity has been deleted.");
        }
Exemple #19
0
        public virtual HttpRequest Create<T>(DeleteEntityRequest<T> request) where T : class
        {
            var entityId = Reflector.IdMember.GetValueFrom(request.Entity);
            Ensure.That(entityId, "entityId").IsNotNullOrWhiteSpace();

            var entityRev = Reflector.RevMember.GetValueFrom(request.Entity);
            Ensure.That(entityRev, "entityRev").IsNotNullOrWhiteSpace();

            var httpRequest = CreateFor<DeleteEntityRequest<T>>(HttpMethod.Delete, GenerateRequestUrl(entityId, entityRev));

            httpRequest.SetIfMatch(entityRev);

            return httpRequest;
        }
        public bool DeleteEntity(IOrganizationService service, XRMSpeedyEntity entity)
        {
            try
            {
                DeleteEntityRequest delete = new DeleteEntityRequest
                {
                    LogicalName = entity.EntityMetadata.SchemaName
                };

                service.Execute(delete);
                return(true);
            }
            catch (FaultException <OrganizationServiceFault> )
            {
                throw;
            }
        }
Exemple #21
0
        public async Task Test_DeleteEntityRequest_Handler()
        {
            // resolving Meditor service implementation using ServiceProvider
            var mediatr = IoC.ServiceProvider.GetRequiredService <IMediator>();


            var createResult = await mediatr.Send(
                new CreateEntityRequest <TestModel>(new TestModel()
            {
                Name = "test name 1",
                Description = "test description 1"
            })
                );

            var deleteEntityRequest = new DeleteEntityRequest <int, TestModel>(createResult.Id);

            var deleteEntityResult = await mediatr.Send(deleteEntityRequest);

            // testing results
            Assert.IsTrue(deleteEntityResult);
        }
        /// <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)
            {
                DeleteEntityRequest request = new DeleteEntityRequest()
                {
                    LogicalName = _customEntityName,
                };
                Console.WriteLine("Entity records have been deleted.");
            }
        }
Exemple #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 void DeleteImageAttributeDemoEntity(bool prompt)
        {
            bool deleteRecords = true;

            if (prompt)
            {
                Console.WriteLine("\nDo you want to delete the entity created for this sample? (y/n) [y]: ");
                String answer = Console.ReadLine();

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

            if (deleteRecords)
            {
                DeleteEntityRequest der = new DeleteEntityRequest()
                {
                    LogicalName = _customEntityName.ToLower()
                };
                _serviceProxy.Execute(der);
                Console.WriteLine("The Image Attribute Demo entity has been deleted.");
            }
        }
Exemple #24
0
        /// <summary>
        /// Deletes the custom entity that was created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user to delete the records created in this sample.</param>
        /// </summary>
        public void DeleteRequiredRecords(bool prompt)
        {
            bool deleteEntity = true;

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

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

            if (deleteEntity)
            {
                DeleteEntityRequest request = new DeleteEntityRequest()
                {
                    LogicalName = _customEntityName,
                };
                _serviceProxy.Execute(request);
                Console.WriteLine("The custom entity has been deleted.");
            }
        }
        /// <summary>
        /// Deletes the custom entity 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 void DeleteCustomEntity(String prefix, bool prompt)
        {
            bool deleteEntity = true;

            if (prompt)
            {
                Console.WriteLine("\nDo you want this custom entity deleted? (y/n)");
                char answer = Convert.ToChar(Console.ReadLine().Substring(0, 1));

                deleteEntity = (answer == 'y' || answer == 'Y');
            }

            if (deleteEntity)
            {
                DeleteEntityRequest request = new DeleteEntityRequest()
                {
                    LogicalName = prefix + "instantmessage",
                };
                _serviceProxy.Execute(request);

                Console.WriteLine("Entity has been deleted.");
            }
        }
Exemple #26
0
        /// <summary>
        /// Deletes any entity records and files 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 void DeleteRequiredRecords(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)
            {
                DeleteEntityRequest del = new DeleteEntityRequest()
                {
                    LogicalName = "new_tweet",
                };
                _serviceProxy.Execute(del);
                _serviceProxy.Delete(FieldSecurityProfile.EntityLogicalName, _profileId);
                _serviceProxy.Delete(Team.EntityLogicalName, _teamId);
                Console.WriteLine("Entity records have been deleted.");
            }
        }
Exemple #27
0
        /// <summary>
        /// Deletes the custom entity that was created for this sample.
        /// <param name="prompt">Indicates whether to prompt the user to delete the records created in this sample.</param>
        /// </summary>
        public void DeleteRequiredRecords(bool prompt)
        {
            bool deleteEntity = true;

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

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

            if (deleteEntity)
            {
                //<snippetCreateUpdateEntityMetadata10>
                DeleteEntityRequest request = new DeleteEntityRequest()
                {
                    LogicalName = _customEntityName,
                };
                _serviceProxy.Execute(request);
                //</snippetCreateUpdateEntityMetadata10>
                Console.WriteLine("The records have been deleted.");
            }
        }
        /// <summary>
        /// Deletes the custom entity 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 void DeleteCustomEntity(String prefix, bool prompt)
        {
            bool deleteEntity = true;

            if (prompt)
            {
                Console.WriteLine("\nDo you want this custom entity deleted? (y/n)");
                char answer = Convert.ToChar(Console.ReadLine().Substring(0, 1));

                deleteEntity = (answer == 'y' || answer == 'Y');
            }

            if (deleteEntity)
            {
                DeleteEntityRequest request = new DeleteEntityRequest()
                {
                    LogicalName = prefix + "instantmessage",
                };
                _serviceProxy.Execute(request);

                Console.WriteLine("Entity has been deleted.");
            }
        }
Exemple #29
0
        /// <summary>
        ///     WARNING!! DELETES THE CUSTOM ENTITY
        /// </summary>
        /// <param name="schemaName"></param>
        public void DeleteEntity(string schemaName)
        {
            lock (LockObject)
            {
                var tempRequest1 = new RetrieveEntityRequest
                {
                    LogicalName = schemaName,
                    EntityFilters = EntityFilters.Relationships
                };
                var response = (RetrieveEntityResponse) Execute(tempRequest1);
                foreach (var r in response.EntityMetadata.OneToManyRelationships)
                {
                    if (r.IsCustomRelationship.HasValue && r.IsCustomRelationship.Value)
                    {
                        var tempRequest2 = new DeleteRelationshipRequest
                        {
                            Name = r.SchemaName
                        };
                        Execute(tempRequest2);
                    }
                }

                var request = new DeleteEntityRequest();
                request.LogicalName = schemaName;
                Execute(request);
                if (GetAllEntityMetadata().Any(m => m.SchemaName == schemaName))
                    GetAllEntityMetadata().Remove(GetAllEntityMetadata().Single(m => m.SchemaName == schemaName));
                if (_entityFieldMetadata.ContainsKey(schemaName))
                    _entityFieldMetadata.Remove(schemaName);
            }
        }
Exemple #30
0
 protected virtual HttpRequest CreateHttpRequest <T>(DeleteEntityRequest <T> request) where T : class
 {
     return(DeleteHttpRequestFactory.Create(request));
 }
  /// <summary>
  /// Deletes the custom entity that was created for this sample.
  /// <param name="prompt">Indicates whether to prompt the user to delete the records created in this sample.</param>
  /// </summary>
  public void DeleteRequiredRecords(bool prompt)
  {
   bool deleteEntity = true;

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

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

   if (deleteEntity)
   {
    //<snippetCreateUpdateEntityMetadata10>
    DeleteEntityRequest request = new DeleteEntityRequest()
    {
     LogicalName = _customEntityName,
    };
    _serviceProxy.Execute(request);
    //</snippetCreateUpdateEntityMetadata10>
    Console.WriteLine("The records have been deleted.");
   }
  }
Exemple #32
0
        /// <summary>
        /// This method creates any entity records that this sample requires.
        /// </summary>
        public void CreateRequiredRecords()
        {
            // Create a managed solution for the Install or upgrade a solution sample

            Guid _tempPublisherId = new Guid();

            System.String _tempCustomizationPrefix       = "ds";
            Guid          _tempSolutionsSampleSolutionId = new Guid();
            Random        rn = new Random();

            System.String _TempGlobalOptionSetName = "_TempSampleGlobalOptionSetName" + rn.Next();
            Boolean       _publisherCreated        = false;
            Boolean       _solutionCreated         = false;


            //Define a new publisher
            Publisher _crmSdkPublisher = new Publisher
            {
                UniqueName           = Constants.PublisherUniqueName,
                FriendlyName         = Constants.PublisherFriendlyName,
                SupportingWebsiteUrl = Constants.PublisherSupportingWebsiteUrl,
                CustomizationPrefix  = Constants.PublisherCustomizationPrefix,
                EMailAddress         = Constants.PublisherEmailAddress,
                Description          = Constants.PublisherDescription
            };

            //Does publisher already exist?
            QueryExpression querySDKSamplePublisher = new QueryExpression
            {
                EntityName = Publisher.EntityLogicalName,
                ColumnSet  = new ColumnSet("publisherid", "customizationprefix"),
                Criteria   = new FilterExpression()
            };

            querySDKSamplePublisher.Criteria.AddCondition("uniquename", ConditionOperator.Equal, _crmSdkPublisher.UniqueName);
            EntityCollection querySDKSamplePublisherResults = _serviceProxy.RetrieveMultiple(querySDKSamplePublisher);
            Publisher        SDKSamplePublisherResults      = null;

            //If it already exists, use it
            if (querySDKSamplePublisherResults.Entities.Count > 0)
            {
                SDKSamplePublisherResults = (Publisher)querySDKSamplePublisherResults.Entities[0];
                _tempPublisherId          = (Guid)SDKSamplePublisherResults.PublisherId;
                _tempCustomizationPrefix  = SDKSamplePublisherResults.CustomizationPrefix;
            }
            //If it doesn't exist, create it
            if (SDKSamplePublisherResults == null)
            {
                _tempPublisherId         = _serviceProxy.Create(_crmSdkPublisher);
                _tempCustomizationPrefix = _crmSdkPublisher.CustomizationPrefix;
                _publisherCreated        = true;
            }

            //Upload only configuration page
            UploadConfigurationPageForSolution();
            //SetWebResourceConfigurationForSolution();

            //Define a solution
            Solution solution = new Solution
            {
                UniqueName          = Constants.SolutionUniqueName,
                FriendlyName        = Constants.SolutionFriendlyName,
                PublisherId         = new EntityReference(Publisher.EntityLogicalName, _tempPublisherId),
                Description         = Constants.SolutionDescription,
                Version             = Constants.SolutionVersion,
                ConfigurationPageId = new EntityReference(WebResource.EntityLogicalName, _webResourceIdForSolution[0])
            };

            //Check whether it already exists
            QueryExpression querySampleSolution = new QueryExpression
            {
                EntityName = Solution.EntityLogicalName,
                ColumnSet  = new ColumnSet(),
                Criteria   = new FilterExpression()
            };

            querySampleSolution.Criteria.AddCondition("uniquename", ConditionOperator.Equal, solution.UniqueName);

            EntityCollection querySampleSolutionResults = _serviceProxy.RetrieveMultiple(querySampleSolution);
            Solution         SampleSolutionResults      = null;

            if (querySampleSolutionResults.Entities.Count > 0)
            {
                SampleSolutionResults          = (Solution)querySampleSolutionResults.Entities[0];
                _tempSolutionsSampleSolutionId = (Guid)SampleSolutionResults.SolutionId;
            }

            if (SampleSolutionResults == null)
            {
                _tempSolutionsSampleSolutionId = _serviceProxy.Create(solution);
                _solutionCreated = true;
            }

            // Add a solution Component
            OptionSetMetadata optionSetMetadata = new OptionSetMetadata()
            {
                Name          = _tempCustomizationPrefix + _TempGlobalOptionSetName,
                DisplayName   = new Label("Example Option Set", _languageCode),
                IsGlobal      = true,
                OptionSetType = OptionSetType.Picklist,
                Options       =
                {
                    new OptionMetadata(new Label("Option A", _languageCode), null),
                    new OptionMetadata(new Label("Option B", _languageCode), null)
                }
            };
            CreateOptionSetRequest createOptionSetRequest = new CreateOptionSetRequest
            {
                OptionSet          = optionSetMetadata,
                SolutionUniqueName = solution.UniqueName
            };

            _serviceProxy.Execute(createOptionSetRequest);

            //delete configuration entity
            if (IsEntityExist(_customEntityName) > 0)
            {
                DeleteEntityRequest customEntityNameFormField = new DeleteEntityRequest()
                {
                    LogicalName = _customEntityName,
                };
                _serviceProxy.Execute(customEntityNameFormField);
            }


            // Create the dots_autonumber entity.
            AutoSMS.DotsAutoNumberEntity();
            // CreateTab();


            //delete dots_configuration entity
            if (IsEntityExist(_customConfigurationEntityName) > 0)
            {
                DeleteEntityRequest customEntityNameFormField = new DeleteEntityRequest()
                {
                    LogicalName = _customConfigurationEntityName,
                };
                _serviceProxy.Execute(customEntityNameFormField);
            }


            //for create dots_configuration entity
            AutoSMS.DotsAutoNumberConfigurationEntity();


            // assign dots_autonumber form entity to solution
            RetrieveEntityRequest retrievepowertEntityRequest = new RetrieveEntityRequest
            {
                EntityFilters = EntityFilters.Entity,
                LogicalName   = _customEntityName
            };


            RetrieveEntityResponse retrievepowerEntityResponse = (RetrieveEntityResponse)_serviceProxy.Execute(retrievepowertEntityRequest);

            AddSolutionComponentRequest addReq = new AddSolutionComponentRequest()
            {
                ComponentType         = 1,
                ComponentId           = (Guid)retrievepowerEntityResponse.EntityMetadata.MetadataId,
                SolutionUniqueName    = solution.UniqueName,
                AddRequiredComponents = true
            };

            _serviceProxy.Execute(addReq);


            //assign dots_configuration entity to solution
            RetrieveEntityRequest retrieveconfigurationtEntityRequest = new RetrieveEntityRequest
            {
                EntityFilters = EntityFilters.Entity,
                LogicalName   = _customConfigurationEntityName
            };


            RetrieveEntityResponse retrieveconfigEntityResponse = (RetrieveEntityResponse)_serviceProxy.Execute(retrieveconfigurationtEntityRequest);

            AddSolutionComponentRequest addConfigReq = new AddSolutionComponentRequest()
            {
                ComponentType         = 1,
                ComponentId           = (Guid)retrieveconfigEntityResponse.EntityMetadata.MetadataId,
                SolutionUniqueName    = solution.UniqueName,
                AddRequiredComponents = true
            };

            _serviceProxy.Execute(addConfigReq);

            //assign web resource to slution
            CreateWebResource(solution.UniqueName);

            //assign configuration page above created to solution
            AssiginConfigurationPageToSolution(_webResourceIdForSolution[0], solution.UniqueName);

            ExportSolutionRequest exportSolutionRequest = new ExportSolutionRequest();

            exportSolutionRequest.Managed      = false;
            exportSolutionRequest.SolutionName = solution.UniqueName;

            ExportSolutionResponse exportSolutionResponse = (ExportSolutionResponse)_serviceProxy.Execute(exportSolutionRequest);

            byte[] exportXml = exportSolutionResponse.ExportSolutionFile;
            System.IO.Directory.CreateDirectory(_outputDir);
            File.WriteAllBytes(_managedSolutionLocation, exportXml);

            // Delete the solution and the components so it can be installed.

            DeleteOptionSetRequest delOptSetReq = new DeleteOptionSetRequest {
                Name = (_tempCustomizationPrefix + _TempGlobalOptionSetName).ToLower()
            };

            _serviceProxy.Execute(delOptSetReq);

            DeleteEntityRequest delEntReq = new DeleteEntityRequest {
                LogicalName = (_customEntityName)
            };

            _serviceProxy.Execute(delEntReq);

            DeleteEntityRequest delEntReqConfig = new DeleteEntityRequest {
                LogicalName = (_customConfigurationEntityName)
            };

            _serviceProxy.Execute(delEntReqConfig);


            if (_solutionCreated)
            {
                _serviceProxy.Delete(Solution.EntityLogicalName, _tempSolutionsSampleSolutionId);

                //delete webresorce
                foreach (var _id in _webResourceIds)
                {
                    _serviceProxy.Delete(WebResource.EntityLogicalName, _id);
                }
                //for configuration page above created delete
                _serviceProxy.Delete(WebResource.EntityLogicalName, _webResourceIdForSolution[0]);
            }

            if (_publisherCreated)
            {
                _serviceProxy.Delete(Publisher.EntityLogicalName, _tempPublisherId);
            }

            Console.WriteLine("Managed Solution created and copied to {0}", _managedSolutionLocation);
        }
        /// <summary>
        /// Deletes any entity records and files 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 void DeleteRequiredRecords(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)
            {
                DeleteEntityRequest del = new DeleteEntityRequest()
                {
                    LogicalName = "new_tweet",
                };
                _serviceProxy.Execute(del);
                _serviceProxy.Delete(FieldSecurityProfile.EntityLogicalName, _profileId);
                _serviceProxy.Delete(Team.EntityLogicalName, _teamId);
                Console.WriteLine("Entity records have been deleted.");
            }
        }
Exemple #34
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 void DeleteImageAttributeDemoEntity(bool prompt)
  {
   bool deleteRecords = true;

   if (prompt)
   {
    Console.WriteLine("\nDo you want to delete the entity created for this sample? (y/n) [y]: ");
    String answer = Console.ReadLine();

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

   if (deleteRecords)
   {
    DeleteEntityRequest der = new DeleteEntityRequest() { LogicalName = _customEntityName.ToLower() };
    _serviceProxy.Execute(der);
    Console.WriteLine("The Image Attribute Demo entity has been deleted.");
   }
  }
 public IActionResult Delete([FromBody] DeleteEntityRequest deleteUserRequest)
 {
     this.flowManager.FlowDataCache.Request = deleteUserRequest;
     this.flowManager.Start("deleteuser");
     return(Ok(this.flowManager.FlowDataCache.Response));
 }
  protected void deleteCustomEntityWithOptionSet()
  {

   DeleteEntityRequest request = new DeleteEntityRequest()
   {
    LogicalName = _customEntitySchemaName.ToLower(),
   };
   _service.Execute(request);


  }