示例#1
0
        /// <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);
            }
        }
示例#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
        /// <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
        public void ValidateDocument(string key, Document Doc = null)
        {
            if (Doc == null)
            {
                Doc = Wkl.MainCtrl.CommonCtrl.CommonProfile.ActiveDoc;
            }
            ContextValidator validator = new ContextValidator(Doc);

            validator.ValidateBeforeSave(key);

            ManagerProfile mgrPro = Wkl.MainCtrl.ManagerCtrl.GetProfile(key);

            if (!mgrPro.IsCorrect)
            {
                mgrPro.WDoc = Doc;
                Hcl.SaveMessageDialog saveNotify = new Hcl.SaveMessageDialog(key);
                saveNotify.Show();
            }
        }