[Original] Java online editing word document calls PageOffice to achieve concurrency control

1 . Features

  PageOffice's concurrency control function is used to solve the technical problem that multiple users may overwrite the modification results of each other when editing the same document online.

  Under the B/S architecture, user access is concurrent, that is to say, N users often send requests to a server page at the same time, which makes it possible for the same document to be opened and edited by multiple users at the same time. Why do they overlap each other? For a simple example, for example, user A first visits the page and opens a document to start editing. At this time, user B visits the same page and opens the same document and starts editing. User B may complete the document modification work soon and save it to the server. . Then user A also completes the work and saves the document to the server. At this time, the document on the server has become the final result of user A's modification, and user B's modification is overwritten by A's save operation and disappears.

  PageOffice's concurrency control can ensure that the same document can only be opened by one person at the same time, and such complex control only requires developers to simply assign values ​​to the TimeSlice property. No matter whether the opened document is stored in the database or in the physical disk, as long as concurrency control is set for this document, the effect is that only the current user can edit and save this document, and other users can only read the document as read-only. form open. During concurrency control, other users have three options, "Abort", "Retry", and "Ignore". Select "terminate" to close the current prompt dialog box and do nothing to this document; select "retry", you can know whether the editing time of the current operating user has expired, and you can see the remaining editing of the current operating user. time; select "Ignore" to open this document in read-only mode, that is, you can only read this document, and cannot edit, modify, or save this document.

2. How to implement concurrency control

  Set the property TimeSlice before WebOpen. For example, set PageOfficeCtrl1.TimeSlice = 4; then the editing time of this document by the logged-in user is 4 minutes. The user must perform operations such as editing and saving before the end of the editing time. After the editing time ends, the unsaved content edited by the user will not be saved.

  PageOfficeCtrl1.TimeSlice = 4;//Enable concurrency control on the current document

  TimeSlice is only valid for the document currently opened by WebOpen. If it is not assigned a value, concurrency control will not be performed. The default value is 0, which means no concurrency control.

  Note: 1. The same document mentioned here is judged by the first parameter of WebOpen. If the first parameter of the two WebOpens is exactly the same, it is regarded as the same document, and if it is different, it is regarded as a different document.

        2. If the first parameter of the two WebOpens is the same, and the third parameter (user name) is also the same, it is considered that the user refers to the original file while modifying and editing the document, which is a special need, and the concurrency control cannot be carried out at this time. effect.

  WebOpen directly opens the document or opens the document output by the dynamic page, which can realize concurrency control:

  (1) Open the document directly, the first parameter of WebOpen is the end of the office file name.

    For example, user a's operation of opening a document is as follows:

    PageOfficeCtrl1.TimeSlice = 4;

    PageOfficeCtrl1.WebOpen("doc/abc.doc", PageOffice.OpenModeType. docAdmin, "a");

    The operation of user b's open document is as follows:

    PageOfficeCtrl1.TimeSlice = 4;

    PageOfficeCtrl1.WebOpen("doc/abc.doc", PageOffice.OpenModeType. docAdmin, "b");

    Then if concurrency control is set for the document doc/abc.doc, when a opens this document, b can only open this document in read-only mode, and b can not edit this document until the control time of a expires .

  (2) Open the document through the dynamic page, the first parameter of WebOpen is the address of a dynamic page, and also has the parameter value.

    For example, user a's operation of opening a document is as follows:

    PageOfficeCtrl1.TimeSlice = 4;

    PageOfficeCtrl1.WebOpen("a.aspx?id=1", PageOffice.OpenModeType. docAdmin, "a");

    The operation of user b's open document is as follows:

    PageOfficeCtrl1.TimeSlice = 4;

    PageOfficeCtrl1.WebOpen("a.aspx?id=1", PageOffice.OpenModeType. docAdmin, "b");

    Then if concurrency control is set on the document downloaded from the a.aspx?id=1 address, when a opens the document, b can only open the document in read-only mode, and b can only open the document in read-only mode until the control time of a expires. Edit this document.

3 . Under what circumstances, concurrency control does not work?

  The same office file can be downloaded with two different url addresses. When two users use different addresses to open the same office file, concurrency control will not work.

  (1) For example, two different dynamic page addresses can download the same file: address a.aspx?id=1 and address b.aspx?id=1 download the same document on the server side, and user a opens it The code for the documentation is:

    PageOfficeCtrl1.TimeSlice = 4;

    PageOfficeCtrl1.WebOpen("a.aspx?id=1", PageOffice.OpenModeType.docAdmin, "a");

    The code for user b's open document is:

    PageOfficeCtrl1.TimeSlice = 4;

    PageOfficeCtrl1.WebOpen("b.aspx?id=1", PageOffice.OpenModeType. docAdmin, "b");

    In this way, although "a.aspx?id=1" and "b.aspx?id=1" open the same document, because the first parameter value of WebOpen is different, the URL for opening the document is also different for PageOffice. PageOffice thinks it's two different files, in which case concurrency control doesn't work.

  (2) For example, a dynamic page address and a URL address ending with a document name: the file downloaded by accessing "a.aspx?id=1" is doc/abc.doc, and the code for user a to open the document is:

    PageOfficeCtrl1.TimeSlice = 4;

    PageOfficeCtrl1.WebOpen("a.aspx?id=1", PageOffice.OpenModeType. docAdmin, "a");

    The code for user b's open document is:

    PageOfficeCtrl1.TimeSlice = 4;

    PageOfficeCtrl1.WebOpen("doc/abc.doc", PageOffice.OpenModeType. docAdmin, "b",);

    Or because the first parameter value of WebOpen is different, although the same document is opened, but because PageOffice thinks that the URLs of the two documents are different, the concurrency control does not work.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325302574&siteId=291194637