コード例 #1
0
        /// <summary>
        /// 通知学校有组织调研
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>

        public ActionResult PushMsg(int ID)
        {
            ResearchPlanInfo infoPlan = ResearchPlanBLL.GetList(a => a.ID == ID).FirstOrDefault();

            ViewBag.listRule = RuleBLL.GetList(a => a.Enable);
            return(View(infoPlan));
        }
コード例 #2
0
        public void TestGetList()
        {
            RuleBLL bll = new RuleBLL(_unit);

            var list = bll.GetList();

            Assert.IsNotNull(list);
        }
コード例 #3
0
        private void GetSelectList()
        {
            ViewBag.listRule = RuleBLL.GetList(a => a.Enable).Select(p => new SelectListItem()
            {
                Text = p.Name, Value = p.ID.ToString()
            }).ToList();
            ViewBag.listMemberGroup = MemberGroupBLL.GetList(a => a.Enable).Select(p => new SelectListItem()
            {
                Text = p.Name, Value = p.ID.ToString()
            }).ToList();
            IEnumerable <SelectListItem> listDepartmentID = DepartmentBLL.GetList(p => p.Enable == true).Select(p => new SelectListItem {
                Text = p.Name, Value = p.ID.ToString()
            }).ToList();

            if (!PowerActionBLL.PowerCheck(PowerInfo.P_系统管理.PP系统帐户管理.PPP用户管理.查看所有帐户))
            {
                listDepartmentID = listDepartmentID.Where(a => a.Value == CurrentUser.ToString());
            }
            ViewBag.listDepartment = listDepartmentID;
        }
コード例 #4
0
        public ActionResult Join(UserInfo info)
        {
            string log = string.Empty;

            try
            {
                int PlanID = Function.GetRequestInt("PlanID");
                log += "\n PlanID=" + PlanID;
                string infoWechatUserReturnOpenID = Function.GetRequestString("infoWechatUserReturnOpenID");
                log += "\n infoWechatUserReturnOpenID=" + infoWechatUserReturnOpenID;
                ResearchPlanInfo infoPlan = ResearchPlanBLL.GetList(p => p.ID == PlanID).FirstOrDefault();
                log += "\n infoPlan=" + infoPlan;
                UserInfo infoUser = null;
                if (info.ID > 0)
                {
                    log     += "\n info.ID > 0=";
                    infoUser = UserBLL.GetList(a => a.ID == info.ID).FirstOrDefault();
                }
                if (null == infoUser)
                {
                    log     += "\n info.ID < 0=";
                    infoUser = UserBLL.GetList(a => a.WechatOpenID == infoWechatUserReturnOpenID).FirstOrDefault();
                }
                log += "\n infoUser="******"\n infoUser is null";
                    WechatUserReturnInfo infoWechatUserReturn = WeiXin.APIClient.WechatService.WechatUser.GetWechatUserReturnInfo(infoWechatUserReturnOpenID);
                    if (null == infoWechatUserReturn)
                    {
                        return(Json(new APIJson(-1, "无法获取用户信息")));
                    }
                    log     += "\n infoWechatUserReturn=" + infoWechatUserReturn;
                    infoUser = new UserInfo();
                    //infoUser.DepartmentID 从config中读到表单hiden了里
                    //infoUser.Name
                    if (string.IsNullOrEmpty(info.Name) || info.Name.Length > 50)
                    {
                        return(Json(new APIJson(-1, "请输入您的姓名")));
                    }
                    if (UserBLL.GetList(a => true).Any(a => a.Name == infoUser.Name))
                    {
                        return(Json(new APIJson(-1, "系统里居然有人跟你同名了,你换一个或加个数字后缀吧")));
                    }
                    var infoUserExistName = UserBLL.GetList(a => a.Name == info.Name).FirstOrDefault();
                    if (null != infoUserExistName)
                    {
                        return(Json(new APIJson(-1, "系统已存在当前用户名,请更换")));
                    }
                    infoUser.DepartmentID = info.DepartmentID;
                    infoUser.Name         = info.Name;
                    infoUser.Code         = infoUser.Name;
                    infoUser.PassWord     = string.Empty;
                    //infoUser.Email
                    if (null == infoUser.Email)
                    {
                        infoUser.Email = string.Empty;
                    }
                    infoUser.Email            = info.Email;
                    infoUser.Tel              = string.Empty;
                    infoUser.CreateDate       = DateTime.Now;
                    infoUser.LastDate         = DateTime.Now;
                    infoUser.Enable           = true;
                    infoUser.LocationX        = infoUser.LocationY = 0;
                    infoUser.WechatOpenID     = infoWechatUserReturn.openid;
                    infoUser.WechatNameNick   = infoWechatUserReturn.nickname;
                    infoUser.WechatHeadImg    = infoWechatUserReturn.headimgurl;
                    infoUser.Sex              = infoWechatUserReturn.sex.ToString();
                    infoUser.IDCard           = string.Empty;
                    infoUser.TypeID           = -1;
                    infoUser.DefaultSubjectID = 0;

                    log += "\n 准备完后infoUser="******"\n 创建完了";
                }

                ResearchPlanUserInfo infoPlanUser = new ResearchPlanUserInfo();
                infoPlanUser.ResearchPlanID = info.ID;
                infoPlanUser.UserID         = infoUser.ID;
                infoPlanUser.DateCreate     = DateTime.Now;
                infoPlanUser.DateConfirm    = DicInfo.DateZone;
                infoPlanUser.IsConfirmed    = true;
                infoPlanUser.Memo           = "二维码邀请";
                infoPlanUser.SumRemark      = string.Empty;
                infoPlan.ResearchPlanUserInfo.Add(infoPlanUser);
                var result = ResearchPlanBLL.Edit(infoPlan);
                if (result)
                {
                    return(Json(new APIJson(0, "恭喜您,成功加入本次听评课计划")));
                }
                else
                {
                    return(Json(new APIJson(-1, "加入失败了,请重试")));
                }
            }
            catch (Exception ex)
            {
                var ex2 = (System.Data.Entity.Infrastructure.DbUpdateException)ex;

                var ErrorMsg = log
                               + "Ex========" + ex.Message
                               + "\n ex2.InnerException.ObjectToJSON();" + ex2.InnerException.ObjectToJSON();
                return(Json(new APIJson(-1, ErrorMsg)));

                throw;
            }
        }
