protected void Page_Load(object sender, EventArgs e)
    {
        _session = SamplePortal.Factory.GetWorkSession(this.Session);
        if (_session == null)
            Response.Redirect("Default.aspx");
        _ansPath = _session.AnswerCollection.FilePath;
        _ansFilename = Path.GetFileName(_ansPath);
        if (!IsPostBack) // first arrival on this page
        {
            // Set the max length on the title and description fields. These were previously set in the ASPX page,
            // but ASP.NET drops them for multi-line fields when rendering the page.
            // So we set them manually here using values configurable in the web.config.
            txtTitle.Attributes.Add("maxlength", Settings.MaxTitleLength.ToString());
            txtDescription.Attributes.Add("maxlength", Settings.MaxDescriptionLength.ToString());

            ViewState["answers"] = HotDocs.Sdk.Server.InterviewResponse.GetAnswers(Request.Form); // get the answers from the browser

            if (_session.AnswerCollection.FilePath.Length > 0)
            {
                using (Answers answers = new Answers())
                {
                    DataView ansData = answers.SelectFile(_ansFilename);
                    // pre-populate answer set title and description
                    txtTitle.Text = ansData[0]["Title"].ToString();
                    txtDescription.Text = ansData[0]["Description"].ToString();
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        _session = SamplePortal.Factory.GetWorkSession(this.Session);
        if (_session == null)
        {
            Response.Redirect("Default.aspx");
        }
        _ansPath     = _session.AnswerCollection.FilePath;
        _ansFilename = Path.GetFileName(_ansPath);
        if (!IsPostBack)         // first arrival on this page
        {
            // Set the max length on the title and description fields. These were previously set in the ASPX page,
            // but ASP.NET drops them for multi-line fields when rendering the page.
            // So we set them manually here using values configurable in the web.config.
            txtTitle.Attributes.Add("maxlength", Settings.MaxTitleLength.ToString());
            txtDescription.Attributes.Add("maxlength", Settings.MaxDescriptionLength.ToString());

            ViewState["answers"] = HotDocs.Sdk.Server.InterviewResponse.GetAnswers(Request.Form);             // get the answers from the browser

            if (_session.AnswerCollection.FilePath.Length > 0)
            {
                using (Answers answers = new Answers())
                {
                    DataView ansData = answers.SelectFile(_ansFilename);
                    // pre-populate answer set title and description
                    txtTitle.Text       = ansData[0]["Title"].ToString();
                    txtDescription.Text = ansData[0]["Description"].ToString();
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        _session = SamplePortal.Factory.GetWorkSession(this.Session);

        if (!IsPostBack)
        {
            ViewState["sortExpression"] = Settings.DefaultTemplateTableSortExpression;
            BindData(null);
        }
    }
Example #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        _session = SamplePortal.Factory.GetWorkSession(this.Session);

        if (!IsPostBack)
        {
            ViewState["sortExpression"] = Settings.DefaultTemplateTableSortExpression;
            BindData(null);
        }
    }
Example #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        _session = SamplePortal.Factory.GetWorkSession(this.Session);

        if (_session == null)
        {
            Response.Redirect("Default.aspx");
        }

        if (!IsPostBack)
        {
            ViewState["sortExpression"] = Settings.DefaultAnswerTableSortExpression;
            BindData(null);
        }
    }
    protected void tplGrid_SelectedIndexChanged(object sender, EventArgs e)
    {
        string packageId = tplGrid.SelectedItem.Cells[5].Text;

        if (string.IsNullOrEmpty(packageId) || packageId.IndexOfAny(new char[] { '/', '\\', ':' }) >= 0)         //Don't allow path control elements in a package ID.
        {
            MessageBox.Show("Invalid template path");
            return;
        }

        if (!PackageCache.PackageExists(packageId))
        {
            MessageBox.Show("The selected template could not be found. Please contact your Sample Portal site administrator for assistance.");
            return;
        }

        //Open a new work session.
        try
        {
            // title is in Cells[2].
            string templateTitle = tplGrid.SelectedItem.Cells[2].Text;
            _session = Factory.CreateWorkSession(Session, packageId, templateTitle);

            // Make sure that there is a cache for the assembled documents, and that it is empty.
            AssembledDocsCache cache = Factory.GetAssembledDocsCache(this.Session);
            cache.Clear();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
            return;
        }

        //Redirect to "select answer set" page
        Response.Redirect("SelAns.aspx");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        _session = SamplePortal.Factory.GetWorkSession(this.Session);

        if (_session == null)
        {
            Response.Redirect("Default.aspx");            //If we don't even have a work session open, then the user hasn't chosen anything to be assembled.
        }
        try
        {
            if (!IsPostBack)             // first arrival on this page
            {
                //Advance past the interview.

                //First some housekeeping. The AssembledDocsCache should clean up after itself when it gets disposed.
                // This attempts to remove old documents in case a disposal fails for some reason.
                Util.SweepTempDirectories();

                // Set the max length on the title and description fields.
                // These were previously set in the ASPX page, but ASP.NET drops them for multi-line fields when rendering the page.
                // So we set them manually here using values configurable in the web.config.
                txtTitle.Attributes.Add("maxlength", Settings.MaxTitleLength.ToString());
                txtDescription.Attributes.Add("maxlength", Settings.MaxDescriptionLength.ToString());

                //Get the user-modified interview answers from the HTTP request.
                System.IO.StringReader sr = new StringReader(HotDocs.Sdk.Server.InterviewResponse.GetAnswers(Request.Form));

                //Merge (overlay) the user-modified interview answers back into the assembly's answer collection.
                _session.FinishInterview(HotDocs.Sdk.Server.InterviewAnswerSet.GetDecodedInterviewAnswers(sr));

                if (!string.IsNullOrEmpty(_session.AnswerCollection.FilePath))
                {
                    using (SamplePortal.Data.Answers answers = new SamplePortal.Data.Answers())
                    {
                        DataView ansData = answers.SelectFile(Path.GetFileName(_session.AnswerCollection.FilePath));
                        if (ansData.Count > 0)
                        {
                            // populate answer set title and description
                            txtTitle.Text       = ansData[0]["Title"].ToString();
                            txtDescription.Text = ansData[0]["Description"].ToString();
                        }
                    }
                }

                // Note for HotDocs host application developers: an informational log entry could be added
                // to a log file before (here) and after the call to _session.AssembleDocuments.
                HotDocs.Sdk.Server.Document[] docs  = _session.AssembleDocuments(null);
                AssembledDocsCache            cache = Factory.GetAssembledDocsCache(this.Session);
                foreach (HotDocs.Sdk.Server.Document doc in docs)
                {
                    cache.AddDoc(doc);
                }

                IEnumerable <HotDocs.Sdk.Server.WorkItem> interviewItems = from n in _session.WorkItems where n is HotDocs.Sdk.Server.InterviewWorkItem select n;
                int numberOfInterviews = interviewItems.Count();
                if (numberOfInterviews > 1)
                {
                    IEnumerable <HotDocs.Sdk.Server.WorkItem> completeItems = from n in interviewItems where n.IsCompleted select n;
                    int completedInterviews = completeItems.Count();
                    pnlNextAsm.Visible = true;
                    if (completedInterviews < numberOfInterviews)
                    {
                        lblContinue.Text = String.Format(
                            "You have completed {0} of {1} interviews required for this document set. There {2} {3} follow-up interview{4} still to be done. Click here to proceed to the next interview.",
                            completedInterviews,
                            numberOfInterviews,
                            (numberOfInterviews - completedInterviews) == 1 ? "is" : "are",
                            (numberOfInterviews - completedInterviews).ToString(),
                            (numberOfInterviews - completedInterviews) == 1 ? "" : "s");
                    }
                    else
                    {
                        lblContinue.Text = String.Format(
                            "You have completed {0} of {1} interviews required for this document set. ",
                            completedInterviews,
                            numberOfInterviews);
                        btnNextInterview.Visible = false;
                    }
                }
                else
                {
                    pnlNextAsm.Visible = false;
                }

                //Initialize Doc Grid
                docGrid.DataSource = cache.ToArray();
                docGrid.DataBind();
                panelDocDownload.Visible = (cache.Count > 0);
            }
        }
        catch (Exception ex)
        {
            // Note for HotDocs host application developers: An error entry should be added to a log file here
            // with information about the current exception, including a stack trace:
            System.Diagnostics.Debug.WriteLine("Page_Load: Exception occurred: " + ex.Message);

            if (Settings.DebugApplication)
            {
                throw;
            }
            else
            {
                pnlError.Visible         = true;
                panelDocDownload.Visible = false;

                lblError.Text = "An error prevented the document from being assembled:<br>";
                if (ex.Message.IndexOf("PDF Advantage") > 0)
                {
                    lblError.Text += "HotDocs could not load the required PDF support library.";
                }
                else
                {
                    lblError.Text += ex.Message;
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //don't cache interviews
        Response.Cache.SetCacheability(HttpCacheability.NoCache);

        _session = SamplePortal.Factory.GetWorkSession(this.Session);
        if (_session == null)
            Response.Redirect("Default.aspx");

        HotDocs.Sdk.Server.WorkItem workItem = _session.CurrentWorkItem;
        if (!(workItem is HotDocs.Sdk.Server.InterviewWorkItem))
        {
            MessageBox.Show("Only interview work items are allowed at the interview page.");
            return;
        }

        _interviewContent = "";
        // Call GetInterview and return the result
        try
        {
            //TODO: Consider skipping this step given that the SelAns page already skips forward to the disposition page if needed.
            // Check the switches in case this assembly resulted from an ASSEMBLE instruction in another template.
            // In this case, it is possible that the template author indicated that no interview should be asked using a
            // "/nw" or "/naw" or "/ni" switch. If this is the case, we skip this page and redirect to the disposition page
            // [LRS:] Also, the WorkSession should have already checked the switches. If one of "/ni", etc. is found, the
            // session should not even be creating an interview work item at all. So checking them here is redundant.
            if (ShouldSkipInterviewUI(workItem.Template.Switches))
                Response.Redirect("Disposition.aspx");

            // Determine which interview format to use, depending on the values for InterviewFormat and InterviewFallback in web.config.
            HotDocs.Sdk.Server.Contracts.InterviewFormat format = HotDocs.Sdk.Server.Contracts.InterviewFormat.Unspecified;
            string formatString = ConfigurationManager.AppSettings["InterviewFormat"];
            if (!String.IsNullOrWhiteSpace(formatString)) {
                if (formatString.ToUpper() == "SILVERLIGHT")
                {
                    // The interview fallback option only comes into play if the specified format in web.config is Silverlight.
                    // (We never "fallback" to Silverlight since it is the more restrictive interview format; JavaScript will work in any browser.)

                    // See if fallback is allowed and then fallback to JavaScript if Silverlight is unavailable.
                    if (Settings.AllowInterviewFallback)
                    {
                        // Get the cookie we set that indicates whether or not Silverlight 5.0 is installed.
                        HttpCookie slCookie = Request.Cookies["SilverlightAvailable"];
                        if (slCookie != null ? !bool.Parse(Request.Cookies["SilverlightAvailable"].Value) : true)
                            format = HotDocs.Sdk.Server.Contracts.InterviewFormat.JavaScript;
                    }
                }
                else if (formatString.ToUpper() == "JAVASCRIPT")
                {
                    format = HotDocs.Sdk.Server.Contracts.InterviewFormat.JavaScript;
                }
            }

            // Note for HotDocs host application developers: an informational log entry could be added to a
            // log file before (here) and after the call to _session.GetCurrentInterview.

            //Get an interview using the default interview options from the web.config file.
            HotDocs.Sdk.Server.InterviewResult interviewResult = _session.GetCurrentInterview(format);
            _interviewContent = interviewResult.HtmlFragment;
        }
        catch (Exception ex)
        {
            // Note for HotDocs host application developers: An error entry should be added to a log file here
            // with information about the current exception, including a stack trace:
            _interviewContent = "Unable to return interview:<br><br>" + ex.Message; //interview error message
        }
    }
Example #9
0
    protected void tplGrid_SelectedIndexChanged(object sender, EventArgs e)
    {
        string packageId = tplGrid.SelectedItem.Cells[5].Text;
        if (string.IsNullOrEmpty(packageId) || packageId.IndexOfAny(new char[] { '/', '\\', ':' }) >= 0) //Don't allow path control elements in a package ID.
        {
            MessageBox.Show("Invalid template path");
            return;
        }

        if (!PackageCache.PackageExists(packageId))
        {
            MessageBox.Show("The selected template could not be found. Please contact your Sample Portal site administrator for assistance.");
            return;
        }

        //Open a new work session.
        try
        {
            // title is in Cells[2].
            string templateTitle = tplGrid.SelectedItem.Cells[2].Text;
            _session = Factory.CreateWorkSession(Session, packageId, templateTitle);

            // Make sure that there is a cache for the assembled documents, and that it is empty.
            AssembledDocsCache cache = Factory.GetAssembledDocsCache(this.Session);
            cache.Clear();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
            return;
        }

        //Redirect to "select answer set" page
        Response.Redirect("SelAns.aspx");
    }
Example #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        _session = SamplePortal.Factory.GetWorkSession(this.Session);

        if (_session == null)
            Response.Redirect("Default.aspx");

        if (!IsPostBack)
        {
            ViewState["sortExpression"] = Settings.DefaultAnswerTableSortExpression;
            BindData(null);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        _session = SamplePortal.Factory.GetWorkSession(this.Session);

        if (_session == null)
            Response.Redirect("Default.aspx");//If we don't even have a work session open, then the user hasn't chosen anything to be assembled.

        try
        {
            if (!IsPostBack) // first arrival on this page
            {
                //Advance past the interview.

                //First some housekeeping. The AssembledDocsCache should clean up after itself when it gets disposed.
                // This attempts to remove old documents in case a disposal fails for some reason.
                Util.SweepTempDirectories();

                // Set the max length on the title and description fields.
                // These were previously set in the ASPX page, but ASP.NET drops them for multi-line fields when rendering the page.
                // So we set them manually here using values configurable in the web.config.
                txtTitle.Attributes.Add("maxlength", Settings.MaxTitleLength.ToString());
                txtDescription.Attributes.Add("maxlength", Settings.MaxDescriptionLength.ToString());

                //Get the user-modified interview answers from the HTTP request.
                System.IO.StringReader sr = new StringReader(HotDocs.Sdk.Server.InterviewResponse.GetAnswers(Request.Form));

                //Merge (overlay) the user-modified interview answers back into the assembly's answer collection.
                _session.FinishInterview(HotDocs.Sdk.Server.InterviewAnswerSet.GetDecodedInterviewAnswers(sr));

                if (!string.IsNullOrEmpty(_session.AnswerCollection.FilePath))
                {
                    using (SamplePortal.Data.Answers answers = new SamplePortal.Data.Answers())
                    {
                        DataView ansData = answers.SelectFile(Path.GetFileName(_session.AnswerCollection.FilePath));
                        if (ansData.Count > 0)
                        {
                            // populate answer set title and description
                            txtTitle.Text = ansData[0]["Title"].ToString();
                            txtDescription.Text = ansData[0]["Description"].ToString();
                        }
                    }
                }

                // Note for HotDocs host application developers: an informational log entry could be added
                // to a log file before (here) and after the call to _session.AssembleDocuments.
                HotDocs.Sdk.Server.Document[] docs = _session.AssembleDocuments(null);
                AssembledDocsCache cache = Factory.GetAssembledDocsCache(this.Session);
                foreach (HotDocs.Sdk.Server.Document doc in docs)
                    cache.AddDoc(doc);

                IEnumerable<HotDocs.Sdk.Server.WorkItem> interviewItems = from n in _session.WorkItems where n is HotDocs.Sdk.Server.InterviewWorkItem select n;
                int numberOfInterviews = interviewItems.Count();
                if (numberOfInterviews > 1)
                {
                    IEnumerable<HotDocs.Sdk.Server.WorkItem> completeItems = from n in interviewItems where n.IsCompleted select n;
                    int completedInterviews = completeItems.Count();
                    pnlNextAsm.Visible = true;
                    if (completedInterviews < numberOfInterviews)
                    {
                        lblContinue.Text = String.Format(
                            "You have completed {0} of {1} interviews required for this document set. There {2} {3} follow-up interview{4} still to be done. Click here to proceed to the next interview.",
                            completedInterviews,
                            numberOfInterviews,
                            (numberOfInterviews - completedInterviews) == 1 ? "is" : "are",
                            (numberOfInterviews - completedInterviews).ToString(),
                            (numberOfInterviews - completedInterviews) == 1 ? "" : "s");
                    }
                    else
                    {
                        lblContinue.Text = String.Format(
                            "You have completed {0} of {1} interviews required for this document set. ",
                            completedInterviews,
                            numberOfInterviews);
                        btnNextInterview.Visible = false;

                    }
                }
                else
                    pnlNextAsm.Visible = false;

                //Initialize Doc Grid
                docGrid.DataSource = cache.ToArray();
                docGrid.DataBind();
                panelDocDownload.Visible = (cache.Count > 0);
            }
        }
        catch (Exception ex)
        {
            // Note for HotDocs host application developers: An error entry should be added to a log file here
            // with information about the current exception, including a stack trace:
            System.Diagnostics.Debug.WriteLine("Page_Load: Exception occurred: " + ex.Message);

            if (Settings.DebugApplication) throw;
            else
            {
                pnlError.Visible = true;
                panelDocDownload.Visible = false;

                lblError.Text = "An error prevented the document from being assembled:<br>";
                if (ex.Message.IndexOf("PDF Advantage") > 0)
                    lblError.Text += "HotDocs could not load the required PDF support library.";
                else
                    lblError.Text += ex.Message;
            }
        }
    }
Example #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //don't cache interviews
        Response.Cache.SetCacheability(HttpCacheability.NoCache);



        _session = SamplePortal.Factory.GetWorkSession(this.Session);
        if (_session == null)
        {
            Response.Redirect("Default.aspx");
        }

        HotDocs.Sdk.Server.WorkItem workItem = _session.CurrentWorkItem;
        if (!(workItem is HotDocs.Sdk.Server.InterviewWorkItem))
        {
            MessageBox.Show("Only interview work items are allowed at the interview page.");
            return;
        }

        _interviewContent = "";
        // Call GetInterview and return the result
        try
        {
            //TODO: Consider skipping this step given that the SelAns page already skips forward to the disposition page if needed.
            // Check the switches in case this assembly resulted from an ASSEMBLE instruction in another template.
            // In this case, it is possible that the template author indicated that no interview should be asked using a
            // "/nw" or "/naw" or "/ni" switch. If this is the case, we skip this page and redirect to the disposition page
            // [LRS:] Also, the WorkSession should have already checked the switches. If one of "/ni", etc. is found, the
            // session should not even be creating an interview work item at all. So checking them here is redundant.
            if (ShouldSkipInterviewUI(workItem.Template.Switches))
            {
                Response.Redirect("Disposition.aspx");
            }

            // Determine which interview format to use, depending on the values for InterviewFormat and InterviewFallback in web.config.
            HotDocs.Sdk.Server.Contracts.InterviewFormat format = HotDocs.Sdk.Server.Contracts.InterviewFormat.Unspecified;
            string formatString = ConfigurationManager.AppSettings["InterviewFormat"];
            if (!String.IsNullOrWhiteSpace(formatString))
            {
                if (formatString.ToUpper() == "SILVERLIGHT")
                {
                    // The interview fallback option only comes into play if the specified format in web.config is Silverlight.
                    // (We never "fallback" to Silverlight since it is the more restrictive interview format; JavaScript will work in any browser.)

                    // See if fallback is allowed and then fallback to JavaScript if Silverlight is unavailable.
                    if (Settings.AllowInterviewFallback)
                    {
                        // Get the cookie we set that indicates whether or not Silverlight 5.0 is installed.
                        HttpCookie slCookie = Request.Cookies["SilverlightAvailable"];
                        if (slCookie != null ? !bool.Parse(Request.Cookies["SilverlightAvailable"].Value) : true)
                        {
                            format = HotDocs.Sdk.Server.Contracts.InterviewFormat.JavaScript;
                        }
                    }
                }
                else if (formatString.ToUpper() == "JAVASCRIPT")
                {
                    format = HotDocs.Sdk.Server.Contracts.InterviewFormat.JavaScript;
                }
            }

            // Note for HotDocs host application developers: an informational log entry could be added to a
            // log file before (here) and after the call to _session.GetCurrentInterview.

            //Get an interview using the default interview options from the web.config file.
            HotDocs.Sdk.Server.InterviewResult interviewResult = _session.GetCurrentInterview(format);
            _interviewContent = interviewResult.HtmlFragment;
        }
        catch (Exception ex)
        {
            // Note for HotDocs host application developers: An error entry should be added to a log file here
            // with information about the current exception, including a stack trace:
            _interviewContent = "Unable to return interview:<br><br>" + ex.Message;             //interview error message
        }
    }