Exemplo n.º 1
0
        public void Execute(System.Web.UI.Page page, Microsoft.SharePoint.SPContext context)
        {
            string urlParent       = page.Request.UrlReferrer.AbsolutePath.ToLower();
            string pageCreationUrl = context.Site.MakeFullUrl(string.Format("/_layouts/15/spcf.aspx?List={0}&RootFolder=%2FSitePages&ContentTypeId=0x0101090100B376979C3565E2489CF19B4387E89143"
                                                                            , HttpUtility.UrlEncode(context.Web.Lists.EnsureSitePagesLibrary().ID.ToString("B"))));

            MemoryPersisted.Set("NewPageActionReferrer", urlParent);
            MemoryPersisted.Set("SecaoMenu", page.Request.QueryString["Secao"]);

            page.Response.Redirect(pageCreationUrl);
        }
Exemplo n.º 2
0
        /// <summary>
        /// An item was added.
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties)
        {
            base.ItemAdded(properties);

            try
            {
                if (properties.ListItem.ContentTypeId.IsChildOf(new SPContentTypeId("0x01010901"))) //pagina de webparts
                {
                    if (MemoryPersisted.Contains(properties.Web.CurrentUser.ID, "NewPageActionReferrer"))
                    {
                        string urlReferrer = MemoryPersisted.Get <string>(properties.Web.CurrentUser.ID, "NewPageActionReferrer");
                        string secao       = MemoryPersisted.Get <string>(properties.Web.CurrentUser.ID, "SecaoMenu");

                        MenuPrincipalAdapter adapter = new MenuPrincipalAdapter(properties.Site.RootWeb);

                        IEnumerable <MenuPrincipal> referrerMenus = adapter.GetByQuery(
                            string.Format("<Where><And><Eq><FieldRef Name=\"{0}\" /><Value Type=\"Text\">{1}</Value></Eq><Contains><FieldRef Name=\"{2}\" /><Value Type=\"Text\">{3}</Value></Contains></And></Where>",
                                          MenuPrincipal.FieldNameURL, urlReferrer, MenuPrincipal.FieldNameSecao, secao));

                        MenuPrincipal referrerUrlMenu = referrerMenus.FirstOrDefault();

                        //if (referrerUrlMenu != null)
                        //{
                        MenuPrincipal newChildMenu = new MenuPrincipal();
                        newChildMenu.Title              = properties.ListItem.File.Name.Remove(properties.ListItem.File.Name.LastIndexOf('.'));
                        newChildMenu.URL                = properties.ListItem.File.ServerRelativeUrl;
                        newChildMenu.Destino            = EmbratelIntranet.Home.Core.Domain.Destino._self;
                        newChildMenu.Secao              = secao;
                        newChildMenu.ParentLookup.Value = referrerUrlMenu;

                        adapter.Add(newChildMenu);
                        //}
                    }
                }
            }
            catch { }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //try
            //{
            string typeName = Page.Request.QueryString["Executable"];

            if (MemoryPersisted.Contains(Page.Request.Url.ToString()))
            {
                return;
            }

            MemoryPersisted.Set(Page.Request.Url.ToString(), true);

            if (string.IsNullOrEmpty(typeName))
            {
                throw new ArgumentNullException("Executable", "O parâmetro 'Executable' não foi especificado.");
            }

            Type type = null;

            try
            {
                type = Type.GetType(typeName);
            }
            catch (Exception ex)
            {
                throw new ArgumentException(string.Format("O tipo de Executable '{0}' não pôde ser encontrado, verifique se é um tipo válido.", typeName), "Executable");
            }

            if (typeof(IExecutable).IsAssignableFrom(type))
            {
                IExecutable executable;

                try
                {
                    executable = Activator.CreateInstance(type) as IExecutable;
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException("Falha ao tentar instanciar o Executable especificado.");
                }

                try
                {
                    executable.Execute(Page, SPContext.Current);
                }
                catch (Exception ex)
                {
                    MemoryPersisted.Remove(Page.Request.Url.ToString());
                    throw ex;
                }
            }
            else
            {
                throw new NotSupportedException("O tipo especificado não implementa 'IExecutable'.");
            }
            //}
            //catch (Exception ex)
            //{
            //    ExceptionManager.Log(ex);
            //}
        }