private void IsValidData(object sender, ConditionalEventArgs e) { IXsltFunction function = this.GetBinding <IXsltFunction>("NewXslt"); e.Result = false; if (function.Name == string.Empty) { this.ShowFieldMessage("NewXslt.Name", GetText("AddNewXsltFunctionWorkflow.MethodEmpty")); return; } if (string.IsNullOrWhiteSpace(function.Namespace)) { this.ShowFieldMessage("NewXslt.Namespace", GetText("AddNewXsltFunctionWorkflow.NamespaceEmpty")); return; } if (!function.Namespace.IsCorrectNamespace('.')) { this.ShowFieldMessage("NewXslt.Namespace", GetText("AddNewXsltFunctionWorkflow.InvalidNamespace")); return; } string functionName = function.Name; string functionNamespace = function.Namespace; bool nameIsReserved = DataFacade.GetData <IXsltFunction>() .Where(func => string.Compare(func.Name, functionName, true) == 0 && string.Compare(func.Namespace, functionNamespace, true) == 0) .Any(); if (nameIsReserved) { this.ShowFieldMessage("NewXslt.Name", GetText("AddNewXsltFunctionWorkflow.DuplicateName")); return; } function.XslFilePath = function.CreateXslFilePath(); ValidationResults validationResults = ValidationFacade.Validate <IXsltFunction>(function); if (!validationResults.IsValid) { foreach (ValidationResult result in validationResults) { this.ShowFieldMessage(string.Format("{0}.{1}", "NewXslt", result.Key), result.Message); } return; } if (!function.ValidateXslFilePath()) { this.ShowFieldMessage("NewXslt.Name", GetText("AddNewXsltFunctionWorkflow.TotalNameTooLang")); return; } IXsltFile xsltfile = DataFacade.BuildNew <IXsltFile>(); xsltfile.FolderPath = System.IO.Path.GetDirectoryName(function.XslFilePath); xsltfile.FileName = System.IO.Path.GetFileName(function.XslFilePath); if (!DataFacade.ValidatePath(xsltfile, "XslFileProvider")) { this.ShowFieldMessage("NewXslt.Name", GetText("AddNewXsltFunctionWorkflow.TotalNameTooLang")); return; } e.Result = true; }
private void IsValidData(object sender, ConditionalEventArgs e) { IXsltFunction function = this.GetBinding <IXsltFunction>("CurrentXslt"); if (function.Name == string.Empty) { this.ShowFieldMessage("CurrentXslt.Name", GetString("EditXsltFunctionWorkflow.EmptyMethodName")); e.Result = false; return; } if (string.IsNullOrWhiteSpace(function.Namespace)) { this.ShowFieldMessage("CurrentXslt.Namespace", GetString("EditXsltFunctionWorkflow.NamespaceEmpty")); return; } if (!function.Namespace.IsCorrectNamespace('.')) { this.ShowFieldMessage("CurrentXslt.Namespace", GetString("EditXsltFunctionWorkflow.InvalidNamespace")); e.Result = false; return; } if (!(function.XslFilePath.StartsWith("\\") || function.XslFilePath.StartsWith("/"))) { this.ShowFieldMessage("CurrentXslt.Name", GetString("EditXsltFunctionWorkflow.InvalidFileName")); e.Result = false; return; } function.XslFilePath = function.CreateXslFilePath(); ValidationResults validationResults = ValidationFacade.Validate <IXsltFunction>(function); if (!validationResults.IsValid) { foreach (ValidationResult result in validationResults) { this.ShowFieldMessage(string.Format("{0}.{1}", "CurrentXslt", result.Key), result.Message); } return; } if (!function.ValidateXslFilePath()) { this.ShowFieldMessage("NewXslt.Name", GetString("AddNewXsltFunctionWorkflow.TotalNameTooLang")); return; } IXsltFile xsltfile = DataFacade.BuildNew <IXsltFile>(); xsltfile.FolderPath = System.IO.Path.GetDirectoryName(function.XslFilePath); xsltfile.FileName = System.IO.Path.GetFileName(function.XslFilePath); if (!DataFacade.ValidatePath(xsltfile, "XslFileProvider")) { this.ShowFieldMessage("CurrentXslt.Name", GetString("EditXsltFunctionWorkflow.TotalNameTooLang")); return; } e.Result = true; }