Solving: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

I was getting the error: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding, when the CloseActivity action was called on a BPT Action.

 

Cause

This was caused by a query in the OnClose action of the BPT action. This query was taking more then 30 seconds resulting in a SQL Server query timeout.

 

Solution

After tweaking the query the error was resolved.

 

4f28f0f1-8d43-4e0b-bc22-3fd624b7f387

Time of Log:

2013-11-11 09:49:09

eSpace:

Test

Tenant:

Users

User:

(7)

Session Id:

ldvw1leqzfsw55ze4zxopmz5

Server:

SERVER001

Module:

Message:

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

Stack:

at OutSystems.HubEdition.RuntimePlatform.Processes.ProcessBase.ThrowSpecificException(String failureMessage)
at OutSystems.HubEdition.RuntimePlatform.GenericExtendedActions.#Reb(HeContext heContext, Int32 activityId, Boolean advanceProcess, Boolean skip, Boolean skipAll, Action`4 activityChecks, List`1 inputs)
at OutSystems.HubEdition.RuntimePlatform.GenericExtendedActions.ActivityClose(HeContext heContext, Int32 activityId, String requiredssKey, String actionName, List`1 inputs, Int32& nextHumanActivityId)
at OutSystems.HubEdition.RuntimePlatform.GenericExtendedActions.ActivityClose(HeContext heContext, Int32 activityId, Int32& nextHumanActivityId)
at ssHRCallRegistration.Actions.ActionCloseActivityCustomAction(HeContext heContext, Int32 inParamActivityId)
at ssHRCallRegistration.Flows.FlowMainFlow.WBlkEnlistmentCreateDocuments.CommandDone(HeContext heContext)
-Env-
eSpaceVer: 725 (Id=2492, PubId=2461, CompiledWith=8.0.0.8)
RequestUrl: http://12.0.0.1/Test/Activity_View.aspx (Method: POST)
AppDomain: /LM/W3SVC/1/ROOT/Test-55-130286322452188885
FilePath: C:\…\PS\running\Test.0862112041\Activity_View.aspx
Locale: nl-NL
DateFormat: yyyy-MM-dd
PID: 1692 (‘w3wp’, Started=’11/8/2013 7:33:37 AM’, Priv=517Mb, Virt=5661Mb)
TID: 66
Thread Name:
.NET: 2.0.50727.6407

How to dynamically call an action in Outsystems, based on the eSpace name and Action name.

This post describes how to call an action in Outsystems, based on a given eSpace name and action name.

 

Lets says you want the user to select a action name from a dropdownlist and execute this action, then you can create a big switch statement to call the actions supplied in the dropdownlist, but if you don’t want to change this switch statement each time a new action is added to the list, then you have to create an Outsystems actions and write some C# code, to dynamically execute the action based on a given eSpace name and action name.

 

Extension

image

 

Visual Studio

image

 

C# code

namespace OutSystems.NssDynamicExtension {

using System;
using System.Collections;
using System.Data;
using OutSystems.HubEdition.RuntimePlatform;
using GotDotNet.ApplicationBlocks;
using System.Text;
using System.Linq;
using System.Reflection;

public class CssDynamicExtension: IssDynamicExtension {

/// <summary>
/// 
/// </summary>
/// <param name="ssresult"></param>
/// <param name="sseSpaceName"></param>
/// <param name="ssactionName"></param>
public void MssInvokeAction(out string ssresult, string sseSpaceName, string ssactionName) {
    ssresult = string.Empty;
    var messages = new StringBuilder(string.Empty);

    try
    {

        // Get all assemblies in current AppDomain.
        AppDomain currentDomain = AppDomain.CurrentDomain;
        Assembly[] assemblies = currentDomain.GetAssemblies();

        // Log all assemblynames.
        assemblies.ToList()
            .OrderBy(x => x.FullName).ToList()
            .ForEach(x => { messages.AppendLine(x.GetName().Name); });

        // Get eSpace assembly.
        Assembly eSpaceAssemlby = assemblies.ToList()
                    .First(x => x.GetName().Name.Equals(sseSpaceName, StringComparison.InvariantCultureIgnoreCase));

        // Get assembly that contians the "HeContext" type.
        Assembly runtimePlatform = assemblies.ToList()
                .First(x => x.GetName().Name.Equals("OutSystems.HubEdition.RuntimePlatform"));

        // Get the type that contains all actions from an eSpace.
        Type actionsType = eSpaceAssemlby.GetType(string.Format("ss{0}.Actions", sseSpaceName));

        // Get "HeContext" type (curent HttpContext object).
        Type contextType = runtimePlatform.GetType("OutSystems.HubEdition.RuntimePlatform.HeContext");

        // Create an instance of the "HeContext" type.
        object contextInstance = Activator.CreateInstance(contextType);

        // Invoke the given action and supply as first parameter the "HeContext" (curent HttpContext) object.
        actionsType.InvokeMember(string.Format("Action{0}", ssactionName), 
                                BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public, 
                                null, null, new object[] { contextInstance });
    }
    catch (Exception ex)
    {
        messages.AppendLine(ex.ToString());
    }

    ssresult = messages.ToString();
} // MssInvokeAction

} // CssDynamicExtension

} // OutSystems.NssDynamicExtension

 

Use the action in Outsystems

image

 

Result

image

 

The action that was dynamically invoked, inserted a record in the database and I could see this record was created, so everything worked just fine.

 

So instead of:

image

 

My code now looks like this:

 

image

 

 

Sometimes, reflection is your friend Smile.

How to debug across eSpaces in Outsystems

 

1. Set a breakpoint in the producer espace.
2. Tell the producer espace to "Debug in Public Area"
3. Tell the consumer espace to "Debug in Public Area"
4. Set the Entry eSpace, on consumer, by going to Debugger -> Select Entry eSpace
5. Do actions that should cause the breakpoint to be hit.

 

http://www.outsystems.com/forums/discussion/9314/debugging-across-espaces-does-not-always-work/

How to use entities from an other eSpace in Outsystems

Lets assume you have two eSpaces:

  • eSpace_1
  • eSpace_2

Now you want to use entities created in eSpace_1 in eSpace_2, then follow the steps below:

 

Open eSpace_1 with Outsystems Service Studio en go to the Data tab:

 

image

 

Click on the entity you want to expose in this case the entity "Test" and change:

Public to Yes

Expose Read Only to No

 

image

 

Publish eSpace_1

 

image

 

Now open eSpace_2 and Add a reference to eSpace_1

 

image

 

Change Show In Use to Show All and check the entities you want to include in eSpace_2

 

image

Uploading large files with Outsystems

If you want to upload "large" files e.g. <= 100MB, on any ASP .NET website, you must edit the web.config file.

There are many settings that you might want to update, when uploading large files e.g. session, request timeouts etc.

 

In this post I will only address the web.config attributes:

But the same steps can be used to update other elements / attributes in the web.config file.

 

Factory Configuration

In Outsystems, on every publish of a eSpace a new web.config file is produced. In order to update this new web.config file, we will have to use the Outsystems solution pack "Factory Configuration". Download the outsystems solution pack "Factory Configuration":http://www.outsystems.com/forge/component/25/Service+Center+Factory+Configuration/

(Service.Center.Factory.Configuration-8.0.0.osp = 325kb)

clip_image001

 

Click on 1-Click Publish

clip_image002

 

Open the page http://localhost/FactoryConfiguration in a browser.

clip_image003

Click on Shared Configurations

clip_image004

Click on Create New Shared Configuration

 

Paste in the XSLT from below:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<!-- 
Description
This xslt is used to add uploading of large files capabilities to a outsystems eSpace on IIS.
- It will upsert the attribute system.web/httpRuntime/@maxRequestLength (<=IIS6).
- It will upsert the attribute system.webServer/security/requestFiltering/requestLimits/@maxAllowedContentLength (>=IIS7).
-->
<!-- Just copy all other xml parts, that don't have a specific template match. -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="configuration">
<!-- Create an "configuration" element in the output document. -->
<configuration>
<!-- Copy child elements to output document. -->
<xsl:apply-templates select="@*|node()"/>
<!-- If the element "system.web" does not exist, create it in the output document. -->
<xsl:if test="count(system.web) = 0">
<system.web>
<httpRuntime maxRequestLength="102400"  />
</system.web>
</xsl:if>   
<!-- If the element "system.webServer" does not exist, create it in the output document. -->
<xsl:if test="count(system.webServer) = 0">
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="104857600"/>
</requestFiltering>
</security>
</system.webServer>
</xsl:if>
</configuration>
</xsl:template>
<!-- If the element "system.web/httpRuntime" does not exist, add it. -->
<xsl:template match="system.web[not(httpRuntime)]">
<system.web>
<xsl:apply-templates select="@*|node()"/>
<httpRuntime maxRequestLength="102400"  />
</system.web>
</xsl:template>
<!-- If the attribute "system.web/httpRuntime/@maxRequestLength" does not exist, add it. -->
<xsl:template match="system.web/httpRuntime[not(@maxRequestLength)]">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<xsl:attribute name="maxRequestLength">
<xsl:value-of select="'102400'"/>
</xsl:attribute>
</xsl:copy>
</xsl:template>
<!-- If the attribute "system.web/httpRuntime/@maxRequestLength" exists update it. -->
<xsl:template match="system.web/httpRuntime/@maxRequestLength">
<xsl:attribute name="maxRequestLength">
<xsl:value-of select="'102400'"/>
</xsl:attribute>
</xsl:template>
<!-- If the element "system.webServer/security" does not exist, add it. -->
<xsl:template match="system.webServer[not(security)]">
<system.webServer>
<xsl:apply-templates select="@*|node()"/>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="104857600"/>
</requestFiltering>
</security>
</system.webServer>
</xsl:template>
<!-- If the element "system.webServer/security/requestFiltering" does not exist, add it. -->
<xsl:template match="system.webServer/security[not(requestFiltering)]">
<security>
<xsl:apply-templates select="@*|node()"/>
<requestFiltering>
<requestLimits maxAllowedContentLength="104857600"/>
</requestFiltering>
</security>
</xsl:template>
<!-- If the element "system.webServer/security/requestFiltering/requestLimits" does not exist, add it. -->
<xsl:template match="system.webServer/security/requestFiltering[not(requestLimits)]">
<requestFiltering>
<xsl:apply-templates select="@*|node()"/>
<requestLimits maxAllowedContentLength="104857600"/>
</requestFiltering>
</xsl:template>
<!-- If the attribute "system.webServer/security/requestFiltering/requestLimits/@maxAllowedContentLength" does not exist, add it. -->
<xsl:template match="system.webServer/security/requestFiltering/requestLimits[not(@maxAllowedContentLength)]">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<xsl:attribute name="maxAllowedContentLength">
<xsl:value-of select="'104857600'"/>
</xsl:attribute>
</xsl:copy>
</xsl:template>
<!-- If the attribute "system.webServer/security/requestFiltering/requestLimits/@maxAllowedContentLength" exists update it. -->
<xsl:template match="system.webServer/security/requestFiltering/requestLimits/@maxAllowedContentLength">
<xsl:attribute name="maxAllowedContentLength">
<xsl:value-of select="'104857600'"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>

Now as you can see, I ‘m not a XSLT goeroe, so someone will tell me, this is a lot of XSLT code for something that simple, please do Smile.

 

 

Click on Create

clip_image005

Now the shared configuration is created, we must associate it to the eSpaces in which we want to use it.

 

Go to the eSpaces tab

clip_image006

 

Select "Add_upload_large_files_capabilities"

clip_image007

Click on Associate

 

 

Now on every publish of an eSpace the web.config of that eSpace will be altered to support uploading of large (<= 100MB) files. After deploying your eSpace, you can check the web.config on the filesystem of the server, to verify the changes were correctly executed. In my case, the web.config was found at: C:\Program Files\OutSystems\Platform Server\running\RliTest.0494247501