/// <summary> /// 判断登陆用户信息(如无则添加) /// </summary> /// <param name="md"></param> /// <returns></returns> public mjuserinfo AddUser(mjuserinfo md, GameSession session) { int returnid = 0; mjuserinfoDAL dal = new mjuserinfoDAL(); mjuserinfo model = dal.GetModel(md.openid); login_logDAL Ldal = new login_logDAL(); login_log Lmodel = new login_log(); if (model == null) { try { returnid = dal.GetMaxID() + 1; md.id = returnid; md.addtime = DateTime.Now; string fileName = string.Empty; string imgurl = PictureUtility.SavePicture(md.headimg, out fileName); //将图片保存至本地返回详细路径和文件名 if (!string.IsNullOrEmpty(imgurl)) //验证是否保存成功 { md.headimg = PutObjectSample.PutObjectFromFile(imgurl, fileName); } dal.Add(md); Lmodel.id = Ldal.GetMaxID() + 1; Lmodel.login_state = 1; Lmodel.login_time = DateTime.Now; Lmodel.openid = md.openid; Ldal.Add(Lmodel); } catch (Exception ex) { session.Logger.Error(ex); } return(md); } else { try { Lmodel.id = Ldal.GetMaxID() + 1; Lmodel.login_state = 1; Lmodel.login_time = DateTime.Now; Lmodel.openid = md.openid; Ldal.Add(Lmodel); } catch (Exception) { throw; } return(model); } }