Introduction A feature used to distinguish between MIDAS and other distributed database solutions is that MIDAS supports dynamic data constraints. These dynamic constraints can control the appearance, service confirmation rules, whether or not to display, and so on by appserver to the profile of the thin client. Author (John Kaster) believes this is a very important feature that is needed for distributed databases. MIDAS Packet (Data Packets) Overview First introduces the detailed feature of the MIDAS packet format, the MIDAS Packet (Data Packet) is a binary stream format data independent of the language and neutral transmission (TRANSTORT). Includes metadata, constraints, data (data), and Deltas. Metadata is used to describe a data set distributed in accordance with AppServer. MIDAS 2, 3 supports nested data sets, so a single packet can contain an information on multiple data sets. Constraint is the relevant business rules used to check and display each field in the data set. DATA is the actual data field and number of records of the data set. Deltas records the log of the client's data modification, and is automatically maintained and transmitted to the Appserver. Midas Data field constraint data field constraints are propagating between AppServer and client programs, quickly modifying business rules, very easy to publish new clients, based on server-side business rules, can automatically apply to customer programs, enhance The survival cycle of the distributed application system and the maintenanceability of the system. If there is no sufficient reason, the client should force the execution of the server-based business rules, which will provide the application system reliability and data accuracy, because there is a problem with the data packet will be immediately detected by the client, so it should be cultivated The correct use of data values and the habit of reducing network loops for invalid data.
Simply put, data constraints allow you to quickly build a distributed system, respond to relevant modifications and improve system reliability MIDAS 2,3 packets to automatically pass the following data field properties by appserver to the client: Constraint Property Description -------------------------------------------------- ------------------------------------------ CONSTRAINTERRORMESSAGE MESSAGE to DISPLAY IF DATA for the field if not valid Example:. CustNo can not be blank CustomConstraint Constraints to place on the validation of the field Expressions can be used for this constraint Example:.. CustNo IS nOT NULL DisplayFormat Controls formatting of the field for display DisplayLabel Used as the data field's default column heading Example:. Customer # EditMask Used for customizing data entry for the field Example:. 0000 MaxValue The maximum value of a numeric field MinValue The minimum value of a numeric field visible A boolean value indicating whether the field should be visible In a Grid by DEFAULT Realization Constraint Editor Server As long as the client is connected to Midas Server, the related RDM (Remote Data Module) will automatically create and provide customers to access the Server constraint editing server (consTsvr.exe) in the first Use these R times DM will get the list of provider and contain in these Provider in these provike. Constraintsvr also provides a user interface for editing field constraints in each provder and saves the result instance for each application instance. After the change is saved (in the system running period), the client only needs to simply reconnect AppServer, get a new packet, which contains new business constraints. A Cast Of Variants starts establishing an application that provides operational period editing data constraints, just do a little code customization. The Screen object has a property that can list all the data modules in an application, and we can also create a list of providers included in the data module by checking this property. This Provider name list is output from the data module through a variable type, and also needs to receive the Provider naming of the data module through the appropriate Delphi type.
Code is as follows: {Copyright (c) 1999 - 2000 by John Kaster, Dan Miser and Louis Kleiman} procedure GetProviderList (ProviderList: TStrings); varProviderNames: OLEVariant; I: Integer; DataSet: TDataSet; GenObject: TComponent; beginif (Screen.DataModuleCount = 0) thenRaise Exception.Create ( 'No data modules are active.'); ProviderList.Clear; {Get the list of all providers for the first data module.All instances of the data module are probably the same.} ProviderNames: = IConstraints (TConstraints (Screen.DataModules [0])) AS_GetProviderNames; for I:. = VarArrayLowBound (ProviderNames, 1) toVarArrayHighBound (ProviderNames, 1) dobegin {Retrieve the component matching the provider name} GenObject: = Screen.DataModules [0] .FindComponent (ProviderNames [I]); if (GenObject is TDataSetProvider) thenDataSet: = TDataSetProvider (Screen.DataModules [0] .FindComponent (ProviderNames [I])) DataSetelse if (GenObject is TDBDataSet) thenDataSet: = TDataSet (Screen.. DataModules [0] .findcomponent (providernames [i])) ElseDataSet: = Ni L; {add it to the list of providers, attaching the dataset if assigned} provikerlist.addObject; {get; {for} end; {getProviderList ()} Receive Contents Now get from RDM instance acquisition The Provider list, others are some traditional Delphi code. The provike is displayed by a list box element, and the field constraint value of each provider is displayed by another list box element. The Provider list box element is named lbProviders.
Code is as follows: procedure TFormConstraintsEditor.lbProvidersClick (Sender: TObject); varDataSet: TDataSet; I: Integer; SaveActive: Boolean; beginlbFields.Clear; DataSet: = TDataSet (lbProviders.Items.Objects [lbProviders.ItemIndex]); if Assigned (DataSet ) ThenbeginsaveAvective: = dataset.active; dataset.open; tryfor i: = 0 to dataset.fieldcount - 1 dolbfield.Items.addObject (dataset.fields [i] .fieldname, dataset.fields [i]); FinallyDataSet.active: = SaveACTIVE; END; {Try ... finally} end; {if} end; Editing Configuration Value Now uses the editing component to assign a value for the selected field. Drag and drop these controls to the form, and then assign a value to the editing element in the following Click event. Field field list box components are named lbfields.
Code is as follows: procedure TFormConstraintsEditor.lbFieldsClick (Sender: TObject); varField: TField; beginField: = TField (lbFields.Items.Objects [lbFields.ItemIndex]); if Assigned (Field) thenbeginedErrorMessage.Text: = Field.ConstraintErrorMessage; edCustomConstraint. Text: = Field.CustomConstraint; edDisplayLabel.Text: = Field.DisplayLabel; edEditMask.Text: = Field.EditMask; edDisplayFormat.Text: = ''; edMinValue.Text: = ''; edMaxValue.Text: = ''; cbVisible .Checked: = Field.Visible; if Field is TNumericField thenbeginwith Field as TNumericField doedDisplayFormat.Text: = DisplayFormat; if Field is TFloatField thenwith Field as TFloatField dobeginedMinValue.Text: = FloatToStr (MinValue); edMaxValue.Text: = FloatToStr (MaxValue) ; endelse if Field is TBCDField thenwith Field as TBCDField dobeginedMinValue.Text: = FloatToStr (MinValue); edMaxValue.Text: = FloatToStr (MaxValue); endelse if Field is TIntegerField thenwith Field as TIntegerField dobeginedMinValue.Text: = IntToStr (MinValue); edMaxValue .Text: = INTTOST r (MaxValue); endelse if Field is TLargeIntField thenwith Field as TLargeIntField dobeginedMinValue.Text: = IntToStr (MinValue); edMaxValue.Text: = IntToStr (MaxValue); end; endelse if Field is TDateTimeField thenwith Field as TDateTimeField doedDisplayFormat.Text: = DisplayFormat; End; {if} end; Submitted the edited constraint value to the field field to confine the corresponding value, you need to submit these constraint values.
Code is as follows: procedure TFormConstraintsEditor.actApplyExecute (Sender: TObject); varField: TField; beginField: = TField (lbFields.Items.Objects [lbFields.ItemIndex]); if Assigned (Field) thenbeginField.ConstraintErrorMessage: = edErrorMessage.Text; Field. CustomConstraint: = edCustomConstraint.Text; Field.DisplayLabel: = edDisplayLabel.Text; Field.EditMask: = edEditMask.Text; Field.Visible: = cbVisible.Checked; if Field is TNumericField thenbeginwith Field as TNumericField doDisplayFormat: = edDisplayFormat.Text; if Field is TFloatField thenwith Field as TFloatField dobeginMinValue: = StrToInt (edMinValue.Text); MaxValue: = StrToInt (edMaxValue.Text); endelse if Field is TBCDField thenwith Field as TBCDField dobeginMinValue: = StrToInt (edMinValue.Text); MaxValue: = StrToInt (edMaxValue.Text); endelse if Field is TIntegerField thenwith Field as TIntegerField dobeginMinValue: = StrToInt (edMinValue.Text); MaxValue: = StrToInt (edMaxValue.Text); endelse if Field is TLargeIntField thenwith Field as TLargeIntF ield dobeginMinValue: = StrToInt (edMinValue.Text); MaxValue: = StrToInt (edMaxValue.Text); end; endelse if Field is TDateTimeField thenwith Field as TDateTimeField doDisplayFormat: = edDisplayFormat.Text; end; {if} end; now created The main code of Constraintsvr, the details can be downloaded. Creating a Forced Constraint Client Customer Program is simple to create a server program because he only needs to simply receive a modified packet without having to write Server's knowledge. This is a very perfect and powerful dynamic constraint program example: We only need to modify the relevant business on the server without modifying the client, and there is no need to issue a new client program.