Example #1
0
        public static void GenerateStandardOptions(StandardComponent standardComponent)
        {
            standardComponent.Options = new List <Portal.Entities.Pages.ShellOption>();

            standardComponent.Options.Add(new Portal.Entities.Pages.ShellOption
            {
                Key   = "identityfield",
                Value = "id"
            });

            standardComponent.Options.Add(new Portal.Entities.Pages.ShellOption
            {
                Key   = "namefield",
                Value = "name"
            });

            standardComponent.Options.Add(new Portal.Entities.Pages.ShellOption
            {
                Key   = "allowadjustment",
                Value = "false"
            });

            standardComponent.Options.Add(new Portal.Entities.Pages.ShellOption
            {
                Key   = "allowupdateparts",
                Value = "false"
            });
        }
Example #2
0
        public async Task <IActionResult> UpdateOne(string id, [FromBody] StandardComponent standardComponent)
        {
            if (ModelState.IsValid)
            {
                standardComponent.Id = id;
                await _standardRepository.UpdateAsync(id, standardComponent);

                _logger.Info("Updated standard component: {@standardComponent}", standardComponent);
                return(Ok());
            }

            return(BadRequest());
        }
Example #3
0
        public async Task <IActionResult> CreateOne([FromBody] StandardComponent standardComponent)
        {
            if (ModelState.IsValid)
            {
                standardComponent.Id = DataUtil.GenerateUniqueId();
                await _standardRepository.AddAsync(standardComponent);

                _logger.Info("Created standard component: {@standardComponent}", standardComponent);
                return(Ok(standardComponent.Id));
            }

            return(BadRequest());
        }
Example #4
0
        public static void Load(string path, ref Canvas canvas)
        {
            var circuit = XElement.Load(path);

            canvas.Children.Clear();
            canvas.Width  = int.Parse(circuit.Attribute("Width").Value);
            canvas.Height = int.Parse(circuit.Attribute("Height").Value);
            var gid = new Dictionary <int, StandardComponent>();

            foreach (XElement gate in circuit.Element("Gates").Elements())
            {
                StandardComponent shape = CreateGate(gate);
                shape.SetValue(Canvas.LeftProperty, double.Parse(gate.Attribute("X").Value));
                shape.SetValue(Canvas.TopProperty, double.Parse(gate.Attribute("Y").Value));
                shape.PosX = (double)shape.GetValue(Canvas.LeftProperty);
                shape.PosY = (double)shape.GetValue(Canvas.TopProperty);
                gid[int.Parse(gate.Attribute("ID").Value)] = shape;
                canvas.Children.Add(shape);
            }
            foreach (XElement wire in circuit.Element("Wires").Elements())
            {
                canvas.UpdateLayout();
                MainWindow.wire = new Wireclass();
                int temp;
                if (!int.TryParse(wire.Element("From").Attribute("ID").Value, out temp))
                {
                    continue;
                }
                StandardComponent gateSrc = gid[temp];
                if (!int.TryParse(wire.Element("To").Attribute("ID").Value, out temp))
                {
                    continue;
                }
                StandardComponent gateDest = gid[temp];
                if (!int.TryParse(wire.Element("From").Attribute("Port").Value, out temp))
                {
                    continue;
                }
                int portSrc = temp;
                if (!int.TryParse(wire.Element("To").Attribute("Port").Value, out temp))
                {
                    continue;
                }
                int portDest = temp;
                Wireclass.selection1 = ((Terminal)gateSrc.OutputStack.Children[portSrc]).elSelector;
                Wireclass.selection2 = ((Terminal)gateDest.inputStack.Children[portDest]).elSelector;
                MainWindow.wire.relier();
            }
        }
