static void Main(string[] args) { string connectionToChange = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MOIN_MSCRM;Data Source=crm11moin"; // "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MANTA_MSCRM;Data Source=CRM11MANTAD"; var queryToChange = "select top 1 new_name as name from new_provider;"; var pathTarget = @"C:\Users\lior_g\Documents\GitHub\DocMailMerge\TemplatesWords\output2.docx"; var pathSource = "http://localhost/TemplatesWords/name.docx"; var mailMergeOpenXml = new MailMergeOpenXml(Log); pathSource = "http://*****:*****@"c:\temp\tal.docm"; var source = new SourceWebDoc(pathSource); var target = new TargetLocalDoc(pathTarget); mailMergeOpenXml.FillData(source, target); return; var customProperties = new Dictionary <string, string>(); customProperties.Add("server", ""); customProperties.Add("entityid", Guid.NewGuid().ToString()); customProperties.Add("tempfolder", "c:\\temp\r.udl"); var result = mailMergeOpenXml.Merge(connectionToChange, queryToChange, source, target, @"c:\\temp\r.udl", @"c:\\temp\TemplateCrmMenta.dotm", customProperties); }
private void button3_Click(object sender, EventArgs e) { if (lstFiles.SelectedItems != null && lstFiles.SelectedItems.Count > 0) { String fileName = lstFiles.SelectedItems[0].Text.ToString();// var targetFileName = Path.ChangeExtension(fileName, "docx"); var pathTarget = TargetFolder + @"\" + targetFileName; Log("pathTarget=" + pathTarget, EventLogEntryType.Information); var pathSource = SourceUri + "/" + fileName; Log("pathSource=" + pathSource, EventLogEntryType.Information); if (File.Exists(pathTarget)) { Log("pathTarget is deleted" + pathTarget, EventLogEntryType.Information); File.Delete(pathTarget); } var mailMergeOpenXml = new MailMergeOpenXml(Log); var source = new SourceWebDoc(pathSource); var target = new TargetLocalDoc(pathTarget); mailMergeOpenXml.FillDataAndConvertDocx(source, target); Log("done Fill Data And Convert To Docx", EventLogEntryType.Information); } }
private void btnDisconnect_Click(object sender, EventArgs e) { if (lstFiles.SelectedItems != null && lstFiles.SelectedItems.Count > 0) { String fileName = lstFiles.SelectedItems[0].Text.ToString(); var pathTarget = TargetFolder + @"\" + fileName; Log("pathTarget=" + pathTarget, EventLogEntryType.Information); var pathSource = SourceUri + "/" + fileName; Log("pathSource=" + pathSource, EventLogEntryType.Information); if (File.Exists(pathTarget)) { Log("pathTarget is deleted" + pathTarget, EventLogEntryType.Information); File.Delete(pathTarget); } var mailMergeOpenXml = new MailMergeOpenXml(Log); var source = new SourceWebDoc(pathSource); var target = new TargetLocalDoc(pathTarget); mailMergeOpenXml.FillData(source, target); Log("done disconnect", EventLogEntryType.Information); } }
private void button2_Click(object sender, EventArgs e) { if (lstXml.SelectedItems != null && lstXml.SelectedItems.Count > 0) { Log("selected item id is " + lstXml.SelectedItems[0].Tag.ToString(), EventLogEntryType.Information); var docTemp = _documentsTemplates.Where(s => s.Id == Guid.Parse(lstXml.SelectedItems[0].Tag.ToString())).Select(ss => new { SQL = ss.Sql, URL = ss.SourceSp }).FirstOrDefault(); // MessageBox.Show(docTemp.SQL); if (docTemp != null) { var sql = docTemp.SQL.Replace("{0}", EntityId.ToString()); string fileName = EntityId.ToString() + "_" + Path.GetFileName(docTemp.URL); var customProperties = new Dictionary <string, string>(); customProperties.Add("server", ""); customProperties.Add("entityid", EntityId.ToString()); customProperties.Add("tempfolder", "c:\\temp\r.udl"); var pathTarget = Path.Combine(SourceFolder, fileName); Log("pathTarget=" + pathTarget, EventLogEntryType.Information); if (File.Exists(pathTarget)) { Log("pathTarget is deleted" + pathTarget, EventLogEntryType.Information); File.Delete(pathTarget); } var pathSource = docTemp.URL; Log("pathSource=" + pathSource, EventLogEntryType.Information); var mailMergeOpenXml = new MailMergeOpenXml(Log); var source = new SourceWebDoc(pathSource); var target = new TargetLocalDoc(pathTarget); var result = mailMergeOpenXml.Merge(ConnectionToChange, sql, source, target, UdlPath, DotMPath, customProperties); Log("done change merge setting =" + result.Drl, EventLogEntryType.Information); } } else { MessageBox.Show("יש בחוק קובץ אחד בלבד XML"); } }