Ejemplo n.º 1
0
 public override void ResetTheme(ThemeEntity theme)
 {
     if (theme.BackColor.HasValue && theme.BackColor.Value != Color.Empty)
     {
         BtnBackColor = theme.BackColor.Value;
     }
 }
Ejemplo n.º 2
0
        private int SaveChangesWithLogging(bool acceptAllChangesOnSuccess, string ChangeOwner, CancellationToken cancellationToken = default(CancellationToken))
        {
            var auditEntries = OnBeforeSaveChanges(ChangeOwner);

            // Check to see if any themes are added during this change
            bool ThemesAdded = ChangeTracker.Entries().Any(e => e.State == EntityState.Added && e.Entity is ThemeEntity);

            ThemeEntity tempTheme = null;

            // Store the theme added before saving
            if (ThemesAdded)
            {
                tempTheme = (ThemeEntity)ChangeTracker.Entries().Where(e => e.State == EntityState.Added && e.Entity is ThemeEntity)
                            .SingleOrDefault().Entity;
            }
            // Save changes
            var result = base.SaveChanges(acceptAllChangesOnSuccess);

            // Send email if a theme is added
            if (ThemesAdded && tempTheme != null)
            {
                Database.ExecuteSqlCommand("EXEC usp_send_btr_email @FromAddress, @ReplyTo, @Recipients, @BodyText, @SubjectText",
                                           new SqlParameter("@FromAddress", _emailconfig.FromAddress),
                                           new SqlParameter("@ReplyTo", _emailconfig.ReplyTo),
                                           new SqlParameter("@Recipients", _emailconfig.Recipients),
                                           new SqlParameter("@BodyText", EmailUtil.FormatThemeString(_emailconfig.BodyText, tempTheme)),
                                           new SqlParameter("@SubjectText", EmailUtil.FormatThemeString(_emailconfig.SubjectText, tempTheme))
                                           );
            }
            OnAfterSaveChanges(auditEntries);
            return(result);
        }
Ejemplo n.º 3
0
        public virtual string GetLayout(ActionExecutedContext filterContext, ThemeEntity theme)
        {
            string name = string.Empty;

            if (theme != null)
            {
                name = theme.ID;
            }
            if (name.IsNotNullAndWhiteSpace())
            {
                string path  = string.Format(Layouts.Theme, name);
                string path2 = string.Format(Layouts.Theme2, name);

                var env        = filterContext.HttpContext.RequestServices.GetService <IHostingEnvironment>();
                var controller = filterContext.Controller as Controller;

                if (File.Exists(env.MapPath(controller.Url.ToArray(path))))
                {
                    return(path);
                }
                if (File.Exists(env.MapPath(controller.Url.ToArray(path2))))
                {
                    return(path2);
                }
            }
            return(Layouts.Default);
            //return "~/Views/Shared/_Layout.cshtml";
        }