Example #5
0
        public Task Upgrade(IVersionContext versionContext)
        {
            var databaseStandard = new StandardComponent
            {
                Id          = "5d25f6abe88d28422061cfaf",
                Name        = "databaseForm",
                DisplayName = "Database Form",
                AppId       = Constants.CoreAppId,
                LayoutType  = PageSectionLayoutType.OneColumn,
                Controls    = new List <Portal.Entities.SectionParts.Controls.PageControl>
                {
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "id",
                        Order   = 0,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Textbox,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "id"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "id"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "true"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "true"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "id"
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "name",
                        Order   = 1,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Textbox,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Name"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Name"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "name"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a database name"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Regex,
                                IsActive         = true,
                                ValidatorMessage = "Please enter only characters and numberic",
                                ValidatorOption  = "[A-Za-z0-9]*"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.MaxLength,
                                IsActive         = true,
                                ValidatorMessage = "This field requires maximum 250 characters",
                                ValidatorOption  = "250"
                            }
                        },
                        AsyncValidators = new List <Portal.Entities.Components.Controls.PageControlAsyncValidator>
                        {
                            new Portal.Entities.Components.Controls.PageControlAsyncValidator
                            {
                                ValidatorName         = "uniquename",
                                IsActive              = true,
                                ValidatorMessage      = "This database name is already existed. Please choose another name.",
                                AsyncValidatorOptions = new Portal.Entities.Components.Controls.ControlAsyncValidatorOptions
                                {
                                    EvaluatedExpression = "response.result == null",
                                    DatabaseOptions     = new Portal.Entities.Shared.DatabaseOptions
                                    {
                                        DatabaseConnectionId = Constants.PortalDatabaseId,
                                        Query = "{\r\n  \"$query\": {\r\n    \"databases\": [\r\n      {\r\n        \"$match\": {\r\n          \"name\": \"{{data.name}}\"\r\n        }\r\n      }\r\n    ]\r\n  }\r\n}"
                                    },
                                    ValidatorType = Portal.Entities.Components.Controls.AsyncValidatorType.DatabaseValidator
                                }
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "dataSource",
                        Order   = 2,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Textbox,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Datasource"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Datasource"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "dataSource"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a datasource"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.MaxLength,
                                IsActive         = true,
                                ValidatorMessage = "This field requires maximum 250 characters",
                                ValidatorOption  = "250"
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "connectionString",
                        Order   = 3,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Textbox,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Connection String"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Connection String"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "connectionString"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a connection string"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.MaxLength,
                                IsActive         = true,
                                ValidatorMessage = "This field requires maximum 500 characters",
                                ValidatorOption  = "500"
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "databaseConnectionType",
                        Order   = 4,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Select,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Connection Type"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = ""
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "databaseConnectionType"
                            }
                        },
                        DatasourceOptions = new Portal.Entities.Shared.DatasourceOptions
                        {
                            DatasourceStaticOptions = new Portal.Entities.Shared.DatasourceStaticOptions
                            {
                                JsonResource = "[{\"name\":\"MongoDB\",\"value\":\"mongodb\"},{\"name\":\"SQL Server\",\"value\":\"sqlserver\"}, {\"name\":\"PostgreSQL\",\"value\":\"postgresql\"}, {\"name\":\"MySQL\",\"value\":\"mysql\"}]"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please choose one connection type"
                            }
                        }
                    }
                }
            };

            var appStandard = new StandardComponent
            {
                Id          = "5d3836194d8fa90874135d68",
                Name        = "appForm",
                DisplayName = "App Form",
                AppId       = Constants.CoreAppId,
                LayoutType  = PageSectionLayoutType.OneColumn,
                Controls    = new List <Portal.Entities.SectionParts.Controls.PageControl>
                {
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "id",
                        Order   = 0,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Textbox,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Id"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = ""
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "true"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "true"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "id"
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "name",
                        Order   = 1,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Textbox,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Name"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Name"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "!!queryparams.id"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "name"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a app name"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Regex,
                                IsActive         = true,
                                ValidatorMessage = "Please enter only characters and numberic",
                                ValidatorOption  = "[A-Za-z0-9]*"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.MaxLength,
                                IsActive         = true,
                                ValidatorMessage = "This field requires maximum 250 characters",
                                ValidatorOption  = "250"
                            }
                        },
                        AsyncValidators = new List <Portal.Entities.Components.Controls.PageControlAsyncValidator>
                        {
                            new Portal.Entities.Components.Controls.PageControlAsyncValidator
                            {
                                ValidatorName         = "uniquename",
                                IsActive              = true,
                                ValidatorMessage      = "This app name is already existed. Please choose another name.",
                                AsyncValidatorOptions = new Portal.Entities.Components.Controls.ControlAsyncValidatorOptions
                                {
                                    EvaluatedExpression = "response.result == null",
                                    DatabaseOptions     = new Portal.Entities.Shared.DatabaseOptions
                                    {
                                        DatabaseConnectionId = Constants.PortalDatabaseId,
                                        Query = "{\r\n  \"$query\": {\r\n    \"apps\": [\r\n      {\r\n        \"$match\": {\r\n          \"name\": \"{{data.name}}\"\r\n        }\r\n      }\r\n    ]\r\n  }\r\n}"
                                    },
                                    ValidatorType = Portal.Entities.Components.Controls.AsyncValidatorType.DatabaseValidator
                                }
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "displayName",
                        Order   = 2,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Textbox,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Display Name"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Display Name"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "displayName"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a display name"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.MaxLength,
                                IsActive         = true,
                                ValidatorMessage = "This field requires maximum 250 characters",
                                ValidatorOption  = "250"
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "defaultUrl",
                        Order   = 3,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Textbox,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Default Url"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Default Url"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "defaultUrl"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a default url"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.MaxLength,
                                IsActive         = true,
                                ValidatorMessage = "This field requires maximum 250 characters",
                                ValidatorOption  = "250"
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "currentVersionNumber",
                        Order   = 4,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Textbox,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Version"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "App Version"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "currentVersionNumber"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a version number"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.MaxLength,
                                IsActive         = true,
                                ValidatorMessage = "This field requires maximum 50 characters",
                                ValidatorOption  = "50"
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "logo",
                        Order   = 4,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.IconPicker,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Icon"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Icon"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "logo"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please choose one icon"
                            }
                        }
                    }
                }
            };

            VersionUtils.GenerateControlEvents(databaseStandard);
            VersionUtils.GenerateControlEvents(appStandard);

            VersionUtils.GenerateStandardOptions(databaseStandard);
            VersionUtils.GenerateStandardOptions(appStandard);
            versionContext.InsertData(databaseStandard);
            versionContext.InsertData(appStandard);

            return(Task.CompletedTask);
        }
