private static Guid CreateControlTables(
            string connectionString, int commandTimeoutSecs, int maxDegreeOfParallelism, Pipelines pipelineOptions)
        {
            var ctrl = new ControlSchema(connectionString, commandTimeoutSecs, maxDegreeOfParallelism, pipelineOptions);

            return(ctrl.CreateTables());
        }
        public static void EnsureSourceTimetablesAreRegistered(
            string adminConnectionString,
            int timeoutSecs,
            IReadOnlyList <SourceTimetableData> timetables,
            int maxDegreeOfParallelism,
            Pipelines pipelineOptions)
        {
            var cs = new ControlSchema(adminConnectionString, timeoutSecs, maxDegreeOfParallelism, pipelineOptions);
            var registeredTimetables = cs.GetSourceTimetableRecords();

            foreach (var tt in timetables)
            {
                var found = registeredTimetables.FirstOrDefault(x => x.Identifier == tt.Identifier);
                if (found != null)
                {
                    if (!found.Name.Equals(tt.Name))
                    {
                        throw new ApplicationException($"Found timetable with guid = {tt.Identifier} but registered under a different timetable name");
                    }
                }
                else
                {
                    found = registeredTimetables.FirstOrDefault(x => x.Name == tt.Name);
                    if (found != null)
                    {
                        throw new ApplicationException($"Found timetable with name = {tt.Name} but registered under a different guid");
                    }
                }

                if (found == null)
                {
                    RegisterSourceTimetable(adminConnectionString, timeoutSecs, tt);
                }
            }
        }
示例#3
0
 public override void SetSchema(ControlSchema controlSchema)
 {
     // set stuff like our press depth, mesh generation, etc...
     // based off the data in the schema
     transform.localPosition = controlSchema.Position;
     transform.localRotation = controlSchema.Rotation;
     _name = controlSchema.Name;
 }
示例#4
0
        public override void SetSchema(ControlSchema controlSchema)
        {
            // set things based off the schema
            transform.localPosition = controlSchema.Position;
            transform.localRotation = controlSchema.Rotation;
            _name = controlSchema.Name;

            buttonSchema = ButtonSchema.CreateFromControl(controlSchema);
        }
示例#5
0
        public override ControlSchema GetSchema()
        {
            ControlSchema schema = new ControlSchema()
            {
                Name     = _name,
                Position = transform.localPosition,
                Rotation = transform.localRotation,
                Type     = GetControlType()
            };

            return(schema);
        }
示例#6
0
        public Dictionary <string, Guid> InitFromTemplate(ControlSchema template, Guid formId)
        {
            ParentFormId = formId;

            //template will have three subitems in 'Controls'
            //first is header
            //last is footer
            //second (middle one) is body which will be repeated to the number of rows
            //for each repeat, we will update bindings and add a rowIndex property
            //bindings of rows will point to grid as bindingsource and also bindingKey will be as specified in the schema
            //BindingId will be PK of that row
            //In case of bindingsource=parentForm we will not set any information because form is data provider.
            return(new Dictionary <string, Guid>());
        }
        /// <summary>
        /// Checks existence and validity of the admin database...
        /// </summary>
        public static void Execute(
            string connectionString, int commandTimeout, int maxDegreeOfParallelism, Pipelines pipelineOptions)
        {
            _log.Debug("Checking existence and validity of admin database");

            // Check that db is the current version...
            var ctrl = new ControlSchema(connectionString, commandTimeout, maxDegreeOfParallelism, pipelineOptions);
            int ver  = ctrl.GetDatabaseVersion();

            _log.DebugFormat("Admin database version = {0}", ver);

            if (ver > 0 && ver != ControlSchema.LatestAdminDbVersion)
            {
                throw new ApplicationException($"Admin database version = {ver}, expecting {ControlSchema.LatestAdminDbVersion}");
            }

            _log.Debug("Admin database version is correct");
        }
