Data Interface Construction
The interface is designed mainly in the component class. The server can refactor it through the integrated interface, and the client calls the interface to implement the function.
The Interface Class exposes the methods, return values, and parameter types that the client needs to call.
// The interface class public interface icarremoteservice {Boolean hascontrolled {Get; set;} // whether the data class has been occupied by other customers void begintransaction (string Xid ); void committransaction (string Xid); void rollback (string Xid); void searchcaravail (string location, ref int availnum); Boolean insertcar (string locationstring, int price, int numcars ); boolean deletecar (string locationstring); List <car> retallcar (); // returns all car rental information Boolean fixcar (string locationstring); // book a car somewhere}
Common method hascontrol: the type is boolean. Indicates whether the data class is currently available. In future transaction processing, when a method needs to operate the dataset, the flag location must be set to true, in this way, the terminus will not allow other programs to operate on this data set.
The public method begintransaction (), the parameter to be passed is the transaction number. This method is used to perform previous operations on the data set, such as locking and data backup.
The public method committransaction () is used to perform operations on the data set when the transaction is committed.
The public method rollback () is used to perform operations on the data set when the transaction is canceled. The data is restored to the corresponding backup status based on the passed transaction number.