コード例 #1
0
ファイル: PublicUser.ashx.cs プロジェクト: zj0532/knowledge
        /// <summary>
        /// 获取简单的用户列表
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string GetSimpleUserList(HttpContext context)
        {
            string userName = context.Request["user_name"] ?? "";
            string name     = context.Request["name"] ?? "";

            string order     = context.Request["order"] ?? "desc";       //排序
            int    rows      = Convert.ToInt32(context.Request["rows"]); //页大小
            int    page      = Convert.ToInt32(context.Request["page"]); //当前页
            int    pageCount = 0;                                        //页总数
            int    total     = 0;                                        //数据总数

            var       dbm         = DataBaseFactory.Instance.Create();
            Hashtable htCondition = new Hashtable();

            htCondition.Add("IsDelete", 0);

            if (userName != "")
            {
                htCondition.Add("UserName LIKE @UserName", new SqlParameter("@UserName", "%" + userName + "%"));
            }
            if (name != "")
            {
                htCondition.Add("Name LIKE @Name", new SqlParameter("@Name", "%" + name + "%"));
            }

            string field = "Id,UserName,Name";
            string table = "Sys_User";

            // 获取全部用户
            var dtUserList = dbm.GetDataTable("Id", field, table, htCondition, "Id DESC", page, rows, out total, out pageCount);

            return("{\"total\":" + total + ",\"rows\":" + JSONHelper.DataTable2Json(dtUserList) + "}");
        }
コード例 #2
0
        private string SMSList(HttpContext context)
        {
            var dbm = DataBaseFactory.Instance.Create();

            int rows      = Convert.ToInt32(context.Request["rows"]); //页大小
            int page      = Convert.ToInt32(context.Request["page"]); //当前页
            int pageCount = 0;                                        //页总数
            int total     = 0;                                        //数据总数

            var dt = dbm.GetDataTable("Id", "*", "Cus_Email", new Hashtable(), "Id desc", page, rows, out total, out pageCount);

            return("{\"total\":" + total + ",\"rows\":" + JSONHelper.DataTable2Json(dt) + "}");
        }
コード例 #3
0
        /// <summary>
        /// 获取知识点信息
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string getKnowInfo(HttpContext context)
        {
            var    dbm = DataBaseFactory.Instance.Create();
            string Id  = context.Request["Id"] ?? "";

            if (Id == "")
            {
                return("参数异常");
            }
            var dtKnow = dbm.GetDataTable("*", "Cus_Knowledge", Id, "Id");

            if (dtKnow.Rows.Count == 0)
            {
                return("没有找到指定的用户");
            }
            return(JSONHelper.DataTable2Json(dtKnow).Replace("[", "").Replace("]", ""));
        }
コード例 #4
0
        /// <summary>
        /// 知识点详细内容
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string getKnowDetailInfo(HttpContext context)
        {
            var    dbm = DataBaseFactory.Instance.Create();
            string Id  = context.Request["Id"] ?? "";

            if (Id == "")
            {
                return("参数异常");
            }
            string field = "Id,(select Text from Cus_CaseType where Id = OneValue) as OneValue,(select Text from Cus_CaseType where Id = TwoValue) as TwoValue,(select Text from Cus_CaseType where Id = ThreeValue) as ThreeValue,(select Text from Cus_CaseType where Id = FourValue) as FourValue,MalDescription,Solution,Created,CreateDate,Checked,MainReason";
            string table = "Cus_Knowledge";

            var dtKnow = dbm.GetDataTable(field, table, Id, "Id");

            if (dtKnow.Rows.Count == 0)
            {
                return("没有找到指定的用户");
            }
            return(JSONHelper.DataTable2Json(dtKnow).Replace("[", "").Replace("]", ""));
        }
コード例 #5
0
ファイル: PublicUser.ashx.cs プロジェクト: zj0532/knowledge
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string GetUserInfo(HttpContext context)
        {
            string userId = context.Request["Id"] ?? "";

            if (userId == "")
            {
                return("参数异常!");
            }

            //组合查询条件
            var dbm     = DataBaseFactory.Instance.Create();
            var dtOwner = dbm.GetDataTable("*", "Sys_User", userId, "Id");

            if (dtOwner.Rows.Count < 1)
            {
                return("没有找到指定的用户!");
            }

            //获取json字符串
            return(JSONHelper.DataTable2Json(dtOwner).Replace("[", "").Replace("]", ""));
        }
