public HttpResponseMessage GetGroupTreeInfoList(int page = 0, int limit = 0, string SearchName = "", int SearchStatus = 1) { IEnumerable <sys_group> ls = db.Sys_groupRepository.Get(fliter: e => !string.IsNullOrEmpty(SearchName) ? e.OuName.Contains(SearchName) : 1 == 1 && e.Status == SearchStatus, orderBy: q => q.OrderBy(e => e.ID), page: page, limit: limit); int Num = db.Sys_groupRepository.Num(fliter: e => !string.IsNullOrEmpty(SearchName) ? e.OuName.Contains(SearchName) : 1 == 1 && e.Status == SearchStatus); JArray jarray = RecursionData.RecursionToJson <sys_group>(ls, ls, new string[] { "OuID", "OuName" }, new string[2] { "value", "name" }, "ParentOuID", "OuID", "0"); var res = new { code = "", msg = "", count = Num, data = JToken.FromObject(jarray) }; return(new Models.JsonpResultAPI <object>(res)); }
private static void AdaptiveSimpsonsMethodCombinations2(Parameters p, float fightDuration, float epsilon, int maxRecursionDepth) { float a = 0.0f; float b = fightDuration; float c = (a + b) / 2; float h = b - a; int fa = 0; GetCombinedUptimeCombinations(p, a, fa); int fb = 1; GetCombinedUptimeCombinations(p, b, fb); int fc = 2; GetCombinedUptimeCombinations(p, c, fc); int S = 0; for (int i = 0; i < (1 << p.effects.Length); i++) { p.partialIntegral[0, i] = (h / 6) * (p.combinedUptime[fa, i] + 4 * p.combinedUptime[fc, i] + p.combinedUptime[fb, i]); } RecursionData[] stack = new RecursionData[2 * maxRecursionDepth]; int stackIndex = 0; stack[stackIndex].a = a; stack[stackIndex].b = b; stack[stackIndex].fa = fa; stack[stackIndex].fb = fb; stack[stackIndex].fc = fc; stack[stackIndex].S = S; stack[stackIndex].level = 1; stack[stackIndex].combine = false; stack[stackIndex].epsilon = epsilon; while (stackIndex >= 0) { if (stack[stackIndex].combine) { // we just computed both subintervals and we have to sum them up into S for (int i = 0; i < (1 << p.effects.Length); i++) { int Sleft = 2 * stack[stackIndex].level - 1; int Sright = 2 * stack[stackIndex].level; p.partialIntegral[stack[stackIndex].S, i] = p.partialIntegral[Sleft, i] + p.partialIntegral[Sright, i]; } // move down in stack stackIndex--; } else { c = (stack[stackIndex].a + stack[stackIndex].b) / 2; h = stack[stackIndex].b - stack[stackIndex].a; float d = (stack[stackIndex].a + c) / 2; float e = (c + stack[stackIndex].b) / 2; int fd = 1 + 2 * stack[stackIndex].level; GetCombinedUptimeCombinations(p, d, fd); int fe = 2 + 2 * stack[stackIndex].level; GetCombinedUptimeCombinations(p, e, fe); int Sleft = 2 * stack[stackIndex].level - 1; int Sright = 2 * stack[stackIndex].level; bool terminate = true; for (int i = 0; i < (1 << p.effects.Length); i++) { p.partialIntegral[Sleft, i] = (h / 12) * (p.combinedUptime[stack[stackIndex].fa, i] + 4 * p.combinedUptime[fd, i] + p.combinedUptime[stack[stackIndex].fc, i]); p.partialIntegral[Sright, i] = (h / 12) * (p.combinedUptime[stack[stackIndex].fc, i] + 4 * p.combinedUptime[fe, i] + p.combinedUptime[stack[stackIndex].fb, i]); if (!(maxRecursionDepth + 1 - stack[stackIndex].level <= 0 || (h < 10 && Math.Abs(p.partialIntegral[Sleft, i] + p.partialIntegral[Sright, i] - p.partialIntegral[stack[stackIndex].S, i]) <= 15 * stack[stackIndex].epsilon))) { terminate = false; } } if (terminate) { // terminal case, combine and drop stack for (int i = 0; i < (1 << p.effects.Length); i++) { p.partialIntegral[stack[stackIndex].S, i] = (p.partialIntegral[Sleft, i] + p.partialIntegral[Sright, i]) * 16.0f / 15.0f - p.partialIntegral[stack[stackIndex].S, i] / 15.0f; } stackIndex--; } else { // we'll need to go deeper, put children on stack and set us to combine after stack[stackIndex].combine = true; stack[stackIndex + 2].a = stack[stackIndex].a; stack[stackIndex + 2].b = c; stack[stackIndex + 2].fa = stack[stackIndex].fa; stack[stackIndex + 2].fb = stack[stackIndex].fc; stack[stackIndex + 2].fc = fd; stack[stackIndex + 2].S = Sleft; stack[stackIndex + 2].level = stack[stackIndex].level + 1; stack[stackIndex + 2].epsilon = stack[stackIndex].epsilon / 2; stack[stackIndex + 2].combine = false; stack[stackIndex + 1].a = c; stack[stackIndex + 1].b = stack[stackIndex].b; stack[stackIndex + 1].fa = stack[stackIndex].fc; stack[stackIndex + 1].fb = stack[stackIndex].fb; stack[stackIndex + 1].fc = fe; stack[stackIndex + 1].S = Sright; stack[stackIndex + 1].level = stack[stackIndex].level + 1; stack[stackIndex + 1].epsilon = stack[stackIndex].epsilon / 2; stack[stackIndex + 1].combine = false; stackIndex += 2; } } } }
protected static void LoadContainer(IUnityContainer unityContainer, string configFile, string containerName, ref RecursionData data) { var fileMap = new ExeConfigurationFileMap { ExeConfigFilename = configFile }; Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); // Parent configs to load. KeyValueConfigurationElement baseFiles = configuration.AppSettings.Settings["base"]; if (baseFiles != null) { string[] files = baseFiles.Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string file in files) { string baseFile = Path.Combine(Path.GetDirectoryName(configFile), file.Trim()); if (!File.Exists(baseFile)) { throw new FileNotFoundException(string.Format("Configuration file '{0}' not found", baseFile)); } // Recursively load parent files. LoadContainer(unityContainer, baseFile, containerName, ref data); } } UnityConfigurationSection unitySection = (UnityConfigurationSection)configuration.GetSection("unity"); // Copy aliases. IList <AliasElement> aliasElements = data.Aliases?.Where(x => unitySection.TypeAliases.All(y => y.Alias != x.Alias)).ToList(); if (aliasElements != null) { foreach (AliasElement aliasElement in aliasElements) { unitySection.TypeAliases.Add(new AliasElement { Alias = aliasElement.Alias, TypeName = aliasElement.TypeName }); } } // Copy namespaces. IList <NamespaceElement> namespaceElements = data.Namespaces?.Where(x => unitySection.Namespaces.All(y => y.Name != x.Name)).ToList(); if (namespaceElements != null) { foreach (NamespaceElement namespaceElement in namespaceElements) { unitySection.Namespaces.Add(new NamespaceElement { Name = namespaceElement.Name }); } } // Copy assemblies. IList <AssemblyElement> assembliesElements = data.Assemblies?.Where(x => unitySection.Assemblies.All(y => y.Name != x.Name)).ToList(); if (assembliesElements != null) { foreach (AssemblyElement assemblyElement in assembliesElements) { unitySection.Assemblies.Add(new AssemblyElement { Name = assemblyElement.Name }); } } data.Aliases = unitySection.TypeAliases; data.Assemblies = unitySection.Assemblies; data.Namespaces = unitySection.Namespaces; if (unitySection.Containers.Any(x => x.Name == containerName)) { unityContainer.LoadConfiguration(unitySection, containerName); } }