Wie füge ich mithilfe von FormsConnectorDefinitionsExtender ein Auswahlfeld-Dropdown-Menü zum Einstellungsabschnitt für C#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Wie füge ich mithilfe von FormsConnectorDefinitionsExtender ein Auswahlfeld-Dropdown-Menü zum Einstellungsabschnitt für

Post by Anonymous »

Ich versuche, mithilfe von FormsConnectorDefinitionsExtender ein Dropdown-Menü zum Abschnitt „connectorsSettings“ im Formularersteller hinzuzufügen.
Mein Feld wird hinzugefügt, aber nur die erste Auswahl wird gerendert und als Kontrollkästchen gerendert. Ich kann es im Backend sehen und die Auswahlmöglichkeiten sehen.
Wenn ich ein anderes integriertes Feld wie Einschränkungen ändere, indem ich es von einem Optionsfeld in ein Dropdown ändere, wird das korrekt gerendert, mein Feld jedoch nicht.
Ich verwende .NET 4.8 – sf v15.3
Der vollständige Code ist unten und ich führe ihn in einem brandneuen Projekt-Setup aus. Abgesehen davon gibt es keine weiteren Änderungen oder Anpassungen ein dynamisches Modul. Beachten Sie, dass im bereitgestellten Screenshot Auswahlmöglichkeiten fehlen, da ich verschiedene Dinge ausprobiert habe.

Code: Select all

public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
Bootstrapper.Bootstrapped += Bootstrapper_Bootstrapped;
}

private void Bootstrapper_Bootstrapped(object sender, EventArgs e)
{
ObjectFactory.Container.RegisterType("CrmWorkflowConnectorExtender");
ObjectFactory.Container.RegisterType(typeof(CrmWorkflowConnectorExtenderConnectionStatus).FullName, new ContainerControlledLifetimeManager());
}
}

public class CrmWorkflowConnectorExtender : FormsConnectorDefinitionsExtender
{
public override int Ordinal
{
get { return 1; }
}

public override string ConnectorName => "CrmConnectorModule";
public override string ConnectorTitle => "CRM Connector";
public override string SectionTitle => "Send data to dynamics CRM";

public override void AddConnectorSettings(ConfigElementDictionary sectionFields)
{
var CRMWorkflowField = new ChoiceFieldElement(sectionFields)
{
Title = "Select CRM Workflow",
FieldName = "CRMWorkflowSelection",
DataFieldName = "CRMWorkflowSelection",
DisplayMode = FieldDisplayMode.Write,
FieldType = typeof(Telerik.Sitefinity.Web.UI.Fields.ChoiceField),
RenderChoiceAs = RenderChoicesAs.DropDown,
ID = "CRMWorkflowSelectionID"
};

//foreach (var workflow in GetWorkflowDefinitions())
//{
//    var choice = new ChoiceElement(CRMWorkflowField.ChoicesConfig)
//    {
//        Text = workflow.WorkflowName,
//        Value = workflow.WorkflowName
//    };
//    CRMWorkflowField.ChoicesConfig.Add(choice);
//}

var mychoices = new List();
mychoices.Add(new ChoiceDefinition()
{
Text = "MVCOnly",
ResourceClassId = typeof(FormsResources).Name,
Value = "0"
});

mychoices.Add(new ChoiceDefinition()
{
Text = "WebFormsOnly",
ResourceClassId = typeof(FormsResources).Name,
Value = "1"
});

CRMWorkflowField.Choices.AddRange(mychoices);
sectionFields.Add(CRMWorkflowField.ID, CRMWorkflowField);
}

private IEnumerable GetWorkflowDefinitions()
{
var manager = DynamicModuleManager.GetManager();
var type = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.CrmWorkflows.WorkflowDefinition");

IEnumerable workflows = manager.GetDataItems(type)
.Where(w => w.Status == ContentLifecycleStatus.Live && w.Visible)
.Select(w => new WorkflowDefinitionDto
{
WorkflowName = w.GetValue("WorkflowName")
});

return workflows;
}

private class WorkflowDefinitionDto
{
public string WorkflowName { get; set; }
}
}

public class CrmWorkflowConnectorExtenderConnectionStatus : IModuleConnectionStatus
{
public string ModuleName => "CrmConnector.CrmConnectorModule";

public void ExecuteIfConfigured(Action action)
{
// Add code to check that the connector is connected
// ex. if (this.connector.IsConnected())
if (action != null)
action();
}

// IMPORTANT: This callback is not invoked as part of Forms connectors. You still need to implement it, as it is used elsewhere.
public void ExecuteIfNotConfigured(Action action)
{
// Add code to check that the connector is not configured
// ex.  if (!this.connector.IsConnected())
if (action != null)
action();
}
}
Fehler:

Typ: System.ArgumentException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Nachricht: Ein Element mit demselben Schlüssel wurde bereits hinzugefügt.

Quelle: mscorlib

Hilfelink: ParamName: Daten: System.Collections.ListDictionaryInternal

TargetSite: void ThrowArgumentException(System.ExceptionResource)

HResult: -2147024809

Stack Trace:

bei System.ThrowHelper.ThrowArgumentException(ExceptionResource resources)

bei System.Collections.Generic.Dictionary 2.Insert(TKey-Schlüssel, TValue-Wert, boolesche Addition)

bei Telerik.Sitefinity.Web.Api.Strategies.Forms.Connectors.FormConnectorService.ResolveUIField(List 1-Felder, FieldDefinitionElement fieldDefinitionElement, ConnectorDataMappingExtender-MappingExtender, SectionFieldWrapper previousField)

at Telerik.Sitefinity.Web.Api.Strategies.Forms.Connectors.FormConnectorService.AdjustFields(List`1
fields, SectionFieldWrapper previousField)

Image

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post