Example #6
0
        static public XElement CreateCircuitXML(Canvas canvas)
        {
            XElement circuit = new XElement("Circuit");

            circuit.SetAttributeValue("Width", canvas.Width);
            circuit.SetAttributeValue("Height", canvas.Height);

            XElement gates = new XElement("Gates");
            var      gid   = new Dictionary <StandardComponent, int>();
            int      id    = 1;

            foreach (object shape in canvas.Children)
            {
                if (shape is StandardComponent)
                {
                    var      g  = shape as StandardComponent;
                    XElement gt = new XElement("Gate");
                    gt.SetAttributeValue("Type", g.GetType().Name);
                    gt.SetAttributeValue("ID", id);
                    gt.SetAttributeValue("X", g.PosX);
                    gt.SetAttributeValue("Y", g.PosY);
                    gt.SetAttributeValue("NumInputs", g.nbrInputs());
                    if (shape is Clock)
                    {
                        gt.SetAttributeValue("HighLevelms", ((Clock)g).HighLevelms);
                        gt.SetAttributeValue("LowLevelms", ((Clock)g).LowLevelms);
                    }
                    if (shape is JK)
                    {
                        if (((JK)shape).Trigger == JK.TriggerType.FallingEdge)
                        {
                            gt.SetAttributeValue("TriggerType", 0);
                        }
                        else
                        {
                            gt.SetAttributeValue("TriggerType", 1);
                        }
                    }
                    if (shape is Registre)
                    {
                        if (((Registre)shape).Trigger == Registre.TriggerType.FallingEdge)
                        {
                            gt.SetAttributeValue("TriggerType", 0);
                        }
                        else if (((Registre)shape).Trigger == Registre.TriggerType.RisingEdge)
                        {
                            gt.SetAttributeValue("TriggerType", 1);
                        }
                        else if (((Registre)shape).Trigger == Registre.TriggerType.LowLevel)
                        {
                            gt.SetAttributeValue("TriggerType", 2);
                        }
                        else if (((Registre)shape).Trigger == Registre.TriggerType.HighLevel)
                        {
                            gt.SetAttributeValue("TriggerType", 3);
                        }
                    }
                    gates.Add(gt);
                    gid.Add(g, id);
                    id++;
                }
            }

            XElement wires = new XElement("Wires");

            foreach (object shape in canvas.Children)
            {
                if (shape is StandardComponent)
                {
                    var g = shape as StandardComponent;
                    for (int i = 0; i < g.inputStack.Children.Count; i++)
                    {
                        var input = g.inputStack.Children[i] as Terminal;
                        if (input.wires.Count > 0)
                        {
                            XElement wire = new XElement("Wire",
                                                         new XElement("From"), new XElement("To"));
                            Terminal          sourceTerminal  = ((Wireclass)input.wires[0]).source;
                            StandardComponent sourceComponent = UserClass.TryFindParent <StandardComponent>(sourceTerminal);
                            wire.Element("From").SetAttributeValue("ID", gid[sourceComponent]);
                            wire.Element("From").SetAttributeValue("Port", sourceComponent.OutputStack.Children.IndexOf(sourceTerminal));
                            wire.Element("To").SetAttributeValue("ID", gid[g]);
                            wire.Element("To").SetAttributeValue("Port", i);
                            wires.Add(wire);
                        }
                    }
                }
            }

            circuit.Add(gates);
            circuit.Add(wires);
            return(circuit);
        }
