private void AddOImportExcelToSavedConnectionsGrid() { var customGridFunction = new CustomGridFunction("IMPORTEEXCEL", "Import Excel", (g) => { if (g.SelectedRows.Count() != 1) { g.ApplicationController.UserMessage("Please Select One Row To Run This Function"); } else { var selectedRow = g.SelectedRows.First(); var instance = ((ObjectRecord)selectedRow.Record).Instance as SavedXrmRecordConfiguration; if (instance != null) { var xrmRecordService = new XrmRecordService(instance, formService: new XrmFormService()); var exportXmlService = new ImportExcelService(xrmRecordService); var dialog = new ImportExcelDialog(exportXmlService, new DialogController(ApplicationController), xrmRecordService); dialog.SetTabLabel(instance.ToString() + " " + dialog.TabLabel); g.ApplicationController.NavigateTo(dialog); } } }, (g) => g.GridRecords != null && g.GridRecords.Any()); this.AddCustomGridFunction(customGridFunction, typeof(SavedXrmRecordConfiguration)); }
private void AddWebBrowseGridFunction() { var customGridFunction = new CustomGridFunction("WEB", "Open In Web", (g) => { if (g.SelectedRows.Count() != 1) { g.ApplicationController.UserMessage("Please Select One Row To Browse The Connection"); } else { ApplicationController.DoOnAsyncThread(() => { var selectedRow = g.SelectedRows.First(); var instance = ((ObjectRecord)selectedRow.Record).Instance as SavedXrmRecordConfiguration; if (instance != null) { var serviceFactory = ApplicationController.ResolveType <IOrganizationConnectionFactory>(); var xrmRecordService = new XrmRecordService(instance, serviceFactory); Process.Start(xrmRecordService.WebUrl); } }); } }, (g) => g.GridRecords != null && g.GridRecords.Any()); this.AddCustomGridFunction(customGridFunction, typeof(SavedXrmRecordConfiguration)); }
private void AddTextSearchButtonToSavedConnectionsGrid() { var customGridFunction = new CustomGridFunction("TEXTSEARCH", "Text Search Selected", (g) => { if (g.SelectedRows.Count() != 1) { g.ApplicationController.UserMessage("Please Select One Row To Search The Connection"); } else { var selectedRow = g.SelectedRows.First(); var instance = ((ObjectRecord)selectedRow.Record).Instance as SavedXrmRecordConfiguration; if (instance != null) { var xrmRecordService = new XrmRecordService(instance, formService: new XrmFormService()); var xrmTextSearchService = new XrmTextSearchService(xrmRecordService, new DocumentWriter.DocumentWriter()); var dialog = new XrmTextSearchDialog(xrmTextSearchService, new DialogController(ApplicationController), xrmRecordService); dialog.SetTabLabel("Text Search " + instance.Name); g.LoadDialog(dialog); } } }, (g) => g.GridRecords != null && g.GridRecords.Any()); this.AddCustomGridFunction(customGridFunction, typeof(SavedXrmRecordConfiguration)); }
private void AddExportButtonToSavedConnectionsGrid() { var customGridFunction = new CustomGridFunction("CUSTOMISATIONEXPORT", "Customisation Export", (g) => { if (g.SelectedRows.Count() != 1) { g.ApplicationController.UserMessage("Please Select One Row To Run This Function"); } else { var selectedRow = g.SelectedRows.First(); var instance = ((ObjectRecord)selectedRow.Record).Instance as SavedXrmRecordConfiguration; if (instance != null) { var xrmRecordService = new XrmRecordService(instance, formService: new XrmFormService()); var xrmTextSearchService = new CustomisationExporterService(xrmRecordService); var dialog = new CustomisationExporterDialog(xrmTextSearchService, new DialogController(ApplicationController), xrmRecordService); dialog.SetTabLabel(instance.Name + " " + dialog.TabLabel); g.ApplicationController.NavigateTo(dialog); } } }, (g) => g.GridRecords != null && g.GridRecords.Any()); this.AddCustomGridFunction(customGridFunction, typeof(SavedXrmRecordConfiguration)); }
private void AddLoadResultItemToGridFunction() { //adds a button the search results summary //to load the matches for a particular type and/or field to a grid for editing var customGridFunction = new CustomGridFunction("LOADTOGRID", "Load Matches To Grid", (DynamicGridViewModel g) => { if (g.SelectedRows.Count() != 1) { g.ApplicationController.UserMessage("1 Row Must Be Selected For Loading Records"); } else { var selectedItem = g.SelectedRows.First().GetRecord() as ObjectRecord; if (selectedItem == null) { throw new Exception($"Error selected item is not of type {typeof(ObjectRecord).Name}"); } var summaryItem = selectedItem.Instance as TextSearchResponse.SummaryItem; if (summaryItem == null) { throw new Exception($"Error selected item is not of type {typeof(TextSearchResponse.SummaryItem).Name}"); } var dialogController = new DialogController(g.ApplicationController); var dialog = new EditResultsDialog(dialogController, summaryItem, g.RemoveParentDialog); g.LoadDialog(dialog); } }, (g) => g.GridRecords != null); this.AddCustomGridFunction(customGridFunction, typeof(TextSearchResponse.SummaryItem)); }
private void AddLoadFolderButton() { var customFormFunction = new CustomGridFunction("LOADFOLDER", "Load Folder", (DynamicGridViewModel g) => { try { var r = g.ParentForm; if (r == null) { throw new NullReferenceException("Could Not Load The Form. The ParentForm Is Null"); } var folder = g.ApplicationController.GetSaveFolderName(); if (!string.IsNullOrWhiteSpace(folder)) { var csvFiles = FileUtility.GetFiles(folder).Where(f => f.EndsWith(".csv")); var mappingGrid = r.GetEnumerableFieldViewModel(nameof(ImportCsvsRequest.CsvsToImport)); foreach (var csv in csvFiles) { var newRecord = r.RecordService.NewRecord(typeof(ImportCsvsRequest.CsvToImport).AssemblyQualifiedName); newRecord.SetField(nameof(ImportCsvsRequest.CsvToImport.SourceCsv), new FileReference(csv), r.RecordService); mappingGrid.InsertRecord(newRecord, 0); } } } catch (Exception ex) { g.ApplicationController.ThrowException(ex); } }, visibleFunction: (g) => true); this.AddCustomGridFunction(customFormFunction, typeof(ImportCsvsRequest.CsvToImport)); }
private void AddRecordCountButtonToSavedConnectionsGrid() { var customGridFunction = new CustomGridFunction("RECORDCOUNT", "Record Counts", (g) => { if (g.SelectedRows.Count() != 1) { g.ApplicationController.UserMessage("Please Select One Row To Run This Function"); } else { var selectedRow = g.SelectedRows.First(); var instance = ((ObjectRecord)selectedRow.Record).Instance as SavedXrmRecordConfiguration; if (instance != null) { var xrmRecordService = new XrmRecordService(instance, ApplicationController.ResolveType <IOrganizationConnectionFactory>(), formService: new XrmFormService()); var xrmTextSearchService = new RecordCountsService(xrmRecordService); var dialog = new RecordCountsDialog(xrmTextSearchService, new DialogController(ApplicationController), xrmRecordService); dialog.SetTabLabel(instance.Name + " " + dialog.TabLabel); g.ApplicationController.NavigateTo(dialog); } } }, (g) => g.GridRecords != null && g.GridRecords.Any()); this.AddCustomGridFunction(customGridFunction, typeof(SavedXrmRecordConfiguration)); }
private void AddExportXmlToSavedConnectionsGrid() { var customGridFunction = new CustomGridFunction("EXPORTXML", "Export XML", (g) => { if (g.SelectedRows.Count() != 1) { g.ApplicationController.UserMessage("Please Select One Row To Run This Function"); } else { var selectedRow = g.SelectedRows.First(); var instance = ((ObjectRecord)selectedRow.Record).Instance as SavedXrmRecordConfiguration; if (instance != null) { var xrmRecordService = new XrmRecordService(instance, ApplicationController.ResolveType <IOrganizationConnectionFactory>(), formService: new XrmFormService()); var exportXmlService = new ExportXmlService(xrmRecordService); var dialog = new ExportXmlDialog(exportXmlService, new DialogController(ApplicationController), xrmRecordService) { LoadedFromConnection = true }; dialog.SetTabLabel(instance.ToString() + " " + dialog.TabLabel); g.ApplicationController.NavigateTo(dialog); } } }, (g) => g.GridRecords != null && g.GridRecords.Any()); this.AddCustomGridFunction(customGridFunction, typeof(SavedXrmRecordConfiguration)); }
public void Load(RecordEntryViewModelBase recordForm, string subGridReference) { recordForm.DoOnMainThread(() => { try { var mainFormInContext = recordForm; if (recordForm is GridRowViewModel) { mainFormInContext = recordForm.ParentForm; } var closeFunction = new CustomGridFunction("RETURN", "Return", () => mainFormInContext.ClearChildForm()); var targetType = GetTargetType(recordForm, subGridReference); var selectedFunction = new CustomGridFunction("ADDSELECTED", "Add Selected", (g) => AddSelectedItems(g, recordForm, subGridReference) , visibleFunction: (g) => g.SelectedRows.Any()); var childForm = new QueryViewModel(new[] { targetType }, GetQueryLookupService(recordForm, subGridReference), recordForm.ApplicationController, allowQuery: AllowQuery, loadInitially: !AllowQuery, closeFunction: closeFunction, customFunctions: new[] { selectedFunction }); childForm.TypeAhead = TypeAhead; mainFormInContext.LoadChildForm(childForm); } catch (Exception ex) { recordForm.ApplicationController.ThrowException(ex); } finally { recordForm.LoadingViewModel.IsLoading = false; } }); }
public static void AddCustomGridFunction(this ModuleBase module, CustomGridFunction customGridFunction, Type type) { //okay this one is autmatically created by the unity container //but iteratively add and resolve 2 items and verify they are retained in the resolved list var customGridFunctions = (CustomGridFunctions)module.ApplicationController.ResolveInstance(typeof(CustomGridFunctions), type.AssemblyQualifiedName); customGridFunctions.AddFunction(customGridFunction); module.ApplicationController.RegisterInstance(typeof(CustomGridFunctions), type.AssemblyQualifiedName, customGridFunctions); }
private void AddPortalDataButtonToRequestFormGrid() { var customGridFunction = new CustomGridFunction("ADDPORTALDATA", "Add Portal Types", (DynamicGridViewModel g) => { try { var r = g.ParentForm; if (r == null) { throw new NullReferenceException("Could Not Load The Form. The ParentForm Is Null"); } r.GetBooleanFieldFieldViewModel(nameof(InstanceComparerRequest.Data)).Value = true; var typesGrid = r.GetEnumerableFieldViewModel(nameof(InstanceComparerRequest.DataComparisons)); var typesToAdd = new[] { "adx_contentsnippet", "adx_entityform", "adx_entityformmetadata", "adx_entitylist", "adx_entitypermission", "adx_pagetemplate", "adx_publishingstate", "adx_sitemarker", "adx_sitesetting", "adx_webfile", "adx_webform", "adx_webformmetadata", "adx_webformstep", "adx_weblink", "adx_weblinkset", "adx_webpage", "adx_webpageaccesscontrolrule", "adx_webrole", "adx_webtemplate", }; var typesGridService = typesGrid.GetRecordService(); foreach (var item in typesToAdd.Reverse()) { var newRecord = typesGridService.NewRecord(typeof(InstanceComparerRequest.InstanceCompareDataCompare).AssemblyQualifiedName); newRecord.SetField(nameof(InstanceComparerRequest.InstanceCompareDataCompare.RecordType), new RecordType(item, item), typesGridService); typesGrid.InsertRecord(newRecord, 0); } } catch (Exception ex) { g.ApplicationController.ThrowException(ex); } }, visibleFunction: (g) => { var lookupService = g.RecordService.GetLookupService(nameof(InstanceComparerRequest.InstanceCompareDataCompare.RecordType), typeof(InstanceComparerRequest.InstanceCompareDataCompare).AssemblyQualifiedName, nameof(InstanceComparerRequest.DataComparisons), null); return(lookupService != null && lookupService.RecordTypeExists("adx_webfile")); }); this.AddCustomGridFunction(customGridFunction, typeof(InstanceComparerRequest.InstanceCompareDataCompare)); }
private void AddWebBrowseGridFunction() { var customGridFunction = new CustomGridFunction("WEB", "Open In Web", (g) => { var selectedRow = g.SelectedRows.First(); var instance = ((ObjectRecord)selectedRow.Record).Instance as SavedXrmRecordConfiguration; if (instance != null) { var xrmRecordService = new XrmRecordService(instance); Process.Start(xrmRecordService.WebUrl); } }, (g) => g.GridRecords != null && g.SelectedRows.Count() == 1); this.AddCustomGridFunction(customGridFunction, typeof(SavedXrmRecordConfiguration)); }
private void AddProductTypesToCsvgenerationGrid() { var customFormFunction = new CustomGridFunction("ADDPRODUCTTYPES", "Add Product Types", (DynamicGridViewModel g) => { try { var r = g.ParentForm; if (r == null) { throw new NullReferenceException("Could Not Load The Form. The ParentForm Is Null"); } var typesGrid = r.GetEnumerableFieldViewModel(nameof(GenerateTemplatesRequest.CsvsToGenerate)); var typesToAdd = new Dictionary <string, IEnumerable <string> >() { { Entities.product, new [] { Fields.product_.name, Fields.product_.productnumber, Fields.product_.defaultuomid, Fields.product_.defaultuomscheduleid, Fields.product_.quantitydecimal, Fields.product_.statecode, Fields.product_.statuscode } }, { Entities.pricelevel, new [] { Fields.pricelevel_.name } }, { Entities.productpricelevel, new [] { Fields.productpricelevel_.pricelevelid, Fields.productpricelevel_.productid, Fields.productpricelevel_.uomscheduleid, Fields.productpricelevel_.uomid, Fields.productpricelevel_.amount, Fields.productpricelevel_.quantitysellingcode, Fields.productpricelevel_.pricingmethodcode } }, { Entities.uom, new [] { Fields.uom_.name, Fields.uom_.uomscheduleid, Fields.uom_.quantity, Fields.uom_.baseuom } }, { Entities.uomschedule, new [] { Fields.uomschedule_.name, Fields.uomschedule_.baseuomname } } }; var typesGridService = typesGrid.GetRecordService(); foreach (var item in typesToAdd.Reverse()) { var newRecord = typesGridService.NewRecord(typeof(GenerateTemplateConfiguration).AssemblyQualifiedName); newRecord.SetField(nameof(GenerateTemplateConfiguration.RecordType), new RecordType(item.Key, item.Key), typesGridService); newRecord.SetField(nameof(GenerateTemplateConfiguration.AllFields), false, typesGridService); newRecord.SetField(nameof(GenerateTemplateConfiguration.FieldsToInclude), item.Value.Select(f => new FieldSetting() { RecordField = new RecordField(f, f) }), typesGridService); typesGrid.InsertRecord(newRecord, 0); } } catch (Exception ex) { g.ApplicationController.ThrowException(ex); } }, visibleFunction: (g) => true); this.AddCustomGridFunction(customFormFunction, typeof(GenerateTemplateConfiguration)); }
private void AddBrowseButtonToSavedConnectionsGrid() { var customGridFunction = new CustomGridFunction("CRUD", "Crud/Query Selected", (g) => { if (g.SelectedRows.Count() != 1) { g.ApplicationController.UserMessage("Please Select One Row To Browse The Connection"); } else { var selectedRow = g.SelectedRows.First(); var instance = ((ObjectRecord)selectedRow.Record).Instance as SavedXrmRecordConfiguration; if (instance != null) { var xrmRecordService = new XrmRecordService(instance, formService: new XrmFormService()); var dialog = new XrmCrudDialog(xrmRecordService, new DialogController(ApplicationController)); dialog.SetTabLabel(instance.ToString() + " " + dialog.TabLabel); g.ApplicationController.NavigateTo(dialog); } } }, (g) => g.GridRecords != null && g.GridRecords.Any()); this.AddCustomGridFunction(customGridFunction, typeof(SavedXrmRecordConfiguration)); }
public QueryViewModel(IEnumerable <string> recordTypes, IRecordService recordService, IApplicationController controller, bool allowQuery = false, bool loadInitially = false, CustomGridFunction closeFunction = null , IEnumerable <CustomGridFunction> customFunctions = null, bool allowCrud = true) : base(controller) { AllowCrud = allowCrud; CustomFunctions = customFunctions; LoadInitially = loadInitially; AllowQuery = allowQuery; RecordService = recordService; if (closeFunction != null) { ReturnButton = new XrmButtonViewModel(closeFunction.LabelFunc(null), () => { closeFunction.Function(DynamicGridViewModel); }, controller); } QueryTypeButton = new XrmButtonViewModel("Change Query Type", ChangeQueryType, ApplicationController); LoadSavedViewButton = new XrmButtonViewModel("LOADVIEW", "Load Saved View", new XrmButtonViewModel[0], ApplicationController); DeleteSelectedConditionsButton = new XrmButtonViewModel("Delete Selected", () => DeleteSelected(), ApplicationController); GroupSelectedConditionsOr = new XrmButtonViewModel("Group Selected Or", () => GroupSelected(FilterOperator.Or), ApplicationController); GroupSelectedConditionsAnd = new XrmButtonViewModel("Group Selected And", () => GroupSelected(FilterOperator.And), ApplicationController); UngroupSelectedConditions = new XrmButtonViewModel("Ungroup Selected", () => UnGroupSelected(), ApplicationController); NotInDeleteSelectedConditionsButton = new XrmButtonViewModel("Delete Selected", () => DeleteSelected(isNotIn: true), ApplicationController); NotInGroupSelectedConditionsOr = new XrmButtonViewModel("Group Selected Or", () => GroupSelected(FilterOperator.Or, isNotIn: true), ApplicationController); NotInGroupSelectedConditionsAnd = new XrmButtonViewModel("Group Selected And", () => GroupSelected(FilterOperator.And, isNotIn: true), ApplicationController); NotInUngroupSelectedConditions = new XrmButtonViewModel("Ungroup Selected", () => UnGroupSelected(isNotIn: true), ApplicationController); RunQueryButton = new XrmButtonViewModel("Run Query", QuickFind, ApplicationController); IncludeNotInButton = new XrmButtonViewModel("Add Not In Query", NotInSwitch, ApplicationController); ChangeQueryType(); QueryTypeButton.IsVisible = AllowQuery; _recordTypes = recordTypes; if (_recordTypes.Count() == 1) { RecordType = _recordTypes.First(); } }
/// <summary> /// This function adds a button the the save setting grid to generate a .bat executable /// </summary> private void AddGenerateBatFunction() { var customGridFunction = new CustomGridFunction("GENERATEBAT", "Create Bat Exe", GenerateBat, (re) => { return(true); }); this.AddCustomGridFunction(customGridFunction, typeof(IAllowSaveAndLoad)); }
public QueryViewModel(IEnumerable <string> recordTypes, IRecordService recordService, IApplicationController controller, bool allowQuery = false, bool loadInitially = false, CustomGridFunction closeFunction = null , IEnumerable <CustomGridFunction> customFunctions = null) : base(controller) { CustomFunctions = customFunctions; LoadInitially = loadInitially; AllowQuery = allowQuery; RecordService = recordService; if (closeFunction != null) { ReturnButton = new XrmButtonViewModel(closeFunction.Label, () => { closeFunction.Function(DynamicGridViewModel); }, controller); } QueryTypeButton = new XrmButtonViewModel("Change Query Type", ChangeQueryType, ApplicationController); DeleteSelectedConditionsButton = new XrmButtonViewModel("Delete Selected", () => DeleteSelected(), ApplicationController); GroupSelectedConditionsOr = new XrmButtonViewModel("Group Selected Or", () => GroupSelected(FilterOperator.Or), ApplicationController); GroupSelectedConditionsAnd = new XrmButtonViewModel("Group Selected And", () => GroupSelected(FilterOperator.And), ApplicationController); UngroupSelectedConditions = new XrmButtonViewModel("Ungroup Selected", () => UnGroupSelected(), ApplicationController); ChangeQueryType(); QueryTypeButton.IsVisible = AllowQuery; _recordTypes = recordTypes; if (_recordTypes.Count() == 1) { RecordType = _recordTypes.First(); } }
/// <summary> /// This function adds load button onto the SavedRequests subgrid when the "Load/Edit Saved Details" is clicked /// </summary> private void AddSavedRequestLoadFunction() { var customGridFunction = new CustomGridFunction("LOADREQUEST", "Load Selected", LoadSelected, (re) => { return(true); }); this.AddCustomGridFunction(customGridFunction, typeof(IAllowSaveAndLoad)); }
private void AddComponentsToSolutionButtonInSummaryGrid() { var customGridFunction = new CustomGridFunction("ADDTOSOLUTION", "Add To Solution", new[] { new CustomGridFunction("ADDTOSOLUTIONC1", (g) => { try { var response = GetResponse(g); return(response.ServiceOne?.XrmRecordConfiguration?.ToString() ?? "Instance 1"); } catch (Exception ex) { g.ApplicationController.ThrowException(ex); return("Instance 1"); } }, (g) => { g.ApplicationController.DoOnAsyncThread(() => { try { g.ParentForm.LoadingViewModel.IsLoading = true; var response = GetResponse(g); var service = response.ServiceOne; var dialogController = new DialogController(g.ApplicationController); var items = response.AllDifferences .Where(d => d.ComponentTypeForSolution.HasValue && d.IdForSolution1 != null) .Select(d => new AddToSolutionItem(d.ComponentTypeForSolution.Value, d.IdForSolution1)) .ToArray(); var request = new AddToSolutionRequest(items, service); var dialog = new AddToSolutionDialog(service, dialogController, request: request, onClose: g.RemoveParentDialog); g.LoadDialog(dialog); } catch (Exception ex) { g.ApplicationController.ThrowException(ex); } finally { g.ParentForm.LoadingViewModel.IsLoading = false; } }); }, (g) => { try { var response = GetResponse(g); var items = response.AllDifferences .Where(d => d.ComponentTypeForSolution.HasValue && d.IdForSolution1 != null) .Select(d => new AddToSolutionItem(d.ComponentTypeForSolution.Value, d.IdForSolution1)) .ToArray(); return(items.Any()); } catch (Exception ex) { g.ApplicationController.ThrowException(ex); } return(false); } ), new CustomGridFunction("ADDTOSOLUTIONC2", (g) => { try { var response = GetResponse(g); return(response.ServiceTwo?.XrmRecordConfiguration?.ToString() ?? "Instance 2"); } catch (Exception ex) { g.ApplicationController.ThrowException(ex); return("Instance 2"); } }, (g) => { g.ApplicationController.DoOnAsyncThread(() => { try { g.ParentForm.LoadingViewModel.IsLoading = true; var response = GetResponse(g); var service = response.ServiceTwo; var dialogController = new DialogController(g.ApplicationController); var items = response.AllDifferences .Where(d => d.ComponentTypeForSolution.HasValue && d.IdForSolution2 != null) .Select(d => new AddToSolutionItem(d.ComponentTypeForSolution.Value, d.IdForSolution2)) .ToArray(); var request = new AddToSolutionRequest(items, service); var dialog = new AddToSolutionDialog(service, dialogController, request: request, onClose: g.RemoveParentDialog); g.LoadDialog(dialog); } catch (Exception ex) { g.ApplicationController.ThrowException(ex); } finally { g.ParentForm.LoadingViewModel.IsLoading = false; } }); }, (g) => { try { var response = GetResponse(g); var items = response.AllDifferences .Where(d => d.ComponentTypeForSolution.HasValue && d.IdForSolution2 != null) .Select(d => new AddToSolutionItem(d.ComponentTypeForSolution.Value, d.IdForSolution2)) .ToArray(); return(items.Any()); } catch (Exception ex) { g.ApplicationController.ThrowException(ex); } return(false); }) }); this.AddCustomGridFunction(customGridFunction, typeof(InstanceComparerTypeSummary)); }