public static string GetActivitySpecificDetails(this ActivityWrapper activityWrapper, RuleDefinitions ruleDefinitions) { var builder = new StringBuilder(); builder.Append(ConvertActivity(activityWrapper.Current, ruleDefinitions)); return(builder.ToString()); }
private void DocumentActivity(DocX body, ActivityWrapper childActivity) { body.DocumentLeafActivity(childActivity.Name); body.DocumentDescription(childActivity.GetDescription()); body.DocumentPlaceholders("Placeholder for Workflow Snapshot"); body.DocumentDependencies(childActivity.GetDependentList().ToCsv()); body.DocumentPlaceholders("Placeholder for Code/UI Snapshot"); body.DocumentDescription(childActivity.GetActivitySpecificDetails(_rulesExtractor.RuleDefinitions)); }
public static string GetTypeInformation(this ActivityWrapper activityWrapper) { var builder = new StringBuilder(); builder.AppendFormat("Type :{0}", activityWrapper.Current.GetType().FullName).AppendLine(); builder.AppendFormat("Depth:{0}", activityWrapper.Depth).AppendLine(); builder.AppendFormat("Root :{0}", activityWrapper.IsRoot).AppendLine(); builder.AppendFormat("Child:{0}", activityWrapper.Children.Count).AppendLine(); return(builder.ToString()); }
/* * private static string FormatUserData(System.Collections.IDictionary iDictionary) * { * var builder = new StringBuilder(); * foreach (var key in iDictionary.Keys) * { * builder.AppendFormat("Key: {0} Value: {1}", key, iDictionary[key] ?? "-").AppendLine(); * } * return builder.ToString(); * } */ private static string Translate(ActivityWrapper activityWrapper, string inputFromTemplate) { var regEx = new Regex("[$](?<props>[a-zA-Z0-9]*)"); MatchCollection matchCollection = regEx.Matches(inputFromTemplate); string output = inputFromTemplate; for (int matchCounter = 0; matchCounter < matchCollection.Count; matchCounter++) { Match match = matchCollection[matchCounter]; if (match.Success) // has some keywords { Group group = match.Groups["props"]; CaptureCollection captures = group.Captures; for (int i = 0; i < captures.Count; i++) { string key = captures[i].Value; switch (key) { case "name": output = output.Replace("$name", activityWrapper.Name); break; case "dependents": output = output.Replace("$dependents", activityWrapper.GetDependentList().ToCsv()); break; default: try { var value = activityWrapper.Current.GetPublicPropertValue <string>(key); output = output.Replace("$" + key, key + ":" + value); } catch { try { var value = activityWrapper.GetPublicPropertValue <string>(key); output = output.Replace("$" + key, key + ":" + value); } catch { output = output.Replace("$" + key, key + ":" + "TBD"); } } break; } } } } return(output); }
public static string GetDescription(this ActivityWrapper activityWrapper) { Activity activity = activityWrapper.Current; string key = activity.GetType().ToString(); try { TemplateRowModel data = _descriptionTemplate.GetTemplateFor(key); return(Translate(activityWrapper, data.Description)); } catch (KeyNotFoundException) { return(String.Format("TBD <<Please add a description here, or alternatively, provide a template for {0} >>", key)); } }
private void BuildActivities(DocX body, List <ActivityWrapper> rootActivities) { for (int i = 0; i < rootActivities.Count; i++) { ActivityWrapper wrapper = rootActivities[i]; if (wrapper.IsRoot) { body.DocumentRootActivity(wrapper.Name); } else { body.DocumentCompositeActivity(wrapper.Name); } var activityDetails = wrapper.GetActivitySpecificDetails(_rulesExtractor.RuleDefinitions); body.DocumentDescription(wrapper.GetDescription()); body.DocumentPlaceholders("Placeholder for Workflow Snapshot"); body.DocumentDependencies(wrapper.GetDependentList().ToCsv()); body.DocumentPlaceholders("Placeholder for Code/UI Snapshot"); body.DocumentDescription(activityDetails); if (wrapper.Children.Count > 0) // has some child activities { // composite activity with children for (int childCount = 0; childCount < wrapper.Children.Count; childCount++) { ActivityWrapper childActivity = wrapper.Children[childCount]; if (LevelToBeCaptured == -1) { DocumentActivity(body, childActivity); BuildActivities(body, childActivity.Children); } else // check for level { if (childActivity.Children.Count > 0 && childActivity.Path.Split('.').Length <= LevelToBeCaptured) { DocumentActivity(body, childActivity); BuildActivities(body, childActivity.Children); // composite activity with children } else if (childActivity.Children.Count > 0 && childActivity.Path.Split('.').Length > LevelToBeCaptured) // gone till 3rd level, so just document this { DocumentActivity(body, childActivity); } } } } } }
public IActionResult All() { if (!isLoggedIn) { return(RedirectToAction("Index", "Home")); } ActivityWrapper ActWrapper = new ActivityWrapper(); ActWrapper.AllActivities = db.Activities .Include(A => A.Activiting) .Include(A => A.PeopleJoining) .ThenInclude(Join => Join.activities) .OrderBy(A => A.Time) .ToList(); ActWrapper.LoggedUser = db.Users.FirstOrDefault(U => U.UserId == (int)uid); return(View("All", ActWrapper)); }