Example #7
0
        public Task Upgrade(IVersionContext versionContext)
        {
            var userFormStandard = new StandardComponent
            {
                Id          = "5d615e501773a96ee8eb5ed3",
                Name        = "userform",
                DisplayName = "User Form",
                AppId       = Constants.CoreAppId,
                LayoutType  = PageSectionLayoutType.OneColumn,
                Controls    = new List <Portal.Entities.SectionParts.Controls.PageControl>
                {
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "id",
                        Order   = 0,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Textbox,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "id"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "id"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "true"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "true"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "id"
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "username",
                        Order   = 1,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Label,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Username"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Enter a username"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "!!queryparams.id"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "username"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "email",
                        Order   = 2,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Email,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Email"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Enter a email"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "email"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a email"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.MaxLength,
                                IsActive         = true,
                                ValidatorMessage = "This field requires maximum 250 characters",
                                ValidatorOption  = "250"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Email,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a correct email format"
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "isConfirmedEmail",
                        Order   = 3,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Checkbox,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Confirmed Email"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = ""
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "isConfirmedEmail"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "isLockoutEnabled",
                        Order   = 4,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Checkbox,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Lockout Enabled"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = ""
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "isLockoutEnabled"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "lockoutEndDate",
                        Order   = 4,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Label,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Lockout End Date"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = ""
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "lockoutEndDate"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "roles",
                        Order   = 4,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.AutoComplete,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Roles"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = ""
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "roles"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "multiple",
                                Value = "true"
                            }
                        },
                        DatasourceOptions = new Portal.Entities.Shared.DatasourceOptions
                        {
                            Type            = Portal.Entities.Shared.DatasourceControlType.Database,
                            DatabaseOptions = new Portal.Entities.Shared.DatabaseOptions
                            {
                                DatabaseConnectionId = Constants.IdentityDatabaseId,
                                EntityName           = "roles",
                                Query = versionContext.ConnectionType == Core.Persistences.ConnectionType.MongoDB ?
                                        "{\r\n  \"$query\": {\r\n    \"roles\": [\r\n      {\r\n        \"$project\": {\r\n          \"name\": \"$displayName\",\r\n          \"value\": \"$name\"\r\n        }\r\n      }\r\n    ]\r\n  }\r\n}"
                                : (versionContext.ConnectionType == Core.Persistences.ConnectionType.MySQL ? "Select `displayName` as name, name as value from `roles`" : "Select \"displayName\" as name, name as value from roles")
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please select at least one role",
                                ValidatorOption  = ""
                            }
                        }
                    }
                }
            };

            var registerNewUserFormStandard = new StandardComponent
            {
                Id          = "5d6222ec3aae6a79ecf035e9",
                Name        = "registerForm",
                DisplayName = "Register Form",
                AppId       = Constants.CoreAppId,
                LayoutType  = PageSectionLayoutType.OneColumn,
                Controls    = new List <Portal.Entities.SectionParts.Controls.PageControl>
                {
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "username",
                        Order   = 1,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Textbox,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Username"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Enter a username"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "username"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a username"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Regex,
                                IsActive         = true,
                                ValidatorMessage = "Please enter only characters and numberic",
                                ValidatorOption  = "[A-Za-z0-9]*"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.MaxLength,
                                IsActive         = true,
                                ValidatorMessage = "This field requires maximum 50 characters",
                                ValidatorOption  = "50"
                            }
                        },
                        AsyncValidators = new List <Portal.Entities.Components.Controls.PageControlAsyncValidator>
                        {
                            new Portal.Entities.Components.Controls.PageControlAsyncValidator
                            {
                                ValidatorName         = "uniquename",
                                IsActive              = true,
                                ValidatorMessage      = "This username is already existed. Please choose another name.",
                                AsyncValidatorOptions = new Portal.Entities.Components.Controls.ControlAsyncValidatorOptions
                                {
                                    EvaluatedExpression = "response.result == null",
                                    DatabaseOptions     = new Portal.Entities.Shared.DatabaseOptions
                                    {
                                        DatabaseConnectionId = Constants.IdentityDatabaseId,
                                        Query = "{\r\n  \"$query\": {\r\n    \"users\": [\r\n      {\r\n        \"$match\": {\r\n          \"username\": \"{{data.username}}\"\r\n        }\r\n      }\r\n    ]\r\n  }\r\n}"
                                    },
                                    ValidatorType = Portal.Entities.Components.Controls.AsyncValidatorType.DatabaseValidator
                                }
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "password",
                        Order   = 2,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Password,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Password"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Enter a password"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "password"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a password"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Regex,
                                IsActive         = true,
                                ValidatorMessage = "Password requires at least one upper case, one lower case, one number, one special character",
                                ValidatorOption  = @"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$^+=!*()@%&]).{6,}$"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.MinLength,
                                IsActive         = true,
                                ValidatorMessage = "Password requires at least {{option}} characters",
                                ValidatorOption  = "6"
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "repassword",
                        Order   = 3,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Password,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Confirm password"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Enter a confirm password"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "repassword"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a confirm password"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.MaxLength,
                                IsActive         = true,
                                ValidatorMessage = "This field requires maximum 50 characters",
                                ValidatorOption  = "50"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.EqualTo,
                                IsActive         = true,
                                ValidatorMessage = "This field must be equal to {{option}}",
                                ValidatorOption  = "password"
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "email",
                        Order   = 4,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Email,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Email"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Enter a email"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "email"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a email"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.MaxLength,
                                IsActive         = true,
                                ValidatorMessage = "This field requires maximum 250 characters",
                                ValidatorOption  = "250"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Email,
                                IsActive         = true,
                                ValidatorMessage = "This field must be email format"
                            }
                        },
                        AsyncValidators = new List <Portal.Entities.Components.Controls.PageControlAsyncValidator>
                        {
                            new Portal.Entities.Components.Controls.PageControlAsyncValidator
                            {
                                ValidatorName         = "uniqueemail",
                                IsActive              = true,
                                ValidatorMessage      = "This email is already existed. Please choose another email.",
                                AsyncValidatorOptions = new Portal.Entities.Components.Controls.ControlAsyncValidatorOptions
                                {
                                    EvaluatedExpression = "response.result == null",
                                    DatabaseOptions     = new Portal.Entities.Shared.DatabaseOptions
                                    {
                                        DatabaseConnectionId = Constants.IdentityDatabaseId,
                                        Query = "{\r\n  \"$query\": {\r\n    \"users\": [\r\n      {\r\n        \"$match\": {\r\n          \"email\": \"{{data.emaill}}\"\r\n        }\r\n      }\r\n    ]\r\n  }\r\n}"
                                    },
                                    ValidatorType = Portal.Entities.Components.Controls.AsyncValidatorType.DatabaseValidator
                                }
                            }
                        }
                    }
                }
            };

            var roleStandard = new StandardComponent
            {
                Id          = "5d63423dbaac7d4790b7d300",
                Name        = "roleForm",
                DisplayName = "Role Form",
                AppId       = Constants.CoreAppId,
                LayoutType  = PageSectionLayoutType.OneColumn,
                Controls    = new List <Portal.Entities.SectionParts.Controls.PageControl>
                {
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "id",
                        Order   = 0,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Textbox,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "id"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "id"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "true"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "true"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "id"
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "name",
                        Order   = 1,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Textbox,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Role Name"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Enter a role name"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "!!queryparams.id"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "name"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a name"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.MaxLength,
                                IsActive         = true,
                                ValidatorMessage = "This field requires maximum 50 characters",
                                ValidatorOption  = "50"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Regex,
                                IsActive         = true,
                                ValidatorMessage = "Please enter only characters",
                                ValidatorOption  = "[A-Za-z]*"
                            }
                        },
                        AsyncValidators = new List <Portal.Entities.Components.Controls.PageControlAsyncValidator>
                        {
                            new Portal.Entities.Components.Controls.PageControlAsyncValidator
                            {
                                ValidatorName         = "uniquename",
                                IsActive              = true,
                                ValidatorMessage      = "This role is already existed. Please choose another name.",
                                AsyncValidatorOptions = new Portal.Entities.Components.Controls.ControlAsyncValidatorOptions
                                {
                                    EvaluatedExpression = "response.result == null",
                                    DatabaseOptions     = new Portal.Entities.Shared.DatabaseOptions
                                    {
                                        DatabaseConnectionId = Constants.IdentityDatabaseId,
                                        Query = "{\r\n  \"$query\": {\r\n    \"roles\": [\r\n      {\r\n        \"$match\": {\r\n          \"name\": \"{{data.name}}\"\r\n        }\r\n      }\r\n    ]\r\n  }\r\n}"
                                    },
                                    ValidatorType = Portal.Entities.Components.Controls.AsyncValidatorType.DatabaseValidator
                                }
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "displayName",
                        Order   = 2,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Textbox,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Role Display Name"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Enter a display name"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "displayName"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a display name"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.MaxLength,
                                IsActive         = true,
                                ValidatorMessage = "This field requires maximum 50 characters",
                                ValidatorOption  = "50"
                            }
                        }
                    }
                }
            };

            VersionUtils.GenerateControlEvents(userFormStandard);
            VersionUtils.GenerateControlEvents(registerNewUserFormStandard);
            VersionUtils.GenerateControlEvents(roleStandard);

            VersionUtils.GenerateStandardOptions(userFormStandard);
            VersionUtils.GenerateStandardOptions(registerNewUserFormStandard);
            VersionUtils.GenerateStandardOptions(roleStandard);

            versionContext.InsertData(userFormStandard);
            versionContext.InsertData(registerNewUserFormStandard);
            versionContext.InsertData(roleStandard);

            return(Task.CompletedTask);
        }
