private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e) { IXsltFunction xsltFunction = DataFacade.BuildNew <IXsltFunction>(); xsltFunction.Id = Guid.NewGuid(); xsltFunction.Name = ""; xsltFunction.OutputXmlSubType = "XHTML"; xsltFunction.Description = ""; BaseFunctionFolderElementEntityToken folderToken = (BaseFunctionFolderElementEntityToken)this.EntityToken; xsltFunction.Namespace = folderToken.FunctionNamespace ?? UserSettings.LastSpecifiedNamespace; this.Bindings.Add("NewXslt", xsltFunction); var copyOfOptions = new List <KeyValuePair <Guid, string> >(); foreach (IXsltFunction function in DataFacade.GetData <IXsltFunction>()) { string fullName = function.Namespace + "." + function.Name; copyOfOptions.Add(new KeyValuePair <Guid, string>(function.Id, fullName)); } // Sorting alphabetically by function's full name copyOfOptions.Sort((a, b) => a.Value.CompareTo(b.Value)); copyOfOptions.Insert(0, new KeyValuePair <Guid, string>(Guid.Empty, GetText("AddNewXsltFunctionStep1.LabelCopyFromEmptyOption"))); this.Bindings.Add(Binding_CopyFromFunctionId, Guid.Empty); this.Bindings.Add(Binding_CopyFromOptions, copyOfOptions); }
public Dictionary <EntityToken, IEnumerable <EntityToken> > GetParents(IEnumerable <EntityToken> entityTokens) { Dictionary <EntityToken, IEnumerable <EntityToken> > result = new Dictionary <EntityToken, IEnumerable <EntityToken> >(); foreach (EntityToken entityToken in entityTokens) { string functionName = entityToken.Id; int index = functionName.LastIndexOf('.'); string folderName = functionName.Remove(index); string id = BaseFunctionProviderElementProvider.BaseFunctionProviderElementProvider.CreateId(folderName, _providerName); EntityToken resultEntityToken = new BaseFunctionFolderElementEntityToken(id); if (!result.TryGetValue(entityToken, out IEnumerable <EntityToken> resultEntityTokens)) { resultEntityTokens = new List <EntityToken>(); result.Add(entityToken, resultEntityTokens); } (resultEntityTokens as List <EntityToken>).Add(resultEntityToken); } return(result); }
/// <summary> /// Refreshed function tree for the currently used function provider element provider. /// </summary> public void RefreshFunctionTree() { WorkflowActionToken actionToken = (WorkflowActionToken)this.ActionToken; var entityToken = new BaseFunctionFolderElementEntityToken(actionToken.Payload, string.Empty); SpecificTreeRefresher specificTreeRefresher = this.CreateSpecificTreeRefresher(); specificTreeRefresher.PostRefreshMesseges(entityToken); }
public static string GetNamespace(this BaseFunctionFolderElementEntityToken entityToken) { int index = entityToken.Id.IndexOf('.'); if (index != -1) { return(entityToken.Id.Remove(0, index + 1)); } else { return(entityToken.Id); } }
private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e) { BaseFunctionFolderElementEntityToken token = (BaseFunctionFolderElementEntityToken)this.EntityToken; string @namespace = token.FunctionNamespace ?? UserSettings.LastSpecifiedNamespace; this.Bindings.Add(Binding_Name, string.Empty); this.Bindings.Add(Binding_Namespace, @namespace); var functionProvider = GetFunctionProvider <UserControlFunctionProvider>(); var copyOfOptions = new List <KeyValuePair <string, string> >(); copyOfOptions.Add(new KeyValuePair <string, string>(string.Empty, GetText("AddNewUserControlFunction.LabelCopyFromEmptyOption"))); foreach (string functionName in FunctionFacade.GetFunctionNamesByProvider(functionProvider.Name)) { copyOfOptions.Add(new KeyValuePair <string, string>(functionName, functionName)); } this.Bindings.Add(Binding_CopyFromFunctionName, string.Empty); this.Bindings.Add(Binding_CopyFromOptions, copyOfOptions); }
private void initializeCodeActivity_ExecuteCode(object sender, EventArgs e) { IMethodBasedFunctionInfo function = DataFacade.BuildNew <IMethodBasedFunctionInfo>(); BaseFunctionFolderElementEntityToken token = (BaseFunctionFolderElementEntityToken)this.EntityToken; string namespaceName = ""; int index = token.Id.IndexOf('.'); if (index > 0) { namespaceName = token.Id.Substring(index + 1); } function.Namespace = namespaceName; if (_lastAddedType != null) { function.Type = _lastAddedType; } this.Bindings.Add("UserMethodName", ""); this.Bindings.Add("NewMethodBasedFunction", function); }
private void saveCodeActivity_ExecuteCode(object sender, EventArgs e) { try { IXsltFunction xslt = this.GetBinding <IXsltFunction>("CurrentXslt"); IXsltFunction previousXslt = DataFacade.GetData <IXsltFunction>(f => f.Id == xslt.Id).SingleOrDefault(); IFile persistemTemplateFile = IFileServices.TryGetFile <IXsltFile>(xslt.XslFilePath); if (persistemTemplateFile != null) { string persistemTemplate = (persistemTemplateFile != null ? persistemTemplateFile.ReadAllText() : ""); if (this.GetBinding <int>("XslTemplateLastSaveHash") != persistemTemplate.GetHashCode()) { this.Bindings["XslTemplate"] = persistemTemplate; this.RerenderView(); ConsoleMessageQueueFacade.Enqueue(new LogEntryMessageQueueItem { Level = LogLevel.Fine, Message = "XSLT file on file system has been changed by another process. In-browser editor updated to reflect file on file system.", Sender = this.GetType() }, this.GetCurrentConsoleId()); } } string xslTemplate = this.GetBinding <string>("XslTemplate"); var parameters = this.GetBinding <IEnumerable <ManagedParameterDefinition> >("Parameters"); IEnumerable <NamedFunctionCall> FunctionCalls = this.GetBinding <IEnumerable <NamedFunctionCall> >("FunctionCalls"); if (FunctionCalls.Select(f => f.Name).Distinct().Count() != FunctionCalls.Count()) { ShowMessage(DialogType.Error, GetString("EditXsltFunctionWorkflow.SameLocalFunctionNameClashTitle"), GetString("EditXsltFunctionWorkflow.SameLocalFunctionNameClashMessage")); return; } using (TransactionScope transactionScope = TransactionsFacade.CreateNewScope()) { // Renaming related file if necessary string oldRelativePath = previousXslt.XslFilePath.Replace('\\', '/'); // This replace takes care of old paths having \ in them string newRelativePath = xslt.CreateXslFilePath(); if (string.Compare(oldRelativePath, newRelativePath, true) != 0) { var xlsFile = IFileServices.GetFile <IXsltFile>(previousXslt.XslFilePath); string systemPath = (xlsFile as FileSystemFileBase).SystemPath; // Implement it in another way? string xsltFilesRoot = systemPath.Substring(0, systemPath.Length - previousXslt.XslFilePath.Length); string newSystemPath = (xsltFilesRoot + newRelativePath).Replace('\\', '/'); if ((string.Compare(systemPath, newSystemPath, true) != 0) && C1File.Exists(newSystemPath)) { FlowControllerServicesContainer serviceContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId); var consoleMessageService = serviceContainer.GetService <IManagementConsoleMessageService>(); consoleMessageService.ShowMessage( DialogType.Error, GetString("EditXsltFunctionWorkflow.InvalidName"), GetString("EditXsltFunctionWorkflow.CannotRenameFileExists").FormatWith(newSystemPath)); return; } string directoryPath = Path.GetDirectoryName(newSystemPath); if (!C1Directory.Exists(directoryPath)) { C1Directory.CreateDirectory(directoryPath); } C1File.Move(systemPath, newSystemPath); xslt.XslFilePath = newRelativePath; // TODO: Implement removing empty Xslt directories } IFile file = IFileServices.GetFile <IXsltFile>(xslt.XslFilePath); file.SetNewContent(xslTemplate); ManagedParameterManager.Save(xslt.Id, parameters); DataFacade.Update(xslt); DataFacade.Update(file); this.Bindings["XslTemplateLastSaveHash"] = xslTemplate.GetHashCode(); DataFacade.Delete <INamedFunctionCall>(f => f.XsltFunctionId == xslt.Id); DataFacade.AddNew <INamedFunctionCall>(ConvertFunctionCalls(FunctionCalls, xslt.Id)); transactionScope.Complete(); } if (previousXslt.Namespace != xslt.Namespace || previousXslt.Name != xslt.Name || previousXslt.Description != xslt.Description) { // This is a some what nasty hack. Due to the nature of the BaseFunctionProviderElementProvider, this hack is needed BaseFunctionFolderElementEntityToken entityToken = new BaseFunctionFolderElementEntityToken("ROOT:XsltBasedFunctionProviderElementProvider"); RefreshEntityToken(entityToken); } SetSaveStatus(true); } catch (Exception ex) { LoggingService.LogCritical("XSLT Save", ex); FlowControllerServicesContainer serviceContainer = WorkflowFacade.GetFlowControllerServicesContainer(WorkflowEnvironment.WorkflowInstanceId); var consoleMsgService = serviceContainer.GetService <IManagementConsoleMessageService>(); consoleMsgService.ShowMessage(DialogType.Error, "Error", ex.Message); SetSaveStatus(false); } }