Beispiel #1
0
    public Task <IEnumerable <DatasourceInfo> > GetGlxPoco(FormGenInfo data)
    {
        IDatasourceParser parser;

        if (data.IsGlxSchema)
        {
            parser = new slsSchemaTableParser(data.TableXmlPath);
        }
        else
        {
            parser = new POCOParser(data.AssemblyPath, data.ClassFullName);
        }
        var res = parser.Parse();

        return(Task.FromResult(res));
    }
    public async Task <IActionResult> Post([FromBody] FormGenInfo data)
    {
        var res = await _formGenService.GenerateFormDesigner(data);

        return(new JsonResult(res));
    }
Beispiel #3
0
    public Task <string> GenerateFormDesigner(FormGenInfo data)
    {
        var desInfo        = new DesignerInfo();
        var editorVisitors = new List <IEditorVisitor>();

        IFormEditorFactory formEditorFactory;

        if (data.IsGlxSchema)
        {
            slsSchemaTable schemaTable = new slsSchemaTableParser(data.TableXmlPath).GetSchemaTable();
            formEditorFactory = new GlxFormEditorFactory(schemaTable);
            desInfo.ClassName = schemaTable.Name + "F";

            var gxControls         = data.PropertiesInfo[0].FormEditor.StartsWith("gx");
            var safeCollectionName = schemaTable.Name.Remove(0, 2);
            data.PropertiesInfo.Insert(0, new FormEditorInfo {
                Name = safeCollectionName, FormEditor = gxControls ? "gxObjectCollectionSource" : "cmObjectCollectionSource"
            });
            data.PropertiesInfo.Insert(1, new FormEditorInfo {
                Name = safeCollectionName, FormEditor = gxControls ? "gxBindingSource" : "cmBindingSource"
            });
            data.PropertiesInfo.Insert(2, new FormEditorInfo {
                Name = safeCollectionName, FormEditor = gxControls ? "gxErrorProvider" : "cmErrorProvider"
            });

            data.PropertiesInfo.Add(new FormEditorInfo {
                FormEditor = "MainLayout"
            });
            data.PropertiesInfo.Add(new FormEditorInfo {
                FormEditor = "MainLayoutGroup"
            });
            data.PropertiesInfo.Add(new FormEditorInfo {
                FormEditor = "MainPanel"
            });
        }
        else
        {
            formEditorFactory = new PocoFormEditorFactory();
            var classFullNameSplit = data.ClassFullName.Split('.');
            desInfo.ClassName = classFullNameSplit[classFullNameSplit.Length - 1] + "F";
        }

        var editors = new List <IApplyFormEditor>();

        foreach (var info in data.PropertiesInfo)
        {
            IApplyFormEditor editor = formEditorFactory.Create(info);
            editors.Add(editor);
            if (editor is IEditorVisitor)
            {
                editorVisitors.Add(editor as IEditorVisitor);
            }
        }

        foreach (var editor in editors)
        {
            editor.Apply();
            VisitFormEditor(editorVisitors, editor);
            FillDesignerInfo(desInfo, editor);
        }

        var des = new CsDesignerTemplate();
        var res = des.GenerateDesigner(desInfo);

        return(Task.FromResult(res));
    }
    public async Task <IActionResult> GetGlxPoco([FromQuery] FormGenInfo data)
    {
        var res = await _formGenService.GetGlxPoco(data);

        return(new JsonResult(res));
    }