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> /// 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; } }
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; } }
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; } }
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; } }
/// <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; } }
/// <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; } }
/// <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; } }
public void FileSave(Office.IRibbonControl control, bool Cancel) { try { TemplateInfo templateInfo = WKL.DataController.MainController.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo; if (templateInfo.IsProntoDoc) { templateInfo.IsAutoSave = false; } WKL.DataController.MainController.MainCtrl.CommonCtrl.CommonProfile.ActiveDoc.Save(); } catch (COMException) // prevent user press Ctrl-S and Cancel { } catch (BaseException baseExp) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_SaveDocumentError); mgrExp.Errors.Add(baseExp); LogUtils.LogManagerError(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; } }
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; } }
public string ProcessError(Exception ex, Response response) { ManagerException managerException = new ManagerException(); response.State = ResponseType.Error; response.Message = managerException.ProcessException(ex); return(managerException.ProcessException(ex)); }
/// <summary> /// Initalizes the Manager /// </summary> /// <param name="appPath">Value of Application.StartupPath</param> public Manager(string appPath) { AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", appPath + "\\App.config"); Manager.culture = ConfigurationManager.AppSettings["Language"]; Manager.appPath = appPath; ManagerException.initializeLocalizedErrorMessages(); HandLanguageDetector.initializeHandLanguageDetector(); }
/// <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> /// 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 async Task <Team> Create([FromBody] Team team) { var result = await _teamManager.CreateTeamAsync(User, team); if (result.Succeeded) { await _notificationManager.NotifyTeamInvite(result.Team); } else { throw ManagerException <TeamError> .Create(result); } return(result.Team); }
/// <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> /// Processes the given PokerStars-file. /// </summary> /// <remarks> /// Normaly there should be only 1 Hand per file, since the FileSystemWatcher scans pretty fast. /// But to provide the functionality of scanning smaller old files(less than 10 MB) at once, we scan the whole file here. /// Additionally a file could have more than one hand if a files is beeing processed later on, since the Tasklimitation of the FileSystemWatcher. /// </remarks> public void processFile() { List <String> fileLines = new List <string>(); try { using (FileStream fs = new FileStream(this.sourceFilePath, FileMode.Open, FileAccess.Read, FileShare.None)) { using (StreamReader sr = new StreamReader(fs)) { while (sr.Peek() > -1) { fileLines.Add(sr.ReadLine()); } } } } catch (IOException ioEx) //mostlikely file is in use... try again 10 times and throw an exception then... { int attempts = 0; FileSystemWatcher.files.TryGetValue(this.sourceFilePath, out attempts); attempts++; if (attempts > 10) { Manager.shutdown = true; throw ManagerException.createManagerException(200, new object[1] { sourceFilePath }, ioEx); } else { FileSystemWatcher.files.TryUpdate(this.sourceFilePath, attempts, attempts - 1); Thread.Sleep(100); this.processFile(); return; } } catch (Exception ex) //something bad goes on here for now we shutdown... TODO: better handling that doesn't crash the whole app... { Manager.shutdown = true; throw ex; } this.createHandTasks(fileLines); this.finishTask(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; } }
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 btnChangeFontDesc_Click(Office.IRibbonControl control) { try { ContextManager context = new ContextManager(); _isSmallToBig = context.ChangeFontSize(false); ribbon.Invalidate(); } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_ChangeFontError, MessageUtils.Expand(Properties.Resources.ipe_ChangeFontError, ex.Message), ex.StackTrace); LogUtils.LogManagerError(mgrExp); } }
/// <summary> /// add right panel into document /// </summary> public void AddProntoTaskPane() { try { TemplateInfo templateInfo = this.TemplateInfo; if (templateInfo.RightPanel != null) { CustomTaskPanes.Add(templateInfo.RightPanel.Control, Properties.Resources.ipm_RibbonTitle); } else { ProntoDocMarkup proMarkupCtrl = new ProntoDocMarkup(); // backup width before add int parentWidth = proMarkupCtrl.cboDomain.Parent.Width; int width = proMarkupCtrl.cboDomain.Width; // add to right panel of document templateInfo.RightPanel = CustomTaskPanes.Add(proMarkupCtrl, Properties.Resources.ipm_RibbonTitle); // after add, the width of domain control is reset to 0 then we need restore its. proMarkupCtrl.cboDomain.Parent.Width = parentWidth; proMarkupCtrl.cboDomain.Width = width; templateInfo.RightPanel.Width = 252; templateInfo.RightPanel.Visible = true; templateInfo.RightPanel.VisibleChanged += new EventHandler(ProntoTaskPane_VisibleChanged); if (ActiveDocument != null) { AddOrderContextMenu(); } } SetHeightForProntoDocMarkup(); } catch (BaseException srvExp) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_LoadResourceError); mgrExp.Errors.Add(srvExp); LogUtils.LogManagerError(mgrExp); } }
/// <summary> /// add image into bookmark /// </summary> /// <param name="name">Name (key) of bookmark</param> /// <param name="text">text (value = biz name) of bookmark</param> /// <returns></returns> public void AddImageBookmark(string key) { try { ManagerProfile mgrProfile = Wkl.MainCtrl.ManagerCtrl.GetProfile(key); mgrProfile.DeletedBookmarkName = mgrProfile.WbmKey; DeleteBookmark(key); // 1. get user data folder string filePath = AssetManager.FileAdapter.TemporaryFolderPath; // 2. make image and save into user data folder using (WinForm.Image img = Properties.Resources.ImageHolder) { WriteTextIntoImage(img, mgrProfile.WbmValue); filePath = string.Format("{0}\\{1}{2}.jpg", filePath, mgrProfile.WbmKey, ProntoMarkup.ImageHolderKey); img.Save(filePath); img.Dispose(); } // 3. make image into word CommonProfile.CurrentSelection.TypeText(" "); InlineShape inlineShape = CommonProfile.CurrentSelection.InlineShapes.AddPicture(filePath, false, true); inlineShape.AlternativeText = mgrProfile.AlternativeText; // 4. add bookmark Selection selection = CommonProfile.CurrentSelection; selection.MoveLeft(WdUnits.wdCharacter, 1); selection.MoveRight(WdUnits.wdCharacter, 1, WdMovementType.wdExtend); mgrProfile.AddBookmark_BookmarkReturn = CommonProfile.Bookmarks.Add(mgrProfile.WbmKey, selection.Range); selection.MoveRight(WdUnits.wdCharacter); // 5. delete file out of user data System.IO.File.Delete(filePath); } catch (System.Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_GenerateImageError, MessageUtils.Expand(Properties.Resources.ipe_GenerateImageError, ex.Message), ex.StackTrace); throw mgrExp; } }
/// <summary> /// get a bookmark object in word follow by bookmark's name /// </summary> /// <param name="name"></param> /// <returns></returns> public Bookmark GetBookmark(string name) { try { if (Wkl.MainCtrl.CommonCtrl.CommonProfile.Bookmarks.Exists(name)) { return(Wkl.MainCtrl.CommonCtrl.CommonProfile.Bookmarks[name]); } return(null); } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_GetWordBookmarksError, MessageUtils.Expand(Properties.Resources.ipe_GetWordBookmarksError, ex.Message), ex.StackTrace); throw mgrExp; } }
/// <summary> /// highlight bookmark /// </summary> /// <param name="name"></param> public void UnHighLightBookmark(string key) { try { ManagerProfile managerPro = Wkl.MainCtrl.ManagerCtrl.GetProfile(key); Bookmark bm = GetBookmark(managerPro.HighlightBookmarkName); WdColorIndex color = managerPro.WdColorIndex == null ? ProntoMarkup.BackgroundHighLight : managerPro.WdColorIndex; if (bm != null && (bm.Range.HighlightColorIndex == color)) { bm.Range.HighlightColorIndex = ProntoMarkup.BackgroundUnHighLight; } } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_UnHighlightWordBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_UnHighlightWordBookmarkError, ex.Message), ex.StackTrace); throw mgrExp; } }
/// <summary> /// Update value of bookmark /// </summary> /// <param name="bm"></param> /// <param name="newText"></param> public void UpdateBookmarkText(Bookmark bm, string newText) { try { // 1. get old information string name = bm.Name; Range range = bm.Range; // 2. update word bookmark range.Text = newText; Bookmark newBm = Wkl.MainCtrl.CommonCtrl.CommonProfile.Bookmarks.Add(name, range); Bookmark endBm = GetBookmark(name.Replace(ProntoMarkup.KeyStartForeach, ProntoMarkup.KeyEndForeach)); if (newText.Contains(Constants.OrderBy.ForeachSortMark)) { newBm.Range.Font.Color = ProntoMarkup.ForeachConditionColor; if (endBm != null) { endBm.Range.Font.Color = ProntoMarkup.ForeachConditionColor; } } else { newBm.Range.Font.Color = ProntoMarkup.ForeachColor; if (endBm != null) { endBm.Range.Font.Color = ProntoMarkup.ForeachColor; } } // 3. update internal bookmark CurrentTemplateInfo.InternalBookmark.GetInternalBookmarkItem(name).BizName = newText; } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_UpdateWordBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_UpdateWordBookmarkError, ex.Message), ex.StackTrace); throw mgrExp; } }
public void btnReconstruct_Click(Office.IRibbonControl control) { try { ContextManager context = new ContextManager(); context.Reconstruct(); } catch (BaseException srvExp) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_ReconstructError); mgrExp.Errors.Add(srvExp); LogUtils.LogManagerError(mgrExp); } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_ReconstructError, MessageUtils.Expand(Properties.Resources.ipe_ReconstructError, ex.Message), ex.StackTrace); LogUtils.LogManagerError(mgrExp); } }
/// <summary> /// Add bookmark with Name = name and Value = current selected range /// </summary> /// <param name="name"></param> public void AddBookmark(string key) { try { ManagerProfile mgrProfile = Wkl.MainCtrl.ManagerCtrl.GetProfile(key); mgrProfile.DeletedBookmarkName = mgrProfile.AddBookmark_Name; DeleteBookmark(key); Range range = CommonProfile.CurrentSelection.Range; Bookmark newBM = CommonProfile.Bookmarks.Add(mgrProfile.AddBookmark_Name, range); CommonProfile.Bookmarks.DefaultSorting = WdBookmarkSortBy.wdSortByLocation; CommonProfile.Bookmarks.ShowHidden = false; newBM.Range.HighlightColorIndex = WdColorIndex.wdNoHighlight; mgrProfile.AddBookmark_BookmarkReturn = newBM; } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_AddWordBookmarkError, MessageUtils.Expand(Properties.Resources.ipe_AddWordBookmarkError, ex.Message), ex.StackTrace); throw mgrExp; } }
/// <summary> /// Occurs before any open document is saved. (Inherited from ApplicationEvents4_Event.) /// </summary> /// <param name="Doc"></param> /// <param name="SaveAsUI"></param> /// <param name="Cancel"></param> private void ThisDocument_DocumentBeforeSave(Word.Document Doc, ref bool SaveAsUI, ref bool Cancel) { try { if (Doc != Application.ActiveDocument) { return; } } catch { return; } TemplateInfo template = this.TemplateInfo; if (template.IsProntoDoc) { try { ContextManager contexMgr = new ContextManager(); contexMgr.SaveDocument(Doc, ref SaveAsUI, ref Cancel); } catch (BaseException baseExp) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_SaveDocumentError); mgrExp.Errors.Add(baseExp); throw mgrExp; } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_SaveDocumentError, MessageUtils.Expand(Properties.Resources.ipe_SaveDocumentError, ex.Message), ex.StackTrace); throw mgrExp; } } }
public void GetPdwInformation(string key) { try { ManagerProfile mgrPro = Wkl.MainCtrl.ManagerCtrl.GetProfile(key); List <XmlObject> contents = new List <XmlObject>(); string osqlId = GetPropertyValue(PdwInfo.OsqlCustomXmlPartId); string xsltId = GetPropertyValue(PdwInfo.XsltCustomXmlPartId); string chksId = GetPropertyValue(PdwInfo.ChksCustomXmlPartId); string osql = GetCustomXmlPartContent(osqlId); string xslt = GetCustomXmlPartContent(xsltId); string chks = GetCustomXmlPartContent(chksId); contents.Add(ObjectSerializeHelper.Deserialize <XmlObject>(osql)); contents.Add(ObjectSerializeHelper.Deserialize <XmlObject>(xslt)); contents.Add(ObjectSerializeHelper.Deserialize <XmlObject>(chks)); if (mgrPro.TemplateType == TemplateType.Pdm) { string controlsId = GetPropertyValue(PdwInfo.PdmFormControlXmlPartId); string controls = GetCustomXmlPartContent(controlsId); contents.Add(ObjectSerializeHelper.Deserialize <XmlObject>(controls)); } mgrPro.XmlObjects = contents; } catch (Exception ex) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_GetPdwInfoError, MessageUtils.Expand(Properties.Resources.ipe_GetPdwInfoError, ex.Message), ex.StackTrace); throw mgrExp; } }