コード例 #6
0
        private string GetRoleList(HttpContext context)
        {
            Hashtable htCondition = new Hashtable();
            var       dbm         = DataBaseFactory.Instance.Create();

            // 先获取角色列表
            var dtRoleList = dbm.GetDataTable("Id,RoleName", "Sys_Role", htCondition, "Id DESC");

            // 是否需要根据用户选中指定角色
            int userId = 0;

            int.TryParse(context.Request["user_id"], out userId);
            if (userId > 0)
            {
                htCondition["UserId"] = userId;
                var dtUserRoleList = dbm.GetDataTable("RoleId", "Sys_UserRole", htCondition, "Id DESC");
                // 设置主键,用于查找
                //dtUserRoleList.PrimaryKey = new DataColumn[] { dtRoleList.Columns["RoleId"] };

                // 需要根据用户来选中行,新增列
                dtRoleList.Columns.Add(new DataColumn("checked", typeof(bool)));
                foreach (DataRow roleRow in dtRoleList.Rows)
                {
                    bool isExists = false;
                    foreach (DataRow userRoleRow in dtUserRoleList.Rows)
                    {
                        if (userRoleRow["RoleId"].ToString() == roleRow["Id"].ToString())
                        {
                            isExists = true;
                            break;
                        }
                    }

                    roleRow["checked"] = isExists;
                }
            }

            return(JSONHelper.DataTable2Json(dtRoleList));
        }
コード例 #7
0
ファイル: PublicUser.ashx.cs プロジェクト: zj0532/knowledge
        public string GetApproveUserListJson(HttpContext context)
        {
            string pkCorp = context.Request["pk_corp"];
            string roleId = context.Request["role_id"] ?? "";

            var dbm = DataBaseFactory.Instance.Create();

            // 根据角色ID找到角色下所有用户
            Hashtable htCondition = new Hashtable();

            GetUserCorpCondition(CurrentSigninUser, pkCorp, htCondition);
            htCondition.Add("a.RoleId = @RoleId", new SqlParameter("@RoleId", roleId));

            string field   = "DISTINCT b.Id,b.Name,d.RoleName";
            string table   = @"Sys_UserRole AS a 
				LEFT OUTER JOIN Sys_User AS b ON a.UserId=b.Id 
				LEFT OUTER JOIN Sys_UserCorp AS c ON a.UserId=c.UserId 
				LEFT OUTER JOIN Sys_Role AS d ON a.RoleId=d.Id"                ;
            var    dtUsers = dbm.GetDataTable(field, table, htCondition, "b.Id");

            return(JSONHelper.DataTable2Json(dtUsers));
        }
コード例 #8
0
        /// <summary>
        /// 知识点列表待审核
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string getCheckKnowlist(HttpContext context)
        {
            var dbm = DataBaseFactory.Instance.Create();

            int rows      = Convert.ToInt32(context.Request["rows"]); //页大小
            int page      = Convert.ToInt32(context.Request["page"]); //当前页
            int pageCount = 0;                                        //页总数
            int total     = 0;                                        //数据总数


            Hashtable htCondition = new Hashtable();

            htCondition.Add("Checked", "0");

            string field = "Id,(select Text from Cus_CaseType where Id = OneValue) as OneCaseType,OneValue,(select Text from Cus_CaseType where Id = TwoValue) as TwoCaseType,TwoValue,(select Text from Cus_CaseType where Id = ThreeValue) as ThreeCaseType,ThreeValue,(select Text from Cus_CaseType where Id = FourValue) as FourCaseType,FourValue,MalDescription,Solution,Created,CreateDate,Checked,MainReason";
            string table = "Cus_Knowledge";

            // 获取全部用户
            var dtKnowLedgeList = dbm.GetDataTable("Id", field, table, htCondition, "Id DESC", page, rows, out total, out pageCount);

            Console.Write(dtKnowLedgeList);
            return("{\"total\":" + total + ",\"rows\":" + JSONHelper.DataTable2Json(dtKnowLedgeList) + "}");
        }
