Ejemplo n.º 1
0
        void SetPageProperties(PropertyPage page, UIColumn column, string prefix = "")
        {
            page.Properties["ID"]          = prefix + column.ColumnName;
            page.Properties["Label"]       = column.ColumnText;
            page.Properties["DataField"]   = column.ColumnName;
            page.Properties["Placeholder"] = "Please, enter " + column.ColumnText;

            Dictionary <string, object> configs = column.ConfigContent.Configure();

            if (configs.ContainsKey("Options"))
            {
                List <ItemOption>           options = (List <ItemOption>)configs["Options"];
                Dictionary <string, string> items   = new Dictionary <string, string>();
                foreach (ItemOption opt in options)
                {
                    items.Add(opt.Value, opt.Text);
                }
                page.Properties["Items"] = items;
            }

            if (configs.ContainsKey("DataSource"))
            {
                page.Properties["QueryOrUrl"] = configs["DataSource"];
            }
            if (configs.ContainsKey("ValueMember"))
            {
                page.Properties["ValueMember"] = configs["ValueMember"];
            }
            if (configs.ContainsKey("DisplayMember"))
            {
                page.Properties["DisplayMember"] = configs["DisplayMember"];
            }
        }
Ejemplo n.º 2
0
        private void btnAddRow_Click(object sender, EventArgs e)
        {
            UIColumn column = CreateNewUIColumn();

            CurrentTable.DataColumns.Add(column);
            this.gridColumns.DataSource = null;
            this.gridColumns.DataSource = CurrentTable.DataColumns;
        }
Ejemplo n.º 3
0
        GridColumn CreateGridColumn(UIColumn col)
        {
            GridColumn column = new GridColumn();

            column.Field      = col.ColumnName;
            column.ColumnName = col.ColumnName;
            column.ColumnText = col.ColumnText;
            return(column);
        }
Ejemplo n.º 4
0
        public override UIColumn BusinessToUI(BUSColumn businessEntity)
        {
            UIColumn UIEntity = base.BusinessToUI(businessEntity);

            UIEntity.FieldName  = businessEntity.FieldName;
            UIEntity.ActionType = businessEntity.ActionType.ToString();
            UIEntity.Header     = businessEntity.Header;
            UIEntity.Type       = businessEntity.Type;
            UIEntity.Required   = businessEntity.Required;
            UIEntity.Readonly   = businessEntity.Readonly;
            return(UIEntity);
        }
Ejemplo n.º 5
0
 private void btnDeleteRow_Click(object sender, EventArgs e)
 {
     if (gridColumns.SelectedRows.Count > 0)
     {
         DataGridViewRow row     = this.gridColumns.SelectedRows[0];
         UIColumn        column  = (UIColumn)row.DataBoundItem;
         List <UIColumn> columns = (List <UIColumn>)gridColumns.DataSource;
         columns.Remove(column);
         gridColumns.DataSource = null;
         gridColumns.DataSource = columns;
     }
 }
Ejemplo n.º 6
0
        void DisplayUITable(DataSourceUITable uitable)
        {
            int  rowIdx      = 0;
            int  colIdx      = 0;
            bool skipThisCol = false;

            foreach (UIColumn col in uitable.DataColumns)
            {
                if (skipThisCol)
                {
                    skipThisCol = false;
                    colIdx++;
                    continue;
                }

                TableRow row = this.elementLayoutDesigner1.AddRow();
                if (colIdx + 1 < uitable.DataColumns.Count - 1)
                {
                    UIColumn nextCol = (UIColumn)uiTable.DataColumns[colIdx + 1];
                    if (col.CtrlType != ControlType.Hidden && nextCol.CtrlType != ControlType.Hidden && col.CtrlType != ControlType.Textarea && nextCol.CtrlType != ControlType.Textarea)
                    {
                        row.AddTableCells(2);

                        this.elementLayoutDesigner1.SelectCell(rowIdx, 0);
                        PropertyPage ctrl = CreatePropertyPageFromUIColumn(col);
                        this.elementLayoutDesigner1.AddElement(ctrl);

                        this.elementLayoutDesigner1.SelectCell(rowIdx, 1);
                        PropertyPage nextCtrl = CreatePropertyPageFromUIColumn(nextCol);
                        this.elementLayoutDesigner1.AddElement(nextCtrl);

                        skipThisCol = true;
                    }
                    else
                    {
                        row.AddTableCells(1);
                        this.elementLayoutDesigner1.SelectCell(rowIdx, 0);
                        PropertyPage ctrl = CreatePropertyPageFromUIColumn(col);
                        this.elementLayoutDesigner1.AddElement(ctrl);
                    }
                }
                else
                {
                    row.AddTableCells(1);
                    this.elementLayoutDesigner1.SelectCell(rowIdx, 0);
                    PropertyPage ctrl = CreatePropertyPageFromUIColumn(col);
                    this.elementLayoutDesigner1.AddElement(ctrl);
                }
                colIdx++;
                rowIdx++;
            }
        }
