📄 replicationprompt.jsp
字号:
<%@ page import="java.util.*" %>
<%@ page import="org.ofbiz.base.util.*" %>
<%@ page import="com.sourcetap.sfa.util.Preference" %>
<%@ page import="com.sourcetap.sfa.ui.*" %>
<%@ page import="com.sourcetap.sfa.replication.*" %>
<%@ include file="/includes/header.jsp" %>
<SCRIPT LANGUAGE="javascript">
function verifyRequiredReplRegistration(frm) {
if (isEmpty(frm.replNodeName.value)) {
showMessage("Node Name is required.", frm.replNodeName);
return false;
}
if (isEmpty(frm.ownerId.value)) {
showMessage("Node Owner is required.", frm.ownerId);
return false;
}
}
// Display a message to user and highlight invalid field.
function showMessage(sMessage, objField) {
alert(sMessage)
objField.focus()
return
}
// general purpose function to see if an input value has been entered at all
function isEmpty(inputStr) {
if (inputStr == "" || inputStr == null) {
return true;
}
return false;
}
function verifyStart() {
return confirm("WARNING!\n\nAll data in the local data base will be erased!\n\nContinue?");
}
</SCRIPT>
<%@ include file="/replication/replicationHeader.jsp" %>
<%
boolean allowReplication = false;
GenericDelegator masterDelegator = GenericDelegator.getGenericDelegator("master");
if (masterDelegator==null) {
%>
<TR>
<TD COLSPAN="3" CLASS="freeFormSectionField">
A problem occurred while trying to connect to the master data base.
</TD>
</TR>
<%
// "Modify the entityengine.xml file on your PC<BR>" +
// "to add a delegator with the name 'master' pointing to the correct IP address.<BR>" +
// "Then restart the web server on your PC and try again.");
return;
}
GenericReplicator genericReplicator =
new GenericReplicator(
delegator,
masterDelegator
);
// Verify user ID and password.
String replUserLoginId = request.getParameter("replUserLoginId") == null ?
"" : request.getParameter("replUserLoginId");
String replPassword = request.getParameter("replPassword") == null ?
"" : request.getParameter("replPassword");
UserInfo masterUserInfo = new UserInfo();
String errorMessage = genericReplicator.validateMasterLogin(
replUserLoginId, replPassword, masterUserInfo);
if (!errorMessage.equals("Success")) {
%>
<TR>
<TD COLSPAN="3" CLASS="freeFormSectionField">
<%= errorMessage %>
</TD>
</TR>
<%
return;
}
String replNodeId = genericReplicator.getReplNodeId(delegator);
UIUserDropDown uiUserDropDown = new UIUserDropDown();
try {
// Get a list of users from the master data base.
List userGVL = uiUserDropDown.getDropDownValuesDynamic(
masterDelegator,
null,
masterUserInfo);
if (replNodeId == null || replNodeId.equals("")) {
if (request.getParameter("replRegistrationContinue") == null) {
// The menu item for replication was selected from the main menu, or user is trying
// again after a failed attempt. Ask the user for registration info.
%>
<FORM METHOD="post" ACTION="/sfa/control/replicationPrompt">
<INPUT TYPE="HIDDEN" NAME="replUserLoginId" VALUE="<%=replUserLoginId%>">
<INPUT TYPE="HIDDEN" NAME="replPassword" VALUE="<%=replPassword%>">
<INPUT TYPE="HIDDEN" NAME="masterUserPartyId" VALUE="<%= masterUserInfo.getPartyId() %>">
<INPUT TYPE="HIDDEN" NAME="masterUserAccountId" VALUE="<%= masterUserInfo.getAccountId() %>">
<INPUT TYPE="HIDDEN" NAME="masterUserRoleId" VALUE="<%= masterUserInfo.getRoleId() %>">
<TR>
<TD COLSPAN="3" CLASS="freeFormSectionField">
This computer is not yet registered for replication.
</TD>
</TR>
<TR>
<TD COLSPAN="3" CLASS="freeFormSectionField">
</TD>
</TR>
<TR>
<TD COLSPAN="3" CLASS="freeFormSectionField">
To register this computer as a replicated node, enter the<BR>requested information, and click Continue.
</TD>
</TR>
<TR>
<TD COLSPAN="3" CLASS="freeFormSectionField">
</TD>
</TR>
<TR>
<TD COLSPAN="3" CLASS="freeFormSectionField">
</TD>
</TR>
<TR>
<TD CLASS="freeFormSectionLabel" WIDTH="100">Node Name:</TD>
<TD CLASS="freeFormSectionField" WIDTH="200">
<INPUT TYPE="text" NAME="replNodeName" VALUE="" SIZE="40" MAXLENGTH="255" CLASS="freeFormSectionInputBoxMandatory">*
</TD>
<TD CLASS="freeFormSectionField" WIDTH="*"> Example: Bob Smith's Laptop</TD>
</TR>
<TR>
<TD CLASS="freeFormSectionLabel">Node Owner:</TD>
<TD CLASS="freeFormSectionField">
<%=
uiUserDropDown.getSelectHtml(
"ownerId",
20,
"",
"",
"selectBoxMandatory",
"N",
"",
UIDropDown.decodeValueArray("contactId", "firstName;\" \";lastName", "ownerId", userGVL),
masterUserInfo.getPartyId(),
false)
%>*
</TD>
<TD WIDTH="*"></TD>
</TR>
<TR>
<TD COLSPAN="3" CLASS="freeFormSectionField">
</TD>
</TR>
<TR HEIGHT="*">
<TD ALIGN="center" COLSPAN="2">
<INPUT TYPE="submit" CLASS="button" NAME="replRegistrationContinue"
VALUE="Continue" onClick="return verifyRequiredReplRegistration(this.form)">
</TD>
<TD WIDTH="*"></TD>
</TR>
</FORM>
<%
} else {
// User entered the registration info and clicked Continue. Do the registration.
// Get the values entered by the user.
String replNodeName = request.getParameter("replNodeName");
String ownerId = request.getParameter("ownerId");
// Register for replication.
replNodeId = genericReplicator.register(
replNodeName,
ownerId,
false,
masterUserInfo.getPartyId());
//out.write("Call to register method complete.<BR>\n");
if (replNodeId == null || replNodeId.equals("")) {
//out.write("Registration not complete.<BR>\n");
%>
<FORM METHOD="post" ACTION="/sfa/control/replicationPrompt">
<INPUT TYPE="HIDDEN" NAME="replUserLoginId" VALUE="<%=replUserLoginId%>">
<INPUT TYPE="HIDDEN" NAME="replPassword" VALUE="<%=replPassword%>">
<INPUT TYPE="HIDDEN" NAME="masterUserPartyId" VALUE="<%= masterUserInfo.getPartyId() %>">
<INPUT TYPE="HIDDEN" NAME="masterUserAccountId" VALUE="<%= masterUserInfo.getAccountId() %>">
<INPUT TYPE="HIDDEN" NAME="masterUserRoleId" VALUE="<%= masterUserInfo.getRoleId() %>">
<TR>
<TD COLSPAN="2" CLASS="freeFormSectionField">
A problem was encountered which prevented<BR>
your computer from being registered for replication.
</TD>
</TR>
<TR>
<TD COLSPAN="2" CLASS="freeFormSectionField">
</TD>
</TR>
<TR>
<TD COLSPAN="2" CLASS="freeFormSectionField">
Click the Register Again button to try again.
</TD>
</TR>
<TR>
<TD COLSPAN="2" CLASS="freeFormSectionField">
</TD>
</TR>
<TR HEIGHT="*">
<TD ALIGN="center" COLSPAN="2">
<INPUT TYPE="submit" CLASS="button" NAME="replRegisterAgain" VALUE="Register Again">
</TD>
</TR>
</FORM>
<%
} else {
// Registration was successful. Continue.
allowReplication = true;
}
}
} else {
// Computer is registered. Allow replication to take place.
allowReplication = true;
}
if (allowReplication) {
// The local computer is registered for replication.
// out.write("Starting main replication page. replNodeId: " + replNodeId + "<BR>\n");
// Main Replication Screen.
GenericValue replNodeGV =
genericReplicator.getReplNodeGenericValue(replNodeId);
String replNodeName = replNodeGV.getString("replNodeName");
String ownerId = replNodeGV.getString("ownerId");
boolean isActive = replNodeGV.getString("isActive").equalsIgnoreCase("Y") ? true : false;
String lastUpdatedDate = replNodeGV.getString("lastUpdatedDate") == null ?
"Never" : replNodeGV.getString("lastUpdatedDate");
HashMap contactFindMap = new HashMap();
contactFindMap.put("contactId", ownerId);
String ownerName = ownerId;
GenericValue contactGV = masterDelegator.findByPrimaryKey("Contact", contactFindMap);
String firstName = contactGV.getString("firstName") == null ? "" : contactGV.getString("firstName");
String lastName = contactGV.getString("lastName") == null ? "" : contactGV.getString("lastName");
ownerName = firstName + " " + lastName;
%>
<FORM METHOD="post" ACTION="/sfa/control/replicate">
<INPUT TYPE="HIDDEN" NAME="replUserLoginId" VALUE="<%=replUserLoginId%>">
<INPUT TYPE="HIDDEN" NAME="replPassword" VALUE="<%=replPassword%>">
<INPUT TYPE="HIDDEN" NAME="masterUserPartyId" VALUE="<%= masterUserInfo.getPartyId() %>">
<INPUT TYPE="HIDDEN" NAME="masterUserAccountId" VALUE="<%= masterUserInfo.getAccountId() %>">
<INPUT TYPE="HIDDEN" NAME="masterUserRoleId" VALUE="<%= masterUserInfo.getRoleId() %>">
<TR>
<TD COLSPAN="2" CLASS="freeFormSectionField">
Your computer is registered for replication.
</TD>
</TR>
<TR>
<TD COLSPAN="2" CLASS="freeFormSectionField">
</TD>
</TR>
<TR>
<TD CLASS="freeFormSectionLabel" WIDTH="100">Node ID:</TD>
<TD CLASS="freeFormSectionField" WIDTH="200">
<%= replNodeId %>
</TD>
</TR>
<TR>
<TD CLASS="freeFormSectionLabel" WIDTH="100">Node Name:</TD>
<TD CLASS="freeFormSectionField" WIDTH="200">
<%= replNodeName %>
</TD>
</TR>
<TR>
<TD CLASS="freeFormSectionLabel">Node Owner:</TD>
<TD CLASS="freeFormSectionField">
<%= ownerName %>
</TD>
</TR>
<TR>
<TD CLASS="freeFormSectionLabel">Last Replicated:</TD>
<TD CLASS="freeFormSectionField">
<%= lastUpdatedDate %>
</TD>
</TR>
<TR>
<TD CLASS="freeFormSectionLabel">Status:</TD>
<TD CLASS="freeFormSectionField">
<%= isActive ? "Active (Incremental replication may be used)" : "Inactive (Incremental replication cannot be used)" %>
</TD>
</TR>
<TR>
<TD COLSPAN="2" CLASS="freeFormSectionField">
</TD>
</TR>
<TR>
<TD COLSPAN="2" CLASS="freeFormSectionField">
Select replication type and click the Start button to begin replication.<BR><BR>
</TD>
</TR>
<TR>
<TD></TD>
<TD CLASS="freeFormSectionField">
<INPUT TYPE="radio" NAME="replicationType" VALUE="Incremental"
<%
// if (isActive) {
// out.write(" CHECKED");
// } else {
out.write(" DISABLED");
// }
%>
>Incremental (Fastest)<BR>
<INPUT TYPE="radio" NAME="replicationType" VALUE="Full"
<%
// if (!isActive) {
out.write(" CHECKED");
// }
%>
>Full
</TD>
</TR>
<TR>
<TD COLSPAN="2" CLASS="freeFormSectionField">
</TD>
</TR>
<TR HEIGHT="*">
<TD ALIGN="center" COLSPAN="2">
<INPUT TYPE="submit" CLASS="button" NAME="replReplicate" VALUE="Start"
onClick="return confirm('WARNING!\n\nAll data in the local data base will be erased!\n\nContinue?')">
</TD>
</TR>
</FORM>
<%
}
} catch (Exception e) {
e.printStackTrace();
out.write(e.getLocalizedMessage());
}
%>
<%@ include file="/replication/replicationFooter.jsp" %>
<%@ include file="/includes/footer.jsp" %>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -