Beispiel #1
0
        public ActionResult GetCatoryTreeJson(string typecode, string tid = "", string keyword = "")
        {
            Operator user = OperatorProvider.Provider.Current();

            StringBuilder sb       = new StringBuilder();
            string        parentId = "0";

            if (!string.IsNullOrEmpty(tid))
            {
                StcategoryEntity hs = StcategoryBLL.GetEntity(tid);
                if (hs != null)
                {
                    DataTable dt = new ERCHTMS.Busines.BaseManage.DepartmentBLL().GetDataTable(string.Format("select id from HRS_STCATEGORY t where instr('{0}',encode)=1 and typecode='{1}'", hs.ENCODE, typecode));
                    foreach (DataRow dr in dt.Rows)
                    {
                        sb.AppendFormat("{0},", dr[0].ToString());
                    }
                }
            }
            var treeList = new List <TreeEntity>();
            var data     = StcategoryBLL.GetList("").Where(t => t.TYPECODE == typecode).OrderBy(t => t.ENCODE).ToList();

            if (!string.IsNullOrEmpty(keyword))
            {
                data = StcategoryBLL.GetList("").Where(t => t.TYPECODE == typecode && t.NAME.Contains(keyword.Trim())).OrderBy(t => t.ENCODE).ToList();
                if (data.Count() > 0)
                {
                    parentId = data.OrderBy(t => t.ENCODE).FirstOrDefault().PARENTID;
                }
            }
            foreach (StcategoryEntity item in data)
            {
                string     hasChild = StcategoryBLL.IsHasChild(item.ID) ? "1" : "0";
                TreeEntity tree     = new TreeEntity();
                tree.id             = item.ID;
                tree.text           = item.NAME;
                tree.value          = item.ID;
                tree.parentId       = item.PARENTID;
                tree.complete       = true;
                tree.hasChildren    = true;
                tree.Attribute      = "Code";
                tree.AttributeValue = item.ENCODE + "|" + hasChild;
                if (!string.IsNullOrEmpty(tid))
                {
                    if (sb.ToString().Contains(item.ID))
                    {
                        tree.isexpand = true;
                    }
                }
                else if (tree.parentId == parentId)
                {
                    tree.isexpand = true;
                }
                treeList.Add(tree);
            }
            return(Content(treeList.TreeToJson(parentId)));
        }
Beispiel #2
0
        /// <summary>
        /// 获取机构部门组织树菜单
        /// </summary>
        /// <returns></returns>
        //[HttpGet]
        public ActionResult GetStandardTreeJson(string isCheck, string ids = "", string selIds = "", string tid = "")
        {
            //暂时取所有,后期用户权限开发完成,数据将通过权限下来进行展示
            Operator user = OperatorProvider.Provider.Current();

            selIds = "," + selIds.Trim(',') + ",";
            var treeList = new List <TreeEntity>();

            var where = string.Format(" and CreateUserOrgCode='{0}' or Id='0'", user.OrganizeCode);
            var data = htstandardbll.GetList(where).OrderBy(t => t.EnCode).ToList();

            try
            {
                StringBuilder sb = new StringBuilder();
                if (!string.IsNullOrEmpty(tid))
                {
                    HtStandardEntity hs = htstandardbll.GetEntity(tid);
                    if (hs != null)
                    {
                        DataTable dt = new ERCHTMS.Busines.BaseManage.DepartmentBLL().GetDataTable(string.Format("select id from BIS_HTSTANDARD t where instr('{0}',encode)=1", hs.EnCode));
                        foreach (DataRow dr in dt.Rows)
                        {
                            sb.AppendFormat("{0},", dr[0].ToString());
                        }
                    }
                }
                if (!string.IsNullOrWhiteSpace(ids))
                {
                    ids = ids.Trim(',');
                    ids = "," + ids + ",";
                }
                foreach (HtStandardEntity item in data)
                {
                    if (!selIds.Contains("," + item.Id + ","))
                    {
                        string     hasChild = htstandardbll.IsHasChild(item.Id) ? "1" : "0";
                        TreeEntity tree     = new TreeEntity();
                        tree.id       = item.Id;
                        tree.text     = item.Name.Replace("\n", "").Replace("\\", "╲");
                        tree.value    = item.Id;
                        tree.parentId = item.Parentid;
                        tree.isexpand = (item.Parentid == "-1") ? true : false;
                        tree.complete = true;
                        if (!string.IsNullOrWhiteSpace(ids))
                        {
                            tree.checkstate = ids.Contains("," + item.Id + ",") ? 1 : 0;
                        }
                        tree.hasChildren = hasChild == "1" ? true : false;
                        tree.Attribute   = "Code";
                        tree.showcheck   = string.IsNullOrEmpty(isCheck) ? false : true;
                        if (!string.IsNullOrEmpty(tid))
                        {
                            if (sb.ToString().Contains(item.Id))
                            {
                                tree.isexpand = true;
                            }
                        }
                        tree.AttributeValue = item.EnCode + "|" + hasChild;
                        treeList.Add(tree);
                    }
                }
                return(Content(treeList.TreeToJson("-1")));
            }
            catch (Exception ex)
            {
                return(Error(ex.Message));
            }
        }
