Sense/Net 6.0 Devblog
The development blog of Sense/Net 6.0
Back to Sense/Net

IT HAS ARRIVED! The New Resource Editor!!!

by Levente Dobson 20. February 2012 18:19

Type in the resources= parameter to the address bar:

If you are an Administrator, every string resource will be highlighted:

From here you can see immediately which labels can be localized on a page and which cannot. These are also links, so

CLICK!

Every language appears that has been configured in the Site's CTD, with the corresponding string resource values. If no value has been given yet, the textbox is empty.

The string resources can be freely edited here in-place, and the corresponding resource content will be updated:

I hope you already see how simple it became to create a localizable page and localize it.

The builder only needs to think of a classname and a stringresourcename, and place the appropriate code in the view:

This will appear with the default values on the UI.

CLICK!

SAVE:

And what is automatically generated in the background:

IT'S MORE FUN TO LOCALIZE.

Tags:

Localization

Localizing javascripts

by Levente Dobson 16. September 2011 18:18

Sense/Net comes with built-in Localization features to enable users to translate their sites and/or change language settings of pages by a single click. The CMS also provides means for developers to make javascripts localizable. This comes handy when you are developing Ajax features that create Html DOM elements with labels, or simply work with labels. To access a resource class, simply include the following tag at the very top of the javascript file:

// resource MyClass

This tag must be placed in the same block as all other javascript dependency definitions, like:

// using $skin/scripts/SN/SN.Util.js
// resource MyClass

From here onwards you are able to access the provided string resource keys via the SN.Resources object as simple strings. For example:

var labelText = SN.Resources.MyClass.LabelText;

The SN.Resource.<className> object contains all the keys that are defined in the CMS for the given class, for the actual language settings.

More information: http://wiki.sensenet.com/index.php?title=Localizing_javascripts

Tags:

GUI | Tips and tricks | Tutorial | Localization

Query template replacer

by János Lévai 16. September 2011 17:21

During projects it is sometimes necessary to use custom query templates. For example, if you want to gather content that was created not longer ago than one year with respect to the current date. In lucene query this is impossible to define, but you can always create your own custom template replacer. The trick here is to inherit from LucQueryTemplateReplacer. Here is an example from the product:

 

public class PortalLucQueryTemplateReplacer : RepositoryLucQueryTemplateReplacer
    {
        private static readonly string[] objectNames = new[] { "currentsite""currentworkspace"
            "currentpage""currentcontent" };
 
        public override IEnumerable<string> ObjectNames
        {
            get { return objectNames; }
        }
 
        public override string EvaluateObjectProperty(string objectName, string propertyName)
        {
            if (HttpContext.Current == null || PortalContext.Current == null)
                return base.EvaluateObjectProperty(objectName, propertyName);
 
            switch (objectName.ToLower())
            {
                case "currentsite":
                    return GetProperty(PortalContext.Current.Site, propertyName);
                case "currentworkspace":
                    return GetProperty(PortalContext.Current.ContextWorkspace, propertyName);
                case "currentpage":
                    return GetProperty(PortalContext.Current.Page, propertyName);
                case "currentcontent":
                    return GetProperty(PortalContext.Current.ContextNode, propertyName);
                default:
                    return base.EvaluateObjectProperty(objectName, propertyName);
            }
        }
    }  

 

 

Tags:

Tips and tricks | Tutorial | Content Query

Tutorial: Applying for a job position using Survey

by Attila Pápai 22. June 2011 15:47

Let's assume that you have an IT company and you're looking for new employees for a bigger project. You have a website powered by Sense/Net but you never created any Survey with it. This tutorial will help you to create a survey for people who applies to your job offer. At first our job is to figure out what questions we want to ask from the candidates.

Survey question planning

On the first page of the survey we gather some personal information:Your name

  • Date of birth
  • Work experience
  • Are you a student?

Since the candidate can be a student we would like to know which school is he or she attending to:

  • Name of school
  • Major
  • Expected graduation date

He or she might be graduated and have already had some work experience, right? These questions could be on the next page:

  • Have you worked in a team?
  • Have you ever led a team?
  • Programming skills

Working well in a team is a great strength especially when you're the leader of them. If the candidate was a leader, then:

  • How big was the team you led?

Finally, let's talk about money:

  • Expected gross salary

As you can see we defined five pages with different questions. These pages will be separated with Page breaks and we will specify rules to jump between these pages. For example if the candidate is a student then he or she will be asked about his or her education but not about work experience and those candidates who worked in a team will be asked about the size of their team as well in a separate page. Finally, all the candidates need to specify their expectations about salary. The following flowchart represents the survey:

Creating an empty survey

  1. Using the Explorer create an instance of Survey Content Type anywhere in your site and configure the general properties as it was describe in the Configuration section above
  2. In Explore mode click on the Manage questions action from the Settings scenario

Defining the questions

In the flowchart all the questions and page breaks are numbered by how the questions should follow each other. Every page with several questions is followed by a Page break except the last one.
In the following table you can see how the types of questions were defined:
QuestionField typeAvailable valuesOptions
Your name ShortText    
Date of birth DateTime   DateTime mode: Date
Work experience Choice less than 2 years
2-5 years
more than 5 years
Display choices: RadioButtons
Are you a student? YesNo Yes
No
 
PageBreak1 PageBreak   Rule:
Question: Are you a student?
Yes: 1
No: 2
Name of school ShortText    
Major ShortText    
Expected graduation date DateTime   DateTime mode: Date
PageBreak2 PageBreak   Rule:
Question: Are you a student?
Yes: 4
No: 4
Have you worked in a team? YesNo Yes
No
 
Have you ever led a team? YesNo Yes
No
 
Programming skills LongText    
PageBreak3 PageBreak   Rule:
Question: Have you ever led a team?
Yes: 3
No: 4
How big was the team you led? YesNo Yes
No
 
PageBreak4 PageBreak   Rule:
Expected gross salary ShortText  

You can create these questions by clicking on the Add field action and selecting the proper Field type.

Explanation of rules

  • Page1 rule - if the candidate is a student he or she will be redirected to Page #1 otherwise to Page #2
  • Page2 rule - we're dealing with a student so we don't want to ask questions about work experiences therefore he or she will be taken to Page #4
  • Page3 rule - if the candidate has already have experience in team work then we'd like to know more about it in Page #3 otherwise there's one more question left in Page #4
  • Page4 rule - since there's only one more page left we can leave this empty

Note: Page numbers are zero based. In other words, the first page is followed by the first page break, the second page is followed by the second page break and so on.

Summary

That's all folks. Easy as pie, isn't it? 
The flowchart has been created for a reason. It helps you build your survey. In a flowchart you can see how the user will be navigated between pages and with it setting up a survey is a lot easier. So it's recommended to create your own flowchart even using a pencil before you start any work in the portal.

You can read more about Survey in our wiki page: http://wiki.sensenet.com/index.php?title=Survey

Tags: ,

Tutorial

Integrating a SilverLight multi-file uploader control in Sense/Net

by Levente Dobson 27. May 2011 16:50

