Exemple #1
0
        public ActionResult UpdateSectionTemplateAttachment(int sectionId, IList <SectionTemplateViewData> sectionTemplates)
        {
            var section = this._sectionService.GetSectionById(sectionId);

            try
            {
                foreach (var sectionTemplate in sectionTemplates)
                {
                    var template = this._templateService.GetTemplateById(sectionTemplate.TemplateId);
                    if (sectionTemplate.IsAttached)
                    {
                        this._templateService.AttachSectionToTemplate(section, template, sectionTemplate.Placeholder);
                    }
                    else
                    {
                        this._templateService.RemoveSectionFromTemplate(section, template);
                    }
                }
                Messages.AddFlashMessageWithParams("SectionAttachedMessage", section.Title);
            }
            catch (Exception ex)
            {
                Logger.Error("Unexpected error while attaching section to templates.", ex);
                Messages.AddFlashException(ex);
            }
            return(RedirectToAction("AttachSectionToTemplate", "Sections", new { id = sectionId }));
        }
        public ActionResult Uninstall(string moduleName)
        {
            ModuleType moduleType = this._moduleTypeService.GetModuleByName(moduleName);
            // First check if there are no sections attached
            IList <Section> sectionsByModuleType = this._sectionService.GetSectionsByModuleType(moduleType);

            if (sectionsByModuleType.Count > 0)
            {
                StringBuilder messageBuilder = new StringBuilder();
                messageBuilder.Append(GetText("UninstallModuleForbiddenBecauseOfRelatedSectionsMessage"));
                messageBuilder.Append(":<br />");
                foreach (var section in sectionsByModuleType)
                {
                    messageBuilder.AppendFormat("{0} ({1})<br />", section.Title, section.Id);
                }
                Messages.AddFlashMessage(messageBuilder.ToString());
            }
            else
            {
                try
                {
                    DatabaseInstaller dbInstaller = GetDbInstallerForModuleType(moduleType);
                    dbInstaller.Uninstall();
                    Messages.AddFlashMessageWithParams("ModuleUninstalledMessage", moduleName);
                }
                catch (Exception ex)
                {
                    Messages.AddFlashException(ex);
                }
            }
            return(RedirectToAction("Index"));
        }
Exemple #3
0
        public ActionResult Delete(int id)
        {
            Node nodeToDelete = this._nodeService.GetNodeById(id);
            Node parentNode   = nodeToDelete.ParentNode;

            try
            {
                string message = "PageDeletedMessage";
                if (nodeToDelete.IsExternalLink)
                {
                    message = "LinkDeletedMessage";
                }
                this._nodeService.DeleteNode(nodeToDelete);
                Messages.AddFlashMessageWithParams(message, nodeToDelete.Title);
                if (parentNode != null)
                {
                    return(RedirectToAction("Index", new { id = parentNode.Id }));
                }
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                Messages.AddFlashException(ex);
            }
            return(RedirectToAction("Index", new { id = nodeToDelete.Id }));
        }