Ejemplo n.º 7
0
 private void gridColumns_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (gridColumns.Columns[e.ColumnIndex].Name == "ColInputType")
     {
         UIColumn     col = (UIColumn)gridColumns.Rows[e.RowIndex].DataBoundItem;
         FormUIConfig frm = new FormUIConfig();
         frm.DataColumn    = col;
         frm.ConfigContent = col.ConfigContent;
         frm.ShowDialog();
         if (frm.IsCanceled == false)
         {
             col.ConfigContent = frm.ConfigContent;
         }
     }
 }
Ejemplo n.º 8
0
        UIColumn CreateNewUIColumn()
        {
            UIColumn column = new UIColumn();

            column.ColumnName    = "NewColumn";
            column.Label         = "New Column";
            column.Use           = true;
            column.View          = true;
            column.Add           = true;
            column.Detail        = true;
            column.Delete        = true;
            column.Edit          = true;
            column.DataType      = "varchar";
            column.ConfigContent = new TextboxConfiguration();
            return(column);
        }
Ejemplo n.º 9
0
        public UIGrid(Vector2 position, Size size, int columnCount)
        {
            this.Position    = position;
            this.Size        = size;
            this.ColumnCount = columnCount;
            this.Columns     = new List <UIColumn>();

            int colW = this.Size.Width / this.ColumnCount;
            int colH = this.Size.Height;

            for (int i = 0; i < this.ColumnCount; i++)
            {
                float colPosX = this.Position.X + (colW * i);
                float colPosY = this.Position.Y;

                UIColumn column = new UIColumn(new Vector2(colPosX, colPosY), new Size(colW, colH));
                column.SetParent(this);
                this.Columns.Add(column);
            }
        }