Example #8
0
        public Task Upgrade(IVersionContext versionContext)
        {
            var appMenu = new StandardComponent
            {
                Id          = "5f6f751c118d1754ac475aa1",
                Name        = "appmenu",
                DisplayName = "App Menu",
                AppId       = Constants.CoreAppId,
                LayoutType  = PageSectionLayoutType.OneColumn,
                Type        = StandardType.Tree,
                Options     = Constants.TreeOptions(inChildren: "subMenus", outChildren: "subMenus"),
                Controls    = new List <Portal.Entities.SectionParts.Controls.PageControl>
                {
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name       = "displayName",
                        IsActive   = true,
                        Type       = Portal.Entities.SectionParts.Controls.ControlType.Textbox,
                        Options    = Constants.ControlOptions("Menu name", "Enter a menu name", "false", "false", "displayName", "true"),
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a menu name"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.MaxLength,
                                IsActive         = true,
                                ValidatorMessage = "This field requires maximum 250 characters",
                                ValidatorOption  = "250"
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name       = "icon",
                        IsActive   = true,
                        Type       = Portal.Entities.SectionParts.Controls.ControlType.IconPicker,
                        Options    = Constants.ControlOptions("Menu Icon", "", "false", "false", "icon", "true"),
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please choose one icon"
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name       = "url",
                        IsActive   = true,
                        Type       = Portal.Entities.SectionParts.Controls.ControlType.Textbox,
                        Options    = Constants.ControlOptions("Menu Url", "Enter a menu url", "false", "false", "url", "true"),
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a url"
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name     = "hide",
                        IsActive = true,
                        Type     = Portal.Entities.SectionParts.Controls.ControlType.Slide,
                        Options  = Constants.ControlOptions("Hide", "", "false", "false", "hide", "true"),
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name     = "availableUrl",
                        IsActive = true,
                        Type     = Portal.Entities.SectionParts.Controls.ControlType.Select,
                        Options  = Constants.ControlOptions("Choose url", "", "false", "false", "availableUrl", "true",
                                                            new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "defaultvalue",
                                Value = ""
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "multiple",
                                Value = "false"
                            }
                        }),
                        DatasourceOptions = new Portal.Entities.Shared.DatasourceOptions
                        {
                            Type = Portal.Entities.Shared.DatasourceControlType.WebService,
                            HttpServiceOptions = new Portal.Entities.Shared.HttpServiceOptions
                            {
                                HttpServiceUrl   = "{{configs.portalBaseEndpoint}}/api/apps/{{queryparams.appId}}/urls",
                                HttpMethod       = "GET",
                                HttpSuccessCode  = "200",
                                JsonBody         = "{}",
                                OutputProjection = "name=name;value=url"
                            }
                        }
                    }
                }
            };

            VersionUtils.GenerateControlEvents(appMenu);

            versionContext.InsertData(appMenu);

            return(Task.CompletedTask);
        }
