Esempio n. 1
0
        public virtual ActionResult Install(InstallModuleModel installModel)
        {
            JsonResultEntry result = new JsonResultEntry() { RedirectToOpener = false };
            try
            {
                if (ModelState.IsValid)
                {
                    var moduleFile = this.Request.Files["ModuleFile"];
                    if (moduleFile == null || moduleFile.ContentLength == 0)
                    {
                        ModelState.AddModelError("ModuleFile", "ModuleFile is null.");
                    }
                    else
                    {
                        StringBuilder log = new StringBuilder();
                        var moduleName = System.IO.Path.GetFileNameWithoutExtension(moduleFile.FileName);

                        var moduleInfo = Manager.Install(moduleName, moduleFile.InputStream, ref log);

                        if (moduleInfo == null && log.Length != 0)
                        {
                            result.Success=false;
                            result.AddMessage(log.ToString());
                        }
                        else
                        {
                            result.RedirectUrl = Url.Action("InstallationCompleted", new { moduleName = moduleInfo.ModuleName });

                            //var moduleInstallUrl = moduleInfo.InstallUrl;
                            //if (string.IsNullOrEmpty(moduleInstallUrl))
                            //{
                            //    result.RedirectUrl = Url.Action("InstallationCompleted", new { moduleName = moduleInfo.ModuleName });
                            //}
                            //else
                            //{
                            //    result.RedirectUrl = Url.Action("InstallScaffold", new { moduleName = moduleInfo.ModuleName, installUrl = moduleInstallUrl });
                            //}
                        }
                    }
                }
            }
            catch (Exception e)
            {
                result.AddException(e);
            }

            result.AddModelState(ModelState);
            return Json(result);
        }
Esempio n. 2
0
 public virtual ActionResult Index(string body)
 {
     JsonResultEntry resultEntry = new JsonResultEntry(ModelState);
     try
     {
         Robots_Txt robot_txt = new Robots_Txt(Site);
         robot_txt.Save(body);
         resultEntry.AddMessage("The robots.txt has been saved.".Localize());
     }
     catch (Exception e)
     {
         resultEntry.AddException(e);
     }
     return Json(resultEntry);
 }
Esempio n. 3
0
 public virtual ActionResult Index(Repository model)
 {
     JsonResultEntry resultEntry = new JsonResultEntry(ModelState);
     try
     {
         if (ModelState.IsValid)
         {
             RepositoryManager.Update(model, RepositoryManager.Get(model.Name));
             resultEntry.AddMessage("Database setting has been changed.".Localize());
         }
     }
     catch (Exception e)
     {
         resultEntry.AddException(e);
     }
     return Json(resultEntry);
 }
Esempio n. 4
0
        public ActionResult Index(string siteName, ModuleInfo_Metadata moduleInfo)
        {
            JsonResultEntry resultEntry = new JsonResultEntry(ModelState);
            try
            {
                if (ModelState.IsValid)
                {
                    ModuleInfo.SaveModuleSetting(ModuleName, siteName, moduleInfo.Settings);
                    resultEntry.AddMessage("Module setting has been changed.".Localize());
                }

            }
            catch (Exception e)
            {
                resultEntry.AddException(e);
            }
            return Json(resultEntry);
        }
Esempio n. 5
0
        public virtual ActionResult ChangePassword(ChangePasswordModel model)
        {
            var entry = new JsonResultEntry();

            try
            {
                entry.Success = ServiceFactory.UserManager.ChangePassword(User.Identity.Name, model.OldPassword, model.NewPassword);
                if (!entry.Success)
                {
                    entry.AddMessage("Invalid old password.".Localize());
                }
            }
            catch (Exception e)
            {
                entry.AddException(e);
            }

            return Json(entry);
        }
Esempio n. 6
0
        public virtual ActionResult ClearCache()
        {
            JsonResultEntry resultEntry = new JsonResultEntry();

            try
            {
                Site.ClearCache();
                var repository = Site.GetRepository();
                if (repository != null)
                {
                    repository.ClearCache();
                }
                CacheManagerFactory.DefaultCacheManager.ClearGlobalObjectCache();

                resultEntry.AddMessage("The site cache has been cleared.");
            }
            catch (Exception e)
            {
                resultEntry.AddException(e);
            }

            return Json(resultEntry);
        }
Esempio n. 7
0
        public virtual ActionResult Index(Site model)
        {
            JsonResultEntry resultEntry = new JsonResultEntry(ModelState);
            try
            {
                if (ModelState.IsValid)
                {
                    var site = Site.AsActual();

                    //if (isNew)
                    //{
                    //    CreateRepository(model.Repository);
                    //}

                    site.DisplayName = model.DisplayName;
                    site.Culture = model.Culture;

                    site.Domains = model.Domains;
                    site.SitePath = model.SitePath;
                    site.Mode = model.Mode;
                    site.Repository = model.Repository;
                    site.Theme = model.Theme;
                    site.Version = model.Version;
                    site.InlineEditing = model.InlineEditing;
                    site.ShowSitemap = model.ShowSitemap;
                    site.Smtp = model.Smtp;
                    site.Security = model.Security;
                    site.ResourceDomain = model.ResourceDomain;
                    if (site.Smtp != null && site.Smtp.To != null)
                    {
                        site.Smtp.To = site.Smtp.To.Where(it => !string.IsNullOrEmpty(it)).ToArray();
                    }
                    site.CustomFields = model.CustomFields;
                    site.EnableVersioning = model.EnableVersioning;
                    site.EnableJquery = model.EnableJquery;
                    site.EnableStyleEdting = model.EnableStyleEdting;

                    ServiceFactory.SiteManager.Update(site);
                    resultEntry.AddMessage("Site setting has been changed.".Localize());
                }

            }
            catch (Exception e)
            {
                resultEntry.AddException(e);
            }
            return Json(resultEntry);
        }
Esempio n. 8
0
        public virtual ActionResult ResetTemplates(Schema[] model)
        {
            JsonResultEntry entry = new JsonResultEntry();
            try
            {
                if (model != null)
                {
                    foreach (var item in model)
                    {
                        ResetAllForm(item.Name);
                    }
                    entry.AddMessage("The templates have been reset.".Localize());
                }
            }
            catch (Exception e)
            {
                entry.SetFailed().AddException(e);
            }

            return Json(entry);
        }
Esempio n. 9
0
        public virtual ActionResult SwitchOffOn(string siteName)
        {
            var isOnLine = ServiceFactory.SiteManager.IsOnline(siteName);
            var entry = new JsonResultEntry();
            try
            {
                if (isOnLine)
                {
                    ServiceFactory.SiteManager.Offline(siteName);
                }
                else
                {
                    ServiceFactory.SiteManager.Online(siteName);
                }
                entry.AddMessage((isOnLine ? "Take offline " : "Take online").Localize()).SetSuccess();
            }
            catch (Exception e)
            {
                entry.AddException(e);
            }

            return Json(entry);
        }