Ejemplo n.º 10
0
 private void btnUp_Click(object sender, EventArgs e)
 {
     if (gridColumns.SelectedRows.Count > 0)
     {
         DataGridViewRow row = gridColumns.SelectedRows[0];
         int             idx = row.Index;
         idx--;
         if (idx > -1)
         {
             UIColumn        column     = (UIColumn)row.DataBoundItem;
             List <UIColumn> columns    = (List <UIColumn>)gridColumns.DataSource;
             UIColumn        prevColumn = (UIColumn)columns[idx];
             columns.Remove(column);
             columns.Insert(idx, column);
             gridColumns.DataSource = columns;
             gridColumns.Refresh();
             gridColumns.ClearSelection();
             gridColumns.Rows[idx].Selected = true;
         }
     }
 }
        public Task <UITable> GetTableMetadata(string ResourceId, string Language, string Locale)
        {
            UITable table = new UITable();
            List <LocalizableResource> list =
                context.LocalizableResources.Where(x => x.ResourceGroupId == ResourceId &&
                                                   x.Language == Language && x.Culture == Locale).ToList();

            List <DynamicTableMetadata> metadata = context.DynamicTableMetadataProperties.Where(x => x.ResourceGroupId == ResourceId).ToList();


            if (list.Count == 0)
            {
                list = context.LocalizableResources.Where(x => x.ResourceGroupId == ResourceId &&
                                                          x.Language == DEFAULT_LANG && x.Culture == DEFAULT_LOCALE).ToList();
            }

            foreach (LocalizableResource r in list)
            {
                if (r.ResourceId == r.ResourceGroupId)
                {
                    table.Traslation = r.Traslation;
                    table.Plural     = r.Plural;
                    table.Language   = r.Language;
                    table.Culture    = r.Culture;
                    table.ShortId    = r.ShortId;
                    table.ResourceId = r.ResourceId;
                }
                else
                {
                    UIColumn col = new UIColumn();
                    col.Traslation = r.Traslation;
                    col.Plural     = r.Plural;
                    col.Language   = r.Language;
                    col.Culture    = r.Culture;
                    col.ShortId    = r.ShortId;
                    col.ResourceId = r.ResourceId;

                    DynamicTableMetadata m = metadata.Where(x => x.ResourceId == r.ResourceId).Take(1).SingleOrDefault();
                    if (m != null)
                    {
                        col.AlwaysHidden          = m.AlwaysHidden;
                        col.DisplayByDefault      = m.DisplayByDefault;
                        col.DisplayIndex          = m.DisplayIndex;
                        col.IsID                  = m.IsID;
                        col.OutpuFormat           = m.OutpuFormat;
                        col.Searchable            = m.Searchable;
                        col.Type                  = (Domain.Shared.DataType)m.Type;
                        col.DefaultSort           = m.DeafultSort;
                        col.DictionaryKey         = m.DictionaryKey;
                        col.DictionaryValue       = m.DictionaryValue;
                        col.DictionaryValueIndex  = m.DictionaryValueIndex;
                        col.APIDictionaryEndpoint = m.APIDictionaryEndpoint;
                        col.BoolDisplayType       = m.BoolDisplayType;
                        col.MarkDeletedField      = m.MarkDeletedField;
                    }
                    else
                    {
                        col.AlwaysHidden          = true;
                        col.DisplayByDefault      = false;
                        col.DisplayIndex          = 0;
                        col.IsID                  = false;
                        col.OutpuFormat           = "";
                        col.Searchable            = false;
                        col.Type                  = Domain.Shared.DataType.text;
                        col.DefaultSort           = false;
                        col.DictionaryKey         = false;
                        col.DictionaryValue       = false;
                        col.DictionaryValueIndex  = 0;
                        col.APIDictionaryEndpoint = "";
                        col.BoolDisplayType       = Domain.Shared.BooleanDisplayType.none;
                        col.MarkDeletedField      = false;
                    }


                    table.Columns.Add(col);
                }
            }


            return(Task.FromResult(table));
        }
Ejemplo n.º 12
0
        public void Initialize <TContext>(TContext context)
            where TContext : MainContext, new()
        {
            Name         = appletInfo.Name;
            BusCompName  = appletInfo.BusCompName;
            Type         = appletInfo.Type;
            Header       = appletInfo.Header;
            DisplayLines = appletInfo.DisplayLines;
            EmptyState   = appletInfo.EmptyState;
            Controls     = new List <UIControl>();
            ControlUPs   = new Dictionary <string, List <UIControlUP> >();
            Columns      = new List <UIColumn>();
            DataBUSControlFR <TContext>   dataBUSControlFactory   = new DataBUSControlFR <TContext>();
            BUSUIControlFR <TContext>     busUIControlFactory     = new BUSUIControlFR <TContext>();
            DataBUSControlUPFR <TContext> dataBUSControlUPFactory = new DataBUSControlUPFR <TContext>();
            BUSUIControlUPFR <TContext>   busUIControlUPFactory   = new BUSUIControlUPFR <TContext>();
            DataBUSColumnFR <TContext>    dataBUSColumnFactory    = new DataBUSColumnFR <TContext>();
            BUSUIColumnFR <TContext>      busUIColumnFactory      = new BUSUIColumnFR <TContext>();

            appletInfo.Controls
            .OrderBy(s => s.Sequence)
            .ToList()
            .ForEach(control =>
            {
                UIControl UIEntity = busUIControlFactory.BusinessToUI(dataBUSControlFactory.DataToBusiness(control, context));
                if (control.Type == "picklist" && control.Field != null)
                {
                    PickList pl = context.PickLists
                                  .Include(b => b.BusComp)
                                  .FirstOrDefault(n => n.Id == control.Field.PickListId);
                    UIEntity.Routing = pl?.BusComp?.Routing;
                }
                if (control.ActionType == ActionType.CopyRecord)
                {
                    ControlUP controlUP = control.ControlUPs.FirstOrDefault(n => n.Name == "Data Map");
                    if (controlUP != null)
                    {
                        DataMap dataMap = context.DataMaps.FirstOrDefault(n => n.Name == controlUP.Value);
                        if (dataMap != null)
                        {
                            UIEntity.Routing = dataMap.Routing;
                        }
                    }
                }
                Controls.Add(UIEntity);
                ControlUPs.Add(control.Name, new List <UIControlUP>());
                control.ControlUPs.ForEach(controlUP =>
                {
                    ControlUPs.GetValueOrDefault(control.Name)
                    .Add(busUIControlUPFactory.BusinessToUI(dataBUSControlUPFactory.DataToBusiness(controlUP, context)));
                });
            });

            appletInfo.Columns
            .OrderBy(s => s.Sequence)
            .ToList()
            .ForEach(column => {
                UIColumn UIEntity = busUIColumnFactory.BusinessToUI(dataBUSColumnFactory.DataToBusiness(column, context));
                Columns.Add(UIEntity);
            });

            PR             = appletInfo.PR;
            Routing        = appletInfo.Routing;
            BusCompRouting = appletInfo.BusCompRouting;
            Initflag       = appletInfo.Initflag;
        }
