/// <summary> /// Gets the functions. /// </summary> /// <param name="type">The type.</param> /// <returns></returns> private static List <Models.Function> GetFunctions(Type type) { List <Models.Function> funcs = new List <Models.Function>(); type.GetMethods().ToList().Where((x) => x.ReturnType != typeof(void)).ToList().ForEach((n) => { if ((!n.Name.Contains("get_")) && (!n.Name.Contains("set_"))) { if (!Core.BaseFunctions.Contains(n.Name)) { var func = new Models.Function { Name = n.Name, Return = Regex.Replace(n.ReturnType.Name, TypingSetter, "[]"), Inputs = GetOverloads(n), Modifier = SetModifier(n) }; func.Documentation = DocumentService.GetFunctionDocumentation(type.Namespace, type.Name, func); funcs.Add(func); } } }); return(funcs); }
public async Task <IActionResult> CreateFunction(string pnum, CreateFunctionInputModel inputModel) { ViewBag.userMenu = GetMenu(); try { var id = (from u in context.RunningNumber where u.Type.Equals("FunctionID") select u).FirstOrDefault(); int num; if (id.Number == null) { num = 100001; } else { num = Convert.ToInt32(id.Number); num = num + 1; } var nameRFC = ""; if (inputModel.RSC.Equals("T")) { nameRFC = "[RFC]_" + inputModel.FunctionName; } else { nameRFC = inputModel.FunctionName; } Models.Function ord = new Models.Function { ProjectNumber = inputModel.ProjectNumber, TaskId = inputModel.TaskId, FunctionName = nameRFC, FunctionStart = inputModel.FunctionStart, FunctionEnd = inputModel.FunctionEnd, FunctionId = num.ToString() }; // Add the new object to the Orders collection. context.Function.Add(ord); await context.SaveChangesAsync(); var query = from xx in context.RunningNumber where xx.Type.Equals("FunctionID") select xx; foreach (RunningNumber RunFunctionID in query) { RunFunctionID.Number = num.ToString(); } // Submit the changes to the database. try { await context.SaveChangesAsync(); try { Models.TeamTask ord2 = new Models.TeamTask { FunctionId = num.ToString(), UserId = inputModel.UserId, ProjectResponsible = inputModel.ProjectResponsible, TaskId = inputModel.TaskId, ProjectNumber = inputModel.ProjectNumber }; context.TeamTask.Add(ord2); await context.SaveChangesAsync(); } catch (Exception x) { Console.WriteLine(x); } } catch (Exception e) { Console.WriteLine(e); // Provide for exceptions. } var SendBack = "false"; if (inputModel.RSC.Equals("T")) { SendBack = "true"; } return(RedirectToAction("CreateFunction", "ProjectManagement", new RouteValueDictionary( new { Controller = "ProjectManagement", Action = "CreateFunction", id = inputModel.TaskId, rsc = SendBack }))); } catch (Exception ex) { var message = ex.Message; return(View()); } }
internal static string GetFunctionDocumentation(string @namespace, string @class, Models.Function function) { string inputs = ""; string returnable = function.Return; function.Inputs.ForEach((x) => { inputs += "[" + string.Format("{0}: {1}", x.Name, Regex.Replace(x.Type.Name, Reflector.TypingSetter, "[]")) + "]"; }); return(string.Format(Templates.FunctionTemplate, function.Name, (string.IsNullOrEmpty(inputs) ? "N/A" : inputs), (string.IsNullOrEmpty(returnable) ? "Void" : returnable), GetXmlDocumentation(@namespace, @class, function.Name, function.Inputs).Sanitize())); }