public HttpResponseMessage Load(string Name)
        {
            var apiResponse = new DTO.ApiTemplateResponse();

            //1=control, 2=javascript.
            var controlName = string.Empty;

            switch (Name.ToLower())
            {
            case "pages":
                controlName = "Main.Pages";
                break;

            case "users":
                controlName = "Main.Users";
                break;

            case "modules":
                controlName = "Main.Modules";
                break;

            case "site":
                controlName = "Main.Site";
                break;

            case "host":
                controlName = "Main.Host";
                break;

            case "cache":
                controlName = "Main.Cache";
                break;

            default:

                break;
            }

            if (string.IsNullOrEmpty(controlName))
            {
                return(Request.CreateResponse(HttpStatusCode.NotAcceptable, false));
            }

            var fileName = DotNetNuke.Common.Globals.ApplicationMapPath + "\\desktopmodules\\nbrane\\administrationsuite\\controls\\" + controlName + ".html";

            if (!System.IO.File.Exists(fileName))
            {
                return(Request.CreateResponse(HttpStatusCode.NotAcceptable, false));
            }

            var fileContents = Regex.Replace(System.IO.File.ReadAllText(fileName), @"[\r\n\t ]+", " ");

            fileContents = System.Web.HttpUtility.HtmlEncode(fileContents);

            apiResponse.HTML = fileContents;

            fileName     = DotNetNuke.Common.Globals.ApplicationMapPath + "\\desktopmodules\\nbrane\\administrationsuite\\controls\\js\\" + controlName + ".js";
            fileContents = Regex.Replace(System.IO.File.ReadAllText(fileName), @"[\r\n\t ]+", " ");

            apiResponse.JS      = fileContents;
            apiResponse.Success = true;

            var response = Request.CreateResponse(HttpStatusCode.OK, apiResponse);

            return(response);
        }
Exemplo n.º 2
0
        public HttpResponseMessage Load(string Name)
        {
            var apiResponse = new DTO.ApiTemplateResponse();

            //1=control, 2=javascript.
            var controlName = string.Empty;

            switch (Name.ToLower())
            {
            case "pages":
                controlName = "Main.Pages";
                break;

            case "users":
                controlName = "Main.Users";
                break;

            case "modules":
                controlName = "Main.Modules";
                break;

            case "site":
                controlName = "Main.Site";
                break;

            case "host":
                controlName = "Main.Host";
                break;

            case "cache":
                controlName = "Main.Cache";
                break;

            case "configure":
                controlName = "Main.Configure";
                break;

            default:

                break;
            }

            if (string.IsNullOrEmpty(controlName))
            {
                return(Request.CreateResponse(HttpStatusCode.NotAcceptable, false));
            }

            var fileName = DotNetNuke.Common.Globals.ApplicationMapPath + "\\desktopmodules\\nbrane\\administrationsuite\\controls\\" + controlName + ".html";

            if (!System.IO.File.Exists(fileName))
            {
                return(Request.CreateResponse(HttpStatusCode.NotAcceptable, false));
            }

            var fileContents = Regex.Replace(System.IO.File.ReadAllText(fileName), @"[\r\n\t ]+", " ");

            fileContents = System.Web.HttpUtility.HtmlEncode(fileContents);

            apiResponse.HTML = fileContents;

            fileName     = DotNetNuke.Common.Globals.ApplicationMapPath + "\\desktopmodules\\nbrane\\administrationsuite\\controls\\js\\" + controlName + ".js";
            fileContents = Regex.Replace(System.IO.File.ReadAllText(fileName), @"[\r\n\t ]+", " ");


            if (fileContents.Contains("\"[data-bind: sslenabled]\""))
            {
                fileContents = fileContents.Replace("\"[data-bind: sslenabled]\"", PortalSettings.SSLEnabled.ToString().ToLower());
            }

            apiResponse.JS = fileContents;

            var result = Newtonsoft.Json.JsonConvert.SerializeObject(localizationProvider.GetCompiledResourceFile(PortalSettings, "/DesktopModules/nBrane/AdministrationSuite/Controls/App_LocalResources/" + controlName + ".resx", System.Threading.Thread.CurrentThread.CurrentCulture.Name));

            apiResponse.LANG = result;

            apiResponse.Success = true;

            var response = Request.CreateResponse(HttpStatusCode.OK, apiResponse);

            return(response);
        }