private void DrainWorkflowRule(CodeBuilder result, TapestryDesignerWorkflowRule workflowRule) { /// INIT IEnumerable <TapestryDesignerWorkflowItem> startingItems = _context.TapestryDesignerWorkflowItems.Where(i => i.ParentSwimlane.ParentWorkflowRule.Id == workflowRule.Id && (i.TypeClass == "uiItem" || i.SymbolType == "circle-single" || i.SymbolType == "envelope-start" || i.SymbolType == "circle-event")); // swimlane has starting item if (startingItems.Count() != workflowRule.Swimlanes.Count || startingItems.Select(wfi => wfi.ParentSwimlaneId).Except(workflowRule.Swimlanes.Select(sw => sw.Id)).Any()) { throw new TapestrySyntacticOmniusException("Each swimlane requires one starting item!"); } // starting item should be the same TapestryDesignerWorkflowItem defaultStartingItem = startingItems.FirstOrDefault(); foreach (TapestryDesignerWorkflowItem item in startingItems) { if (item.SymbolType != defaultStartingItem.SymbolType || item.ComponentName != defaultStartingItem.ComponentName) { throw new TapestrySyntacticOmniusException("Starting items has to be same for WorkflowRule"); } } // method name _methodName = workflowRule.Name.ToUpper() == "INIT" ? Tapestry.MethodName(null) : Tapestry.MethodName(defaultStartingItem.ComponentName); /// start build result.AppendLine($"public {(_methodName == Tapestry.MethodName(null) ? "override " : "")}void {_methodName}(string[] userRoleNames, Action<int, Block> _symbolAction)"); result.StartBlock(); /// swimlanes bool firstSwimlane = true; foreach (TapestryDesignerSwimlane swimlane in workflowRule.Swimlanes) { // roles if (!firstSwimlane) { result.Append("else "); } result.AppendLine($"if ({(string.IsNullOrEmpty(swimlane.Roles) ? "true" : string.Join("||", swimlane.Roles.Split(',').Select(r => $"userRoleNames.Contains(\"{r}\")")))})"); result.StartBlock(); /// WF (var item, int count) = DrainBranch(result, startingItems.Single(si => si.ParentSwimlaneId == swimlane.Id), BranchType.Method); if (item != null || count != 0) { _progressHandler.Warning("WF ends too soon"); } result.EndBlock(); // end if - roles firstSwimlane = false; } // has no required role result.AppendLine("else"); result.AppendLine($" throw new TapestryAuthenticationOmniusException(\"Authentication error\", \"{string.Join(",", workflowRule.Swimlanes.Select(sw => sw.Roles))}\" , string.Join(\",\", userRoleNames));"); result.EndBlock(); // end method }
private void GenerateInitBlock(string blockName) { CodeBuilder result = new CodeBuilder(); foreach (string use in _usings) { result.AppendLine($"using {use};"); } result.AppendLine($"namespace {Tapestry.BlockNamespace(_application.Name)}"); result.StartBlock(); result.AppendLine($"public class __INIT__ : {blockName}"); result.StartBlock(); result.AppendLine("public __INIT__(COREobject core) : base(core)"); result.AppendLine("{ }"); /// AppDomain //result.AppendLine("~__INIT__()"); //result.StartBlock(); //result.AppendLine("_core.Destroy();"); //result.EndBlock(); result.EndBlock(); result.EndBlock(); string filePath = Path.Combine(Tapestry.PathOutputTemp, $"App_{_application.Name}__INIT__.cs"); File.WriteAllText(filePath, result.ToString()); }
public void Display(Tapestry.TapestryNode frg) { ClearMappings(); List<ElementCloudItem> lst = new List<ElementCloudItem>(); foreach (Tapestry.TapestryNode f in frg.Children()) { lst.Add(ConvertToEci(f)); } RestartCloud(lst); }
private void ResolveContentControlForUri(Tapestry.TapestryNode frg) { if (frg.Children().Count() > 0) { ccBranch.Visibility = Visibility.Visible; ccLeaf.Visibility = Visibility.Collapsed; fragmentCloud.Display(frg); } else { ccBranch.Visibility = Visibility.Collapsed; ccLeaf.Visibility = Visibility.Visible; nodeDisplay.Display(frg); } }
private static string GetCurrentVersion(string ApplicationName) { string lastVersion = Tapestry.GetAssemblyVersion(ApplicationName); string todayVersionBegining = DateTime.UtcNow.ToString("yyyy.MM.dd."); // no version today if (lastVersion == null || !lastVersion.StartsWith(todayVersionBegining)) { return($"{todayVersionBegining}0000"); } int lastInt = Convert.ToInt32(lastVersion.Substring(lastVersion.LastIndexOf(".") + 1)); return($"{todayVersionBegining}{(lastInt + 1).ToString().PadLeft(4, '0')}"); }
private ElementCloudItem ConvertToEci(Tapestry.TapestryNode f) { ElementCloudItem eci = new ElementCloudItem(); eci.Height = 60; eci.MinWidth = 60; eci.Width = double.NaN; //equivalent to XAML Width="Auto" Button btn = new Button(); TextBlock tb = new TextBlock(); tb.Text = f.GetShortName(); tb.TextWrapping = TextWrapping.WrapWithOverflow; tb.Height = double.NaN; //equivalent to XAML Height="Auto" btn.Content = tb; btn.Click += Button_Click; eci.Children.Add(btn); mappings[btn] = f; return eci; }
public override bool Parallels(Tapestry.TapestryNode nd) { throw new NotImplementedException(); }
public FragmentClickedEventArgs(Tapestry.TapestryNode f) { Node = f; }
/// <summary> /// Compile workflow to dll file /// </summary> private void GenerateDll() { _progressHandler.SetMessage("T2_dll", "Generating dll", MessageType.InProgress); /// init string dllPath = Tapestry.FullDllName(Tapestry.PathOutput, _application.Name, _currentVersion); string tempDllPath = Tapestry.FullDllName(Tapestry.PathOutputTemp, _application.Name, _currentVersion); List <string> errors = new List <string>(); /// delete old file File.Delete(tempDllPath); /// files to compile IEnumerable <string> pathGeneratedfiles = Directory.EnumerateFiles(Tapestry.PathOutputTemp).Where(p => Path.GetFileName(p).StartsWith($"App_{_application.Name}_") && p.EndsWith(".cs")); /// compile config Process compileProcess = new Process(); compileProcess.StartInfo = new ProcessStartInfo { FileName = Path.Combine(Tapestry.PathSolutionRoot, "packages", "Microsoft.Net.Compilers.2.7.0", "tools", "csc.exe"), Arguments = $"/t:library /debug:pdbonly /out:{tempDllPath} {string.Join(" ", _resourceLinks.Select(r => $"/r:\"{r}\""))} {string.Join(" ", pathGeneratedfiles)}", RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, CreateNoWindow = true }; compileProcess.EnableRaisingEvents = true; compileProcess.OutputDataReceived += (sender, args) => { if (args.Data?.Contains("error ") ?? false) { errors.Add(args.Data); } else { Debug.WriteLine(args.Data); } }; compileProcess.ErrorDataReceived += (sender, args) => { if (args.Data?.Contains("error ") ?? false) { errors.Add(args.Data); } else { Debug.WriteLine(args.Data); } }; /// compile compileProcess.Start(); compileProcess.BeginOutputReadLine(); compileProcess.BeginErrorReadLine(); compileProcess.WaitForExit(); // OK if (File.Exists(tempDllPath)) { /// AppDomain //Tapestry.UnloadAppDomain(_application.Name); //File.Delete(dllPath); File.Move(tempDllPath, dllPath); Tapestry.RefreshAssembly(_application.Name); // debug try { string pdbPath = Tapestry.PdbName(dllPath); string tempPdbPath = Tapestry.PdbName(tempDllPath); File.Move(tempPdbPath, pdbPath); } catch (Exception) { _progressHandler.Warning("Can't override symbol file!"); } _progressHandler.SetMessage("T2_dll", "Generate dll - completed", MessageType.Success); } else { throw new OmniusMultipleException(errors.Select(e => new Exception(e)).ToList()); } }
private void GenerateBlock() { string blockName = _currentBlockCommit.Name.RemoveDiacritics(); string DisplayName = _currentBlockCommit.Name; string ModelName = _currentBlockCommit.ModelTableName; _threadMethods = new CodeBuilder(); _varNames = new HashSet <string>(); CodeBuilder result = new CodeBuilder(); // usings foreach (string use in _usings) { result.AppendLine($"using {use};"); } // class result.AppendLine($"namespace {Tapestry.BlockNamespace(_application.Name)}"); result.StartBlock(); string attribute = $"Name = \"{blockName}\", DisplayName = \"{_currentBlockCommit.Name}\""; if (!string.IsNullOrEmpty(_currentBlockCommit.ModelTableName)) { attribute += $", ModelTableName = \"{_currentBlockCommit.ModelTableName}\""; } else if (!string.IsNullOrEmpty(_currentBlockCommit.AssociatedTableName)) { attribute += $", ModelTableName = \"{_currentBlockCommit.AssociatedTableName.Split(',').First()}\""; } if (!string.IsNullOrEmpty(_currentBlockCommit.AssociatedBootstrapPageIds)) { attribute += $", BootstrapPageId = {_currentBlockCommit.AssociatedBootstrapPageIds.Split(',').First()}"; } if (!string.IsNullOrEmpty(_currentBlockCommit.AssociatedPageIds)) { attribute += $", MozaicPageId = {_currentBlockCommit.AssociatedPageIds.Split(',').Where(pId => _context.MozaicEditorPages.Find(Convert.ToInt32(pId))?.IsModal == false).First()}"; } result.AppendLine($"[Block({attribute})]"); result.AppendLine($"public class {blockName} : {_tapestryNameSpace}"); result.StartBlock(); result.AppendLine($"public {blockName}(COREobject core) : base(core)"); result.AppendLine("{ }"); /// AppDomain //result.AppendLine($"~{blockName}()"); //result.StartBlock(); //result.AppendLine("_core.Destroy();"); //result.EndBlock(); // ActionRule _progressHandler.SetMessage("T2_wfRule", progressSteps: _currentBlockCommit.WorkflowRules.Count); foreach (TapestryDesignerWorkflowRule workflowRule in _currentBlockCommit.WorkflowRules) { try { _currentWFRule = workflowRule; DrainWorkflowRule(result, workflowRule); _progressHandler.IncrementProgress("T2_wfRule"); } catch (TapestrySyntacticOmniusException ex) { ex.ApplicationName = _application.Name; ex.BlockName = _currentBlockCommit.Name; ex.WorkflowName = workflowRule.Name; throw; } catch (Exception ex) { throw new TapestrySyntacticOmniusException(ex.Message, _application.Name, _currentBlockCommit.Name, workflowRule.Name, ex); } } // thread method result.Append(_threadMethods); // variables foreach (var varName in _varNames) { result.AppendLine("[IsVariable]"); result.AppendLine($"public object {varName} {{ get; set; }}"); } result.EndBlock(); // end class result.EndBlock(); // end namespace string filePath = Path.Combine(Tapestry.PathOutputTemp, $"App_{_application.Name}_{blockName}.cs"); File.WriteAllText(filePath, result.ToString()); }