Ejemplo n.º 13
0
        PropertyPage CreatePropertyPageFromUIColumn(UIColumn column)
        {
            string       prefix = "";
            PropertyPage page   = null;

            if (column.CtrlType == ControlType.Textbox || column.CtrlType == ControlType.Numericbox || column.CtrlType == ControlType.Hidden)
            {
                page   = new TextboxPropertyPage();
                prefix = "txt";
                if (column.CtrlType == ControlType.Numericbox)
                {
                    page.Properties["IsNumeric"] = true;
                }

                if (column.CtrlType == ControlType.Hidden)
                {
                    page.Properties["IsHidden"] = true;
                }
            }
            else if (column.CtrlType == ControlType.Textarea || column.CtrlType == ControlType.HtmlEditor)
            {
                prefix = "txt";

                page = new TextareaPropertyPage();
                if (column.CtrlType == ControlType.HtmlEditor)
                {
                    page.Properties["IsHtml"] = true;
                }
            }
            else if (column.CtrlType == ControlType.Image || column.CtrlType == ControlType.File)
            {
                prefix = "file";
                if (column.CtrlType == ControlType.Image)
                {
                    prefix = "image";
                }

                page = new FileUploadPropertyPage();
            }
            else if (column.CtrlType == ControlType.Combobox || column.CtrlType == ControlType.LookupCombobox)
            {
                prefix = "cmb";
                page   = new SelectBoxPropertyPage();
            }
            else if (column.CtrlType == ControlType.Checkboxes || column.CtrlType == ControlType.LookupCheckboxes)
            {
                prefix = "chk";
                page   = new CheckboxPropertyPage();
            }
            else if (column.CtrlType == ControlType.Radiobuttons || column.CtrlType == ControlType.LookupRadiobuttons)
            {
                prefix = "rd";
                page   = new RadioGroupPropertyPage();
            }
            else if (column.CtrlType == ControlType.Date || column.CtrlType == ControlType.Datetime || column.CtrlType == ControlType.Daterange)
            {
                prefix = "dt";
                page   = new DateTimePropertyPage();
                if (column.CtrlType == ControlType.Datetime)
                {
                    page.Properties["IncludeTime"] = true;
                }
                if (column.CtrlType == ControlType.Daterange)
                {
                    page.Properties["DateRange"] = true;
                }
            }


            SetPageProperties(page, column, prefix);


            return(page);
        }