Exemple #4
0
 public ActionResult RebuildIndex()
 {
     try
     {
         IEnumerable <ISearchable> legacySearchableModules = GetLegacySearchModulesForCurrentSite();
         this._searchService.RebuildIndex(legacySearchableModules);
         Messages.AddFlashMessage("FullTextIndexRebuildMessage");
     }
     catch (Exception ex)
     {
         Messages.AddFlashException(ex);
     }
     return(RedirectToAction("Index"));
 }
        public ActionResult SaveServiceRole(int userid, string RetypePassword)
        {
            if (userid <= 0)
            {
                throw new HttpRequestValidationException();
            }
            IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>();
            IRBACRoleProvider       _RoleProvider       = IoC.Resolve <IRBACRoleProvider>();
            Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;
            user    model      = _MemberShipProvider.GetUser(userid, false);

            if (HttpContext.User.Identity.Name == model.username)
            {
                Messages.AddErrorFlashMessage(Resources.Message.User_UMesCantEdit);
                return(RedirectToAction("ServiceRoleIndex"));
            }
            string oldpassHash = model.password;
            string username    = model.username;
            string email       = model.email;

            try
            {
                TryUpdateModel(model);
                model.username = username;
                if (model.password != RetypePassword)
                {
                    ViewData["RetypePassword"] = model.password;
                    Messages.AddErrorFlashMessage(Resources.Message.User_MesConfirmPass);
                    return(View("ServiceRoleEdit", model));
                }
                if (RetypePassword != oldpassHash)
                {
                    model.password = GeneratorPassword.EncodePassword(RetypePassword, model.PasswordFormat, model.PasswordSalt);//FormsAuthentication.HashPasswordForStoringInConfigFile(RetypePassword, "MD5");
                }
                model.FailedPasswordAttemptCount = 0;
                _MemberShipProvider.UpdateUser(model);
                _RoleProvider.UpdateUsersToRoles(model.username, new string[] { "ServiceRole" });
                Messages.AddFlashMessage(Resources.Message.User_UMesSuccess);
                log.Info("ServiceRoleUpdate by: " + HttpContext.User.Identity.Name + "Info-- tai khoan " + model.username);
                return(RedirectToAction("ServiceRoleIndex"));
            }
            catch (Exception ex)
            {
                ViewData["RetypePassword"] = model.password;
                log.Error("ServiceRoleUpdate-" + ex.Message);
                Messages.AddFlashException(ex);
                return(View("ServiceRoleEdit", model));
            }
        }
Exemple #6
0
        public ActionResult Delete(long id)
        {
            Article article = this._contentItemService.GetById(id);

            try
            {
                this._contentItemService.Delete(article);
                Messages.AddFlashMessageWithParams("ArticleDeletedMessage", article.Title);
            }
            catch (Exception ex)
            {
                Messages.AddFlashException(ex);
            }
            return(RedirectToAction("Index", GetNodeAndSectionParams()));
        }
Exemple #7
0
        public ActionResult Delete(int id)
        {
            FileResource fileResource = this._contentItemService.GetById(id);

            try
            {
                this._fileResourceService.DeleteFileResource(fileResource);
                Messages.AddFlashMessage("FileDeletedMessage");
            }
            catch (Exception ex)
            {
                Messages.AddFlashException(ex);
            }
            return(RedirectToAction("Index", "ManageFiles", GetNodeAndSectionParams()));
        }
        public ActionResult DeleteRole(int id)
        {
            Role role = this._userService.GetRoleById(id);

            try
            {
                this._userService.DeleteRole(role);
                Messages.AddFlashMessageWithParams("RoleDeletedMessage", role.Name);
            }
            catch (Exception ex)
            {
                Messages.AddFlashException(ex);
            }
            return(RedirectToAction("Roles"));
        }
Exemple #9
0
        public ActionResult SetPagePermissions(int id, int[] viewRoleIds, int[] editRoleIds, bool propagateToChildPages, bool propagateToChildSections)
        {
            Node node = this._nodeService.GetNodeById(id);

            try
            {
                this._nodeService.SetNodePermissions(node, viewRoleIds, editRoleIds, propagateToChildPages, propagateToChildSections);
                Messages.AddFlashMessageWithParams("PermissionsUpdatedMessage", node.Title);
            }
            catch (Exception ex)
            {
                Messages.AddFlashException(ex);
            }
            return(RedirectToAction("Index", new { id = id }));
        }
