本文整理汇总了C#中Voodoo.Basement.DataEntities.AddToUser方法的典型用法代码示例。如果您正苦于以下问题:C# DataEntities.AddToUser方法的具体用法?C# DataEntities.AddToUser怎么用?C# DataEntities.AddToUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Voodoo.Basement.DataEntities
的用法示例。
在下文中一共展示了DataEntities.AddToUser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btn_Save_Click
protected void btn_Save_Click(object sender, EventArgs e)
{
DataEntities ent = new DataEntities();
int id = WS.RequestInt("id");
User u = (from l in ent.User where l.ID == id select l).FirstOrDefault();
if (u == null)
{
u = new User();
}
u.UserName = txt_UserName.Text;
u.ChineseName = txt_ChineseName.Text;
u.Email = txt_Email.Text;
u.Tel = txt_TelNumber.Text;
u.Mobile = txt_Mobile.Text;
u.WebSite = txt_Website.Text;
u.Image = txt_Image.Text;
u.Address = txt_Address.Text;
u.ZipCode = txt_Zipcode.Text;
u.Intro = txt_Intro.Text;
u.Group = ddl_Group.SelectedValue.ToInt32();
u.Cent = txt_Cent.Text.ToInt32(0);
u.PostCount = txt_PostCount.Text.ToInt32(0);
u.QQ = txt_QQ.Text;
u.GTalk = txt_Gtalk.Text;
u.ICQ = txt_ICQ.Text;
//u.Weibo = txt_Weibo.Text;
u.StudentNo = txt_StudentNo.Text.TrimDbDangerousChar();
u.TeachNo = txt_TeachNo.Text.TrimDbDangerousChar();
u.Enable = chk_Enable.Checked;
if (u.ID <= 0)
{
u.LastLoginTime = DateTime.Now;
u.LastLoginIP = WS.GetIP();
ent.AddToUser(u);
}
ent.SaveChanges();
ent.Dispose();
Js.AlertAndChangUrl("保存成功!", "UserList.aspx");
}
示例2: UserRegister
/// <summary>
/// 用户注册
/// </summary>
/// <param name="user"></param>
/// <returns></returns>
public Result UserRegister(User user)
{
using (DataEntities ent = new DataEntities())
{
SysSetting setting = BasePage.SystemSetting;
Result r = new Result();
if (!setting.EnableReg)//不允许注册
{
r.Success = false;
r.Text = "系统关闭了用户注册功能!";
return r;
}
if ((from l in ent.User where l.UserName == user.UserName select l).Count() > 0)
{
r.Success = false;
r.Text = "这个账号已经存在,请重新选择!";
return r;
}
if (user.UserName.Length > setting.MaxUserName || user.UserName.Length < setting.MinUserName)
{
r.Success = false;
r.Text = string.Format("账号长度请设置在{0}和{1}之间", setting.MinUserName, setting.MaxUserName);
return r;
}
//密码经过MD5加密后无法验证长度
//系统保留词
string[] userNameFilter = setting.UserNameFilter.Trim().Split(',');
foreach (string k in userNameFilter)
{
if (user.UserName.Contains(k))
{
r.Success = false;
r.Text = "账号中存在系统保留词,请重新设置";
return r;
}
}
if (setting.EmailCheck)
{
if ((from l in ent.User where l.Email == user.Email select l).Count() > 0)
{
r.Success = false;
r.Text = "您设置的邮箱账号已经在系统中注册,系统不允许重复注册";
return r;
}
}
//用户默认分组
if (user.Group <= 0)
{
user.Group = setting.RegisterDefaultGroup;
}
UserGroup g = //UserGroupView.GetModelByID(user.Group.ToS());
(from l in ent.UserGroup where l.ID == user.Group select l).FirstOrDefault();
user.Enable = g.RegAutoAudit;
//注册时间间隔
if (setting.EnableRegTimeCheck)
{
user.RegIP = WS.GetIP();
var ipusers = //UserView.GetModelList(string.Format("RegIP='{0}'", user.RegIP)).OrderByDescending(p => p.RegTime);
(from l in ent.User where l.RegIP == user.RegIP orderby l.RegTime descending select l).ToList();
if (ipusers.Count() > 0)
{
User _lastUser = ipusers.First();
if (_lastUser != null && (DateTime.Now - _lastUser.RegTime.ToDateTime()).TotalMinutes < Convert.ToDouble(setting.RegTimeSpan.ToDecimal()))
{
r.Success = false;
r.Text = "您的注册动作过于频繁,请稍后重试!";
return r;
}
}
}
user.LoginCount = 0;
user.RegTime = DateTime.Now;
user.Cent = setting.RegCent;
user.LastLoginIP = WS.GetIP();
user.LastLoginTime = DateTime.Now;
ent.AddToUser(user);
ent.SaveChanges();
r.Success = true;
r.Text = "注册成功!";
return r;
}
}
示例3: SaveResume
/// <summary>
/// 上传简历
/// </summary>
/// <param name="file">简历文件</param>
/// <param name="id">用户id,不输入的话则自动创建新用户</param>
public static void SaveResume(HttpPostedFile file, int id = 0)
{
DataEntities ent = new DataEntities();
string extName = Path.GetExtension(file.FileName).ToLower();
string fileName = string.Format("/u/Resume/{0}{1}", DateTime.Now.ToString("yyyyMMddHHmmssfff"), extName);
BasePage.UpLoadFile(file, fileName);
Aspose.Words.Document doc = new Aspose.Words.Document(System.Web.HttpContext.Current.Server.MapPath(fileName));
string Context = doc.GetText();
User u = new User();
if (id <= 0)
{
u.UserName = @int.GetRandomNumber(1000, 999999).ToS();
u.UserPass = Voodoo.Security.Encrypt.Md5("1");
u.RegTime = DateTime.Now;
u.RegIP = WS.GetIP();
u.LoginCount = 0;
u.LastLoginTime = DateTime.Now;
u.LastLoginIP = WS.GetIP();
u.Cent = 0;
u.Enable = true;
u.Group = 1;
ent.AddToUser(u);
ent.SaveChanges();
}
else
{
u = (from l in ent.User where l.ID == id select l).First();
}
JobResumeInfo r = new JobResumeInfo();
var userResume = from l in ent.JobResumeInfo where l.UserID == u.ID select l;
if (userResume.Count() > 0)
{
r = userResume.First();
}
else
{
r.UserID = u.ID;
r.Title = string.Format("{0}的临时简历", u.UserName);
ent.AddToJobResumeInfo(r);
ent.SaveChanges();
}
#region 文件处理
var files = from l in ent.JobResumeFile where l.UserID == u.ID select l;
var resumeFile = new JobResumeFile();
if (files.Count() == 0)
{
resumeFile.UserID = u.ID;
resumeFile.ResumeID = r.ID;
resumeFile.FilePath = fileName;
resumeFile.FileName = Path.GetFileName(file.FileName);
ent.AddToJobResumeFile(resumeFile);
}
else
{
resumeFile = files.First();
resumeFile.FilePath = fileName;
resumeFile.FileName = file.FileName;
}
ent.SaveChanges();
Match match = new Regex("男|女").Match(Context);
string str_r = "";
if (match.Success)
{
str_r = match.Groups[0].Value;
if (str_r == "男")
{
r.IsMale = true;
}
else
{
r.IsMale = false;
}
}
match = new Regex("[a-zA-Z\\._]*[email protected]*?\\.(com|net|org|cn|edu|gov)").Match(Context);
if (match.Success)
{
if (id <= 0)
{
u.Email = match.Groups[0].Value;
}
r.Email = match.Groups[0].Value;
}
match = new Regex("姓名.{1,3}[^ ;,\\r]*").Match(Context);
if (match.Success)
//.........这里部分代码省略.........
示例4: QQLogin
/// <summary>
/// QQ用户登录
/// </summary>
protected void QQLogin()
{
DataEntities ent = new DataEntities();
if (Request.Params["code"] != null)
{
QOpenClient qzone = null;
QConnectSDK.Models.User currentUser = null;
var verifier = Request.Params["code"];
string state = Session["requeststate"].ToString();
qzone = new QOpenClient(verifier, state);
//
currentUser = qzone.GetCurrentUser();
if (null != currentUser)
{
string openid = qzone.OAuthToken.OpenId;
var SysUser = //UserView.Find(string.Format("UserName=N'{0}'", openid));
(from l in ent.User where l.UserName == openid select l).FirstOrDefault();
if (SysUser.ID <= 0)
{
SysUser.Cent = SystemSetting.RegCent;
SysUser.ChineseName = currentUser.Nickname;
SysUser.Enable = true;
SysUser.Group = 0;
SysUser.Image = currentUser.Figureurl;
SysUser.LastLoginIP = WS.GetIP();
SysUser.LastLoginTime = DateTime.UtcNow.AddHours(8);
SysUser.LoginCount = 1;
SysUser.PostCount = 0;
SysUser.RegIP = WS.GetIP();
SysUser.RegTime = DateTime.UtcNow.AddHours(8);
SysUser.StudentNo = "";
SysUser.TeachNo = "";
SysUser.Tel = "";
SysUser.Twitter = "";
SysUser.UserName = openid;
SysUser.UserPass = "";
SysUser.WebSite = "";
//SysUser.Weibo = "";
try
{
var i = qzone.GetWeiboUserInfo("", qzone.OAuthToken.OpenId);
SysUser.Address = i.Data.Location;
SysUser.Email = i.Data.Email;
SysUser.Intro = i.Data.Introduction;
SysUser.ZipCode = i.Data.City_code.ToS();
}
catch
{
}
//UserView.Insert(SysUser);
ent.AddToUser(SysUser);
}
else
{
SysUser.LoginCount++;
SysUser.LastLoginIP = WS.GetIP();
SysUser.LastLoginTime = DateTime.UtcNow.AddHours(8);
}
ent.SaveChanges();
//System.Web.HttpContext.Current.Session["sys_user"] = SysUser.ID;
System.Web.HttpCookie cookie = new System.Web.HttpCookie("User");
cookie.Expires = DateTime.Now.AddDays(7);
cookie.Values.Add("uid", SysUser.ID.ToString());
cookie.Values.Add("k", Voodoo.Security.Encrypt.Md5(string.Format("{0}{1}{2}",
SysUser.ID,
SysUser.UserName,
SysUser.UserPass,
BasePage.SystemSetting.SiteName
)));
Voodoo.Cookies.Cookies.SetCookie(cookie);
Response.Redirect("/");
}
Session["QzoneOauth"] = qzone;
}
ent.Dispose();
}