public DocumentActionWindow(B10DeskHelper pB10DH, DocumentAction pDocAction) { InitializeComponent(); B10DH = pB10DH; DocAction = pDocAction; PurchaseInvoiceLineTab.Visibility = Visibility.Hidden; CreatePurchaseInvoiceTab.Visibility = Visibility.Hidden; GetPurchaseInvoiceDueDateTab.Visibility = Visibility.Hidden; PostPurchaseInvoiceTab.Visibility = Visibility.Hidden; switch (DocAction.Action) { case EDocumentAction.get_purchase_invoice_lines: FillPurchaseInvoiceLineTab(); break; case EDocumentAction.create_purchase_invoice: FillCreatePurchaseInvoiceTab(); break; case EDocumentAction.post_block_purchase_invoice: FillPostPurchaseInvoiceTab(); break; case EDocumentAction.get_payment_due_date: FillGetPurchaseInvoiceDueDateTab(); break; case EDocumentAction.unblock_purchase_invoice_for_payment: case EDocumentAction.block_purchase_invoice_for_payment: FillUnblockInvoiceTab(); break; } }
public async Task SignInvoice_Success( DocumentAction pDocumentAction, string pLedgerCode, [Frozen] IBlue10AsyncClient pBlue10AsyncCLient, InvoiceService pInvoiceService) { // Setup Data pDocumentAction.Status = string.Empty; pDocumentAction.PurchaseInvoice.AdministrationCode = string.Empty; var fExpected = string.Empty; // Setup services pBlue10AsyncCLient.EditDocumentActionAsync(Arg.Any <DocumentAction>()).Returns(fExpected); // Test var fResult = await pInvoiceService.SignInvoice(pDocumentAction, pLedgerCode); // Validate await pBlue10AsyncCLient.Received(1).EditDocumentActionAsync( Arg.Is <DocumentAction>( x => x.Status == "done" && x.PurchaseInvoice.AdministrationCode == pLedgerCode) ); fResult.Should().BeOfType <DocumentAction?>(); fResult.Should().NotBeNull(); }
protected void setData() { DataTable dataTable = DocumentAction.QueryOneSendFile(this.FileID); if (dataTable.Rows.Count == 1) { this.txtFileNumber.Text = dataTable.Rows[0]["FileNumber"].ToString(); this.txtTitle.Text = dataTable.Rows[0]["Title"].ToString(); this.txtSignUserName.Text = dataTable.Rows[0]["SignUserName"].ToString(); this.txtDraftDept.Text = dataTable.Rows[0]["DraftDept"].ToString(); this.txtIssueRange.Text = dataTable.Rows[0]["IssueRange"].ToString(); this.txtIssuePage.Text = dataTable.Rows[0]["IssuePage"].ToString(); this.txtShareNumber.Text = dataTable.Rows[0]["ShareNumber"].ToString(); this.txtIssueDate.Text = dataTable.Rows[0]["IssueDate"].ToString(); this.txtRemark.Text = dataTable.Rows[0]["Remark"].ToString(); this.hdnFilePath.Value = dataTable.Rows[0]["FilePath"].ToString(); this.txtOriginalName.Text = dataTable.Rows[0]["OriginalName"].ToString(); this.annexName.InnerText = dataTable.Rows[0]["OriginalName"].ToString(); if (this.hdnFilePath.Value.Length > 0) { this.tr_add.Visible = false; this.tr_edit.Visible = true; return; } this.tr_add.Visible = true; this.tr_edit.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { if (!this.Page.IsPostBack) { this.UserCode = this.Session["yhdm"].ToString(); this.FilterField = base.Request["flt"]; object value = DocumentAction.QueryClassTypeCode(this.FilterField); this.ClassTypeCode = Convert.ToString(value); this.btnAdd.Attributes["onclick"] = string.Concat(new string[] { "openClassEdit(1,'", this.ClassTypeCode, "','", this.UserCode, "')" }); this.btnEdit.Attributes["onclick"] = string.Concat(new string[] { "openClassEdit(2,'", this.ClassTypeCode, "','", this.UserCode, "')" }); this.btnDel.Attributes["onclick"] = " return confirm('确定删除当前记录数据吗?');"; this.dgClass_Bind(); } }
protected void BtnAdd_Click(object sender, EventArgs e) { DateTime arg_05_0 = DateTime.Now; Hashtable hashtable = new Hashtable(); hashtable.Add("FileID", SqlStringConstructor.GetQuotedString(this.FileID.ToString())); hashtable.Add("Title", SqlStringConstructor.GetQuotedString(this.txtTitle.Text)); hashtable.Add("Remark", SqlStringConstructor.GetQuotedString(this.txtRemark.Text)); hashtable.Add("IsPigeonhole", SqlStringConstructor.GetQuotedString("0")); hashtable.Add("UserCode", SqlStringConstructor.GetQuotedString(this.Session["yhdm"].ToString())); hashtable.Add("RecordDate", SqlStringConstructor.GetQuotedString(this.txtRecordDate.Text.ToString())); hashtable.Add("CorpCode", SqlStringConstructor.GetQuotedString(this.CorpCode)); hashtable.Add("AuditState", "-1"); if (base.Request.QueryString["fid"] == "") { if (DocumentAction.AddSendFileInfo(hashtable)) { this.JS.Text = "alert('保存成功!');window.returnValue=true;window.close();"; return; } this.JS.Text = "alert('保存失败!');"; return; } else { string where = " where FileID = '" + this.FileID.ToString() + " '"; if (DocumentAction.UpdSendFileInfo(hashtable, where)) { this.JS.Text = "alert('保存成功!');window.returnValue=true;window.close();"; return; } this.JS.Text = "alert('保存失败!');"; return; } }
protected void BtnAdd_Click(object sender, EventArgs e) { Guid.NewGuid(); DateTime arg_0B_0 = DateTime.Now; Hashtable hashtable = new Hashtable(); hashtable.Add("FileNumber", SqlStringConstructor.GetQuotedString(this.txtFileNumber.Text)); hashtable.Add("SignUserName", SqlStringConstructor.GetQuotedString(this.txtSignUserName.Text)); hashtable.Add("DraftDept", SqlStringConstructor.GetQuotedString(this.txtDraftDept.Text)); hashtable.Add("IssueRange", SqlStringConstructor.GetQuotedString(this.txtIssueRange.Text)); hashtable.Add("IssuePage", SqlStringConstructor.GetQuotedString(this.txtIssuePage.Text)); hashtable.Add("ShareNumber", SqlStringConstructor.GetQuotedString(this.txtShareNumber.Text)); hashtable.Add("IssueDate", SqlStringConstructor.GetQuotedString(this.txtIssueDate.Text)); hashtable.Add("Remark", SqlStringConstructor.GetQuotedString(this.txtRemark.Text)); if (this.FileUpload1.HasFile) { HttpPostedFile postedFile = this.FileUpload1.PostedFile; com.jwsoft.pm.entpm.action.FileUpload fileUpload = new com.jwsoft.pm.entpm.action.FileUpload(); string[] array = fileUpload.Upload(postedFile, 1); hashtable.Add("OriginalName", SqlStringConstructor.GetQuotedString(array[0])); hashtable.Add("FilePath", SqlStringConstructor.GetQuotedString(array[1])); } string where = " where FileID = '" + this.FileID.ToString() + " '"; if (DocumentAction.UpdSendFileInfo(hashtable, where)) { this.JS.Text = "alert('保存成功!');window.returnValue=true;window.close();"; return; } this.JS.Text = "alert('保存失败!');"; }
protected void Page_Load(object sender, EventArgs e) { if (!this.Page.IsPostBack) { this.UserCode = this.Session["yhdm"].ToString(); this.FilterField = base.Request.QueryString["flt"]; this.hdnTypes.Value = base.Request.QueryString["f"]; if (base.Request.QueryString["title"] == "staffSort") { this.PageTitle = "人员类别分类"; } this.Page.Header.Title = this.PageTitle; this.Td_Title.InnerText = this.PageTitle; object value = DocumentAction.QueryClassTypeCode(this.FilterField); this.ClassTypeCode = Convert.ToString(value); this.btnAdd.Attributes["onclick"] = string.Concat(new string[] { "openClassEdit(1,'", this.ClassTypeCode, "','", this.UserCode, "')" }); this.btnEdit.Attributes["onclick"] = string.Concat(new string[] { "openClassEdit(2,'", this.ClassTypeCode, "','", this.UserCode, "')" }); this.btnDel.Attributes["onclick"] = " return confirm('确定删除当前记录数据吗?');"; this.dgClass_Bind(); } }
protected void setData() { DataTable dataTable = DocumentAction.QueryOneReceiveFile(this.FileID); if (dataTable.Rows.Count == 1) { this.txtReceiveType.Enabled = true; this.txtTitle.Text = dataTable.Rows[0]["Title"].ToString(); this.txtSendCorpName.Text = dataTable.Rows[0]["SendCorpName"].ToString(); this.txtReceiveType.SelectedValue = dataTable.Rows[0]["ReceiveType"].ToString(); this.txtReceiveDate.Text = dataTable.Rows[0]["ReceiveDate"].ToString(); this.txtRemark.Text = dataTable.Rows[0]["Remark"].ToString(); this.hdnFilePath.Value = dataTable.Rows[0]["FilePath"].ToString(); this.txtOriginalName.Text = dataTable.Rows[0]["OriginalName"].ToString(); this.annexName.InnerText = dataTable.Rows[0]["OriginalName"].ToString(); if (this.hdnFilePath.Value.Length > 0) { this.tr_add.Visible = false; this.tr_edit.Visible = true; return; } this.tr_add.Visible = true; this.tr_edit.Visible = false; } }
private void Fire(Document document, DocumentAction action) { var documentEvent = Create <DocumentEvent>(); documentEvent.Document = document.GetName(); documentEvent.Action = action; FireNow(documentEvent); }
private async Task HandleDocumentActionAsync(CallbackQuery query, DocumentAction action) { _documentAction = action; await _telegramBotClient.AnswerCallbackQueryAsync(query.Id); await _telegramBotClient.SendTextMessageAsync(_chatId, "Okay no problem.", replyToMessageId : query.Message.MessageId); }
public async Task <(PurchaseInvoice, byte[])> PullInvoice(DocumentAction action) { var invoice = await _blue10.GetPurchaseInvoiceAsync(action.PurchaseInvoice.Id); var data = await _blue10.GetPurchaseInvoiceOriginalAsync(action.PurchaseInvoice.Id); return(invoice, data); }
protected void btnDel_Click(object sender, EventArgs e) { int templateId = Convert.ToInt32(this.hdnTemplateID.Value); if (DocumentAction.DelDocTemplate(templateId)) { this.JS.Text = "alert('删除成功!');"; this.dgTemplate_Bind(); } }
protected void btnDel_Click(object sender, EventArgs e) { int classId = Convert.ToInt32(this.hdnClassID.Value); if (DocumentAction.DelDocClass(classId)) { base.RegisterScript("top.ui.show( '删除成功!')"); this.dgClass_Bind(); } }
private void ActionNotImplemented(DocumentAction pDocumentAction) { var fDocumentActionReturn = new DocumentAction() { Id = pDocumentAction.Id, Status = "done" }; mBlue10Client.EditDocumentAction(fDocumentActionReturn); }
protected void btnDel_Click(object sender, EventArgs e) { int classId = Convert.ToInt32(this.hdnClassID.Value); if (DocumentAction.DelDocClass(classId)) { this.JS.Text = "alert('删除成功!');"; this.dgClass_Bind(); } }
protected void btnDel_Click(object sender, EventArgs e) { Guid fileId = new Guid(this.hdnFileID.Value); if (DocumentAction.DelSendFileInfo(fileId)) { this.JS.Text = "alert('删除成功!');"; this.dgFileList_Bind(); } }
protected void setData() { DataTable dataTable = DocumentAction.QueryOneSendFile(this.FileID); if (dataTable.Rows.Count == 1) { this.LbTitle.Text = dataTable.Rows[0]["Title"].ToString(); this.LbUserName.Text = dataTable.Rows[0]["UserName"].ToString(); this.LbRecordDate.Text = Convert.ToDateTime(dataTable.Rows[0]["RecordDate"].ToString()).ToShortDateString(); this.LbRemark.Text = dataTable.Rows[0]["Remark"].ToString(); } }
protected void setDate() { DataTable dataTable = DocumentAction.QueryOneSendFile(this.InstanceCode); if (dataTable.Rows.Count == 1) { this.txtTitle.Text = dataTable.Rows[0]["Title"].ToString(); this.txtUserName.Text = dataTable.Rows[0]["userName"].ToString(); this.txtRecordDate.Text = dataTable.Rows[0]["RecordDate"].ToString(); this.txtOriginalName.Text = dataTable.Rows[0]["OriginalName"].ToString(); this.txtRemark.Text = dataTable.Rows[0]["Remark"].ToString(); } }
protected void dgTemplate_SelectedIndexChanged(object sender, EventArgs e) { string str = ""; string str2 = ""; int templateId = Convert.ToInt32(this.dgTemplate.DataKeys[this.dgTemplate.SelectedIndex].ToString()); DataTable dataTable = DocumentAction.QueryOneDocTemplate(templateId); if (dataTable.Rows.Count == 1) { str = dataTable.Rows[0]["OriginalName"].ToString(); str2 = dataTable.Rows[0]["FilePath"].ToString(); } base.Response.Redirect("/EPC/uploadfile/down.aspx?fileName=" + str + "&filePath=" + str2); }
protected void BtnAdd_Click(object sender, EventArgs e) { Guid guid = Guid.NewGuid(); DateTime dateTime = default(DateTime); dateTime = DateTime.Now; Hashtable hashtable = new Hashtable(); hashtable.Add("FileID", SqlStringConstructor.GetQuotedString(guid.ToString())); hashtable.Add("Title", SqlStringConstructor.GetQuotedString(this.txtTitle.Text)); hashtable.Add("SendCorpName", SqlStringConstructor.GetQuotedString(this.txtSendCorpName.Text)); hashtable.Add("ReceiveType", SqlStringConstructor.GetQuotedString(this.txtReceiveType.SelectedValue)); hashtable.Add("ReceiveDate", SqlStringConstructor.GetQuotedString(this.txtReceiveDate.Text)); hashtable.Add("Remark", SqlStringConstructor.GetQuotedString(this.txtRemark.Text)); hashtable.Add("IsPigeonhole", SqlStringConstructor.GetQuotedString("0")); hashtable.Add("UserCode", SqlStringConstructor.GetQuotedString(this.UserCode)); hashtable.Add("RecordDate", SqlStringConstructor.GetQuotedString(dateTime.ToString())); hashtable.Add("CorpCode", SqlStringConstructor.GetQuotedString(this.CorpCode)); if (this.FileUpload1.HasFile) { HttpPostedFile postedFile = this.FileUpload1.PostedFile; com.jwsoft.pm.entpm.action.FileUpload fileUpload = new com.jwsoft.pm.entpm.action.FileUpload(); string[] array = fileUpload.Upload(postedFile, 1); hashtable.Add("OriginalName", SqlStringConstructor.GetQuotedString(array[0])); hashtable.Add("FilePath", SqlStringConstructor.GetQuotedString(array[1])); } if (this.FileID == Guid.Empty) { if (DocumentAction.AddReceiveFileInfo(hashtable)) { this.JS.Text = "alert('保存成功!');window.returnValue=true;window.close();"; return; } this.JS.Text = "alert('保存失败!');"; return; } else { string where = " where FileID = '" + this.FileID.ToString() + " '"; if (DocumentAction.UpdReceiveFileInfo(hashtable, where)) { this.JS.Text = "alert('保存成功!');window.returnValue=true;window.close();"; return; } this.JS.Text = "alert('保存失败!');"; return; } }
protected void setData(int classId) { DataTable dataTable = DocumentAction.QueryOneDocumentClass(classId); if (dataTable.Rows.Count == 1) { this.txtClassCode.Text = dataTable.Rows[0]["ClassCode"].ToString(); this.txtClassName.Text = dataTable.Rows[0]["ClassName"].ToString(); string text = dataTable.Rows[0]["IsValid"].ToString(); if (text != "" && text != null) { this.ddltIsValid.ClearSelection(); this.ddltIsValid.Items.FindByValue(text).Selected = true; } } }
public async Task <DocumentAction?> SignInvoice(DocumentAction pInvoiceAction, string pLedgerCode) { pInvoiceAction.Status = "done"; pInvoiceAction.PurchaseInvoice.AdministrationCode = pLedgerCode; var fUpdateResult = await _blue10.EditDocumentActionAsync(pInvoiceAction); if (fUpdateResult != null) { return(pInvoiceAction); } else { return(null); } }
protected void Page_Load(object sender, EventArgs e) { if (!this.Page.IsPostBack) { this.UserCode = Convert.ToString(this.Session["yhdm"]); DataTable dataTable = DocumentAction.QueryCorpCode(this.UserCode); if (dataTable.Rows.Count > 0) { this.CorpCode = dataTable.Rows[0]["CorpCode"].ToString(); } else { this.CorpCode = ""; } this.btnAdd.Attributes["onclick"] = string.Concat(new string[] { "openClassEdit(1,'", this.CorpCode, "','", this.UserCode, "')" }); this.btnEdit.Attributes["onclick"] = string.Concat(new string[] { "openClassEdit(2,'", this.CorpCode, "','", this.UserCode, "')" }); this.btnView.Attributes["onclick"] = string.Concat(new string[] { "openClassEdit(3,'", this.CorpCode, "','", this.UserCode, "')" }); this.btnGiveOut.Attributes["onclick"] = "openSelect(1);"; this.btnViewSign.Attributes["onclick"] = "openSelect(2);"; this.btnDel.Attributes["onclick"] = " return confirm('确定删除当前记录数据吗?');"; this.btnOnHole.Attributes["onclick"] = " return confirm('确定归档吗?');"; this.dgFileList_Bind(); } }
protected void btnPigeOnHole_Click(object sender, EventArgs e) { string corpCode = "%"; string userCode = this.Session["yhdm"].ToString(); DataTable dataTable = DocumentAction.QueryCorpCode(userCode); if (dataTable.Rows.Count > 0) { corpCode = dataTable.Rows[0]["corpCode"].ToString(); } int meetingInfoId = Convert.ToInt32(this.hdnRecordID.Value); if (ConferenceManage.PigeOnHole(userCode, corpCode, meetingInfoId)) { this.JS.Text = "alert('会议纪要已归档!');"; this.gvMeetinInfo.DataBind(); } }
protected void TvClass_Created() { DataTable dataTable = DocumentAction.FilterDocumentClass(this.FilterField); TreeNode treeNode = new TreeNode(); treeNode.Text = "会议分类"; treeNode.NavigateUrl = ""; treeNode.Target = "TemplateList"; this.TVClass.Nodes.Add(treeNode); foreach (DataRow dataRow in dataTable.Rows) { TreeNode treeNode2 = new TreeNode(); treeNode2.Text = dataRow["ClassName"].ToString(); treeNode2.NavigateUrl = "TemplateList.aspx?cid=" + dataRow["ClassID"].ToString(); treeNode2.Target = "TemplateList"; treeNode.Nodes.Add(treeNode2); } }
protected void TVCorpCode_Create() { DataTable dataTable = DocumentAction.QueryCorpCode(this.UserCode); TreeNode treeNode = new TreeNode(); treeNode.Text = "名称"; treeNode.NavigateUrl = ""; treeNode.Target = "SendFileList"; this.TVCorpCode.Nodes.Add(treeNode); foreach (DataRow dataRow in dataTable.Rows) { TreeNode treeNode2 = new TreeNode(); treeNode2.Text = dataRow["CorpName"].ToString(); treeNode2.NavigateUrl = "SendFileList.aspx?code=" + dataRow["CorpCode"].ToString(); treeNode2.Target = "SendFileList"; treeNode.Nodes.Add(treeNode2); } }
protected void BtnAdd_Click(object sender, EventArgs e) { string pStr = this.ddltIsValid.SelectedValue.ToString(); DataTable dataTable = DocumentAction.QueryCorpCode(this.UserCode); string pStr2; if (dataTable.Rows.Count == 0) { pStr2 = "%"; } else { pStr2 = dataTable.Rows[0]["CorpCode"].ToString(); } Hashtable hashtable = new Hashtable(); hashtable.Add("ClassTypeCode", SqlStringConstructor.GetQuotedString(this.ClassTypeCode)); hashtable.Add("CorpCode", SqlStringConstructor.GetQuotedString(pStr2)); hashtable.Add("ClassCode", SqlStringConstructor.GetQuotedString(this.txtClassCode.Text)); hashtable.Add("ClassName", SqlStringConstructor.GetQuotedString(this.txtClassName.Text)); hashtable.Add("IsValid", SqlStringConstructor.GetQuotedString(pStr)); if (this.ClassID == 0) { if (DocumentAction.AddDocClass(hashtable)) { this.JS.Text = "alert('保存成功!');window.returnValue=true;window.close();"; return; } this.JS.Text = "alert('保存失败!');"; return; } else { string where = " where ClassID = '" + this.ClassID + " '"; if (DocumentAction.UpdDocClass(hashtable, where)) { this.JS.Text = "alert('保存成功!');window.returnValue=true;window.close();"; return; } this.JS.Text = "alert('保存失败!');"; return; } }
protected void BtnSave_Click(object sender, EventArgs e) { string pStr = "%"; DataTable dataTable = DocumentAction.QueryCorpCode(this.UserCode); if (dataTable.Rows.Count > 0) { pStr = dataTable.Rows[0]["CorpCode"].ToString(); } DateTime dateTime = default(DateTime); dateTime = DateTime.Now; Hashtable hashtable = new Hashtable(); hashtable.Add("MeetingInfoID", this.MeetingInfoID.ToString()); hashtable.Add("UserCode", SqlStringConstructor.GetQuotedString(this.UserCode)); hashtable.Add("RecordDate", SqlStringConstructor.GetQuotedString(dateTime.ToString("yyyy-MM-dd"))); hashtable.Add("CorpCode", SqlStringConstructor.GetQuotedString(pStr)); hashtable.Add("Topic", SqlStringConstructor.GetQuotedString(this.txtTopic.Text)); hashtable.Add("Content", SqlStringConstructor.GetQuotedString(this.txtContent.Text)); if (this.RecordID == 0) { if (ConferenceManage.AddConferenceTopic(hashtable)) { this.JS.Text = "alert('保存成功!');window.returnValue=true;window.close();"; return; } this.JS.Text = "alert('保存失败!');"; return; } else { string where = " where RecordID = " + this.RecordID.ToString(); if (ConferenceManage.UpdConferenceTopic(hashtable, where)) { this.JS.Text = "alert('保存成功!');window.returnValue=true;window.close();"; return; } this.JS.Text = "alert('保存失败!');"; return; } }
private PTMultiClasses GetData() { PTMultiClasses pTMultiClasses = new PTMultiClasses(); pTMultiClasses.ClassTypeCode = this.ClassTypeCode; pTMultiClasses.ClassCode = this.ClassCode; pTMultiClasses.ParentClassCode = ""; pTMultiClasses.ClassName = this.txtClassName.Text.Trim(); pTMultiClasses.Remark = this.txtRemark.Text.Trim(); pTMultiClasses.IsValid = "1"; string corpCode = "%"; DataTable dataTable = DocumentAction.QueryCorpCode(this.Session["yhdm"].ToString()); if (dataTable.Rows.Count > 0) { corpCode = dataTable.Rows[0]["corpCode"].ToString(); } pTMultiClasses.CorpCode = corpCode; return(pTMultiClasses); }
protected void ImageBtn_Click(object sender, ImageClickEventArgs e) { com.jwsoft.pm.entpm.action.FileUpload fileUpload = new com.jwsoft.pm.entpm.action.FileUpload(); string value = this.hdnFilePath.Value; if (fileUpload.Delete(value)) { this.tr_add.Visible = true; this.tr_edit.Visible = false; Hashtable hashtable = new Hashtable(); hashtable.Add("OriginalName", SqlStringConstructor.GetQuotedString("")); hashtable.Add("FilePath", SqlStringConstructor.GetQuotedString("")); string where = " where TempletID = '" + this.TemplateID + " '"; if (DocumentAction.UpdDocTemplate(hashtable, where)) { this.JS.Text = "alert('模板文件删除成功!');"; return; } this.JS.Text = "alert('模板文件删除失败!');"; } }
/// <summary> /// Copy the template, add the data and print, save or open the report. /// </summary> /// <remarks> /// This method takes a collection of objects and uses reflection to check their /// properties for tags with the same name in the template from which the document /// is generated. /// </remarks> /// <param name="records">The list of records for which this report is created.</param> /// <param name="templateFileOrFolder"> /// The folder where to look for the template, or the name of the template to use. /// <remarks> /// If this is an existing file, the template selection is skipped and the /// given file is used as the template for the document to generate. /// </remarks> /// </param> /// <param name="docxFileName">Filename of the document to generate.</param> /// <param name="action">Determines what to do after the document has been generated.</param> public static void CreateReportFromList(IEnumerator records, string templateFileOrFolder, string docxFileName, DocumentAction action = DocumentAction.OpenAction) { DocxReport report = new DocxReport(); if (report.OpenTemplate(templateFileOrFolder, docxFileName)) { while (records.MoveNext()) { foreach (string path in report.Tags.Keys) { foreach (TagInfo tag in report.Tags[path]) { report.AddData(records.Current, path, tag); } } } report.SaveReport(action); } }
/// <summary> /// Copy the template, add the data and print, save or open the report. /// </summary> /// <remarks> /// This method takes a single object and uses reflection to check it's /// properties for tags with the same name in the template from which the document /// is generated. /// </remarks> /// <param name="record">The record for which this report is created.</param> /// <param name="templateFileOrFolder"> /// The folder where to look for the template, or the name of the template to use. /// <remarks> /// If this is an existing file, the template selection is skipped and the /// given file is used as the template for the document to generate. /// </remarks> /// </param> /// <param name="docxFileName">Filename of the document to generate.</param> /// <param name="action">Determines what to do after the document has been generated.</param> public static void CreateReportFromObject(object record, string templateFileOrFolder, string docxFileName, DocumentAction action = DocumentAction.OpenAction) { DocxReport report = new DocxReport(); if (report.OpenTemplate(templateFileOrFolder, docxFileName)) { foreach (string path in report.Tags.Keys) { if (string.IsNullOrEmpty(path)) { foreach (TagInfo tag in report.Tags[path]) { tag.InsertText("%"); } } else { foreach (TagInfo tag in report.Tags[path]) { report.AddData(record, path, tag); } } } report.SaveReport(action); } }
/// <summary> /// Check what to do with the generated document. /// </summary> /// <remarks> /// Options are Print, Save or Open. /// </remarks> /// <param name="action">Determines what to do after the document has been generated.</param> private void SaveReport(DocumentAction action) { this.document.Save(); this.file.Dispose(); if (DocumentAction.SaveAction != action) { ProcessStartInfo psi = new ProcessStartInfo(this.fileName); if (DocumentAction.PrintAction == action) { psi.Verb = "Print"; } psi.UseShellExecute = true; Process process = Process.Start(psi); if ((DocumentAction.PrintAction == action) || this.deleteFileWhenDone) { process.WaitForExit(); } } if (this.deleteFileWhenDone) { File.Delete(this.fileName); } }