public ErrorInfo FileDel(ref ErrorInfo err, ApiRequesEntityBean <ErrorInfo> inEnt) { GlobalUser gu = Global.GetUser(inEnt.authToken); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } ErrorInfo reEnt = new ErrorInfo(); using (DBEntities db = new DBEntities()) { var file = db.fa_files.SingleOrDefault(x => x.ID == inEnt.id); if (file == null) { err.IsError = true; err.Message = "文件对象不存在"; return(null); } db.fa_files.Remove(file); if (Fun.DBEntitiesCommit(db, ref err)) { var allPath = Fun.UrlToAllPath(file.URL); if (System.IO.File.Exists(allPath)) { System.IO.File.Delete(allPath); } reEnt.IsError = false; } } return(reEnt); }
/* 2017-5-6 22:57:48 */ public FaUserInfo UserInfoSingle(ref ErrorInfo err, ApiRequesEntityBean <FaUserInfo> inEnt) { GlobalUser gu = Global.GetUser(inEnt.authToken); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } using (DBEntities db = new DBEntities()) { ApiRequesEntityBean <TUser> userEnt = Fun.ClassToCopy <ApiRequesEntityBean <FaUserInfo>, ApiRequesEntityBean <TUser> >(inEnt); var user = api.UserApi.UserSingle(db, inEnt.authToken, ref err, userEnt); if (user == null) { return(null); } var userInfo = db.fa_user_info.FirstOrDefault(x => x.ID == user.ID); if (userInfo == null) { return(Mapper.Map <FaUserInfo>(user)); } var reEnt = Mapper.Map <FaUserInfo>(user); reEnt = Mapper.Map(userInfo, reEnt); return(reEnt); } }
public ErrorInfo GetChineseCalendar(ref ErrorInfo err, ApiRequesEntityBean <ErrorInfo> inEnt) { DateTime dateTime = new DateTime(); if (!DateTime.TryParse(inEnt.data.ToString(), out dateTime)) { err.IsError = true; err.Message = "参数有误"; return(err); } var tempPar = inEnt.para.FirstOrDefault(x => x.K == "inType"); try { if (tempPar == null || tempPar.V == "china") { ChineseCalendar cc = new ChineseCalendar(dateTime.Year, dateTime.Month, dateTime.Day, false); err.Message = cc.Date.ToString("yyyy-MM-dd"); } else { ChineseCalendar cc = new ChineseCalendar(dateTime); err.Message = cc.ChineseDateString; } } catch { err.Message = dateTime.ToString("yyyy-MM-dd"); } return(err); }
public FaUserInfoRelative UserInfoRelative(ref ErrorInfo err, ApiRequesEntityBean <FaUserInfoRelative> inEnt) { GlobalUser gu = Global.GetUser(inEnt.authToken); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } FaUserInfoRelative reEnt = new FaUserInfoRelative(); using (DBEntities db = new DBEntities()) { var userInfo = db.fa_user_info.SingleOrDefault(x => x.ID == inEnt.id); if (userInfo == null) { err.IsError = true; err.Message = "用户ID有误"; return(null); } var tmpXY = AddSonItem(reEnt.ItemList, userInfo, 1, 6, new XYZ { X = 0, Y = 0, Z = 0 }); var nowInfo = InfoToItem(userInfo, (tmpXY[0] + tmpXY[1]) / 2, 0); reEnt.ItemList.Add(nowInfo); AddFatherItem(reEnt.ItemList, userInfo, 1, 2, new XYZ { X = nowInfo.x, Y = nowInfo.y, Z = userInfo.fa_user_info1.Count() }, tmpXY[0], tmpXY[1]); var minX = reEnt.ItemList.Min(x => x.x); var minY = reEnt.ItemList.Max(x => x.y); minY = -minY; if (minX > 0) { minX = 0; } if (minY > 0) { minY = 0; } foreach (var item in reEnt.ItemList) { item.y = -item.y; item.y = item.y - minY; item.x = item.x - minX; } reEnt.RelativeList = reEnt.ItemList.Where(x => x.FatherId != null).Select(x => new KV { K = x.Id.ToString(), V = x.FatherId.ToString() }).ToList(); return(reEnt); } }
public ErrorInfo ResetPassword(ref ErrorInfo err, ApiRequesEntityBean <ErrorInfo> inEnt) { ErrorInfo reEnt = new ErrorInfo(); string VerifyCode = ""; string LoginName = ""; string NewPwd = ""; var tmp = inEnt.para.SingleOrDefault(x => x.K == "VerifyCode"); if (tmp != null) { VerifyCode = tmp.V; } tmp = inEnt.para.SingleOrDefault(x => x.K == "LoginName"); if (tmp != null) { LoginName = tmp.V; } tmp = inEnt.para.SingleOrDefault(x => x.K == "NewPwd"); if (tmp != null) { NewPwd = tmp.V; } if (string.IsNullOrEmpty(VerifyCode) || string.IsNullOrEmpty(LoginName) || string.IsNullOrEmpty(NewPwd)) { err.IsError = true; err.Message = "参数不正确"; return(err); } using (DBEntities db = new DBEntities()) { var login = db.fa_login.SingleOrDefault(x => x.LOGIN_NAME == LoginName); if (login == null) { err.IsError = true; err.Message = "登录名不存在"; return(err); } if (login.VERIFY_CODE != VerifyCode) { err.IsError = true; err.Message = "验证码不正确"; return(err); } //检测密码复杂度 if (!Fun.CheckPassword(ref err, NewPwd)) { err.IsError = true; err.Message = string.Format("密码复杂度不够:{0}", err.Message); return(err); } login.PASSWORD = NewPwd.Md5(); Fun.DBEntitiesCommit(db, ref err); return(reEnt); } }
public ErrorInfo UserInfoDelete(ref ErrorInfo err, ApiRequesEntityBean <ErrorInfo> inEnt) { GlobalUser gu = Global.GetUser(inEnt.authToken); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } if (inEnt.id == 0) { err.IsError = true; err.Message = "参数有误"; return(null); } //调用用户保存 using (DBEntities db = new DBEntities()) { var userInfo = db.fa_user_info.SingleOrDefault(x => x.ID == inEnt.id); if (userInfo == null) { err.IsError = true; err.Message = "用户不存在"; return(null); } if (userInfo.fa_user_info1.Count() > 0) { err.IsError = true; err.Message = "该用户已有子女,不能删除"; return(null); } if (userInfo.fa_user != null) { userInfo.fa_user.fa_district1.Clear(); userInfo.fa_user.fa_module.Clear(); userInfo.fa_user.fa_role.Clear(); userInfo.fa_user.fa_user_info1.Clear(); db.fa_user.Remove(userInfo.fa_user); } userInfo.fa_user1.Clear(); foreach (var t in userInfo.fa_user_event.ToList()) { db.fa_user_event.Remove(t); } db.fa_user_info.Remove(userInfo); Fun.DBEntitiesCommit(db, ref err); return(err); } }
public static dynamic Func(MyAction1 myAction, ref ErrorInfo err, ApiRequesEntityBean <outT> inEnt) { try { return(myAction(ref err, inEnt)); } catch (Exception e) { err.IsError = true; err.Message = e.Message; return(err); } }
public ErrorInfo CheckToken(ref ErrorInfo err, ApiRequesEntityBean <ErrorInfo> inEnt) { GlobalUser gu = Global.GetUser(inEnt.authToken); if (gu == null) { err.IsError = true; err.Message = "不存在"; return(null); } else { return(new ErrorInfo()); } }
public ErrorInfo SendCode(ref ErrorInfo err, ApiRequesEntityBean <ErrorInfo> inEnt) { string phone = ""; var tmpPar = inEnt.para.FirstOrDefault(x => x.K == "phone"); if (tmpPar != null) { phone = tmpPar.V; } if (string.IsNullOrEmpty(phone)) { err.IsError = true; err.Message = "电话号码不能为空"; return(err); } return(SendCode(inEnt.authToken, ref err, phone)); }
public FaUserInfo UserInfoFatherSingle(ref ErrorInfo err, ApiRequesEntityBean <FaUserInfo> inEnt) { GlobalUser gu = Global.GetUser(inEnt.authToken); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } using (DBEntities db = new DBEntities()) { var userId = inEnt.id; if (inEnt.id == 0) { userId = gu.UserId; } var ent = db.fa_user_info.SingleOrDefault(x => x.ID == userId); if (ent == null) { err.IsError = true; err.Message = "用户不存在"; return(null); } if (ent.FATHER_ID == null) { return(new FaUserInfo { BIRTHDAY_TIME = DateTime.Now, DIED_TIME = DateTime.Now, SEX = "男", NAME = ent.fa_user.NAME.Substring(0, 1), IS_LIVE = 1 }); } inEnt.id = ent.FATHER_ID.Value; return(UserInfoSingle(ref err, inEnt)); } }
public TUser UserSingle(object dbObject, string loginKey, ref ErrorInfo err, ApiRequesEntityBean <TUser> inEnt) { GlobalUser gu = Global.GetUser(loginKey); if (gu == null) { err.IsError = true; err.Message = "登录超时"; return(null); } DBEntities db = dbObject as DBEntities; var user = db.fa_user.FirstOrDefault(x => x.ID == inEnt.id); if (user == null) { user = db.fa_user.FirstOrDefault(x => x.ID == gu.UserId); } if (user == null) { err.IsError = true; err.Message = "用户ID不存在"; return(null); } var reEnt = Mapper.Map <TUser>(user); var login = db.fa_login.FirstOrDefault(x => x.LOGIN_NAME == user.LOGIN_NAME); if (login != null) { reEnt.Login = Mapper.Map <LOGIN>(login); } if (user.ICON_FILES_ID != null) { var file = db.fa_files.SingleOrDefault(x => x.ID == user.ICON_FILES_ID); if (file != null) { reEnt.ImgUrl = file.URL; } } return(reEnt); }
public async Task <dynamic> UserInfoFatherSingle(ApiRequesEntityBean <FaUserInfo> inEnt) { if (Request.Method.Method == "OPTIONS") { return(null); } ErrorInfo err = new ErrorInfo(); Fun <ErrorInfo> .Valid(inEnt, ModelState, ref err); if (err.IsError) { return(err); } dynamic reEnt = await Task.Run(() => Fun <FaUserInfo> .Func(api.UserInfoApi.UserInfoFatherSingle, ref err, inEnt)); if (err.IsError) { return(err); } return(reEnt); }
public async Task <dynamic> GetChineseCalendar(ApiRequesEntityBean <ErrorInfo> inEnt) { if (Request.Method.Method == "OPTIONS") { return(null); } ErrorInfo err = new ErrorInfo(); Fun <ErrorInfo> .Valid(inEnt, ModelState, ref err); if (err.IsError) { return(err); } dynamic reEnt = await Task.Run(() => Fun <ErrorInfo> .Func(api.PublicApi.GetChineseCalendar, ref err, inEnt)); if (err.IsError) { return(err); } return(reEnt); }
public ApiPagingDataBean <FaUserInfo> UserInfoSingleByName(ref ErrorInfo err, ApiRequesEntityBean <FaUserInfo> inEnt) { using (DBEntities db = new DBEntities()) { var namePar = inEnt.para.FirstOrDefault(x => x.K == "name"); if (namePar == null) { err.IsError = true; err.Message = "名称不能为空"; return(null); } var userInfo = db.fa_user_info.Where(x => x.fa_user.NAME == namePar.V).ToList(); var data = Mapper.Map <IList <FaUserInfo> >(userInfo); ApiPagingDataBean <FaUserInfo> reEnt = new ApiPagingDataBean <FaUserInfo>(); reEnt.data = data; reEnt.currentPage = 1; reEnt.pageSize = 10; reEnt.totalCount = data.Count(); reEnt.totalPage = 1; return(reEnt); } }
public ErrorInfo LoginOut(ref ErrorInfo err, ApiRequesEntityBean <ErrorInfo> inEnt) { Global.Del(inEnt.authToken, ref err); return(new ErrorInfo()); }
public FILES FileUp(ref ErrorInfo err, ApiRequesEntityBean <FILES> inEnt) { throw new NotImplementedException(); }