コード例 #5
0
        public ActionResult InportLightPost2()
        {
            bool   HidenIsInport = Function.GetRequestString("HidenIsInport").ToLower() == "true";
            string DdlWorkSheet  = Function.GetRequestString("DdlWorkSheet");
            string HidenFileURL  = Function.GetRequestString("HidenFileURL");

            HidenFileURL = Server.MapPath(HidenFileURL);
            DataTable dt = new DataTable();

            try
            {
                dt = Tool.ExcelHelper.ExcelToDatatable(HidenFileURL, DdlWorkSheet);
            }
            catch (Exception ex)
            {
                return(Json(new APIJson(-1, "系统出错:" + ex.Message)));
            }
            for (int i = dt.Rows.Count - 1; i >= 0; i--)
            {
                if (string.IsNullOrEmpty(dt.Rows[i][0].ToString().Trim()))
                {
                    dt.Rows.RemoveAt(i);
                }
            }


            var ErrorMsg = CheckDataTableHeadLight(dt);

            if (!string.IsNullOrEmpty(ErrorMsg))
            {
                return(Json(new APIJson(-1, ErrorMsg)));
            }
            if (!HidenIsInport)
            {
                return(Json(new APIJson(0, "解析成功", dt.DataTableToList())));
            }
            var      ListSubject             = SubjectBLL.GetList(a => true).ToList();
            int      DefaultRuleIDWhenInport = Function.ConverToInt(ProfilesBLL.GetValue(ProfilesInfo.InportSetting.DefaultRuleIDWhenInport));
            RuleInfo infoRule = RuleBLL.GetList(a => a.ID == DefaultRuleIDWhenInport).FirstOrDefault();


            List <string>   listInportResult = new List <string>();
            List <UserInfo> listUserInport   = new List <UserInfo>();

            foreach (DataRow item in dt.Rows)
            {
                UserInfo infoUser = new UserInfo();
                infoUser.DepartmentID     = CurrentUser.DepartmentID;
                infoUser.Name             = item["真实姓名"].ToString().Trim();
                infoUser.Code             = item["登录名"].ToString().Trim();
                infoUser.PassWord         = item["初始密码"].ToString().Trim();
                infoUser.Email            = string.Empty;
                infoUser.Tel              = string.Empty;
                infoUser.CreateDate       = DateTime.Now;
                infoUser.LastDate         = DicInfo.DateZone;
                infoUser.Enable           = true;
                infoUser.LocationX        = 0;
                infoUser.LocationY        = 0;
                infoUser.WechatOpenID     = string.Empty;
                infoUser.WechatNameNick   = string.Empty;
                infoUser.WechatHeadImg    = string.Empty;
                infoUser.Sex              = string.Empty;
                infoUser.IDCard           = string.Empty;
                infoUser.TypeID           = -3;
                infoUser.DefaultSubjectID = 0;
                infoUser.Email            = string.Empty;
                var HelpText1 = item["学科"].ToString().Trim();

                var UserSubjectinfo = ListSubject.Where(a => HelpText1.Split('|').Contains(a.Name));
                if (UserSubjectinfo.Count() > 0)
                {
                    infoUser.DefaultSubjectID = UserSubjectinfo.FirstOrDefault().ID;
                    infoUser.SubjectInfo      = new List <SubjectInfo>();
                    foreach (var itemSubject in UserSubjectinfo)
                    {
                        infoUser.SubjectInfo.Add(itemSubject);
                    }
                }
                else
                {
                    return(Json(new APIJson(-1, string.Format("提交失败,序号:{0}所在行中,对应学科数据无法识别", item["序号"].ToString()))));
                }
                infoUser.RuleInfo.Add(infoRule);

                if (string.IsNullOrEmpty(infoUser.Name) || string.IsNullOrEmpty(infoUser.Code))
                {
                    return(Json(new APIJson(-1, string.Format("提交失败,序号:{0}所在行中,用户名或登录名为空白,请先补填完整", item["序号"].ToString()))));
                }
                UserInfo infoDb = UserBLL.GetList(a => a.Code == infoUser.Code || a.Name == infoUser.Name).FirstOrDefault();
                if (null != infoDb)
                {
                    return(Json(new APIJson(-1, string.Format("提交失败,序号:{0}所在行中,用户名或登录名被占用,请为更改【可以登录名后加上数字或字母】", item["序号"].ToString()))));
                }
                if (infoUser.PassWord.Length < 6 || !ValidatePassWord(infoUser))
                {
                    return(Json(new APIJson(-1, string.Format("提交失败,序号:{0}所在行中,密码不符合要求,必需包括数字和字母,并且长度在6位数以上", item["序号"].ToString()))));
                }
                listUserInport.Add(infoUser);
            }
            foreach (var item in listUserInport)
            {
                UserBLL.Create(item);
            }
            listInportResult.Add("导入完成!");
            return(Json(new APIJson(2, "提交成功," + listUserInport.Count() + "个帐户成功导入")));
        }
