Summary: MiDAS in the dynamic mandatory constraint programming

xiaoxiao2021-03-06  24

MiDAS dynamic forced constraint programming

Author: Chen Jiao Introduction

One feature used to distinguish 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, etc. 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 propagated between Appserver and client programs, which can quickly modify business rules, very easy to publish new clients, based on server-side business rules, can automatically apply to client programs, enhance distributed application The survival cycle 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, promptly respond to relevant modifications and improve the system's reliability MIDAS 2,3 packets to automatically pass the following data field properties by appServer to the client: Constraint Property DescriptionConterrorMessage Message to display if data for the field if not valid Example:. CustNo can not be blankCustomConstraint Constraints to place on the validation of the field Expressions can be used for this constraint Example:.. CustNo IS nOT NULLDisplayFormat Controls formatting of the field for displayDisplayLabel 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 fieldMinValue The minimum value of a numeric fieldVisible A boolean value indicating whether the field should be visible in a grid by default implementation constraints editing server (Constraint Editor Server) as long as the client is connected to the MIDAS Server, related RDM (remote Data Module Automatically creates and supplied to customers to access the Server Constraint Editing Server (ConstraintSvr.exe) will get the list of providerues and contain in these provikes in these provikes. 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. The code is as follows: {CopyRight (c) 1999 - 2000 by John Kaster, Dan Miser and Louis Kleiman} Procedure GetProviderList (provikerlist: tstrings); var

Providernames: olevariant; i: integer;

DataSet: TDataSet; GenObject: Tcomponent; Begin

IF (Screen.DataModulecount = 0) The Raise 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) To VararrayHighBound (providernames, 1) do begin

{Retrieve the component matching the provider name} GenObject:. = Screen.DataModules [0] .FindComponent (ProviderNames [I]); if (GenObject is TDataSetProvider) then DataSet: = TDataSetProvider (Screen.DataModules [0] FindComponent (ProviderNames [ I])). DataSet Else IF (GenObject is TdbDataSet) THEN DATASET: = TDataSet (Screen.DataModules [0]. FindComponent (providernames [i])) ElseDataSet: = nil; {add it to the list of providers, attaching the DataSet if assigned} provikerlist.addobject (provindernames [i], dataset; end; {for}

End; {getProviderList ()} Receive constraint content

Now get the Provider list from RDM instance, 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. The code is as follows: Procedure TFormConstraintseditor.lbProvidersClick (Sender: Tobject); VAR

DataSet: TDataSet; i: integer;

SaveActive: Boolean; Begin

lbfields.clear; dataset: = tdataset (lbProviders.Items.Objects [lbproviders.ItemIndex]); if Assigned (Dataset) THEN BEGIN

SaveActive: = dataset.active; dataset.open;

Try for i: = 0 to dataset.fieldcount - 1 do lbfields.Items.addObject (dataset.fields [i] .fieldname, dataset.fields [i]);

Finally DataSet.Active: = sactive; end; {try ... finally} end; {i}

End; edit constraint content value

Now use editing components 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. The code is as follows: procedure tformconstraintseditor.lbfieldsclick (sender: TOBJECT); VAR

Field: Tfield; Begin

Field: = tfield (lbfields.Items.Objects [lbfields.ItemIndex]); if Assigned (Field) THEN Begin

edErrorMessage.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 then beginwith Field as TNumericField do edDisplayFormat.Text: = DisplayFormat; if Field is TFloatField then with Field as TFloatField do begin

Edminvalue.Text: = floattostr (minValue); edmaxvalue.text: = floattostr (maxValue); End

Else if Field Is Tbdfield Then with Field As Tbcdfield Do Begin

Edminvalue.Text: = floattostr (minValue); edmaxvalue.text: = floattostr (maxValue); End

Else if Field Is Tintegerfield Then With Field As Tintegerfield Do Begin

Edminvalue.Text: = INTOSTR (minValue); edmaxvalue.text: = INTOSTR (maxValue);

Else if Field Is TirgeinTfield The with Field As Tirgeintfield Do Begin

Edminvalue.Text: = INTOSTR (minValue); edmaxvalue.text: = INTTOSTR (MaxValue);

END ELSE IFORD IS TDATETIMEFIELD IHEN WIELD As TdateTimefield Do EddisplayFormat; End; {if}

End; submit the edited constraint value

After the corresponding value is confusing to the field field, you need to submit these constraint values. The code is as follows: procedure tformconstraintseditor.Actapplyexecute (sender: TOBJECT); VAR

Field: Tfield; Begin

Field: = tfield (lbfields.Items.Objects [lbfields.ItemIndex]); if Assigned (Field) THEN Begin

Field.ConstraintErrorMessage: = edErrorMessage.Text; Field.CustomConstraint: = edCustomConstraint.Text; Field.DisplayLabel: = edDisplayLabel.Text; Field.EditMask: = edEditMask.Text; Field.Visible: = cbVisible.Checked; if Field is TNumericField then Beginwith Field As TNUMERICFIELD Do DISPLAYFORMAT: = EddisplayFormat.Text; if Field Is Tfloatfield Then With Field As Tfloatfield Do Begin

MinValue: = start (edminvalue.text); maxValue: = start (edmaxvalue.text); END

Else if Field Is Tbdfield Then with Field As Tbcdfield Do Begin

MinValue: = start (edminvalue.text); maxValue: = start (edmaxvalue.text);

Else if Field Is Tintegerfield Then With Field As Tintegerfield Do Begin

MinValue: = start (edminvalue.text); maxValue: = start (edmaxvalue.text); END

Else if Field Is TirgeinTfield The with Field As Tirgeintfield Do Begin

MinValue: = start (edminvalue.text); maxValue: = start (edmaxvalue.text);

END ELSE IFORD IS TDATETIMEFIELD THEN WIELD As TdateTimefield Do DisplayFormat: = EddisplayFormat.Text; End; {if}

END; the main code of ConstraintsVR is now created, and the details can be downloaded. Create a forced constraint customer program

The client program is simple to easily Dora, 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. Establish a client program with the following steps: DCMMCONNECTION component settings: removeserver = constraintsvr.constraints Drag a ClientDataSet component setting: removeserver = dcomconnection1 setting: proviker = prVcusTomer DataSource

Setting: DataSet = ClientDataSet1 Drag a DBNAVIGATOR

Setting: DataSource = DataSource1 Drag a Button

Provided: Name = btnOpen double-click button click event established, btnOpenClick event code as follows: procedure TFormConstraintClient.BtnOpenClick (Sender: TObject); beginif ClientDataSet1.Active then ClientDataSet1.Close; ClientDataSet1.Open; {Refresh the dataset} BtnOpen.Caption: = ' & Reopen '; END;

转载请注明原文地址:https://www.9cbs.com/read-79503.html

New Post(0)