コード例 #1
0
        public static TList <GE.MyLearning.BL.Menus> GetMenusByUserID(string userid)
        {
            string whereClause = "ParentMenuID is not null and ParentMenuID<>'' and ParentMenuID<>'0' and PermissionID in (   select PermissionID   from RolePermission as a inner join UserRole as b on a.RoleID=b.RoleID   where userid=" + CommonClass.sqlString(userid) + " ) and status=" + ConfigInfo.Instance().VertualUniversityStyle.ToString();
            string orderBy     = "ParentMenuID,ShowOrder";
            int    count       = -1;
            TList <GE.MyLearning.BL.Menus> menus = DataRepository.MenusProvider.GetPaged(whereClause, orderBy, 0, 0x7fffffff, out count);

            whereClause = "(ParentMenuID is null or ParentMenuID='' or ParentMenuID='0') and status=" + ConfigInfo.Instance().VertualUniversityStyle.ToString();
            orderBy     = "ShowOrder";
            TList <GE.MyLearning.BL.Menus> groups = DataRepository.MenusProvider.GetPaged(whereClause, orderBy, 0, 0x7fffffff, out count);

            for (int i = 0; i < groups.Count; i++)
            {
                if (menus.FindAll(MenusColumn.ParentMenuId, groups[i].MenuId).Count > 0)
                {
                    menus.Add(groups[i]);
                }
            }
            if (ConfigInfo.Instance().VertualUniversityStyle.ToString() == "0")
            {
                DataRepository.UserRoleProvider.GetPaged(string.Format("(UserID='{0}') and (RoleID='000000003' or RoleID='000000004')", userid), null, 0, 0x7fffffff, out count);
                if (count != 0)
                {
                    return(menus);
                }
                DataRepository.UserInfoProvider.GetPaged(string.Format("OHR_HR_Rep='{0}'", userid), null, 0, 0x7fffffff, out count);
                if (count == 0)
                {
                    return(menus);
                }
                groups = DataRepository.MenusProvider.GetPaged("PermissionID='MgtInstitute03'", null, 0, 0x7fffffff, out count);
                foreach (GE.MyLearning.BL.Menus menu in groups)
                {
                    menus.Add(menu);
                }
            }
            return(menus);
        }
コード例 #2
0
        public ActionResult UploadImage()
        {
            string savePath  = "/kindup/";
            string saveUrl   = "/kindup/";
            string fileTypes = "gif,jpg,jpeg,png,bmp";
            double maxSize   = Convert.ToDouble(ConfigInfo <UploadInfo> .Instance().UploadSize) * 1024 * 1024;
            //Convert.ToDouble(file.ContentLength) > Convert.ToDouble(ConfigInfo<UploadInfo>.Instance().UploadSize) * 1024 * 1024
            Hashtable hash = new Hashtable();

            HttpPostedFileBase file = Request.Files["imgFile"];

            if (file == null)
            {
                hash          = new Hashtable();
                hash["error"] = 0;
                hash["url"]   = "请选择文件";
                return(Json(hash));
            }

            string dirPath = Server.MapPath(savePath);

            if (!Directory.Exists(dirPath))
            {
                hash          = new Hashtable();
                hash["error"] = 0;
                hash["url"]   = "上传目录不存在";
                return(Json(hash));
            }

            string fileName = file.FileName;
            string fileExt  = Path.GetExtension(fileName).ToLower();

            ArrayList fileTypeList = ArrayList.Adapter(fileTypes.Split(','));

            if (file.InputStream == null || file.InputStream.Length > maxSize)
            {
                hash          = new Hashtable();
                hash["error"] = 0;
                hash["url"]   = "上传文件大小超过限制";
                return(Json(hash));
            }

            if (string.IsNullOrEmpty(fileExt) || Array.IndexOf(fileTypes.Split(','), fileExt.Substring(1).ToLower()) == -1)
            {
                hash          = new Hashtable();
                hash["error"] = 0;
                hash["url"]   = "上传文件扩展名是不允许的扩展名";
                return(Json(hash));
            }

            string newFileName = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + fileExt;
            string filePath    = dirPath + newFileName;

            file.SaveAs(filePath);
            string fileUrl = saveUrl + newFileName;

            hash          = new Hashtable();
            hash["error"] = 0;
            hash["url"]   = fileUrl;

            return(Json(hash, "text/html;charset=UTF-8"));;
        }