Example #1
0
 public override void RenderControl(HtmlTextWriter writer)
 {
     try
     {
         SPSControlar controlator = new SPSControlar("71D70B8F-1556-4d4c-925D-342EE0EE59C0",
                                                     "Navigation.2.0");
         if (controlator.Aceptado())
         {
             if (!string.IsNullOrEmpty(ListGuid))
             {
                 treeView.ExpandAll();
                 treeView.RenderControl(writer);
             }
             else
             {
                 writer.Write("SPSProfessional - Missing configuration.<br/>");
             }
         }
     }
     catch (Exception e)
     {
         writer.Write(string.Format("Error: {0}<br/>Message: {1}<br/> Trace: {2}<br/>",
                                    e.GetType(),
                                    e.Message,
                                    e));
     }
 }
 public XFolderBreadCrumb()
 {
     _controlar = new SPSControlar("fcbe46c1-d32a-4723-92bd-51bbc7f619d6", "1.0.0.0");
     _licensed  = _controlar.Aceptado();
 }
Example #3
0
        public override void ItemAdding(SPItemEventProperties properties)
        {
            try
            {
                SPSControlar controlador = new SPSControlar("754806B7-B6B5-444C-BB3A-97B2D016404C",
                                                            "SiteCreationEvent.1.0");

                SiteCreationEngine engine = new SiteCreationEngine(properties.ListId);

                if (controlador.Aceptado())
                {
                    SiteCreationEventActions actions = new SiteCreationEventActions();

                    foreach (DictionaryEntry prop in properties.AfterProperties)
                    {
                        Debug.WriteLine(prop.Key + " -> " + prop.Value);
                    }

                    string siteTitleValue = properties.AfterProperties[engine.SiteField].ToString();

                    if (string.IsNullOrEmpty(siteTitleValue))
                    {
                        throw new ArgumentException(SiteCreationEngine.GetResourceString("ErrCantBeEmpty"));
                    }

                    string siteTemplateValue;

                    Dictionary <string, string> templates = engine.GetTemplates();

                    if (engine.OptHideTemplateField)
                    {
                        IEnumerator enumerator = templates.Keys.GetEnumerator();
                        enumerator.MoveNext();
                        siteTemplateValue = enumerator.Current as string;
                    }
                    else
                    {
                        siteTemplateValue = properties.AfterProperties[engine.TemplateField].ToString();
                    }


                    if (string.IsNullOrEmpty(siteTemplateValue) || !templates.ContainsKey(siteTemplateValue))
                    {
                        throw new ArgumentException(SiteCreationEngine.GetResourceString("ErrBadTemplateDefinition"));
                    }

                    DebugData(engine, properties, siteTitleValue, templates[siteTemplateValue]);

                    SPWeb web;

                    try
                    {
                        web = actions.CreateWeb(properties.WebUrl,
                                                siteTitleValue,
                                                templates[siteTemplateValue],
                                                engine.OptUniquePermissions,
                                                engine.OptForceDup);

                        properties.AfterProperties[engine.UrlField] = web.Url;

                        if (engine.OptOnQuickLaunch)
                        {
                            actions.AddOnQuickLaunchBar(web);
                        }

                        actions.SetUseSharedNavbar(web, engine.OptUseSharedNavBar);
                        actions.SetPermissions(web, engine.NewPermissions);
                    }
                    catch (SPSException ex)
                    {
                        Debug.WriteLine(ex.Message);

                        if (engine.OptLogError)
                        {
                            properties.AfterProperties[engine.UrlField] = "http://, " + ex.Message;
                            // + " " + ex.InnerException.Message
                        }
                    }
                }
                else
                {
                    Debug.WriteLine(ERR_LICENSE);
                    properties.AfterProperties[engine.UrlField] = "http://, " + ERR_LICENSE;
                }

                base.ItemAdding(properties);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }