private IBaseTemplate LoadTemplateData()
        {
            var document = new OfficeDocument(Globals.ThisAddIn.Application.ActiveDocument);

            var template = new FactFinder();

            //read content controls and set template values.
            foreach (PropertyInfo pInfo in template.GetType().GetProperties())
            {
                if (pInfo == null)
                {
                    break;
                }

                if (!String.Equals(pInfo.PropertyType.Name, "string", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }
                string value = document.ReadContentControlValue(pInfo.Name);
                pInfo.SetValue(template, value, null);
            }

            //read cover page and logo property values and set template values
            template.CoverPageTitle = document.GetPropertyValue(Constants.WordDocumentProperties.CoverPageTitle);
            template.LogoTitle      = document.GetPropertyValue(Constants.WordDocumentProperties.LogoTitle);
            return(template);
        }
Пример #2
0
        private void ThisAddIn_DocumentOpen(Document doc)
        {
            try
            {
                if (doc == null)
                {
                    return;
                }

                doc.ActiveWindow.View.ShadeEditableRanges = 0;
                Ribbon.ribbon.Invalidate();



                var document   = new OfficeDocument(doc);
                var documentId = document.GetPropertyValue(Constants.WordDocumentProperties.DocumentId);
                var fragmentsUsedPropertyValue = document.GetPropertyValue(Constants.WordDocumentProperties.UsedDateOfFragements);
                var logoPropertyValue          = document.GetPropertyValue(Constants.WordDocumentProperties.UsedDateOfLogo);
                var themePropertyValue         = document.GetPropertyValue(Constants.WordDocumentProperties.UsedDateOfTheme);
                var mainTemplatePropertyValue  = document.GetPropertyValue(Constants.WordDocumentProperties.BuiltInTitle) + ";" + document.GetPropertyValue(Constants.WordDocumentProperties.DocumentGeneratedDate);

                var spList         = new Models.SharePoint.SharePointList(Settings.Default.SharePointContextUrl, "TemplateUpdateTracking");
                var item           = spList.GetListItemByTitle(documentId);
                var shouldHide     = "false";
                var hideChosedDate = "";
                if (item != null)
                {
                    shouldHide     = item.GetFieldValue("Hide");
                    hideChosedDate = item.GetFieldValue("Modified");
                }

                var task = Task.Factory.StartNew(() => ExecuteUpdateChecker(shouldHide, fragmentsUsedPropertyValue, themePropertyValue, logoPropertyValue, mainTemplatePropertyValue, documentId, hideChosedDate));

                //System.Threading.Tasks.Task.Factory.StartNew(() => ThisAddIn.CheckStartupTasks(document), CancellationToken.None, TaskCreationOptions.None, uiScheduler);
            }
            catch (Exception ex)
            {
                OnError(ex);
            }
        }
Пример #3
0
        private void ThisAddIn_DocumentOpen(Document doc)
        {
            try
            {
                var logger = new EventViewerLogger();
                logger.Log(string.Format("DocumentOpen event"), Type.Information);

                if (doc == null)
                {
                    logger.Log(string.Format("DocumentOpen event - doc is null, returning"), Type.Information);
                    return;
                }

                doc.ActiveWindow.View.ShadeEditableRanges = 0;
                Ribbon.ribbon.Invalidate();


                var document   = new OfficeDocument(doc);
                var documentId = document.GetPropertyValue(Constants.WordDocumentProperties.DocumentId);
                logger.Log(string.Format("DocumentOpen event - documentId = {0}", documentId), Type.Information);

                // disabled update check Nov 2017 DSZ
                //var fragmentsUsedPropertyValue = document.GetPropertyValue(Constants.WordDocumentProperties.UsedDateOfFragements);
                //var logoPropertyValue = document.GetPropertyValue(Constants.WordDocumentProperties.UsedDateOfLogo);
                //var themePropertyValue = document.GetPropertyValue(Constants.WordDocumentProperties.UsedDateOfTheme);
                //var mainTemplatePropertyValue =
                //    document.GetPropertyValue(Constants.WordDocumentProperties.BuiltInTitle) + ";" +
                //    document.GetPropertyValue(Constants.WordDocumentProperties.DocumentGeneratedDate);

                //var spList = ListFactory.Create("TemplateUpdateTracking");
                //var item = spList.GetListItemByTitle(documentId);
                //var shouldHide = "false";
                //var hideChosedDate = "";
                //if (item != null)
                //{
                //    shouldHide = item.GetFieldValue("Hide");
                //    hideChosedDate = item.GetFieldValue("Modified");
                //}

                //var task =
                //    Task.Factory.StartNew(
                //        () =>
                //            ExecuteUpdateChecker(shouldHide, fragmentsUsedPropertyValue, themePropertyValue,
                //                logoPropertyValue, mainTemplatePropertyValue, documentId, hideChosedDate));

                //System.Threading.Tasks.Task.Factory.StartNew(() => ThisAddIn.CheckStartupTasks(document), CancellationToken.None, TaskCreationOptions.None, uiScheduler);
            }
            catch (Exception ex)
            {
                OnError(ex);
            }
        }
Пример #4
0
        private static bool LoadImageWizard(Enums.FormLoadType loadType, OfficeDocument officeDoc)
        {
            var loadImageWizard = officeDoc.GetPropertyValue(
                Constants.WordDocumentProperties.LoadBrandingImageSelector, false);

            if (string.Equals(loadImageWizard, "true", StringComparison.OrdinalIgnoreCase))
            {
                var wizard = new ThemesOnlyWizard(officeDoc)
                {
                    TopMost       = true,
                    StartPosition = FormStartPosition.CenterParent,
                    Reload        = (loadType != Enums.FormLoadType.OpenDocument)
                };
                wizard.Show();
                return(true);
            }
            return(false);
        }