30.4.2. Registering/unregistering applications
To register an application on the collaboration system server, use the BeginInfoBaseRegistration(), RegisterInfoBaseAsync(), and RegisterInfoBase() methods. The first two methods run in the client application and are asynchronous. The latter method runs on the server and is synchronous.
All methods get registration parameters (the CollaborationSystemInfoBaseRegistrationParameters object) and return the registration result (the CollaborationSystemInfoBaseRegistrationResult object). How the operation result is received depends on the method used:
- For the callback option: pass a reference to the notification handler (the NotifyDescription object), to which the registration result will be sent, to the BeginInfoBaseRegistration() method.
- For the promise option: the registration result will be the promise result returned by the RegisterInfoBaseAsync() method.
- For a server call: the registration result will be the method result.
In the CollaborationSystemInfoBaseRegistrationResult object, the registration status is displayed by the RegistrationCompleted property. If the registration is not completed, the MessageText property contains the information for the user.
The registration is performed in several steps:
- In the first step, the parameters of the registered application are passed to the server of the collaboration system. To do this, fill in the Email and ServerAddress properties of the CollaborationSystemInfoBaseRegistrationParameters object and call the BeginInfoBaseRegistration()/ RegisterInfoBaseAsync()/RegisterInfoBase(). method.
- In the next step, the collaboration system server sends an activation code to the email address that was specified in the previous step.
- At the final step, call the BeginInfoBaseRegistration()/RegisterInfoBaseAsync()/RegisterInfoBase() method again. In addition to the Email and ServerAddress properties, fill in the ActivationCode property. In this property, you should put the value that came in the email from the collaboration system server.
The collaboration system server address can be the 1cDialog.com server address (wss://1cdialog.com:443) or the address of the self-deployed collaboration system server.
- If no errors occurred, then by this time the registration was completed successfully. If errors occur when calling the registration method, the information for the user is passed in the MessageText property of the CollaborationSystemInfoBaseRegistrationResult object. The means to obtain the object with the registration result depend on the registration method used. After the end of registration, all cryptographic keys that are necessary for managing the collaboration system are generated and saved.
The CollaborationSystemInfoBaseRegistrationParameters.InfoBaseName property is used to specify the registered application presentation.
To unregister an application in the service, use the BeginInfoBaseUnregistration(), UnregisterInfoBaseAsync(), or UnregisterInfoBase() methods.
After successful completion of the method, users of the current application will not be able to use the collaboration system. In particular, all necessary cryptographic keys will be deleted. However, if you reregister an application using the same email, the access to the collaboration system and all the correspondence generated before the disconnection will be restored. To reregister applications:
- Explicitly specify an email. Note that if you use an email that differs from the one you used during the previous registration, you will lose access to all collaboration system objects that were generated before the disconnection. In fact, you will register a new application.
- Do not specify an email. In this case, the email that was used when the infobase was connected for the first time will be used for registration. An activation code will be sent to this email. Use this way if there is no information about the email used for registration but you are sure that this email is currently available. In this case, an email message with an activation code will help you restore the connection to the collaboration system and get the email used for the activation. If the current infobase has not been connected to the collaboration system before, reconnection without specifying an email fails.
To completely disconnect an application from the collaboration service (including the loss of access to all correspondence generated when operating in the application), use the SetInfoBaseRegistrationData() method to which you pass the Undefined value as the registration data. After this action, the application registration is canceled, and access to messages is irretrievably lost.
The SetInfoBaseRegistrationData() method has a paired method, GetInfoBaseRegistrationData(), which allows you to get all the information about the collaboration system connected to the server as a single object. This object contains all the information that was specified during registration, as well as all cryptographic keys that are used to operate with the collaboration system server. If you transfer this data as a parameter of the SetInfoBaseRegistrationData() method, the collaboration system considers the application where this action is performed to be completely equivalent to the application where the data used for the installation was obtained. Therefore, the main purpose of the Get/SetInfoBaseRegistrationData() method pair is data area migration between different databases.
The last thing you should know about registering an application in the collaboration service is how you can get various information about the collaboration server and its "relations" with the current infobase. For this, use the following methods:
Method |
Description |
ServerAddress() |
Returns the address of the collaboration system server where the infobase is registered. |
SubscriberEmail() |
Returns the email address used for registering the infobase. |
ServerVersion() |
Returns the version of the collaboration system server where the infobase is registered. |
InfoBaseRegistered() |
Checks whether the application is registered in the service and this registration is not disabled. |
CanUse() |
Checks whether the application is registered in the service, the registration is not disabled, and the application has users. |
CurrentUserIsSubscriberAdministrator() |
Checks whether the current collaboration system user is a subscriber administrator. |