Exemple #10
0
        public ActionResult Delete(int id)
        {
            User user = this._userService.GetUserById(id);

            try
            {
                this._userService.DeleteUser(user);
                Messages.AddFlashMessageWithParams("UserDeletedMessage", user.UserName);
            }
            catch (Exception ex)
            {
                Messages.AddFlashException(ex);
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(int id)
        {
            Template template = this._templateService.GetTemplateById(id);

            try
            {
                this._templateService.DeleteTemplate(template);
                Messages.AddFlashMessageWithParams("TemplateDeletedMessage", template.Name);
            }
            catch (Exception ex)
            {
                Messages.AddFlashException(ex);
            }
            return(RedirectToAction("Index"));
        }
Exemple #12
0
        public ActionResult DeleteAlias(int id)
        {
            var siteAlias = this._siteService.GetSiteAliasById(id);

            try
            {
                this._siteService.DeleteSiteAlias(siteAlias);
                Messages.AddFlashMessageWithParams("SiteAliasDeletedMessage", siteAlias.Url);
            }
            catch (Exception ex)
            {
                Messages.AddFlashException(ex);
            }
            return(RedirectToAction("Aliases"));
        }
        public ActionResult Delete(int id)
        {
            Category category = this._categoryService.GetCategoryById(id);

            try
            {
                this._categoryService.DeleteCategory(category);
                Messages.AddFlashMessageWithParams("CategoryDeletedMessage", category.Name);
            }
            catch (Exception ex)
            {
                Messages.AddFlashException(ex);
            }
            return(RedirectToAction("Index"));
        }
        public ActionResult Upgrade(string moduleName)
        {
            ModuleType moduleType = this._moduleTypeService.GetModuleByName(moduleName);

            try
            {
                DatabaseInstaller dbInstaller = GetDbInstallerForModuleType(moduleType);
                dbInstaller.Upgrade();
                Messages.AddFlashMessageWithParams("ModuleUpgradedMessage", moduleName);
            }
            catch (Exception ex)
            {
                Messages.AddFlashException(ex);
            }
            return(RedirectToAction("Index"));
        }
Exemple #15
0
        public ActionResult DetachSectionFromPage(int nodeId, int sectionIdToDelete)
        {
            Section sectionToDetach = this._sectionService.GetSectionById(sectionIdToDelete);

            try
            {
                this._sectionService.DetachSection(sectionToDetach, nodeId);
                Messages.AddFlashMessageWithParams("SectionDetachedMessage", sectionToDetach.Title);
            }
            catch (Exception ex)
            {
                Logger.Error("Unexpected error while detaching section.", ex);
                Messages.AddFlashException(ex);
            }
            return(RedirectToAction("Design", "Pages", new { id = nodeId }));
        }
Exemple #16
0
        public ActionResult Delete(string path, string[] directories, string[] files)
        {
            var directoriesToDelete = directories != null?directories.Select(dir => Server.MapPath(dir)).ToArray() : new string[0];

            var filesToDelete = files != null?files.Select(file => Server.MapPath(file)).ToArray() : new string[0];

            try
            {
                this._fileManagerService.DeleteFilesAndDirectories(filesToDelete, directoriesToDelete);
                Messages.AddFlashMessage(GetText("FilesDirectoriesDeletedMessage"));
            }
            catch (Exception ex)
            {
                Messages.AddFlashException(ex);
            }
            return(RedirectToAction("List", new { Path = path }));
        }
Exemple #17
0
        public ActionResult CreateDirectory(string name, string parentPath)
        {
            VerifyAccessRights(parentPath);

            string physicalDirectory = Server.MapPath(parentPath + name);

            try
            {
                this._fileManagerService.CreateDirectory(physicalDirectory);
                Messages.AddFlashMessageWithParams(GetText("DirectoryCreatedMessage"), name);
            }
            catch (Exception ex)
            {
                Messages.AddFlashException(ex);
            }
            return(RedirectToAction("List", new { Path = parentPath }));
        }
Exemple #18
0
 public ActionResult Upload(string uploadpath, HttpPostedFileBase filedata)
 {
     if (filedata != null)
     {
         try
         {
             string physicalDataDirectory = Server.MapPath(uploadpath);
             string physicalFilePath      = Path.Combine(physicalDataDirectory, filedata.FileName);
             string fileNameAfterUpload   = this._fileManagerService.UploadFile(physicalFilePath, filedata.InputStream);
             Messages.AddFlashMessageWithParams(GetText("FileUploadSuccessMessage"), fileNameAfterUpload);
         }
         catch (Exception ex)
         {
             Messages.AddFlashException(ex);
         }
     }
     return(RedirectToAction("List", new { Path = uploadpath }));
 }
 public ActionResult Install(string moduleName)
 {
     try
     {
         string            moduleInstallDirectory = GetPhysicalModuleInstallDirectory(moduleName);
         DatabaseInstaller dbInstaller            = new DatabaseInstaller(moduleInstallDirectory, null);
         dbInstaller.Install();
         ModuleType moduleType = this._moduleTypeService.GetModuleByName(moduleName);
         moduleType.AutoActivate = true;
         this._moduleTypeService.SaveOrUpdateModuleType(moduleType);
         this._moduleLoader.ActivateModule(moduleType);
         Messages.AddFlashMessageWithParams("ModuleInstalledAndActivatedMessage", moduleName);
     }
     catch (Exception ex)
     {
         Messages.AddFlashException(ex);
     }
     return(RedirectToAction("Index"));
 }
Exemple #20
0
        public ActionResult Move(string path, string[] directories, string[] files, string pathTo)
        {
            var directoriesToMove = directories != null?directories.Select(dir => Server.MapPath(dir)).ToArray() : new string[0];

            var filesToMove = files != null?files.Select(file => Server.MapPath(file)).ToArray() : new string[0];

            var toDirectory = Server.MapPath(pathTo);

            try
            {
                this._fileManagerService.MoveFilesAndDirectories(filesToMove, directoriesToMove, toDirectory);
                Messages.AddFlashMessageWithParams(GetText("FilesDirectoriesMovedMessage"), pathTo);
            }
            catch (Exception ex)
            {
                Messages.AddFlashException(ex);
            }
            return(RedirectToAction("List", new { Path = path }));
        }
Exemple #21
0
        public ActionResult EditStatus(int id)
        {
            if (id <= 0)
            {
                throw new HttpRequestValidationException();
            }
            IDecisionService decSrc = IoC.Resolve <IDecisionService>();
            Decision         dec    = decSrc.Getbykey(id);

            try
            {
                string ErrMessage = "";
                if (dec.Status == 0)
                {
                    if (decSrc.SendDecision(dec, out ErrMessage) == true)
                    {
                        Messages.AddFlashMessage("Quyết định đã được gửi");
                    }
                    else
                    {
                        Messages.AddErrorFlashMessage(ErrMessage);
                    }
                }
                else if (dec.Status == 1)
                {
                    if (decSrc.ApproveDecision(dec, out ErrMessage))
                    {
                        Messages.AddFlashMessage("Quyết định đã được cơ quan thuế chấp nhận!");
                    }
                    else
                    {
                        Messages.AddErrorFlashMessage(ErrMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                Messages.AddFlashException(ex);
                log.Error("EditStatus-" + ex.Message);
            }
            return(RedirectToAction("DetailsDecision/" + id + ""));
        }
        public ActionResult Activate(string moduleName, bool autoActivate)
        {
            ModuleType moduleType = this._moduleTypeService.GetModuleByName(moduleName);

            try
            {
                moduleType.AutoActivate = autoActivate;
                this._moduleTypeService.SaveOrUpdateModuleType(moduleType);
                if (autoActivate)
                {
                    this._moduleLoader.ActivateModule(moduleType);
                    Messages.AddFlashMessageWithParams("ModuleActivatedMessage", moduleType.Name);
                }
                else
                {
                    Messages.AddFlashMessageWithParams("ModuleDeactivatedMessage", moduleType.Name);
                }
            }
            catch (Exception ex)
            {
                Messages.AddFlashException(ex);
            }
            return(RedirectToAction("Index"));
        }