コード例 #9
0
        /// <summary>
        /// 知识库列表
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>

        private string getKnowList(HttpContext context)
        {
            var dbm = DataBaseFactory.Instance.Create();

            int rows      = Convert.ToInt32(context.Request["rows"]); //页大小
            int page      = Convert.ToInt32(context.Request["page"]); //当前页
            int pageCount = 0;                                        //页总数
            int total     = 0;                                        //数据总数

            string OneValue        = context.Request["OneValue"] ?? "";
            string TwoValue        = context.Request["TwoValue"] ?? "";
            string ThreeValue      = context.Request["ThreeValue"] ?? "";
            string FourValue       = context.Request["FourValue"] ?? "";
            string MalDescription  = context.Request["MalDescription"] ?? "";
            string CreateDateStart = context.Request["CreateDateStart"] ?? "";
            string CreateDateEnd   = context.Request["CreateDateEnd"] ?? "";
            string Created         = context.Request["Created"] ?? "";

            Hashtable htCondition = new Hashtable();

            htCondition.Add("Checked", "1");
            if (OneValue != "")
            {
                htCondition.Add("OneValue", OneValue);
            }
            if (TwoValue != "")
            {
                htCondition.Add("TwoValue", TwoValue);
            }
            if (ThreeValue != "")
            {
                htCondition.Add("ThreeValue", ThreeValue);
            }
            if (FourValue != "")
            {
                htCondition.Add("FourValue", FourValue);
            }
            if (MalDescription != "")
            {
                htCondition.Add("MalDescription like @MalDescription", new SqlParameter("@MalDescription", "%" + MalDescription + "%"));
            }
            if (CreateDateStart != "")
            {
                htCondition.Add("CreateDate >= @CreateDateStart", new SqlParameter("@CreateDateStart", CreateDateStart));
            }
            if (CreateDateEnd != "")
            {
                htCondition.Add("CreateDate <= @CreateDateEnd", new SqlParameter("@CreateDateEnd", CreateDateEnd));
            }
            if (Created != "")
            {
                htCondition.Add("Created", Created);
            }

            string field = "Id,(select Text from Cus_CaseType where Id = OneValue) as OneCaseType,OneValue,(select Text from Cus_CaseType where Id = TwoValue) as TwoCaseType,TwoValue,(select Text from Cus_CaseType where Id = ThreeValue) as ThreeCaseType,ThreeValue,(select Text from Cus_CaseType where Id = FourValue) as FourCaseType,FourValue,MalDescription,Solution,Created,CreateDate,Checked,MainReason";
            string table = "Cus_Knowledge";

            // 获取全部用户
            var dtKnowLedgeList = dbm.GetDataTable("Id", field, table, htCondition, "Id DESC", page, rows, out total, out pageCount);

            return("{\"total\":" + total + ",\"rows\":" + JSONHelper.DataTable2Json(dtKnowLedgeList) + "}");
        }
コード例 #10
0
ファイル: BPM_User.ashx.cs プロジェクト: zj0532/knowledge
        public void ProcessRequest(HttpContext context)
        {
            string json   = string.Empty;
            string action = context.Request["action"] ?? "";

            Hashtable htCondition = new Hashtable();
            var       dbm         = DataBaseFactory.Instance.Create();

            switch (action)
            {
            case "auto_complete":      //用户表--全部-市场
            {
                var id = context.Request["id"] ?? "";
                htCondition.Clear();
                htCondition.Add("IsDelete", "0");
                string name = context.Request["q"] ?? "";
                name = name.TrimStart().TrimEnd();
                htCondition.Add("Name LIKE '" + string.Format("%{0}%", name) + "'", new SqlParameter("@m", "1"));
                if (!string.IsNullOrEmpty(id))
                {
                    htCondition.Add("Id", id);
                }
                //获取权限
                string   rolestring  = "";
                UserInfo currentUser = CurrentSigninUser;
                if (rolestring != "")
                {
                    htCondition.Add(" id in( select distinct userid from Sys_UserCorp where (" + rolestring + "))", new SqlParameter("@n", "1"));
                }

                var dtInfo = dbm.GetDataTable("Id as [Key],Name as [Value]", "Sys_User", htCondition, "Id");
                //添加一行空数据
                if (name == "")
                {
                    var row1 = dtInfo.NewRow();
                    row1[0] = "0";
                    row1[1] = "全部";
                    dtInfo.Rows.InsertAt(row1, 0);
                }
                json = JSONHelper.DataTable2Json(dtInfo);
            }
            break;

            case "auto_complete1":      //用户表-全部-协调
            {
                var id = context.Request["id"] ?? "";
                htCondition.Clear();
                htCondition.Add("IsDelete", "0");
                string name = context.Request["q"] ?? "";
                name = name.TrimStart().TrimEnd();
                htCondition.Add("Name LIKE '" + string.Format("%{0}%", name) + "'", new SqlParameter("@m", "1"));

                if (!string.IsNullOrEmpty(id))
                {
                    htCondition.Add("Id", id);
                }

                var dtInfo = dbm.GetDataTable("Id as [Key],Name as [Value]", "Sys_User", htCondition, "Id");
                //添加一行空数据
                if (name == "")
                {
                    var row1 = dtInfo.NewRow();
                    row1[0] = "0";
                    row1[1] = "全部";
                    dtInfo.Rows.InsertAt(row1, 0);
                }
                json = JSONHelper.DataTable2Json(dtInfo);
            }
            break;

            case "auto_xmjmcomplete":      //项目经理表--全部
            {
                var id = context.Request["id"] ?? "";
                htCondition.Clear();
                htCondition.Add("PersonName LIKE '" + string.Format("%{0}%", context.Request["q"] ?? "") + "'", new SqlParameter("@m", "1"));

                if (!string.IsNullOrEmpty(id))
                {
                    htCondition.Add("Id", id);
                }
                var dtInfo = dbm.GetDataTable("Id as [Key],PersonName as [Value]", "BPM_ProjectManager", htCondition, "Id");
                //添加一行空数据
                var row1 = dtInfo.NewRow();
                row1[0] = "0";
                row1[1] = "全部";
                dtInfo.Rows.InsertAt(row1, 0);
                json = JSONHelper.DataTable2Json(dtInfo);
            }
            break;

            case "auto_xmjmcomplete1":      //项目经理表
            {
                var id = context.Request["id"] ?? "";
                htCondition.Clear();
                htCondition.Add("PersonName LIKE '" + string.Format("%{0}%", context.Request["q"] ?? "") + "'", new SqlParameter("@m", "1"));

                if (!string.IsNullOrEmpty(id))
                {
                    htCondition.Add("Id", id);
                }
                var dtInfo = dbm.GetDataTable("Id as [Key],PersonName as [Value]", "BPM_ProjectManager", htCondition, "Id");
                json = JSONHelper.DataTable2Json(dtInfo);
            }
            break;

            default:
                break;
            }

            // 输出结果
            context.Response.ContentType = "text/plain";
            context.Response.Write(json);
        }
