Skip to content

Instantly share code, notes, and snippets.

@FembotDBA
Last active December 18, 2015 10:39
Show Gist options
  • Save FembotDBA/5769832 to your computer and use it in GitHub Desktop.
Save FembotDBA/5769832 to your computer and use it in GitHub Desktop.
MicroStrategy C# clear all caches
//live strings
string MSTRServer = "SERVERNAME";
string MSTRLogin = "LoginWithAdminRights";
string MSTRPwd = "Password";
int ProjNum = 4; //you would need to get the project number from MSTR
string projectSource = "Project Source Name";
string projectName = "Project Name";
DSSDataSource oServerDS = new DSSDataSource();
oServerDS.Type = EnumDSSDataSourceType.DssDataSourceTypeServer;
oServerDS.Mode = EnumDSSConnectionMode.DssConnectionModeServerAccess;
oServerDS.AuthMode = EnumDSSAuthModes.DssAuthStandard;
oServerDS.Location = MSTRServer;
oServerDS.port = 34952;
oServerDS.login = MSTRLogin;
oServerDS.Passwd = MSTRPwd;
try
{
oServerDS.Init();
IDSSSession oSession = oServerDS.CreateSession();
IDSSServerAdmin oServerAdmin = oSession.ServerAdmin;
IDSSProjectInstances oProjectList = oServerAdmin.get_ProjectInstances(EnumDSSRefreshOption.DssServerRefreshNo);
IDSSProjectInstance oProject = oProjectList.get_ItemByIndex(ProjNum);
int nProjID = oProject.ID;
DSSCOMMasterLib.IDSSServerAdmin myadmin = oSession.DataSource.ServerAdmin;
DSSCOMMasterLib.IDSSReportCacheAdmin mycache = (DSSCOMMasterLib.IDSSReportCacheAdmin)myadmin.get_CacheAdministrator(nProjID);
mycache.ExpireAllCaches(0);
if (oSession != null)
{
oServerDS.Reset();
oServerDS = null;
oSession.Close();
oSession = null;
}
}
catch(Exception e)
{
Console.WriteLine("Error rec'd: " + e.Message.ToString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment