protected override void ExecuteAdd(Base.Module.ModuleService moduleService)
{
switch(transContext)
{
case "BeginTransaction":
{
string rootFolder = this.resource["RootFolder"].ToString();
if (rootFolder == "")
{
rootFolder = "c:\\ProvisioningModuleTestFolder\\";
}
if (rootFolder.Substring(rootFolder.Length - 1, 1) != "\\")
{
rootFolder += "\\";
}
string newFolderName = moduleService["Name"].ToString();
if (!Directory.Exists(rootFolder))
{
Directory.CreateDirectory(rootFolder);
}
string newFolderFullPath = rootFolder + newFolderName;
if (Directory.Exists(newFolderFullPath))
{
throw ExceptionHelper.GetModuleException("ID422008", null, null);
}
else
{
Directory.CreateDirectory(newFolderFullPath);
}
}
break;
case "CommitTransaction":
{
//folder is already added in BeginTransaction
//everything is OK and nothing to do
}
break;
case "RollBackTransaction":
{
//we should remove added folder
string rootFolder = this.resource["RootFolder"].ToString();
if (rootFolder == "")
{
rootFolder = "c:\\ProvisioningModuleTestFolder\\";
}
if (rootFolder.Substring(rootFolder.Length - 1, 1) != "\\")
{
rootFolder += "\\";
}
string newFolderName = moduleService["Name"].ToString();
string newFolderFullPath = rootFolder + newFolderName;
if (Directory.Exists(newFolderFullPath))
{
Directory.Delete(newFolderFullPath, true);
}
else
{
//nothing to do
}
}
break;
}
}