/// <summary> /// 验证用户身份。 /// </summary> /// <param name="schoolID">学校ID。</param> /// <param name="type">类型。</param> /// <param name="account">账号。</param> /// <param name="password">密码。</param> /// <returns></returns> public CallResult VerifyUserIdentity(GUIDEx schoolID, int type, string account, string password) { try { IUserAuthentication auth = new ModuleConfiguration().UserAuthentication; if (auth != null) { string err = null; SFITSchools school = new SFITSchools(); school.SchoolID = schoolID; if (!this.schoolsEntity.LoadRecord(ref school)) { throw new Exception("学校ID不存在或被修改删除!"); } GUIDEx userCode = auth.VerifyUser(type, account, password, out err); if (!userCode.IsValid) throw new Exception(string.IsNullOrEmpty(err) ? "未知错误" : err); string employeeID = null, employeeCode = null, employeeName = null; if (this.localUserInfo.GetUserInfo(type, userCode, out employeeID, out employeeCode, out employeeName)) { if (type == 1) { //是否为任课教师。 if (!this.teaClassEntity.VerifyInstructor(schoolID, employeeID)) { throw new Exception(string.Format("教师[{0},{1}]不属于学校[{2},{3}]的任课教师!", employeeCode, employeeName, school.SchoolCode, school.SchoolName)); } } } else throw new Exception(string.Format("账号[{0}]对应的信息不存在!", account)); return new CallResult(0, string.Join(",", new string[] { employeeID, employeeCode, employeeName })); } return new CallResult(-1, "未接入城域网。"); } catch (Exception e) { return new CallResult(-1, e.Message); } }
protected void btnSave_Click(object sender, EventArgs e) { try { SFITSchools data = new SFITSchools(); data.SchoolID = this.SchoolID.IsValid ? this.SchoolID : GUIDEx.New; data.SchoolCode = this.txtSchoolCode.Text; data.SchoolName = this.txtSchoolName.Text; data.SchoolType = int.Parse(this.ddlSchoolType.SelectedValue); data.OrderNO = int.Parse(this.txtOrderNO.Text); data.SyncStatus = int.Parse(this.ddlSyncStatus.SelectedValue); if (this.presenter.UpdateSFITSchools(data)) this.SaveData(); } catch (Exception ex) { this.ShowMessage(ex.Message); } }