private bool IsCorrectWordStruct(string key, Document Doc, ref List <string> message) { try { Wkl.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo.XmlContent = GetWordBodyOuterXml(Doc); mainManager.MainService.TemplateService.CheckWordBodyStructure(); foreach (XmlNode node in Wkl.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo.DeletedTags) { message.Add(node.OuterXml); } bool isError = (Wkl.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo.DeletedTags.Count == 0); return(isError); } catch (BaseException baseEx) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_CheckWordStructError); mgrExp.Errors.Add(baseEx); throw mgrExp; } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_CheckWordStructError, MessageUtils.Expand(Properties.Resources.ipe_CheckWordStructError, ex.Message), ex.StackTrace); throw mgrExp; } }
/// <summary> /// update unique name for all fields in UscItem before add to internal bookmark when tagging /// ngocbv: need to confirm with Mery /// </summary> /// <param name="item"></param> /// <param name="domainName"></param> public void UpdateUniqueNameForUscItem(string key) { try { IntegrationServiceProfile inteProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).IntegrationService; if (inteProfile.UscItem != null && inteProfile.UscItem.Fields != null) { DomainInfo domainInfo = Wkl.MainCtrl.CommonCtrl.GetDomainInfo(inteProfile.UscItem.DomainName); foreach (USCItem field in inteProfile.UscItem.Fields) { if (domainInfo.Fields.ContainsKey(field.BusinessName)) { field.UniqueName = domainInfo.Fields[field.BusinessName].UniqueName; } } } } catch (BaseException srvExp) { Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_UpdateUSCItemError); newSrvExp.Errors.Add(srvExp); throw newSrvExp; } catch (Exception ex) { ServiceException srvExp = new ServiceException(ErrorCode.ipe_UpdateUSCItemError, MessageUtils.Expand(Properties.Resources.ipe_UpdateUSCItemError, ex.Message), ex.StackTrace); throw srvExp; } }
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> /// update table index and relation for internal bookmark /// </summary> /// <param name="key"></param> public void UpdateInternalBookmark(string key) { try { TemplateInfo templateInfo = Wkl.MainCtrl.CommonCtrl.GetTemplateInfo(key); foreach (string domainName in templateInfo.DomainNames) { DomainInfo domainInfo = Wkl.MainCtrl.CommonCtrl.GetDomainInfo(domainName); InternalBookmarkDomain ibmDomain = templateInfo.InternalBookmark.GetInternalBookmarkDomain(domainName); foreach (InternalBookmarkItem iBmItem in ibmDomain.InternalBookmarkItems) { if (domainInfo.Fields.ContainsKey(iBmItem.BizName)) { iBmItem.TableIndex = domainInfo.Fields[iBmItem.BizName].TableIndex; iBmItem.Relation = domainInfo.Fields[iBmItem.BizName].Relation; iBmItem.DomainName = domainName; } } } } catch (BaseException srvExp) { Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_UpdateIbmItemError); newSrvExp.Errors.Add(srvExp); throw newSrvExp; } catch (Exception ex) { ServiceException srvExp = new ServiceException(ErrorCode.ipe_UpdateIbmItemError, MessageUtils.Expand(Properties.Resources.ipe_UpdateIbmItemError, ex.Message), ex.StackTrace); throw srvExp; } }
private void HighlightNotMatchFields(DomainMatch domainMatch) { try { foreach (DomainMatchItem matchItem in domainMatch.DomainMatchItems.Values) { foreach (string wBmValue in matchItem.NotMatchBizs) { foreach (Bookmark wBm in Wkl.MainCtrl.CommonCtrl.CommonProfile.ActiveDoc.Bookmarks) { if (MarkupUtilities.GetRangeText(wBm.Range) == wBmValue) { wBm.Range.HighlightColorIndex = ProntoMarkup.BackgroundHighLight; } } } } } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_HighlightBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_HighlightBookmarkError, ex.Message), ex.StackTrace); throw mgrExp; } }
private bool IsMatchWithDataSegment(string docFullName, ref List <string> message) { try { // compare with data domain. if not exist in datadomain then highlight string key; ContentServiceProfile contentProfile = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out key).ContentService; contentProfile.ValidateBookmark_ITemplateName = docFullName; mainManager.MainService.BookmarkService.ValidateBookmarkCollectionWithDomain(key); bool result = (bool)contentProfile.Result; message.AddRange(contentProfile.UnMatchedFields); Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(key); return(result); } catch (BaseException baseExp) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_CheckWbmWithDatasegment); mgrExp.Errors.Add(baseExp); throw mgrExp; } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_CheckWbmWithDatasegment, MessageUtils.Expand(Properties.Resources.ipe_CheckWbmWithDatasegment, ex.Message), ex.StackTrace); throw mgrExp; } }
/// <summary> /// Save internal bookmark object into document /// </summary> public void SaveInternalBookmark() { // 1. Get xml content // 2. Save custom xml part // 3. Save custom xml part id try { string content = string.Empty; string id = string.Empty; if (CurrentTemplateInfo.InternalBookmark != null) { content = ObjectSerializeHelper.SerializeToString <InternalBookmark>(CurrentTemplateInfo.InternalBookmark); } else { content = ObjectSerializeHelper.SerializeToString <InternalBookmark>(new Pdw.Core.InternalBookmark()); } XmlObject xmlObject = new XmlObject(content, ContentType.InternalBookmark); content = ObjectSerializeHelper.SerializeToString <XmlObject>(xmlObject); id = GetCustomPartId(); id = AddCustomXmlPart(content, id); AddCustomProperty(Pdw.Core.ProntoMarkup.InternalBMCustomXmlPartId, id); } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_SaveInternalBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_SaveInternalBookmarkError, ex.Message), ex.StackTrace); throw mgrExp; } }
public void RemoveBookmark(string key) { try { ManagerProfile mgrPro = Wkl.MainCtrl.ManagerCtrl.GetProfile(key); foreach (string bmKey in mgrPro.WbmKeys) { if (_doc.Bookmarks.Exists(bmKey)) { _doc.Bookmarks[bmKey].Range.HighlightColorIndex = ProntoMarkup.BackgroundUnHighLight; _doc.Bookmarks[bmKey].Delete(); } iBm.RemoveInternalBookmarkItem(bmKey); } } catch (BaseException baseExp) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_RemoveBookmarkError); mgrExp.Errors.Add(baseExp); throw mgrExp; } catch (System.Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_RemoveBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_DeleteBookmarkError, ex.Message), ex.StackTrace); throw mgrExp; } }
public static void LoadDomainData(string domainName) { try { //If not existed in Domain WKL if (!Wkl.MainCtrl.CommonCtrl.CommonProfile.DomainInfos.ContainsKey(domainName)) { DomainInfo domainInfo = Wkl.MainCtrl.CommonCtrl.CreateDomainInfo(domainName); DSDomain domainData = MemorySegment.GetDomain(AssetManager.FileAdapter.DataSegmentDllPath, domainName); domainInfo.DSDomainData = domainData; } } catch (BaseException srvExp) { Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_LoadDomainDataError); newSrvExp.Errors.Add(srvExp); throw newSrvExp; } catch (Exception ex) { Services.ServiceException srvExp = new Services.ServiceException(ErrorCode.ipe_LoadDomainDataError, MessageUtils.Expand(Properties.Resources.ipe_LoadDomainDataError, ex.Message), ex.StackTrace); throw srvExp; } }
public void btnForEach_Click(Office.IRibbonControl control) { try { string bookmarkKey = DateTime.Now.ToString(ProntoMarkup.BookmarkKeyFormat); InternalBookmarkItem bm = new InternalBookmarkItem(bookmarkKey, ProntoMarkup.TagContentSForeach, ProntoMarkup.TagContentEForeach, DSIconType.ForEach.ToString()); bm.Type = XsltType.Foreach; AddForeachBookmark(bm); } catch (BaseException baseExp) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_AddForechTagError); mgrExp.Errors.Add(baseExp); LogUtils.LogManagerError(mgrExp); } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_AddForechTagError, MessageUtils.Expand(Properties.Resources.ipe_AddForechTagError, ex.Message), ex.StackTrace); throw mgrExp; } }
private bool CheckExistsField(List <SqlVariableName> listExpressFields) { if (listExpressFields == null || listExpressFields.Count <= 0) { _messageContent = MessageUtils.Expand(Properties.Resources.ipm_M001, Properties.Resources.ipe_M009); return(true); } foreach (SqlVariableName varName in listExpressFields) { if (!IsExistNameInDomain(_listFields, varName)) { _messageContent = MessageUtils.Expand(Properties.Resources.ipm_M001, Properties.Resources.ipe_M010, varName.Name); if (FieldsInExpression != null) { FieldsInExpression = null; } return(false); } else { FieldsInExpression.Add(_listFields[TrimBracesSymbol(varName.Name).ToLower()]); } } return(true); }
/// <summary> /// Delete all bookmarks with same value /// </summary> /// <param name="bmItem"></param> /// <returns></returns> public bool DeleteAllBookmarks(BookmarkItem bmItem) { try { for (int i = 0; i < bmItem.Items.Count; i++) { DeleteBookmarkWithPair(bmItem.Items[i]); } return(true); } catch (BaseException srvExp) { Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_DeleteBookmarkError); newSrvExp.Errors.Add(srvExp); throw newSrvExp; } catch (Exception ex) { ServiceException srvExp = new ServiceException(ErrorCode.ipe_DeleteBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_DeleteBookmarkError, ex.Message), ex.StackTrace); return(false); throw srvExp; } }
/// <summary> /// Delete a bookmark with name in current document /// </summary> /// <param name="name">Name of bookmark</param> /// <returns></returns> public bool DeleteBookmark(string key) { ManagerProfile mgrProfile = Wkl.MainCtrl.ManagerCtrl.GetProfile(key); try { foreach (Bookmark bookmark in Wkl.MainCtrl.CommonCtrl.CommonProfile.Bookmarks) { if (bookmark.Name.Equals(mgrProfile.DeletedBookmarkName)) { DeleteBookmark(bookmark, mgrProfile.DeleteWholeBookmark); break; } } return(true); } catch (System.Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_DeleteBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_DeleteBookmarkError, ex.Message), ex.StackTrace); throw mgrExp; } }
public void HighlightWordBookmark(string key) { try { ContentServiceProfile contentProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).ContentService; string keyService; ServicesProfile serviceProfile = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out keyService); if (!string.IsNullOrEmpty(contentProfile.HighlightBookmark_IBMName)) { HighlightBookmark(keyService); } } catch (BaseException srvExp) { Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_HighlightBookmarkError); newSrvExp.Errors.Add(srvExp); throw newSrvExp; } catch (Exception ex) { ServiceException srvExp = new ServiceException(ErrorCode.ipe_HighlightBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_HighlightBookmarkError, ex.Message, ex.StackTrace), ex.StackTrace); throw srvExp; } }
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; } }
/// <summary> /// make sure internal bookmark and word bookmark are match /// </summary> /// <returns></returns> private bool ValidateBookmark(List <string> highlightedBmKeys, WdColorIndex color) { try { // update word bm List <string> removedWord = ValidateWordBookmark(color); highlightedBmKeys.AddRange(removedWord); // update internal bookmark (remove bm exist in internal but not exist in word) ValidateInternalBookmark(); return(removedWord.Count == 0); } catch (BaseException baseExp) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_ValidateBookmarkError); mgrExp.Errors.Add(baseExp); throw mgrExp; } catch (System.Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_ValidateBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_ValidateWordBookmarkWithDomainError, ex.Message), ex.StackTrace); throw mgrExp; } }
/// <summary> /// Get bookmark list order by position (top , left -> bottom, right) in document /// </summary> /// <returns></returns> public List <Bookmark> GetBookmarksOrderByPosition() { try { List <Bookmark> bms = new List <Bookmark>(); foreach (Bookmark bm in CommonProfile.Bookmarks) { bms.Add(bm); } bms.Sort(delegate(Bookmark bm1, Bookmark bm2) { return(bm1.Start.CompareTo(bm2.Start)); }); return(bms); } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_GetWordBookmarkByPositionError, MessageUtils.Expand(Properties.Resources.ipe_GetWordBookmarkByPositionError, ex.Message), ex.StackTrace); throw mgrExp; } }
/// <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; } }
/// <summary> /// Save a document /// </summary> /// <param name="Doc"></param> /// <param name="SaveAsUI"></param> /// <param name="Cancel"></param> public void SaveDocument(Document Doc, ref bool SaveAsUI, ref bool Cancel) { TemplateInfo tempInfo = Wkl.MainCtrl.CommonCtrl.GetTemplateInfo(Doc.FullName); if (tempInfo == null) { return; } if (!tempInfo.IsSaving) { string mgrKey = string.Empty; string filePath = Doc.FullName; bool isAutoSaving = tempInfo.IsAutoSave; ManagerProfile mgrPro = Wkl.MainCtrl.ManagerCtrl.CreateProfile(out mgrKey); mgrPro.TemplateType = MarkupUtilities.GetTemplateType(filePath); ContextValidator validator = new ContextValidator(Doc); validator.ValidateBeforeSave(mgrKey); tempInfo.IsAutoSave = true; Cancel = true; SaveAsUI = false; if (!mgrPro.IsCorrect) // not AutoSave then we need to validate, check file path and prevent save event of word object { if (!isAutoSaving) { tempInfo.IsSaving = false; if (mgrPro.WbmKeys.Count == 0) { ShowPopupMessage(MessageUtils.Expand(Properties.Resources.ipe_NotIsProntoDoc, Properties.Resources.ipe_ValidateMessage)); } else { mgrPro.WDoc = Doc; Hcl.SaveMessageDialog saveNotify = new Hcl.SaveMessageDialog(mgrKey); saveNotify.Show(); } } UpdateStatus(MessageUtils.Expand(Properties.Resources.ipm_NotIsProntoDoc, Properties.Resources.ipe_NotSaveMessage)); } else { if (!isAutoSaving && !File.Exists(filePath)) { filePath = GetNewFileName(); } Save(Doc, filePath); SaveUserData(); } Wkl.MainCtrl.ManagerCtrl.RemoveDataObject(mgrKey); } }
/// <summary> /// validate bookmark position (open tag and close tag must be have same node level) /// </summary> /// <param name="Doc"></param> /// <returns></returns> private bool ValidateData(List <string> highlightedBmKeys, WdColorIndex color) { try { XmlDocument xDoc = new XmlDocument(); string abc = _doc.WordOpenXML; xDoc.LoadXml(_doc.WordOpenXML); foreach (Bookmark bm in _doc.Bookmarks) { string startBmName = bm.Name; string endBmName = string.Empty; if (startBmName.EndsWith(ProntoMarkup.KeyStartForeach)) { endBmName = bm.Name.Replace(ProntoMarkup.KeyStartForeach, ProntoMarkup.KeyEndForeach); } else if (startBmName.EndsWith(ProntoMarkup.KeyStartIf)) { endBmName = bm.Name.Replace(ProntoMarkup.KeyStartIf, ProntoMarkup.KeyEndIf); } if (!string.IsNullOrEmpty(endBmName)) { if (!ValidateBookmark(xDoc, startBmName, endBmName)) { highlightedBmKeys.Add(startBmName); highlightedBmKeys.Add(endBmName); HighLightBookmark(startBmName, color); HighLightBookmark(endBmName, color); return(false); } } } return(true); } catch (BaseException baseExp) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_ValidateDataError); mgrExp.Errors.Add(baseExp); throw mgrExp; } catch (System.Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_ValidateDataError, MessageUtils.Expand(Properties.Resources.ipe_ValidateWordBookmarkError, ex.Message), ex.StackTrace); throw mgrExp; } }
/// <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; } }
/// <summary> /// show message in the status bar of word document /// </summary> /// <param name="message"></param> public void UpdateStatus(string message) { try { Wkl.MainCtrl.CommonCtrl.CommonProfile.App.StatusBar = message; } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_UpdateStatusBarError, MessageUtils.Expand(Properties.Resources.ipe_UpdateStatusBarError, ex.Message), ex.StackTrace); throw mgrExp; } }
public ChecksumInfo GetChecksum() { try { string srvKey = string.Empty; ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey); GetPdwInformation(srvKey); Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey); List <XmlObject> customXmls = srvPro.XmlObjects; ChecksumInfo checksum = null; string osql = string.Empty; foreach (XmlObject xmlObject in customXmls) { if (xmlObject == null) { continue; } if (xmlObject.ContentType == ContentType.Checksum) { checksum = ObjectSerializeHelper.Deserialize <ChecksumInfo>(xmlObject.Content); checksum.InternalBookmark = GetInternalBookmarkString(); checksum.Osql = osql; } else if (xmlObject.ContentType == ContentType.Osql) { osql = xmlObject.Content; if (checksum != null) { checksum.Osql = osql; } } } return(checksum != null ? checksum : new ChecksumInfo()); } catch (BaseException srvExp) { Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_GetChecksumError); newSrvExp.Errors.Add(srvExp); throw newSrvExp; } catch (Exception ex) { ServiceException srvExp = new ServiceException(ErrorCode.ipe_GetChecksumError, MessageUtils.Expand(Properties.Resources.ipe_GetChecksumError, ex.Message), ex.StackTrace); throw srvExp; } }
/// <summary> /// Validate Internal Bookmark is match with any Domain. Key is full name of document /// </summary> /// <param name="fullDocName"></param> public void IsInternalBMMatchWithDomain(string key) { //1.Get InternalBM //2.Get Checksum information //3.Load Data from datasegment. //4.Check match try { IntegrationServiceProfile integrationProfile = Wkl.MainCtrl.ServiceCtrl.GetProfile(key).IntegrationService; TemplateInfo templateInfo = Wkl.MainCtrl.CommonCtrl.GetTemplateInfo(integrationProfile.TemplateFileName); string srvKey = string.Empty; ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey); GetInternalBookmark(srvKey); templateInfo.InternalBookmark = srvPro.Ibm; templateInfo.UpdateDomainNames(); templateInfo.PdeContent = srvPro.PdeContent; Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey); //Get Checksum Info. ChecksumInfo checksum = GetChecksum(); integrationProfile.CheckMatchWithDomain_OListMatch = new List <DomainMatch>(); integrationProfile.Result = true; foreach (InternalBookmarkDomain ibmDomain in templateInfo.InternalBookmark.InternalBookmarkDomains) { DomainMatchItem domainMatchItem = IsMatchWithDataSegment(ibmDomain, ibmDomain.DomainName); if (domainMatchItem != null && (!domainMatchItem.IsMatch || !domainMatchItem.IsMatchRelationOn)) // not match { DomainMatch domainMatch = FindTheNearestDomain(ibmDomain, domainMatchItem, ibmDomain.DomainName); integrationProfile.CheckMatchWithDomain_OListMatch.Add(domainMatch); integrationProfile.Result = false; } } } catch (BaseException srvExp) { Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_ValidateIbmWithDomainError); newSrvExp.Errors.Add(srvExp); throw newSrvExp; } catch (Exception ex) { ServiceException srvExp = new ServiceException(ErrorCode.ipe_ValidateIbmWithDomainError, MessageUtils.Expand(Properties.Resources.ipe_ValidateIbmWithDomainError, ex.Message), ex.StackTrace); throw srvExp; } }
/// <summary> /// save pdw information into document /// save document -> input pdw information -> re-save document /// </summary> /// <param name="filePath"></param> /// <param name="Doc"></param> /// <param name="isReconstruct"></param> private PdwInfo SavePdwInfo(string filePath, Document Doc, bool isReconstruct) { try { string srvKey = string.Empty; ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey); // get pdw information string fileExt = Path.GetExtension(filePath); TemplateType templateType = GetTemplateType(fileExt); if (!isReconstruct && templateType != TemplateType.None) { string oldKey = Doc.FullName; Doc.SaveAs(filePath); Wkl.MainCtrl.CommonCtrl.ChangeTemplateInfoKey(oldKey, Doc.FullName); srvPro.TemplateType = templateType; srvPro.IsFullDoc = true; } else { srvPro.IsFullDoc = false; srvPro.TemplateType = TemplateType.None; } srvPro.FullDocName = Doc.FullName; mainManager.MainService.PdwGeneratorService.GetPdwInfo(srvKey); // save pdw information mainManager.MainService.PropertyService.SavePdwInformation(srvKey); Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey); return(srvPro.PdwInfo); } catch (BaseException baseExp) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_SavePdwInfoError); mgrExp.Errors.Add(baseExp); throw mgrExp; } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_SavePdwInfoError, MessageUtils.Expand(Properties.Resources.ipe_SaveDocumentError, ex.Message), ex.StackTrace); throw mgrExp; } }
/// <summary> /// Save document as pronto template /// </summary> /// <param name="Doc"></param> /// <param name="filePath"></param> /// <param name="isToFinal">true: Actually Save to file. false: save to temp file to get xsl,...</param> public PdwInfo SaveAsTemplate(Document Doc, string filePath, bool isToFinal = true) { TemplateInfo tempInfo = Wkl.MainCtrl.CommonCtrl.GetTemplateInfo(Doc.FullName); if (tempInfo == null) { return(null); } string mgrKey = string.Empty; ManagerProfile mgrPro = Wkl.MainCtrl.ManagerCtrl.CreateProfile(out mgrKey); mgrPro.TemplateType = MarkupUtilities.GetTemplateType(filePath); ContextValidator validator = new ContextValidator(Doc); validator.ValidateBeforeSave(mgrKey); PdwInfo pdwInfo = null; if (!mgrPro.IsCorrect) { tempInfo.IsSaving = false; if (mgrPro.WbmKeys.Count == 0) { ShowPopupMessage(MessageUtils.Expand(Properties.Resources.ipe_NotIsProntoDoc, Properties.Resources.ipe_ValidateMessage)); } else { mgrPro.WDoc = Doc; Hcl.SaveMessageDialog saveNotify = new Hcl.SaveMessageDialog(mgrKey); saveNotify.Show(); } } else { pdwInfo = Save(Doc, filePath, isToFinal: isToFinal); if (isToFinal) { SaveUserData(); } } Wkl.MainCtrl.ManagerCtrl.RemoveDataObject(mgrKey); return(pdwInfo); }
/// <summary> /// Delete Current Bookmark. /// </summary> /// <param name="bmItem"></param> /// <returns></returns> public bool DeleteOneBookmark(BookmarkItem bmItem) { //1.If selected text is bookmark, delete current bookmark //2.else: delete first bookmark //3. If bookmark is data tag, delete one bookmark only //4. If bookmark is a pair of bookmark, delete both. try { string srvKey = string.Empty; ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey); GetCurrentSelection(srvKey); Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey); Selection selectedText = srvPro.ContentService.WSelection; Bookmark deletedBM; if (selectedText.Text.Trim().Equals(bmItem.Value) && (selectedText.Bookmarks.Count > 0)) { deletedBM = selectedText.Bookmarks[1]; } else { deletedBM = GetFirstBookmark(bmItem); } bmItem.Items.Remove(deletedBM); DeleteBookmarkWithPair(deletedBM); return(true); } catch (BaseException srvExp) { Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_DeleteBookmarkError); newSrvExp.Errors.Add(srvExp); throw newSrvExp; } catch (Exception ex) { ServiceException srvExp = new ServiceException(ErrorCode.ipe_DeleteBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_DeleteBookmarkError, ex.Message), ex.StackTrace); return(false); throw srvExp; } }
public static void GetListDomain() { try { if (Wkl.MainCtrl.CommonCtrl.CommonProfile.Classifiers == null) { Wkl.MainCtrl.CommonCtrl.CommonProfile.Classifiers = new Dictionary <string, Classifer>(); Wkl.MainCtrl.CommonCtrl.CommonProfile.ListDomains = new Dictionary <string, bool>(); Wkl.MainCtrl.CommonCtrl.CommonProfile.DataSegmentInfo = MemorySegment.GetAllDomain(AssetManager.FileAdapter.DataSegmentDllPath); if (Wkl.MainCtrl.CommonCtrl.CommonProfile.DataSegmentInfo != null) { foreach (DSHeaderInfo domain in Wkl.MainCtrl.CommonCtrl.CommonProfile.DataSegmentInfo.DSHeaderInfos) { string classifier = (domain.Classifier == null) ? string.Empty : domain.Classifier; string domainName = domain.Name; if (!Wkl.MainCtrl.CommonCtrl.CommonProfile.Classifiers.ContainsKey(classifier)) { Wkl.MainCtrl.CommonCtrl.CommonProfile.Classifiers.Add(classifier, new Classifer(classifier)); } Wkl.MainCtrl.CommonCtrl.CommonProfile.Classifiers[classifier].DomainNames.Add(domainName); if (!Wkl.MainCtrl.CommonCtrl.CommonProfile.ListDomains.ContainsKey(domainName)) { Wkl.MainCtrl.CommonCtrl.CommonProfile.ListDomains.Add(domainName, domain.IsMultiSection); } } } } } catch (BaseException srvExp) { Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_GetListDomainError); newSrvExp.Errors.Add(srvExp); throw newSrvExp; } catch (Exception ex) { Services.ServiceException srvExp = new Services.ServiceException(ErrorCode.ipe_GetListDomainError, MessageUtils.Expand(Properties.Resources.ipe_GetListDomainError, ex.Message), ex.StackTrace); throw srvExp; } }
public bool IsValid() { if (null == _expData) { _messageContent = MessageUtils.Expand(Properties.Resources.ipm_M001, Properties.Resources.ipe_M007); return(false); } Stack <Token> suffixExpressionStack = new Stack <Token>(); ExpressionProvider expProvider = new ExpressionProvider(); ReturnCode retCode = expProvider.Parser(_expData, ref suffixExpressionStack, ref _messageContent); if (ReturnCode.OK != retCode) { return(false); } // Check existing of operand List <SqlVariableName> lstSqlFieldsAndParams = new List <SqlVariableName>(); lstSqlFieldsAndParams = expProvider.GetListFields(); // Set type for operand before validate SetDataTypeForVarialbe(ref suffixExpressionStack); if ((!CheckExistsField(lstSqlFieldsAndParams))) { return(false); } // Validate expression retCode = expProvider.Validate(suffixExpressionStack, ref _messageContent); if (ReturnCode.OK != retCode) { return(false); } // Expression must condition expression if (SQLTypeName.BOOLEAN != expProvider.ReturnType.Name) { _messageContent = MessageUtils.Expand(Properties.Resources.ipm_M001, Properties.Resources.ipe_M008); return(false); } return(true); }
/// <summary> /// Get internal bookmark object of active document /// </summary> /// <returns></returns> public void GetInternalBookmark(string key) { try { ManagerProfile mgrPro = Wkl.MainCtrl.ManagerCtrl.GetProfile(key); if (CurrentTemplateInfo.InternalBookmark.InternalBookmarkDomains.Count == 0) { string customXmlPartId = GetCustomPartId(); string content = GetCustomXmlPartContent(customXmlPartId); if (string.IsNullOrEmpty(content)) { CurrentTemplateInfo.InternalBookmark = new Core.InternalBookmark(true); return; } XmlObject xmlObject = ObjectSerializeHelper.Deserialize <XmlObject>(content); if (xmlObject == null) { CurrentTemplateInfo.InternalBookmark = new Core.InternalBookmark(true); return; } content = xmlObject.Content; if (!string.IsNullOrEmpty(content)) { CurrentTemplateInfo.InternalBookmark = ObjectSerializeHelper.Deserialize <Pdw.Core.InternalBookmark>(content); } else { CurrentTemplateInfo.InternalBookmark = new Core.InternalBookmark(true); } } mgrPro.Ibm = CurrentTemplateInfo.InternalBookmark; mgrPro.PdeContent = GetPdeContent(); } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_GetInternalBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_GetInternalBookmarkError, ex.Message), ex.StackTrace); throw mgrExp; } }