/// <summary> /// Store a document and associate the document with its template's path. /// </summary> /// <param name="document">The document to be stored.</param> public void AddDoc(HotDocs.Sdk.Server.Document document) { string docPath = Path.Combine(_folder, Path.GetRandomFileName() + document.FileExtension); //Write the document to a file. using (FileStream outputStream = File.Create(docPath)) { // Make sure we copy from the start of the memory stream. document.Content.Position = 0; document.Content.CopyTo(outputStream); } SamplePortal.Document doc = new Document(docPath, document.Source.Title); _docs.Add(doc); }
/// <summary> /// Save an answer collection. Also save its title and description. /// </summary> /// <param name="ansColl">The answer collection to save.</param> /// <param name="newTitle">The answer collection title to save.</param> /// <param name="newDescription">The answer collection description to save.</param> public static void SaveAnswers(HotDocs.Sdk.AnswerCollection ansColl, string newTitle, string newDescription) { string answerPath = ansColl.FilePath; string answerFileName = Path.GetFileName(answerPath); using (SamplePortal.Data.Answers answers = new SamplePortal.Data.Answers()) { if (!String.IsNullOrEmpty(ansColl.FilePath))//If this assembly began with an answer file on the server { System.Data.DataView ansData = answers.SelectFile(answerFileName); if (ansData.Count > 0 && ansData[0]["Title"].ToString() == newTitle)//If the title did not change { //Update the existing entry. ansColl.WriteFile(false); answers.UpdateAnswerFile(answerFileName, newTitle, newDescription); } else { //Create a new entry and answer set. string newfname = Util.MakeTempFilename(".anx"); ansColl.WriteFile(Path.Combine(Settings.AnswerPath, newfname), false); answers.InsertNewAnswerFile(newfname, newTitle, newDescription); } } else//If this assembly began with a new or uploaded answer file { //Create a new answer file. string newfname = Util.MakeTempFilename(".anx"); ansColl.WriteFile(Path.Combine(Util.SafeDir(Settings.AnswerPath), newfname), false); //Create a new entry. answers.InsertNewAnswerFile(newfname, newTitle, newDescription); } } }
/* methods */ /// <summary> /// Called by the host application when it needs to deliver an interview down to the end user in a web page. /// Wraps the underlying IServices.GetInterview call (for convenience). /// </summary> /// <param name="options">The InterviewOptions to use for this interview. This parameter makes the WorkSession's /// DefaultInterviewOptions redundant/useless. TODO: We need to decide whether to use a parameter, or only the defaults.</param> /// <returns></returns> public InterviewResult GetInterview(HotDocs.Sdk.Server.Contracts.InterviewOptions options) { throw new NotImplementedException(); }
public static string GetSessionDebugSummary(HotDocs.Sdk.Server.WorkSession session) { var result = new System.Text.StringBuilder(); result.Append("Service type="); if (session.Service is HotDocs.Sdk.Server.Cloud.Services) result.Append("C"); else if (session.Service is HotDocs.Sdk.Server.Local.Services) result.Append("L"); else if (session.Service is HotDocs.Sdk.Server.WebService.Services) result.Append("W"); else result.Append("O"); result.AppendFormat("; Answers={0}", session.AnswerCollection == null ? "null" : session.AnswerCollection.AnswerCount.ToString()); result.AppendFormat("; WorkItems={0}", (session.WorkItems as List<WorkItem>).Count); var item = session.CurrentWorkItem; result.AppendFormat("; Current={0} ({1})", item == null ? "null" : item.Template.FileName, item == null ? "Complete" : ((item is HotDocs.Sdk.Server.InterviewWorkItem) ? "Interview" : "Document")); return result.ToString(); }