コード例 #11
0
ファイル: PublicUser.ashx.cs プロジェクト: zj0532/knowledge
        public string GetUserListJson(HttpContext context)
        {
            string userName  = context.Request["user_name"] ?? "";
            string name      = context.Request["name"] ?? "";
            string role      = context.Request["role"] ?? "";
            string oneArea   = context.Request["oneArea"] ?? "";
            string twoArea   = context.Request["twoArea"] ?? "";
            string threeArea = context.Request["threeArea"] ?? "";

            string order     = context.Request["order"] ?? "desc";       //排序
            int    rows      = Convert.ToInt32(context.Request["rows"]); //页大小
            int    page      = Convert.ToInt32(context.Request["page"]); //当前页
            int    pageCount = 0;                                        //页总数
            int    total     = 0;                                        //数据总数

            var       dbm         = DataBaseFactory.Instance.Create();
            Hashtable htCondition = new Hashtable();

            htCondition.Add("t.IsDelete = @IsDelete", new SqlParameter("@IsDelete", "0"));

            if (userName != "")
            {
                htCondition.Add("t.UserName LIKE @UserName", new SqlParameter("@UserName", "%" + userName + "%"));
            }
            if (name != "")
            {
                htCondition.Add("t.Name LIKE @Name", new SqlParameter("@Name", "%" + name + "%"));
            }
            if (role != "")
            {
                htCondition.Add("t.RoleNames LIKE @RoleName", new SqlParameter("@RoleName", "%" + role + "%"));
            }
            if (oneArea != "")
            {
                htCondition.Add("OneArea", oneArea);
            }
            if (twoArea != "")
            {
                htCondition.Add("TwoArea", twoArea);
            }
            if (threeArea != "")
            {
                htCondition.Add("ThreeArea", threeArea);
            }

            string field = "t.Id,t.UserName,t.Name,t.Phone,t.Email,t.Address,t.Enable,t.OneArea,t.TwoArea,t.ThreeArea,t.RoleIds,t.RoleNames";
            //string table = "Sys_User";
            StringBuilder sbTable = new StringBuilder();

            sbTable.Append("(select Id,UserName,Name,Phone,Email,Address,Enable,OneArea,TwoArea,ThreeArea,IsDelete,");
            sbTable.Append("(select cast(ro.Id as varchar(15)) + ',' from Sys_UserRole ur left join Sys_Role ro on ur.RoleId=ro.Id where ur.UserId=u.Id for xml path('')) RoleIds,");
            sbTable.Append("(select ro.RoleName + ',' from Sys_UserRole ur left join Sys_Role ro on ur.RoleId=ro.Id where ur.UserId=u.Id for xml path('')) RoleNames ");
            sbTable.Append("from Sys_User u) t");

            // 获取全部用户
            var dtUserList = dbm.GetDataTable("t.Id", field, sbTable.ToString(), htCondition, "t.Id DESC", page, rows, out total, out pageCount);

            // 处理掉过长的数据
            dtUserList.Columns.Add(new DataColumn("ShortRoleName"));
            foreach (DataRow row in dtUserList.Rows)
            {
                string roleNames = row["RoleNames"].ToString();

                // 先去掉后面的逗号
                roleNames = roleNames.TrimEnd(',');

                roleNames = roleNames.Length > 35 ? roleNames.Substring(0, 35) + "..." : roleNames;

                row["ShortRoleName"] = roleNames;
                string Enable = row["Enable"].ToString();
                if (Enable == "0")
                {
                    row["Enable"] = "使用";
                }
                else
                {
                    row["Enable"] = "过期";
                }
            }

            return("{\"total\":" + total + ",\"rows\":" + JSONHelper.DataTable2Json(dtUserList) + "}");
        }