示例#8
0
        private RowCountAndDuration ExtractTimetablesToStage(IReadOnlyList <SourceTimetableData> srcTimetableRecs, string stageSchemaName)
        {
            var stats = new RowCountAndDuration();

            var b      = StagingTablesBuilder.Get(stageSchemaName);
            var tables = b.GetTables();

            var cs = new ControlSchema(AdminConnectionString, Timeouts.AdminDatabase, _configuration.MaxDegreeOfParallelism, _configuration.Pipelines);

            // don't use Parallel.ForEach here (no gain)
            var processedTimetables = new HashSet <int>();

            foreach (var tt in srcTimetableRecs)
            {
                _log.DebugFormat("Extracting timetable ({0}) to stage ({1})", tt.Name, stageSchemaName);

                var ttRec = cs.GetSourceTimetableRecord(tt.Identifier);
                if (ttRec == null)
                {
                    throw new ApplicationException(string.Format("Could not find source timetable registration: {0}", tt.Name));
                }

                // sanity check...
                if (processedTimetables.Contains(ttRec.Id))
                {
                    throw new ApplicationException(string.Format("Already processed a timetable with this Id: {0}", ttRec.Id));
                }

                processedTimetables.Add(ttRec.Id);

                // don't use Parallel.ForEach here (no gain)
                foreach (var t in tables)
                {
                    var stagingTable = (V7StagingTable)t;

                    using (var p = new StagingEtlProcess(
                               tt.ConnectionString,
                               AdminConnectionString,
                               stagingTable,
                               stageSchemaName,
                               Timeouts,
                               ttRec.Id,
                               _configuration.Pipelines))
                    {
                        p.Execute();
                        stats += p.Stats;

                        var errors = p.GetAllErrors().ToArray();

                        if (errors.Any())
                        {
                            var msg = $"Errors occurred during execution of staging process: {stagingTable.Name}";
                            _log.Error(msg);

                            // throw the first exception
                            throw new ApplicationException(msg, errors[0]);
                        }
                    }
                }
            }

            return(stats);
        }
示例#9
0
        public FormSchema Build(IProvider provider, string tblName)
        {
            FormSchema schema = new FormSchema(CID.New("WinForm"));

            schema.Name = tblName;

            ControlSchema feeder = new ControlSchema(CID.New("RowFeeder"));

            schema.Controls.Add("Feeder1", feeder);


            DBField[] fields = provider.GetFieldsInfo(tblName);

            foreach (DBField field in fields)
            {
                ControlSchema ctl = new ControlSchema(CID.New("TextBox"));
                ctl.Properties.Add("Text", field.name);
                ctl.Bindings.Add("Text", new BindingSchema(field.name));
                schema.Controls.Add(field.name, ctl);

                if (field.name == "PK_ID")
                {
                    ctl.AddServiceEventHandler("TextChanged", "Feeder1", "FeedRowStr");
                }
            }

            ControlSchema req = new ControlSchema(CID.New("RequiredFieldValidator"));

            req.Bindings.Add("FieldToValidate", new BindingSchema(fields[0].name));

            ControlSchema reqLabel = new ControlSchema(CID.New("Label"));

            reqLabel.Properties.Add("Text", "id is required");
            req.Controls.Add("ReqLbl1", reqLabel);

            schema.Controls.Add("Req1", req);


            ControlSchema saver = new ControlSchema(CID.New("DataSaver"));

            schema.Controls.Add("Saver1", saver);

            ControlSchema ok = new ControlSchema(CID.New("Button"));

            ok.Properties.Add("Text", "Save");

            ok.AddConnectorEventHandler("Click", null, "FormSubmit"); //null means form
            ok.AddServiceEventHandler("Click", "Saver1", "SaveData");

            schema.Controls.Add("OKButton", ok);

            ControlSchema grid = new ControlSchema(CID.New("DataGrid"));

            grid.Properties.Add("TableName", "TABLE1");
            grid.Properties.Add("Columns", new string[] { "PK_ID", "USER_NAME", "USER_SCORE" });
            grid.Properties.Add("ColumnHeaders", new string[] { "ID", "User Name", "User Score" });
            schema.Controls.Add("Grid1", grid);

            //schema.WriteForm("form.xml");

            //XmlSerializer xml = new XmlSerializer(typeof(FormSchema));
            //FileStream fs = new FileStream("a.xml", FileMode.Create);
            //xml.Serialize(fs, schema);

            return(schema);
        }