How to get the dnn module version using c# - dnn9

I would like to get the version in a DotNetNuke Module.
I try:
new ModuleController().GetModule(this.ModuleId).ModuleVersion
but its always -1.
On the .dnn file I have this definition:
<package name="xxxx" type="Module" version="02.01.88">
How could I get the "02.01.88" string?

I just found that we could use:
new ModuleController().GetModule(this.ModuleId).DesktopModule.Version

Related

Define variables in csproj SDK style

I have converted a WPF project to the new csproj SDK format. It shows some properties such as:
Company: $(Authors)
Where do I define the variable $(Authors) and similar such variables? I am building my project both locally and in Azure DevOps.
This is MSBuild specific, it does not depend on SDK project style in particular, see:
Define and reference properties in a project file
Define a tag with the name of the property inside a PropertyGroup.
<Project Sdk="Microsoft.NET.Sdk">
<!-- ... -->
<PropertyGroup>
<Authors>John Doe, Jane Doe</Authors>
</PropertyGroup>
<!-- ... -->
</Project>
Since you refer to a property named Authors, you probably mean a special property that is used for NuGet packaging, see pack target inputs and Package properties.

Android Studio - PreferenceScreen not 'previewing'

I have a fresh new install of Android Studio 3.1.4 I wish to add a PreferenceScreen to my app (I'm just following a tutorial to add Settings panel). I read the docs step by step and I'm coding accordingly but I cannot understand why Android Studio is not rendering the PreferenceScreen.
This's the code of my PrefenceScreen:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<SwitchPreference
android:defaultValue="false"
android:key="switch_preference_1"
android:title="Switch preference" />
<EditTextPreference
android:defaultValue="Default value"
android:key="edit_text_preference_1"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="Edit text preference" />
</PreferenceScreen>
The layout preview is blank:
the preferences.xml file is located in \res\xml directory.
No errors/warning on build.
I ran into the same problem today but with a newer version of Android Studio.
I am using Android Studio 4.0.1 and the Android X libraries. I found an answer to a related question here: https://stackoverflow.com/a/53615855/5152586 which indicates that using the preferences screen layout requires the addition of preference dependency to the build.gradle file.
implementation 'androidx.preference:preference:1.1.1'
Adding that dependency to my build.gradle file worked for me and I can now see the rendered preview for my preference screen in the Layout Designer mode.
If you are not using the newest stuff yet, another answer (https://stackoverflow.com/a/54738703/5152586) to that same question indicated that the dependencies you'll need would be both the AppCompat and Preference dependencies from the support library.
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:preference-v7:28.0.0'

Angular: How can I use Velocity.js within my Angular application?

I have used velocity.js in my own personal web sites but never within an angular application. I'm not an angular developer (yet) so please bear with me.
I am following the README file on the angular-velocity github page. But when I run my application, I am getting an error that I am missing the module.
Here is what my module declaration looks like:
var appModule = angular.module('app.module', ['module-one', 'module-two', 'angular-velocity']);
...
The error I get now is:
Module 'angular-velocity' is not available! You either misspelled the module name or forgot to load it.
Further reading I see this:
When installing from npm, it is assumed that VelocityJS will be installed and loaded before Angular Velocity.
Ok, so I installed (via npm) the velocity library. How do I include that in my list of dependancies?
Also this:
angular-velocity assumes that the Angular core and the additional ngAnimate module is loaded
So does that mean I need something like this?
var appModule = angular.module('app.module', ['module-one', 'module-two', 'ngAnimate', 'angular-velocity']);
But in the example, all that is listed is angular-velocity.
Nowhere in my project do I see individual script tags. I am assuming the project just reads the dependancies and grabs them from the package.json file? (Completely guessing).
This does not happen:
<script src="bower_components/velocity/velocity.min.js"></script>
<script src="bower_components/velocity/velocity.ui.min.js"></script
<script src="bower_components/angular-velocity/angular-velocity.min.js"></script>
Thank you for any suggestions!
You can include velocity using CDN
<script src="//cdnjs.cloudflare.com/ajax/libs/velocity/1.2.3/velocity.min.js"></script>
<script src="//cdn.jsdelivr.net/velocity/1.2.3/velocity.min.js"></script>
or using bower
bower install velocity
and add its references in the header from default folder bower_components.
If instead you use npm you can use:
npm install velocity-animate
and add its references in the header from default folder node_modules.

How to Programatically Create Page on Module Installation?

I have a custom DNN module that I'm working on that I need to create an Admin Page when the module is installed within a DNN instance. I have creating the page handled, but getting code to run when the module is installed/upgraded is something I haven't figured out.
How do you wire up code to be executed as part of the installation/upgrade of a DNN module?
I've been successful with using IUpgradeable as part of the install. You specify a method in a core module class (FeatureController.cs if using the Christoc.com template) in the dnn install manifest file.
This [class].UpgradModule is executed after the app restart (happens after a module install/config change for the module version(s) specified).
It's quite "elegant"...the DNN install schedules an "eventexecution" as specified in the manifest and you can run whatever code you desire.
My manifest (modulename.dnn) had an eventMessage attribute (placed after the desktopModule element). Ex:
<eventMessage>
<processorType>DotNetNuke.Entities.Modules.EventMessageProcessor,DotNetNuke</processorType>
<processorCommand>UpgradeModule</processorCommand>
<attributes>
<businessControllerClass>SSI.DNN.SSIReplicationModule.Controllers.FeatureController, SSIReplicationModule</businessControllerClass>
<desktopModuleID>[DESKTOPMODULEID]</desktopModuleID>
<upgradeVersionsList>00.00.01</upgradeVersionsList>
</attributes>
</eventMessage>
Whatever is in:
<businessControllerClass>SSI.DNN.SSIReplicationModule.Controllers.FeatureController, SSIReplicationModule</businessControllerClass>
With the method name:
<processorCommand>UpgradeModule</processorCommand>
will get executed at install.
Hope that helps...if you need code for the page creation and module add let me know.
My first SO post ever!!
Apparently, there's a new way to do it, but so far I haven't found documentation. It looks like this:
<desktopModule>
...
<page type="Admin" common="true">
<name>Configuration Manager</name>
<icon>~/Icons/Sigma/Configuration_16X16_Standard.png</icon>
<largeIcon>~/Icons/Sigma/Configuration_32X32_Standard.png</largeIcon>
<description>Modify configuration settings for your site</description>
</page>
....
</desktopModule>
Not sure when this was added, but I found it in source code of DNN 8.0.3.

Add scala class to DataNucleus enhancer CLASSPATH

I am writing a Google App Engine web app and wish to use Scala on the server side. I'm using Eclipse and the Google App Engine plugin. However, as soon as I add an empty Scala class source file to my project, the DataNucleus enhancer warns:
SEVERE: Class "com.my.package.UserAccount" was not found in the
CLASSPATH. Please check your specification and your CLASSPATH.
I will eventually get round to making the class persistent but I want to get rid of this error first.
So far I've added the Scala Nature, and have tried cleaning the project and also restarting Eclipse but I always get the same warning issued from the enhancer.
Any ideas on what I can do to get the enhancer to run successfully?
I've struggled away with this for the last few days. Class not found errors thrown by the datanucleus enhancer on Scala classes occur because the scala-library.jar file isn't in the classpath when the enhancer runs. I've found two solutions:
Simple but cludgy: Copy scala-library.jar to the folder in eclipse/plugins which contains the enhancer. For me this is currently: /opt/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.5.5.r36v201110112027/appengine-java-sdk-1.5.5/lib/tools/orm
Switch off the enhancer builder in your project properties and create an ant file to run it manually. You can then properly control the classpath. I really struggled to get the scala-library into the classpath so gave up and copied it into the same folder as my datanucleus jars. My ant file if anyone's interested is:
<project name="DataNucleusEnhancer" default="enhance" basedir=".">
<property name="base.dir" location="/home/steve/Projects/DNProject"/>
<property name="datanucleus.libs" location="/home/steve/Projects/Jar Libraries/datanucleusjars"/>
<property name="sdk.dir" location="/opt/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.5.5.r36v201110112027/appengine-java-sdk-1.5.5"/>
<property name="classes.dir" location="${base.dir}/war/WEB-INF/classes/"/>
<property name="entities.dir" location="${base.dir}/war/WEB-INF/classes/packagenamehere/entities"/>
<path id="enhancer.classpath">
<fileset dir="${datanucleus.libs}" includes="*.jar" excludes="" />
<fileset dir="${sdk.dir}/lib/user" includes="*.jar" />
</path>
<target name="enhance" description="DataNucleus enhancement">
<taskdef name="datanucleusenhancer" classpathref="enhancer.classpath" classname="org.datanucleus.enhancer.tools.EnhancerTask" />
<datanucleusenhancer dir="${classes.dir}" failonerror="true" verbose="true">
<fileset dir="${entities.dir}" includes="**/*.class" />
<classpath>
<path location="${base.dir}/war/WEB-INF/classes/"/>
<path refid="enhancer.classpath"/>
</classpath>
</datanucleusenhancer>
</target>
</project>
In testing I also found the enhancer unwilling to enhance classes if I had no namespaces. I'm also concerned that I now need to manage the copy of scala-library.jar to make sure it's the same as in the scala eclipse plugin. It'd be much better if the gae plugin worked properly!
I tried the option 1 of steve's answer dropping the scala-library.jar in the eclipse plugin folder. It is still not solving yet. I then drop scala-library.jar in PROJECT/war/WEB-INF/lib/ and add it to Build Path. It works! So I undo option 1 of steve's answer by removing the scala-library.jar from the eclipse plugin folder and restart the eclipse. I try again and it still works! I am using eclipse 2.7.1, scala 2.9.1 and scala-ide 2.0.0

Resources