private void HighlightAllBookmark(InternalBookmark iBm) { try { if (iBm != null && iBm.InternalBookmarkDomains != null) { string key; ContentServiceProfile contentProfile = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out key).ContentService; foreach (InternalBookmarkDomain ibmDomain in iBm.InternalBookmarkDomains) { foreach (InternalBookmarkItem item in ibmDomain.InternalBookmarkItems) { contentProfile.HighlightBookmark_IBMName = item.Key; mainManager.MainService.BookmarkService.HighlightWordBookmark(key); } } Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(key); } } catch (BaseException baseExp) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_HighlightBookmarkError); mgrExp.Errors.Add(baseExp); throw mgrExp; } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_HighlightBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_HighlightBookmarkError, ex.Message), ex.StackTrace); throw mgrExp; } }
public string GetInternalBookmarkString() { try { string srvKey = string.Empty; ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey); GetInternalBookmark(srvKey); InternalBookmark internalBm = srvPro.Ibm; Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey); return(ObjectSerializeHelper.SerializeToString <InternalBookmark>(internalBm)); } catch (BaseException srvExp) { Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_LoadInternalBookmarkError); newSrvExp.Errors.Add(srvExp); throw newSrvExp; } catch (Exception ex) { ServiceException srvExp = new ServiceException(ErrorCode.ipe_LoadInternalBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_LoadInternalBookmarkError, ex.Message), ex.StackTrace); throw srvExp; } }
/// <summary> /// Remove all word bookmark that not exist on internal bookmark collection /// </summary> /// <param name="iBms"></param> public void ValidateBookmarkCollection(string key) { // 1. Get all word bookmark // 2. If bookmark in word not exist in internal bookmark // 2.1. markup this to return // 2.2. if isUpdate = true, we delete its try { ContentServiceProfile contentProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).ContentService; InternalBookmark iBms = Wkl.MainCtrl.CommonCtrl.GetTemplateInfo( contentProfile.ValidateBookmark_ITemplateName).InternalBookmark; GetBookmarkCollection(key); List <string> deletedList = new List <string>(); Dictionary <string, string> wBms = contentProfile.GetBookmarks_OListBM; foreach (string bmKey in wBms.Keys) { InternalBookmarkItem item = iBms.GetInternalBookmarkItem(bmKey); if (item == null || item.BizName != wBms[bmKey]) // compare key and value { if (MarkupUtilities.IsProntoDocCommentBookmark(bmKey) || MarkupUtilities.IsPdeTagBookmark(bmKey)) { continue; } deletedList.Add(wBms[bmKey]); contentProfile.HighlightBookmarkName = bmKey; HighlightBookmark(key); if (contentProfile.ValidateBookmark_IIsUpdate) { contentProfile.DeletedBookmarkName = bmKey; contentProfile.DeleteWholeBookmark = false; DeleteBookmark(key); } } } contentProfile.ValidateBookmark_ORemovedList = deletedList; } catch (BaseException srvExp) { Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_ValidateWordBookmarkError); newSrvExp.Errors.Add(srvExp); throw newSrvExp; } catch (Exception ex) { ServiceException srvExp = new ServiceException(ErrorCode.ipe_ValidateWordBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_ValidateWordBookmarkError, ex.Message), ex.StackTrace); throw srvExp; } }
public XslGenerator(InternalBookmark ibookmark, string htmlFileName) { _isAddSection = Wkl.MainCtrl.CommonCtrl.CommonProfile.IsAddSection; _htmlFileName = htmlFileName; _ibm = ibookmark; _foreach = new List <ForeachItem>(); }
/// <summary> /// Delete internal bookmark that not exist in word bookmark /// </summary> public void ValidateInternalBookmarkCollection(string key) { // 1. Get internal bookmark object // 2. Get all key of internal bookmark item that not exist in word bookmark collection // 3. Remove all internal bookmark item has key in key collection above try { IntegrationServiceProfile integrationProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).IntegrationService; List <string> removed = new List <string>(); InternalBookmark iBms = null; List <string> removeKeys = new List <string>(); string srvKey = string.Empty; ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey); GetInternalBookmark(srvKey); iBms = srvPro.Ibm; Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey); foreach (InternalBookmarkDomain ibmDomain in iBms.InternalBookmarkDomains) { ValidateInternalBookmarkDomain(ibmDomain, integrationProfile.ValidateInternalBM_IListBM, ref removed, ref removeKeys); } if (integrationProfile.ValidateInternalBM_IIsUpdate) { srvKey = string.Empty; srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey); foreach (string bmKey in removeKeys) { srvPro.WbmKey = bmKey; RemoveInternalBookmark(srvKey); } Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey); } integrationProfile.ValidateInternalBM_OListError = removed; } catch (BaseException srvExp) { Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_ValidateIbmsError); newSrvExp.Errors.Add(srvExp); throw newSrvExp; } catch (Exception ex) { ServiceException srvExp = new ServiceException(ErrorCode.ipe_ValidateIbmsError, MessageUtils.Expand(Properties.Resources.ipe_ValidateIbmsError, ex.Message), ex.StackTrace); throw srvExp; } }
private void BindData() { _isOK = false; TemplateInfo templateInfo = WKL.DataController.MainController.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo; InternalBookmark ibm = templateInfo.InternalBookmark; BindComboBoxColor(cboDSCColor, ibm.DocumentSpecificColor); foreach (InternalBookmarkDomain ibmDomain in ibm.InternalBookmarkDomains) { AddDomain(ibmDomain.DomainName, ibmDomain.Color); } }
public override void GenOsql(DomainInfo domain, InternalBookmark ibm, int domainIndex) { GenOsqlParamInfo paramInfo = new GenOsqlParamInfo(); paramInfo.DomainInfo = domain; paramInfo.IbmDomain = ibm.GetInternalBookmarkDomain(domain.DSDomainData.Name); paramInfo.IndexOfDomain = domainIndex; GenOsql(ref paramInfo); paramInfo.OsqlXmlItem.DatabaseType = 2; OsqlXmlItem = paramInfo.OsqlXmlItem; UpdateChecksumInfo(ref paramInfo, OracleQueryConstants.DicSelectClauseParamName, PdxDbTypes.ipx_oracle); }
private string GetPdeDataType(string key, InternalBookmark ibm) { if (ibm == null || string.IsNullOrWhiteSpace(key)) { return(string.Empty); } InternalBookmarkItem ibmItem = ibm.GetInternalBookmarkItem(key); if (ibmItem == null) { return(string.Empty); } return(MarkupUtilities.SqlDbType2XsdDataType(ibmItem.DataType)); }
private bool IsMatchBetweenInternalAndWord(ref List <string> message, bool isUpdate, string templateName) { try { // update word bm (remove bm exist in word but not exist in internal) InternalBookmark interBm = Wkl.MainCtrl.CommonCtrl.GetTemplateInfo(templateName).InternalBookmark; string serviceKey; //Add to WKL ServicesProfile serviceProfile = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out serviceKey); ContentServiceProfile contentProfile = serviceProfile.ContentService; contentProfile.ValidateBookmark_IIsUpdate = isUpdate; contentProfile.ValidateBookmark_ITemplateName = templateName; mainManager.MainService.BookmarkService.ValidateBookmarkCollection(serviceKey); message.AddRange(contentProfile.ValidateBookmark_ORemovedList); // update internal bookmark (remove bm exist in internal but not exist in word) mainManager.MainService.BookmarkService.GetBookmarkCollection(serviceKey); IntegrationServiceProfile integrationPro = serviceProfile.IntegrationService; integrationPro.ValidateInternalBM_IListBM = contentProfile.GetBookmarks_OListBM; integrationPro.ValidateInternalBM_IIsUpdate = isUpdate; mainManager.MainService.PropertyService.ValidateInternalBookmarkCollection(serviceKey); message.AddRange(integrationPro.ValidateInternalBM_OListError); //Remove objects in Wkl Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(serviceKey); return(contentProfile.ValidateBookmark_ORemovedList.Count == 0 && integrationPro.ValidateInternalBM_OListError.Count == 0); } catch (BaseException baseExp) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_CheckIbmAndWbmError); mgrExp.Errors.Add(baseExp); throw mgrExp; } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_CheckIbmAndWbmError, MessageUtils.Expand(Properties.Resources.ipe_CheckIbmAndWbmError, ex.Message), ex.StackTrace); throw mgrExp; } }
public void GenOsql(List <DomainInfo> domains, InternalBookmark ibm) { OsqlString = string.Empty; Ibm = ibm.Clone(); ChecksumInfoItems = new List <ChecksumInfoItem>(); OsqlXml = new OsqlXml(); int domainIndex = 1; foreach (DomainInfo domain in domains) { BaseGenOsqlHelper genHelper = null; ProntoDoc.Framework.CoreObject.AppDbTypes dbType = GetDatabaseType(domain); switch (dbType) { case ProntoDoc.Framework.CoreObject.AppDbTypes.Oracle: genHelper = new GenOsqlOracleHelper(); break; case ProntoDoc.Framework.CoreObject.AppDbTypes.Sql: genHelper = new GenOsqlSql08Helper(); break; default: break; } if (genHelper != null) { genHelper.GenOsql(domain, Ibm, domainIndex); // genHelper.ChecksumInfoItem.DocumentSpecificColor = ibm.DocumentSpecificColor; // replace for BaseGenOsqlHelper ChecksumInfoItems.Add(genHelper.ChecksumInfoItem); OsqlXml.OsqlXmlItems.Add(genHelper.OsqlXmlItem); } domainIndex++; } OsqlString = ProntoDoc.Framework.Utils.ObjectSerializeHelper.SerializeToString <OsqlXml>(OsqlXml); }
public PartBookmark(string name, InternalBookmark ibookmark) { InternalBookmarkItem bookmark = ibookmark.GetInternalBookmarkItem(name); if (bookmark != null) { BizName = bookmark.OrginalBizName; Key = name; } else { PdeDataTagInfo pdeTag = ibookmark.GetPdeDataTagInfo(name); if (pdeTag != null) { BizName = pdeTag.BookmarkName; Key = name; } } InitializeBookmark(); }
public virtual void GenOsql(DomainInfo domain, InternalBookmark ibm, int domainIndex) { }
private PdeExports GetExportedData(Excel.Workbook wExcel) { if (wExcel == null) { return(null); } InternalBookmark ibm = GetPdeInternalBookmark(wExcel); PdeExports export = new PdeExports(); DomainExportItem expDomain = new DomainExportItem(); expDomain.DomainName = "DomainName"; #region get tags foreach (Excel.Name name in wExcel.Names) { ExportItem expItem = new ExportItem(); expItem.IsUsed = false; // default is not used bool isAdd = false; string strName = name.Name; if (string.IsNullOrWhiteSpace(strName)) { continue; } // update field if (strName.EndsWith(BaseProntoMarkup.KeySelect)) { expItem.MapType = MapType.SingleCell; expItem.DataType = GetPdeDataType(strName, ibm); isAdd = true; } // update table if (strName.EndsWith(BaseProntoMarkup.KeyTable)) { expItem.MapType = MapType.Table; Excel.Range range = name.RefersToRange; Excel.ListObject listColumn = range.ListObject; expItem.Columns = new System.Collections.Generic.List <ColumnExportItem>(); // update columns foreach (Excel.ListColumn lstCol in listColumn.ListColumns) { ColumnExportItem expColumn = new ColumnExportItem(); expColumn.ColumnName = lstCol.Name; expColumn.ExcelName = lstCol.Range.Name.Name; expColumn.TreeNodeName = expColumn.ExcelName; expColumn.ExcelAddress = lstCol.Range.AddressLocal; expColumn.ParentName = strName; expColumn.DomainName = expDomain.DomainName; expColumn.IsUsed = false; expColumn.DataType = GetPdeDataType(expColumn.ExcelName, ibm); expItem.Columns.Add(expColumn); } isAdd = true; } if (isAdd) { expItem.ExcelSheetName = name.RefersToRange.Parent.Name; expItem.ExcelName = strName; expItem.ExcelAddress = name.RefersToRange.AddressLocal; expItem.TreeNodeName = expItem.ExcelName; expItem.ParentName = expDomain.DomainName; expDomain.Items.Add(expItem); } } #endregion #region get charts foreach (Excel.Worksheet sheet in wExcel.Sheets) { Excel.ChartObjects charts = sheet.ChartObjects(Type.Missing); if (charts != null) { foreach (Excel.ChartObject chart in charts) { ExportItem exportItem = new ExportItem(); exportItem.MapType = MapType.Chart; exportItem.ExcelName = chart.Name; exportItem.TreeNodeName = exportItem.ExcelName; exportItem.ParentName = expDomain.DomainName; exportItem.ExcelSheetName = sheet.Name; exportItem.Chart = new ExportItemChart(); exportItem.Chart.Name = chart.Name; string filePath = AssetManager.FileAdapter.GenRandomFilePath(ChartExtension); chart.Chart.Export(filePath, "JPG"); exportItem.Chart.Content = ProntoDoc.Framework.Utils.FileHelper.FileToBase64(filePath); System.IO.File.Delete(filePath); expDomain.Items.Add(exportItem); } } } #endregion export.Items = new System.Collections.Generic.List <DomainExportItem>(); export.Items.Add(expDomain); return(export); }
public void ValidateDataTagPosition(string key) { ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.GetProfile(key); GetForeachTagsBoundCurrentPosEvent(key); srvPro.ContentService.IsValid = true; InternalBookmark ibm = Wkl.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo.InternalBookmark; //DomainInfo domainInfo = Wkl.MainCtrl.CommonCtrl.GetDomainInfo(srvPro.ContentService.DomainName); //Dictionary<int, int> tableIndexes = new Dictionary<int, int>(); foreach (string wbmName in srvPro.ContentService.DicBookmarks.Keys) { string startName = string.Empty; string endName = string.Empty; if (wbmName.EndsWith(ProntoMarkup.KeyStartForeach)) { startName = wbmName; endName = wbmName.Replace(ProntoMarkup.KeyStartForeach, ProntoMarkup.KeyEndForeach); } else if (wbmName.EndsWith(ProntoMarkup.KeyEndForeach)) { endName = wbmName; startName = wbmName.Replace(ProntoMarkup.KeyEndForeach, ProntoMarkup.KeyStartForeach); } //else //{ // InternalBookmarkItem ibmItem = ibm.GetInternalBookmarkItem(wbmName); // if (ibmItem != null) // { // int tableIndex = Math.Max(0, ibmItem.TableIndex); // if (!tableIndexes.ContainsKey(tableIndex)) // tableIndexes.Add(tableIndex, tableIndex); // } //} #region check: all data tags can inside only Domain if (srvPro.ContentService.DicBookmarks.ContainsKey(startName) && srvPro.ContentService.DicBookmarks.ContainsKey(endName)) { InternalBookmarkDomain ibmDomain = ibm.GetInternalBookmarkDomainByItemKey(startName); if (ibmDomain.DomainName != srvPro.ContentService.DomainName) { srvPro.ContentService.IsValid = false; srvPro.Message = "Only allow data tag of [" + ibmDomain.DomainName + "] in this foreach tag."; return; } #region get order by //Dictionary<string, OrderByType> sorteds = MarkupUtilities.GetOldOrderBy(srvPro.ContentService.DicBookmarks[startName].Range.Text, false); //if (sorteds.Count > 0) //{ // foreach (string bizName in sorteds.Keys) // { // string originalBizName = domainInfo.GetUdfSortedBizName(bizName); // ProntoDoc.Framework.CoreObject.DataSegment.DSTreeView field = domainInfo.GetField(originalBizName); // if (field != null) // { // int tableIndex = field.TableIndex; // tableIndex = Math.Max(0, tableIndex); // if (!tableIndexes.ContainsKey(tableIndex)) // tableIndexes.Add(tableIndex, tableIndex); // } // } //} #endregion } #endregion } #region check: all data tags can inside only Domain //int pathCount = 0; //if (tableIndexes.Count > 0) //{ // foreach (var dsRelationRow in domainInfo.DSDomainData.TableRelations.Rows.Items) // { // if ("WhereClause".Equals(dsRelationRow.Name, StringComparison.OrdinalIgnoreCase)) // continue; // string relations = ProntoDoc.Framework.Utils.BitHelper.ToBinaryFormat(dsRelationRow.Data, true); // relations = BaseMarkupUtilities.ReverseString(relations); // } //} #endregion }
/// <summary> /// Get bookmark collection in word /// </summary> /// <returns>Dictionary with key is bookmark name and value is bookmark text</returns> public void GetDistinctBookmarks(string key) { //1.Get All Bookmarks //2.Do not add EndIf, EndForEach bookmark //3.If a bookmark is existed in List, increase number entry //4.Else insert to list. try { ContentServiceProfile contentProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).ContentService; List <BookmarkItem> listBookmarks = new List <BookmarkItem>(); Bookmarks bms = Wkl.MainCtrl.CommonCtrl.CommonProfile.Bookmarks; for (int j = 1; j <= bms.Count; j++) { Bookmark bookmark = bms[j]; //2.Do not add EndIf, EndForEach bookmark if (!MarkupUtilities.GetRangeText(bookmark.Range).Contains(Constants.BookMarkControl.EndIfTag)) { BookmarkItem item = new BookmarkItem(bookmark.Name, string.Empty, string.Empty, bookmark); if (bookmark.Name.Contains("Image")) { GetInternalBookmark(key); InternalBookmark internalBM = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).Ibm; foreach (InternalBookmarkDomain ibmDomain in internalBM.InternalBookmarkDomains) { foreach (InternalBookmarkItem internalItem in ibmDomain.InternalBookmarkItems) { if (internalItem.Key.CompareTo(bookmark.Name) == 0) { item.Value = internalItem.BizName; item.DisplayName = SplitValue(internalItem.BizName); } } } } else { item.Value = MarkupUtilities.GetRangeText(bookmark.Range); item.DisplayName = SplitValue(item.Value); } if (listBookmarks.Count == 0) { listBookmarks.Add(item); } else { int n = -1; bool existed = false; for (int i = 0; i < listBookmarks.Count; i++) { n += 1; if (listBookmarks[i].Value.Equals(item.Value)) { existed = true; break; } } //3. if (existed) { listBookmarks[n].NumberEntry += 1; listBookmarks[n].Items.Add(bookmark); } else//4. { listBookmarks.Add(item); } } } } contentProfile.GetDistinctBM_OListBM = listBookmarks; } catch (BaseException srvExp) { Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_GetDistinctBookmarkError); newSrvExp.Errors.Add(srvExp); throw newSrvExp; } catch (Exception ex) { ServiceException srvExp = new ServiceException(ErrorCode.ipe_GetDistinctBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_GetDistinctBookmarkError, ex.Message), ex.StackTrace); throw srvExp; } }
/// <summary> /// Highlight all word bookmark that not exist on data domain /// </summary> /// <param name="iBms"></param> public void ValidateBookmarkCollectionWithDomain(string key) { try { bool isHighlight = false; List <string> unMatched = new List <string>(); //Get Bookmark Collection then put to WKL GetBookmarkCollection(key); ContentServiceProfile contentProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).ContentService; Dictionary <string, string> wBm = contentProfile.GetBookmarks_OListBM; //Get Internal Bookmark TemplateInfo templateInfo = Wkl.MainCtrl.CommonCtrl.GetTemplateInfo( contentProfile.ValidateBookmark_ITemplateName); InternalBookmark interBm = templateInfo.InternalBookmark; //Get Domain Data foreach (string domainName in templateInfo.DomainNames) { DomainInfo domainInfo = Wkl.MainCtrl.CommonCtrl.GetDomainInfo(domainName); if (domainInfo != null) { InternalBookmarkDomain ibmDomain = interBm.GetInternalBookmarkDomain(domainName); foreach (InternalBookmarkItem item in ibmDomain.InternalBookmarkItems) { if (!MarkupUtilities.IsExistOnDomain(item, domainInfo.Fields, true)) { if (wBm.ContainsKey(item.Key) && wBm[item.Key] == item.BizName) { contentProfile.HighlightBookmarkName = item.Key; unMatched.Add(item.BizName); HighlightBookmark(key); isHighlight = true; } } } } else { isHighlight = true; } } contentProfile.UnMatchedFields = unMatched; contentProfile.Result = !isHighlight; } catch (BaseException srvExp) { Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_ValidateWordBookmarkWithDomainError); newSrvExp.Errors.Add(srvExp); throw newSrvExp; } catch (Exception ex) { ServiceException srvExp = new ServiceException(ErrorCode.ipe_ValidateWordBookmarkWithDomainError, MessageUtils.Expand(Properties.Resources.ipe_ValidateWordBookmarkWithDomainError, ex.Message), ex.StackTrace); throw srvExp; } }