Exemplo n.º 1
0
        public ActionResult CreateWeb([Bind(Prefix = "Web")] Web web, string solution = "core", string lang = "")
        {
            try
            {
                var app = App.Get();
                //set default locale
                if (!string.IsNullOrEmpty(lang))
                {
                    DnaConfig.UpdateWebConfig("configuration/appSettings/add[@key=\"DefaultLocale\"]", "value", lang);
                }

                app.Widgets.RegisterAll();
                var topWeb = app.Solutions.Install(solution, "home", web.Owner, web.Title, web.Description, "", lang);

                if (topWeb.Pages.Count() == 0)
                {
                    topWeb.CreatePage("Default");
                }

                PermissionLoader.Load();

                DnaConfig.UpdateWebConfig("configuration/appSettings/add[@key=\"Initialized\"]", "value", "True");
            }
            catch (Exception e)
            {
                //var msg = e.Message;
                Exception innerExpt = e.InnerException;
                var       errors    = new StringBuilder();

                App.Get().DataContext.Delete <Web>(w => w.Name.Equals("home"));
                App.Get().DataContext.SaveChanges();
                errors.AppendLine(e.Message);

                while (innerExpt != null)
                {
                    errors.AppendLine(innerExpt.Message);
                    //msg = innerExpt.Message;
                    innerExpt = innerExpt.InnerException;
                }
                errors.AppendLine(e.StackTrace);
                //if (innerExpt != null)
                // errors.Append(e.Message);
                //msg = innerExpt.Message;

                return(Json(new { error = errors.ToString() }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
 public ActionResult RefreshPerms()
 {
     PermissionLoader.Load();
     return(new HttpStatusCodeResult(200));
     //return Redirect("~/host/roles");
 }