App_Handler/GetParSubLevel.ashx
(开头部分) 6KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<%@ WebHandler Language="C#" Class="GetParSubLevel" %>
using System;
using System.Web;
using System.Data;
using MicroDBHelper;
using Newtonsoft.Json.Linq;
using MicroPublicHelper;
using MicroAuthHelper;
/// <summary>
/// 有父和子项关系的表,获取它们的Level和LevelCode返回给前端
/// </summary>
public class GetParSubLevel : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
MicroAuth.CheckLogin();
string flag = string.Empty,
Action = context.Server.UrlDecode(context.Request.Form["action"]),
MID = context.Server.UrlDecode(context.Request.Form["mid"]),
Fields = context.Server.UrlDecode(context.Request.Form["fields"]);
//测试数据
//Fields = "{ \"idname\": \"DeptID\", \"val\": \"1\", \"stn\": \"Dept\"}";
if (!string.IsNullOrEmpty(Action) && !string.IsNullOrEmpty(Fields))
flag = GetLevel(Action, Fields);
context.Response.Write(flag);
}
private string GetLevel(string Action, string Fields)
{
string flag = string.Empty, strTpl = GetStrTpl(), ShortTableName = string.Empty, IDName = string.Empty, Value = string.Empty;
try
{
dynamic json = JToken.Parse(Fields) as dynamic;
ShortTableName = json["stn"]; IDName = json["idname"]; Value = json["val"];
//测试数据
//ShortTableName = "Dept"; IDName = "DeptID"; Value = "1";
string TableName = MicroPublic.GetTableName(ShortTableName);
//*****获取Level*****
//根据子节点得到所有父节点的数量,然后+1作为新的Level,返回给前端
string _sql = "with Temp AS( select * from " + TableName.toStringTrim() + " where " + IDName + "=" + Value.toInt() + " UNION ALL select t.* from Temp," + TableName.toStringTrim() + " t where Temp.ParentID=t." + IDName + ") select count(*) as q from Temp";
string Level = ((MicroPublic.GetSingleField(_sql, 0)).toInt()).ToString();
//*****获取LevelCode和Sort*****
string LevelCode = string.Empty, Sort = string.Empty;
if (!string.IsNullOrEmpty(Value) || Value != "0") //当Value不为空或不为0时(即有发生Select Change事件),
{
//获取当前节点的LevelCode(0101),然后+1作为新的LevelCode返回给前端
string _sql2 = "select * from " + TableName.toStringTrim() + " where ParentID=" + Value.toInt() + "";
DataTable _dt2 = MsSQLDbHelper.Query(_sql2).Tables[0];
if (_dt2 != null && _dt2.Rows.Count > 0) //当前节点的子节点不为空时
后面还有 91 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