コード例 #6
0
        public ActionResult InportPost2()
        {
            bool   HidenIsInport = Function.GetRequestString("HidenIsInport").ToLower() == "true";
            string DdlWorkSheet  = Function.GetRequestString("DdlWorkSheet");
            string HidenFileURL  = Function.GetRequestString("HidenFileURL");
            int    ActivityID    = Function.GetRequestInt("ActivityID");

            HidenFileURL = Server.MapPath(HidenFileURL);
            DataTable dt = new DataTable();

            try
            {
                dt = Tool.ExcelHelper.ExcelToDatatable(HidenFileURL, DdlWorkSheet);
            }
            catch (Exception ex)
            {
                return(Json(new APIJson(-1, "系统出错:" + ex.Message)));
            }
            for (int i = dt.Rows.Count - 1; i >= 0; i--)
            {
                if (string.IsNullOrEmpty(dt.Rows[i][0].ToString().Trim()))
                {
                    dt.Rows.RemoveAt(i);
                }
            }


            var ErrorMsg = CheckDataTableHead(dt);

            if (!string.IsNullOrEmpty(ErrorMsg))
            {
                return(Json(new APIJson(-1, ErrorMsg)));
            }
            if (!HidenIsInport)
            {
                return(Json(new APIJson(dt.DataTableToList())));
            }
            var           ListSubject      = SubjectBLL.GetList(a => true).ToList();
            var           ListRule         = RuleBLL.GetList(a => true).ToList();
            List <string> listInportResult = new List <string>();

            foreach (DataRow item in dt.Rows)
            {
                var      HelpText1 = item["登录名"].ToString().Trim();
                UserInfo info      = UserBLL.GetList(a => a.Code == HelpText1).FirstOrDefault();
                if (null == info)
                {
                    info                  = new UserInfo();
                    info.PassWord         = Md5Helper.Md5("qwe123");
                    info.Email            = string.Empty;
                    info.Tel              = string.Empty;
                    info.CreateDate       = DateTime.Now;
                    info.LastDate         = DateTime.Now;
                    info.LocationX        = info.LocationY = 0;
                    info.WechatOpenID     = info.WechatNameNick = info.WechatHeadImg = string.Empty;
                    info.Sex              = "未知";
                    info.IDCard           = string.Empty;
                    info.TypeID           = 0;
                    info.DefaultSubjectID = 0;
                }
                HelpText1 = item["单位名称"].ToString().Trim();
                DepartmentInfo infoDepartment = DepartmentBLL.GetList(a => a.Name == HelpText1).FirstOrDefault();
                if (null == infoDepartment)
                {
                    return(Json(new APIJson(-1, string.Format("提交失败,ID:{0}所在行中,单位名称在系统不存在", item["ID"].ToString()))));
                }
                info.DepartmentID = infoDepartment.ID;
                info.Enable       = item["是否启用"].ToString().Trim() == "可用";
                if (info.ID > 0)
                {
                    if (item["学科"].ToString().Trim() != "忽略")
                    {
                        info.SubjectInfo.Clear();
                    }
                    if (item["角色"].ToString().Trim() != "忽略")
                    {
                        info.RuleInfo.Clear();
                    }
                }
                foreach (var itemSubject in ListSubject.Where(a => item["学科"].ToString().Trim().Split('/').Contains(a.Name)))
                {
                    info.SubjectInfo.Add(itemSubject);
                }
                foreach (var itemRule in ListRule.Where(a => item["角色"].ToString().Trim().Split('/').Contains(a.Name)))
                {
                    info.RuleInfo.Add(itemRule);
                }

                listInportResult.Add(string.Format("ID:{0}验证成功", item["ID"].ToString()));
                if (info.ID == 0)
                {
                    UserBLL.Create(info);
                }
                else
                {
                    UserBLL.Edit(info);
                }
            }
            listInportResult.Add("导入完成!");
            return(Json(new APIJson(1, "提交成功", listInportResult)));
        }