The current version of the portal uses a Flash multi-file uploader (http://www.swfupload.org/) to upload files to the Content Repository. This tool is fast and reliable, but since it uses Flash, it sometimes has trouble when the portal uses NTLM authentication, especially when accessed via Internet Explorer. For that reason it might be worthy to try some SilverLight upload controls, as they support NTML authentication natively. There are some great multiple file uploader controls on the web (ie.: SilverLight File Upload by darick_c or SilverLight Multi File Uploader by Michiel Post) that can be easily integrated into any existing Sense/Net solution. To do that, one will have to go through the following steps:

  • create an .ascx control to host the SilverLight application and handle upload parameters (ContentType, target path, etc.)
  • create a portlet to host the control to allow easy deployment for users
  • create a Smart Application Page with the portlet placed on it to be able to access upload functionality on folders with just by clicking on an action link
  • create a handler to process file uploads and place the uploaded files in the Content Repository

The above steps include a bit of coding and some page building, but the results are convincing. To see the detailed process on how to integrate a third-party SilverLight multi-file uploader in Sense/Net and to see an example for it check out this wiki article we have created. It shows some basic portal building techniques and walks you through the process of creating a new upload application step-by-step. It is a complete example of integrating one specific SilverLight uploader, but these uploaders work pretty much the same from the server perspective, so you should not have any problem in integrating any kind of file uploader to your Sense/Net solution:

Business Solution: Integrating a SilverLight multi-file uploader control

Props for darick_c for the great SilverLight multi-file uploader control!

 

Sense/Net important wiki docs

by Levente Dobson 16. May 2011 11:07

We don't usually post it if there are new wiki articles available at wiki.sensenet.com - we are constantly documenting new and old features. However, in the last core development sprint - in correspondence with some new stabilization features - a couple new important articles have been created, that relate to the topic of indexing and communication between application domains. It is highly recommended for everyone who uses Sense/Net to read these articles, as they may clarify a lot of things that were previously not well documented. These articles are:

Some other fresh wiki articles:

 

Tags:

Documentation | Tutorial

Tutorial: Customizing RegistrationWorkflow

by Attila Pápai 3. May 2011 22:34


RegistrationWorkflow contains a SendMail activity which sends a confirmation e-mail to the person who wants to register to your site. The content of the e-mail such as the subject and body are specified right inside the workflow definition (/Root/System/Workflows/RegistrationWorkflow.xaml). This short tutorial will show you how to localize and even customize these texts using String Resources.

We usually refer to the content which represents the WF4 Workflow in the repository as StateContent. It’s created when you start the desired workflow. Using StateContent is the best way to exchange information between a workflow and your Sense/Net powered portal. We could also say it’s kind of a gateway.

So what we need to do is:

  • Extend RegistrationWorkflow content type with two more fields
  • Create localized string resources
  • Create a custom content handler that handles extra fields
  • Modify workflow definition

Our first step is to add two more fields: EmailSubject and EmailBody to the Content Type Definition. These fields can be ShortText fields and hidden because we don’t need the user to see it.


<Field name="EmailSubject" type="ShortText">
  <DisplayName>EmailSubject</DisplayName>
  <Configuration>
    <VisibleBrowse>Hide</VisibleBrowse>
    <VisibleEdit>Hide</VisibleEdit>
    <VisibleNew>Hide</VisibleNew>
  </Configuration>
</Field>
<Field name="EmailBody" type="ShortText">
  <DisplayName>EmailBody</DisplayName>
  <Configuration>
    <VisibleBrowse>Hide</VisibleBrowse>
    <VisibleEdit>Hide</VisibleEdit>
    <VisibleNew>Hide</VisibleNew>
  </Configuration>
</Field>

Now we need the localized string resources. Open Content Explorer and create a new resource file under /Root/Localization or you can also extend an already existing file.
I added the following lines into RegistrationWorkflowResources.xml:


<?xml version="1.0" encoding="utf-8"?>
<Resources>
  <ResourceClass name="RegistrationWorkflow">
    <Languages>
      <Language cultureName="en">
        <data name="EmailBody" xml:space="preserve">
          <value>Please confirm your registration by visiting this url: {0}</value>
        </data>
        <data name="EmailSubject" xml:space="preserve">
          <value>Please confirm your registration</value>
        </data>
      </Language>
      <Language cultureName="hu">
        <data name="EmailBody" xml:space="preserve">
          <value>Kérjük erősítse meg a regisztrációját a következő linkre kattintva: {0}</value>
        </data>
        <data name="EmailSubject" xml:space="preserve">
          <value>Regisztráció megerősítése</value>
        </data>
      </Language>
    </Languages>
  </ResourceClass>
</Resources>

As you can see there's a parameter {0} in EmailBody. This will contain the confirmation link which is built up by two parts. First part defines the site URL and the second part specifies the URL of the confirmation action. The second part is only available after StateContent has been saved so that it will be added to the URL in the workflow definition.

Basically, overwriting system files is not a good approach so we’re not going to modify the RegistrationWorkflow content handler in order to set the values of the extra fields. We will create a new content handler instead and refer to it in the CTD. In our new content handler, called CustomRegistrationWorkflow, we need to override two Save() methods and implement our own logic then call the base method to do the rest of it:

[ContentHandler]
public class CustomRegistrationWorkflow : RegistrationWorkflow
{
  public CustomRegistrationWorkflow(Node parent) : this(parent, null) { }
  public CustomRegistrationWorkflow(Node parent, string nodeTypeName) : base(parent, nodeTypeName) { }
  protected CustomRegistrationWorkflow(NodeToken nt) : base(nt) { }

  public override void Save(){
      GenerateEmailContent();
      base.Save();
  }
  public override void Save(NodeSaveSettings settings){
      GenerateEmailContent();
      base.Save(settings);
  }
  private void GenerateEmailContent(){
      this["EmailSubject"] = SenseNetResourceManager.Current.GetString("RegistrationWorkflow", "EmailSubject");
      this["EmailBody"] = String.Format(SenseNetResourceManager.Current.GetString("RegistrationWorkflow", "EmailBody"), PortalContext.Current.RequestedUri.GetLeftPart(UriPartial.Authority));
  }
}

Don’t forget to change the handler in the CTD:


<ContentType name="RegistrationWorkflow" parentType="Workflow"handler="SenseNet.Workflow.CustomRegistrationWorkflow" xmlns="http://schemas.sensenet.com/SenseNet/ContentRepository/ContentTypeDefinition">

One more step left: modify the workflow definition.
The definition file can be found under the /Root/System/Workflows folder. Using Visual Studio you’re able to make the changes in a nice visual editor. Look for SendMail then change the Body and Subject parameters as follows:

Subject: CStr(StateContent("EmailSubject"))
Body: CStr(StateContent("EmailBody")) + ConfirmationItem.ActionUrl("Browse")

That’s pretty much of it. Now when a new user registrates he/she will be informed in the language of your site.

Tags: , ,

Tutorial

Preventing index corruptions

by Attila Pápai 27. April 2011 09:30

We were analyzing a specific anomaly in one of our sites and it helped us to find an issue which leads to corrupt indexes in case of AppPool recycles and AppDomain restarts.

The following workaround works from Sense/Net 6.0.0, till the latest 6.0.4. We suggest you to follow the steps below:

  1. Go to the Application Pool of your Site in IIS then click on Advanced Settings...
    • Under Recycling set Disable Overlapped Recycle to True. This prevents another worker process to be started as long as the current worker process is running.
    • Under Recycling set Recycling for Configuration Changes to True. By setting this you need to do the AppPool recycle manually to apply the changed configuration.
  2. Site must be shut down before updating DLL files.


More about the issue: AppDomain-AppPool-recycle.pptx

Tags: , ,

Tips and tricks

Sense/Net 6.0.4 Community Edition

by Attila Pápai 12. April 2011 12:55

If you have ever been thinking about managing your documents directly from Microsoft Office instead of constantly up- and downloading them to and from the portal, then it's high time you tried the latest version of Sense/Net with enhanced Office support! Our Office protocol implementation brings the whole Sense/Net Document Workspace experience right into the world of Word and Excel, enabling you to access literally every single part of your Workspaces using Office! And if you've thought this release cannot be more amazing, just have a look at our new Notification subsystem! If you want to recieve email on Content changes in the Content Repository, this release offers you the means by allowing you to easily subscribe to any Content and manage your subscriptions to get daily, weekly, monthly or immediate notifications! Sense/Net 6.0.4 is definiately a milestone in our product's history regarding enterprise features, but there is more! The core team has managed to enhance the portal's operating speed and lower overall response time by implementing complex caching functionality including level 2 cache and UI cache for logged in users. And as always: a lot of bug fixes make this release the most stable one among the previous versions, so don't hesitate to upgrade!

Installation

  • Before installing please read installation section on our wiki!
  • Please note that there might be issues when installing the package with WebPI to IIS 7.0. Should you encounter any problems during installation, please report the issue to our forum at http://forum.sensenet.com.
  • Application pools should be running with .NET 4
  • ASP.NET MVC 2 is required
  • ASP.NET MVC 3 is required

Office protocol

Managing workspace documents using Microsoft Office is a common feature of Enterprise Content Management Systems. Using Sense/Net you are able to create, modify or delete workspaces within Office. Editing and publishing documents into a workspace is as easy as managing tasks or links as well. There's no need to learn how to upload documents or other files into Sense/Net workspaces manually, it's done automatically while you're using Office. 

Read more: http://wiki.sensenet.com/index.php?title=Managing_Documents_from_Microsoft_Office

Notification

Notification is a feature for users who want to be informed about Content changes in the system. Users can subscribe to notifications for Content in the Content Repository to get notified about any changes made on these Content. 

Read more: http://wiki.sensenet.com/index.php?title=Notification

Changelog:

http://wiki.sensenet.com/index.php?title=ChangeLog_6.0.3_-_6.0.4

Production level config:

http://wiki.sensenet.com/index.php?title=Configuration_for_Production_Environment_-_version_6.0.4

Download link:

Sense/Net 6.0.4 Community Edition is available at Codeplex: http://sensenet.codeplex.com/releases/view/64249

Tags: ,

Announcement | Enterpise Portal | Enterprise Content Management

Fiddler as a system proxy cracks windows authentication

by Attila Pápai 31. March 2011 13:55

We are in the middle of a project where Fiddler makes our work easier with monitoring internet traffic between our web service and Microsoft Word.

Firstly, we set up our Sense/Net portal to use windows authentication to work with WebDAV and also associated the computer’s host name with the site because this is the only way for Fiddler to be able to monitor local traffic between our webservice and Word. There seemed to be a configuration problem in some computers when trying to open files associated to Word right from Sense/Net because the Windows Authentication Dialog popped up three times asking for credentials. On other computers it worked without asking for any username and password.

We spent hours trying to figure out what could possibly cause such an unwanted behavior but with no luck until we realized that when Fiddler wasn’t running, there was no problem. So we dug ourselves into Fiddler’s configuration and we found the following option “Act as system proxy on startup”. By turning off this guy made us the happiest people on the Earth, the issue described above disappeared like a grey donkey in the fog.
You can find this option under Tools \ Fiddler options… \ Connections.

Note that, turning off “Reuse client connections” and “Reuse connections to servers” may also help in same other cases.

Tags: , , ,

Tips and tricks

Bookmark and Share