コード例 #1
0
ファイル: ContextManager.cs プロジェクト: leonchen09/poc
        /// <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
ファイル: 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);
        }
コード例 #3
0
ファイル: ContextManager.cs プロジェクト: leonchen09/poc
        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();
            }
        }