Ejemplo n.º 4
0
        private ThemeEntity GetTheme(IWebElement themeElement)
        {
            var url = themeElement.GetAttribute("href");
            var ids = url.SplitUrl();

            var model = new ThemeEntity
            {
                ThemeId = ids[2],
                Name    = themeElement.FindElement(By.TagName("span")).Text,
                Url     = url
            };

            //var urlSplitted = url.Replace("https://entraide-covid19.maxicours.com/LSI/prod/Arbo/home/bo/", "").Replace("?", "/").Split('/');
            //int.TryParse(urlSplitted[0], out var schoolLevelId);
            //int.TryParse(urlSplitted[1], out var subjectId);
            //int.TryParse(urlSplitted[2], out var themeId);

            //var model = new ThemeEntity
            //{
            //    ThemeId = themeId,
            //    Name = themeElement.FindElement(By.TagName("span")).Text,
            //    Url = url
            //};

            return(model);
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> PostIdeaAsync([FromBody] IdeaEntity idea)
        {
            ThemeEntity parentTheme = await _context.Themes.Where(t => t.ThemeId == idea.ThemeId).SingleAsync();

            if (parentTheme != null && (parentTheme.CloseDt - DateTime.Now < TimeSpan.Zero))
            {
                return(Forbid());
            }

            idea.SubmitDt   = DateTime.Now;
            idea.ModifiedDt = idea.SubmitDt;
            idea.Owner      = "Michael";

            await _context.Ideas.AddAsync(idea);

            await _context.SaveChangesAsync(true, "testSame");

            Status ideaStatus = new Status()
            {
                StatusCode = StatusType.Submitted,
                Response   = "",
                SubmitDt   = idea.SubmitDt,
                IdeaId     = idea.PostId,
                Idea       = idea
            };

            await _context.Statuses.AddAsync(ideaStatus);

            await _context.SaveChangesAsync(true, "testSam");

            return(Ok(idea));
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> GetThemeByIdAsync(int id)
        {
            if (!(_context.Themes.Any(t => t.ThemeId == id)))
            {
                return(NotFound());
            }
            var themeQuery = _context.Themes
                             .Where(a => a.ThemeId == id)
                             .Include(a => a.Ideas)
                             .Include(a => a.Ideas)
                             .ThenInclude(i => i.Votes)
                             .Include(a => a.Ideas)
                             .ThenInclude(i => i.Comments)
                             .ThenInclude(i => i.Votes)
                             .Include(a => a.Ideas)
                             .ThenInclude(i => i.Comments)
                             .ThenInclude(c => c.Comments)
                             .ThenInclude(i => i.Votes)
                             .FirstOrDefaultAsync();

            ThemeEntity loadedTheme = await themeQuery;

            loadedTheme.Ideas = loadedTheme.Ideas.OrderByDescending(o => o.Score).ToList <IdeaEntity>();

            //foreach (IdeaEntity idea in loadedTheme.Ideas)
            //{
            //    idea.Comments = idea.Comments.OrderByDescending(c => c.Score).ToList();

            //    Vote tempVote = idea.Votes.Where(v => v.Owner == _userPrincipal.SAMName)
            //        .OrderByDescending(v => v.SubmitDt).FirstOrDefault();

            //    if (tempVote != null)
            //        idea.UserVoteDirection = tempVote.Direction;

            //    foreach (CommentEntity comment in idea.Comments)
            //    {
            //        comment.Comments = comment.Comments.OrderByDescending(c => c.Score).ToList();

            //        Vote subtempVote = comment.Votes.Where(v => v.Owner == _userPrincipal.SAMName)
            //            .OrderByDescending(v => v.SubmitDt).FirstOrDefault();

            //        if (subtempVote != null)
            //            comment.UserVoteDirection = subtempVote.Direction;

            //        foreach (CommentEntity subComment in comment.Comments)
            //        {
            //            Vote subsubtempVote = subComment.Votes.Where(v => v.Owner == _userPrincipal.SAMName)
            //                .OrderByDescending(v => v.SubmitDt).FirstOrDefault();

            //            if (subsubtempVote != null)
            //                subComment.UserVoteDirection = subsubtempVote.Direction;
            //        }
            //    }
            //}
            return(Ok(loadedTheme));
        }
Ejemplo n.º 7
0
        /// <summary>
        ///     map method
        /// </summary>
        /// <param name="themeEntity">ThemeEntity instance</param>
        /// <returns>instance of Theme (for BLL)</returns>
        public static Theme Map(this ThemeEntity themeEntity)
        {
            var resultTheme = new Theme
            {
                ThemeId = themeEntity.ThemeEntityId,
                Name    = themeEntity.Name
            };

            return(resultTheme);
        }
Ejemplo n.º 8
0
 public static string FormatThemeString(string FormatString, ThemeEntity Theme)
 {
     return(FormatString
            .Replace("<Title>", Theme.Title)
            .Replace("<ThemeId>", Theme.ThemeId.ToString())
            .Replace("<Owner>", Theme.Owner)
            .Replace("<OpenDt>", Theme.OpenDt.ToString())
            .Replace("<CloseDt>", Theme.CloseDt.ToString())
            .Replace("<Description>", Theme.Description));
 }
Ejemplo n.º 9
0
        /// <summary>
        ///     map method
        /// </summary>
        /// <param name="theme">Theme instance </param>
        /// <returns>instance of ThemeEntity (for DAL)</returns>
        public static ThemeEntity Map(this Theme theme)
        {
            var resultTheme = new ThemeEntity
            {
                ThemeEntityId = theme.ThemeId,
                Name          = theme.Name
            };

            return(resultTheme);
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> PostThemeAsync([FromBody] ThemeEntity theme)
        {
            theme.OpenDt = DateTime.Now;
            theme.Owner  = "Michael";

            await _context.Themes.AddAsync(theme);

            await _context.SaveChangesAsync();

            return(Ok(theme.ThemeId));
        }
Ejemplo n.º 11
0
        public ActionResult Send(int id)
        {
            ThemeEntity theme = (from t in _context.Themes
                                 where t.ThemeId == id
                                 select t).First();

            if (theme == null || theme.CloseDt < DateTime.Now)
            {
                return(BadRequest());
            }

            _context.SendEmail(theme, true);
            return(Ok());
        }
Ejemplo n.º 12
0
        public void CanGetComposedLook()
        {
            using (var ctx = TestCommon.CreateClientContext())
            {
                using (ClientContext cc = ctx.Clone("https://bertonline.sharepoint.com/sites/temp2/s1"))
                {
                    ThemeEntity t = cc.Web.GetCurrentComposedLook();
                }

                using (var cc = ctx.Clone("https://bertonline.sharepoint.com/sites/4f020b2a38344bc79fd431759272b48d"))
                {
                    ThemeEntity t = cc.Web.GetCurrentComposedLook();
                }
                using (var cc = ctx.Clone("https://bertonline.sharepoint.com/sites/130020"))
                {
                    ThemeEntity t = cc.Web.GetCurrentComposedLook();
                }

                using (var cc = ctx.Clone("https://bertonline.sharepoint.com/sites/130020"))
                {
                    ThemeEntity t = cc.Web.GetCurrentComposedLook();
                }

                using (var cc = ctx.Clone("https://bertonline.sharepoint.com/sites/20140020"))
                {
                    ThemeEntity t = cc.Web.GetCurrentComposedLook();
                }

                using (var cc = ctx.Clone("https://bertonline.sharepoint.com/sites/dev4"))
                {
                    ThemeEntity t = cc.Web.GetCurrentComposedLook();
                }

                using (var cc = ctx.Clone("https://bertonline.sharepoint.com/sites/temp3"))
                {
                    ThemeEntity t = cc.Web.GetCurrentComposedLook();
                }

                using (var cc = ctx.Clone("https://bertonline.sharepoint.com/sites/temp3/demo1"))
                {
                    ThemeEntity t = cc.Web.GetCurrentComposedLook();
                }

                using (var cc = ctx.Clone("https://bertonline.sharepoint.com/sites/temp2"))
                {
                    ThemeEntity t = cc.Web.GetCurrentComposedLook();
                }
            }
        }
Ejemplo n.º 13
0
 public static ThemeViewModel ToModelTheme(this ThemeEntity entity)
 {
     if (entity != null)
     {
         return(new ThemeViewModel()
         {
             Id = entity.Id,
             Name = entity.Name,
             DatePublication = entity.DatePublication,
             CountViews = entity.CountViews,
             CreatorId = entity.CreatorId,
             SectionId = entity.SectionId,
             Content = entity.Content
         });
     }
     return(null);
 }
Ejemplo n.º 14
0
 public static DalTheme ToDalTheme(this ThemeEntity themeEntity)
 {
     if (themeEntity != null)
     {
         return(new DalTheme()
         {
             Id = themeEntity.Id,
             Name = themeEntity.Name,
             DatePublication = themeEntity.DatePublication,
             CountViews = themeEntity.CountViews,
             CreatorId = themeEntity.CreatorId,
             SectionId = themeEntity.SectionId,
             Content = themeEntity.Content
         });
     }
     return(null);
 }
Ejemplo n.º 15
0
        public ThemeEntity GetTheme(int idusuario)
        {
            string      keyCache = "THEME_" + idusuario;
            ThemeEntity Theme    = CacheLayer.Get <ThemeEntity>(keyCache);

            if (Theme == null)
            {
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    Theme =
                        (from d in dbContext.Theme where d.IdUsuario == idusuario select d).FirstOrDefault();
                }
                if (Theme != null)
                {
                    CacheLayer.Add <ThemeEntity>(Theme, keyCache);
                }
            }

            return(Theme);
        }
Ejemplo n.º 16
0
        //override for audit logging
        public void SendEmail(ThemeEntity Theme, bool AsReminder = false)
        {
            string SubjectText = "";
            string BodyText    = "";

            if (AsReminder)
            {
                SubjectText = _emailconfig.ReminderSubjectText;
                BodyText    = _emailconfig.ReminderBodyText;
            }
            else
            {
                SubjectText = _emailconfig.SubjectText;
                BodyText    = _emailconfig.BodyText;
            }
            Database.ExecuteSqlCommand("EXEC usp_send_btr_email @FromAddress, @ReplyTo, @Recipients, @BodyText, @SubjectText",
                                       new SqlParameter("@FromAddress", _emailconfig.FromAddress),
                                       new SqlParameter("@ReplyTo", _emailconfig.ReplyTo),
                                       new SqlParameter("@Recipients", _emailconfig.Recipients),
                                       new SqlParameter("@BodyText", EmailUtil.FormatThemeString(BodyText, Theme)),
                                       new SqlParameter("@SubjectText", EmailUtil.FormatThemeString(SubjectText, Theme))
                                       );
        }
Ejemplo n.º 17
0
 public override string GetLayout(ActionExecutedContext filterContext, ThemeEntity theme)
 {
     return(Layouts.PageDesign);
 }
Ejemplo n.º 18
0
 public virtual string GetLayout(ActionExecutedContext filterContext, ThemeEntity theme)
 {
     return(Layouts.Default);
 }
Ejemplo n.º 19
0
 public override string GetLayout(ActionExecutedContext filterContext, ThemeEntity theme)
 {
     return("~/Views/Shared/_DesignPageLayout.cshtml");
 }
Ejemplo n.º 20
0
        private ThemeEntity CreateTheme(string themeName, List <PositionEntry> cssFiles)
        {
            const string themeCss    = "theme.css";
            const string themeCssMin = "theme.min.css";
            const string thumbnail   = "thumbnail.jpg";

            #region Write theme.css,theme.min.css
            using (FileStream themeFilestram = new FileStream(Path.Combine(ThemeBasePath, themeName, themeCssMin), FileMode.Create))
            {
                using (StreamWriter writer = new StreamWriter(themeFilestram))
                {
                    if (cssFiles.All(css => !BootstrapFilter.IsMatch(css.Entry)))
                    {
                        writer.WriteLine("@import url(\"/lib/bootstrap/dist/css/bootstrap.min.css\");");
                    }
                    writer.WriteLine("@import url(\"/css/theme-base.css\");");
                    foreach (var item in cssFiles.OrderBy(m => m.Position))
                    {
                        writer.WriteLine("@import url(\"{0}\");", item.Entry);
                    }
                }
            }
            using (FileStream themeFilestram = new FileStream(Path.Combine(ThemeBasePath, themeName, themeCss), FileMode.Create))
            {
                using (StreamWriter writer = new StreamWriter(themeFilestram))
                {
                    if (cssFiles.All(css => !BootstrapFilter.IsMatch(css.Entry)))
                    {
                        writer.WriteLine("@import url(\"/lib/bootstrap/dist/css/bootstrap.min.css\");");
                    }
                    writer.WriteLine("@import url(\"/css/theme-base.css\");");
                    foreach (var item in cssFiles.OrderBy(m => m.Position))
                    {
                        writer.WriteLine("@import url(\"{0}\");", item.Entry);
                    }
                }
            }
            #endregion
            if (!File.Exists(Path.Combine(ThemeBasePath, themeName, thumbnail)) &&
                File.Exists(Path.Combine(ThemeBasePath, "Default", thumbnail)))
            {
                File.Copy(Path.Combine(ThemeBasePath, "Default", thumbnail), Path.Combine(ThemeBasePath, themeName, thumbnail));
            }
            ThemeEntity themeEntity = new ThemeEntity
            {
                ID          = themeName,
                Title       = themeName,
                Description = "By TemplateImporter",
                IsActived   = false,
                Status      = (int)Easy.Constant.RecordStatus.Active,
                Thumbnail   = $"~/{ThemeFolder}/{themeName}/{thumbnail}",
                Url         = $"~/{ThemeFolder}/{themeName}/{themeCssMin}",
                UrlDebugger = $"~/{ThemeFolder}/{themeName}/{themeCss}"
            };

            var theme = _themeService.Get(themeEntity.ID);
            if (theme == null)
            {
                _themeService.Add(themeEntity);
            }
            _themeService.ChangeTheme(themeEntity.ID);
            return(themeEntity);
        }
Ejemplo n.º 21
0
        private void SaveProvisioningTemplateInternal(ClientContext context, GetProvisioningTemplateJob job, Boolean globalRepository = true)
        {
            // Fix the job filename if it is missing the .pnp extension
            if (!job.FileName.ToLower().EndsWith(".pnp"))
            {
                job.FileName += ".pnp";
            }

            // Get the Access Token from the current context
            //var accessToken = "Bearer " + context.GetAccessToken();
            var accessToken = context.GetAccessToken();

            Console.WriteLine("Bearer " + accessToken);

            // Get a reference to the target web site
            Web web = context.Web;

            context.Load(web, w => w.Url, w => w.ServerRelativeUrl);
            context.ExecuteQueryRetry();

            // Prepare the support variables
            ClientContext repositoryContext = null;
            Web           repositoryWeb     = null;

            // Define whether we need to use the global infrastructural repository or the local one
            if (globalRepository)
            {
                // Get a reference to the global repository web site and context
                repositoryContext = PnPPartnerPackContextProvider.GetAppOnlyClientContext(
                    PnPPartnerPackSettings.InfrastructureSiteUrl);
            }
            else
            {
                // Get a reference to the local repository web site and context
                repositoryContext = web.Context.GetSiteCollectionContext();
            }

            using (repositoryContext)
            {
                repositoryWeb = repositoryContext.Site.RootWeb;
                repositoryContext.Load(repositoryWeb, w => w.Url);
                repositoryContext.ExecuteQueryRetry();

                // Configure the XML SharePoint provider for the Infrastructural Site Collection
                XMLTemplateProvider provider = new XMLOpenXMLTemplateProvider(job.FileName,
                                                                              new SharePointConnector(repositoryContext, repositoryWeb.Url,
                                                                                                      PnPPartnerPackConstants.PnPProvisioningTemplates));

                ProvisioningTemplateCreationInformation ptci =
                    new ProvisioningTemplateCreationInformation(web);
                ptci.FileConnector                  = provider.Connector;
                ptci.IncludeAllTermGroups           = job.IncludeAllTermGroups;
                ptci.IncludeSearchConfiguration     = job.IncludeSearchConfiguration;
                ptci.IncludeSiteCollectionTermGroup = job.IncludeSiteCollectionTermGroup;
                ptci.IncludeSiteGroups              = job.IncludeSiteGroups;
                ptci.PersistBrandingFiles           = job.PersistComposedLookFiles;

                // We do intentionally remove taxonomies and search, which are not supported
                // in the AppOnly Authorization model
                // For further details, see the PnP Partner Pack documentation
                ptci.HandlersToProcess ^= Handlers.TermGroups;
                ptci.HandlersToProcess ^= Handlers.SearchSettings;

                // Extract the current template
                ProvisioningTemplate templateToSave = web.GetProvisioningTemplate(ptci);

                templateToSave.Description = job.Description;
                templateToSave.DisplayName = job.Title;

                if (job.PersistComposedLookFiles)
                {
                    // Create Theme Entity object
                    ThemeEntity themeEntity = web.GetCurrentComposedLook();

                    foreach (var p in themeEntity.GetType().GetProperties().Where(p => p.GetGetMethod().GetParameters().Count() == 0))
                    {
                        string propName  = p.Name;
                        string propValue = Convert.ToString(p.GetValue(themeEntity, null));

                        if (propName == "Theme")
                        {
                            propName = "ColorFile";
                        }
                        else if (propName == "Font")
                        {
                            propName = "FontFile";
                        }
                        else if (propName == "BackgroundImage")
                        {
                            propValue = "PlaceHolderValue";
                        }
                        else if (propName == "Name" && String.IsNullOrEmpty(propValue))
                        {
                            propValue = "CustomTheme";
                        }

                        string fileName    = propValue.Substring(propValue.LastIndexOf("/") + 1);
                        string relativeURL = propValue.Substring(0, propValue.LastIndexOf("/") + 1);

                        // Update template Files
                        if (propName != "Name" && propName != "IsCustomComposedLook" && !String.IsNullOrEmpty(propValue))
                        {
                            var property = templateToSave.ComposedLook.GetType().GetProperty(propName);

                            try
                            {
                                string folderPath = "";
                                Stream fileStream = null;

                                if (propName == "BackgroundImage")
                                {
                                    if (job.templateBackgroundImgFile != null)
                                    {
                                        folderPath = "{site}/SiteAssets";
                                        fileName   = job.FileName.ToLower().Replace(".pnp", ".png");
                                        fileStream = job.templateBackgroundImgFile.ToStream();
                                        Console.WriteLine("fileName: " + fileName);
                                        Console.WriteLine("fileStream: " + fileStream);
                                        templateToSave.ComposedLook.BackgroundFile = String.Format("{{sitecollection}}/SiteAssets/{0}", fileName);
                                    }
                                }
                                else if (propName.Contains("MasterPage"))
                                {
                                    folderPath = "{masterpagecatalog}";
                                    var strUrl = String.Format("{0}/_api/web/getfilebyserverrelativeurl('{1}{2}')/$value", web.Url, web.ServerRelativeUrl, propValue);
                                    fileStream = HttpHelper.MakeGetRequestForStream(strUrl, "application/octet-stream", accessToken);
                                    property.SetValue(templateToSave.ComposedLook, String.Format("{{masterpagecatalog}}/{0}", fileName), new object[] { });
                                }
                                else
                                {
                                    folderPath = "{themecatalog}/15";
                                    var strUrl = String.Format("{0}/_api/web/getfilebyserverrelativeurl('{1}{2}')/$value", web.Url, web.ServerRelativeUrl, propValue);
                                    fileStream = HttpHelper.MakeGetRequestForStream(strUrl, "application/octet-stream", accessToken);
                                    property.SetValue(templateToSave.ComposedLook, String.Format("{{themecatalog}}/15/{0}", fileName), new object[] { });
                                }

                                Console.WriteLine("Saving files: {0}, {1}", fileName, fileStream);
                                provider.Connector.SaveFileStream(fileName, fileStream);

                                Console.WriteLine("File Paths: {0}, {1}", fileName, folderPath);
                                templateToSave.Files.Add(new OfficeDevPnP.Core.Framework.Provisioning.Model.File
                                {
                                    Src       = fileName,
                                    Folder    = folderPath,
                                    Overwrite = true,
                                });

                                Console.WriteLine("Files saved: {0}, {1}", fileName, folderPath);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex);
                            }
                        }
                        else if (propName == "Name")
                        {
                            var property = templateToSave.ComposedLook.GetType().GetProperty(propName);

                            property.SetValue(templateToSave.ComposedLook, fileName, new object[] { });
                        }
                    }

                    if (job.templateAltCSSFile != null)
                    {
                        //TODO: Add handling for native Alternate CSS
                        //web.AlternateCssUrl;
                        string folderPath = "{site}/SiteAssets";
                        string fileName   = job.FileName.ToLower().Replace(".pnp", ".css");
                        Stream fileStream = job.templateAltCSSFile.ToStream();

                        provider.Connector.SaveFileStream(fileName, fileStream);

                        templateToSave.WebSettings = new WebSettings
                        {
                            AlternateCSS = String.Format("{{sitecollection}}/SiteAssets/{0}", fileName),
                        };

                        Console.WriteLine("File Paths: {0}, {1}", fileName, folderPath);
                        templateToSave.Files.Add(new OfficeDevPnP.Core.Framework.Provisioning.Model.File
                        {
                            Src       = fileName,
                            Folder    = folderPath,
                            Overwrite = true,
                        });
                    }
                }

                // Save template image preview in folder
                Microsoft.SharePoint.Client.Folder templatesFolder = repositoryWeb.GetFolderByServerRelativeUrl(PnPPartnerPackConstants.PnPProvisioningTemplates);
                repositoryContext.Load(templatesFolder, f => f.ServerRelativeUrl, f => f.Name);
                repositoryContext.ExecuteQueryRetry();

                // If there is a preview image
                if (job.TemplateImageFile != null)
                {
                    // Determine the preview image file name
                    String previewImageFileName = job.FileName.ToLower().Replace(".pnp", "_preview.png");

                    // Save the preview image inside the Open XML package
                    provider.Connector.SaveFileStream(previewImageFileName, job.TemplateImageFile.ToStream());

                    // And store URL in the XML file
                    templateToSave.ImagePreviewUrl = String.Format("{0}{1}/{2}/{3}/{4}",
                                                                   repositoryWeb.Url.ToLower().StartsWith("https") ? "pnps" : "pnp",
                                                                   repositoryWeb.Url.Substring(repositoryWeb.Url.IndexOf("://")),
                                                                   templatesFolder.Name, job.FileName, previewImageFileName);
                }

                // And save it on the file system
                provider.SaveAs(templateToSave, job.FileName.ToLower().Replace(".pnp", ".xml"));

                Microsoft.SharePoint.Client.File templateFile = templatesFolder.GetFile(job.FileName);
                ListItem item = templateFile.ListItemAllFields;

                item[PnPPartnerPackConstants.ContentTypeIdField]               = PnPPartnerPackConstants.PnPProvisioningTemplateContentTypeId;
                item[PnPPartnerPackConstants.TitleField]                       = job.Title;
                item[PnPPartnerPackConstants.PnPProvisioningTemplateScope]     = job.Scope.ToString();
                item[PnPPartnerPackConstants.PnPProvisioningTemplateSourceUrl] = job.SourceSiteUrl;

                item.Update();

                repositoryContext.ExecuteQueryRetry();
            }
        }
Ejemplo n.º 22
0
 public void UpdateTheme(ThemeEntity theme)
 {
     themeRepository.Update(theme.ToDalTheme());
     uow.Commit();
 }
Ejemplo n.º 23
0
 public virtual void ResetTheme(ThemeEntity theme)
 {
 }