private PdwInfo GetPdwInfo(Document Doc) { string srvKey = string.Empty; try { Document doc = Wkl.MainCtrl.CommonCtrl.CommonProfile.ActiveDoc; string tempFileName; if (File.Exists(doc.FullName)) { tempFileName = doc.FullName; } else { tempFileName = Path.Combine(Pdw.AssetManager.FileAdapter.TemporaryFolderPath, Guid.NewGuid().ToString() + FileExtension.ProntoDocumenentWord); } Context.ContextManager contextMgr = new Context.ContextManager(); PdwInfo pdwInfo = contextMgr.SaveAsTemplate(doc, tempFileName, false); return(pdwInfo); } finally { Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey); } }
private void SaveTemplate(TemplateType type) { WaitingForm frmWaiting = null; WdCursorType originalCursor = WdCursorType.wdCursorNormal; try { originalCursor = Wkl.MainCtrl.CommonCtrl.CommonProfile.App.System.Cursor; TemplateInfo templateInfo = Wkl.MainCtrl.CommonCtrl.CommonProfile.CurrentTemplateInfo; if (templateInfo.IsProntoDoc) { string filter = string.Empty; switch (type) { case TemplateType.Pdw: filter = PdwFilter; break; case TemplateType.Pdh: filter = PdhFilter; break; case TemplateType.Pdz: filter = PdzFilter; break; //HACK:FORM CONTROLS - TEMPORARY INSTEAD OF TemplateType.Pdm case TemplateType.Pdm: filter = PdmFilter; break; default: break; } SaveFileDialog saveDialog = new SaveFileDialog { Filter = filter }; if (saveDialog.ShowDialog() == DialogResult.OK) { // set wating cursor Wkl.MainCtrl.CommonCtrl.CommonProfile.App.System.Cursor = WdCursorType.wdCursorWait; frmWaiting = new WaitingForm(); frmWaiting.Show(); Context.ContextManager contextMgr = new Context.ContextManager(); contextMgr.SaveAsTemplate(Wkl.MainCtrl.CommonCtrl.CommonProfile.ActiveDoc, saveDialog.FileName); if (File.Exists(Wkl.MainCtrl.CommonCtrl.CommonProfile.ActiveDoc.FullName)) { MessageBox.Show(MessageUtils.Expand(Properties.Resources.ipm_M006, Wkl.MainCtrl.CommonCtrl.CommonProfile.ActiveDoc.FullName)); } } } else { MessageBox.Show(MessageUtils.Expand(Properties.Resources.ipm_NotIsProntoDoc, Properties.Resources.ipe_NotIsProntoDoc)); } } catch (BaseException baseExp) { ManagerException mgrExp = new ManagerException(ErrorCode.ipe_SavePdwError); mgrExp.Errors.Add(baseExp); LogUtils.LogManagerError(mgrExp); } finally { try { if (frmWaiting != null) { frmWaiting.Close(); frmWaiting.Dispose(); } Wkl.MainCtrl.CommonCtrl.CommonProfile.App.System.Cursor = originalCursor; } catch { } } }