public void GenerateEarlyBoundEntities(string connectionstring, List <string> entities, List <string> globalOptionSets, List <string> actions, string @namespace, string filepath, string servicecontextname) { if (string.IsNullOrWhiteSpace(servicecontextname)) { servicecontextname = null; } var intepret = Utility.InterpretConnectionstring.Interpret(connectionstring); if (actions != null) { actions = actions.Select(x => x.ToLower()).ToList(); } var service = Connection.CrmConnection.GetClientByConnectionString(connectionstring); var globalOptionSetDepedencies = new List <XrmEarlyBound.Utility.ListItem>(); //new Dictionary<string, string>(); foreach (var gos in globalOptionSets) { var response = (RetrieveOptionSetResponse)service.Execute(new RetrieveOptionSetRequest { Name = gos }); RetrieveDependentComponentsRequest dependencyRequest = new RetrieveDependentComponentsRequest { ObjectId = response.OptionSetMetadata.MetadataId.Value, ComponentType = 9 }; var result = (RetrieveDependentComponentsResponse)service.Execute(dependencyRequest); foreach (var dep in result.EntityCollection.Entities) { var dependentcomponentobjectid = (Guid)dep.Attributes["dependentcomponentobjectid"]; var _result = (RetrieveAttributeResponse)service.Execute(new RetrieveAttributeRequest { MetadataId = dependentcomponentobjectid }); if (_result.AttributeMetadata != null && _result.AttributeMetadata.EntityLogicalName != null && _result.AttributeMetadata.LogicalName != null) { globalOptionSetDepedencies.Add(new Utility.ListItem { Item1 = $"{_result.AttributeMetadata.EntityLogicalName.ToLower()}_{_result.AttributeMetadata.LogicalName.ToLower()}", Item2 = gos }); } } } var config = new Utility.Config { Entites = entities, Actions = actions, GlobalOptionSets = globalOptionSets, GlobalOptionSetsDepedencies = globalOptionSetDepedencies }; config.Save(); var hasActions = actions != null ? actions.Count > 0 : false; var outpath = GetPath(filepath); Utility.RunSvcProcess.Run(intepret.Url, intepret.UserName, intepret.Domain, intepret.Password, @namespace, filepath, hasActions, servicecontextname, ShowMessage); config.Delete(); }
public FilteringService(ICodeWriterFilterService defaultService) { this.DefaultService = defaultService; config = XrmEarlyBound.Utility.Config.LoadSettings(); GeneratedOptionSets = new Dictionary <String, bool>(); }