public override bool PerformDelete() { if (Alias.Contains(".") == false) { //there is no extension so we'll assume it's a folder ApplicationContext.Current.Services.FileService.DeleteScriptFolder(Alias.TrimStart('/')); } else { ApplicationContext.Current.Services.FileService.DeleteScript(Alias.TrimStart('/'), User.Id); } return(true); }
public override bool PerformDelete() { var fileService = (FileService)ApplicationContext.Current.Services.FileService; if (IsPartialViewMacro == false) { if (Alias.Contains(".") == false) { //there is no extension so we'll assume it's a folder fileService.DeletePartialViewFolder(Alias.TrimStart('/')); return(true); } return(fileService.DeletePartialView(Alias.TrimStart('/'), User.Id)); } if (Alias.Contains(".") == false) { //there is no extension so we'll assume it's a folder fileService.DeletePartialViewMacroFolder(Alias.TrimStart('/')); return(true); } return(fileService.DeletePartialViewMacro(Alias.TrimStart('/'), User.Id)); }
private string ValidateAlias() { string error = null; if (String.IsNullOrWhiteSpace(Alias)) { error = "Alias can't be empty"; } else { string[] UnallowedCharacters = { "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "{", "}" }; bool hasInvalidChars = false; for (int i = 0; i < UnallowedCharacters.Length; i++) { if (Alias.Contains(UnallowedCharacters[i])) { hasInvalidChars = true; error = "Alias contains invalid characters"; break; } } } return(error); }
public ReleaseIdentifierSubstitution(MemoryRepository repo, IColumn extractionIdentifierToSubFor, IExtractableCohort extractableCohort, bool isPartOfMultiCHISubstitution, IQuerySyntaxHelper querySyntaxHelper) : base(repo) { if (!extractionIdentifierToSubFor.IsExtractionIdentifier) { throw new Exception("Column " + extractionIdentifierToSubFor + " is not marked IsExtractionIdentifier so cannot be substituted for a ReleaseIdentifier"); } OriginalDatasetColumn = extractionIdentifierToSubFor; this._querySyntaxHelper = querySyntaxHelper; if (OriginalDatasetColumn.ColumnInfo == null) { throw new Exception("The column " + OriginalDatasetColumn.GetRuntimeName() + " references a ColumnInfo that has been deleted"); } var syntaxHelper = extractableCohort.GetQuerySyntaxHelper(); //the externally referenced Cohort table var externalCohortTable = extractableCohort.ExternalCohortTable; var privateIdentifierFieldDiscovered = externalCohortTable.Discover().ExpectTable(externalCohortTable.TableName).DiscoverColumn(externalCohortTable.PrivateIdentifierField); string collateStatement = ""; //the release identifier join might require collation //if the private has a collation if (!string.IsNullOrWhiteSpace(privateIdentifierFieldDiscovered.Collation)) { var cohortCollation = privateIdentifierFieldDiscovered.Collation; var otherTableCollation = OriginalDatasetColumn.ColumnInfo.Collation; //only collate if the server types match and if the collations differ if (privateIdentifierFieldDiscovered.Table.Database.Server.DatabaseType == OriginalDatasetColumn.ColumnInfo.TableInfo.DatabaseType) { if (!string.IsNullOrWhiteSpace(otherTableCollation) && !string.Equals(cohortCollation, otherTableCollation)) { collateStatement = " collate " + cohortCollation; } } } if (!isPartOfMultiCHISubstitution) { SelectSQL = extractableCohort.GetReleaseIdentifier(); Alias = syntaxHelper.GetRuntimeName(SelectSQL); } else { SelectSQL = "(SELECT DISTINCT " + extractableCohort.GetReleaseIdentifier() + " FROM " + externalCohortTable.TableName + " WHERE " + extractableCohort.WhereSQL() + " AND " + externalCohortTable.PrivateIdentifierField + "=" + OriginalDatasetColumn.SelectSQL + collateStatement + ")"; if (!string.IsNullOrWhiteSpace(OriginalDatasetColumn.Alias)) { string toReplace = extractableCohort.GetPrivateIdentifier(true); string toReplaceWith = extractableCohort.GetReleaseIdentifier(true); //take the same name as the underlying column Alias = OriginalDatasetColumn.Alias; //but replace all instances of CHI with PROCHI (or Barcode, or whatever) if (!Alias.Contains(toReplace) || Regex.Matches(Alias, Regex.Escape(toReplace)).Count > 1) { throw new Exception("Expected OriginalDatasetColumn " + OriginalDatasetColumn.Alias + " to have the text \"" + toReplace + "\" appearing once (and only once in it's name)," + "we planned to replace that text with:" + toReplaceWith); } Alias = Alias.Replace(toReplace, toReplaceWith); } else { throw new Exception("In cases where you have multiple columns marked IsExtractionIdentifier, they must all have Aliases, the column " + OriginalDatasetColumn.SelectSQL + " does not have one"); } } JoinSQL = OriginalDatasetColumn.SelectSQL + "=" + externalCohortTable.PrivateIdentifierField + collateStatement; }