public void DrawTreeView(USDConfigurationData usdConfigData) { this.usdConfigData = usdConfigData; var usdTree = USDTree.GenerateUSDTree(usdConfigData); TreeViewGenerator.GenerateTreeViewFromHostedControls(treeView1, usdTree, checkBox1.Checked); }
private static List <Models.CRM.Action> GetSubActionsByActionId(USDConfigurationData usdConfigData, Guid actionId) { return(usdConfigData.ActionSubActionConnections.Where(c => c.ActionId == actionId).Select(c => { var subaction = usdConfigData.Actions.FirstOrDefault(sa => sa.Id == c.SubActionId); subaction.SubActions = GetSubActionsByActionId(usdConfigData, subaction.Id); return subaction; }).OrderBy(a => a.Order).ThenBy(a => a.Name).ToList()); }
public static List <HostedControl> GenerateUSDTree(USDConfigurationData usdConfigData) { return(usdConfigData.HostedControls.Select( h => { h.Events = usdConfigData.Events.Where(e => e.HostedControl != null && e.HostedControl.Id == h.Id).OrderBy(e => e.Name).Select( e => { e.Actions = usdConfigData.EventActionConnections.Where(c => c.EventId == e.Id).Select(c => usdConfigData.Actions.FirstOrDefault(a => a.Id == c.ActionId)).OrderBy(a => a.Order).ThenBy(a => a.Name).ToList(); e.Actions.ForEach(a => a.SubActions = GetSubActionsByActionId(usdConfigData, a.Id)); return e; }).ToList(); return h; }).ToList()); }
private void RefreshUSDConfigurationDataTree() { WorkAsync(new WorkAsyncInfo { Message = "Retrieving USD Configuration...", Work = (w, e) => { Helpers.GlobalProperties.WebApplicationUrl = ConnectionDetail.WebApplicationUrl; usdConfigData = new USDConfigurationData(); w.ReportProgress(0, "Retrieving Hosted Controls"); usdConfigData.HostedControls = HostedControlRepository.GetHostedControls(Service); w.ReportProgress(0, "Retrieving Events"); usdConfigData.Events = EventRepository.GetEvents(Service); w.ReportProgress(0, "Retrieving Actions"); usdConfigData.Actions = ActionRepository.GetActions(Service); w.ReportProgress(0, "Retrieving Event-Action Connections"); usdConfigData.EventActionConnections = EventActionConnectionRepository.GetEventActionConnections(Service); w.ReportProgress(0, "Retrieving Action-SubAction Connections"); usdConfigData.ActionSubActionConnections = ActionSubActionRepository.GetActionSubActionConnections(Service); w.ReportProgress(0, "Drawing Tree"); DrawTreeView(usdConfigData); tabControl1.Invoke((MethodInvoker) delegate { tabControl1.Enabled = true; }); e.Result = "Done"; }, ProgressChanged = e => { SetWorkingMessage(e.UserState.ToString()); }, PostWorkCallBack = e => { //MessageBox.Show($"You are { e.Result}"); }, AsyncArgument = null, IsCancelable = true, MessageWidth = 340, MessageHeight = 150 }); }
public static void Main(string[] args) { try { IOrganizationService Service = CreateIOrganizationService(@"*****@*****.**", @"-HXIAA#S0a#k!m\P", @"https://bdlabx-lmes-25-dev.api.crm4.dynamics.com/XRMServices/2011/Organization.svc"); var usdConfigData = new USDConfigurationData(); usdConfigData.HostedControls = HostedControlRepository.GetHostedControls(Service); usdConfigData.Events = EventRepository.GetEvents(Service); usdConfigData.Actions = ActionRepository.GetActions(Service); usdConfigData.EventActionConnections = EventActionConnectionRepository.GetEventActionConnections(Service); usdConfigData.ActionSubActionConnections = ActionSubActionRepository.GetActionSubActionConnections(Service); var usdTree = USDTree.GenerateUSDTree(usdConfigData); PrintUSDTree(usdTree); Console.ReadKey(); } catch (Exception ex) { string message = ex.Message; throw; } }