示例#1
0
        public Model_TPIFUser DataRowToModel(DataRow row)
        {
            Model_TPIFUser user = new Model_TPIFUser();

            if (row != null)
            {
                if (row["ThirdPartyIFUser_Id"] != null)
                {
                    user.ThirdPartyIFUser_Id = row["ThirdPartyIFUser_Id"].ToString();
                }
                if (row["School"] != null)
                {
                    user.School = row["School"].ToString();
                }
                if (row["UserName"] != null)
                {
                    user.UserName = row["UserName"].ToString();
                }
                if (row["Remark"] != null)
                {
                    user.Remark = row["Remark"].ToString();
                }
                if ((row["CreateTime"] != null) && (row["CreateTime"].ToString() != ""))
                {
                    user.CreateTime = new DateTime?(DateTime.Parse(row["CreateTime"].ToString()));
                }
            }
            return(user);
        }
示例#2
0
        public bool Add(Model_TPIFUser model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into TPIFUser(");
            builder.Append("ThirdPartyIFUser_Id,School,UserName,Remark,CreateTime)");
            builder.Append(" values (");
            builder.Append("@ThirdPartyIFUser_Id,@School,@UserName,@Remark,@CreateTime)");
            SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@ThirdPartyIFUser_Id", SqlDbType.Char, 0x24), new SqlParameter("@School", SqlDbType.VarChar, 50), new SqlParameter("@UserName", SqlDbType.NVarChar, 200), new SqlParameter("@Remark", SqlDbType.NVarChar, 0xfa0), new SqlParameter("@CreateTime", SqlDbType.DateTime) };
            cmdParms[0].Value = model.ThirdPartyIFUser_Id;
            cmdParms[1].Value = model.School;
            cmdParms[2].Value = model.UserName;
            cmdParms[3].Value = model.Remark;
            cmdParms[4].Value = model.CreateTime;
            return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
示例#3
0
        public List <Model_TPIFUser> DataTableToList(DataTable dt)
        {
            List <Model_TPIFUser> list = new List <Model_TPIFUser>();
            int count = dt.Rows.Count;

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    Model_TPIFUser item = this.dal.DataRowToModel(dt.Rows[i]);
                    if (item != null)
                    {
                        list.Add(item);
                    }
                }
            }
            return(list);
        }
示例#4
0
        public bool Update(Model_TPIFUser model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update TPIFUser set ");
            builder.Append("School=@School,");
            builder.Append("UserName=@UserName,");
            builder.Append("Remark=@Remark,");
            builder.Append("CreateTime=@CreateTime");
            builder.Append(" where ThirdPartyIFUser_Id=@ThirdPartyIFUser_Id ");
            SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@School", SqlDbType.VarChar, 50), new SqlParameter("@UserName", SqlDbType.NVarChar, 200), new SqlParameter("@Remark", SqlDbType.NVarChar, 0xfa0), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@ThirdPartyIFUser_Id", SqlDbType.Char, 0x24) };
            cmdParms[0].Value = model.School;
            cmdParms[1].Value = model.UserName;
            cmdParms[2].Value = model.Remark;
            cmdParms[3].Value = model.CreateTime;
            cmdParms[4].Value = model.ThirdPartyIFUser_Id;
            return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }
示例#5
0
 public bool Add(Model_TPIFUser model)
 {
     return(this.dal.Add(model));
 }
示例#6
0
 public bool Update(Model_TPIFUser model)
 {
     return(this.dal.Update(model));
 }