Example #9
0
        public Task Upgrade(IVersionContext versionContext)
        {
            var profileStandard = new StandardComponent
            {
                Id          = "5e79c14931a1754a2cd38cbc",
                Name        = "profileForm",
                DisplayName = "Profile Form",
                AppId       = Constants.CoreAppId,
                LayoutType  = PageSectionLayoutType.TwoColumns,
                Controls    = new List <Portal.Entities.SectionParts.Controls.PageControl>
                {
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "fullName",
                        Order   = 1,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Textbox,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Full Name"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Enter a full name"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "fullName"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a full name"
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "avatar",
                        Order   = 2,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Uploader,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Avatar"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = ""
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "avatar"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "allowfileurl",
                                Value = "true"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "saveonchange",
                                Value = "false"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.FileMaximumSize,
                                IsActive         = true,
                                ValidatorMessage = "File must have size less than {{option}} Mb",
                                ValidatorOption  = "5"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.FileExtensions,
                                IsActive         = true,
                                ValidatorMessage = "File must have an extension in {{option}}",
                                ValidatorOption  = "jpg;jpeg;png;gif"
                            }
                        }
                    }
                }
            };

            var changePasswordStandard = new StandardComponent
            {
                Id          = "5e79c14931a1754a2cd38cc3",
                Name        = "changePasswordForm",
                DisplayName = "Change Password Form",
                AppId       = Constants.CoreAppId,
                LayoutType  = PageSectionLayoutType.TwoColumns,
                Controls    = new List <Portal.Entities.SectionParts.Controls.PageControl>
                {
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "currentPassword",
                        Order   = 1,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Password,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Current Password"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Enter a current password"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "currentPassword"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a current password"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType = Portal.Entities.SectionParts.Controls.ValidatorType.MaxLength,
                                IsActive      = false
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType = Portal.Entities.SectionParts.Controls.ValidatorType.MinLength,
                                IsActive      = false
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType = Portal.Entities.SectionParts.Controls.ValidatorType.Equal,
                                IsActive      = false
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType = Portal.Entities.SectionParts.Controls.ValidatorType.EqualTo,
                                IsActive      = false
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType = Portal.Entities.SectionParts.Controls.ValidatorType.Regex,
                                IsActive      = false
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "newPassword",
                        Order   = 2,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Password,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "New password"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Enter a new password"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "newPassword"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a new password"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Regex,
                                IsActive         = true,
                                ValidatorMessage = "Password requires at least one upper case, one lower case, one number, one special character",
                                ValidatorOption  = @"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[#$^+=!*()@%&]).{6,}$"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.MinLength,
                                IsActive         = true,
                                ValidatorMessage = "Password requires at least {{option}} characters",
                                ValidatorOption  = "6"
                            }
                        }
                    },
                    new Portal.Entities.SectionParts.Controls.PageControl
                    {
                        Name    = "reNewPassword",
                        Order   = 3,
                        Type    = Portal.Entities.SectionParts.Controls.ControlType.Password,
                        Options = new List <Portal.Entities.Pages.ShellOption>
                        {
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "label",
                                Value = "Confirm new password"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "placeholder",
                                Value = "Re-enter a new password"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "disabled",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "hidden",
                                Value = "false"
                            },
                            new Portal.Entities.Pages.ShellOption
                            {
                                Key   = "bindname",
                                Value = "reNewPassword"
                            }
                        },
                        Validators = new List <Portal.Entities.SectionParts.Controls.PageControlValidator>
                        {
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.Required,
                                IsActive         = true,
                                ValidatorMessage = "Please enter a password"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.MaxLength,
                                IsActive         = true,
                                ValidatorMessage = "This field requires maximum {{option}} characters",
                                ValidatorOption  = "50"
                            },
                            new Portal.Entities.SectionParts.Controls.PageControlValidator
                            {
                                ValidatorType    = Portal.Entities.SectionParts.Controls.ValidatorType.EqualTo,
                                IsActive         = true,
                                ValidatorMessage = "This field must be equal to new password",
                                ValidatorOption  = "newPassword"
                            }
                        }
                    }
                }
            };

            VersionUtils.GenerateStandardOptions(profileStandard);
            VersionUtils.GenerateStandardOptions(changePasswordStandard);
            versionContext.InsertData(profileStandard);
            versionContext.InsertData(changePasswordStandard);

            return(Task.CompletedTask);
        }
