Esempio n. 1
0
        protected void btnExportResources_Click(object sender, EventArgs e)
        {
#if OnlineDemo
            this.ErrorDisplay.ShowError(WebUtils.LRes("FeatureDisabled"));
            return;
#endif

            DbResXConverter Exporter = new DbResXConverter(Context.Request.PhysicalApplicationPath);

            if (DbResourceConfiguration.Current.ResxExportProjectType == GlobalizationResxExportProjectTypes.WebForms)
            {
                if (!Exporter.GenerateLocalWebResourceResXFiles())
                {
                    ErrorDisplay.ShowError(WebUtils.LRes("ResourceGenerationFailed"));
                    return;
                }
                if (!Exporter.GenerateGlobalWebResourceResXFiles())
                {
                    ErrorDisplay.ShowError(WebUtils.LRes("ResourceGenerationFailed"));
                    return;
                }
            }
            else
            {
                if (!Exporter.GenerateResXFiles())
                {
                    ErrorDisplay.ShowError(WebUtils.LRes("ResourceGenerationFailed"));
                    return;
                }
            }

            ErrorDisplay.ShowMessage(WebUtils.LRes("ResourceGenerationComplete"));
        }
        public bool ExportResxResources(dynamic parms)
        {
#if OnlineDemo
            throw new ApplicationException(WebUtils.GRes("FeatureDisabled"));
#endif
            // Post:  {outputBasePath: "~\Properties", resourceSets: ["rs1","rs2"] }
            string outputBasePath = parms["outputBasePath"];

            string[] resourceSets = null;
            JArray   t            = parms["resourceSets"] as JArray;
            if (t != null)
            {
                resourceSets = t.ToObject <string[]>();
                if (resourceSets != null && resourceSets.Length == 1 && string.IsNullOrEmpty(resourceSets[0]))
                {
                    resourceSets = null;
                }
            }

            if (string.IsNullOrEmpty(outputBasePath))
            {
                outputBasePath = DbResourceConfiguration.Current.ResxBaseFolder;
            }
            else if (outputBasePath.StartsWith("~"))
            {
                outputBasePath = Context.Server.MapPath(outputBasePath);
            }

            outputBasePath = outputBasePath.Replace("/", "\\").Replace("\\\\", "\\");

            DbResXConverter exporter = new DbResXConverter(outputBasePath);

            if (DbResourceConfiguration.Current.ResxExportProjectType == GlobalizationResxExportProjectTypes.WebForms)
            {
                if (!exporter.GenerateLocalWebResourceResXFiles())
                {
                    throw new ApplicationException(WebUtils.GRes(STR_RESOURCESET, "ResourceGenerationFailed"));
                }
                if (!exporter.GenerateGlobalWebResourceResXFiles())
                {
                    throw new ApplicationException(WebUtils.GRes(STR_RESOURCESET, "ResourceGenerationFailed"));
                }
            }
            else
            {
                // if resourceSets is null all resources are generated
                if (!exporter.GenerateResXFiles(resourceSets))
                {
                    throw new ApplicationException(WebUtils.GRes(STR_RESOURCESET, "ResourceGenerationFailed"));
                }
            }

            return(true);
        }
        public bool ExportResxResources(string outputBasePath = null)
        {
#if OnlineDemo
            throw new ApplicationException(WebUtils.GRes("FeatureDisabled"));
#endif
            if (string.IsNullOrEmpty(outputBasePath))
            {
                outputBasePath = DbResourceConfiguration.Current.ResxBaseFolder;
            }
            else if (outputBasePath.StartsWith("~"))
            {
                outputBasePath = Context.Server.MapPath(outputBasePath);
            }

            outputBasePath = outputBasePath.Replace("/", "\\").Replace("\\\\", "\\");

            DbResXConverter exporter = new DbResXConverter(outputBasePath);

            if (DbResourceConfiguration.Current.ResxExportProjectType == GlobalizationResxExportProjectTypes.WebForms)
            {
                if (!exporter.GenerateLocalWebResourceResXFiles())
                {
                    throw new ApplicationException(WebUtils.GRes(STR_RESOURCESET, "ResourceGenerationFailed"));
                }
                if (!exporter.GenerateGlobalWebResourceResXFiles())
                {
                    throw new ApplicationException(WebUtils.GRes(STR_RESOURCESET, "ResourceGenerationFailed"));
                }
            }
            else
            {
                if (!exporter.GenerateResXFiles())
                {
                    throw new ApplicationException(WebUtils.GRes(STR_RESOURCESET, "ResourceGenerationFailed"));
                }
            }

            return(true);
        }
        public bool ExportResxResources(dynamic parms)
        {
#if OnlineDemo
            throw new ApplicationException(WebUtils.GRes("FeatureDisabled"));
#endif
            // Post:  {outputBasePath: "~\Properties", resourceSets: ["rs1","rs2"] }
            string outputBasePath = parms["outputBasePath"] ;

            string[] resourceSets = null;
            JArray t = parms["resourceSets"] as JArray;
            if (t != null)
            {
                resourceSets = t.ToObject<string[]>();
                if (resourceSets != null && resourceSets.Length == 1 && string.IsNullOrEmpty(resourceSets[0]))
                    resourceSets = null;
            }

            if (string.IsNullOrEmpty(outputBasePath))
                outputBasePath = DbResourceConfiguration.Current.ResxBaseFolder;
            else if (outputBasePath.StartsWith("~"))
                outputBasePath = Context.Server.MapPath(outputBasePath);

            outputBasePath = outputBasePath.Replace("/", "\\").Replace("\\\\", "\\");

            DbResXConverter exporter = new DbResXConverter(outputBasePath);

            if (DbResourceConfiguration.Current.ResxExportProjectType == GlobalizationResxExportProjectTypes.WebForms)
            {
                if (!exporter.GenerateLocalWebResourceResXFiles())
                    throw new ApplicationException(WebUtils.GRes(STR_RESOURCESET, "ResourceGenerationFailed"));
                if (!exporter.GenerateGlobalWebResourceResXFiles())
                    throw new ApplicationException(WebUtils.GRes(STR_RESOURCESET, "ResourceGenerationFailed"));
            }
            else
            {
                    // if resourceSets is null all resources are generated
                    if (!exporter.GenerateResXFiles(resourceSets))
                        throw new ApplicationException(WebUtils.GRes(STR_RESOURCESET, "ResourceGenerationFailed"));                
            }

            return true;
        }
        public bool ExportResxResources(string outputBasePath = null)
        {
#if OnlineDemo
            throw new ApplicationException(WebUtils.GRes("FeatureDisabled"));
#endif
            if (string.IsNullOrEmpty(outputBasePath))
                outputBasePath = DbResourceConfiguration.Current.ResxBaseFolder;
            else if(outputBasePath.StartsWith("~"))
                outputBasePath = Context.Server.MapPath(outputBasePath);

            outputBasePath = outputBasePath.Replace("/", "\\").Replace("\\\\", "\\");

            DbResXConverter exporter = new DbResXConverter(outputBasePath);

            if (DbResourceConfiguration.Current.ResxExportProjectType == GlobalizationResxExportProjectTypes.WebForms)
            {
                if (!exporter.GenerateLocalWebResourceResXFiles())
                    throw new ApplicationException(WebUtils.GRes(STR_RESOURCESET, "ResourceGenerationFailed"));
                if (!exporter.GenerateGlobalWebResourceResXFiles())
                    throw new ApplicationException(WebUtils.GRes(STR_RESOURCESET, "ResourceGenerationFailed"));
            }
            else
            {
                if (!exporter.GenerateResXFiles())
                    throw new ApplicationException(WebUtils.GRes(STR_RESOURCESET, "ResourceGenerationFailed"));
            }

            return true;
        }