Skip to content

Commit

Permalink
Troubleshooting + latest unmanaged/managed version of solution
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewButenko committed Jul 12, 2019
1 parent e7779a4 commit 882b073
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 104 deletions.
12 changes: 10 additions & 2 deletions AB.HtmlLocalization.Plugins/GetLocalizations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void Execute(IServiceProvider serviceProvider)

var jsWebResourcesQuery = new QueryExpression("webresource")
{
ColumnSet = new ColumnSet("dependencyxml")
ColumnSet = new ColumnSet("name", "dependencyxml")
};

jsWebResourcesQuery.Criteria.AddCondition("name", ConditionOperator.In, webResources);
Expand All @@ -44,11 +44,19 @@ public void Execute(IServiceProvider serviceProvider)
.Where(d => d.Attribute("name") != null).Select(d => d.Attribute("name").Value).Distinct());
});

if (dependentWebresources.Count == 0)
{
context.OutputParameters["Localizations"] = JsonConvert.SerializeObject(new Dictionary<string, string>());
return;
}

var resxWebResourcesQuery = new QueryExpression("webresource")
{
ColumnSet = new ColumnSet("content", "name")
};
resxWebResourcesQuery.Criteria.AddCondition("name", ConditionOperator.In, dependentWebresources.ToList<object>().ToArray());
//Webresource Type 12 - resx files - we need only those
resxWebResourcesQuery.Criteria.AddCondition("webresourcetype", ConditionOperator.Equal, 12);

var resxWebResources = service.RetrieveMultiple(resxWebResourcesQuery).Entities.ToList();

