Walkthrough 5: Allowing the User to Take a Snapshot and Resume the Session
Prerequisites:
Instructions:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EmploymentAgreement.Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <script type="text/javascript" src="http://files.hotdocs.ws/download/easyXDM.js"></script> <script type="text/javascript" src="http://files.hotdocs.ws/download/hotdocs.js"></script> <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script> </head> <body onload="HD$.CreateInterviewFrame('interview', '<%= GetSessionID() %>');"> <form id="form1" runat="server"> <h1>Employment Agreement Generator</h1> <div id="interview" style="width:100%; height:600px; border:1px solid black"> </div> </form> </body> </html>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EmploymentAgreement.Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <script type="text/javascript" src="http://files.hotdocs.ws/download/easyXDM.js"></script> <script type="text/javascript" src="http://files.hotdocs.ws/download/hotdocs.js"></script> <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script> </head> <body onload="HD$.CreateInterviewFrame('interview', '<%= GetSessionID() %>');"> <button onclick="snapshot()">Snapshot</button> <form id="form1" runat="server"> <h1>Employment Agreement Generator</h1> <div id="interview" style="width:100%; height:600px; border:1px solid black"> </div> </form> </body> </html>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EmploymentAgreement.Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <script type="text/javascript" src="http://files.hotdocs.ws/download/easyXDM.js"></script> <script type="text/javascript" src="http://files.hotdocs.ws/download/hotdocs.js"></script> <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script> </head> <body onload="HD$.CreateInterviewFrame('interview', '<%= GetSessionID() %>');"> <button onclick="snapshot()">Snapshot</button> <form id="form1" runat="server"> <h1>Employment Agreement Generator</h1> <div id="interview" style="width:100%; height:600px; border:1px solid black"> </div> </form> <script> function snapshot() { HD$.GetSnapshot(function (s) { $.post(location.href, { snapshot: s }); }); } </script> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using HotDocs.Cloud.Client; using System.IO; namespace EmploymentAgreement { public partial class Default : System.Web.UI.Page { protected internal readonly string _snapshotFilePath = Path.Combine(Path.GetTempPath(), "snapshot.txt"); protected void Page_Load(object sender, EventArgs e) { if (Request.Form["snapshot"] != null) { File.WriteAllText(_snapshotFilePath, Request.Form["snapshot"]); Response.End(); } } protected string GetSessionID() { var client = new RestClient("SUBSCRIPTION_ID", "SIGNING_KEY"); return client.CreateSession("Employment Agreement", Server.MapPath("/EmploymentAgreement.hdpkg")); } } }
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EmploymentAgreement.Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <script type="text/javascript" src="http://files.hotdocs.ws/download/easyXDM.js"></script> <script type="text/javascript" src="http://files.hotdocs.ws/download/hotdocs.js"></script> <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script> </head> <body onload="HD$.CreateInterviewFrame('interview', '<%= GetSessionID() %>');"> <button onclick="snapshot()">Snapshot</button> <a style="float:right; display:<%= System.IO.File.Exists(_snapshotFilePath) ? "block" : "none" %>" id="resume-link" href="Default.aspx?resume=true">Resume Interview from Snapshot</a> <form id="form1" runat="server"> <h1>Employment Agreement Generator</h1> <div id="interview" style="width:100%; height:600px; border:1px solid black"> </div> </form> <script> function snapshot() { HD$.GetSnapshot(function (s) { $.post(location.href, { snapshot: s }); }); } </script> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using HotDocs.Cloud.Client; using System.IO; namespace EmploymentAgreement { public partial class Default : System.Web.UI.Page { protected internal readonly string _snapshotFilePath = Path.Combine(Path.GetTempPath(), "snapshot.txt"); protected void Page_Load(object sender, EventArgs e) { if (Request.Form["snapshot"] != null) { File.WriteAllText(_snapshotFilePath, Request.Form["snapshot"]); Response.End(); } } protected string GetSessionID() { var client = new RestClient("SUBSCRIPTION_ID", "SIGNING_KEY"); if (Request.QueryString["resume"] == "true") { var snapshot = File.ReadAllText(_snapshotFilePath); File.Delete(_snapshotFilePath); return client.ResumeSession(snapshot); } return client.CreateSession("Employee Agreement", Server.MapPath("/EmploymentAgreement.hdpkg")); } } }
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EmploymentAgreement.Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <script type="text/javascript" src="http://files.hotdocs.ws/download/easyXDM.js"></script> <script type="text/javascript" src="http://files.hotdocs.ws/download/hotdocs.js"></script> <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script> </head> <body onload="HD$.CreateInterviewFrame('interview', '<%= GetSessionID() %>');"> <button onclick="snapshot()">Snapshot</button> <a style="float:right; display:<%= System.IO.File.Exists(_snapshotFilePath) ? "block" : "none" %>" id="resume-link" href="Default.aspx?resume=true">Resume Interview from Snapshot</a> <form id="form1" runat="server"> <h1>Employment Agreement Generator</h1> <div id="interview" style="width:100%; height:600px; border:1px solid black"> </div> </form> <script> function snapshot() { HD$.GetSnapshot(function (s) { $.post(location.href, { snapshot: s }, function () { $('#resume-link').show(); }); }); } </script> </body> </html>
Note: This is not intended to be a realistic application of the snapshot/resume functionality, as it does not store snapshots on a per-user basis.