StiMobileDesigner is an ASP.NET component for creating and editing reports in a web browser. In this article we will describe how to use this component in the cloud platform Azure.
First of all, it should be noted that the component StiMobileDesigner is based on the client-server technology. The cache is on the server side which means the cell for storing information with quick access. You can get any desired object from the cache or alternatively upload it to the cache. But if you load the report designer on Azure, then the stored version of an object can be saved in different server instances. Therefore, when saving the report to various server instances the problem occurs with its storage in the cache. In order to work correctly, it is necessary that the report is saved in the same cache.
To solve this problem we have created a class StiCacheHelper for each of the following components – StiMvcMobileDesigner, StiMvcMobileViewer, StiMobileDesigner, StiMobileViewer and allow the user to override the methods SaveObjectToCache and GetObjectFromCache. In these methods you can describe its own saving in the cache and removal of the object from the cache. In other words, you need to override the method and store any objects in its own cache, which greatly simplifies and speeds up work with reports on Azure.
class StiAzureCacheHelper : StiMobileViewer.StiCacheHelper
{
string SlsPath = RoleEnvironment.GetLocalResource("TestStorage").RootPath + "\\";
public override void SaveObjectToCache(object obj, string guid)
{
byte[] cacheData = GetCacheDataFromObject(obj);
System.IO.File.WriteAllBytes(SlsPath + guid, cacheData);
}
public override object GetObjectFromCache(string guid)
{
if (!System.IO.File.Exists(SlsPath + guid)) return null;
byte[] cacheData = System.IO.File.ReadAllBytes(SlsPath + guid);
return GetObjectFromCacheData(cacheData);
}
}
StiMobileViewer1.CacheHelper = new StiAzureCacheHelper();
First of all, it should be noted that the component StiMobileDesigner is based on the client-server technology. The cache is on the server side which means the cell for storing information with quick access. You can get any desired object from the cache or alternatively upload it to the cache. But if you load the report designer on Azure, then the stored version of an object can be saved in different server instances. Therefore, when saving the report to various server instances the problem occurs with its storage in the cache. In order to work correctly, it is necessary that the report is saved in the same cache.
To solve this problem we have created a class StiCacheHelper for each of the following components – StiMvcMobileDesigner, StiMvcMobileViewer, StiMobileDesigner, StiMobileViewer and allow the user to override the methods SaveObjectToCache and GetObjectFromCache. In these methods you can describe its own saving in the cache and removal of the object from the cache. In other words, you need to override the method and store any objects in its own cache, which greatly simplifies and speeds up work with reports on Azure.
class StiAzureCacheHelper : StiMobileViewer.StiCacheHelper
{
string SlsPath = RoleEnvironment.GetLocalResource("TestStorage").RootPath + "\\";
public override void SaveObjectToCache(object obj, string guid)
{
byte[] cacheData = GetCacheDataFromObject(obj);
System.IO.File.WriteAllBytes(SlsPath + guid, cacheData);
}
public override object GetObjectFromCache(string guid)
{
if (!System.IO.File.Exists(SlsPath + guid)) return null;
byte[] cacheData = System.IO.File.ReadAllBytes(SlsPath + guid);
return GetObjectFromCacheData(cacheData);
}
}
StiMobileViewer1.CacheHelper = new StiAzureCacheHelper();