Ejemplo n.º 1
0
        private void AddModulePart()
        {
            String moduleIDString = Request.Params.Get("addmpart");
            Module module         = new Module(int.Parse(moduleIDString));

            //TODO: we could support filtering by module.ViewRoles
            if (module.AvailableForMyPage)
            {
                SiteModuleControl siteModule = Page.LoadControl("~/" + module.ControlSource) as SiteModuleControl;
                if (siteModule != null)
                {
                    siteModule.SiteId = siteSettings.SiteId;
                    siteModule.ID     = "module" + module.ModuleId.ToString();

                    siteModule.ModuleConfiguration = module;
                    siteModule.RenderInWebPartMode = true;

                    WebPart webPart = WebPartManager1.CreateWebPart(siteModule);

                    siteModule.ModuleId = module.ModuleId;
                    Module.UpdateCountOfUseOnMyPage(module.ModuleId, 1);

                    CWebPartManager CManager = (CWebPartManager)this.WebPartManager1;
                    CManager.AddWebPart(webPart, this.CenterWebPartZone, 0);
                    CManager.SetDirty();
                }
            }
        }
Ejemplo n.º 2
0
        public override WebPart GetWebPart(WebPartDescription description)
        {
            SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();

            if (siteSettings == null)
            {
                return(null);
            }

            WebPart webPart = null;

            if (description.ID.Length == 36)
            {
                Guid           webPartID      = new Guid(description.ID);
                WebPartContent webPartContent = new WebPartContent(webPartID);
                if (webPartContent.WebPartId != Guid.Empty)
                {
                    if (HttpContext.Current != null)
                    {
                        String path = HttpContext.Current.Server.MapPath("~/bin")
                                      + Path.DirectorySeparatorChar + webPartContent.AssemblyName + ".dll";
                        Assembly assembly = Assembly.LoadFrom(path);
                        Type     type     = assembly.GetType(webPartContent.ClassName, true, true);
                        object   obj      = Activator.CreateInstance(type);
                        if (obj != null)
                        {
                            webPart = (WebPart)obj;
                            WebPartContent.UpdateCountOfUseOnMyPage(webPartContent.WebPartId, 1);
                        }
                    }
                }
            }
            else
            {
                Cynthia.Business.Module module = new Cynthia.Business.Module(int.Parse(description.ID));

                SiteModuleControl siteModule = Page.LoadControl("~/" + module.ControlSource) as SiteModuleControl;
                if (siteModule != null)
                {
                    siteModule.SiteId = siteSettings.SiteId;
                    siteModule.ID     = "module" + module.ModuleId.ToString(CultureInfo.InvariantCulture);

                    siteModule.ModuleConfiguration = module;
                    siteModule.RenderInWebPartMode = true;

                    webPart = WebPartManager.CreateWebPart(siteModule);


                    siteModule.ModuleId = module.ModuleId;
                    Cynthia.Business.Module.UpdateCountOfUseOnMyPage(module.ModuleId, 1);
                }
            }

            return(webPart);
        }
Ejemplo n.º 3
0
        private void LoadSettings()
        {
            timeOffset     = SiteUtils.GetUserTimeOffset();
            pageId         = WebUtils.ParseInt32FromQueryString("pageid", -1);
            moduleId       = WebUtils.ParseInt32FromQueryString("mid", -1);
            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);

            if (moduleSettings.Contains("ResultBarColor"))
            {
                resultBarColor = moduleSettings["ResultBarColor"].ToString();
            }

            if (CurrentPage.ContainsModule(moduleId))
            {
                currentModule = new Cynthia.Business.Module(moduleId);
                currentPoll   = new Poll(moduleId);
            }
        }