Ejemplo n.º 14
0
        public override BUSColumn UIToBusiness(UIColumn UIEntity, TContext context, IViewInfo viewInfo, bool isNewRecord)
        {
            BUSColumn businessEntity = base.UIToBusiness(UIEntity, context, viewInfo, isNewRecord);
            Applet    applet         = context.Applets
                                       .AsNoTracking()
                                       .Select(a => new
            {
                id        = a.Id,
                name      = a.Name,
                busCompId = a.BusCompId,
                columns   = a.Columns.Select(column => new
                {
                    id   = column.Id,
                    name = column.Name
                })
            })
                                       .Select(a => new Applet
            {
                Id        = a.id,
                Name      = a.name,
                BusCompId = a.busCompId,
                Columns   = a.columns.Select(column => new Column
                {
                    Id   = column.id,
                    Name = column.name
                }).ToList()
            })
                                       .FirstOrDefault(n => n.Id.ToString() == ComponentsRecordsInfo.GetSelectedRecord("Applet"));

            if (applet == null)
            {
                businessEntity.ErrorMessage = "First you need create applet.";
            }
            else
            {
                // Если запись новая и она не уникальна, записывается ошибка
                Column column = applet.Columns?.FirstOrDefault(n => n.Name == UIEntity.Name);
                if (column != null && column.Id != UIEntity.Id)
                {
                    businessEntity.ErrorMessage = $"Column with this name is already exists in applet {applet.Name}.";
                }

                else
                {
                    // Applet
                    businessEntity.Applet   = applet;
                    businessEntity.AppletId = applet.Id;

                    // BusComp
                    BusinessComponent busComp = context.BusinessComponents
                                                .AsNoTracking()
                                                .Select(bc => new
                    {
                        id     = bc.Id,
                        name   = bc.Name,
                        fields = bc.Fields.Select(field => new
                        {
                            id   = field.Id,
                            name = field.Name
                        })
                    })
                                                .Select(bc => new BusinessComponent
                    {
                        Id     = bc.id,
                        Name   = bc.name,
                        Fields = bc.fields.Select(field => new Field
                        {
                            Id   = field.id,
                            Name = field.name
                        }).ToList()
                    })
                                                .FirstOrDefault(i => i.Id == applet.BusCompId);

                    // BusComp
                    if (busComp != null)
                    {
                        businessEntity.BusComp   = busComp;
                        businessEntity.BusCompId = busComp.Id;

                        // Field
                        Field field = busComp.Fields.FirstOrDefault(n => n.Name == UIEntity.FieldName);
                        if (field != null)
                        {
                            businessEntity.Field     = field;
                            businessEntity.FieldId   = field.Id;
                            businessEntity.FieldName = field.Name;
                        }
                    }
                }

                if (string.IsNullOrWhiteSpace(UIEntity.ActionType))
                {
                    businessEntity.ActionType = ActionType.None;
                }
                else
                {
                    businessEntity.ActionType = (ActionType)Enum.Parse(typeof(ActionType), UIEntity.ActionType);
                }
                businessEntity.Readonly = UIEntity.Readonly;
                businessEntity.Header   = UIEntity.Header;
                businessEntity.Type     = UIEntity.Type;
                businessEntity.Required = UIEntity.Required;
            }
            return(businessEntity);
        }
Ejemplo n.º 15
0
        public override IEnumerable <ValidationResult> BUSUIValidate(TContext context, BUSColumn businessComponent, UIColumn UIEntity)
        {
            List <ValidationResult> result = base.BUSUIValidate(context, businessComponent, UIEntity).ToList();

            if (string.IsNullOrWhiteSpace(businessComponent.ErrorMessage))
            {
                if (!string.IsNullOrWhiteSpace(UIEntity.FieldName))
                {
                    if (businessComponent.BusComp == null)
                    {
                        result.Add(new ValidationResult(
                                       $"At first you need to add a business component to applet {businessComponent.Applet.Name}.",
                                       new List <string>()
                        {
                            "BusComp"
                        }));
                    }
                    else if (businessComponent.Field == null)
                    {
                        result.Add(new ValidationResult("Field with this name not found.", new List <string>()
                        {
                            "FieldName"
                        }));
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 16
0
        public override IEnumerable <ValidationResult> UIValidate(TContext context, IViewInfo viewInfo, UIColumn UIEntity, bool isNewRecord)
        {
            List <ValidationResult> result = base.UIValidate(context, viewInfo, UIEntity, isNewRecord).ToList();

            if (string.IsNullOrWhiteSpace(UIEntity.ActionType))
            {
                result.Add(new ValidationResult("Action type is a required field.", new List <string>()
                {
                    "ActionType"
                }));
            }
            return(result);
        }