Expand All @@ -62,7 +70,7 @@ public void Execute(IServiceProvider serviceProvider)
var content = t.GetAttributeValue<string>("content");
content = Encoding.Default.GetString(Convert.FromBase64String(content)).Substring(3);
content = Encoding.Default.GetString(Convert.FromBase64String(content));
var contentDocument = XDocument.Parse(content);
Expand Down
27 changes: 16 additions & 11 deletions AB.HtmlLocalization.WebResources/ab_/HtmlLocalization.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,25 @@ AB.HtmlLocalization = (function () {
Xrm.WebApi.online.execute(ab_GetLocalizationRequest).then(
function success(result) {
if (result.ok) {
var results = JSON.parse(result.responseText);
result.json().then(function(results) {
var resultsObject = JSON.parse(results.Localizations);

var resultsObject = JSON.parse(results.Localizations);
for (var i in resultsObject) {
if (i === "DependencyNameToGuidMap") {
window[i] = JSON.parse(resultsObject[i]);
} else {
window[i] = resultsObject[i];
}
}

for (var i in resultsObject) {
if (i === "DependencyNameToGuidMap") {
window[i] = JSON.parse(resultsObject[i]);
} else {
window[i] = resultsObject[i];
}
}
resolve();
},
function(error) {
reject(error);
});
} else {
reject(new Error("Something went wrong during call of action..."));
}

resolve();
},
function (error) {
reject(error);
Expand Down
16 changes: 8 additions & 8 deletions AB.HtmlLocalization.WebResources/ab_/Localization.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
var Localization = (function () {

function localizeLabel() {
AB.HtmlLocalization.Initialize(["ab_/Localization.js"])
.then(function() {
var a = Xrm.Utility.getResourceString("ab_/Messages", "LocalizedMessage");
console.log("Localized Value - " + a);
},
function(e) {
console.log(e);
});
AB.HtmlLocalization.Initialize(["ab_/Localization.js"])
.then(function() {
var a = Xrm.Utility.getResourceString("ab_/Messages", "LocalizedMessage");
console.log("Localized Value - " + a);
},
function(e) {
console.log(e);
});
}

return {
Expand Down
115 changes: 32 additions & 83 deletions AB.HtmlLocalization.WebResources/spkl.json
Original file line number Diff line number Diff line change
@@ -1,121 +1,70 @@
{
{
"webresources": [
{
/*
Option - profile - Provide a comma delimitered list of profile names that can be referenced when calling spkl
*/
"profile": "default,debug",

/*
Optional - root - Provide the relatative path of the webresources.
*/
"root": "Webresources/",

/*
Optional - solution - Add webresources to a solution when deploying
*/
//"solution": "Default",

/*
Required - files - List the webresources to deploy relatative to the root of this file (or the the root parameter above)
*/
"solution": null,
"files": [
{
"uniquename": "new_/js/somefile.js",
"file": "new_\\js\\somefile.js",
"description": ""
"description": "",
"ts": null
},
{
"uniquename": "ab_/HtmlLocalization.js",
"file": "/ab_/HtmlLocalization.js",
"description": "",
"ts": null
},
{
"uniquename": "ab_/Localization.html",
"file": "/ab_/Localization.html",
"description": "",
"ts": null
},
{
"uniquename": "ab_/Localization.js",
"file": "/ab_/Localization.js",
"description": "",
"ts": null
},
{
"uniquename": "ab_/Messages.1033.resx",
"file": "/ab_/Messages.1033.resx",
"description": "",
"ts": null
}
]
}
],
"plugins": [
{
/*
Required - assemblypath - Relative path (from this file or the path parameter above) to the assembies to deply
Can be either plugins or workflow activities
Create multiple entries for different profiles
*/
"profile": "default,debug",
"assemblypath": "bin\\Debug"
/*
Optional - defines the regex to use to detect a plugin or workflow activity when using a custom base class
*/
//"classRegex": "((public( sealed)? class (?'class'[\\w]*)[\\W]*?)((?'plugin':[\\W]*?((IPlugin)|(PluginBase)|(Plugin)))|(?'wf':[\\W]*?CodeActivity)))"
"assemblypath": "bin\\Debug",
"classRegex": null
}
],
"earlyboundtypes": [
{
/*
Comma seperate list of entity logical names.
I've not provided support for -all- entities because this results in unneccessarily large plugins!
*/
"entities": "account,contact,quote",

/*
Comma seperated list of actions request/responses to generate - leave emtpty or ommit for none
*/
"actions": "dev1_simpleaction",

/*
Set to 'true' to generate Enums for optionsets
*/
"generateOptionsetEnums": "true",

/*
Set to 'true' to generate Enums for States and Statuses
*/
"generateStateEnums": "true",
/*
Set to 'true' to generate Enums for Global optionsets
*/
"generateOptionsetEnums": true,
"generateGlobalOptionsets": false,
/*
The path (relative to this file) to output
*/
"generateStateEnums": true,
"filename": "EarlyBoundTypes.cs",

/*
The namespace to put the classes under
*/
"classNamespace": "",

/*
The name of the Service context to create - leave blank or ommit for none
*/
"serviceContextName": "XrmSvc"
}
],
/*
The solutions section defines a solution that can be extracted to individual xml files to make
versioning of Dynamics metadata (entities, attributes etc) easier
*/
"solutions": [
{
"profile": "default,debug",
/*
The unique name of the solution to extract, unpack, pack and import
*/
"solution_uniquename": "spkltestsolution",
/*
The relative folder path to store the extracted solution metadata xml files
*/
"packagepath": "package",
/*
The relative path name of the solution to pack into
*/
"solutionpath": "solution_{0}_{1}_{2}_{3}.zip",
/*
Set to 'unmanaged' or 'managed' - default to 'unmanaged' if omitted
*/
"packagetype": "unmanaged",
/*
Set to 'true' to increment the minor version number before importing from the xml files
*/
"increment_on_import": false,

/*
Map code artefacts to the solution package folder
*/
"map": [
{
"map": "path",
Expand Down
Binary file not shown.
Binary file not shown.
Binary file removed Solutions/HtmlWebresourcesLocalization_1_0_0_0.zip
Binary file not shown.

0 comments on commit 882b073

Please sign in to comment.