Example #10
0
        public static void GenerateControlEvents(StandardComponent standardComponent)
        {
            foreach (var control in standardComponent.Controls)
            {
                switch (control.Type)
                {
                case Portal.Entities.SectionParts.Controls.ControlType.Label:
                    control.PageControlEvents = new List <Portal.Entities.Components.Controls.PageControlEvent>();
                    break;

                case Portal.Entities.SectionParts.Controls.ControlType.AutoComplete:
                    control.PageControlEvents = new List <Portal.Entities.Components.Controls.PageControlEvent>
                    {
                        new Portal.Entities.Components.Controls.PageControlEvent
                        {
                            EventName               = control.Name + "_change",
                            EventActionType         = Portal.Entities.Components.Controls.EventActionType.TriggerEvent,
                            EventHttpServiceOptions = new Portal.Entities.Components.Controls.EventHttpServiceOptions
                            {
                                BoundData        = System.Array.Empty <string>(),
                                HttpMethod       = "Get",
                                HttpServiceUrl   = "",
                                HttpSuccessCode  = "200",
                                JsonBody         = "",
                                OutputProjection = ""
                            },
                            EventDatabaseOptions = new Portal.Entities.Components.Controls.EventDatabaseOptions
                            {
                                BoundData            = System.Array.Empty <string>(),
                                DatabaseConnectionId = "",
                                EntityName           = "",
                                Query            = "",
                                OutputProjection = ""
                            },
                            TriggerEventOptions = new Portal.Entities.Components.Controls.TriggerEventOptions
                            {
                                EventsList = System.Array.Empty <string>()
                            }
                        }
                    };
                    break;

                default:
                    control.PageControlEvents = new List <Portal.Entities.Components.Controls.PageControlEvent>
                    {
                        new Portal.Entities.Components.Controls.PageControlEvent
                        {
                            EventName               = control.Name + "_change",
                            EventActionType         = Portal.Entities.Components.Controls.EventActionType.TriggerEvent,
                            EventHttpServiceOptions = new Portal.Entities.Components.Controls.EventHttpServiceOptions
                            {
                                BoundData        = System.Array.Empty <string>(),
                                HttpMethod       = "Get",
                                HttpServiceUrl   = "",
                                HttpSuccessCode  = "200",
                                JsonBody         = "",
                                OutputProjection = ""
                            },
                            EventDatabaseOptions = new Portal.Entities.Components.Controls.EventDatabaseOptions
                            {
                                BoundData            = System.Array.Empty <string>(),
                                DatabaseConnectionId = "",
                                EntityName           = "",
                                Query            = "",
                                OutputProjection = ""
                            },
                            TriggerEventOptions = new Portal.Entities.Components.Controls.TriggerEventOptions
                            {
                                EventsList = System.Array.Empty <string>()
                            }
                        }
                    };
                    break;
                }
            }
        }