コード例 #1
0
        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);
            }
        }
コード例 #2
0
        public void btnPreviewOsql_Click(Office.IRibbonControl control)
        {
            _isForceDisablePreviewOsql = false;
            Document doc = Wkl.MainCtrl.CommonCtrl.CommonProfile.ActiveDoc;

            try
            {
                //Validate document
                string mgrKey = string.Empty;
                Pdw.WKL.Profiler.Manager.ManagerProfile mgrPro = Wkl.MainCtrl.ManagerCtrl.CreateProfile(out mgrKey);
                mgrPro.WdColorIndex   = DefineColors.GetColor(selectedColor).Color;
                mgrPro.IsSaveDocument = false;

                ContextValidator validator = new ContextValidator(doc);
                validator.ValidateBeforeSave(mgrKey);

                //If document has invalid bookmarks
                if (!mgrPro.IsCorrect)
                {
                    //Ask user to remove invalid bookmarks
                    mgrPro.WDoc = doc;
                    Hcl.SaveMessageDialog saveNotify  = new Hcl.SaveMessageDialog(mgrKey);
                    DialogResult          userConfirm = saveNotify.ShowDialog();

                    if (userConfirm != DialogResult.OK || !HasSelectIBM())
                    {
                        return;
                    }
                }

                //Build and show osql
                PdwInfo pdwInfo = GetPdwInfo(doc);

                ChecksumInfo checkSum = ProntoDoc.Framework.Utils.ObjectSerializeHelper.Deserialize <ChecksumInfo>(pdwInfo.ChecksumString);
                OsqlXml      osqlXml = ProntoDoc.Framework.Utils.ObjectSerializeHelper.Deserialize <OsqlXml>(pdwInfo.OsqlString);
                string       renderArgument, jRenderArgument;
                GetRenderArguments(checkSum, out renderArgument, out jRenderArgument);

                Pdw.PreviewOsql.PreviewOsqlForm previewDialog = new Pdw.PreviewOsql.PreviewOsqlForm();
                previewDialog.Osql            = osqlXml.GetOsql("/*------------------------------------*/");
                previewDialog.JOsql           = osqlXml.GetJsql("/*------------------------------------*/");
                previewDialog.Xsl             = pdwInfo.XsltString;
                previewDialog.RenderArgument  = renderArgument;
                previewDialog.JRenderArgument = jRenderArgument;
                previewDialog.CheckSumInfo    = checkSum;
                previewDialog.OsqlXml         = osqlXml;
                previewDialog.ShowDialog();
            }
            catch { }
        }
コード例 #3
0
ファイル: ContextManager.cs プロジェクト: leonchen09/poc
        /// <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);
        }
コード例 #4
0
ファイル: ContextManager.cs プロジェクト: leonchen09/poc
        /// <summary>
        /// Save document information
        /// </summary>
        /// <param name="Doc"></param>
        /// <param name="filePath"></param>
        /// <param name="isReconstruct"></param>
        private PdwInfo Save(Document Doc, string filePath, bool isReconstruct = false, bool isToFinal = true)
        {
            try
            {
                TemplateInfo tempInfo = Wkl.MainCtrl.CommonCtrl.GetTemplateInfo(Doc.FullName);
                if (tempInfo == null)
                {
                    return(null);
                }

                PdwInfo pdwInfo = null;
                tempInfo.IsSaving = true; // markup the document is saving

                if (!string.IsNullOrEmpty(filePath))
                {
                    // put where clause into internal bookmark
                    foreach (string domainName in tempInfo.DomainNames)
                    {
                        DomainInfo             domainInfo = Wkl.MainCtrl.CommonCtrl.GetDomainInfo(domainName);
                        InternalBookmarkDomain ibmDomain  = tempInfo.InternalBookmark.GetInternalBookmarkDomain(domainName);
                        if (ibmDomain != null)
                        {
                            ibmDomain.WhereClause = domainInfo.DSDomainData.WhereClause.Clause;
                        }
                    }

                    // save pdwinfo (checksum, oslq, xslt)
                    pdwInfo = SavePdwInfo(filePath, Doc, isReconstruct);

                    // save internal bookmark
                    mainManager.MainService.PropertyService.SaveInterBookmark();

                    // save the document
                    if (isToFinal)
                    {
                        TemplateType type = MarkupUtilities.GetTemplateType(filePath);

                        if (type == TemplateType.Pdm)
                        {
                            mainManager.MainService.PdmService.Save();
                        }
                        else
                        {
                            // Doc.SaveAs(filePath);
                            Doc.Save();
                        }
                    }

                    tempInfo = Wkl.MainCtrl.CommonCtrl.GetTemplateInfo(Doc.FullName);
                    if (tempInfo != null)
                    {
                        tempInfo.IsProntoDoc = true; // markup the document is pronto doc

                        // set autosave option
                        if (!isReconstruct && Wkl.MainCtrl.CommonCtrl.CommonProfile.App.Options.SaveInterval != ProntoMarkup.SaveInterval)
                        {
                            Wkl.MainCtrl.CommonCtrl.CommonProfile.App.Options.SaveInterval = ProntoMarkup.SaveInterval;
                        }

                        if (isToFinal)
                        {
                            UpdateStatus(MessageUtils.Expand(Properties.Resources.ipm_SaveSuccessful, filePath)); // update status
                        }
                    }
                }

                if (tempInfo != null)
                {
                    tempInfo.IsSaving = false; // markup the document is saved
                }
                return(pdwInfo);
            }
            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;
            }
        }