示例#7
0
        public static string loginIndex(string userName, string passWord, string backUrl)
        {
            string strJson = string.Empty;
            string iurl    = string.Empty;

            try
            {
                HttpContext.Current.Session["UserPublicUrl"] = null;
                string loginName     = string.Empty;
                string loginPassWord = string.Empty;
                loginName     = userName.Trim();
                loginPassWord = Rc.Common.StrUtility.DESEncryptLogin.EncryptString(passWord.Trim());
                Model_F_User loginModel = new Model_F_User();
                object       objFUser   = new BLL_F_User().GetModelByUserName(loginName);
                object       objIFUser  = new BLL_TPIFUser().GetModelByUserName(loginName);
                if (objFUser == null && objIFUser == null)
                {
                    HttpContext.Current.Session.Clear();
                    strJson = JsonConvert.SerializeObject(new
                    {
                        err  = "该账号不存在,请重新登录。",
                        iurl = ""
                    });
                    return(strJson);
                }

                #region 验证第三方接口用户
                if (objIFUser != null)
                {
                    Model_TPIFUser   modelIFUser = objIFUser as Model_TPIFUser;
                    Model_TPSchoolIF modelSIF    = new BLL_TPSchoolIF().GetModelBySchoolIF_Code(modelIFUser.School);
                    if (modelSIF == null)
                    {
                        HttpContext.Current.Session.Clear();
                        strJson = JsonConvert.SerializeObject(new
                        {
                            err  = "学校接口配置不存在,请重新登录。",
                            iurl = ""
                        });
                        return(strJson);
                    }
                    Model_ConfigSchool modelCS = new BLL_ConfigSchool().GetModelBySchoolIdNew(modelSIF.SchoolId);
                    if (modelCS == null)
                    {
                        HttpContext.Current.Session.Clear();
                        strJson = JsonConvert.SerializeObject(new
                        {
                            err  = "学校配置不存在,请重新登录。",
                            iurl = ""
                        });
                        return(strJson);
                    }

                    if (modelSIF.SchoolIF_Code == ThirdPartyEnum.ahjzvs.ToString())
                    {
                        #region 安徽金寨职业学校
                        loginModel = new BLL_F_User().GetModel(modelIFUser.UserName, loginPassWord);
                        if (loginModel == null)
                        {
                            Model_F_User loginModelNew = (Model_F_User)objFUser;
                            if (loginModelNew.Password == Rc.Common.StrUtility.DESEncryptLogin.EncryptString(Rc.Common.Config.Consts.DefaultPassword))
                            {
                                HttpContext.Current.Session.Clear();
                                strJson = JsonConvert.SerializeObject(new
                                {
                                    err  = "当前密码123456,过于简单,建议在个人中心中修改。",
                                    iurl = ""
                                });
                                return(strJson);
                            }
                            HttpContext.Current.Session.Clear();
                            strJson = JsonConvert.SerializeObject(new
                            {
                                err  = "用户密码错误,请重新登录。",
                                iurl = ""
                            });
                            return(strJson);
                        }

                        HttpContext.Current.Session["FLoginUser"] = loginModel;

                        if (loginModel.UserIdentity == "T")
                        {
                            //是否带班
                            int classCount = new BLL_UserGroup().GetRecordCount(" UserGroup_AttrEnum='Class' and UserGroup_Id in(select UserGroup_Id from UserGroup_Member where USER_ID='" + loginModel.UserId + "' and User_ApplicationStatus='passed' and UserStatus='0') ");
                            if (classCount > 0 && (Rc.Cloud.Web.Common.pfunction.GetWebMdlIsShow("cTeachPlan")))
                            {
                                iurl = "/teacher/cTeachPlan.aspx";
                            }
                            else
                            {
                                iurl = "/teacher/basicSetting.aspx";
                            }
                        }
                        else if (loginModel.UserIdentity == "S")
                        {
                            iurl = "/student/oHomework.aspx";
                        }
                        else if (loginModel.UserIdentity == "P")
                        {
                            iurl = "/parent/student.aspx";
                        }

                        string local_url = string.Empty; // 局域网地址
                        #region 学校配置URL
                        DataTable dtUrl = new BLL_ConfigSchool().GetSchoolPublicUrl(loginModel.UserId).Tables[0];
                        if (dtUrl.Rows.Count > 0)
                        {
                            HttpContext.Current.Session["UserPublicUrl"] = dtUrl.Rows[0]["publicUrl"];
                            local_url = dtUrl.Rows[0]["apiUrlList"].ToString();
                        }
                        #endregion
                        string rurl = string.Format("/onlinecheck.aspx?iurl={0}&local_url={1}"
                                                    , HttpContext.Current.Server.UrlEncode(iurl)
                                                    , HttpContext.Current.Server.UrlEncode(local_url));
                        if (dtUrl.Rows.Count > 0) // 有局域网配置数据,验证是否局域网
                        {
                            iurl = rurl;
                        }
                        if (string.IsNullOrEmpty(iurl))
                        {
                            iurl = string.Format("/RE_Register/PerfectInformation.aspx?SchoolId={0}&UserId={1}"
                                                 , modelCS.School_ID, loginModel.UserId);
                        }
                        strJson = JsonConvert.SerializeObject(new
                        {
                            err  = "null",
                            iurl = iurl
                        });
                        return(strJson);

                        #endregion
                    }
                    else
                    {
                        #region 其他学校
                        if (Rc.Interface.AuthAPI_pfunction.AuthUserLoginByIF(modelCS, modelIFUser.School, userName, passWord))
                        {
                            #region 登录
                            loginModel = new BLL_F_User().GetModelByUserName(modelIFUser.School + modelIFUser.UserName);
                            HttpContext.Current.Session["FLoginUser"] = loginModel;

                            if (loginModel.UserIdentity == "T")
                            {
                                //是否带班
                                int classCount = new BLL_UserGroup().GetRecordCount(" UserGroup_AttrEnum='Class' and UserGroup_Id in(select UserGroup_Id from UserGroup_Member where USER_ID='" + loginModel.UserId + "' and User_ApplicationStatus='passed' and UserStatus='0') ");
                                if (classCount > 0 && (Rc.Cloud.Web.Common.pfunction.GetWebMdlIsShow("cTeachPlan")))
                                {
                                    iurl = "/teacher/cTeachPlan.aspx";
                                }
                                else
                                {
                                    iurl = "/teacher/basicSetting.aspx";
                                }
                            }
                            else if (loginModel.UserIdentity == "S")
                            {
                                iurl = "/student/oHomework.aspx";
                            }
                            else if (loginModel.UserIdentity == "P")
                            {
                                iurl = "/parent/student.aspx";
                            }

                            string local_url = string.Empty; // 局域网地址
                            #region 学校配置URL
                            DataTable dtUrl = new BLL_ConfigSchool().GetSchoolPublicUrl(loginModel.UserId).Tables[0];
                            if (dtUrl.Rows.Count > 0)
                            {
                                HttpContext.Current.Session["UserPublicUrl"] = dtUrl.Rows[0]["publicUrl"];
                                local_url = dtUrl.Rows[0]["apiUrlList"].ToString();
                            }
                            #endregion
                            string rurl = string.Format("/onlinecheck.aspx?iurl={0}&local_url={1}"
                                                        , HttpContext.Current.Server.UrlEncode(iurl)
                                                        , HttpContext.Current.Server.UrlEncode(local_url));
                            if (dtUrl.Rows.Count > 0) // 有局域网配置数据,验证是否局域网
                            {
                                iurl = rurl;
                            }
                            if (string.IsNullOrEmpty(iurl))
                            {
                                iurl = string.Format("/RE_Register/PerfectInformation.aspx?SchoolId={0}&UserId={1}", modelCS.School_ID, loginModel.UserId);
                            }
                            strJson = JsonConvert.SerializeObject(new
                            {
                                err  = "null",
                                iurl = iurl
                            });
                            return(strJson);

                            #endregion
                        }
                        else
                        {
                            HttpContext.Current.Session.Clear();
                            strJson = JsonConvert.SerializeObject(new
                            {
                                err  = "接口用户密码错误,请重新登录。",
                                iurl = ""
                            });
                            return(strJson);
                        }
                        #endregion
                    }
                }
                #endregion

                #region 验证作业平台用户
                if (objFUser != null)
                {
                    objFUser = new BLL_F_User().GetModel(loginName, loginPassWord);
                    if (objFUser != null)
                    {
                        #region 登录
                        loginModel = objFUser as Model_F_User;
                        HttpContext.Current.Session["FLoginUser"] = loginModel;

                        if (loginModel.UserIdentity == "T")
                        {
                            //是否带班
                            int classCount = new BLL_UserGroup().GetRecordCount(" UserGroup_AttrEnum='Class' and UserGroup_Id in(select UserGroup_Id from UserGroup_Member where USER_ID='" + loginModel.UserId + "' and User_ApplicationStatus='passed' and UserStatus='0') ");
                            if (classCount > 0 && (Rc.Cloud.Web.Common.pfunction.GetWebMdlIsShow("cTeachPlan")))
                            {
                                iurl = "/teacher/cTeachPlan.aspx";
                            }
                            else
                            {
                                iurl = "/teacher/basicSetting.aspx";
                            }
                        }
                        else if (loginModel.UserIdentity == "S")
                        {
                            iurl = "/student/oHomework.aspx";
                        }
                        else if (loginModel.UserIdentity == "P")
                        {
                            iurl = "/parent/student.aspx";
                        }

                        if (!string.IsNullOrEmpty(backUrl))
                        {
                            iurl = backUrl;
                        }
                        #endregion
                        if (string.IsNullOrEmpty(loginModel.TrueName))
                        {
                            loginModel.TrueName = loginModel.UserName;
                            new BLL_F_User().Update(loginModel);
                        }

                        string local_url = string.Empty; // 局域网地址
                        #region 学校配置URL
                        DataTable dtUrl = new BLL_ConfigSchool().GetSchoolPublicUrl(loginModel.UserId).Tables[0];
                        if (dtUrl.Rows.Count > 0)
                        {
                            HttpContext.Current.Session["UserPublicUrl"] = dtUrl.Rows[0]["publicUrl"];
                            local_url = dtUrl.Rows[0]["apiUrlList"].ToString();
                        }
                        #endregion
                        string rurl = string.Format("/onlinecheck.aspx?iurl={0}&local_url={1}"
                                                    , HttpContext.Current.Server.UrlEncode(iurl)
                                                    , HttpContext.Current.Server.UrlEncode(local_url));
                        if (dtUrl.Rows.Count > 0) // 有局域网配置数据,验证是否局域网
                        {
                            iurl = rurl;
                        }
                        strJson = JsonConvert.SerializeObject(new
                        {
                            err  = "null",
                            iurl = iurl
                        });
                    }
                    else
                    {
                        HttpContext.Current.Session.Clear();
                        strJson = JsonConvert.SerializeObject(new
                        {
                            err  = "用户密码错误,请重新登录。",
                            iurl = ""
                        });
                    }
                }
                else
                {
                    HttpContext.Current.Session.Clear();
                    strJson = JsonConvert.SerializeObject(new
                    {
                        err  = "该账号不存在,请重新登录。。",
                        iurl = ""
                    });
                }
                #endregion
            }
            catch (Exception ex)
            {
                strJson = JsonConvert.SerializeObject(new
                {
                    err  = "null",
                    iurl = "/ErrorPageF.aspx?errorType=6"
                });
                Rc.Common.SystemLog.SystemLog.AddLogErrorFromBS("", "用户登录", ex.Message.ToString());
            }

            return(strJson);
        }
        /// <summary>
        /// 处理用户信息,返回用户登录后网页地址 18-01-03TS
        /// </summary>
        public static string HandelUserInfo(string schoolCode, string loginName, string trueName)
        {
            string iurl     = string.Empty;
            string schoolId = string.Empty;

            List <Model_TPIFUser> listIFUser  = new BLL_TPIFUser().GetModelList("UserName='******'");
            Model_TPIFUser        modelIFUser = new BLL_TPIFUser().GetModelBySchoolUserName(schoolCode, loginName);

            if (schoolCode == ThirdPartyEnum.ahjzvs.ToString())
            {
                #region 安徽金寨职业学校
                if (modelIFUser != null)//用户已登录过
                {
                    #region 登录
                    Model_F_User loginModel = new BLL_F_User().GetModelByUserName(modelIFUser.UserName);
                    HttpContext.Current.Session["FLoginUser"] = loginModel;

                    if (loginModel.UserIdentity == "T")
                    {
                        //是否带班
                        int classCount = new BLL_UserGroup().GetRecordCount(" UserGroup_AttrEnum='Class' and UserGroup_Id in(select UserGroup_Id from UserGroup_Member where USER_ID='" + loginModel.UserId + "' and User_ApplicationStatus='passed' and UserStatus='0') ");
                        if (classCount > 0 && (Rc.Cloud.Web.Common.pfunction.GetWebMdlIsShow("cTeachPlan")))
                        {
                            iurl = "/teacher/cTeachPlan.aspx";
                        }
                        else
                        {
                            iurl = "/teacher/basicSetting.aspx";
                        }
                    }
                    else if (loginModel.UserIdentity == "S")
                    {
                        iurl = "/student/oHomework.aspx";
                    }
                    else if (loginModel.UserIdentity == "P")
                    {
                        iurl = "/parent/student.aspx";
                    }

                    string local_url = string.Empty; // 局域网地址
                    #region 学校配置URL
                    DataTable dtUrl = new BLL_ConfigSchool().GetSchoolPublicUrl(loginModel.UserId).Tables[0];
                    if (dtUrl.Rows.Count > 0)
                    {
                        HttpContext.Current.Session["UserPublicUrl"] = dtUrl.Rows[0]["publicUrl"];
                        local_url = dtUrl.Rows[0]["apiUrlList"].ToString();
                    }
                    #endregion
                    string rurl = string.Format("/onlinecheck.aspx?iurl={0}&local_url={1}"
                                                , HttpContext.Current.Server.UrlEncode(iurl)
                                                , HttpContext.Current.Server.UrlEncode(local_url));
                    if (dtUrl.Rows.Count > 0) // 有局域网配置数据,验证是否局域网
                    {
                        iurl = rurl;
                    }
                    if (string.IsNullOrEmpty(iurl))
                    {
                        Model_TPSchoolIF modelSIF = new BLL_TPSchoolIF().GetModelBySchoolIF_Code(schoolCode);
                        if (modelSIF != null)
                        {
                            schoolId = modelSIF.SchoolId;
                        }
                        iurl = string.Format("/RE_Register/PerfectInformation.aspx?SchoolId={0}&UserId={1}", schoolId, loginModel.UserId);
                    }
                    #endregion
                }
                else
                {
                    #region 第一次登录,写入用户数据
                    Model_TPSchoolIF modelSIF = new BLL_TPSchoolIF().GetModelBySchoolIF_Code(schoolCode);
                    if (modelSIF != null)
                    {
                        schoolId = modelSIF.SchoolId;
                    }
                    string userId = Guid.NewGuid().ToString();
                    #region TPIFUser
                    modelIFUser = new Model_TPIFUser();
                    modelIFUser.ThirdPartyIFUser_Id = Guid.NewGuid().ToString();
                    modelIFUser.School     = schoolCode;
                    modelIFUser.UserName   = loginName;
                    modelIFUser.CreateTime = DateTime.Now;
                    new BLL_TPIFUser().Add(modelIFUser);
                    #endregion
                    #region F_User
                    Model_F_User modelFUser = new Model_F_User();
                    modelFUser.UserId     = userId;
                    modelFUser.UserName   = loginName;
                    modelFUser.TrueName   = trueName;
                    modelFUser.Password   = DESEncryptLogin.EncryptString(Rc.Common.Config.Consts.DefaultPassword);
                    modelFUser.CreateTime = DateTime.Now;
                    new BLL_F_User().Add(modelFUser);
                    #endregion
                    iurl = string.Format("/RE_Register/PerfectInformation.aspx?userId={0}&schoolId={1}", userId, schoolId);
                    #endregion
                }
                #endregion
            }
            else
            {
                #region 其他学校
                if (modelIFUser != null)//用户已登录过
                {
                    #region 登录
                    Model_F_User loginModel = new BLL_F_User().GetModelByUserName(modelIFUser.School + modelIFUser.UserName);
                    HttpContext.Current.Session["FLoginUser"] = loginModel;

                    if (loginModel.UserIdentity == "T")
                    {
                        //是否带班
                        int classCount = new BLL_UserGroup().GetRecordCount(" UserGroup_AttrEnum='Class' and UserGroup_Id in(select UserGroup_Id from UserGroup_Member where USER_ID='" + loginModel.UserId + "' and User_ApplicationStatus='passed' and UserStatus='0') ");
                        if (classCount > 0 && (Rc.Cloud.Web.Common.pfunction.GetWebMdlIsShow("cTeachPlan")))
                        {
                            iurl = "/teacher/cTeachPlan.aspx";
                        }
                        else
                        {
                            iurl = "/teacher/basicSetting.aspx";
                        }
                    }
                    else if (loginModel.UserIdentity == "S")
                    {
                        iurl = "/student/oHomework.aspx";
                    }
                    else if (loginModel.UserIdentity == "P")
                    {
                        iurl = "/parent/student.aspx";
                    }

                    string local_url = string.Empty; // 局域网地址
                    #region 学校配置URL
                    DataTable dtUrl = new BLL_ConfigSchool().GetSchoolPublicUrl(loginModel.UserId).Tables[0];
                    if (dtUrl.Rows.Count > 0)
                    {
                        HttpContext.Current.Session["UserPublicUrl"] = dtUrl.Rows[0]["publicUrl"];
                        local_url = dtUrl.Rows[0]["apiUrlList"].ToString();
                    }
                    #endregion
                    string rurl = string.Format("/onlinecheck.aspx?iurl={0}&local_url={1}"
                                                , HttpContext.Current.Server.UrlEncode(iurl)
                                                , HttpContext.Current.Server.UrlEncode(local_url));
                    if (dtUrl.Rows.Count > 0) // 有局域网配置数据,验证是否局域网
                    {
                        iurl = rurl;
                    }
                    if (string.IsNullOrEmpty(iurl))
                    {
                        Model_TPSchoolIF modelSIF = new BLL_TPSchoolIF().GetModelBySchoolIF_Code(schoolCode);
                        if (modelSIF != null)
                        {
                            schoolId = modelSIF.SchoolId;
                        }
                        iurl = string.Format("/RE_Register/PerfectInformation.aspx?SchoolId={0}&UserId={1}", schoolId, loginModel.UserId);
                    }
                    #endregion
                }
                else
                {
                    #region 第一次登录,写入用户数据
                    Model_TPSchoolIF modelSIF = new BLL_TPSchoolIF().GetModelBySchoolIF_Code(schoolCode);
                    if (modelSIF != null)
                    {
                        schoolId = modelSIF.SchoolId;
                    }
                    string userId = Guid.NewGuid().ToString();
                    #region TPIFUser
                    modelIFUser = new Model_TPIFUser();
                    modelIFUser.ThirdPartyIFUser_Id = Guid.NewGuid().ToString();
                    modelIFUser.School     = schoolCode;
                    modelIFUser.UserName   = loginName;
                    modelIFUser.CreateTime = DateTime.Now;
                    new BLL_TPIFUser().Add(modelIFUser);
                    #endregion
                    #region F_User
                    Model_F_User modelFUser = new Model_F_User();
                    modelFUser.UserId     = userId;
                    modelFUser.UserName   = schoolCode + loginName;
                    modelFUser.TrueName   = trueName;
                    modelFUser.CreateTime = DateTime.Now;
                    new BLL_F_User().Add(modelFUser);
                    #endregion
                    iurl = "/RE_Register/PerfectInformation.aspx?userId=" + userId + "&schoolId=" + schoolId;
                    #endregion
                }
                #endregion
            }
            return(iurl);
        }