protected override void ExecuteRemove(Base.Module.ModuleService moduleService)
{
string deleteSufix = "_MarkedForDelete";
switch (transContext)
{
case "BeginTransaction":
{
//we only rename folder to foldername_MarkedForDelete
string rootFolder = this.resource["RootFolder"].ToString();
if (rootFolder == "")
{
rootFolder = "c:\\ProvisioningModuleTestFolder\\";
}
if (rootFolder.Substring(rootFolder.Length - 1, 1) != "\\")
{
rootFolder += "\\";
}
string folderName = moduleService["Name"].ToString();
string folderFullPath = rootFolder + folderName;
if (Directory.Exists(folderFullPath))
{
Directory.Move(folderFullPath, folderFullPath + deleteSufix);
}
else
{
throw ExceptionHelper.GetModuleException("ID422009", null, null);
}
}
break;
case "CommitTransaction":
{
//we delete folder which have sufix deleteSufix
string rootFolder = this.resource["RootFolder"].ToString();
if (rootFolder == "")
{
rootFolder = "c:\\ProvisioningModuleTestFolder\\";
}
if (rootFolder.Substring(rootFolder.Length - 1, 1) != "\\")
{
rootFolder += "\\";
}
string folderName = moduleService["Name"].ToString();
string folderFullPath = rootFolder + folderName;
if (Directory.Exists(folderFullPath + deleteSufix))
{
Directory.Delete(folderFullPath + deleteSufix, true);
}
else
{
//if folder dont exist nothing to do //throw ExceptionHelper.GetModuleException("ID422009", null, null);
}
}
break;
case "RollBackTransaction":
{
//we should change name of folder folderFullPath + deleteSufix to folderFullPath
string rootFolder = this.resource["RootFolder"].ToString();
if (rootFolder == "")
{
rootFolder = "c:\\ProvisioningModuleTestFolder\\";
}
if (rootFolder.Substring(rootFolder.Length - 1, 1) != "\\")
{
rootFolder += "\\";
}
string folderName = moduleService["Name"].ToString();
string folderFullPath = rootFolder + folderName;
if (Directory.Exists(folderFullPath + deleteSufix))
{
Directory.Move(folderFullPath + deleteSufix, folderFullPath);
}
else
{
//if folder don't exist nothing to do //throw ExceptionHelper.GetModuleException("ID422009", null, null);
}
}
break;
}
}