Beispiel #3
0
        public object RegisterUser()
        {
            string fileName = DateTime.Now.ToString("yyyyMMdd") + ".log";
            string json     = HttpContext.Current.Request.Params["json"];

            try
            {
                if (!string.IsNullOrEmpty(json))
                {
                    ERCHTMS.Busines.BaseManage.UserBLL       userBll = new ERCHTMS.Busines.BaseManage.UserBLL();
                    ERCHTMS.Busines.BaseManage.DepartmentBLL deptBll = new ERCHTMS.Busines.BaseManage.DepartmentBLL();
                    dynamic dy = JsonConvert.DeserializeObject <ExpandoObject>(json);
                    if (string.IsNullOrEmpty(dy.userName))
                    {
                        return(new { code = 1, data = "", info = "参数:userName为空" });
                    }
                    if (string.IsNullOrEmpty(dy.mobile))
                    {
                        return(new { code = 1, data = "", info = "参数:mobile为空" });
                    }
                    if (string.IsNullOrEmpty(dy.deptName))
                    {
                        return(new { code = 1, data = "", info = "参数:deptName为空" });
                    }
                    //判断账号是否在系统中存在
                    bool result = userBll.ExistAccount(dy.mobile, "");
                    if (result)
                    {
                        string deptid  = new DataItemDetailBLL().GetItemValue("dept", "TryDept"); //所属单位ID,在后台配置(目前处理方案是在后台初始化好一个演示的单位,注册的用户直接挂在此单位即可)
                        string pathurl = new DataItemDetailBLL().GetItemValue("imgUrl");          //web平台对应的地址,放在编码配置也可后台直接后去,请根据实际情况处理
                        if (!string.IsNullOrEmpty(deptid))
                        {
                            var        dept = deptBll.GetEntity(deptid);
                            UserEntity user = new UserEntity();
                            user.UserId  = Guid.NewGuid().ToString();
                            user.Account = dy.mobile;
                            Random rnd = new Random();
                            string str = rnd.Next(10000, 99999).ToString();
                            user.RealName       = dy.userName;
                            user.Password       = str;
                            user.DepartmentId   = dept.DepartmentId;
                            user.DepartmentCode = dept.EnCode;
                            user.OrganizeId     = dept.OrganizeId;
                            user.OrganizeCode   = dept.EnCode;
                            user.Mobile         = dy.mobile;
                            user.IsEpiboly      = "0";
                            user.RoleName       = "公司级用户,公司管理员";
                            user.RoleId         = "aece6d68-ef8a-4eac-a746-e97f0067fab5,5af22786-e2f2-4a3d-8da3-ecfb16b96f36";
                            user.AllowStartTime = DateTime.Now;
                            user.AllowEndTime   = Convert.ToDateTime(user.AllowStartTime).AddDays(15);
                            user.Description    = dy.deptName;
                            user.IdentifyID     = "420115" + new Random().Next(1970, 2000) + "0722" + new Random().Next(1000, 9999);
                            user.IsPresence     = "1";
                            var tempdata = new
                            {
                                account      = dy.mobile,//账号
                                password     = str,
                                allowEndTime = Convert.ToDateTime(user.AllowEndTime).ToString("yyyy-MM-dd HH:mm:ss"),
                                path         = pathurl
                            };
                            userBll.SaveForm(user.UserId, user);
                            System.IO.File.AppendAllText(HttpContext.Current.Server.MapPath("~/logs/" + fileName), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ,注册成功,参数为:" + json + "\r\n");
                            return(new { code = 0, data = tempdata, info = "操作成功" });
                        }
                        else
                        {
                            return(new { code = 1, data = "", info = "试用单位未配置" });
                        }
                    }
                    else
                    {
                        return(new { code = 1, data = "", info = "手机号已存在!" });
                    }
                }
                else
                {
                    return(new { code = 1, data = "", info = "json参数为空" });
                }
            }
            catch (Exception ex)
            {
                System.IO.File.AppendAllText(HttpContext.Current.Server.MapPath("~/logs/" + fileName), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ,注册失败,异常信息:" + ex.Message + "参数为:" + json + "\r\n");
                return(new { code = 1, data = "", info = ex.Message });
            }
        }