private void AddGenerateMappingsWhenExcelFileSelected()
        {
            var customFunction = new OnChangeFunction((RecordEntryViewModelBase revm, string changedField) =>
            {
                switch (changedField)
                {
                case nameof(ImportExcelRequest.ExcelFile):
                    {
                        if (revm.GetFieldViewModel(nameof(ImportExcelRequest.ExcelFile)).ValueObject != null)
                        {
                            var mappings = revm.GetEnumerableFieldViewModel(nameof(ImportExcelRequest.Mappings));
                            if (mappings.DynamicGridViewModel != null &&
                                mappings.GridRecords != null &&
                                !mappings.GridRecords.Any())
                            {
                                GenerateMappings(mappings.DynamicGridViewModel);
                            }
                        }
                        break;
                    }
                }
            });

            this.AddOnChangeFunction(customFunction, typeof(ImportExcelRequest));
        }
Esempio n. 2
0
        private void OpenToolingConnectorOnConfigurationForm()
        {
            var customFunction = new OnChangeFunction((RecordEntryViewModelBase revm, string changedField) =>
            {
                try
                {
                    switch (changedField)
                    {
                    case nameof(SavedXrmRecordConfiguration.UseXrmToolingConnector):
                        {
                            if (!(revm is GridRowViewModel))
                            {
                                var useToolingConnectorViewModel = revm.GetBooleanFieldFieldViewModel(nameof(SavedXrmRecordConfiguration.UseXrmToolingConnector));
                                if (useToolingConnectorViewModel.Value ?? false)
                                {
                                    var connectionIdViewModel = revm.GetStringFieldFieldViewModel(nameof(SavedXrmRecordConfiguration.ToolingConnectionId));
                                    if (string.IsNullOrWhiteSpace(connectionIdViewModel.Value))
                                    {
                                        try
                                        {
                                            connectionIdViewModel.Value = $"{ApplicationController.ApplicationName}_{Guid.NewGuid().ToString()}";
                                            var objectRecord            = revm.GetRecord() as ObjectRecord;
                                            if (objectRecord == null)
                                            {
                                                throw new Exception($"Expected Form Record Of Type {nameof(ObjectRecord)}. Actual Type Is {revm.GetRecord().GetType().Name}");
                                            }
                                            var xrmConfiguration = objectRecord.Instance as SavedXrmRecordConfiguration;
                                            if (xrmConfiguration == null)
                                            {
                                                throw new Exception($"Expected Form Object Of Type {nameof(SavedXrmRecordConfiguration)}. Actual Type Is {objectRecord.Instance.GetType().Name}");
                                            }
                                            var serviceFactory   = ApplicationController.ResolveType <IOrganizationConnectionFactory>();
                                            var xrmRecordService = new XrmRecordService(xrmConfiguration, serviceFactory);
                                            var verifyConnection = xrmRecordService.VerifyConnection();
                                            if (!verifyConnection.IsValid)
                                            {
                                                throw new Exception(verifyConnection.GetErrorString());
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            useToolingConnectorViewModel.Value = false;
                                            connectionIdViewModel.Value        = null;
                                            revm.ApplicationController.ThrowException(ex);
                                        }
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    revm.ApplicationController.ThrowException(ex);
                }
            });

            this.AddOnChangeFunction(customFunction, typeof(SavedXrmRecordConfiguration));
        }
Esempio n. 3
0
        public static void AddOnChangeFunction(this ModuleBase module, OnChangeFunction onChangeFunction, 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 customFunctions = (OnChangeFunctions)module.ApplicationController.ResolveInstance(typeof(OnChangeFunctions), type.AssemblyQualifiedName);

            customFunctions.AddFunction(onChangeFunction);
            module.ApplicationController.RegisterInstance(typeof(OnChangeFunctions), type.AssemblyQualifiedName, customFunctions);
        }
        private void AutoOpenSelections()
        {
            var customFunction = new OnChangeFunction((RecordEntryViewModelBase revm, string changedField) =>
            {
                try
                {
                    if (revm is GridRowViewModel)
                    {
                        switch (changedField)
                        {
                        case nameof(ExportRecordType.IncludeAllFields):
                            {
                                if (!revm.GetBooleanFieldFieldViewModel(nameof(ExportRecordType.IncludeAllFields)).Value ?? false)
                                {
                                    var fieldsIncludedViewModel = revm.GetEnumerableFieldViewModel(nameof(ExportRecordType.IncludeOnlyTheseFields));
                                    if (fieldsIncludedViewModel.Value == null || !fieldsIncludedViewModel.Value.GetEnumerator().MoveNext())
                                    {
                                        fieldsIncludedViewModel.BulkAddButton?.Invoke();
                                    }
                                }
                                break;
                            }

                        case nameof(ExportRecordType.Type):
                            {
                                if (revm.GetPicklistFieldFieldViewModel(nameof(ExportRecordType.Type)).Value == PicklistOption.EnumToPicklistOption(ExportType.SpecificRecords))
                                {
                                    var recordsIncludedViewModel = revm.GetEnumerableFieldViewModel(nameof(ExportRecordType.SpecificRecordsToExport));
                                    if (recordsIncludedViewModel.Value == null || !recordsIncludedViewModel.Value.GetEnumerator().MoveNext())
                                    {
                                        recordsIncludedViewModel.BulkAddButton?.Invoke();
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    revm.ApplicationController.ThrowException(ex);
                }
            });

            this.AddOnChangeFunction(customFunction, typeof(ExportRecordType));
        }
        private void AddGenerateColumnMappingsTargetTypeSelected()
        {
            var customFunction = new OnChangeFunction((RecordEntryViewModelBase revm, string changedField) =>
            {
                switch (changedField)
                {
                case nameof(ImportExcelRequest.ExcelImportTabMapping.TargetType):
                    {
                        if (revm.GetFieldViewModel(nameof(ImportExcelRequest.ExcelImportTabMapping.SourceTab)).ValueObject != null &&
                            revm.GetFieldViewModel(nameof(ImportExcelRequest.ExcelImportTabMapping.TargetType)).ValueObject != null)
                        {
                            var mappings = revm.GetEnumerableFieldViewModel(nameof(ImportExcelRequest.ExcelImportTabMapping.Mappings));
                        }
                        break;
                    }
                }
            });

            this.AddOnChangeFunction(customFunction, typeof(ImportExcelRequest.ExcelImportTabMapping));
        }
Esempio n. 6
0
        private void AddGenerateMappingsWhenCsvFileSelected()
        {
            var customFunction = new OnChangeFunction((RecordEntryViewModelBase revm, string changedField) =>
            {
                switch (changedField)
                {
                case nameof(ImportCsvsRequest.CsvToImport.SourceCsv):
                    {
                        if (revm.GetFieldViewModel(nameof(ImportCsvsRequest.CsvToImport.SourceCsv)).ValueObject != null)
                        {
                            var mappings = revm.GetEnumerableFieldViewModel(nameof(ImportCsvsRequest.CsvToImport.Mappings));
                            if (mappings.Enumerable == null ||
                                !mappings.Enumerable.GetEnumerator().MoveNext())
                            {
                                GenerateMappings(revm);
                            }
                        }
                        break;
                    }
                }
            });

            this.AddOnChangeFunction(customFunction, typeof(ImportCsvsRequest.CsvToImport));
        }
Esempio n. 7
0
        private void AddRecordsForSelectionInAddPortalRecords()
        {
            var customFunction = new OnChangeFunction((RecordEntryViewModelBase revm, string changedField) =>
            {
                switch (changedField)
                {
                case nameof(AddPortalCodeRequest.PortalRecordsToExport.IncludeAll):
                    {
                        if (!revm.GetBooleanFieldFieldViewModel(nameof(AddPortalCodeRequest.PortalRecordsToExport.IncludeAll)).Value)
                        {
                            var parentForm = revm.ParentForm;
                            if (parentForm == null)
                            {
                                throw new Exception("Cannot get parent form");
                            }
                            parentForm.LoadingViewModel.IsLoading = true;
                            revm.DoOnAsynchThread(() =>
                            {
                                try
                                {
                                    var recordType = revm.GetRecordTypeFieldViewModel(nameof(AddPortalCodeRequest.PortalRecordsToExport.RecordType)).Value?.Key;
                                    if (recordType == null)
                                    {
                                        throw new NullReferenceException($"Error {nameof(AddPortalCodeRequest.PortalRecordsToExport.RecordType)} is null");
                                    }
                                    var lookupService = revm.RecordService.LookupService;
                                    var websiteId     = parentForm.GetLookupFieldFieldViewModel(nameof(AddPortalCodeRequest.WebSite)).Value?.Id;
                                    if (websiteId == null)
                                    {
                                        revm.GetBooleanFieldFieldViewModel(nameof(AddPortalCodeRequest.PortalRecordsToExport.IncludeAll)).Value = true;
                                        revm.ApplicationController.UserMessage("Please Select The Website Before Selecting Records For Inclusion");
                                        return;
                                    }

                                    var results = AddPortalCodeConfiguration.GetRecordsForConfig(recordType, lookupService, websiteId);
                                    if (!results.Any())
                                    {
                                        revm.GetBooleanFieldFieldViewModel(nameof(AddPortalCodeRequest.PortalRecordsToExport.IncludeAll)).Value = true;
                                        revm.ApplicationController.UserMessage("Sorry There No Records Of This Type Were Identified For Selection");
                                    }
                                    else
                                    {
                                        var grid              = revm.GetEnumerableFieldViewModel(nameof(AddPortalCodeRequest.PortalRecordsToExport.RecordsToInclude));
                                        var nameField         = lookupService.GetPrimaryField(recordType);
                                        var itemsForSelection = results
                                                                .Select(r => new AddPortalCodeRequest.PortalRecordsToExport.SelectableRecordToInclude(r.Id, r.GetStringField(nameField)))
                                                                .ToArray();
                                        revm.GetFieldViewModel(nameof(AddPortalCodeRequest.PortalRecordsToExport.RecordsToInclude)).ValueObject = itemsForSelection;
                                        revm.OnPropertyChanged(nameof(AddPortalCodeRequest.PortalRecordsToExport.RecordsToInclude));

                                        //okay so lets autoload the multi select
                                        //if user has selected not to inlude all, then naturally they will have to select which specific ones
                                        //so lets save a click!
                                        grid.BulkAddButton.Invoke();
                                    }
                                }
                                catch (Exception ex)
                                {
                                    revm.ApplicationController.ThrowException(ex);
                                }
                                finally
                                {
                                    parentForm.LoadingViewModel.IsLoading = false;
                                }
                            });
                        }
                        break;
                    }
                }
            });

            this.AddOnChangeFunction(customFunction, typeof(AddPortalCodeRequest.PortalRecordsToExport));
        }
Esempio n. 8
0
        #pragma warning disable 1998
        protected override void BuildRenderTree(Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder)
        {
            __Blazor.SurcosBlazor.Client.Shared.RadioButtonGeneric.TypeInference.CreateListadoGenerico_0(__builder, 0, 1,
#line 3 "C:\Users\agust\source\repos\SurcosBlazor\Client\Shared\RadioButtonGeneric.razor"
                                                                                                         listado

#line default
#line hidden
                                                                                                         , 2, (__builder2) => {
                __builder2.AddMarkupContent(3, "\r\n        ");
                __builder2.OpenElement(4, "div");
                __builder2.AddAttribute(5, "class",
#line 5 "C:\Users\agust\source\repos\SurcosBlazor\Client\Shared\RadioButtonGeneric.razor"
                                        $"RadiobuttonGenerico"

#line default
#line hidden
                                        );
                __builder2.AddMarkupContent(6, "\r\n");
#line 6 "C:\Users\agust\source\repos\SurcosBlazor\Client\Shared\RadioButtonGeneric.razor"
                foreach (T item in listado)
                {
#line default
#line hidden
#line 8 "C:\Users\agust\source\repos\SurcosBlazor\Client\Shared\RadioButtonGeneric.razor"
                    if (this.item != null && this.item.Equals(item))
                    {
#line default
#line hidden
                        __builder2.AddContent(7, "                    ");
                        __builder2.OpenElement(8, "input");
                        __builder2.AddAttribute(9, "checked", true);
                        __builder2.AddAttribute(10, "onclick", Microsoft.AspNetCore.Components.EventCallback.Factory.Create <Microsoft.AspNetCore.Components.Web.MouseEventArgs>(this,
#line 10 "C:\Users\agust\source\repos\SurcosBlazor\Client\Shared\RadioButtonGeneric.razor"
                                                                                                                                                                                 (() => OnChangeFunction.InvokeAsync(item))

#line default
#line hidden
                                                                                                                                                                                 ));
                        __builder2.AddAttribute(11, "type", "radio");
                        __builder2.AddAttribute(12, "name",
#line 10 "C:\Users\agust\source\repos\SurcosBlazor\Client\Shared\RadioButtonGeneric.razor"
                                                $"RadiobuttonGenerico{item.GetType().Name}"

#line default
#line hidden
                                                );
                        __builder2.CloseElement();
                        __builder2.AddMarkupContent(13, "\r\n                    ");
                        __builder2.OpenElement(14, "span");
                        __builder2.AddContent(15,
#line 11 "C:\Users\agust\source\repos\SurcosBlazor\Client\Shared\RadioButtonGeneric.razor"
                                              item.GetType().GetProperty(propAMostrar).GetValue(item, null)

#line default
#line hidden
                                              );
                        __builder2.CloseElement();
                        __builder2.AddMarkupContent(16, "\r\n");
#line 12 "C:\Users\agust\source\repos\SurcosBlazor\Client\Shared\RadioButtonGeneric.razor"
                    }
                    else
                    {
#line default
#line hidden
                        __builder2.AddContent(17, "                    ");
                        __builder2.OpenElement(18, "input");
                        __builder2.AddAttribute(19, "onclick", Microsoft.AspNetCore.Components.EventCallback.Factory.Create <Microsoft.AspNetCore.Components.Web.MouseEventArgs>(this,
#line 15 "C:\Users\agust\source\repos\SurcosBlazor\Client\Shared\RadioButtonGeneric.razor"
                                                                                                                                                                                 (() => OnChangeFunction.InvokeAsync(item))

#line default
#line hidden
                                                                                                                                                                                 ));
                        __builder2.AddAttribute(20, "type", "radio");
                        __builder2.AddAttribute(21, "name",
#line 15 "C:\Users\agust\source\repos\SurcosBlazor\Client\Shared\RadioButtonGeneric.razor"
                                                $"RadiobuttonGenerico{item.GetType().Name}"

#line default
#line hidden
                                                );
                        __builder2.CloseElement();
                        __builder2.AddMarkupContent(22, "\r\n                    ");
                        __builder2.OpenElement(23, "span");
                        __builder2.AddContent(24,
#line 16 "C:\Users\agust\source\repos\SurcosBlazor\Client\Shared\RadioButtonGeneric.razor"
                                              item.GetType().GetProperty(propAMostrar).GetValue(item, null)

#line default
#line hidden
                                              );
                        __builder2.CloseElement();
                        __builder2.AddMarkupContent(25, "\r\n");
#line 17 "C:\Users\agust\source\repos\SurcosBlazor\Client\Shared\RadioButtonGeneric.razor"
                    }

#line default
#line hidden
#line 18 "C:\Users\agust\source\repos\SurcosBlazor\Client\Shared\RadioButtonGeneric.razor"
                }

#line default
#line hidden
                __builder2.AddContent(26, "        ");
                __builder2.CloseElement();
                __builder2.AddMarkupContent(27, "\r\n    ");
            }
                                                                                                         );
        }