private static Field smethod_1(string A_0, Document A_1) { int num = 9; Field field = null; string str = A_0.Trim(); FieldType type = Class819.smethod_2(str); FieldType type2 = type; if (type2 <= FieldType.FieldMergeField) { if (type2 != FieldType.FieldIf) { if (type2 != FieldType.FieldMergeField) { goto Label_005C; } field = new MergeField(A_1); } else { field = new IfField(A_1); } goto Label_0113; } switch (type2) { case FieldType.FieldFormTextInput: case FieldType.FieldFormCheckBox: case FieldType.FieldFormDropDown: { string str2 = str.ToUpper(); if (str2 != null) { if ((str2 == BookmarkStart.b("笮琰欲愴縶眸欺格款", num)) || (str2 == BookmarkStart.b("椮縰愲破挶簸挺椼", num))) { field = new TextFormField(A_1); } else if ((str2 == BookmarkStart.b("欮田缲簴搶洸", num)) || (str2 == BookmarkStart.b("椮縰愲破猶欸琺洼笾เᑂୄ", num))) { field = new DropDownFormField(A_1); } else if ((str2 == BookmarkStart.b("氮礰瘲瘴簶笸琺攼", num)) || (str2 == BookmarkStart.b("椮縰愲破琶焸縺縼琾̀ూᵄ", num))) { field = new CheckBoxFormField(A_1); } } (field as FormField).HasFFData = false; goto Label_0113; } } Label_005C: field = new Field(A_1); Label_0113: field.Code = field.Code + A_0; if (!(field is FormField)) { field.Type = type; } return(field); }
private static Field smethod_7(string A_0, Document A_1) { int num = 12; Field field = null; string str = A_0.Trim(); FieldType type = Class819.smethod_2(str); FieldType type2 = type; if (type2 <= FieldType.FieldMergeField) { if (type2 != FieldType.FieldIf) { if (type2 != FieldType.FieldMergeField) { goto Label_005C; } field = new MergeField(A_1); } else { field = new IfField(A_1); } goto Label_0113; } switch (type2) { case FieldType.FieldFormTextInput: case FieldType.FieldFormCheckBox: case FieldType.FieldFormDropDown: { string str2 = str.ToUpper(); if (str2 != null) { if ((str2 == BookmarkStart.b("昱焳渵氷猹爻渽ᔿᙁ", num)) || (str2 == BookmarkStart.b("琱笳搵男渹礻昽ᐿ", num))) { field = new TextFormField(A_1); } else if ((str2 == BookmarkStart.b("瘱瀳稵焷椹栻", num)) || (str2 == BookmarkStart.b("琱笳搵男縹渻焽ဿفୃᅅه", num))) { field = new DropDownFormField(A_1); } else if ((str2 == BookmarkStart.b("焱簳猵笷焹縻焽ᠿ", num)) || (str2 == BookmarkStart.b("琱笳搵男礹琻笽̿ुكॅ၇", num))) { field = new CheckBoxFormField(A_1); } } (field as FormField).HasFFData = false; goto Label_0113; } } Label_005C: field = new Field(A_1); Label_0113: field.Code = field.Code + A_0; if (!(field is FormField)) { field.Type = type; } return(field); }
private void button1_Click(object sender, EventArgs e) { //Open a Word document with form. Document document = new Document(@"..\..\..\..\..\..\Data\FillFormField.doc"); //Load data. using (Stream stream = File.OpenRead(@"..\..\..\..\..\..\Data\User.xml")) { XPathDocument xpathDoc = new XPathDocument(stream); XPathNavigator user = xpathDoc.CreateNavigator().SelectSingleNode("/user"); //Fill data. foreach (FormField field in document.Sections[0].Body.FormFields) { String path = String.Format("{0}/text()", field.Name); XPathNavigator propertyNode = user.SelectSingleNode(path); if (propertyNode != null) { switch (field.Type) { case FieldType.FieldFormTextInput: field.Text = propertyNode.Value; break; case FieldType.FieldFormDropDown: DropDownFormField combox = field as DropDownFormField; for (int i = 0; i < combox.DropDownItems.Count; i++) { if (combox.DropDownItems[i].Text == propertyNode.Value) { combox.DropDownSelectedIndex = i; break; } if (field.Name == "country" && combox.DropDownItems[i].Text == "Others") { combox.DropDownSelectedIndex = i; } } break; case FieldType.FieldFormCheckBox: if (Convert.ToBoolean(propertyNode.Value)) { CheckBoxFormField checkBox = field as CheckBoxFormField; checkBox.Checked = true; } break; } } } } //Save doc file. document.SaveToFile("Sample.doc", FileFormat.Doc); //Launch the Word file. WordDocViewer("Sample.doc"); }
private void imethod_15(CharacterFormat A_0, FieldType A_1) { Field field; FieldType type = A_1; if (type <= FieldType.FieldMergeField) { if (type != FieldType.FieldIf) { if (type != FieldType.FieldMergeField) { goto Label_0044; } field = new MergeField(this.document_0); } else { field = new IfField(this.document_0); } goto Label_007A; } switch (type) { case FieldType.FieldFormTextInput: field = new TextFormField(this.document_0); goto Label_007A; case FieldType.FieldFormCheckBox: field = new CheckBoxFormField(this.document_0); goto Label_007A; case FieldType.FieldFormDropDown: field = new DropDownFormField(this.document_0); goto Label_007A; } Label_0044: field = new Field(this.document_0); Label_007A: this.fieldCharType_0 = FieldCharType.Begin; field.Type = A_1; field.CharacterFormat = (CharacterFormat)A_0.Clone(); this.documentObject_0.method_13(field); if (A_1 == FieldType.FieldTOC) { (this.documentObject_0 as Paragraph).IsTOCPara = true; } this.stack_0.Push(field); }
private int method_17(int A_0, DocumentObject A_1) { int num = 0x13; switch ((A_1 as FormField).FormFieldType) { case FormFieldType.TextInput: { TextFormField field = A_1 as TextFormField; if ((field.Name == null) || (field.Name == string.Empty)) { field.Name = (BookmarkStart.b("洸帺䔼䬾Ṁ", num) + Guid.NewGuid().ToString().Replace(BookmarkStart.b("ᐸ", num), BookmarkStart.b("昸", num))).Substring(0, 20); } if ((field.DefaultText == null) || (field.DefaultText == string.Empty)) { field.DefaultText = BookmarkStart.b("㬘㤚㼜㴞䍠", num); } break; } case FormFieldType.CheckBox: { CheckBoxFormField field3 = A_1 as CheckBoxFormField; if ((field3.Name == null) || (field3.Name == string.Empty)) { field3.Name = (BookmarkStart.b("稸区堼尾⩀᱂", num) + Guid.NewGuid().ToString().Replace(BookmarkStart.b("ᐸ", num), BookmarkStart.b("昸", num))).Substring(0, 20); } break; } case FormFieldType.DropDown: { DropDownFormField field2 = A_1 as DropDownFormField; if ((field2.Name == null) || (field2.Name == string.Empty)) { field2.Name = (BookmarkStart.b("紸䤺刼伾Ṁ", num) + Guid.NewGuid().ToString().Replace(BookmarkStart.b("ᐸ", num), BookmarkStart.b("昸", num))).Substring(0, 20); } break; } } (this.Owner as Paragraph).method_78((A_1 as FormField).Name); (this.Owner as Paragraph).Items.Insert(A_0, new BookmarkStart(base.Document, (A_1 as FormField).Name)); A_0++; return(A_0); }
void MailMerge_MergeField(object sender, MergeFieldEventArgs args) { if (args.FieldValue == "Yes") { //Create a checkbox name string checkBoxName = args.FieldName; Paragraph para = args.CurrentMergeField.OwnerParagraph; int index = para.ChildObjects.IndexOf(args.CurrentMergeField); // Insert a check box. CheckBoxFormField field = para.AppendField(checkBoxName, FieldType.FieldFormCheckBox) as CheckBoxFormField; para.ChildObjects.Insert(index, field); para.ChildObjects.Remove(args.CurrentMergeField); field.Checked = true; } if (args.FieldValue == "No") { //Create a checkbox name string checkBoxName = args.FieldName; Paragraph para = args.CurrentMergeField.OwnerParagraph; int index = para.ChildObjects.IndexOf(args.CurrentMergeField); // Insert a check box. CheckBoxFormField field = para.AppendField(checkBoxName, FieldType.FieldFormCheckBox) as CheckBoxFormField; para.ChildObjects.Insert(index, field); para.ChildObjects.Remove(args.CurrentMergeField); field.Checked = false; } // Insert html during mail merge. if (args.FieldName == "Body") { Paragraph para = args.CurrentMergeField.OwnerParagraph; para.AppendHTML(args.FieldValue.ToString()); para.ChildObjects.Remove(args.CurrentMergeField); } // Insert text input form field. if (args.FieldName == "Date") { string textInputName = args.FieldName; Paragraph para = args.CurrentMergeField.OwnerParagraph; TextFormField field = para.AppendField(textInputName, FieldType.FieldFormTextInput) as TextFormField; para.ChildObjects.Remove(args.CurrentMergeField); field.Text = args.FieldValue.ToString(); } }
private void imethod_14(Class42 A_0, CharacterFormat A_1) { switch (A_0.method_87()) { case FormFieldType.TextInput: { TextFormField field3 = this.stack_0.Peek() as TextFormField; field3.Name = A_0.method_46(); field3.ApplyCharacterFormat(A_1); field3.DefaultText = A_0.method_68(); field3.MaximumLength = A_0.method_64(); field3.StringFormat = A_0.method_70(); field3.TextFieldType = A_0.method_66(); return; } case FormFieldType.CheckBox: { CheckBoxFormField field = this.stack_0.Peek() as CheckBoxFormField; field.Name = A_0.method_46(); field.ApplyCharacterFormat(A_1); field.CalculateOnExit = A_0.method_50(); field.CheckBoxSize = (int)(((float)A_0.method_74()) / 2f); field.SizeType = A_0.method_72() ? CheckBoxSizeType.Auto : CheckBoxSizeType.Exactly; field.Checked = A_0.method_78(); field.DefaultCheckBoxValue = A_0.method_76(); return; } case FormFieldType.DropDown: { DropDownFormField field2 = this.stack_0.Peek() as DropDownFormField; field2.Name = A_0.method_46(); field2.ApplyCharacterFormat(A_1); field2.DefaultDropDownValue = A_0.method_81(); A_0.method_86().method_6(field2.DropDownItems); field2.DropDownSelectedIndex = A_0.method_83(); return; } } }
public string doWord2Txt(string docPath, string draPath, bool bCopyDra = true) { //string docPath = @"D:\每日工作处理文件\20200323\复审无效样例\无效\DOC\W36229_109752_6W109752.doc"; //string draPath = @"D:\每日工作处理文件\20200323\复审无效样例\无效\DOC"; string txtPath = draPath + "\\" + Path.GetFileNameWithoutExtension(docPath) + ".txt"; Document document = new Document(docPath); int index = 0; string txtCotent = document.GetText(); StreamWriter sw = new StreamWriter(txtPath, false, Encoding.UTF8); int iTable = 0; //document.SaveToFile("d:\\Targetxml.xml", FileFormat.WordXml); //Get Each Section of Document foreach (Section section in document.Sections) { foreach (DocumentObject obj in section.Body.ChildObjects) { if (obj.DocumentObjectType == DocumentObjectType.Paragraph) { #region Paragraph Paragraph paragraph = obj as Paragraph; StringBuilder sbPara = new StringBuilder(); //WORD默认生成的下拉小序号 if (!String.IsNullOrEmpty(paragraph.ListText)) { sbPara.Append(paragraph.ListText); } foreach (DocumentObject docObject in paragraph.ChildObjects) { //If Type of Document Object is Picture, Extract. if (docObject.DocumentObjectType == DocumentObjectType.Picture) { DocPicture pic = docObject as DocPicture; String imgName = draPath + String.Format("\\Image -{0}.png", index); //Save Image sbPara.Append("<image>" + index + ".png" + "</image>"); if (bCopyDra) { pic.Image.Save(imgName, System.Drawing.Imaging.ImageFormat.Png); } index++; } else if (docObject.DocumentObjectType == DocumentObjectType.TextRange) { TextRange txt = docObject as TextRange; if (txt.CharacterFormat.SubSuperScript == SubSuperScript.SubScript) { sbPara.Append("<sub>" + txt.Text + "</sub>"); } else if (txt.CharacterFormat.SubSuperScript == SubSuperScript.SuperScript) { sbPara.Append("<sup>" + txt.Text + "</sup>"); } else if (txt.CharacterFormat.SubSuperScript == SubSuperScript.BaseLine) { sbPara.Append(txt.Text); } else { sbPara.Append(txt.Text); } } else if (docObject.DocumentObjectType == DocumentObjectType.BookmarkStart) { sbPara.Append("<bookmark>"); continue; #region 注释BOOKMARK /* * BookmarkStart mark = docObject as BookmarkStart; * BookmarksNavigator navigator = new BookmarksNavigator(document); * navigator.MoveToBookmark(mark.Name); * TextBodyPart textBodyPart = navigator.GetBookmarkContent(); * string text = null; * foreach (var item in textBodyPart.BodyItems) * { * if (item is Paragraph) * { * text += (item as Paragraph).Text; * foreach (var childObject in (item as Paragraph).ChildObjects) * { * if (childObject is TextRange) * { * text += (childObject as TextRange).Text; * } * } * } * } * sbPara.Append("<bookmarkStart>" + text + "</bookmarkStart>"); */ #endregion } else if (docObject.DocumentObjectType == DocumentObjectType.BookmarkEnd) { sbPara.Append("</bookmark>"); continue; #region 注释BOOKMARK /* * BookmarkEnd mark = docObject as BookmarkEnd; * BookmarksNavigator navigator = new BookmarksNavigator(document); * navigator.MoveToBookmark(mark.Name); * TextBodyPart textBodyPart = navigator.GetBookmarkContent(); * string text = null; * foreach (var item in textBodyPart.BodyItems) * { * if (item is Paragraph) * { * text += (item as Paragraph).Text; * foreach (var childObject in (item as Paragraph).ChildObjects) * { * if (childObject is TextRange) * { * text += (childObject as TextRange).Text; * } * } * } * } * sbPara.Append("<bookmarkEnd>" + text + "</bookmarkEnd>"); */ #endregion } else if (docObject.DocumentObjectType == DocumentObjectType.TextFormField) { continue; //TextFormField textForm = docObject as TextFormField; //sbPara.Append("<textForm>" + textForm.Name + "</textForm>"); } else if (docObject.DocumentObjectType == DocumentObjectType.FieldMark) { //FieldMark fieldMark = docObject as FieldMark; //sbPara.Append("<FieldMark>" + fieldMark.StyleName + "</FieldMark>"); } else if (docObject.DocumentObjectType == DocumentObjectType.CheckBox) { CheckBoxFormField checkBox = docObject as CheckBoxFormField; sbPara.Append("<CheckBox>" + checkBox.Checked.ToString() + "</CheckBox>"); } else if (docObject.DocumentObjectType == DocumentObjectType.Break) { Break bk = docObject as Break; if (sbPara.Length > 0 && (bk.BreakType == BreakType.PageBreak || bk.BreakType == BreakType.LineBreak))//无效数据中总是不折行 { sbPara.Append("\r\n"); } sbPara.Append("<Break>" + bk.BreakType + "</Break>"); } else if (docObject.DocumentObjectType == DocumentObjectType.OleObject) { DocOleObject ole = docObject as DocOleObject; sbPara.Append("<OleObject>" + ole.ShapeType + "</OleObject>"); } else if (docObject.DocumentObjectType == DocumentObjectType.TextRange) { TextRange tr = docObject as TextRange; sbPara.Append(tr.Text); } else { } } sw.WriteLine(sbPara.ToString()); #endregion } else if (obj.DocumentObjectType == DocumentObjectType.Table) { iTable++; if (iTable > 2)//table需要转PIC,不再做内容了 { sw.WriteLine("<image>" + index++ + ".png" + "</image>"); continue; } StringBuilder sbTable = new StringBuilder(); sbTable.Append("<table>"); Table table = obj as Table; foreach (TableRow row in table.Rows) { sbTable.Append("<row>"); foreach (TableCell cell in row.Cells) { sbTable.Append("<col>"); foreach (DocumentObject item in cell.ChildObjects) { if (item.DocumentObjectType == DocumentObjectType.Table) { continue; } Paragraph itemPara = item as Paragraph; foreach (DocumentObject child in itemPara.ChildObjects) { if (child.DocumentObjectType == DocumentObjectType.TextRange) { TextRange tr = child as TextRange; sbTable.Append(tr.Text); } else if (child.DocumentObjectType == DocumentObjectType.BookmarkStart) { sbTable.Append("<bookmark>"); } else if (child.DocumentObjectType == DocumentObjectType.BookmarkEnd) { sbTable.Append("</bookmark>"); } else if (child.DocumentObjectType == DocumentObjectType.FieldMark) { sbTable.Append("<FieldMark>"); } } } sbTable.Append("</col>"); } sbTable.Append("</row>"); } sbTable.Append("</table>"); sw.WriteLine(sbTable.ToString()); sw.Flush(); } } } sw.Flush(); sw.Close(); sw.Dispose(); return(txtPath); }
public ActionResult DownloadPDF(string DownloadToken) { try { var fullUploadPath = (string)Session["FullUploadPath"]; var brokerVM = (BrokerVM)Session["Broker"]; string templateFolder = System.Web.HttpContext.Current.Server.MapPath("~/App_Data/Template/"); Document document = new Document(); document.LoadFromFile(Path.Combine(templateFolder, "TemplateBrokerPotvrdaPrijave.docx")); foreach (FormField field in document.Sections[0].Body.FormFields) { if (field.Type == FieldType.FieldFormCheckBox) { CheckBoxFormField checkBox = field as CheckBoxFormField; if (checkBox.Name == "L1") { checkBox.Checked = (brokerVM.VrstaPrijaveBroker == VrstaPrijaveBroker.PrijavaL1); } if (checkBox.Name == "L2") { checkBox.Checked = (brokerVM.VrstaPrijaveBroker == VrstaPrijaveBroker.PrijavaL2); } if (checkBox.Name == "L3") { checkBox.Checked = (brokerVM.VrstaPrijaveBroker == VrstaPrijaveBroker.PrijavaL3); } } } document.Replace("%ImePrezime%", string.Format($"{brokerVM.Ime.ToUpper()} {brokerVM.Prezime.ToUpper()}"), false, true); document.Replace("%DatumMjestoDrzavaRodjenja%", string.Format($"{brokerVM.DatumRodjenja.ToString("dd.MM.yyyy.")}, {brokerVM.MjestoRodjenja.ToUpper()}, {brokerVM.DrzavaRodjenja.ToUpper()}"), false, true); document.Replace("%ObrazovanjeNazivZanimanje%", string.Format($"{brokerVM.StupanjObrazovanja.ToUpper()}, {brokerVM.SteceniNaziv.ToUpper()}, {brokerVM.Zanimanje.ToUpper()}"), false, true); document.Replace("%AdresaPrebivalista%", string.Format($"{brokerVM.Ulica.ToUpper()} {brokerVM.KucniBroj.ToUpper()}, {brokerVM.Grad.ToUpper()}"), false, true); document.Replace("%AdresaZaPrepisku%", string.Format($"{brokerVM.UlicaPrepiska.ToUpper()} {brokerVM.KucniBrojPrepiska.ToUpper()}, {brokerVM.GradPrepiska.ToUpper()}"), false, true); document.Replace("%Telefon%", string.Format($"{brokerVM.Telefon}"), false, true); document.Replace("%Email%", string.Format($"{brokerVM.Email.ToUpper()}"), false, true); document.Replace("%OIB%", brokerVM.OIB.ToUpper(), false, true); document.Replace("%SifraKandidata%", string.Format($"{brokerVM.SifraKandidata}"), false, true); document.Replace("%IspitPolazem%", string.Format($"{brokerVM.IspitPolazem.ToString()}"), false, true); if (brokerVM.IspitiPolozeniUHanfi != null) { document.Replace("%IspitiPolozeniUHanfi%", string.Format($"{brokerVM.IspitiPolozeniUHanfi.ToUpper()}"), false, true); } else { document.Replace("%IspitiPolozeniUHanfi%", string.Empty, false, true); } if (brokerVM.IspitiPolozeniUOrganizacijiCFA != null) { document.Replace("%IspitiPolozeniUOrganizacijiCFA%", string.Format($"{brokerVM.IspitiPolozeniUOrganizacijiCFA.ToUpper()}"), false, true); } else { document.Replace("%IspitiPolozeniUOrganizacijiCFA%", string.Empty, false, true); } document.Replace("%DatumPrijave%", string.Format($"{DateTime.Now.ToString("dd.MM.yyyy.")}"), false, true); var newPdfFileName = String.Format($"{brokerVM.VrijemePrijave}_{brokerVM.Ime}_{brokerVM.Prezime}_{brokerVM.SifraKandidata}_PrijavaBrokeri.pdf"); document.SaveToFile(Path.Combine(fullUploadPath, newPdfFileName), FileFormat.PDF); using (MemoryStream stream = new MemoryStream()) { document.SaveToStream(stream, FileFormat.PDF); //snimi u bazu još ovaj fajl, prijavu OnLinePrijaveContext db = new OnLinePrijaveContext(); int brokerID = (int)Session["brokerID"]; var broker = db.Brokeri.FirstOrDefault(b => b.BrokerId == brokerID); broker.BrokerFiles.Add(new BrokerFile { FilePath = (Path.Combine(fullUploadPath, newPdfFileName)) }); db.SaveChanges(); emailService.SendEmail( fromDisplayName: "", fromEmailAddress: "*****@*****.**", toName: "", toEmailAddress: brokerVM.Email, subject: "Potvrda primitka prijave za provjeru znanja i stjecanje kvalifikacija za L1 Informiranje/ L2 Brokerski poslovi/L3 Investicijsko savjetovanje ", message: "Vaša prijava za provjeru znanja i stjecanje kvalifikacija za L1 Informiranje/ L2 Brokerski poslovi/L3 Investicijsko savjetovanje uspješno je zaprimljena.", attachments: new Attachment(newPdfFileName, stream.ToArray())); FlashMessage.Confirmation("Na adresu elektroničke pošte navedene na obrascu prijave, dobit ćete potvrdu primitka Vaše prijave. U slučaju da predmetnu potvrdu ne zaprimite, molimo da se javite na adresu [email protected]"); return(RedirectToAction("Brokeri")); } } catch (Exception ex) { log.Error("Error", ex); return(Json(new { status = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public ActionResult DownloadPDF(string DownloadToken) { try { var fullUploadPath = (string)Session["FullUploadPath"]; var distributerVM = (DistributerVM)Session["Distributer"]; string templateFolder = System.Web.HttpContext.Current.Server.MapPath("~/App_Data/Template/"); log.Info($"Template folder distributeri:{templateFolder}"); Document document = new Document(); document.LoadFromFile(Path.Combine(templateFolder, "TemplateDistributerPotvrdaPrijave.docx")); document.Replace("%ImePrezime%", string.Format($"{distributerVM.Ime.ToUpper()} {distributerVM.Prezime.ToUpper()}"), false, true); document.Replace("%OIB%", distributerVM.OIB.ToUpper(), false, true); document.Replace("%DatumMjestoDrzavaRodjenja%", string.Format($"{distributerVM.DatumRodjenja.ToString("dd.MM.yyyy.")}, {distributerVM.MjestoRodjenja}, {distributerVM.DrzavaRodjenja.ToUpper()}"), false, true); document.Replace("%AdresaBrojTelefona%", string.Format($"{distributerVM.Ulica.ToUpper()} {distributerVM.KucniBroj.ToUpper()}, {distributerVM.Grad.ToUpper()}, {distributerVM.BrojTelefona.ToUpper()}"), false, true); document.Replace("%Email%", string.Format($"{distributerVM.Email.ToUpper()}"), false, true); document.Replace("%StrucnaSprema%", string.Format($"{distributerVM.StrucnaSprema.ToUpper()}"), false, true); if (!string.IsNullOrEmpty(distributerVM.Zanimanje)) { document.Replace("%Zanimanje%", string.Format($"{distributerVM.Zanimanje.ToUpper()}"), false, true); } else { document.Replace("%Zanimanje%", "", false, true); } if (!string.IsNullOrEmpty(distributerVM.ZaposlenKod)) { document.Replace("%ZaposlenKod%", string.Format($"{distributerVM.ZaposlenKod.ToUpper()}"), false, true); } else { document.Replace("%ZaposlenKod%", "", false, true); } document.Replace("%IspitPolazem%", string.Format($"{distributerVM.IspitPolazem.ToString()}"), false, true); document.Replace("%SifraKandidata%", string.Format($"{distributerVM.SifraKandidata}"), false, true); document.Replace("%DatumPrijave%", string.Format($"{DateTime.Now.ToString("dd.MM.yyyy.")}"), false, true); foreach (FormField field in document.Sections[0].Body.FormFields) { if (field.Type == FieldType.FieldFormCheckBox) { CheckBoxFormField checkBox = field as CheckBoxFormField; if (checkBox.Name == "ZivotnoOsig") { checkBox.Checked = distributerVM.ZivotnoOsiguranje; } if (checkBox.Name == "NezivotnoOsig") { checkBox.Checked = distributerVM.NezivotnoOsiguranje; } if (checkBox.Name == "DistribucijeOsig") { checkBox.Checked = distributerVM.DistribucijaOsiguranja; } if (checkBox.Name == "DistribucijeReosig") { checkBox.Checked = distributerVM.DistribucijaReosiguranja; } if (checkBox.Name == "ZaRacunDrustva") { checkBox.Checked = distributerVM.ZastupnikUOsiguranju; } if (checkBox.Name == "PoNaloguStrankeOsig") { checkBox.Checked = distributerVM.BrokerUOsiguranju; } if (checkBox.Name == "PoNaloguStrankeRe") { checkBox.Checked = distributerVM.BrokerUReosiguranju; } if (checkBox.Name == "SporedniPosrednik") { checkBox.Checked = distributerVM.PosrednikUOsiguranju; } } } var newPdfFileName = String.Format($"{distributerVM.VrijemePrijave}_{distributerVM.Ime}_{distributerVM.Prezime}_{distributerVM.SifraKandidata}_PrijavaDistributeri.pdf"); document.SaveToFile(Path.Combine(fullUploadPath, newPdfFileName), FileFormat.PDF); using (MemoryStream stream = new MemoryStream()) { document.SaveToStream(stream, FileFormat.PDF); //snimi u bazu još ovaj fajl, prijavu OnLinePrijaveContext db = new OnLinePrijaveContext(); int distributerID = (int)Session["DistributerID"]; var distributer = db.Distributeri.FirstOrDefault(d => d.DistributerId == distributerID); distributer.DistributerFiles.Add(new DistributerFile { FilePath = (Path.Combine(fullUploadPath, newPdfFileName)) }); db.SaveChanges(); emailService.SendEmail( fromDisplayName: "", fromEmailAddress: "*****@*****.**", toName: "", toEmailAddress: distributerVM.Email, subject: "Potvrda primitka prijave za polaganje ispita za distribuciju osiguranja i/ili reosiguranja", message: "Vaša prijava za polaganje ispita za distribuciju osiguranja i/ili reosiguranja je uspješno zaprimljena.", attachments: new Attachment(newPdfFileName, stream.ToArray())); FlashMessage.Confirmation("Na adresu elektroničke pošte navedene na obrascu prijave, dobit ćete potvrdu primitka Vaše prijave. U slučaju da predmetnu potvrdu ne zaprimite, molimo da se javite na adresu [email protected]"); return(RedirectToAction("Distributeri")); } } catch (Exception ex) { log.Error("Error", ex); return(Json(new { status = false, message = ex.Message }, JsonRequestBehavior.AllowGet)); } }