コード例 #12
0
ファイル: PublicEnum.ashx.cs プロジェクト: zj0532/knowledge
        IDataBaseMgr dataBaseMgr = DataBaseFactory.Instance.Create();//数据库访问对象
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest Request = context.Request;

            action = Request["action"] ?? "";
            string field = "*";
            //组合查询条件
            Hashtable htCondition = new Hashtable();

            //int result = 0;//执行方法返回值
            switch (action)
            {
            case "enum_auto":    //查询系统中新增枚举值

                //获取必要参数
                var ParentValue = Request["pvalue"] ?? "0";
                var InsertAll   = Request["insert_select_all_item"] ?? "";

                htCondition.Clear();
                htCondition.Add("IsDelete", "0");       //未删除
                htCondition.Add("IsEnable", "1");       //启用
                if (!string.IsNullOrEmpty(ParentValue)) //父级值
                {
                    htCondition.Add("ParentValue", ParentValue);
                }
                field = "EnumValue AS [Key],EnumText as [Value]";
                var dtenum = dataBaseMgr.GetDataTable(field, "BPM_Sys_Enum", htCondition, "EnumOrder ASC");

                if (InsertAll != "")
                {
                    DataRow row = dtenum.NewRow();
                    row["Key"]   = "0";
                    row["Value"] = "全部";
                    dtenum.Rows.InsertAt(row, 0);
                }

                //获取json字符串
                json = JSONHelper.DataTable2Json(dtenum);
                break;

            case "enum_auto_q":    //查询系统中新增枚举值--带全部
                //获取必要参数
                var ParentValueq = Request["pvalue"] ?? "0";

                htCondition.Clear();
                htCondition.Add("IsDelete", "0");        //未删除
                htCondition.Add("IsEnable", "1");        //启用
                if (!string.IsNullOrEmpty(ParentValueq)) //父级值
                {
                    htCondition.Add("ParentValue", ParentValueq);
                }
                field = "EnumValue AS [Key],EnumText as [Value]";
                var dtenumq = dataBaseMgr.GetDataTable(field, "BPM_Sys_Enum", htCondition, "EnumOrder ASC");
                //添加一行空数据
                var row1 = dtenumq.NewRow();
                row1[0] = "0";
                row1[1] = "全部";
                dtenumq.Rows.InsertAt(row1, 0);
                //获取json字符串
                json = JSONHelper.DataTable2Json(dtenumq);
                break;

            case "enum_Text":    //根据key,获取text
                //获取必要参数
                var Value = Request["value"] ?? "0";

                string sql = "select EnumText as [Value] from BPM_Sys_Enum where IsDelete='0' and IsEnable='1' and EnumValue='" + Value + "' order by EnumOrder";
                json = (string)dataBaseMgr.ExecuteScalar(sql);
                break;

            case "enum_getPid":    //根据key,获取pid
                //获取必要参数
                Value = Request["value"] ?? "0";
                sql   = "";
                sql   = "select ParentValue as [Value] from BPM_Sys_Enum where IsDelete='0' and IsEnable='1' and EnumValue='" + Value + "' order by EnumOrder";
                json  = (string)dataBaseMgr.ExecuteScalar(sql);
                break;

            default:
                break;
            }

            context.Response.Write(json);
        }