private PdeContentItem AddPdeConentItem(string pdeFilePath, string templateName, string stn, int sAppID) { #region validate if (string.IsNullOrWhiteSpace(stn)) { MessageBox.Show("Supplemetary template name is not allowed empty."); return(null); } if (PdeContent.Items.Exists(c => string.Equals(stn, c.STN, StringComparison.OrdinalIgnoreCase))) { MessageBox.Show("This supplemetary template name is already defined. Please input another."); return(null); } #endregion #region add PdeContentItem pdeContentItem = new PdeContentItem(); pdeContentItem.FileContent = ProntoDoc.Framework.Utils.FileHelper.ExcelToBase64(pdeFilePath); pdeContentItem.SAppID = sAppID; pdeContentItem.Status = Core.Constants.ContextManager.NotUsingStatus; pdeContentItem.STN = stn; pdeContentItem.TemplateName = templateName; pdeContentItem.FilePath = pdeFilePath; PdeContent.Items.Add(pdeContentItem); #endregion return(pdeContentItem); }
private bool ImportPdeChart(PdeContentItem pdeContentItem, string domainName, string chartName) { if (pdeContentItem == null || pdeContentItem.ExportData == null || pdeContentItem.ExportData.Items == null) { return(false); } // validate export domain information DomainExportItem expDomain = pdeContentItem.ExportData.Items.FirstOrDefault( c => string.Equals(c.DomainName, domainName, StringComparison.OrdinalIgnoreCase)); if (expDomain == null || expDomain.Items == null) { return(false); } // validate export item information ExportItem expItem = expDomain.Items.FirstOrDefault( c => c.MapType == MapType.Chart && c.Chart != null && string.Equals(c.Chart.Name, chartName, StringComparison.OrdinalIgnoreCase)); if (expItem == null) { return(false); } expItem.IsUsed = true; return(true); }
/// <summary> /// open pde template and make link with excel add-in /// </summary> /// <param name="pdeFilePath"></param> /// <param name="wDoc"></param> public void ImportPde(PdeContentItem pdeContentItem, Word.Document wDoc) { _wDoc = wDoc; Excel.Workbook workBook = OpenExcelFileToImport(pdeContentItem.FilePath); pdeContentItem.ExportData = GetExportedData(workBook); CloseExcel(); }
public string ImportPdeChart(Word.Document wDoc, PdeContentItem pdeContentItem, string domainName, string chartName, string chartContent) { string bmName = ImportPdeChart(wDoc, chartName, chartContent); ImportPdeChart(pdeContentItem, domainName, chartName); return(bmName); }
private void dgvData_CellClick(object sender, DataGridViewCellEventArgs e) { DataGridViewRow row = dgvData.Rows[e.RowIndex]; string oldSTN = row.Cells[ColSTN.Name].Value.ToString(); PdeContentItem item = PdeContent.Items.FirstOrDefault( c => string.Equals(oldSTN, c.STN, StringComparison.OrdinalIgnoreCase)); frmImportItem importItem = new frmImportItem(); importItem.pdeContent = item; importItem.ShowDialog(); importItem.ShowImportedItem(); }
public string ImportPdeTag(Word.Document wDoc, PdeContentItem pdeContentItem, string domainName, string tableExcelName, string columnExcelName, string displayName) { string bmName = string.IsNullOrWhiteSpace(columnExcelName) ? tableExcelName : columnExcelName; bmName = ImportPdeTag(wDoc, bmName, displayName); if (!string.IsNullOrWhiteSpace(bmName)) { ImportPdeTag(pdeContentItem, domainName, tableExcelName, columnExcelName); } return(bmName); }
private void btnDelete_Click(object sender, EventArgs e) { if (dgvData.SelectedRows != null && dgvData.SelectedRows.Count > 0) { DataGridViewRow row = dgvData.SelectedRows[0]; string oldSTN = row.Cells[ColSTN.Name].Value.ToString(); PdeContentItem item = PdeContent.Items.FirstOrDefault( c => string.Equals(oldSTN, c.STN, StringComparison.OrdinalIgnoreCase)); if (item != null) { PdeContent.Items.Remove(item); dgvData.Rows.RemoveAt(row.Index); } } }
private bool IsUseInInlineShape(Word.Document wDoc, PdeContentItem pdeContentItem) { foreach (Word.InlineShape shape in wDoc.InlineShapes) { if (shape.HasChart == Office.MsoTriState.msoTrue && shape.LinkFormat != null) { string linkSource = shape.LinkFormat.SourceFullName; if (linkSource.IndexOf(pdeContentItem.FilePath) > -1) { return(true); } } } return(false); }
private bool IsUseInField(Word.Document wDoc, PdeContentItem pdeContentItem) { foreach (Word.Field field in wDoc.Fields) { if (field.Type == Word.WdFieldType.wdFieldLink) { string linkSource = field.LinkFormat.SourceFullName; if (linkSource.IndexOf(pdeContentItem.FilePath) > -1) { return(true); } } } return(false); }
private void AddExportXSD(PdeContentItem pdeContentItem) { if (pdeContentItem == null || pdeContentItem.ExportData == null) { return; } string filePath = GenNewPdeFilePath(pdeContentItem); pdeContentItem.FilePath = filePath; ProntoDoc.Framework.Utils.FileHelper.ExcelFromBase64(pdeContentItem.FileContent, filePath); AddExportXSD(filePath, pdeContentItem.EncodeSTN, pdeContentItem.ExportData); // delete temporary file pdeContentItem.FileContent = ProntoDoc.Framework.Utils.FileHelper.ExcelToBase64(filePath); ProntoDoc.Framework.Utils.FileHelper.DeleteFile(filePath); }
private bool ImportPdeTag(PdeContentItem pdeContentItem, string domainName, string tableExcelName, string columnExcelName) { if (pdeContentItem == null || pdeContentItem.ExportData == null || pdeContentItem.ExportData.Items == null) { return(false); } // validate export domain information DomainExportItem expDomain = pdeContentItem.ExportData.Items.FirstOrDefault( c => string.Equals(c.DomainName, domainName, StringComparison.OrdinalIgnoreCase)); if (expDomain == null || expDomain.Items == null) { return(false); } // validate export item information ExportItem expItem = expDomain.Items.FirstOrDefault( c => string.Equals(c.ExcelName, tableExcelName, StringComparison.OrdinalIgnoreCase)); if (expItem == null) { return(false); } // validate export column if (!string.IsNullOrWhiteSpace(columnExcelName)) { if (expItem.Columns == null) { return(false); } ColumnExportItem expColumn = expItem.Columns.FirstOrDefault( c => string.Equals(c.ExcelName, columnExcelName, StringComparison.OrdinalIgnoreCase)); if (expColumn == null) { return(false); } expColumn.IsUsed = true; } expItem.IsUsed = true; return(true); }
private void btnUpdate_Click(object sender, EventArgs e) { if (dgvData.SelectedRows != null && dgvData.SelectedRows.Count > 0) { DataGridViewRow row = dgvData.SelectedRows[0]; string oldSTN = row.Cells[ColSTN.Name].Value.ToString(); PdeContentItem item = PdeContent.Items.FirstOrDefault( c => string.Equals(oldSTN, c.STN, StringComparison.OrdinalIgnoreCase)); if (item != null) { #region validate if (string.IsNullOrWhiteSpace(txtSTN.Text)) { MessageBox.Show("Supplemetary template name is not allowed empty."); return; } if (PdeContent.Items.Exists(c => string.Equals(txtSTN.Text, c.STN, StringComparison.OrdinalIgnoreCase) && (!string.Equals(oldSTN, c.STN, StringComparison.OrdinalIgnoreCase)))) { MessageBox.Show("This supplemetary template name is already defined. Please input another."); return; } #endregion // update pde content item.SAppID = Convert.ToInt32(numSAppID.Value); item.STN = txtSTN.Text; // update ui row.Cells[ColSAppID.Name].Value = numSAppID.Value; row.Cells[ColSTN.Name].Value = txtSTN.Text; // todo: ngocbv_check and update in here //ContextManager contextMgr = new ContextManager(); //contextMgr.UpdateLinkSource(); } } }
private void btnAdd_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtPdeFile.Text)) { MessageBox.Show("Please select a pde file."); return; } if (!System.IO.File.Exists(txtPdeFile.Text)) { MessageBox.Show("Pde file is not exist."); return; } string templateName = System.IO.Path.GetFileNameWithoutExtension(txtPdeFile.Text); PdeContentItem pdeContentItem = AddPdeConentItem(txtPdeFile.Text, templateName, txtSTN.Text, Convert.ToInt32(numSAppID.Value)); if (pdeContentItem == null) { return; } BindPdeContent(); ContextManager contextMgr = new ContextManager(); contextMgr.ImportPde(pdeContentItem, _wDoc); frmImportItem importItem = new frmImportItem(); importItem.pdeContent = pdeContentItem; importItem.ShowDialog(); importItem.ShowImportedItem(); //Wkl.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo.ProntoDocMarkup.LoadImportPDE(); //Close(); }
public void ImportPde(PdeContentItem pdeContentItem, Document wDoc) { mainManager.MainService.PropertyService.ImportPde(pdeContentItem, wDoc); }
private string GenNewPdeFilePath(PdeContentItem pdeContentItem) { return(string.Format("{0}\\{1}_{2}.pde", AssetManager.FileAdapter.TemporaryFolderPath, Guid.NewGuid(), pdeContentItem.STN)); }
public void ImportPde(PdeContentItem pdeContentItem, Document wDoc) { PdeService.ImportPde(pdeContentItem, wDoc); }